Browse Source

连续率优化修改

dev
wenlele 1 year ago
parent
commit
e6a9d6879a
  1. 14
      api/app/lib/controllers/control/analysis.js
  2. 47
      web/client/src/sections/control/components/alarm-chart.jsx

14
api/app/lib/controllers/control/analysis.js

@ -744,11 +744,11 @@ async function getStrucSeries (ctx) {
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs
const { database: anxinyun } = clickHouse.anxinyun.opts.config const { database: anxinyun } = clickHouse.anxinyun.opts.config
const { pepProjectId } = ctx.query const { pepProjectId, strucId } = ctx.query
let anxinStruc = await anxinStrucIdRange({ ctx, pepProjectId }) let anxinStruc = await anxinStrucIdRange({ ctx, pepProjectId })
if (anxinStruc.length) { if (anxinStruc.length) {
const anxinStrucIds = anxinStruc.map(a => a.strucId) const anxinStrucIds = [strucId ? strucId : anxinStruc[0].strucId]
// 查在线率 // 查在线率
const strucSeriesClient = ctx.app.fs.esclient.strucSeries const strucSeriesClient = ctx.app.fs.esclient.strucSeries
@ -818,10 +818,16 @@ async function getStrucSeries (ctx) {
} }
ctx.status = 200; ctx.status = 200;
ctx.body = sensor; ctx.body = {
sensor: sensor || [],
anxinStruc: anxinStruc || []
};
} else { } else {
ctx.status = 200; ctx.status = 200;
ctx.body = []; ctx.body = {
sensor: [],
anxinStruc: []
};
} }
} catch (error) { } catch (error) {

47
web/client/src/sections/control/components/alarm-chart.js → 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) => { const getStrucSeries = async (id, strucId) => {
await dispatch(control.getStrucSeries({ pepProjectId: id })).then(res => { await dispatch(control.getStrucSeries({ pepProjectId: id, strucId: strucId })).then(res => {
if (res.success) { if (res.success) {
let data = res.payload.data let data = res.payload.data?.sensor
setSuccessionId(Number(id)) let struc = res.payload.data?.anxinStruc?.map(s => ({ value: s.strucId, label: s?.strucName }))
let struc = [] if (!strucId) {
data?.forEach(f => { setSuccessionId(Number(id))
if (!struc?.find(h => h.value == f.structure)) { setSeriesStruc(struc)
struc.push({ value: f.structure, label: f?.struc?.strucName }) setSeriesValue(struc[0]?.value)
} }
}) setSeries(data?.slice(0, 10) || [])
setSeriesStruc(struc) setSensorList(data?.map(v => ({ value: v.id, label: v.name })) || [])
setSeriesValue(struc[0]?.value) setSensorValue(data?.map(v => v.id)?.slice(0, 10) || [])
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) || [])
} }
}) })
} }
@ -645,7 +641,7 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
optionList={onlineStruc} optionList={onlineStruc}
onChange={v => { onChange={v => {
setValue(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: '数据在线率', text: '数据在线率',
}, },
grid: { grid: {
left: 27, left: 30,
right: 10, right: 30,
bottom: 20, bottom: 20,
}, },
tooltip: { tooltip: {
@ -718,12 +714,9 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
maxTagCount={1} maxTagCount={1}
style={{ width: 160, marginRight: 10 }} style={{ width: 160, marginRight: 10 }}
optionList={seriesStruc} optionList={seriesStruc}
onChange={v => { onChange={async v => {
setSeriesValue(v) setSeriesValue(v)
let data = strucSeries?.filter(s => v == s.structure) await getStrucSeries(successionId, v)
setSeries(data?.slice(0, 10) || [])
setSensorList(data?.map(v => ({ value: v.id, label: v.name })) || [])
setSensorValue(data?.slice(0, 10)?.map(d => d.id) || [])
}} }}
/> />
<Select showClear <Select showClear
@ -736,7 +729,7 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
optionList={sensorList} optionList={sensorList}
onChange={v => { onChange={v => {
setSensorValue(v) setSensorValue(v)
let data = strucSeries?.filter(s => (!v.length > 0 || v.includes(s.id)) && seriesValue == s.structure) let data = strucSeries?.sensor?.filter(s => (!v.length > 0 || v.includes(s.id)) && seriesValue == s.structure)
setSeries(data || []) setSeries(data || [])
}} }}
/> />
@ -748,8 +741,8 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
text: '数据连续率', text: '数据连续率',
}, },
grid: { grid: {
left: 27, left: 30,
right: 10, right: 30,
bottom: 20, bottom: 20,
}, },
tooltip: { tooltip: {
Loading…
Cancel
Save