From 24334393d154c73fcb176ee8e431c2256501219e Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 22 Sep 2022 19:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A8=E9=80=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B7=AF=E7=94=B1=E6=94=B9=E4=B8=BA=20push=5Flist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/app/lib/controllers/status/alarm.js | 57 + .../api/app/lib/controllers/status/index.js | 15 + .../api/app/lib/controllers/status/push.js | 4 +- .../api/app/lib/controllers/vender/index.js | 32 +- .../api/app/lib/models/camera_status_alarm.js | 96 + .../api/app/lib/routes/index.js | 7 +- .../api/app/lib/routes/status/index.js | 9 +- .../api/app/lib/routes/vender/index.js | 2 +- code/VideoAccess-VCMP/api/config.js | 1 + .../api/sequelize-automate.config.js | 2 +- .../schema/1.create_camera_status_alarm.sql | 29 + .../web/client/src/layout/index.jsx | 2 +- .../equipmentWarehouse/containers/camera.jsx | 1658 ++++++++--------- .../equipmentWarehouse/containers/nvr.jsx | 1182 ++++++------ .../web/client/src/utils/webapi.js | 2 +- 15 files changed, 1653 insertions(+), 1445 deletions(-) create mode 100644 code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js create mode 100644 code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js create mode 100644 code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js b/code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js new file mode 100644 index 0000000..5b22be6 --- /dev/null +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js @@ -0,0 +1,57 @@ +'use strict'; +const moment = require('moment'); + +async function record (ctx) { + try { + const { models } = ctx.fs.dc; + const { statusCode, description = '', cameraId, platform = 'yingshi' } = ctx.request.body; + + let statusRes = await models.CameraStatus.findOne({ + where: { + status: statusCode + } + }) + let alarmRes = null; + if (!statusRes) { + statusRes = await models.CameraStatus.create({ + platform: platform, + status: statusCode, + describe: description, + forbidden: false, + }) + } else { + alarmRes = await models.CameraStatusAlarm.findOne({ + where: { + statusId: statusRes.id, + description, + cameraId, + confirm: null + } + }) + } + if (alarmRes) { + await models.CameraStatusAlarm.update({ + updateTime: moment().format() + }) + } else { + await models.CameraStatusAlarm.create({ + statusId: statusRes.id, + description, + createTime: moment().format(), + cameraId, + }) + } + + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +module.exports = { + record, +}; \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js index 2df763e..1516892 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js @@ -264,6 +264,20 @@ async function statusCheck (ctx) { } } +async function statusRecord (ctx) { + try { + const models = ctx.fs.dc.models; + + ctx.status = 20; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + module.exports = { get, getSimpleAll, @@ -271,4 +285,5 @@ module.exports = { paraphraseCustom, resolveEdit, statusCheck, + statusRecord, }; \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js b/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js index c3625b2..92ef8d1 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js @@ -119,7 +119,7 @@ async function edit (ctx) { } } -async function get (ctx) { +async function getStatusPushList (ctx) { try { const models = ctx.fs.dc.models; const { userId, token } = ctx.fs.api @@ -397,5 +397,5 @@ async function pushLog (ctx) { module.exports = { - edit, get, banned, del, copy, pushLog + edit, getStatusPushList, banned, del, copy, pushLog }; \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/vender/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/vender/index.js index d77d4f5..2060f4f 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/vender/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/vender/index.js @@ -1,23 +1,23 @@ 'use strict'; -async function get (ctx) { - const models = ctx.fs.dc.models; - try { - const res = await models.Vender.findAll({ - order: [ - ['id', 'ASC'] - ] - }) +async function getVenderList (ctx) { + const models = ctx.fs.dc.models; + try { + const res = await models.Vender.findAll({ + order: [ + ['id', 'ASC'] + ] + }) - ctx.status = 200; - ctx.body = res - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = {} - } + ctx.status = 200; + ctx.body = res + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = {} + } } module.exports = { - get, + getVenderList, }; \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js b/code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js new file mode 100644 index 0000000..32e7aa3 --- /dev/null +++ b/code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js @@ -0,0 +1,96 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const CameraStatusAlarm = sequelize.define("cameraStatusAlarm", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "camera_status_alarm_id_uindex" + }, + statusId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "status_id", + autoIncrement: false, + references: { + key: "id", + model: "cameraStatus" + } + }, + description: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "描述", + primaryKey: false, + field: "description", + autoIncrement: false + }, + confirm: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "确认信息", + primaryKey: false, + field: "confirm", + autoIncrement: false + }, + confirmTime: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "confirm_time", + autoIncrement: false + }, + createTime: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "生成时间", + primaryKey: false, + field: "create_time", + autoIncrement: false + }, + updateTime: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "更新时间", + primaryKey: false, + field: "update_time", + autoIncrement: false + }, + cameraId: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "camera_id", + autoIncrement: false, + references: { + key: "id", + model: "camera" + } + } + }, { + tableName: "camera_status_alarm", + comment: "", + indexes: [] + }); + dc.models.CameraStatusAlarm = CameraStatusAlarm; + return CameraStatusAlarm; +}; \ No newline at end of file diff --git a/code/VideoAccess-VCMP/api/app/lib/routes/index.js b/code/VideoAccess-VCMP/api/app/lib/routes/index.js index 39cbc75..e94f334 100644 --- a/code/VideoAccess-VCMP/api/app/lib/routes/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/routes/index.js @@ -7,8 +7,13 @@ module.exports = function (app, router, opts) { fs.readdirSync(__dirname).forEach((filename) => { if (filename.indexOf('.') !== 0 && fs.lstatSync(path.join(__dirname, filename)).isDirectory()) { fs.readdirSync(path.join(__dirname, filename)).forEach((api) => { + console.log('加载路由文件:' + filename + '/' + api); if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return; - require(`./${filename}/${api}`)(app, router, opts); + try { + require(`./${filename}/${api}`)(app, router, opts); + } catch (e) { + console.error(e); + } }); } }); diff --git a/code/VideoAccess-VCMP/api/app/lib/routes/status/index.js b/code/VideoAccess-VCMP/api/app/lib/routes/status/index.js index dc1c7c7..07911a9 100644 --- a/code/VideoAccess-VCMP/api/app/lib/routes/status/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/routes/status/index.js @@ -2,6 +2,7 @@ const status = require('../../controllers/status'); const push = require('../../controllers/status/push'); +const alarm = require('../../controllers/status/alarm'); module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/status'] = { content: '获取状态码', visible: false }; @@ -26,8 +27,8 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['PUT/status/push'] = { content: '编辑推送配置', visible: false }; router.put('/status/push', push.edit); - app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false }; - router.get('/status/push', push.get); + app.fs.api.logAttr['GET/status/push_list'] = { content: '获取推送配置', visible: false }; + router.get('/status/push_list', push.getStatusPushList); app.fs.api.logAttr['PUT/status/push/banned'] = { content: '禁用推送配置', visible: false }; router.put('/status/push/banned', push.banned); @@ -41,4 +42,8 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/status/push/:configId/detail'] = { content: '获取推送记录', visible: false }; router.get('/status/push/:configId/log', push.pushLog); // 信鸽推送 END + + // 状态告警 + app.fs.api.logAttr['POST/status/alarm'] = { content: '保存或更新告警信息', visible: false }; + router.post('/status/alarm', alarm.record); }; diff --git a/code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js b/code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js index 3eda838..007b8dc 100644 --- a/code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js @@ -4,5 +4,5 @@ const vender = require('../../controllers/vender'); module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/vender'] = { content: '获取设备厂商', visible: false }; - router.get('/vender', vender.get); + router.get('/vender', vender.getVenderList); }; diff --git a/code/VideoAccess-VCMP/api/config.js b/code/VideoAccess-VCMP/api/config.js index 1106420..68bf66a 100644 --- a/code/VideoAccess-VCMP/api/config.js +++ b/code/VideoAccess-VCMP/api/config.js @@ -94,6 +94,7 @@ const product = { exclude: [ { p: '/camera', o: 'GET' }, // 暂时滴 { p: '/application/check', o: 'GET' }, // 暂时滴 + { p: '/status/alarm', o: 'POST' }, ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 redis: { host: IOTA_REDIS_SERVER_HOST, diff --git a/code/VideoAccess-VCMP/api/sequelize-automate.config.js b/code/VideoAccess-VCMP/api/sequelize-automate.config.js index 5ebd0fc..9a97578 100644 --- a/code/VideoAccess-VCMP/api/sequelize-automate.config.js +++ b/code/VideoAccess-VCMP/api/sequelize-automate.config.js @@ -26,7 +26,7 @@ module.exports = { dir: './app/lib/models', // 指定输出 models 文件的目录 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir` - tables: ['mirror',], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 + tables: ['camera_status_alarm',], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql b/code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql new file mode 100644 index 0000000..f7bc4ae --- /dev/null +++ b/code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql @@ -0,0 +1,29 @@ +create table if not exists camera_status_alarm +( + id serial not null, + status_id integer not null, + description varchar(1024), + confirm varchar(1024), + confirm_time timestamp with time zone, + create_time timestamp with time zone, + update_time timestamp with time zone, + camera_id integer, + constraint camera_status_alarm_pk + primary key (id), + constraint camera_status_alarm_camera_status_id_fk + foreign key (status_id) references camera_status, + constraint camera_status_alarm_camera_id_fk + foreign key (camera_id) references camera +); + +comment on column camera_status_alarm.description is '描述'; + +comment on column camera_status_alarm.confirm is '确认信息'; + +comment on column camera_status_alarm.create_time is '生成时间'; + +comment on column camera_status_alarm.update_time is '更新时间'; + +create unique index if not exists camera_status_alarm_id_uindex + on camera_status_alarm (id); + diff --git a/code/VideoAccess-VCMP/web/client/src/layout/index.jsx b/code/VideoAccess-VCMP/web/client/src/layout/index.jsx index dfddebf..4f52436 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/index.jsx +++ b/code/VideoAccess-VCMP/web/client/src/layout/index.jsx @@ -202,7 +202,7 @@ const Root = props => { } // setMicroAppWaiting(false) - if (props.location.pathname == '/video_play_status') { + if (props.location && props.location.pathname == '/video_play_status') { setAuthCrossLoading(false) setMicroAppWaiting(false) } diff --git a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx index d671b79..8e8806d 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx +++ b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx @@ -3,15 +3,15 @@ import { connect } from "react-redux"; import moment from "moment"; import qs from "qs"; import { - Button, - Form, - Table, - Pagination, - Popover, - Tag, - Skeleton, - Popconfirm, - Row, + Button, + Form, + Table, + Pagination, + Popover, + Tag, + Skeleton, + Popconfirm, + Row, } from "@douyinfe/semi-ui"; import { SimpleFileDownButton, VideoPlayModal, SkeletonScreen } from "$components"; import "../style.less"; @@ -22,632 +22,632 @@ import SideSheets from "../components/sideSheet"; import { accessType } from "./nvr"; const CameraHeader = (props) => { - const { dispatch, actions, user, loading, equipmentWarehouseCamera } = props; - const [cameraModal, setCameraModal] = useState(false); - const [remarksModal, setRemarksModal] = useState(false); - const [videoPlay, setVideoPlay] = useState(false); - const [modalName, setModalName] = useState(""); - const [setup, setSetup] = useState(false); - const [sideSheet, setSideSheet] = useState(false); - const [cameraSetup, setcameraSetup] = useState(false); - const [setupp, setSetupp] = useState([]); - const [venderList, setvenderList] = useState([]); //厂商信息 - const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 - const [search, setSearch] = useState({}); //搜索条件 - const [rowId, setRowId] = useState(); //表格数据id - const [cameraData, setCameraData] = useState({}); //表格传递数据 - const [modify, setModify] = useState(false); //修改 - const [parentCamera, setParentCamera] = useState(""); //级联摄像头父级设备 - const [addNvr, setAddNvr] = useState(false); //nvr页面传递参数打开NVR摄像头添加弹框 - const [nvrNumber, setNvrNumber] = useState(); - const [videoObj, setVideoObj] = useState(); //播放条件 - const [axyData, setAxyData] = useState(); - const [cameraRemarks, setCameraRemarks] = useState([]);//备注 - const { equipmentWarehouse } = actions; - const api = useRef(); - const searchData = useRef({}) - const limits = useRef(); //每页实际条数 - const page = useRef(query.page); - const deviceClickb = useRef(true) - const CAMERAS = "cameras"; - const tableList = [//表格属性 - { - title: '设备信息', - list: [ - { name: "设备厂家", value: "manufactor" }, - { name: "接入类型", value: "type" }, - { name: "设备状态", value: "state" }, - { name: "云台支持", value: "support" }, - { name: "内存卡信息", value: "memoryCard" }, - { name: "设备创建时间", value: "time" }, - { name: "设备添加账号", value: "account" }, - ] - }, - { - title: '项目信息', - list: [ - { name: "项目名称", value: "name" }, - { name: "pcode", value: "pcode" }, - { name: "结构物", value: "structure" }, - { name: "测点", value: "measuringPoint" }, - { name: "监测因素", value: "factor" }, - ] - }, - ]; - useEffect(() => { - //安心云传参 - let isAxyData = props.location.search - if (isAxyData) { - setAxyData(qs.parse(isAxyData.slice(1))) - setCameraModal(true) - } - //NVR传来的参数 - if (props.location.query) { - setAddNvr(props.location.query.addNvr) - setNvrNumber(props.location.query.serialNo) - setCameraModal(true); - } - dispatch(actions.equipmentWarehouse.getVender()).then((res) => { - setvenderList(res.payload.data); - attribute(res.payload.data); - }); - //初始化表格显示设置 - localStorage.getItem(CAMERAS) == null - ? localStorage.setItem( - CAMERAS, - JSON.stringify(["state", "type", "manufactor"]) - ) - : ""; - }, []); + const { dispatch, actions, user, loading, equipmentWarehouseCamera } = props; + const [cameraModal, setCameraModal] = useState(false); + const [remarksModal, setRemarksModal] = useState(false); + const [videoPlay, setVideoPlay] = useState(false); + const [modalName, setModalName] = useState(""); + const [setup, setSetup] = useState(false); + const [sideSheet, setSideSheet] = useState(false); + const [cameraSetup, setcameraSetup] = useState(false); + const [setupp, setSetupp] = useState([]); + const [venderList, setvenderList] = useState([]); //厂商信息 + const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 + const [search, setSearch] = useState({}); //搜索条件 + const [rowId, setRowId] = useState(); //表格数据id + const [cameraData, setCameraData] = useState({}); //表格传递数据 + const [modify, setModify] = useState(false); //修改 + const [parentCamera, setParentCamera] = useState(""); //级联摄像头父级设备 + const [addNvr, setAddNvr] = useState(false); //nvr页面传递参数打开NVR摄像头添加弹框 + const [nvrNumber, setNvrNumber] = useState(); + const [videoObj, setVideoObj] = useState(); //播放条件 + const [axyData, setAxyData] = useState(); + const [cameraRemarks, setCameraRemarks] = useState([]);//备注 + const { equipmentWarehouse } = actions; + const api = useRef(); + const searchData = useRef({}) + const limits = useRef(); //每页实际条数 + const page = useRef(query.page); + const deviceClickb = useRef(true) + const CAMERAS = "cameras"; + const tableList = [//表格属性 + { + title: '设备信息', + list: [ + { name: "设备厂家", value: "manufactor" }, + { name: "接入类型", value: "type" }, + { name: "设备状态", value: "state" }, + { name: "云台支持", value: "support" }, + { name: "内存卡信息", value: "memoryCard" }, + { name: "设备创建时间", value: "time" }, + { name: "设备添加账号", value: "account" }, + ] + }, + { + title: '项目信息', + list: [ + { name: "项目名称", value: "name" }, + { name: "pcode", value: "pcode" }, + { name: "结构物", value: "structure" }, + { name: "测点", value: "measuringPoint" }, + { name: "监测因素", value: "factor" }, + ] + }, + ]; + useEffect(() => { + //安心云传参 + let isAxyData = props.location.search + if (isAxyData) { + setAxyData(qs.parse(isAxyData.slice(1))) + setCameraModal(true) + } + //NVR传来的参数 + if (props.location.query) { + setAddNvr(props.location.query.addNvr) + setNvrNumber(props.location.query.serialNo) + setCameraModal(true); + } + dispatch(actions.equipmentWarehouse.getVender()).then((res) => { + setvenderList(res.payload.data); + attribute(res.payload.data); + }); + //初始化表格显示设置 + localStorage.getItem(CAMERAS) == null + ? localStorage.setItem( + CAMERAS, + JSON.stringify(["state", "type", "manufactor"]) + ) + : ""; + }, []); - useEffect(() => { - equipmentGetCamera(); - }, [query, search]); + useEffect(() => { + equipmentGetCamera(); + }, [query, search]); - const equipmentGetCamera = () => { - searchData.current = { ...query, ...search } - dispatch(equipmentWarehouse.getCamera(searchData.current)).then((res) => { - limits.current = res.payload.data.data.length - }); - } - function equipmentStatus (data) { - switch (data) { - case "ON": - return "在线" - case "ONLINE": - return "在线" - case "OFF": - return "离线" - default: - return "未知" - } - } + const equipmentGetCamera = () => { + searchData.current = { ...query, ...search } + dispatch(equipmentWarehouse.getCamera(searchData.current)).then((res) => { + limits.current = res.payload.data.data.length + }); + } + function equipmentStatus (data) { + switch (data) { + case "ON": + return "在线" + case "ONLINE": + return "在线" + case "OFF": + return "离线" + default: + return "未知" + } + } - function colorStatus (data) { - switch (data) { - case "ON": - return "#04B234" - case "ONLINE": - return "#04B234" - case "OFF": - return "rgba(0, 0, 0, 0.45)" - default: - return "#1859C1" - } - } - const columns = [ - { - title: "序号", - dataIndex: "", - render: (text, r, index) => { - return index + 1; - }, - }, - { - title: "设备名称", - dataIndex: "name", - render: (_, row) => { - return ( -
- {row.name} - { - if (deviceClickb.current) { - if (row.type == "nvr") { - setSearch({ ...search, nvrId: row.nvr.id }) - } else { - setSearch({ ...search, externalDomain: row.externalDomain }) - } - deviceClickb.current = false - } else { - if (row.type == "nvr") { - setSearch({ ...search, nvrId: null }) - } else { - setSearch({ ...search, externalDomain: null }) - } - deviceClickb.current = true - } - }} - > - {row.type == "nvr" ? `@${row.nvr.name}` : row.type == "cascade" ? `@${row.externalDomain}` : ""} - -
- ); - }, - }, - { - title: "操作", - width: "20%", - dataIndex: "", - render: (_, row) => { - return ( -
- - - - {row.forbidden ? ( - - ) : ( - { - dispatch( - equipmentWarehouse.putForbidden( - { - cameraId: row.id, - forbidden: !row.forbidden, - }, - row.forbidden - ) - ).then(() => { - dispatch(equipmentWarehouse.getCamera(searchData.current)) - }); - }} - > - - - )} + + + + {row.forbidden ? ( + + ) : ( + { + dispatch( + equipmentWarehouse.putForbidden( + { + cameraId: row.id, + forbidden: !row.forbidden, + }, + row.forbidden + ) + ).then(() => { + dispatch(equipmentWarehouse.getCamera(searchData.current)) + }); + }} + > + + + )} - { - dispatch( - equipmentWarehouse.delCamera(row.id) - ).then(() => { - if (page.current > 0 && limits.current < 2) { - setQuery({ limit: 10, page: page.current - 1 }) - } else { - setQuery({ limit: 10, page: page.current }) - } - }); - }} - > - - - -
- ); - }, - }, - ]; + { + dispatch( + equipmentWarehouse.delCamera(row.id) + ).then(() => { + if (page.current > 0 && limits.current < 2) { + setQuery({ limit: 10, page: page.current - 1 }) + } else { + setQuery({ limit: 10, page: page.current }) + } + }); + }} + > + + + + + ); + }, + }, + ]; - //获取表格属性设置 - function attribute (data) { - const arr = localStorage.getItem(CAMERAS) - ? JSON.parse(localStorage.getItem(CAMERAS)) - : []; + //获取表格属性设置 + function attribute (data) { + const arr = localStorage.getItem(CAMERAS) + ? JSON.parse(localStorage.getItem(CAMERAS)) + : []; - const column = [ - { - title: "设备厂家", - dataIndex: "venderId", - key: "manufactor", - render: (_, r, index) => { - let manufactorName = data.find((item) => item.id == r.venderId); - return manufactorName ? manufactorName.name : "未知"; - }, - }, - { - title: "接入类型", - dataIndex: "cameraAbility.type", - key: "type", - render: (_, r, index) => { - let access = accessType.find((item) => item.key == r.type); - return access ? access.name : ""; - }, + const column = [ + { + title: "设备厂家", + dataIndex: "venderId", + key: "manufactor", + render: (_, r, index) => { + let manufactorName = (data || []).find((item) => item.id == r.venderId); + return manufactorName ? manufactorName.name : "未知"; }, - { - title: "设备状态", - dataIndex: "channelCount", - key: "state", - render: (_, r, index) => { - let status = r.gbCamera; - return ( -
- - {r.forbidden ? "禁用" : status ? equipmentStatus(status.online) : ""} -
- ); - }, + }, + { + title: "接入类型", + dataIndex: "cameraAbility.type", + key: "type", + render: (_, r, index) => { + let access = accessType.find((item) => item.key == r.type); + return access ? access.name : ""; }, - { - title: "云台支持", - dataIndex: "cloudControl", - key: "support", - render: (text, r, index) => { - return r.cloudControl ? "支持" : "不支持"; - }, - + }, + { + title: "设备状态", + dataIndex: "channelCount", + key: "state", + render: (_, r, index) => { + let status = r.gbCamera; + return ( +
+ + {r.forbidden ? "禁用" : status ? equipmentStatus(status.online) : ""} +
+ ); }, - { - title: "内存卡信息", - dataIndex: "memoryCard", - key: "memoryCard", + }, + { + title: "云台支持", + dataIndex: "cloudControl", + key: "support", + render: (text, r, index) => { + return r.cloudControl ? "支持" : "不支持"; }, - { - title: "设备创建时间", - dataIndex: "createTime", - key: "time", - render: (_, r, index) => { - return moment(r.createTime).format("YYYY-MM-DD HH:MM:SS"); - }, + + }, + { + title: "内存卡信息", + dataIndex: "memoryCard", + key: "memoryCard", + }, + { + title: "设备创建时间", + dataIndex: "createTime", + key: "time", + render: (_, r, index) => { + return moment(r.createTime).format("YYYY-MM-DD HH:MM:SS"); }, - { - title: "设备添加账号", - dataIndex: "size", - key: "account", - render: (text, r, index) => { - return r.createUser?.namePresent - }, + }, + { + title: "设备添加账号", + dataIndex: "size", + key: "account", + render: (text, r, index) => { + return r.createUser?.namePresent }, - { - title: "项目名称", - dataIndex: "updateTime", - key: "name", - render: (_, r, index) => { - return r.station.length == 0 - ? "" - : station(r, "name", _, "projects") - }, + }, + { + title: "项目名称", + dataIndex: "updateTime", + key: "name", + render: (_, r, index) => { + return r.station.length == 0 + ? "" + : station(r, "name", _, "projects") }, - { - title: "pcode", - dataIndex: "updateTime", - key: "pcode", - render: (_, r, index) => { - return r.station.length == 0 - ? "" - : station(r, "url", _, "projects") - }, + }, + { + title: "pcode", + dataIndex: "updateTime", + key: "pcode", + render: (_, r, index) => { + return r.station.length == 0 + ? "" + : station(r, "url", _, "projects") }, - { - title: "结构物", - dataIndex: "", - key: "structure", - render: (_, r, index) => { - return r.station.length == 0 - ? "" - : station(r, "name", r.station[0].structure.name, _, "structure") - }, + }, + { + title: "结构物", + dataIndex: "", + key: "structure", + render: (_, r, index) => { + return r.station.length == 0 + ? "" + : station(r, "name", r.station[0].structure.name, _, "structure") }, - { - title: "测点", - dataIndex: "updateTime", - key: "measuringPoint", - render: (_, r, index) => { - return r.station.length == 0 - ? "" - : station(r, "name", r.station[0].name, _, "point") - }, + }, + { + title: "测点", + dataIndex: "updateTime", + key: "measuringPoint", + render: (_, r, index) => { + return r.station.length == 0 + ? "" + : station(r, "name", r.station[0].name, _, "point") }, - { - title: "监测因素", - dataIndex: "updateTime", - key: "factor", - render: (_, r, index) => { - return r.station.length == 0 - ? "" - : station(r, "name", r.station[0].factor.name) - }, + }, + { + title: "监测因素", + dataIndex: "updateTime", + key: "factor", + render: (_, r, index) => { + return r.station.length == 0 + ? "" + : station(r, "name", r.station[0].factor.name) }, - ]; - for (let i = 0; i < arr.length; i++) { - let colum = column.filter((item) => { - return item.key === arr[i]; - }); - columns.splice(i + 2, 0, colum[0]); - } - setSetupp(columns); - } + }, + ]; + for (let i = 0; i < arr.length; i++) { + let colum = column.filter((item) => { + return item.key === arr[i]; + }); + columns.splice(i + 2, 0, colum[0]); + } + setSetupp(columns); + } - //表格请求数据中station属性数据的展示 - function station (r, name, data, projects, exhibition) { - let datas = [] - if (projects == "projects") { - r.station.map((v) => { - if (v.structure.projects.length > 0) { - v.structure.projects.map((item) => datas.push(item[name])) - } - }) - } else { - r.station.map((v) => { - if (exhibition == "structure") { - datas.push(v.structure.name) - } else { - if (exhibition == "point") { - datas.push(v.name) - } else { - datas.push(v.factor.name) - } - } - }) - } - let dataSet = [...(new Set(datas))] - return dataSet.length > 0 ? 1 ? -
- {dataSet.map((v, index) =>
{v}
)} -
- : "" + //表格请求数据中station属性数据的展示 + function station (r, name, data, projects, exhibition) { + let datas = [] + if (projects == "projects") { + r.station.map((v) => { + if (v.structure.projects.length > 0) { + v.structure.projects.map((item) => datas.push(item[name])) + } + }) + } else { + r.station.map((v) => { + if (exhibition == "structure") { + datas.push(v.structure.name) + } else { + if (exhibition == "point") { + datas.push(v.name) + } else { + datas.push(v.factor.name) + } } - > - {dataSet.length > 1 ? `${dataSet[0]}...` : dataSet.length > 0 ? dataSet[0] : ""} -
: "" + }) + } + let dataSet = [...(new Set(datas))] + return dataSet.length > 0 ? 1 ? +
+ {dataSet.map((v, index) =>
{v}
)} +
+ : "" + } + > + {dataSet.length > 1 ? `${dataSet[0]}...` : dataSet.length > 0 ? dataSet[0] : ""} +
: "" - } - //条件赛选样式 - const screen = { - width: 193, - marginRight: 20, - marginBottom: 16, - color: "rgba(0, 0, 0, 0.65)", - }; + } + //条件赛选样式 + const screen = { + width: 193, + marginRight: 20, + marginBottom: 16, + color: "rgba(0, 0, 0, 0.65)", + }; - return ( - <> -
-