Browse Source

连续率优化修改

dev
wenlele 1 year ago
parent
commit
e6a9d6879a
  1. 14
      api/app/lib/controllers/control/analysis.js
  2. 41
      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 { 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) {

41
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) => {
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
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))
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) || [])
}
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)
}}
/>
<Select showClear
@ -736,7 +729,7 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
optionList={sensorList}
onChange={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 || [])
}}
/>
@ -748,8 +741,8 @@ const AlarmChart = ({ dispatch, actions, user, history, projectPoms, loading, so
text: '数据连续率',
},
grid: {
left: 27,
right: 10,
left: 30,
right: 30,
bottom: 20,
},
tooltip: {
Loading…
Cancel
Save