From 972708bd01c9fc467334e5547436772a74de1aaf Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 18:30:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B3=A8=E9=87=8A=20websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sections/control/containers/control.jsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index 189e5df..625c0b2 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -60,18 +60,18 @@ const Control = (props) => { // websocket 使用测试 useEffect(() => { - if (socket) { - socket.on('alarmSendSocket', function (msg) { - // console.info(msg); - - // console.info(msg); - console.log(msg); - let a = msg; - }); - return () => { - socket.off("alarmSendSocket") - } - } + // if (socket) { + // socket.on('alarmSendSocket', function (msg) { + // // console.info(msg); + + // // console.info(msg); + // console.log(msg); + // let a = msg; + // }); + // return () => { + // socket.off("alarmSendSocket") + // } + // } }, [socket]) useEffect(() => { @@ -133,7 +133,7 @@ const Control = (props) => { } else { setProblemsList(res.payload.data) } - } + } }) // 统计概览--相关成员与web应用 await dispatch(control.getConsoleUser({ pepId: pepProjectId || projectId })).then(res => { From e2918aef00bca671eb604edfa883d5c7fd0cdff4 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 18:39:51 +0800 Subject: [PATCH 2/6] delete false use '0' --- api/app/lib/controllers/alarm/app.js | 2 +- api/app/lib/controllers/alarm/video.js | 2 +- api/app/lib/controllers/control/analysis.js | 8 ++++---- api/app/lib/controllers/control/data.js | 6 +++--- api/app/lib/controllers/control/toolLink.js | 2 +- api/app/lib/controllers/organization/index.js | 8 ++++---- api/app/lib/controllers/project/index.js | 4 ++-- api/app/lib/controllers/push/config.js | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index f49cf9c..03e8191 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -97,7 +97,7 @@ async function inspectionList(ctx) { } } let userPepRes = notedUserIds.size ? - await clickHouse.pepEmis.query(`SELECT DISTINCT user.id AS id, "user"."name" AS name FROM user WHERE user.id IN (${[...notedUserIds].join(',')})`).toPromise() : + await clickHouse.pepEmis.query(`SELECT DISTINCT user.id AS id, "user"."name" AS name FROM user WHERE user.id IN (${[...notedUserIds].join(',')}, -1)`).toPromise() : [] for (let ins of inspectionRes) { if (ins.notedPepUserId) { diff --git a/api/app/lib/controllers/alarm/video.js b/api/app/lib/controllers/alarm/video.js index efc5c14..323c456 100644 --- a/api/app/lib/controllers/alarm/video.js +++ b/api/app/lib/controllers/alarm/video.js @@ -122,7 +122,7 @@ async function alarmList(ctx) { LEFT JOIN vender ON vender.id = camera.vender_id WHERE - camera.delete = false + camera.delete = '0' AND camera.recycle_time is null ${statusAlarmWhereOption.length ? 'AND ' + statusAlarmWhereOption.join(' AND ') : ''} AND alarmId IN ( diff --git a/api/app/lib/controllers/control/analysis.js b/api/app/lib/controllers/control/analysis.js index 5d26317..d3e51b7 100644 --- a/api/app/lib/controllers/control/analysis.js +++ b/api/app/lib/controllers/control/analysis.js @@ -62,8 +62,8 @@ async function personnelApp (ctx) { LEFT JOIN department ON department.id=department_user.department WHERE - user.id IN (${[...userIds].join(',')}) - AND department.delete=false` + user.id IN (${[...userIds].join(',')}, -1) + AND department.delete='0'` ).toPromise() : [] @@ -84,7 +84,7 @@ async function personnelApp (ctx) { // 查对应的项企项目信息 let pepProjectRes = pepPojectIds.size ? await clickHouse.projectManage.query(` - SELECT id, project_name, isdelete FROM t_pim_project WHERE id IN (${[...pepPojectIds]}) + SELECT id, project_name, isdelete FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')}, -1) `).toPromise() : [] @@ -296,7 +296,7 @@ async function problem (ctx) { ON camera.serial_no = camera_status_alarm.serial_no AND camera.channel_no = camera_status_alarm.channel_no WHERE - camera.delete = false + camera.delete = '0' AND camera.recycle_time is null AND alarmId IN ( SELECT camera_status_alarm.id AS alarmId diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index a52223b..584830e 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -167,7 +167,7 @@ async function getVideoAlarmsAggDay(ctx) { ON camera.serial_no = camera_status_alarm.serial_no AND camera.channel_no = camera_status_alarm.channel_no WHERE - camera.delete = false + camera.delete = '0' AND camera.recycle_time is null ${statusAlarmWhereOption.length ? 'AND ' + statusAlarmWhereOption.join(' AND ') : ''} AND alarmId IN ( @@ -317,11 +317,11 @@ async function getLatestDynamic(ctx) { } } let pepProjects = pepPojectIds.size ? await clickHouse.projectManage.query(` - SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds]}) + SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')},-1) `).toPromise() : []; let userPepRes = notedUserIds.size ? await clickHouse.pepEmis.query( - `SELECT DISTINCT user.id AS id, "user"."name" AS name FROM user WHERE user.id IN (${[...notedUserIds].join(',')}) + `SELECT DISTINCT user.id AS id, "user"."name" AS name FROM user WHERE user.id IN (${[...notedUserIds].join(',')},-1) `).toPromise() : [] diff --git a/api/app/lib/controllers/control/toolLink.js b/api/app/lib/controllers/control/toolLink.js index 794bdfc..9b25d90 100644 --- a/api/app/lib/controllers/control/toolLink.js +++ b/api/app/lib/controllers/control/toolLink.js @@ -243,7 +243,7 @@ async function count (ctx) { LEFT JOIN vender ON vender.id = camera.vender_id WHERE - camera.delete = false + camera.delete = '0' AND camera.recycle_time is null AND alarmId IN ( SELECT camera_status_alarm.id AS alarmId diff --git a/api/app/lib/controllers/organization/index.js b/api/app/lib/controllers/organization/index.js index a742c49..1007c06 100644 --- a/api/app/lib/controllers/organization/index.js +++ b/api/app/lib/controllers/organization/index.js @@ -29,7 +29,7 @@ async function allUsers (ctx) { const userRes = await clickHouse.pepEmis.query(` SELECT id, name FROM user - WHERE delete = false + WHERE delete = '0' `).toPromise() ctx.status = 200; @@ -253,8 +253,8 @@ async function user (ctx) { LEFT JOIN department ON department.id=department_user.department WHERE - user.id IN (${[...userIds].join(',')}) - AND department.delete=false` + user.id IN (${[...userIds].join(',')},-1) + AND department.delete='0'` ).toPromise() : [] @@ -275,7 +275,7 @@ async function user (ctx) { // 查对应的项企项目信息 let pepProjectRes = pepPojectIds.size ? await clickHouse.projectManage.query(` - SELECT id, project_name, isdelete FROM t_pim_project WHERE id IN (${[...pepPojectIds]}) + SELECT id, project_name, isdelete FROM t_pim_project WHERE id IN (${[...pepPojectIds]},-1) `).toPromise() : [] diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 0abf675..fdf0630 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -76,14 +76,14 @@ async function pomsProject (ctx) { ON t_pim_project.id = t_pim_project_construction.project_id LEFT JOIN t_pim_project_state ON t_pim_project_construction.construction_status_id = t_pim_project_state.id - WHERE id IN (${[...pepProjectIds].join(',')}) + WHERE id IN (${[...pepProjectIds].join(',')}, -1) ` ).toPromise() : [] const anxinProjectRes = anxinProjectIds.size ? - await clickHouse.anxinyun.query(`SELECT id,"name",project_state AS projectState FROM t_project WHERE id IN (${[...anxinProjectIds].join(',')})`).toPromise() : + await clickHouse.anxinyun.query(`SELECT id,"name",project_state AS projectState FROM t_project WHERE id IN (${[...anxinProjectIds].join(',')},-1)`).toPromise() : [] diff --git a/api/app/lib/controllers/push/config.js b/api/app/lib/controllers/push/config.js index 8e64b37..f9fdfb2 100644 --- a/api/app/lib/controllers/push/config.js +++ b/api/app/lib/controllers/push/config.js @@ -80,7 +80,7 @@ async function list (ctx) { // 查配置所包含的所有结构物 const allStrucRes = allStrucIds.size ? await clickHouse.anxinyun.query(` SELECT id, name FROM t_structure - WHERE id IN (${[...allStrucIds].join(',')}) + WHERE id IN (${[...allStrucIds].join(',')}, -1) `).toPromise() : [] // 查所有配置的推送的次数 @@ -98,7 +98,7 @@ async function list (ctx) { // 查询所有的用户信息 const userRes = allReceiverIds.size ? await clickHouse.pepEmis.query(` SELECT id, name, delete FROM user - WHERE id IN (${[...allReceiverIds].join(',')}) + WHERE id IN (${[...allReceiverIds].join(',')}, -1) `).toPromise() : [] let returnD = [] From f2607fba24af6cd28e2d77b6d0e278d1f6361694 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 18:47:19 +0800 Subject: [PATCH 3/6] delete false use '0' --- api/app/lib/controllers/control/analysis.js | 2 +- api/app/lib/schedule/alarms_push.js | 2 +- api/app/lib/utils/alarmHandle.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/app/lib/controllers/control/analysis.js b/api/app/lib/controllers/control/analysis.js index d3e51b7..d052ce8 100644 --- a/api/app/lib/controllers/control/analysis.js +++ b/api/app/lib/controllers/control/analysis.js @@ -170,7 +170,7 @@ async function personnelApp (ctx) { ON t_pim_project.id = t_pim_project_construction.project_id LEFT JOIN t_pim_project_state ON t_pim_project_construction.construction_status_id = t_pim_project_state.id - WHERE id IN (${[...pepProjectIds].join(',')}) + WHERE id IN (${[...pepProjectIds].join(',')}, -1) ` ).toPromise() : [] diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index c7ff0ee..443ecac 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -48,7 +48,7 @@ module.exports = function (app, opts) { ON t_pim_project.id = t_pim_project_construction.project_id LEFT JOIN t_pim_project_state ON t_pim_project_construction.construction_status_id = t_pim_project_state.id - WHERE id IN (${[...pepProjectIds].join(',')}) + WHERE id IN (${[...pepProjectIds].join(',')}, -1) ` ).toPromise() : [] diff --git a/api/app/lib/utils/alarmHandle.js b/api/app/lib/utils/alarmHandle.js index f146d2b..7dec930 100644 --- a/api/app/lib/utils/alarmHandle.js +++ b/api/app/lib/utils/alarmHandle.js @@ -108,7 +108,8 @@ module.exports = function (app, opts) { } let pepProjects = pepPojectIds.size ? await clickHouse.projectManage.query(` - SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds]})`).toPromise() : []; + SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds]}, -1)` + ).toPromise() : []; return { projects, pepProjects }; } catch (err) { From bb02a6e6cad0bc9ce47de45986be7bddf821a701 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 18:54:12 +0800 Subject: [PATCH 4/6] delete false use '0' --- api/app/lib/controllers/control/analysis.js | 4 ++-- api/app/lib/controllers/control/data.js | 4 ++-- api/app/lib/controllers/control/toolLink.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/control/analysis.js b/api/app/lib/controllers/control/analysis.js index d052ce8..cf930ab 100644 --- a/api/app/lib/controllers/control/analysis.js +++ b/api/app/lib/controllers/control/analysis.js @@ -235,7 +235,7 @@ async function problem (ctx) { if (anxinStruc.length) { const anxinStrucIds = anxinStruc.map(a => a.strucId) - whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")})`) + whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")}, -1)`) const alarmRes = await clickHouse.dataAlarm.query(` SELECT AlarmId,State,AlarmGroup,AlarmGroupUnit,SourceName,StartTime,${anxinyun}.t_alarm_group_unit.name AS typeName @@ -304,7 +304,7 @@ async function problem (ctx) { RIGHT 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(',')})`} + ${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')}, -1)`} ) ${limit ? 'LIMIT ' + limit : ''} ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index 584830e..553c28d 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -176,7 +176,7 @@ async function getVideoAlarmsAggDay(ctx) { RIGHT 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(',')})`} + ${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')}, -1)`} ) ) AS cameraAlarm LEFT JOIN camera_status @@ -190,7 +190,7 @@ async function getVideoAlarmsAggDay(ctx) { AND anxinIpc.serial_no = cameraAlarm.cameraSerialNo LEFT JOIN ${anxinyun}.t_structure AS anxinStruc ON anxinStruc.id = anxinIpc.structure - AND anxinStruc.id IN (${anxinStrucIds.join(',')}) + AND anxinStruc.id IN (${anxinStrucIds.join(',')}, -1) LEFT JOIN ${anxinyun}.t_video_ipc_station AS anxinIpcStation ON anxinIpcStation.ipc = anxinIpc.id `).toPromise() : [] diff --git a/api/app/lib/controllers/control/toolLink.js b/api/app/lib/controllers/control/toolLink.js index 9b25d90..7361fbc 100644 --- a/api/app/lib/controllers/control/toolLink.js +++ b/api/app/lib/controllers/control/toolLink.js @@ -251,7 +251,7 @@ async function count (ctx) { RIGHT 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(',')})` + ${`WHERE ${anxinyun}.t_video_ipc.structure IN (${anxinStrucIds.join(',')}, -1)` } ) ) AS cameraAlarm @@ -267,7 +267,7 @@ async function count (ctx) { AND anxinIpc.serial_no = cameraAlarm.cameraSerialNo LEFT JOIN ${anxinyun}.t_structure AS anxinStruc ON anxinStruc.id = anxinIpc.structure - AND anxinStruc.id IN (${anxinStrucIds.join(',')}) + AND anxinStruc.id IN (${anxinStrucIds.join(',')}, -1) LEFT JOIN ${anxinyun}.t_video_ipc_station AS anxinIpcStation ON anxinIpcStation.ipc = anxinIpc.id LEFT JOIN ${anxinyun}.t_sensor AS anxinStation From 262a16bb8f87581eac4590efc23d4a050c786dd4 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 19:29:38 +0800 Subject: [PATCH 5/6] SELECT FROM t_pim_project --- api/app/lib/controllers/control/analysis.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/control/analysis.js b/api/app/lib/controllers/control/analysis.js index cf930ab..0b074c7 100644 --- a/api/app/lib/controllers/control/analysis.js +++ b/api/app/lib/controllers/control/analysis.js @@ -77,10 +77,11 @@ async function personnelApp (ctx) { // 获取响应的绑定的 项企项目的 id let pepPojectIds = new Set() for (let p of pomsProjectRes) { - if (p.pepProjectId) { + if (p.pepProjectId && !isNaN(p.pepProjectId)) { pepPojectIds.add(p.pepProjectId) } } + console.log([...pepPojectIds]); // 查对应的项企项目信息 let pepProjectRes = pepPojectIds.size ? await clickHouse.projectManage.query(` From 1eaf1d3115338a9cf7b963908cc14af7c8e09c5f Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 19:39:44 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B3=A8=E9=87=8A=20getConsoleCount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/client/src/layout/actions/webSocket.js | 20 +++++++++---------- .../sections/control/containers/control.jsx | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web/client/src/layout/actions/webSocket.js b/web/client/src/layout/actions/webSocket.js index d27ee01..ca1b6b7 100644 --- a/web/client/src/layout/actions/webSocket.js +++ b/web/client/src/layout/actions/webSocket.js @@ -22,19 +22,19 @@ export function initWebSocket ({ ioUrl, token, pomsUserId }) { } return dispatch => { - const socket = io( - ioUrl - // 'http://10.8.30.7:4000' - , { - query: { - token: token, - pomsUserId: pomsUserId - }, - }); + // const socket = io( + // ioUrl + // // 'http://10.8.30.7:4000' + // , { + // query: { + // token: token, + // pomsUserId: pomsUserId + // }, + // }); dispatch({ type: INIT_WEB_SOCKET, payload: { - socket: socket + socket:null// socket } }) } diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index 625c0b2..f7231a5 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -105,9 +105,9 @@ const Control = (props) => { if (pepProjectId) setProjectId(pepProjectId) if (!projectId) { // 工作台数据请求 - await dispatch(control.getConsoleCount({ pepProjectId: pepProjectId })).then(res => { - if (res.success) setWorkData(res.payload.data) - }) + // await dispatch(control.getConsoleCount({ pepProjectId: pepProjectId })).then(res => { + // if (res.success) setWorkData(res.payload.data) + // }) // 查询BI分析数据-数据 await dispatch(control.getDataAlarmsAggDay({ pepProjectId: pepProjectId })).then(res => { if (res.success) setDataBI(res.payload.data)