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..0b074c7 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() : [] @@ -77,14 +77,15 @@ 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(` - 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() : [] @@ -170,7 +171,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() : [] @@ -235,7 +236,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 @@ -296,7 +297,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 @@ -304,7 +305,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 a52223b..553c28d 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 ( @@ -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() : [] @@ -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..7361fbc 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 @@ -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 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 = [] 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) { 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 55984ef..3ee724e 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -45,6 +45,7 @@ const Control = (props) => { const [videoBI, setVideoBI] = useState([]); //查询BI分析数据-视频 const [appBI, setAppBI] = useState([]); //查询BI分析数据-应用 const [efficiencyBI, setEfficiencyBI] = useState({}); //查询BI分析数据-问题处置 + const [query, setQuery] = useState({ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' }); //最新动态 const [querydata1, setQueryData1] = useState([]); //最新动态数据 const [long, setLong] = useState(''); //最新动态设置 const [pomsList, setPomsList] = useState([]); //项目 @@ -57,7 +58,7 @@ const Control = (props) => { const exhibition = useRef({ workbench: [], statistical: [] }) //页面结构 const FormApi = useRef() const querydata = useRef([])//最新动态数据 - const query = useRef({ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' }) //最新动态 + // const query={ limit: 10, page: 0, projectCorrelationId: '', types: '1,2,3,4' } //最新动态 // websocket 使用测试 useEffect(() => { @@ -97,72 +98,6 @@ const Control = (props) => { }) } concentration2() - - const line = document.getElementById("line") - const news = document.getElementById("news") - if (line && news) { - news.onscroll = () => { - if ((line.clientHeight - 578) < news.scrollTop + 10) { - query.current = { ...query.current, page: query.current.page + 1 } - if (exhibition?.current?.dynamic?.length > 0) { - dispatch(control.getLatestDynamic({ ...query.current, projectCorrelationId: pepProjectId, page: query.current.page })).then(res => { - console.log(res.payload.data) - let branches = [...res.payload.data?.appear, ...res.payload.data?.confirm, ...res.payload.data?.notice] - if (branches?.length == 10) { - news.scrollTop = news.scrollTop - 640 - } - let data = querydata.current - if (res.success) { - if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { - res.payload.data?.appear?.map(v => data.push({ - seed: 'discovery', - project: v.projectName, - sources: v.alarmInfo?.sourceName, - type: v.type, - time: v.time, - id: v.id, - })) - } - if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) { - res.payload.data?.confirm?.map(v => data.push({ - seed: 'confirm', - project: v.projectName, - sources: v.alarmInfo?.source, - type: v.alarmInfo?.type, - time: v.confirmTime, - userName: v.userName, - id: v.id, - })) - } - if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { - res.payload.data?.notice?.map(v => data.push({ - seed: 'notice', - time: v.time, - project: v.projectName, - userName: v.userName?.map(u => u.name), - alarmPushConfig: v.alarmPushConfig?.name, - tactics: v.tactics, - interval: v.tacticsParams?.interval, - deviceProportion: v.tacticsParams?.deviceProportion, - id: v.id, - })) - } - data.sort((a, b) => { - if (moment(a.time).isBefore(b.time)) { - return 1 - } else { - return -1 - } - }) - console.log(data) - querydata.current = data - setQueryData1(data) - } - }) - } - } - } - } return () => { } @@ -235,12 +170,11 @@ const Control = (props) => { //查询最新动态 async function concentration3 () { if (exhibition?.current?.dynamic?.length > 0) { - let dynamicData = [1] - await dispatch(control.getLatestDynamic({ ...query.current, projectCorrelationId: pepProjectId })).then(res => { + console.log(query?.page); + await dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId })).then(res => { // console.log(res.payload.data); if (res.payload.data?.appear?.length || 0 + res.payload.data?.confirm?.length + res.payload.data?.notice?.length < 10) setASk(false) let data = [] - querydata.current = [] if (res.success) { if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { res.payload.data?.appear?.map(v => data.push({ @@ -293,7 +227,74 @@ const Control = (props) => { concentration3() }, [pepProjectId, exhibition.current]) + useEffect(() => { + const line = document.getElementById("line") + const news = document.getElementById("news") + if (line && news) { + news.onscroll = () => { + console.log(line.clientHeight) + console.log(news.clientHeight) + console.log(news.scrollTop) + if ((line.clientHeight - 578) < news.scrollTop + 10) { + setQuery({ ...query, page: query.page + 1 }) + if (exhibition?.current?.dynamic?.length > 0) { + dispatch(control.getLatestDynamic({ ...query, projectCorrelationId: pepProjectId, page: query.page + 1 })).then(res => { + console.log(res.payload.data) + news.scrollTop = news.scrollTop - 640 + let data = querydata.current + if (res.success) { + if (exhibition?.current?.dynamic?.find(v => v.key == 'discovery')) { + res.payload.data?.appear?.map(v => data.push({ + seed: 'discovery', + project: v.projectName, + sources: v.alarmInfo?.sourceName, + type: v.type, + time: v.time, + id: v.id, + })) + } + if (exhibition?.current?.dynamic?.find(v => v.key == 'confirm')) { + res.payload.data?.confirm?.map(v => data.push({ + seed: 'confirm', + project: v.projectName, + sources: v.alarmInfo?.source, + type: v.alarmInfo?.type, + time: v.confirmTime, + userName: v.userName, + id: v.id, + })) + } + if (exhibition?.current?.dynamic?.find(v => v.key == 'notice')) { + res.payload.data?.notice?.map(v => data.push({ + seed: 'notice', + time: v.time, + project: v.projectName, + userName: v.userName?.map(u => u.name), + alarmPushConfig: v.alarmPushConfig?.name, + tactics: v.tactics, + interval: v.tacticsParams?.interval, + deviceProportion: v.tacticsParams?.deviceProportion, + id: v.id, + })) + } + data.sort((a, b) => { + if (moment(a.time).isBefore(b.time)) { + return 1 + } else { + return -1 + } + }) + console.log(data) + querydata.current = data + setQueryData1(data) + } + }) + } + } + } + } + }, [query]) useEffect(() => {