Browse Source

本地化项目的告警列表不展示操作

dev
CODE 1 year ago
parent
commit
2f19217018
  1. 46
      api/app/lib/controllers/alarm/data.js
  2. 8
      web/client/src/sections/problem/components/tableData.jsx
  3. 3
      web/client/src/sections/problem/containers/dataAlarm.jsx

46
api/app/lib/controllers/alarm/data.js

@ -126,7 +126,9 @@ async function list (ctx) {
${anxinyun}.t_structure.longitude AS StructureLongitude, ${anxinyun}.t_structure.longitude AS StructureLongitude,
${anxinyun}.t_structure.latitude AS StructureLatitude, ${anxinyun}.t_structure.latitude AS StructureLatitude,
${anxinyun}.t_alarm_code.name AS AlarmCodeName, ${anxinyun}.t_alarm_code.name AS AlarmCodeName,
AlarmContent AlarmContent,
Project,
AlarmCount AS detailCount
${alarmQueryOptionStr} ${alarmQueryOptionStr}
ORDER BY alarms.StartTime DESC ORDER BY alarms.StartTime DESC
${!toExport && limit ? 'LIMIT ' + limit : ''} ${!toExport && limit ? 'LIMIT ' + limit : ''}
@ -163,19 +165,21 @@ async function list (ctx) {
`).toPromise() : `).toPromise() :
[]; [];
const detailCountAlarm = alarmRes /** 231019 alarm AlarmCount
.map(ar => "'" + ar.AlarmId + "'") * alarmDetailCount就不需要计算查询了
const alarmDetailCount = detailCountAlarm.length ? await clickHouse.dataAlarm.query(` */
SELECT // const detailCountAlarm = alarmRes
count(Time) AS count, AlarmId // .map(ar => "'" + ar.AlarmId + "'")
FROM // const alarmDetailCount = detailCountAlarm.length ? await clickHouse.dataAlarm.query(`
alarm_details // SELECT
WHERE // count(Time) AS count, AlarmId
AlarmId IN (${detailCountAlarm.join(',')}) // FROM
AND AlarmState < 3 // alarm_details
GROUP BY AlarmId // WHERE
`).toPromise() : // AlarmId IN (${detailCountAlarm.join(',')})
[] // AND AlarmState < 3
// GROUP BY AlarmId
// `).toPromise() : []
alarmRes.forEach(ar => { alarmRes.forEach(ar => {
@ -194,8 +198,8 @@ async function list (ctx) {
ar.confirmedContent = corConfirmedData.Content || null ar.confirmedContent = corConfirmedData.Content || null
ar.confirmedTime = corConfirmedData.Time || null ar.confirmedTime = corConfirmedData.Time || null
// 告警详情的数量 // // 告警详情的数量
ar.detailCount = (alarmDetailCount.find(adc => adc.AlarmId == ar.AlarmId) || { count: 0 }).count // ar.detailCount = (alarmDetailCount.find(adc => adc.AlarmId == ar.AlarmId) || { count: 0 }).count
}) })
if (toExport) { if (toExport) {
@ -321,10 +325,12 @@ async function detail (ctx) {
${limit ? 'LIMIT ' + limit : ''} ${limit ? 'LIMIT ' + limit : ''}
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''}
`).toPromise() `).toPromise()
const count = await clickHouse.dataAlarm.query(`
SELECT count(*) AS count FROM alarm_details // const count = await clickHouse.dataAlarm.query(`
WHERE AlarmId = '${alarmId}' // SELECT count(*) AS count FROM alarm_details
`).toPromise() // WHERE AlarmId = '${alarmId}'
// `).toPromise()
ctx.status = 200; ctx.status = 200;
// ctx.body = { // ctx.body = {
// count: count[0].count, // count: count[0].count,

8
web/client/src/sections/problem/components/tableData.jsx

@ -3,11 +3,6 @@ import { connect } from "react-redux";
import { Button, Form, Modal, Skeleton, Pagination, Table, Tooltip, Toast } from "@douyinfe/semi-ui"; import { Button, Form, Modal, Skeleton, Pagination, Table, Tooltip, Toast } from "@douyinfe/semi-ui";
import { SkeletonScreen, } from "$components"; import { SkeletonScreen, } from "$components";
import moment from "moment"; import moment from "moment";
import { validate } from "schema-utils";
import { emit } from "superagent";
import qs from "qs";
const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId,
selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user, statusId, setStatusId }) => { selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user, statusId, setStatusId }) => {
@ -45,6 +40,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
type: v.type ? typeData[v.type] : "", type: v.type ? typeData[v.type] : "",
confirm: v.confirm, confirm: v.confirm,
confirmAuto: v.confirmAuto, confirmAuto: v.confirmAuto,
projectLocal: v.Project,
})) }))
setCount(tableDatas?.length || 0); setCount(tableDatas?.length || 0);
setTableData(tableDatas) setTableData(tableDatas)
@ -76,6 +72,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
confirm: v.confirmContent, confirm: v.confirmContent,
camerOnline: v.camerOnline, camerOnline: v.camerOnline,
autoRestore: v.autoRestore, autoRestore: v.autoRestore,
projectLocal: v.Project,
})) }))
setCount(tableDatas?.length || 0); setCount(tableDatas?.length || 0);
setTableData(tableDatas) setTableData(tableDatas)
@ -109,6 +106,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
alarmType: v.alarmType, alarmType: v.alarmType,
confirm: v.confirmedContent, confirm: v.confirmedContent,
station: v.StructureLongitude && v.StructureLatitude ? v.StructureLongitude + '. ' + v.StructureLatitude : "", station: v.StructureLongitude && v.StructureLatitude ? v.StructureLongitude + '. ' + v.StructureLatitude : "",
projectLocal: v.Project,
})) }))
setTableData(tableDatas) setTableData(tableDatas)
} }

3
web/client/src/sections/problem/containers/dataAlarm.jsx

@ -310,6 +310,7 @@ const DataAlarm = (props) => {
name: '操作', sort: 25, value: 'text', render: (_, r, index) => { name: '操作', sort: 25, value: 'text', render: (_, r, index) => {
return <div style={{ width: 195 }}> return <div style={{ width: 195 }}>
{r.State < 3 || route && ['videoAbnormal', 'useAbnormal'].includes(route) && !r.confirmTime ? {r.State < 3 || route && ['videoAbnormal', 'useAbnormal'].includes(route) && !r.confirmTime ?
r.projectLocal ? '' :
<Button theme='borderless' style={{ width: 65 }} onClick={() => { <Button theme='borderless' style={{ width: 65 }} onClick={() => {
setConfirm(true) setConfirm(true)
setSelected([r.id]) setSelected([r.id])
@ -344,7 +345,7 @@ const DataAlarm = (props) => {
let arr = localStorage.getItem(name) let arr = localStorage.getItem(name)
? JSON.parse(localStorage.getItem(name)) ? JSON.parse(localStorage.getItem(name))
: []; : [];
// console.log(arr);
if (route) { if (route) {
let setup = tableList[route].map(v => columnAll.find(vv => v == vv.value)) let setup = tableList[route].map(v => columnAll.find(vv => v == vv.value))

Loading…
Cancel
Save