From 6da32419d01927fcc22f61ad7bbcb26af4e32e04 Mon Sep 17 00:00:00 2001 From: wenlele Date: Fri, 29 Dec 2023 08:29:41 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/data.js | 11 +- api/app/lib/controllers/alarm/service.js | 41 +++ api/app/lib/controllers/control/toolLink.js | 22 +- api/app/lib/models/exception_typ_check.js | 44 +++ api/app/lib/routes/alarm/index.js | 8 + api/app/lib/schedule/alarms_push.js | 136 +++++---- script/4.2/schema/1.exception_typ_check.sql | 14 + .../src/layout/components/header/index.jsx | 2 +- .../control/components/alarm-chart.jsx | 168 +++++------ .../sections/control/containers/control.jsx | 19 +- .../src/sections/problem/actions/problem.jsx | 24 ++ .../problem/components/inspection.jsx | 2 +- .../sections/problem/components/tableData.jsx | 264 ++++++++++++------ .../sections/problem/containers/dataAlarm.jsx | 97 ++++--- web/client/src/sections/problem/nav-item.jsx | 18 +- web/client/src/sections/problem/routes.js | 50 ++-- .../sections/service/components/pushModal.jsx | 38 +-- .../sections/service/containers/emPush.jsx | 31 +- web/client/src/utils/webapi.js | 1 + 19 files changed, 641 insertions(+), 349 deletions(-) create mode 100644 api/app/lib/models/exception_typ_check.js create mode 100644 script/4.2/schema/1.exception_typ_check.sql diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 5715085..e4a0c3c 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -46,7 +46,8 @@ async function list (ctx) { const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs const { database: anxinyun } = clickHouse.anxinyun.opts.config - const { timestamps,pepProjectId, keywordTarget, keyword, groupId, groupUnitId, sustainTimeStart, sustainTimeEnd, limit, page, state, onlineState, toExport } = ctx.query + const { timestamps, pepProjectId, keywordTarget, keyword, groupId, groupUnitId, sustainTimeStart, sustainTimeEnd, + limit, page, state, onlineState, toExport } = ctx.query let anxinStruc = await anxinStrucIdRange({ ctx, pepProjectId, keywordTarget, keyword @@ -60,7 +61,7 @@ async function list (ctx) { whereOption.push(`alarms.AlarmGroup IN (${groupId})`) } if (groupUnitId) { - whereOption.push(`alarms.AlarmGroupUnit=${groupUnitId}`) + whereOption.push(`alarms.AlarmGroupUnit IN (${groupUnitId})`) } if (sustainTimeStart && sustainTimeEnd) { let momentStart = moment(sustainTimeStart).format('YYYY-MM-DD HH:mm:ss') @@ -100,10 +101,10 @@ async function list (ctx) { let alarmQueryOptionStr = ` FROM alarms - ${timestamps?`LEFT JOIN ( + ${timestamps ? `LEFT JOIN ( SELECT DeviceId, any(Status) AS Status,max(Time) FROM DeviceStatus GROUP BY DeviceId ) AS DeviceStatus - ON DeviceStatus.DeviceId = alarms.SourceId`:''} + ON DeviceStatus.DeviceId = alarms.SourceId`: ''} LEFT JOIN ${anxinyun}.t_structure ON ${anxinyun}.t_structure.id = alarms.StructureId LEFT JOIN ${anxinyun}.t_alarm_code @@ -121,7 +122,7 @@ async function list (ctx) { SourceTypeId, AlarmAdviceProblem, AlarmGroup, AlarmGroupUnit, AlarmAdviceProblem, alarms.StructureId AS StructureId, - ${timestamps?`DeviceStatus.Status AS DeviceStatus,`:''} + ${timestamps ? `DeviceStatus.Status AS DeviceStatus,` : ''} ${anxinyun}.t_structure.name AS StructureName, ${anxinyun}.t_structure.longitude AS StructureLongitude, ${anxinyun}.t_structure.latitude AS StructureLatitude, diff --git a/api/app/lib/controllers/alarm/service.js b/api/app/lib/controllers/alarm/service.js index 51d123f..6e02493 100644 --- a/api/app/lib/controllers/alarm/service.js +++ b/api/app/lib/controllers/alarm/service.js @@ -157,10 +157,51 @@ async function serviceErrorList (ctx) { } } +async function getExceptionTypeCheck (ctx) { + try { + const models = ctx.fs.dc.models; + const { userId } = ctx.query + + const res = await models.ExceptionTypeCheck.findOne({ where: { userId } }) + + ctx.status = 200; + ctx.body = res + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +async function postExceptionTypeCheck (ctx) { + try { + const models = ctx.fs.dc.models; + const { userId, typeId } = ctx.request.body + + const findOne = await models.ExceptionTypeCheck.findOne({ where: { userId } }) + if (findOne) { + await models.ExceptionTypeCheck.update({ typeId }, { where: { userId } }) + } else { + await models.ExceptionTypeCheck.create({ typeId, userId }) + } + 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 = { serviceError, serviceErrorList, + getExceptionTypeCheck, + postExceptionTypeCheck, }; \ No newline at end of file diff --git a/api/app/lib/controllers/control/toolLink.js b/api/app/lib/controllers/control/toolLink.js index d67b1b9..52ce639 100644 --- a/api/app/lib/controllers/control/toolLink.js +++ b/api/app/lib/controllers/control/toolLink.js @@ -382,27 +382,27 @@ async function count (ctx) { alarmId: a.alarmId, confirmContent: a.confirmContent, confirmTime: a.confirmTime, - + venderId: a.venderId, venderName: a.venderName, cameraKindId: a.cameraKindId, yingshiToken: a.yingshiToken, - + resolve: [], struc: [], station: [] } - + // pep 项目 d.pomsProject = ( anxinStruc.find(as => as.strucId == a.strucId) || { pomsProject: [ - + ] } ).pomsProject - + if (a.resolveId) { d.resolve.push({ id: a.resolveId, @@ -487,14 +487,14 @@ async function count (ctx) { ctx.status = 200; ctx.body = { - dataSurplus: dataSurplus + videoSurplus, - dataNewAdd: dataNewAdd + videoNewAdd, - dataConfirme: videoConfirme + dataConfirmeToday, + dataSurplus: dataSurplus + toolSurplus, + dataNewAdd: dataNewAdd + toolNewAdd, + dataConfirme: dataConfirmeToday + toolConfirmeToday, - toolSurplus: toolSurplus, - toolNewAdd: toolNewAdd, - toolConfirme: toolConfirmeToday, + videoSurplus: videoSurplus, + videoNewAdd: videoNewAdd, + videoConfirme: videoConfirme, appSurplus: appSurplus, diff --git a/api/app/lib/models/exception_typ_check.js b/api/app/lib/models/exception_typ_check.js new file mode 100644 index 0000000..bbb41d7 --- /dev/null +++ b/api/app/lib/models/exception_typ_check.js @@ -0,0 +1,44 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const ExceptionTypeCheck = sequelize.define("exceptionTypeCheck", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "exception_type_check_id_uindex" + }, + userId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: "", + primaryKey: false, + field: "user_id", + autoIncrement: false + }, + + typeId: { + type: DataTypes.ARRAY(DataTypes.INTEGER), + allowNull: true, + defaultValue: null, + comment: "", + primaryKey: false, + field: "type_id", + autoIncrement: false + }, + }, { + tableName: "exception_type_check", + comment: "", + indexes: [] + }); + dc.models.ExceptionTypeCheck = ExceptionTypeCheck; + return ExceptionTypeCheck; +}; \ 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 fd085b0..1958c11 100644 --- a/api/app/lib/routes/alarm/index.js +++ b/api/app/lib/routes/alarm/index.js @@ -93,4 +93,12 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/data/continuity/:continuityId/detail'] = { content: '获取数据连续性监控信息详细', visible: true } router.get('/data/continuity/:continuityId/detail', dataContinuity.dataContinuityDetail); + + + app.fs.api.logAttr['GET/exception/type/check'] = { content: '获取用户的数据异常勾选信息', visible: true }; + router.get('/exception/type/check', service.getExceptionTypeCheck); + + app.fs.api.logAttr['POST/exception/type/check'] = { content: '存储用户的数据异常勾选信息', visible: true }; + router.post('/exception/type/check', service.postExceptionTypeCheck); + }; diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index ea4bb4d..79cf6bd 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -10,7 +10,7 @@ module.exports = function (app, opts) { const alarmsPush = app.fs.scheduleInit( { interval: isDev ? - '24 0 */1 * * *' : // 延长运行时间 好debug + '24 */1 * * *' : // 延长运行时间 好debug '12 */1 * * * *', // interval: '12 0 0 0 */1 *', immediate: isDev, @@ -327,16 +327,19 @@ module.exports = function (app, opts) { // 判断告警数据范围 if (c.alarmType.includes('data_outages')) { dataAlarmGroupOption.push(1) + dataAlarmGroupOption.push(4) + dataAlarmGroupOption.push(5) if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_outages'] || []) } if (c.alarmType.includes('data_exception')) { dataAlarmGroupOption.push(2) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_exception'] || []) - } - if (c.alarmType.includes('strategy_hit')) { dataAlarmGroupOption.push(3) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['strategy_hit'] || []) + if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['data_exception'] || []) } + // if (c.alarmType.includes('strategy_hit')) { + // dataAlarmGroupOption.push(3) + // if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['strategy_hit'] || []) + // } if (c.alarmType.includes('video_exception')) { let videoAlarmSubType = c.alarmSubType ? ( @@ -524,11 +527,11 @@ module.exports = function (app, opts) { }] }) : [] } - if (c.alarmType.includes('device_exception')) { - dataAlarmGroupOption.push(4) - dataAlarmGroupOption.push(5) - if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['device_exception']) - } + // if (c.alarmType.includes('device_exception')) { + // dataAlarmGroupOption.push(4) + // dataAlarmGroupOption.push(5) + // if (c.alarmSubType) dataAlarmSubType = dataAlarmSubType.concat(c.alarmSubType['device_exception']) + // } // 查数据告警 三警合一 if (dataAlarmGroupOption.length && searchStrucIds.length) { @@ -1125,9 +1128,9 @@ module.exports = function (app, opts) { } } } - dataAlarmG3.push(d) + dataAlarmG2.push(d) } else if (d.AlarmGroup == 4 || d.AlarmGroup == 5) { - dataAlarmG45.push(d) + // dataAlarmG45.push(d) } deviceStatistic.add(d.SourceId) @@ -1181,8 +1184,8 @@ module.exports = function (app, opts) { let dataAlarmG145Data = dataAlarms.filter(a => { return a.AlarmGroup == 1 - // || a.AlarmGroup == 4 - // || a.AlarmGroup == 5 + || a.AlarmGroup == 4 + || a.AlarmGroup == 5 }) pLog('数据中断', dataAlarmG145Data.length) if (dataAlarmG145Data.length) { @@ -1310,6 +1313,7 @@ module.exports = function (app, opts) { ...alarms, alarmId: SubDevice, sourceId: SubDevice, + below: true }) } } else { @@ -1386,51 +1390,71 @@ module.exports = function (app, opts) { // 处理那些没有被匹配到的告警信息 // 将设备没有绑定到测点的告警也推出去 + + let unmatchSourceId = [] + alarmDatas.forEach(d => { + if (!matchedAlarmIds.includes(d.alarmId)) { + unmatchSourceId.push(d.sourceId) + } + }) + + const alarmDaRes = await clickHouse.iot.query( + ` + SELECT + Device.id AS id, + Device.name AS name + FROM + Device + WHERE + Device.id IN (${[...unmatchSourceId, -1].map(d => `'${d}'`).join(',')}) ` + ).toPromise() || [] + for (let a of alarmDatas) { if (!matchedAlarmIds.includes(a.alarmId)) { + let deviceName = (alarmDaRes.find(d => d.id == a.sourceId) || {}).name pLog('未匹配到的告警 ' + a.alarmId) - // let curStruc = strucMap[a.StructureId] - // if (curStruc) { - // // curStruc 可以推出 告警属于哪个 project -> pomsProject - // let curProject = pepProject_name.filter(p => p.anxinProjectId && p.anxinProjectId.includes(curStruc.projectId)); - // for (let cp of curProject) { - // // cp.projects 是结构物信息 - // let curStruc = cp.projects.find(cpp => cpp.id == a.StructureId) - // if (!curStruc) { - // console.error(`没有查到结构物信息:${a.StructureId}?!不应该不应该!`); - // } else { - // // let emptyFactor = { id: -1 } - // let emptyFactor = curStruc.factor.find(f => f.id == -1) - // if (!emptyFactor) { - // curStruc.factor.push({ - // id: -1, - // devices: [{ - // alarmDatas: [ - // { ...a } - // ], - // iotaDeviceId: a.sourceId, - // name: a.SourceName, - // structureId: a.StructureId, - // }] - // }) - // } else { - // let curDevice = emptyFactor.devices.find(d => d.iotaDeviceId == a.sourceId) - // if (!curDevice) { - // emptyFactor.devices.push({ - // alarmDatas: [ - // { ...a } - // ], - // iotaDeviceId: a.sourceId, - // name: a.SourceName, - // structureId: a.StructureId, - // }) - // } else { - // curDevice.alarmDatas.push({ ...a }) - // } - // } - // } - // } - // } + let curStruc = strucMap[a.StructureId] + if (curStruc) { + // curStruc 可以推出 告警属于哪个 project -> pomsProject + let curProject = pepProject_name.filter(p => p.anxinProjectId && p.anxinProjectId.includes(curStruc.projectId)); + for (let cp of curProject) { + // cp.projects 是结构物信息 + let curStruc = cp.projects.find(cpp => cpp.id == a.StructureId) + if (!curStruc) { + console.error(`没有查到结构物信息:${a.StructureId}?!不应该不应该!`); + } else { + // let emptyFactor = { id: -1 } + let emptyFactor = curStruc.factor.find(f => f.id == -1) + if (!emptyFactor) { + curStruc.factor.push({ + id: -1, + devices: [{ + alarmDatas: [ + { ...a, SourceName: a.SourceName + (a.below ? ("(" + deviceName + ")") : "") } + ], + iotaDeviceId: a.sourceId, + name: a.SourceName, + structureId: a.StructureId, + }] + }) + } else { + let curDevice = emptyFactor.devices.find(d => d.iotaDeviceId == a.sourceId) + if (!curDevice) { + emptyFactor.devices.push({ + alarmDatas: [ + { ...a, SourceName: a.SourceName + (a.below ? ("(" + deviceName + ")") : "") } + ], + iotaDeviceId: a.sourceId, + name: a.SourceName, + structureId: a.StructureId, + }) + } else { + curDevice.alarmDatas.push({ ...a }) + } + } + } + } + } } } diff --git a/script/4.2/schema/1.exception_typ_check.sql b/script/4.2/schema/1.exception_typ_check.sql new file mode 100644 index 0000000..d126596 --- /dev/null +++ b/script/4.2/schema/1.exception_typ_check.sql @@ -0,0 +1,14 @@ +create table exception_type_check +( + id serial not null, + user_id int not null, + type_id integer[] +); + +create unique index exception_type_check_id_uindex + on exception_type_check (id); + +alter table exception_type_check + add constraint exception_type_check_pk + primary key (id); + diff --git a/web/client/src/layout/components/header/index.jsx b/web/client/src/layout/components/header/index.jsx index 3b36325..a2e15a9 100644 --- a/web/client/src/layout/components/header/index.jsx +++ b/web/client/src/layout/components/header/index.jsx @@ -63,7 +63,7 @@ const Header = (props) => { setCount(res.payload.data?.count) } }) - dispatch(problem.getAlarmDataGroup()) + dispatch(problem.getAlarmDataGroup({showAll:true})) } }, []) diff --git a/web/client/src/sections/control/components/alarm-chart.jsx b/web/client/src/sections/control/components/alarm-chart.jsx index 9a72a7e..c010493 100644 --- a/web/client/src/sections/control/components/alarm-chart.jsx +++ b/web/client/src/sections/control/components/alarm-chart.jsx @@ -239,63 +239,71 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so const behindHandle = (key) => { let show = [] switch (key) { - case '数据中断': - dispatch(problem.getAlarmDataGroup()).then((res) => { - if (res.success) { - let data = res.payload.data?.find(v => v.desc == '数据中断')?.unit || [] - let sumData = datumData?.filter(s => s.AlarmGroup == 1) || [] - data?.forEach(v => { - let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] - let untreated = dataList?.filter(s => s.State < 3)?.length || 0 - show.push({ - name: v.name, - untreated: untreated, - processed: dataList?.length - untreated, - num: dataList?.length - }) - }) - setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) - } - }) - break; + // case '数据中断': + // dispatch(problem.getAlarmDataGroup()).then((res) => { + // if (res.success) { + // let data = res.payload.data?.find(v => v.desc == '数据中断')?.unit || [] + // let sumData = datumData?.filter(s => s.AlarmGroup == 1) || [] + // data?.forEach(v => { + // let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] + // let untreated = dataList?.filter(s => s.State < 3)?.length || 0 + // show.push({ + // name: v.name, + // untreated: untreated, + // processed: dataList?.length - untreated, + // num: dataList?.length + // }) + // }) + // setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) + // } + // }) + // break; case '数据异常': - dispatch(problem.getAlarmDataGroup()).then((res) => { - if (res.success) { - let data = res.payload.data?.find(v => v.desc == '数据异常')?.unit || [] - let sumData = datumData?.filter(s => s.AlarmGroup == 2) || [] - data?.forEach(v => { - let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] - let untreated = dataList?.filter(s => s.State < 3)?.length || 0 - show.push({ - name: v.name, - untreated: untreated, - processed: dataList?.length - untreated, - num: dataList?.length - }) - }) - setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) - } - }) - break; - case '策略命中': - dispatch(problem.getAlarmDataGroup()).then((res) => { + dispatch(problem.getAlarmDataGroup()).then(async (res) => { if (res.success) { - let data = res.payload.data?.find(v => v.desc == '策略命中')?.unit || [] - let sumData = datumData?.filter(s => s.AlarmGroup == 3) || [] - data?.forEach(v => { - let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] - let untreated = dataList?.filter(s => s.State < 3)?.length || 0 - show.push({ - name: v.name, - untreated: untreated, - processed: dataList?.length - untreated, - num: dataList?.length - }) + let data2 = res.payload.data?.find(v => v.id == 2)?.unit || [] + let data3 = res.payload.data?.find(v => v.id == 3)?.unit || [] + let sumData = datumData?.filter(s => s.AlarmGroup == 2 || s.AlarmGroup == 3) || [] + console.log(111, datumData,); + + await dispatch(problem.getExceptionTypeCheck({ userId: user?.id, })).then(res => { + if (res.success) { + + [...data2, ...data3]?.filter(d => (res.payload.data?.typeId || [8, 40, 41, 48, 49]).includes(d.id))?.forEach(v => { + let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] + let untreated = dataList?.filter(s => s.State < 3)?.length || 0 + show.push({ + name: v.name, + untreated: untreated, + processed: dataList?.length - untreated, + num: dataList?.length + }) + }) + setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) + } }) - setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) } }) break; + // case '策略命中': + // dispatch(problem.getAlarmDataGroup()).then((res) => { + // if (res.success) { + // let data = res.payload.data?.find(v => v.desc == '策略命中')?.unit || [] + // let sumData = datumData?.filter(s => s.AlarmGroup == 3) || [] + // data?.forEach(v => { + // let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] + // let untreated = dataList?.filter(s => s.State < 3)?.length || 0 + // show.push({ + // name: v.name, + // untreated: untreated, + // processed: dataList?.length - untreated, + // num: dataList?.length + // }) + // }) + // setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) + // } + // }) + // break; case '视频异常': dispatch(problem.getAlarmVideoExceptionType()).then((res) => { if (res.success) { @@ -331,25 +339,25 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so }) setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) break; - case '设备异常': - dispatch(problem.getAlarmDataGroup()).then((res) => { - if (res.success) { - let data = res.payload.data?.find(v => v.desc == '掉线' || v.desc == '不活跃')?.unit || [] - let sumData = datumData?.filter(s => s.AlarmGroup == 4 || s.AlarmGroup == 5) || [] - data?.forEach(v => { - let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] - let untreated = dataList?.filter(s => s.State < 3)?.length || 0 - show.push({ - name: v.name, - untreated: untreated, - processed: dataList?.length - untreated, - num: dataList?.length - }) - }) - setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) - } - }) - break; + // case '设备异常': + // dispatch(problem.getAlarmDataGroup()).then((res) => { + // if (res.success) { + // let data = res.payload.data?.find(v => v.desc == '掉线' || v.desc == '不活跃')?.unit || [] + // let sumData = datumData?.filter(s => s.AlarmGroup == 4 || s.AlarmGroup == 5) || [] + // data?.forEach(v => { + // let dataList = sumData?.filter(s => s.AlarmGroupUnit == v.id) || [] + // let untreated = dataList?.filter(s => s.State < 3)?.length || 0 + // show.push({ + // name: v.name, + // untreated: untreated, + // processed: dataList?.length - untreated, + // num: dataList?.length + // }) + // }) + // setBehindShow(show.sort((a, b) => b.num - a.num)?.slice(0, 5) || []) + // } + // }) + // break; } setBehind(false) } @@ -406,27 +414,29 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
-
behindHandle('数据中段')}> +
behindHandle('数据中段')} + >
数据中断:
- {dataAlarm?.group1?.untreated || 0} / - {dataAlarm?.group1?.sum || 0} + {(dataAlarm?.group1?.untreated || 0) + (dataAlarm?.group4?.untreated || 0) + (dataAlarm?.group5?.untreated || 0)} / + {(dataAlarm?.group1?.sum || 0) + (dataAlarm?.group4?.sum || 0) + (dataAlarm?.group5?.sum || 0)}
behindHandle('数据异常')}>
数据异常:
- {dataAlarm?.group2?.untreated || 0} / - {dataAlarm?.group2?.sum || 0} + {(dataAlarm?.group2?.untreated || 0) + (dataAlarm?.group3?.untreated || 0)} / + {(dataAlarm?.group2?.sum || 0) + (dataAlarm?.group3?.sum || 0)}
-
behindHandle('策略命中')}> + {/*
behindHandle('策略命中')}>
策略命中:
{dataAlarm?.group3?.untreated || 0} / {dataAlarm?.group3?.sum || 0}
-
+
*/}
behindHandle('视频异常')}>
视频异常:
@@ -443,13 +453,13 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
-
behindHandle('设备异常')}> + {/*
behindHandle('设备异常')}>
设备异常:
{(dataAlarm?.group4?.untreated || 0) + (dataAlarm?.group5?.untreated || 0)} / {(dataAlarm?.group4?.sum || 0) + (dataAlarm?.group5?.sum || 0)}
-
+
*/}
diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index be2ee11..79175b0 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -161,7 +161,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject } } workbench.appSurplus += (workbench.appNewAdd - workbench.appConfirme) - workbench.toolSurplus += (workbench.toolNewAdd - workbench.toolConfirme) + workbench.videoSurplus += (workbench.videoNewAdd - workbench.videoConfirme) workbench.dataSurplus += (workbench.dataNewAdd - workbench.dataConfirme) setWorkData({ ...workbench }) @@ -203,7 +203,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject //初始化表格显示设置 let data = ['overall_new', 'workbench', 'statistical', 'analyse', 'dynamic'] - localStorage.getItem('overall')?localStorage.removeItem('overall'):"" + localStorage.getItem('overall') ? localStorage.removeItem('overall') : "" data.map(v => { localStorage.getItem(v) == null ? localStorage.setItem(v, JSON.stringify(show[v])) @@ -598,7 +598,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject { name: '关注的项目', sort: 1, key: 'project', data: workData?.projects || 0, img: 'url(/assets/images/console/lan_1.png)' }, { name: '数据告警', sort: 2, key: 'data', data: workData?.dataSurplus || 0, img: 'url(/assets/images/console/lv_1.png)', url: '/problem/dataAlarm/dataLnterrupt' }, { name: '应用告警', sort: 2, key: 'app', data: workData?.appSurplus || 0, img: 'url(/assets/images/console/hong_1.png)', url: '/problem/useAlarm/useAbnormal' }, - { name: '设备告警', sort: 2, key: 'device', data: workData?.toolSurplus || 0, img: 'url(/assets/images/console/hong_1.png)', url: '/problem/deviceAlarm/deviceAbnormal' }, + { name: '视频告警', sort: 2, key: 'device', data: workData?.videoSurplus || 0, img: 'url(/assets/images/console/hong_1.png)', url: '/problem/deviceAlarm/deviceAbnormal' }, { name: '项目里程碑', sort: 1, key: 'milestone', }, { name: '相关成员', sort: 2, key: 'personnel', }, @@ -700,7 +700,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject 剩余问题:
- {(workData?.appSurplus + workData?.dataSurplus + workData?.toolSurplus) || 0} + {(workData?.appSurplus + workData?.dataSurplus + workData.videoSurplus) || 0}
@@ -709,7 +709,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject
- {(workData?.appNewAdd + workData?.dataNewAdd + workData?.toolNewAdd) || 0} + {(workData?.appNewAdd + workData?.dataNewAdd + workData.dataNewAdd) || 0}
@@ -721,28 +721,29 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject 今日处理:
- {(workData?.appConfirme + workData?.dataConfirme + workData?.toolConfirme) || 0} + {(workData?.appConfirme + workData?.dataConfirme + workData.dataConfirme) || 0}
{/* 循环类型 */} {exhibition.current['workbench']?.map((item, index) => { - return ( + return item && ( pepProjectId && item.name == '关注的项目' ? '' :
{item.name} {item.name == '关注的项目' ? ' ( 个 )' : ' ( 条 )'} + {item.name == '关注的项目' ? '' : 待处理}
dispatch(push(item.url))} style={{ fontSize: 32, color: index == 0 ? '#0F7EFB' : index == 1 ? '#0091A1' : index == 2 ? '#FE9812' : '#FF7575', fontFamily: 'YouSheBiaoTiHei', cursor: 'pointer', }}>{item.data}
- {item.name == '关注的项目' ? '' :
待处理
} +
) - }) + }) || null }
diff --git a/web/client/src/sections/problem/actions/problem.jsx b/web/client/src/sections/problem/actions/problem.jsx index 9a4428a..07c7be0 100644 --- a/web/client/src/sections/problem/actions/problem.jsx +++ b/web/client/src/sections/problem/actions/problem.jsx @@ -184,3 +184,27 @@ export function getVcmpAuth () { //获取视频平台应用鉴权token reducer: { name: '' } }); } + +export function getExceptionTypeCheck (query = {}) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + query, + actionType: 'GET_VCMP_AUTH', + url: `${ApiTable.exceptionTypeCheck}`, + msg: { error: '获取用户的数据异常勾选信息' }, + reducer: { name: '' } + }); +} + +export function postExceptionTypeCheck (data = {}) { + return dispatch => basicAction({ + type: 'post', + dispatch: dispatch, + data, + actionType: 'POST_EXCEPTION_TYPE_CHECK', + url: `${ApiTable.exceptionTypeCheck}`, + msg: { option: '存储用户的数据异常勾选信息' }, + reducer: { name: '' } + }); +} \ No newline at end of file diff --git a/web/client/src/sections/problem/components/inspection.jsx b/web/client/src/sections/problem/components/inspection.jsx index b1bbb2d..4da182e 100644 --- a/web/client/src/sections/problem/components/inspection.jsx +++ b/web/client/src/sections/problem/components/inspection.jsx @@ -105,7 +105,6 @@ const Inspection = ({ dispatch, actions, user, route, statistic, pepProjectId })
{ - console.log(v.time) setCheckPatrol({ appId: v.appId, noted: v.noted, @@ -122,6 +121,7 @@ const Inspection = ({ dispatch, actions, user, route, statistic, pepProjectId }) }} getFormApi={(formApi) => (api.current = formApi)} layout="horizontal" + style={{ position: "relative", width: "100%", flex: 1, display: 'flex' }} > { const { problem } = actions @@ -19,6 +22,11 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe const groupId = useRef() let title = { dataLnterrupt: "数据中断详情", dataAbnormal: "数据异常详情", strategyHit: "策略命中详情", videoAbnormal: "视频异常详情", useAbnormal: "应用异常详情", deviceAbnormal: "设备异常详情" } const [exportUrl, setExportUrl] = useState('') + const [typeSet, setTypeSet] = useState(false) + const [typeId, setTypeId] = useState([]) + const [check, setCheck] = useState([]) + + useEffect(() => { switch (route) { case 'useAbnormal': @@ -82,8 +90,12 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe }) break; default: - if (genre?.length > 0) { - dispatch(problem.getAlarmDataList({...(route === 'deviceAbnormal' ? { timestamps: moment().valueOf() } : {}), ...query, ...search.current, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => { + if (genre?.length > 0 && (route === 'dataAbnormal' ? typeId?.length > 0 : true)) { + dispatch(problem.getAlarmDataList({ + ...(route === 'dataLnterrupt' ? { timestamps: true } : {}), + ...(route === 'dataAbnormal' ? { groupUnitId: typeId?.length > 0 ? typeId?.join(',') : "", } : {}), + ...query, ...(api.current?.getValues() || {}), groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId, + })).then((res) => { if (res.success) { setCount(res.payload.data?.count || 0) let tableDatas = res.payload.data?.rows?.map(v => ({ @@ -99,7 +111,7 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe SourceName: v.SourceName, AlarmGroupUnit: v.AlarmGroupUnit ? genre?.find(r => r.value == v.AlarmGroupUnit)?.name : "无", Strategy: v.AlarmGroupUnit ? genre?.find(r => r.value == v.AlarmGroupUnit)?.name : "", - type: route == 'deviceAbnormal' ? v.DeviceStatus == 0 ? "离线" : '' : v.AlarmGroupUnit ? genre?.find(r => r.value == v.AlarmGroupUnit)?.name : "", + type: (v.AlarmGroup == 4 || v.AlarmGroup == 5) ? v.DeviceStatus == 0 ? "离线" : '' : v.AlarmGroupUnit ? genre?.find(r => r.value == v.AlarmGroupUnit)?.name : "", cameraKindId: v.AlarmGroupUnit ? genre?.find(r => r.value == v.AlarmGroupUnit)?.name : "", AlarmCodeName: v.AlarmCodeName, CurrentLevel: v.CurrentLevel, @@ -108,8 +120,9 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe State: v.State, alarmType: v.alarmType, confirm: v.confirmedContent, - station: v.StructureLongitude && v.StructureLatitude ? v.StructureLongitude + '. ' + v.StructureLatitude : "", + station: v.StructureLongitude && v.StructureLatitude ? v.StructureLongitude + ',' + v.StructureLatitude : "", projectLocal: v.Project, + AlarmGroup: v.AlarmGroup, })) setTableData(tableDatas) } @@ -117,50 +130,61 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe } break; } - }, [query, genre, pepProjectId]) + }, [query, genre, pepProjectId,typeId]) useEffect(() => { - if (location) { - search.current = { ...search.current, ...location, state: 'new' } - api.current?.setValues({ ...location, state: 'new' }) - } - if (route !== 'videoAbnormal' && route !== 'useAbnormal') { - // dispatch(problem.getAlarmDataGroup()).then((res) => { - // if (res.success) { - let data - if (route == 'dataLnterrupt') data = alarmDataGroup?.filter(v => v.desc == '数据中断') - if (route == 'dataAbnormal') data = alarmDataGroup?.filter(v => v.desc == '数据异常') - if (route == 'strategyHit') data = alarmDataGroup?.filter(v => v.desc == '策略命中') - if (route == 'deviceAbnormal') data = alarmDataGroup?.filter(v => v.desc == '掉线' || v.desc == '不活跃') - groupId.current = data - let genreData = [] - data?.map(v => { - v?.unit?.map(vv => { - genreData.push({ name: vv.name, value: vv.id }) - }) + if (alarmDataGroup?.length > 0) { + if (location) { + search.current = { ...search.current, ...location, state: 'new' } + api.current?.setValues({ ...location, state: 'new' }) + } + if (route !== 'videoAbnormal' && route !== 'useAbnormal') { + let data + if (route == 'dataLnterrupt') data = alarmDataGroup?.filter(v => (v.desc == '数据中断' || v.desc == '掉线' || v.desc == '不活跃')) + if (route == 'dataAbnormal') data = alarmDataGroup?.filter(v => (v.desc == '数据异常' || v.desc == '策略命中')) + // if (route == 'strategyHit') data = alarmDataGroup?.filter(v => v.desc == '策略命中') + // if (route == 'deviceAbnormal') data = alarmDataGroup?.filter(v => v.desc == '掉线' || v.desc == '不活跃') + groupId.current = data + let genreData = [] + data?.map(v => { + v?.unit?.map(vv => { + genreData.push({ name: vv.name, value: vv.id }) + }) + }) + setGenre(genreData) + if (route == 'dataAbnormal') { + dispatch(problem.getExceptionTypeCheck({ userId: user?.id, })).then(res => { + if (res.success) { + setTypeId(res.payload.data?.typeId || [8, 40, 41, 48, 49]) + } }) - setGenre(genreData) - // } - // }) - } - if (route == 'useAbnormal') { - setGenre({ element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" }) - } - if (route == 'videoAbnormal') { - dispatch(problem.getAlarmVideoDeviceKind()).then((res) => { - if (res.success) { - kindName.current = res.payload.data.map(v => ({ name: v.kind, value: v.id })) - setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) - } - }) - dispatch(problem.getAlarmVideoExceptionType()).then((res) => { - if (res.success) { - setStatusId(res.payload.data.map(v => ({ name: v.describe, value: v.statusId }))) } - }) + } + if (route == 'useAbnormal') { + setGenre({ element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" }) + } + if (route == 'videoAbnormal') { + dispatch(problem.getAlarmVideoDeviceKind()).then((res) => { + if (res.success) { + kindName.current = res.payload.data.map(v => ({ name: v.kind, value: v.id })) + setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) + } + }) + dispatch(problem.getAlarmVideoExceptionType()).then((res) => { + if (res.success) { + setStatusId(res.payload.data.map(v => ({ name: v.describe, value: v.statusId }))) + } + }) + } + } + + return () => { + } - }, [route]) + + }, [route, alarmDataGroup]) + const handleExport = () => { let url = '' let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', statusId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current @@ -212,16 +236,16 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe }) break; default: - dispatch(problem.getAlarmDataList({...(route === 'deviceAbnormal' ? { timestamps: moment().valueOf() } : {}), ...query, ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => { + dispatch(problem.getAlarmDataList({ ...(route === 'dataLnterrupt' ? { timestamps: true } : {}), ...query, ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => { if (res.success) { if (res.payload.data.count) { let groups = { - "dataLnterrupt": "1", - "dataAbnormal": "2", - "strategyHit": "3", - "deviceAbnormal": "4,5" + "dataLnterrupt": "1,4,5", + "dataAbnormal": "2,3", + // "strategyHit": "3", + // "deviceAbnormal": "4,5" } - url = `alarm/data/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId}` + url = `alarm/data/list?token=${user.token}&toExport=1×tamp=${true}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId}` + `&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart}` + `&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}` setExportUrl(url); @@ -252,7 +276,8 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe onSubmit={(values) => console.log(values)} getFormApi={(formApi) => (api.current = formApi)} layout="horizontal" - style={{ position: "relative", width: "100%", flex: 1,display:'flex' }} + allowEmpty={false} + style={{ position: "relative", width: "100%", flex: 1, display: 'flex' }} > {(() => { let frame = [] @@ -278,26 +303,59 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe } } else { - frame.push( - {v.data?.map((item) => { - return ( - - {item.name} - - ); - })} - ) + if (route == 'dataAbnormal' && v.special) { + frame.push(
+ + {v.data?.filter(d => typeId?.includes(d.value))?.map((item) => { + return ( + + {item.name} + + ); + })} + + { + setCheck(typeId) + setTypeSet(true) + }} /> +
+ ) + } else { + frame.push( + {v.data?.map((item) => { + return ( + + {item.name} + + ); + })} + ) + + } + } }) frame.push( {(() => { - console.log((route == 'useAbnormal' || route == 'videoAbnormal') ? - (tableData?.slice(query.page * query.limit, (query.page + 1) * query.limit) || []) - : tableData); return v.id)) }, - + }} /> })()} @@ -472,9 +527,60 @@ const TableData = ({alarmDataGroup, route, dispatch, actions, collectData, setSe }} /> : ""} - + { + exportUrl ?