Browse Source

添加NVR摄像头,解决NVR页面部分自测问题

release_0.0.2
wenlele 3 years ago
parent
commit
b31d5a8c1d
  1. 29
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/camera.js
  2. 39
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/cameraModal.jsx
  3. 350
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrCamera.jsx
  4. 8
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrModal.jsx
  5. 7
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/sideSheet.jsx
  6. 2
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx
  7. 8
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx
  8. 10
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx
  9. 5
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js

29
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/camera.js

@ -29,14 +29,13 @@ export function putForbidden(data, forbidden) {
}); });
} }
export function delCamera(query) { export function delCamera(orgId) {
return (dispatch) => return (dispatch) =>
basicAction({ basicAction({
type: "del", type: "del",
dispatch: dispatch, dispatch: dispatch,
actionType: "DEL_CAMERA", actionType: "DEL_CAMERA",
query, url: `${ApiTable.delCamera.replace("{cameraId}", orgId)}`,
url: `${ApiTable.delCamera}`,
msg: { option: "删除摄像头" }, //删除摄像头 msg: { option: "删除摄像头" }, //删除摄像头
reducer: {}, reducer: {},
}); });
@ -102,3 +101,27 @@ export function postCameraIpc(data) {
reducer: { name: "" }, reducer: { name: "" },
}); });
} }
export function getVideoStreaming(query) {
return (dispatch) =>
basicAction({
type: "get",
dispatch: dispatch,
query,
actionType: "GET_VIDEO_STREAMING",
url: `${ApiTable.getVideoStreaming}`,
msg: { option: "" }, //获取NVR视频流
reducer: { name: "videoStreaming" },
});
}
export function postCameraNvr(data) {
return (dispatch) =>
basicAction({
type: "post",
dispatch: dispatch,
data,
actionType: "POST_CAMERA_NVR",
url: `${ApiTable.postCameraNvr}`,
msg: { option: "" }, //记录NVR摄像头
});
}

39
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/cameraModal.jsx

