From 23ae9981f632e08e9ddcf113d5f31123e4b41d7b Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 27 Sep 2022 21:10:09 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sections/problem/components/sideSheet.jsx | 146 +++++++++--------- .../sections/problem/components/tableData.jsx | 7 +- .../sections/problem/containers/dataAlarm.jsx | 30 +++- 3 files changed, 100 insertions(+), 83 deletions(-) diff --git a/web/client/src/sections/problem/components/sideSheet.jsx b/web/client/src/sections/problem/components/sideSheet.jsx index cad182b..98cbb80 100644 --- a/web/client/src/sections/problem/components/sideSheet.jsx +++ b/web/client/src/sections/problem/components/sideSheet.jsx @@ -8,7 +8,7 @@ import ReactECharts from 'echarts-for-react'; let projectScrollbar; -function SideSheets ({ dispatch, actions, close }) { +function SideSheets ({ dispatch, actions, close, alarmId }) { const { problem } = actions; const [clickStyle, setclickStyle] = useState(); @@ -19,72 +19,75 @@ function SideSheets ({ dispatch, actions, close }) { useEffect(() => { - dispatch(problem.getAlarmDataDetail({ alarmId: "fa7fd145-f251-3657-8176-8f8f04a92a96" })).then((res) => { - if (res?.success) { - console.log(res.payload.data); - setdataSource(res.payload.data); - projectScrollbar = new PerfectScrollbar("#Alarm", { - suppressScrollX: true, - }); - } - }); - dispatch(problem.getAlarmDataDetailAgg({ alarmId: "fa7fd145-f251-3657-8176-8f8f04a92a96" })).then((res) => { - if (res?.success) { - let dataSort = res.payload.data || [] - console.log(dataSort); - // moment.duration(videoAfter?.diff(videoFront))._data.milliseconds; - dataSort.sort((a, b) => { - if (moment(a.hours).isBefore(b.hours)) { - return -1 - } else { - return 1 - } - }) - console.log(dataSort); - let data = { - dataZoom: [ - { - show: true, - type: 'inside', - filterMode: 'none', - xAxisIndex: [0], - }, - { - show: true, - type: 'inside', - filterMode: 'none', - yAxisIndex: [0], - } - ], - tooltip: { - trigger: 'axis' - }, - - xAxis: { - type: 'category', - name: "时间", - data: dataSort.map(v => v.hours) - }, - yAxis: { - type: 'value', - name: "次数", - }, - series: [ - { - data: dataSort.map(v => v.count), - type: 'line', - name: '次数', - // markLine: { - // data: [{ type: 'average', name: 'Avg' }] - // } + if (alarmId) { + dispatch(problem.getAlarmDataDetail({ alarmId: alarmId })).then((res) => { + if (res?.success) { + console.log(res.payload.data); + setdataSource(res.payload.data); + projectScrollbar = new PerfectScrollbar("#Alarm", { + suppressScrollX: true, + }); + } + }); + dispatch(problem.getAlarmDataDetailAgg({ alarmId: alarmId })).then((res) => { + if (res?.success) { + let dataSort = res.payload.data || [] + // console.log(dataSort); + // moment.duration(videoAfter?.diff(videoFront))._data.milliseconds; + dataSort.sort((a, b) => { + if (moment(a.hours).isBefore(b.hours)) { + return -1 + } else { + return 1 } - ] + }) + // console.log(dataSort); + let data = { + dataZoom: [ + { + show: true, + type: 'inside', + filterMode: 'none', + xAxisIndex: [0], + }, + { + show: true, + type: 'inside', + filterMode: 'none', + yAxisIndex: [0], + } + ], + tooltip: { + trigger: 'axis' + }, + + xAxis: { + type: 'category', + name: "时间", + data: dataSort.map(v => v.hours) + }, + yAxis: { + type: 'value', + name: "次数", + }, + series: [ + { + data: dataSort.map(v => v.count), + type: 'line', + name: '次数', + // markLine: { + // data: [{ type: 'average', name: 'Avg' }] + // } + } + ] + } + // console.log(data); + setOption(data) + // setNvrDetails(res.payload.data); } - console.log(data); - setOption(data) - // setNvrDetails(res.payload.data); - } - }); + }); + } + }, []); @@ -102,7 +105,7 @@ function SideSheets ({ dispatch, actions, close }) { rowKey: 'AlarmState', render: (_, r, index) => { let data = { 0: '首次产生', 1: '持续产生', 2: '等级提升', 3: '自动恢复', 4: '人工恢复' } - return data[r.AlarmState] + return data[r.AlarmState] || '' }, }, { title: "告警信息", @@ -114,13 +117,13 @@ function SideSheets ({ dispatch, actions, close }) { rowKey: 'CurrentLevel', render: (_, r, index) => { let data = { 1: '一级', 2: '二级', 3: '三级' } - return data[r.CurrentLevel] + return data[r.CurrentLevel] || "" }, }, { title: "产生时间", dataIndex: "Time", rowKey: 'Time', - render: (_, r, index) => r.Time?moment(r.Time).format("YYYY-MM-DD HH:mm:ss"):"" + render: (_, r, index) => r.Time ? moment(r.Time).format("YYYY-MM-DD HH:mm:ss") : "" }, ] @@ -152,7 +155,7 @@ function SideSheets ({ dispatch, actions, close }) { } }} /> -
+ {dataSource?.length > 0 ?
共{dataSource?.length || 0}条告警 @@ -167,7 +170,7 @@ function SideSheets ({ dispatch, actions, close }) { setQuery({ pageSize: pageSize, page: currentPage }); }} /> -
+
: ""} +
开发中,敬请期待!
- + ); } diff --git a/web/client/src/sections/problem/components/tableData.jsx b/web/client/src/sections/problem/components/tableData.jsx index 7efd37c..094e2f9 100644 --- a/web/client/src/sections/problem/components/tableData.jsx +++ b/web/client/src/sections/problem/components/tableData.jsx @@ -67,7 +67,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition // console.log(genreData); setGenre(genreData) if (data && data[0]?.id) { - dispatch(problem.getAlarmDataList({ ...query, ...search, groupId: '', pepProjectId: '' })).then((res) => { + dispatch(problem.getAlarmDataList({ ...query, ...search, groupId: data.map(v => v.id).join(), pepProjectId: '' })).then((res) => { console.log(res); if (res.success) { setCount(res.payload.data?.count || 0) @@ -75,13 +75,12 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition key: v.AlarmId, StructureName: v.StructureName, projectName: v.pepProject?.map(r => r.projectName)?.filter(c => c), - createTime: v.StartTime ? moment(v.StartTime).format("YYYY-MM-DD HH:mm:ss") : "", updateTime: v.EndTime ? moment(v.EndTime).format("YYYY-MM-DD HH:mm:ss") : "", confirmTime: v.confirmedTime ? moment(v.confirmedTime).format("YYYY-MM-DD HH:mm:ss") : "", SourceName: v.SourceName, AlarmGroupUnit: v.AlarmGroupUnit ? genreData.find(r => r.id == v.AlarmGroupUnit)?.name : "", - Strategy: v.AlarmGroupUnit ? genreData.find(r => r.id == v.AlarmGroupUnit)?.name : "", + Strategy: v.AlarmGroupUnit ? genreData[0]?.unit?.find(r => r.id == v.AlarmGroupUnit)?.name : "", type: v.AlarmGroupUnit ? genreData.find(r => r.id == v.AlarmGroupUnit)?.name : "", AlarmCodeName: v.AlarmCodeName, CurrentLevel: v.CurrentLevel, @@ -267,7 +266,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition } setCheckAll(!checkAll) }} - style={{ width: 93, height: 24, borderRadius: '1px', border: '1px solid #0F7EFB', color: '#0F7EFB',background:"#FFFFFF", fontWeight: 400, margin: '0 10px' }}> + style={{ width: 93, height: 24, borderRadius: '1px', border: '1px solid #0F7EFB', color: '#0F7EFB', background: "#FFFFFF", fontWeight: 400, margin: '0 10px' }}> {checkAll ? '全选' : "取消全选"} diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx index 8cf26dc..57baf2b 100644 --- a/web/client/src/sections/problem/containers/dataAlarm.jsx +++ b/web/client/src/sections/problem/containers/dataAlarm.jsx @@ -37,7 +37,6 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { if (route) { //初始化表格显示设置 let data = columns[route] - data.splice(0, 1) localStorage.getItem(tableType[route]) == null ? localStorage.setItem( tableType[route], @@ -145,7 +144,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { dataLnterrupt: ['index', 'projectName', 'StructureName', 'SourceName', 'AlarmGroupUnit', 'AlarmCodeName', 'createTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime',], dataAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'type', 'alarmType', 'createTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'], strategyHit: ['index', 'projectName', 'StructureName', 'SourceName', 'Strategy', 'State', 'createTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'], - videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', '19', '20', '21', '22', 'AlarmContent', '111', 'createTime', 'updateTime', 'confirm', 'confirmTime','56115'], + videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', '19', '20', '21', '22', 'AlarmContent', '111', 'createTime', 'updateTime', 'confirm', 'confirmTime', '56115'], useAbnormal: ['index', 'projectName', 'appName', 'url', 'type', 'alarmContent', 'createTime', 'updateTime', 'confirm', 'confirmTime'], deviceAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', '19', 'alarmContent', '21', 'AlarmContent', 'AlarmCodeName', 'createTime', 'updateTime', 'confirm', 'confirmTime'], } @@ -211,7 +210,18 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { } }, { name: '结构物名称', value: 'StructureName' }, - { name: '告警源', value: 'SourceName' }, + { + name: '告警源', value: 'SourceName', render: (_, r, index) => { + // let data = '' + // if (route == 'dataLnterrupt' || route == 'dataAbnormal') { + // data = '传感器' + // } + // if (route == 'strategyHit') data = '测点' + return <> + {/*
{data}
*/} + {r.SourceName} + } + }, { name: '中断类型', value: 'AlarmGroupUnit' }, { name: '告警信息', value: 'AlarmContent' }, { name: '常见原因', value: 'AlarmCodeName' }, @@ -224,7 +234,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { return data[r.CurrentLevel] } }, - { name: '产生次数', value: 'detailCount' }, + { name: '产生次数', value: 'detailCount', render: (_, r, index) => r.detailCount + '次' }, { name: '确认信息', value: 'confirm', render: (_, r, index) => r.confirm }, { name: '确认/恢复时间', value: 'confirmTime', }, { @@ -250,9 +260,9 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { { name: '接入方式', value: '22' }, { name: '应用名称', value: 'appName' }, { name: 'URL地址', value: 'url' }, - {name: '异常类型', value: 'type'}, - {name: '解决方案', value: '111'}, - {name: '在离线', value: '56115'}, + { name: '异常类型', value: 'type' }, + { name: '解决方案', value: '111' }, + { name: '在离线', value: '56115' }, ] @@ -297,7 +307,10 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { } {route ? ['dataLnterrupt', 'dataAbnormal', 'strategyHit'].includes(route) ? <> - + : "" : "" } @@ -415,6 +428,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { {checkPop ? { setCheckPop(false) }}