diff --git a/web/client/src/sections/control/components/alarm-chart.js b/web/client/src/sections/control/components/alarm-chart.js index d1dfd9d..99c6ce4 100644 --- a/web/client/src/sections/control/components/alarm-chart.js +++ b/web/client/src/sections/control/components/alarm-chart.js @@ -5,7 +5,6 @@ import { push } from 'react-router-redux'; import { Setup, OutHidden } from "$components"; import ReactECharts from 'echarts-for-react'; import moment from "moment"; -import SimpleBar from 'simplebar-react'; @@ -63,35 +62,14 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so setRadioStatistics('day') setRadioRank('day') setFaultId('') - - await dispatch(control.getStatisticOnline({ pepProjectId: pepProjectId })).then(res => { - if (res.success) { - setOnlineId('') - let data = res.payload.data - setOnlineStruc(data?.map(v => ({ value: v.strucId, label: v.strucName })) || []) - setOnline(data?.slice(0, 10) || []) - setValue(data?.map(v => v.strucId)?.slice(0, 10) || []) - } - }) - - await dispatch(control.getStrucSeries({ pepProjectId: pepProjectId })).then(res => { - if (res.success) { - setSuccessionId('') - setSeriesValue('') - let data = res.payload.data?.filter(s => !successionId || s?.struc?.pomsProject?.map(p => p.id)?.includes(successionId)) - setSeriesStruc(data?.map(v => ({ value: v.id, label: v.name })) || []) - setSeries(data?.slice(0, 10) || []) - setSensorList(data?.map(v => ({ value: v.id, label: v.name })) || []) - setSensorValue(data?.map(v => v.id)?.slice(0, 10) || []) - } - }) + let ProjectId = pepProjectId ? (pepProjectId?.length > 0 ? pepProjectId.split(",")[0] : pepProjectId) : projectPoms[0]?.id + await getStatisticOnline(ProjectId) //始终获取一个项目的数据 + await getStrucSeries(ProjectId) //始终获取一个项目的数据 if (pepProjectId) { setPomsList(projectPoms?.filter(v => v.pepProjectIsDelete != 1 && ((pepProjectId?.length > 0 ? pepProjectId.split(",")?.map(p => Number(p)) : [pepProjectId]).includes(v.id)))?.map(v => ({ value: v.id, label: v.pepProjectName || v.name }))) if (!pepProjectId?.length > 0 || pepProjectId.split(",")?.length == 1) { setFaultId(Number(pepProjectId)) - setOnlineId(Number(pepProjectId)) - setSuccessionId(Number(pepProjectId)) } } else { setPomsList(projectPoms?.filter(v => v.pepProjectIsDelete != 1)?.map(v => ({ value: v.id, label: v.pepProjectName || v.name }))) @@ -101,6 +79,42 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so }, [pepProjectId, projectPoms]) + //数据在线率 + const getStatisticOnline = async (id) => { + await dispatch(control.getStatisticOnline({ pepProjectId: id })).then(res => { + if (res.success) { + setOnlineId(Number(id)) + let data = res.payload.data + setOnlineStruc(data?.map(v => ({ value: v.strucId, label: v.strucName })) || []) + setOnline(data?.slice(0, 10) || []) + setValue(data?.map(v => v.strucId)?.slice(0, 10) || []) + } + }) + } + + //数据连续率 + const getStrucSeries = async (id) => { + await dispatch(control.getStrucSeries({ pepProjectId: id })).then(res => { + if (res.success) { + let data = res.payload.data + setSuccessionId(Number(id)) + let struc = [] + data?.forEach(f => { + if (!struc?.find(h => h.value == f.structure)) { + struc.push({ value: f.structure, label: f?.struc?.strucName }) + } + }) + setSeriesStruc(struc) + setSeriesValue(struc[0]?.value) + let findStruc = data?.filter(d => d.structure == struc[0]?.value) + setSeries(findStruc?.slice(0, 10) || []) + setSensorList(findStruc?.map(v => ({ value: v.id, label: v.name })) || []) + setSensorValue(findStruc?.map(v => v.id)?.slice(0, 10) || []) + } + }) + } + + const getRank = async (data) => { let dataList = [] @@ -615,18 +629,15 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so {/* 数据在线率 */}