@ -24,6 +24,7 @@ function cameraModal(props) {
const fluoriteRef = useRef(); const fluoriteRef = useRef();
const ipcRef = useRef(); const ipcRef = useRef();
const cascadeRef = useRef(); const cascadeRef = useRef();
const nvrRef = useRef();
const [isloading, setloading] = useState(false); //loading const [isloading, setloading] = useState(false); //loading
const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip
const [okText, setokText] = useState("确定"); //oktext const [okText, setokText] = useState("确定"); //oktext
@ -91,8 +92,20 @@ function cameraModal(props) {
}); });
}); });
} else if (clickNum == 2) { } else if (clickNum == 2) {
console.log("22222222222222"); //NVR
close(); let data = nvrRef.current.NVRcameraList.map((v) => {
return { streamid: v.streamid, name: v.name, cloudControl: v.support };
});
dispatch(
equipmentWarehouse.postCameraNvr({
serialNo: nvrRef.current.equipmentNum,
data: data,
})
).then((res) => {
if (res.success) {
onReset();
}
});
} else if (clickNum == 3) { } else if (clickNum == 3) {
//IPC //IPC
ipcRef.current.ipcCameraForm().then((values) => { ipcRef.current.ipcCameraForm().then((values) => {
@ -145,9 +158,25 @@ function cameraModal(props) {
close(); close();
} else if (clickNum == 4) { } else if (clickNum == 4) {
close(); close();
} } else {
nvrRef.current.resetFluoriteCamera();
close(); close();
} }
}
//
function reset() {
if (clickNum == 1) {
fluoriteRef.current.resetFluoriteCamera();
fluoriteRef.current.toempty();
} else if (clickNum == 3) {
ipcRef.current.resetIpcCamera();
ipcRef.current.toempty();
} else if (clickNum == 4) {
} else {
nvrRef.current.resetFluoriteCamera();
}
}
function toTest() { function toTest() {
if (clickNum == 1) { if (clickNum == 1) {
fluoriteRef.current fluoriteRef.current
@ -386,7 +415,7 @@ function cameraModal(props) {
cursor: "pointer", cursor: "pointer",
marginRight: 16, marginRight: 16,
}} }}
onClick={onReset} onClick={reset}
> >
<img <img
src="/assets/images/background/Reset.png" src="/assets/images/background/Reset.png"
@ -430,7 +459,7 @@ function cameraModal(props) {
cameraData={cameraData} cameraData={cameraData}
/> />
) : clickNum == 2 ? ( ) : clickNum == 2 ? (
<NvrCamera /> <NvrCamera nvrRef={nvrRef} />
) : clickNum == 3 ? ( ) : clickNum == 3 ? (
<IpcCamera <IpcCamera
aRef={ipcRef} aRef={ipcRef}

350
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrCamera.jsx

@ -1,157 +1,269 @@
import React, { useState ,useRef,useEffect,useImperativeHandle} from 'react' import React, { useState, useRef, useEffect, useImperativeHandle } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Form,Row,Col,Button,CheckboxGroup, Checkbox,Radio,Input } from '@douyinfe/semi-ui'; import {
import { IconEdit,IconPlayCircle } from '@douyinfe/semi-icons'; Form,
Row,
Col,
Button,
CheckboxGroup,
Checkbox,
Radio,
Input,
} from "@douyinfe/semi-ui";
import { IconEdit, IconPlayCircle } from "@douyinfe/semi-icons";
import "./cameraModal.less"; import "./cameraModal.less";
function nvrCamera({cRef}){ import PerfectScrollbar from "perfect-scrollbar";
let equipmentScrollbar;
function nvrCamera({ dispatch, actions, nvrRef }) {
const { equipmentWarehouse } = actions;
const form = useRef(); const form = useRef();
const [nvrCheckList, setNvrCheckList] = useState([]);//nvr const [nvrCheckList, setNvrCheckList] = useState([]); //nvr
const [NVRcameraList,setNVRcameraList]=useState([])//nvr const [NVRcameraList, setNVRcameraList] = useState([]); //nvr
const [isAllChoose,setIsAllChoose]=useState(false)// const [isAllChoose, setIsAllChoose] = useState(false); //
const [equipmentNum,setEquipmentNum]=useState('')//nvr const [equipmentNum, setEquipmentNum] = useState(""); //nvr
function NvrChangeName(e,index){//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) useEffect(() => {
NvrchangeList[index].change=true NVRcameraList
setNVRcameraList(NvrchangeList) ? (equipmentScrollbar = new PerfectScrollbar("#video_streaming", {
e.stopPropagation() suppressScrollX: true,
}))
: "";
}, [NVRcameraList]);
useEffect(() => {
const videoStreaming = document.getElementById("video_streaming");
if (videoStreaming && equipmentScrollbar) {
equipmentScrollbar.update();
} }
function nvronBlur(index){//nvr });
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) function NvrChangeName(e, index) {
NvrchangeList[index].change=false //nvr
setNVRcameraList(NvrchangeList) let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].change = true;
setNVRcameraList(NvrchangeList);
e.stopPropagation();
} }
function inputchange(e,index){//nvr function nvronBlur(index) {
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) //nvr
NvrchangeList[index].name=e let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
setNVRcameraList(NvrchangeList) NvrchangeList[index].change = false;
setNVRcameraList(NvrchangeList);
} }
function toggle(e,index){//nvr function inputchange(e, index) {
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) //nvr
NvrchangeList[index].support=e.target.checked let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
setNVRcameraList(NvrchangeList) console.log(e);
e.stopPropagation() NvrchangeList[index].name = e;
setNVRcameraList(NvrchangeList);
} }
function getVideoList(){ function toggle(e, index) {
form.current.validate().then(values=>{// //nvr
let chooseList=[] let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
let nvrCameraList=[{ NvrchangeList[index].support = e.target.checked;
id:10, setNVRcameraList(NvrchangeList);
name:'南昌县1', e.stopPropagation();
number:'111111111111111111',
support:false,
change:false,
},{
id:20,
name:'南昌县2',
number:'222222222222222222',
support:false,
change:false,
},{
id:30,
name:'南昌县3',
number:'333333333333333333',
support:false,
change:false,
},{
id:40,
name:'南昌县4',
number:'444444444444444444',
support:false,
change:false,
}]
setNVRcameraList(nvrCameraList)
for (let index = 0; index < nvrCameraList.length; index++) {
chooseList.push(nvrCameraList[index].id)
} }
setNvrCheckList(chooseList) function getVideoList() {
setIsAllChoose(true) form.current
}) .validate()
.catch(errors=>{// .then((values) => {
console.log('errors',errors); //
}) let chooseList = [];
let valuess = JSON.parse(JSON.stringify(values));
valuess.streamId = values.serialNo;
delete valuess.serialNo;
dispatch(equipmentWarehouse.getVideoStreaming(valuess)).then((res) => {
let data = res.payload.data.map((item) => {
item.change = false;
item.support = false;
return item;
});
console.log(data);
setNVRcameraList(data);
for (let index = 0; index < data.length; index++) {
chooseList.push(data[index].id);
} }
function allChoose(e){/// console.log(chooseList);
let chooseList=[] setNvrCheckList(chooseList);
if(NVRcameraList.length==nvrCheckList.length){ setIsAllChoose(true);
setNvrCheckList([]) });
setIsAllChoose(false) })
.catch((errors) => {
//
console.log("errors", errors);
});
} }
else{ function allChoose(e) {
///
let chooseList = [];
if (NVRcameraList.length == nvrCheckList.length) {
setNvrCheckList([]);
setIsAllChoose(false);
} else {
for (let index = 0; index < NVRcameraList.length; index++) { for (let index = 0; index < NVRcameraList.length; index++) {
chooseList.push(NVRcameraList[index].id) chooseList.push(NVRcameraList[index].id);
} }
setNvrCheckList(chooseList) setNvrCheckList(chooseList);
setIsAllChoose(true) setIsAllChoose(true);
} }
} }
function playVideo(e) {//nvr function playVideo(e) {
console.log('22222222222222222'); //nvr
e.stopPropagation() console.log("22222222222222222");
e.stopPropagation();
} }
// useImperativeHandle(cRef,() => ({// useImperativeHandle(nvrRef, () => ({
// //aa //
// getDate : form.current.validate, //aa
// // resetFluoriteCamera : form.current.reset resetFluoriteCamera: form.current.reset,
// })) equipmentNum: equipmentNum,
NVRcameraList: NVRcameraList.filter((v) =>
nvrCheckList.some((e) => e == v.id)
),
}));
return ( return (
<> <>
<Form <Form
allowEmpty allowEmpty
labelPosition='left' labelPosition="left"
labelAlign='left' labelAlign="left"
labelWidth= '115px' labelWidth="115px"
onValueChange={values=>{setEquipmentNum(values.equipmentNum)}} onValueChange={(values) => {
getFormApi={formApi => form.current = formApi}> setEquipmentNum(values.serialNo);
<div style={{display:'flex'}}> }}
<Form.Input field='equipmentNum' maxLength='39' label='设备编号:' initValue={''} placeholder='请输入设备编号' style={{ width:307 }} getFormApi={(formApi) => (form.current = formApi)}
>
<div style={{ display: "flex" }}>
<Form.Input
field="serialNo"
maxLength="39"
label="设备编号:"
initValue={""}
placeholder="请输入设备编号"
style={{ width: 307 }}
rules={[ rules={[
{ required: true, message: '请输入设备编号' }, { required: true, message: "请输入设备编号" },
{ pattern: '^[A-Za-z0-9]+$', message: '只能输入数字或者字母' } { pattern: "^[A-Za-z0-9]+$", message: "只能输入数字或者字母" },
]}/> ]}
<Button disabled={!equipmentNum.length>0} theme='solid' type='primary' onClick={()=>{getVideoList()}} style={{ marginLeft: 8,marginTop:12 }}>视频流获取</Button> />
{NVRcameraList.length>0?<div style={{display: 'flex',alignItems: 'center',marginLeft: 211}}> <Button
disabled={!equipmentNum.length > 0}
theme="solid"
type="primary"
onClick={() => {
getVideoList();
}}
style={{ marginLeft: 8, marginTop: 12 }}
>
视频流获取
</Button>
{NVRcameraList.length > 0 ? (
<div
style={{ display: "flex", alignItems: "center", marginLeft: 211 }}
>
<Radio <Radio
checked={isAllChoose} checked={isAllChoose}
mode="advanced" mode="advanced"
onChange={e=>allChoose(e)} onChange={(e) => allChoose(e)}
aria-label="全选"> aria-label="全选"
>
全选 全选
</Radio> </Radio>
</div>:''} </div>
) : (
""
)}
</div> </div>
<Row> <Row>
<CheckboxGroup type='pureCard' direction='vertical' aria-label="视频流获取" <CheckboxGroup
type="pureCard"
direction="vertical"
aria-label="视频流获取"
value={nvrCheckList} value={nvrCheckList}
onChange={(nvrCheck) => { onChange={(nvrCheck) => {
setNvrCheckList(nvrCheck); setNvrCheckList(nvrCheck);
// console.log('11111111111',nvrCheck); if (NVRcameraList.length == nvrCheck.length) {
if(NVRcameraList.length==nvrCheck.length){ setIsAllChoose(true);
setIsAllChoose(true) } else {
setIsAllChoose(false);
} }
else{ }}
setIsAllChoose(false) >
} <div id="video_streaming" style={{ maxHeight: 300,position: "relative"}}>
}}> {NVRcameraList.length > 0
{NVRcameraList.length>0?NVRcameraList.map((item,index)=>( ? NVRcameraList.map((item, index) => (
<Col key={index} span={12} style={{display:'flex',justifyContent:'center',marginTop:12}}> <Col
<Checkbox value={item.id} key={index}
span={12}
style={{
display: "flex",
justifyContent: "center",
marginTop: 12,
}}
>
<Checkbox
value={item.id}
extra={ extra={
<div> <div>
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',height:30}}> <div
<div>通道名称{item.change?<Input autofocus style={{width:100}} value={item.name} onChange={e=>inputchange(e,index)} onBlur={()=>nvronBlur(index)}></Input>:item.name}</div> style={{
<div style={{display:'flex',alignItems:'center'}}> display: "flex",
alignItems: "center",
justifyContent: "space-between",
height: 30,
}}
>
<div>
通道名称
{item.change ? (
<Input
autofocus
style={{ width: 100 }}
value={item.name}
onChange={(e) => inputchange(e, index)}
onBlur={() => nvronBlur(index)}
></Input>
) : (
item.name
)}
</div>
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<IconEdit <IconEdit
style={{fontSize:16,marginLeft:18,cursor: "pointer",color:'#1859C1'}} style={{
onClick={e=>NvrChangeName(e,index)}/> fontSize: 16,
marginLeft: 18,
cursor: "pointer",
color: "#1859C1",
}}
onClick={(e) => NvrChangeName(e, index)}
/>
</div>
</div> </div>
<div style={{ marginTop: 8, width: 246 }}>
设备编号{item.parent}
</div> </div>
<div style={{marginTop:8,width:246}}>设备编号{item.number}</div> <div
<div style={{marginTop:12,display:'flex',justifyContent:'space-between',alignItems:'center'}}> style={{
<IconPlayCircle size='extra-large' style={{color:'#1859C1',}} onClick={e=>playVideo(e)}/> marginTop: 12,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<IconPlayCircle
size="extra-large"
style={{ color: "#1859C1" }}
onClick={(e) => playVideo(e)}
/>
<Radio <Radio
checked={item.support} checked={item.support}
mode="advanced" mode="advanced"
onChange={e=>toggle(e,index)} onChange={(e) => toggle(e, index)}
aria-label="单选" aria-label="单选"
> >
云台支持 云台支持
@ -159,10 +271,12 @@ function nvrCamera({cRef}){
</div> </div>
</div> </div>
} }
style={{width:280,border:'1px solid #F9F9F9',}}> style={{ width: 280, border: "1px solid #F9F9F9" }}
</Checkbox> ></Checkbox>
</Col> </Col>
)):''} ))
: ""}
</div>
</CheckboxGroup> </CheckboxGroup>
</Row> </Row>
</Form> </Form>

8
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrModal.jsx

@ -57,9 +57,9 @@ function nvrModal(props){
setokText('确认'); setokText('确认');
setcancelText('上一步'); setcancelText('上一步');
setloading(false); setloading(false);
}, 2000); }, 1000);
}, 2000) }, 1000)
}, 2000); }, 1000);
}) })
.catch(errors=>{// .catch(errors=>{//
console.log('errors',errors); console.log('errors',errors);
@ -120,7 +120,7 @@ function nvrModal(props){
]}/> ]}/>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Form.Input maxLength='15' field='regionCode' label='行政区区码:' initValue={nvrData.regionCode||''} placeholder='请输入行政区区码' style={{ width:149 }}/> <Form.InputNumber formatter={value => `${value}`.replace(/\D/g, '')} hideButtons={true} maxLength='15' field='regionCode' label='行政区区码:' initValue={nvrData.regionCode||''} placeholder='请输入行政区区码' style={{ width:149 }}/>
</Col> </Col>
<Col span={24}> <Col span={24}>
<Form.Input maxLength='36' field='name' label='设备名称:' initValue={nvrData.name||''} placeholder='请输入设备名称、常用项目或位置定义' style={{ width:421 }} <Form.Input maxLength='36' field='name' label='设备名称:' initValue={nvrData.name||''} placeholder='请输入设备名称、常用项目或位置定义' style={{ width:421 }}

