diff --git a/api/app/lib/controllers/control/analysis.js b/api/app/lib/controllers/control/analysis.js index a6a2eaf..dac77da 100644 --- a/api/app/lib/controllers/control/analysis.js +++ b/api/app/lib/controllers/control/analysis.js @@ -744,11 +744,11 @@ async function getStrucSeries (ctx) { const { clickHouse } = ctx.app.fs const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs const { database: anxinyun } = clickHouse.anxinyun.opts.config - const { pepProjectId } = ctx.query + const { pepProjectId, strucId } = ctx.query let anxinStruc = await anxinStrucIdRange({ ctx, pepProjectId }) if (anxinStruc.length) { - const anxinStrucIds = anxinStruc.map(a => a.strucId) + const anxinStrucIds = [strucId ? strucId : anxinStruc[0].strucId] // 查在线率 const strucSeriesClient = ctx.app.fs.esclient.strucSeries @@ -818,10 +818,16 @@ async function getStrucSeries (ctx) { } ctx.status = 200; - ctx.body = sensor; + ctx.body = { + sensor: sensor || [], + anxinStruc: anxinStruc || [] + }; } else { ctx.status = 200; - ctx.body = []; + ctx.body = { + sensor: [], + anxinStruc: [] + }; } } catch (error) { diff --git a/web/client/src/sections/control/components/alarm-chart.js b/web/client/src/sections/control/components/alarm-chart.jsx similarity index 96% rename from web/client/src/sections/control/components/alarm-chart.js rename to web/client/src/sections/control/components/alarm-chart.jsx index 99c6ce4..e01728c 100644 --- a/web/client/src/sections/control/components/alarm-chart.js +++ b/web/client/src/sections/control/components/alarm-chart.jsx @@ -93,23 +93,19 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so } //数据连续率 - const getStrucSeries = async (id) => { - await dispatch(control.getStrucSeries({ pepProjectId: id })).then(res => { + const getStrucSeries = async (id, strucId) => { + await dispatch(control.getStrucSeries({ pepProjectId: id, strucId: strucId })).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) || []) + let data = res.payload.data?.sensor + let struc = res.payload.data?.anxinStruc?.map(s => ({ value: s.strucId, label: s?.strucName })) + if (!strucId) { + setSuccessionId(Number(id)) + setSeriesStruc(struc) + setSeriesValue(struc[0]?.value) + } + setSeries(data?.slice(0, 10) || []) + setSensorList(data?.map(v => ({ value: v.id, label: v.name })) || []) + setSensorValue(data?.map(v => v.id)?.slice(0, 10) || []) } }) } @@ -645,7 +641,7 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so optionList={onlineStruc} onChange={v => { setValue(v) - setOnline(statisticOnline?.filter(s => s.structure == v)) + setOnline(statisticOnline?.filter(s => !v.length > 0 || v.includes(s.strucId))) }} /> @@ -656,8 +652,8 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so text: '数据在线率', }, grid: { - left: 27, - right: 10, + left: 30, + right: 30, bottom: 20, }, tooltip: { @@ -718,12 +714,9 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so maxTagCount={1} style={{ width: 160, marginRight: 10 }} optionList={seriesStruc} - onChange={v => { + onChange={async v => { setSeriesValue(v) - let data = strucSeries?.filter(s => v == s.structure) - setSeries(data?.slice(0, 10) || []) - setSensorList(data?.map(v => ({ value: v.id, label: v.name })) || []) - setSensorValue(data?.slice(0, 10)?.map(d => d.id) || []) + await getStrucSeries(successionId, v) }} />