|
@@ -482,8 +482,13 @@ export function historyAnalysisPanel(data, section, extra = {}) {
|
|
|
const current = data || {}
|
|
const current = data || {}
|
|
|
const filter = extra.historyTypeFilter && typeof extra.historyTypeFilter === 'object' ? extra.historyTypeFilter : {}
|
|
const filter = extra.historyTypeFilter && typeof extra.historyTypeFilter === 'object' ? extra.historyTypeFilter : {}
|
|
|
const filterCode = typeof filter.code === 'string' ? filter.code.trim() : ''
|
|
const filterCode = typeof filter.code === 'string' ? filter.code.trim() : ''
|
|
|
|
|
+ const filterFamily = String(filter.family || '').toUpperCase()
|
|
|
const allEvents = Array.isArray(current.events) ? current.events : []
|
|
const allEvents = Array.isArray(current.events) ? current.events : []
|
|
|
- const events = filterCode ? allEvents.filter((item) => item && item.type === filterCode) : allEvents
|
|
|
|
|
|
|
+ const events = filterCode
|
|
|
|
|
+ ? allEvents.filter((item) => item && (filterFamily === EVENT_FAMILY.ALARM
|
|
|
|
|
+ ? String(item.name || '').trim() === filterCode
|
|
|
|
|
+ : item.type === filterCode))
|
|
|
|
|
+ : allEvents
|
|
|
const filtered = filterCode ? { ...current, events } : current
|
|
const filtered = filterCode ? { ...current, events } : current
|
|
|
const levelCounts = [1, 2, 3, 4].map((level) => ({
|
|
const levelCounts = [1, 2, 3, 4].map((level) => ({
|
|
|
code: String(level),
|
|
code: String(level),
|
|
@@ -1191,6 +1196,20 @@ function alarmEventTypeRows(current, family, extra) {
|
|
|
.map(([label, count]) => ({ code: label, label, count }))
|
|
.map(([label, count]) => ({ code: label, label, count }))
|
|
|
.sort((left, right) => right.count - left.count)
|
|
.sort((left, right) => right.count - left.count)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/** 预警族「按事件类型」以**同一份已加载历史行**聚合,避免 90 天多窗与后端 30 天窗口对不上。 */
|
|
|
|
|
+function historyEventTypeRows(events) {
|
|
|
|
|
+ if (!Array.isArray(events) || !events.length) return null
|
|
|
|
|
+ const counts = new Map()
|
|
|
|
|
+ for (const event of events) {
|
|
|
|
|
+ const code = String((event && event.type) || '').trim()
|
|
|
|
|
+ if (!code) continue
|
|
|
|
|
+ counts.set(code, (counts.get(code) || 0) + 1)
|
|
|
|
|
+ }
|
|
|
|
|
+ return [...counts.entries()]
|
|
|
|
|
+ .map(([code, count]) => ({ code, label: eventTypeText(code), count }))
|
|
|
|
|
+ .sort((left, right) => right.count - left.count)
|
|
|
|
|
+}
|
|
|
export function eventAnalysisPanel(data, section, extra) {
|
|
export function eventAnalysisPanel(data, section, extra) {
|
|
|
const current = data || {}
|
|
const current = data || {}
|
|
|
const family = current.family || (extra && extra.mode) || EVENT_FAMILY.WARNING
|
|
const family = current.family || (extra && extra.mode) || EVENT_FAMILY.WARNING
|
|
@@ -1207,14 +1226,16 @@ export function eventAnalysisPanel(data, section, extra) {
|
|
|
// 报警族的「按事件类型」改由事件行的 `eventName` 归类(后端对该族恒回未知桶);
|
|
// 报警族的「按事件类型」改由事件行的 `eventName` 归类(后端对该族恒回未知桶);
|
|
|
// 预警族仍用后端 EVENT_TYPE 桶(那套 `WARN-xxx` 码对预警是准的)。
|
|
// 预警族仍用后端 EVENT_TYPE 桶(那套 `WARN-xxx` 码对预警是准的)。
|
|
|
const alarmTypes = alarmEventTypeRows(current, family, extra)
|
|
const alarmTypes = alarmEventTypeRows(current, family, extra)
|
|
|
- const rawTypeRows = alarmTypes || current.types || []
|
|
|
|
|
|
|
+ const historyTypes = family === EVENT_FAMILY.WARNING ? historyEventTypeRows(extra && extra.historyEvents) : null
|
|
|
|
|
+ const rawTypeRows = historyTypes || alarmTypes || current.types || []
|
|
|
const historyFilter = extra && extra.historyTypeFilter && typeof extra.historyTypeFilter === 'object'
|
|
const historyFilter = extra && extra.historyTypeFilter && typeof extra.historyTypeFilter === 'object'
|
|
|
? extra.historyTypeFilter : {}
|
|
? extra.historyTypeFilter : {}
|
|
|
const historyTypeCode = typeof historyFilter.code === 'string' ? historyFilter.code.trim() : ''
|
|
const historyTypeCode = typeof historyFilter.code === 'string' ? historyFilter.code.trim() : ''
|
|
|
- // 预警族的类型排行可点:点击把类型写入历史分析的本地筛选;报警族没有预警类型码,不做假筛选。
|
|
|
|
|
- const typeRows = family === EVENT_FAMILY.WARNING
|
|
|
|
|
- ? rawTypeRows.map((row) => ({ ...row, selected: Boolean(historyTypeCode && row.code === historyTypeCode) }))
|
|
|
|
|
- : rawTypeRows
|
|
|
|
|
|
|
+ // 两族的类型排行都可点:点击把类型写入历史分析的本地筛选。
|
|
|
|
|
+ const typeRows = rawTypeRows.map((row) => ({
|
|
|
|
|
+ ...row,
|
|
|
|
|
+ selected: Boolean(historyTypeCode && row.code === historyTypeCode),
|
|
|
|
|
+ }))
|
|
|
return sectionView('eventAnalysis', section, [
|
|
return sectionView('eventAnalysis', section, [
|
|
|
// 2026-10-13 维护者反馈:条形图四连排视觉疲劳——类别少的构成改环形图(行业=行业色、
|
|
// 2026-10-13 维护者反馈:条形图四连排视觉疲劳——类别少的构成改环形图(行业=行业色、
|
|
|
// 类型=图表色序),等级/片区保留条形(条形适合作排名比较)。行业行保留联动。
|
|
// 类型=图表色序),等级/片区保留条形(条形适合作排名比较)。行业行保留联动。
|
|
@@ -1223,7 +1244,7 @@ export function eventAnalysisPanel(data, section, extra) {
|
|
|
// 维护者第 15 轮:类型是**多类别**,排行(由大到小)比环图更读得清;成因改堆叠条。
|
|
// 维护者第 15 轮:类型是**多类别**,排行(由大到小)比环图更读得清;成因改堆叠条。
|
|
|
rankingBarsBlock('按事件类型', sortByCountDesc(typeRows, (row) => row.count), {
|
|
rankingBarsBlock('按事件类型', sortByCountDesc(typeRows, (row) => row.count), {
|
|
|
limit: 0,
|
|
limit: 0,
|
|
|
- action: family === EVENT_FAMILY.WARNING ? 'historyType' : '',
|
|
|
|
|
|
|
+ action: 'historyType',
|
|
|
variant: 'rank',
|
|
variant: 'rank',
|
|
|
unit: '起',
|
|
unit: '起',
|
|
|
// 报警族的类别来自事件名称(后端对该族的 EVENT_TYPE 恒为未知桶),如实标注。
|
|
// 报警族的类别来自事件名称(后端对该族的 EVENT_TYPE 恒为未知桶),如实标注。
|