7
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/sideSheet.jsx

@ -159,7 +159,7 @@ function SideSheets(props) {
} }
const domEquipment = document.getElementById("equipment_information"); const domEquipment = document.getElementById("equipment_information");
if (domEquipment && equipmentScrollbar) { if (domEquipment && equipmentScrollbar) {
projectScrollbar.update(); equipmentScrollbar.update();
} }
}); });
return ( return (
@ -206,8 +206,7 @@ function SideSheets(props) {
<div <div
id="project_information" id="project_information"
style={{ style={{
height: document.body.clientHeight - 182, height: document.body.clientHeight - 182,position: "relative"
// position: "relative",
}} }}
> >
{nvrDetails {nvrDetails
@ -236,7 +235,7 @@ function SideSheets(props) {
<div <div
id="equipment_information" id="equipment_information"
style={{ style={{
height: document.body.clientHeight - 126, height: document.body.clientHeight - 126,position: "relative"
}} }}
> >
{nvrDetails {nvrDetails

2
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx

@ -1,5 +1,7 @@
import React from "react";
import { Table } from "@douyinfe/semi-ui"; import { Table } from "@douyinfe/semi-ui";
export function skeletonScreen(line, columns) { export function skeletonScreen(line, columns) {
const data = () => { const data = () => {
let str = []; let str = [];

8
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx

@ -169,7 +169,7 @@ const CameraHeader = (props) => {
position="topRight" position="topRight"
onConfirm={() => { onConfirm={() => {
dispatch( dispatch(
equipmentWarehouse.delCamera({ cameraId: row.id }) equipmentWarehouse.delCamera(row.id )
).then(() => { ).then(() => {
equipmentGetCamera(); equipmentGetCamera();
}); });
@ -215,8 +215,12 @@ const CameraHeader = (props) => {
}, },
{ {
title: "云台支持", title: "云台支持",
dataIndex: "port", dataIndex: "cloudControl",
key: "support", key: "support",
render: (text, r, index) => {
return r.cloudControl ? "支持" : "不支持";
},
}, },
{ {
title: "内存卡信息", title: "内存卡信息",

10
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx

@ -154,6 +154,7 @@ const NvrHeader = (props) => {
dataIndex: "venderId", dataIndex: "venderId",
key: "manufactor", key: "manufactor",
render: (_, r, index) => { render: (_, r, index) => {
console.log(r);
let manufactorName = data.find((item) => item.id == r.venderId); let manufactorName = data.find((item) => item.id == r.venderId);
return manufactorName ? manufactorName.name : ""; return manufactorName ? manufactorName.name : "";
}, },
@ -162,6 +163,10 @@ const NvrHeader = (props) => {
title: "添加账号", title: "添加账号",
dataIndex: "createUserId", dataIndex: "createUserId",
key: "accountNumber", key: "accountNumber",
render: (_, r, index) => {
let createUserName = r.createUser;
return createUserName ? createUserName.name : "";
},
}, },
{ {
title: "通道数", title: "通道数",
@ -528,7 +533,10 @@ const NvrHeader = (props) => {
</a> </a>
</div> </div>
</div> </div>
<Skeleton loading={loading} placeholder={skeletonScreen(8, setupp.length)}> <Skeleton
loading={loading}
placeholder={skeletonScreen(8, setupp.length)}
>
<Table <Table
columns={setupp.filter((s) => s)} columns={setupp.filter((s) => s)}
dataSource={equipmentWarehouseNvr.data} dataSource={equipmentWarehouseNvr.data}

5
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -18,12 +18,15 @@ export const ApiTable = {
getCamera: "camera/project", // 获取摄像头列表 getCamera: "camera/project", // 获取摄像头列表
putForbidden: "camera/banned", //禁用摄像头 putForbidden: "camera/banned", //禁用摄像头
delCamera:"camera", //删除摄像头 delCamera:"camera/{cameraId}", //删除摄像头
getCameraDetails: "camera/{cameraId}/detail", //获取摄像头详情 getCameraDetails: "camera/{cameraId}/detail", //获取摄像头详情
getCameraKind: "camera/kind", //获取摄像头种类列表 getCameraKind: "camera/kind", //获取摄像头种类列表
getAbility: "/camera/ability", //获取摄像头能力列表 getAbility: "/camera/ability", //获取摄像头能力列表
postCameraYingshi: "camera/create/yingshi", //创建萤石摄像头 postCameraYingshi: "camera/create/yingshi", //创建萤石摄像头
postCameraIpc: "camera/create/ipc", //创建IPC摄像头 postCameraIpc: "camera/create/ipc", //创建IPC摄像头
getVideoStreaming:"camera/nvr_stream", //获取NVR视频流
postCameraNvr:"camera/create/nvr", //记录NVR摄像头
}; };
export const RouteTable = { export const RouteTable = {

Loading…
Cancel
Save