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) =>
basicAction({
type: "del",
dispatch: dispatch,
actionType: "DEL_CAMERA",
query,
url: `${ApiTable.delCamera}`,
url: `${ApiTable.delCamera.replace("{cameraId}", orgId)}`,
msg: { option: "删除摄像头" }, //删除摄像头
reducer: {},
});
@ -102,3 +101,27 @@ export function postCameraIpc(data) {
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 ipcRef = useRef();
const cascadeRef = useRef();
const nvrRef = useRef();
const [isloading, setloading] = useState(false); //loading
const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip
const [okText, setokText] = useState("确定"); //oktext
@ -91,8 +92,20 @@ function cameraModal(props) {
});
});
} else if (clickNum == 2) {
console.log("22222222222222");
close();
//NVR
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) {
//IPC
ipcRef.current.ipcCameraForm().then((values) => {
@ -145,9 +158,25 @@ function cameraModal(props) {
close();
} else if (clickNum == 4) {
close();
}
} else {
nvrRef.current.resetFluoriteCamera();
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() {
if (clickNum == 1) {
fluoriteRef.current
@ -386,7 +415,7 @@ function cameraModal(props) {
cursor: "pointer",
marginRight: 16,
}}
onClick={onReset}
onClick={reset}
>
<img
src="/assets/images/background/Reset.png"
@ -430,7 +459,7 @@ function cameraModal(props) {
cameraData={cameraData}
/>
) : clickNum == 2 ? (
<NvrCamera />
<NvrCamera nvrRef={nvrRef} />
) : clickNum == 3 ? (
<IpcCamera
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 { Form,Row,Col,Button,CheckboxGroup, Checkbox,Radio,Input } from '@douyinfe/semi-ui';
import { IconEdit,IconPlayCircle } from '@douyinfe/semi-icons';
import {
Form,
Row,
Col,
Button,
CheckboxGroup,
Checkbox,
Radio,
Input,
} from "@douyinfe/semi-ui";
import { IconEdit, IconPlayCircle } from "@douyinfe/semi-icons";
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 [nvrCheckList, setNvrCheckList] = useState([]);//nvr
const [NVRcameraList,setNVRcameraList]=useState([])//nvr
const [isAllChoose,setIsAllChoose]=useState(false)//
const [equipmentNum,setEquipmentNum]=useState('')//nvr
function NvrChangeName(e,index){//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList))
NvrchangeList[index].change=true
setNVRcameraList(NvrchangeList)
e.stopPropagation()
const [nvrCheckList, setNvrCheckList] = useState([]); //nvr
const [NVRcameraList, setNVRcameraList] = useState([]); //nvr
const [isAllChoose, setIsAllChoose] = useState(false); //
const [equipmentNum, setEquipmentNum] = useState(""); //nvr
useEffect(() => {
NVRcameraList
? (equipmentScrollbar = new PerfectScrollbar("#video_streaming", {
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))
NvrchangeList[index].change=false
setNVRcameraList(NvrchangeList)
});
function NvrChangeName(e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].change = true;
setNVRcameraList(NvrchangeList);
e.stopPropagation();
}
function inputchange(e,index){//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList))
NvrchangeList[index].name=e
setNVRcameraList(NvrchangeList)
function nvronBlur(index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].change = false;
setNVRcameraList(NvrchangeList);
}
function toggle(e,index){//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList))
NvrchangeList[index].support=e.target.checked
setNVRcameraList(NvrchangeList)
e.stopPropagation()
function inputchange(e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
console.log(e);
NvrchangeList[index].name = e;
setNVRcameraList(NvrchangeList);
}
function getVideoList(){
form.current.validate().then(values=>{//
let chooseList=[]
let nvrCameraList=[{
id:10,
name:'南昌县1',
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)
function toggle(e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].support = e.target.checked;
setNVRcameraList(NvrchangeList);
e.stopPropagation();
}
setNvrCheckList(chooseList)
setIsAllChoose(true)
})
.catch(errors=>{//
console.log('errors',errors);
})
function getVideoList() {
form.current
.validate()
.then((values) => {
//
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){///
let chooseList=[]
if(NVRcameraList.length==nvrCheckList.length){
setNvrCheckList([])
setIsAllChoose(false)
console.log(chooseList);
setNvrCheckList(chooseList);
setIsAllChoose(true);
});
})
.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++) {
chooseList.push(NVRcameraList[index].id)
chooseList.push(NVRcameraList[index].id);
}
setNvrCheckList(chooseList)
setIsAllChoose(true)
setNvrCheckList(chooseList);
setIsAllChoose(true);
}
}
function playVideo(e) {//nvr
console.log('22222222222222222');
e.stopPropagation()
function playVideo(e) {
//nvr
console.log("22222222222222222");
e.stopPropagation();
}
// useImperativeHandle(cRef,() => ({//
// //aa
// getDate : form.current.validate,
// // resetFluoriteCamera : form.current.reset
// }))
useImperativeHandle(nvrRef, () => ({
//
//aa
resetFluoriteCamera: form.current.reset,
equipmentNum: equipmentNum,
NVRcameraList: NVRcameraList.filter((v) =>
nvrCheckList.some((e) => e == v.id)
),
}));
return (
<>
<Form
allowEmpty
labelPosition='left'
labelAlign='left'
labelWidth= '115px'
onValueChange={values=>{setEquipmentNum(values.equipmentNum)}}
getFormApi={formApi => form.current = formApi}>
<div style={{display:'flex'}}>
<Form.Input field='equipmentNum' maxLength='39' label='设备编号:' initValue={''} placeholder='请输入设备编号' style={{ width:307 }}
labelPosition="left"
labelAlign="left"
labelWidth="115px"
onValueChange={(values) => {
setEquipmentNum(values.serialNo);
}}
getFormApi={(formApi) => (form.current = formApi)}
>
<div style={{ display: "flex" }}>
<Form.Input
field="serialNo"
maxLength="39"
label="设备编号:"
initValue={""}
placeholder="请输入设备编号"
style={{ width: 307 }}
rules={[
{ required: true, 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}}>
{ required: true, 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 }}
>
<Radio
checked={isAllChoose}
mode="advanced"
onChange={e=>allChoose(e)}
aria-label="全选">
onChange={(e) => allChoose(e)}
aria-label="全选"
>
全选
</Radio>
</div>:''}
</div>
) : (
""
)}
</div>
<Row>
<CheckboxGroup type='pureCard' direction='vertical' aria-label="视频流获取"
<CheckboxGroup
type="pureCard"
direction="vertical"
aria-label="视频流获取"
value={nvrCheckList}
onChange={(nvrCheck) => {
setNvrCheckList(nvrCheck);
// console.log('11111111111',nvrCheck);
if(NVRcameraList.length==nvrCheck.length){
setIsAllChoose(true)
if (NVRcameraList.length == nvrCheck.length) {
setIsAllChoose(true);
} else {
setIsAllChoose(false);
}
else{
setIsAllChoose(false)
}
}}>
{NVRcameraList.length>0?NVRcameraList.map((item,index)=>(
<Col key={index} span={12} style={{display:'flex',justifyContent:'center',marginTop:12}}>
<Checkbox value={item.id}
}}
>
<div id="video_streaming" style={{ maxHeight: 300,position: "relative"}}>
{NVRcameraList.length > 0
? NVRcameraList.map((item, index) => (
<Col
key={index}
span={12}
style={{
display: "flex",
justifyContent: "center",
marginTop: 12,
}}
>
<Checkbox
value={item.id}
extra={
<div>
<div style={{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'}}>
<div
style={{
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
style={{fontSize:16,marginLeft:18,cursor: "pointer",color:'#1859C1'}}
onClick={e=>NvrChangeName(e,index)}/>
style={{
fontSize: 16,
marginLeft: 18,
cursor: "pointer",
color: "#1859C1",
}}
onClick={(e) => NvrChangeName(e, index)}
/>
</div>
</div>
<div style={{ marginTop: 8, width: 246 }}>
设备编号{item.parent}
</div>
<div style={{marginTop:8,width:246}}>设备编号{item.number}</div>
<div style={{marginTop:12,display:'flex',justifyContent:'space-between',alignItems:'center'}}>
<IconPlayCircle size='extra-large' style={{color:'#1859C1',}} onClick={e=>playVideo(e)}/>
<div
style={{
marginTop: 12,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<IconPlayCircle
size="extra-large"
style={{ color: "#1859C1" }}
onClick={(e) => playVideo(e)}
/>
<Radio
checked={item.support}
mode="advanced"
onChange={e=>toggle(e,index)}
onChange={(e) => toggle(e, index)}
aria-label="单选"
>
云台支持
@ -159,10 +271,12 @@ function nvrCamera({cRef}){
</div>
</div>
}
style={{width:280,border:'1px solid #F9F9F9',}}>
</Checkbox>
style={{ width: 280, border: "1px solid #F9F9F9" }}
></Checkbox>
</Col>
)):''}
))
: ""}
</div>
</CheckboxGroup>
</Row>
</Form>

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

@ -57,9 +57,9 @@ function nvrModal(props){
setokText('确认');
setcancelText('上一步');
setloading(false);
}, 2000);
}, 2000)
}, 2000);
}, 1000);
}, 1000)
}, 1000);
})
.catch(errors=>{//
console.log('errors',errors);
@ -120,7 +120,7 @@ function nvrModal(props){
]}/>
</Col>
<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 span={24}>
<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");
if (domEquipment && equipmentScrollbar) {
projectScrollbar.update();
equipmentScrollbar.update();
}
});
return (
@ -206,8 +206,7 @@ function SideSheets(props) {
<div
id="project_information"
style={{
height: document.body.clientHeight - 182,
// position: "relative",
height: document.body.clientHeight - 182,position: "relative"
}}
>
{nvrDetails
@ -236,7 +235,7 @@ function SideSheets(props) {
<div
id="equipment_information"
style={{
height: document.body.clientHeight - 126,
height: document.body.clientHeight - 126,position: "relative"
}}
>
{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";
export function skeletonScreen(line, columns) {
const data = () => {
let str = [];

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

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

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

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

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

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

Loading…
Cancel
Save