wenlele 2 years ago
parent
commit
eb1b9bc4dc
  1. 2
      api/app/lib/controllers/alarm/app.js
  2. 2
      api/app/lib/controllers/alarm/video.js
  3. 17
      api/app/lib/controllers/control/analysis.js
  4. 10
      api/app/lib/controllers/control/data.js
  5. 6
      api/app/lib/controllers/control/toolLink.js
  6. 8
      api/app/lib/controllers/organization/index.js
  7. 4
      api/app/lib/controllers/project/index.js
  8. 4
      api/app/lib/controllers/push/config.js
  9. 2
      api/app/lib/schedule/alarms_push.js
  10. 3
      api/app/lib/utils/alarmHandle.js
  11. 20
      web/client/src/layout/actions/webSocket.js
  12. 141
      web/client/src/sections/control/containers/control.jsx

2
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) {

2
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 (

17
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) : ''}

10
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() : []

6
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

8
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() :
[]

4
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() :
[]

4
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 = []

2
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() :
[]

3
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) {

20
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
}
})
}

141
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(() => {

Loading…
Cancel
Save