From 2f1921701812eca9f4b94c759063d976fe7fb1fc Mon Sep 17 00:00:00 2001 From: CODE <1650192445@qq.com> Date: Thu, 19 Oct 2023 10:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E5=91=8A=E8=AD=A6=E5=88=97=E8=A1=A8=E4=B8=8D=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/data.js | 46 +++++++++++-------- api/config.js | 14 +++--- .../sections/problem/components/tableData.jsx | 8 ++-- .../sections/problem/containers/dataAlarm.jsx | 11 +++-- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 9e1f9a1..af30048 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -126,7 +126,9 @@ async function list (ctx) { ${anxinyun}.t_structure.longitude AS StructureLongitude, ${anxinyun}.t_structure.latitude AS StructureLatitude, ${anxinyun}.t_alarm_code.name AS AlarmCodeName, - AlarmContent + AlarmContent, + Project, + AlarmCount AS detailCount ${alarmQueryOptionStr} ORDER BY alarms.StartTime DESC ${!toExport && limit ? 'LIMIT ' + limit : ''} @@ -163,19 +165,21 @@ async function list (ctx) { `).toPromise() : []; - const detailCountAlarm = alarmRes - .map(ar => "'" + ar.AlarmId + "'") - const alarmDetailCount = detailCountAlarm.length ? await clickHouse.dataAlarm.query(` - SELECT - count(Time) AS count, AlarmId - FROM - alarm_details - WHERE - AlarmId IN (${detailCountAlarm.join(',')}) - AND AlarmState < 3 - GROUP BY AlarmId - `).toPromise() : - [] + /** 231019 alarm 表有 AlarmCount 字段 , + * alarmDetailCount就不需要计算查询了 + */ + // const detailCountAlarm = alarmRes + // .map(ar => "'" + ar.AlarmId + "'") + // const alarmDetailCount = detailCountAlarm.length ? await clickHouse.dataAlarm.query(` + // SELECT + // count(Time) AS count, AlarmId + // FROM + // alarm_details + // WHERE + // AlarmId IN (${detailCountAlarm.join(',')}) + // AND AlarmState < 3 + // GROUP BY AlarmId + // `).toPromise() : [] alarmRes.forEach(ar => { @@ -194,8 +198,8 @@ async function list (ctx) { ar.confirmedContent = corConfirmedData.Content || 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) { @@ -321,10 +325,12 @@ async function detail (ctx) { ${limit ? 'LIMIT ' + limit : ''} ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} `).toPromise() - const count = await clickHouse.dataAlarm.query(` - SELECT count(*) AS count FROM alarm_details - WHERE AlarmId = '${alarmId}' - `).toPromise() + + // const count = await clickHouse.dataAlarm.query(` + // SELECT count(*) AS count FROM alarm_details + // WHERE AlarmId = '${alarmId}' + // `).toPromise() + ctx.status = 200; // ctx.body = { // count: count[0].count, diff --git a/api/config.js b/api/config.js index d13eb6c..15fde3c 100644 --- a/api/config.js +++ b/api/config.js @@ -196,7 +196,7 @@ const product = { camundarest: { host: FS_CAMUNDA_HOST, root: FS_CAMUNDA_ROOT - }, + }, exclude: [ // "*", { p: '/attachments/:p', o: 'POST' }, @@ -216,8 +216,8 @@ const product = { { p: '/project/group/statistic/alarm', o: 'GET' }, { p: '/project/group/list', o: 'GET' }, { p: '/project/group/:groupId/detail', o: 'GET' }, - {p:'/project/workOrders/repairRank',o:'GET'}, - {p:'/project/workOrders',o:'GET'} + { p: '/project/workOrders/repairRank', o: 'GET' }, + { p: '/project/workOrders', o: 'GET' } ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 apMergeDeVeAnxinProjectId: AP_MERGE_DEVE_ANXINPROJECT_ID, anxinCloud: { @@ -270,10 +270,10 @@ const product = { pssaRequest: [{// name 会作为一个 request 出现在 ctx.app.fs name: 'axyRequest', root: API_ANXINYUN_URL - },{ - name:'craw', - root:API_CRAW_URL, - dataWord:'text' + }, { + name: 'craw', + root: API_CRAW_URL, + dataWord: 'text' }, { name: 'emisRequest', root: API_EMIS_URL diff --git a/web/client/src/sections/problem/components/tableData.jsx b/web/client/src/sections/problem/components/tableData.jsx index c07b746..d498b77 100644 --- a/web/client/src/sections/problem/components/tableData.jsx +++ b/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 { SkeletonScreen, } from "$components"; 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, 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] : "", confirm: v.confirm, confirmAuto: v.confirmAuto, + projectLocal: v.Project, })) setCount(tableDatas?.length || 0); setTableData(tableDatas) @@ -76,6 +72,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition confirm: v.confirmContent, camerOnline: v.camerOnline, autoRestore: v.autoRestore, + projectLocal: v.Project, })) setCount(tableDatas?.length || 0); setTableData(tableDatas) @@ -109,6 +106,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition alarmType: v.alarmType, confirm: v.confirmedContent, station: v.StructureLongitude && v.StructureLatitude ? v.StructureLongitude + '. ' + v.StructureLatitude : "", + projectLocal: v.Project, })) setTableData(tableDatas) } diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx index fbbe8f2..daff70d 100644 --- a/web/client/src/sections/problem/containers/dataAlarm.jsx +++ b/web/client/src/sections/problem/containers/dataAlarm.jsx @@ -310,10 +310,11 @@ const DataAlarm = (props) => { name: '操作', sort: 25, value: 'text', render: (_, r, index) => { return