From bb643a0562d3f40e6426681f57d922c814a68b8c Mon Sep 17 00:00:00 2001 From: deartibers <947466799@qq.com> Date: Wed, 16 Nov 2022 16:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=BC=82=E5=B8=B8=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/video.js | 36 ++++++++++++++++++- api/app/lib/routes/alarm/index.js | 3 ++ .../sections/install/containers/system.jsx | 36 +++++++++---------- .../src/sections/problem/actions/problem.jsx | 11 ++++++ .../sections/problem/components/tableData.jsx | 15 +++++--- .../sections/problem/containers/dataAlarm.jsx | 7 ++++ web/client/src/utils/webapi.js | 1 + 7 files changed, 86 insertions(+), 23 deletions(-) diff --git a/api/app/lib/controllers/alarm/video.js b/api/app/lib/controllers/alarm/video.js index a8ec73a..ce69e26 100644 --- a/api/app/lib/controllers/alarm/video.js +++ b/api/app/lib/controllers/alarm/video.js @@ -38,6 +38,39 @@ async function deviceType (ctx) { } } +async function exceptionType(ctx) { + try { + const { models } = ctx.fs.dc; + const { clickHouse } = ctx.app.fs + const { database: anxinyun } = clickHouse.anxinyun.opts.config + const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs + let anxinStruc = await anxinStrucIdRange({ + ctx, + }) + const anxinStrucIds = anxinStruc.map(a => a.strucId) + + const statusRes = await clickHouse.vcmp.query(` + SELECT DISTINCT + camera_status.id AS statusId,camera_status.describe AS describe + FROM camera_status + INNER JOIN camera_status_alarm + ON camera_status.id = camera_status_alarm.status_id + INNER JOIN ${anxinyun}.t_video_ipc + ON toString(${anxinyun}.t_video_ipc.channel_no) = camera_status_alarm.channel_no + AND ${anxinyun}.t_video_ipc.serial_no = camera_status_alarm.serial_no + ${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')})`} + `).toPromise() + ctx.status = 200; + ctx.body = statusRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + async function alarmList (ctx) { try { const { models } = ctx.fs.dc; @@ -461,5 +494,6 @@ module.exports = { alarmList, confirm, alarmAdded, - vcmpAppAuthToken + vcmpAppAuthToken, + exceptionType }; \ No newline at end of file diff --git a/api/app/lib/routes/alarm/index.js b/api/app/lib/routes/alarm/index.js index cfba9d0..9d97aaf 100644 --- a/api/app/lib/routes/alarm/index.js +++ b/api/app/lib/routes/alarm/index.js @@ -60,4 +60,7 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/vcmp/auth'] = { content: '获取视频平台应用鉴权token', visible: true }; router.get('/vcmp/auth', videoAlarm.vcmpAppAuthToken); + + app.fs.api.logAttr['GET/alarm/video/exception_statusId'] = { content: '查询视频异常类型', visible: true }; + router.get('/alarm/video/exception_statusId', videoAlarm.exceptionType); }; diff --git a/web/client/src/sections/install/containers/system.jsx b/web/client/src/sections/install/containers/system.jsx index b192fbe..e634b24 100644 --- a/web/client/src/sections/install/containers/system.jsx +++ b/web/client/src/sections/install/containers/system.jsx @@ -225,28 +225,28 @@ const Example = (props) => { } }, { - title: '关联时间', - dataIndex: "createTime", - key: 'time', - render: (_, row) => { - return moment(row.createTime).format("YYYY-MM-DD HH:mm:ss") - } + title: '关联时间', + dataIndex: "createTime", + key: 'time', + render: (_, row) => { + return moment(row.createTime).format("YYYY-MM-DD HH:mm:ss")||'无'; + } }, { - title: '修改时间', - dataIndex: "updateTime", - key: 'updateTime', - render: (_, row) => { - return moment(row.updateTime).format("YYYY-MM-DD HH:mm:ss") - } + title: '修改时间', + dataIndex: "updateTime", + key: 'updateTime', + render: (_, row) => { + return (row.updateTime?moment(row.updateTime).format("YYYY-MM-DD HH:mm:ss"):moment(row.createTime).format("YYYY-MM-DD HH:mm:ss")); + } }, { - title: '添加人员', - dataIndex: "pepUserName", - key: 'pepUserName', - render: (_, row) => { - return row.pepUserName - } + title: '添加人员', + dataIndex: "pepUserName", + key: 'pepUserName', + render: (_, row) => { + return row.pepUserName||'无' + } }, { title: "管理", diff --git a/web/client/src/sections/problem/actions/problem.jsx b/web/client/src/sections/problem/actions/problem.jsx index b8bf96e..903cb7d 100644 --- a/web/client/src/sections/problem/actions/problem.jsx +++ b/web/client/src/sections/problem/actions/problem.jsx @@ -149,6 +149,17 @@ export function getAlarmVideoDeviceKind () { //查询视频设备类型 }); } +export function getAlarmVideoExceptionStatusId () { //查询视频异常类型 + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_ALARM_VIDEO_EXCEPTION_STATUS_ID', + url: `${ApiTable.getAlarmVideoExceptionStatusId}`, + msg: { option: '查询视频异常类型' }, + reducer: { name: '' } + }); + } + export function putAlarmVideoConfirm (data) { //确认视频告警 return dispatch => basicAction({ type: 'put', diff --git a/web/client/src/sections/problem/components/tableData.jsx b/web/client/src/sections/problem/components/tableData.jsx index 8c649c6..60f8b94 100644 --- a/web/client/src/sections/problem/components/tableData.jsx +++ b/web/client/src/sections/problem/components/tableData.jsx @@ -10,14 +10,14 @@ import qs from "qs"; const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, - selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user }) => { + selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user, statusId, setStatusId}) => { const { problem } = actions const [count, setCount] = useState(0) // const [checkAll, setCheckAll] = useState(true) //查询 const api = useRef(); const search = useRef({ - state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', + state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', statusId:'', errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: '' }) const kindName = useRef() @@ -153,12 +153,17 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) } }) + dispatch(problem.getAlarmVideoExceptionStatusId()).then((res) => { + if (res.success) { + setStatusId(res.payload.data.map(v => ({ name: v.describe, value: v.statusId }))) + } + }) } }, []) const handleExport = () => { let url = '' - let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current + let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', statusId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current switch (route) { case 'useAbnormal': url = `alarm/application/api?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType} @@ -166,7 +171,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition break; case 'videoAbnormal': url = `alarm/video/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keywordTarget=${keywordTarget} - &keyword=${keyword}&kindId=${kindId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd} + &keyword=${keyword}&kindId=${kindId}&statusId=${statusId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd} &pepProjectId=${pepProjectId || ''}` break; default: @@ -277,6 +282,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition keywordTarget: v.keywordTarget, keyword: v.keyword, kindId: v.kindId, + statusId: v.statusId, groupUnitId: v.groupUnitId, errType: v.errType, confirmState: v.confirmState, @@ -299,6 +305,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition keywordTarget: v.keywordTarget, keyword: v.keyword, kindId: v.kindId, + statusId: v.statusId, groupUnitId: v.groupUnitId, errType: v.errType, confirmState: v.confirmState, diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx index 4f1ca61..27ef6be 100644 --- a/web/client/src/sections/problem/containers/dataAlarm.jsx +++ b/web/client/src/sections/problem/containers/dataAlarm.jsx @@ -31,6 +31,7 @@ const DataAlarm = (props) => { const [content, setContent] = useState(false); //确认内容 const [selected, setSelected] = useState([]) //表格被勾选项 const [genre, setGenre] = useState([]) //搜索类型 + const [statusId, setStatusId] = useState([]) //异常类型 const [checkPop, setCheckPop] = useState(false) //查看弹框是否显现 const [alarmId, setAlarmId] = useState(false) //查看alarmId const [query, setQuery] = useState({ limit: 10, page: 0 }) //分页 @@ -112,6 +113,10 @@ const DataAlarm = (props) => { name: '设备类型', field: 'kindId', data: genre, }, + { + name: '异常类型', field: 'statusId', + data: statusId, + }, { name: '异常状态', field: 'state', data: [ @@ -424,11 +429,13 @@ const DataAlarm = (props) => { selected={selected} setSelected={setSelected} setGenre={setGenre} + setStatusId={setStatusId} query={query} setQuery={setQuery} tableData={tableData} setTableData={setTableData} genre={genre} + statusId={statusId} location={props.location?.query} /> {setup ? ( diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 8ec5d94..b69f118 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -47,6 +47,7 @@ export const ApiTable = { getAlarmVideoDeviceKind: 'alarm/video/device_kind', //查询视频设备类型 putAlarmVideoConfirm: 'alarm/video/confirm', //确认视频告警信息 getVcmpAuth: 'vcmp/auth', // 获取视频平台应用鉴权token + getAlarmVideoExceptionStatusId: 'alarm/video/exception_statusId', //查询视频设备类型 //服务-信鸽服务 getPush: "push", //获取推送配置列表