|
@@ -8,7 +8,7 @@
|
|
|
import { MAP_OBJECT_KIND } from './mapSummary.js'
|
|
import { MAP_OBJECT_KIND } from './mapSummary.js'
|
|
|
import { planPointMarkers, pointLegend } from './pointStatus.js'
|
|
import { planPointMarkers, pointLegend } from './pointStatus.js'
|
|
|
import { facilityPointMarkers } from './facilityPoints.js'
|
|
import { facilityPointMarkers } from './facilityPoints.js'
|
|
|
-import { deviceFactIndex, displayDeviceStatus } from './deviceStatus.js'
|
|
|
|
|
|
|
+import { deviceDisplayStatusIndex } from './deviceStatus.js'
|
|
|
|
|
|
|
|
export const MODE_LAYER = {
|
|
export const MODE_LAYER = {
|
|
|
OVERVIEW: 'overview',
|
|
OVERVIEW: 'overview',
|
|
@@ -92,16 +92,15 @@ function abnormalStatusMap(abnormalDevices) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 设备编码 → 显示状态;标签池没覆盖到的设备回退到后端单一状态(不猜、不放行)。
|
|
|
|
|
|
|
+ * 设备编码 → 显示状态;索引没覆盖到的设备回退到后端单一状态(不猜、不放行)。
|
|
|
* @param {string} code 设备编码
|
|
* @param {string} code 设备编码
|
|
|
* @param {string} fallback 后端单一状态(地图对象自身 `status`)
|
|
* @param {string} fallback 后端单一状态(地图对象自身 `status`)
|
|
|
- * @param {Map<string, object>} factIndex `deviceFactIndex()` 的产物
|
|
|
|
|
|
|
+ * @param {Map<string, string>} statusIndex `deviceDisplayStatusIndex()` 的产物
|
|
|
*/
|
|
*/
|
|
|
-function displayStatusFor(code, fallback, factIndex) {
|
|
|
|
|
|
|
+function displayStatusFor(code, fallback, statusIndex) {
|
|
|
const key = String(code || '').trim()
|
|
const key = String(code || '').trim()
|
|
|
- const fact = key && factIndex ? factIndex.get(key) : null
|
|
|
|
|
- if (!fact) return fallback || ''
|
|
|
|
|
- return displayDeviceStatus(fact.base, fact.tags) || fallback || ''
|
|
|
|
|
|
|
+ const status = key && statusIndex ? statusIndex.get(key) : ''
|
|
|
|
|
+ return status || fallback || ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -129,23 +128,27 @@ function withLocateTarget(visible, objects, mode, locateTarget) {
|
|
|
* · **自身状态**是业务异常(报警/预警/工单处置)—— 工单处置只有这条路径可得;
|
|
* · **自身状态**是业务异常(报警/预警/工单处置)—— 工单处置只有这条路径可得;
|
|
|
* · 它挂着的**设备**命中设备侧异常集(票 46 规格 Q8 的设备证据口径,保留)。
|
|
* · 它挂着的**设备**命中设备侧异常集(票 46 规格 Q8 的设备证据口径,保留)。
|
|
|
*/
|
|
*/
|
|
|
-function isAttentionPoint(object, abnormalCodes, factIndex) {
|
|
|
|
|
|
|
+function isAttentionPoint(object, abnormalCodes, statusIndex) {
|
|
|
if (!object || object.kind !== MAP_OBJECT_KIND.MONITORING_POINT) return false
|
|
if (!object || object.kind !== MAP_OBJECT_KIND.MONITORING_POINT) return false
|
|
|
if (isAttentionPointStatus(object.status)) return true
|
|
if (isAttentionPointStatus(object.status)) return true
|
|
|
- if (!Array.isArray(object.deviceCodes)) return false
|
|
|
|
|
- // 设备侧标签事实优先于「异常设备清单」:后者只装四态快照,本次实测 0 条 WARNING,
|
|
|
|
|
|
|
+ const deviceCodes = Array.isArray(object.deviceCodes) ? object.deviceCodes : []
|
|
|
|
|
+ // 设备侧标签事实与「异常设备清单」取并集:后者只装四态快照,本次实测 0 条 WARNING,
|
|
|
// 但仍可能有一台设备在 `/events/current` 里带预警标签(#108 已锁的标签口径)。
|
|
// 但仍可能有一台设备在 `/events/current` 里带预警标签(#108 已锁的标签口径)。
|
|
|
- if (object.deviceCodes.some((code) => isAttentionPointStatus(displayStatusFor(code, '', factIndex)))) return true
|
|
|
|
|
- return object.deviceCodes.some((code) => abnormalCodes.has(code))
|
|
|
|
|
|
|
+ // 这里只认报警/预警(与 abnormalCodeSet 的异常证据同口径);工单处置仍是「对象自身状态」那条路径。
|
|
|
|
|
+ for (const code of deviceCodes) {
|
|
|
|
|
+ if (ATTENTION_STATUSES.has(displayStatusFor(code, '', statusIndex))) return true
|
|
|
|
|
+ if (abnormalCodes.has(code)) return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 未关联设备同口径:自身状态是业务异常,或命中设备侧异常集。 */
|
|
|
|
|
-function isAttentionEquipment(object, abnormalCodes, factIndex) {
|
|
|
|
|
|
|
+/** 未关联设备同口径:自身显示状态是业务异常,或命中设备侧异常集。 */
|
|
|
|
|
+function isAttentionEquipment(object, abnormalCodes, statusIndex) {
|
|
|
if (!object) return false
|
|
if (!object) return false
|
|
|
- return isAttentionPointStatus(displayStatusFor(object.code, object.status, factIndex)) || abnormalCodes.has(object.code)
|
|
|
|
|
|
|
+ return isAttentionPointStatus(displayStatusFor(object.code, object.status, statusIndex)) || abnormalCodes.has(object.code)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter, factIndex, locateTarget) {
|
|
|
|
|
|
|
+function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter, statusIndex, locateTarget) {
|
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
|
const source = Array.isArray(objects) ? objects : []
|
|
const source = Array.isArray(objects) ? objects : []
|
|
|
// 设备标签筛选:点位只要有任一关联设备命中即显示(监测点是设备聚合点);
|
|
// 设备标签筛选:点位只要有任一关联设备命中即显示(监测点是设备聚合点);
|
|
@@ -167,8 +170,8 @@ function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter, factInd
|
|
|
if (mode === MODE_LAYER.WARNING_RESPONSE) {
|
|
if (mode === MODE_LAYER.WARNING_RESPONSE) {
|
|
|
return withLocateTarget(tagFiltered.filter((object) => {
|
|
return withLocateTarget(tagFiltered.filter((object) => {
|
|
|
if (!object) return false
|
|
if (!object) return false
|
|
|
- if (object.kind === MAP_OBJECT_KIND.MONITORING_POINT) return isAttentionPoint(object, abnormalCodes, factIndex)
|
|
|
|
|
- if (object.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT) return isAttentionEquipment(object, abnormalCodes, factIndex)
|
|
|
|
|
|
|
+ if (object.kind === MAP_OBJECT_KIND.MONITORING_POINT) return isAttentionPoint(object, abnormalCodes, statusIndex)
|
|
|
|
|
+ if (object.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT) return isAttentionEquipment(object, abnormalCodes, statusIndex)
|
|
|
return false
|
|
return false
|
|
|
}), source, mode, locateTarget)
|
|
}), source, mode, locateTarget)
|
|
|
}
|
|
}
|
|
@@ -207,14 +210,18 @@ function planNonPointLayers({ mode, entered, facilities, pipelines, facilityPoin
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function selectionVisible({ mode, selection, objects, markers, associatedDevices, abnormalCodes, factIndex, locateTarget }) {
|
|
|
|
|
|
|
+function selectionVisible({ mode, selection, objects, markers, associatedDevices, abnormalCodes, statusIndex, locateTarget }) {
|
|
|
const current = selection || {}
|
|
const current = selection || {}
|
|
|
if (!current.level || current.level === 'none') return false
|
|
if (!current.level || current.level === 'none') return false
|
|
|
// 定位目标本身必须可见(#127):定位的语义是「让目标可见」,不是只把相机开过去。
|
|
// 定位目标本身必须可见(#127):定位的语义是「让目标可见」,不是只把相机开过去。
|
|
|
- // 基础设施模式整体不呈现监测设备,该模式不破例。
|
|
|
|
|
|
|
+ // 基础设施模式整体不呈现监测设备,该模式不破例;目标没被坐标准入收下时也不画面板。
|
|
|
if (locateTarget && mode !== MODE_LAYER.INFRASTRUCTURE) {
|
|
if (locateTarget && mode !== MODE_LAYER.INFRASTRUCTURE) {
|
|
|
const targetCode = String(locateTarget.code || '').trim()
|
|
const targetCode = String(locateTarget.code || '').trim()
|
|
|
- if (targetCode && (current.deviceCode === targetCode || (!current.deviceCode && current.pointCode === targetCode))) return true
|
|
|
|
|
|
|
+ const targetDevice = String(locateTarget.deviceCode || '').trim()
|
|
|
|
|
+ const targetDrawn = Boolean(targetCode) && (markers || []).some((marker) => marker && marker.code === targetCode)
|
|
|
|
|
+ if (targetDrawn && (current.deviceCode === targetCode
|
|
|
|
|
+ || (!current.deviceCode && current.pointCode === targetCode)
|
|
|
|
|
+ || (targetDevice && current.deviceCode === targetDevice))) return true
|
|
|
}
|
|
}
|
|
|
// 设备级选择**优先看设备**(设备级选择仍保留 pointCode 供"返回点位"用,
|
|
// 设备级选择**优先看设备**(设备级选择仍保留 pointCode 供"返回点位"用,
|
|
|
// 先查 pointCode 会把"设备被本模式隐藏"误判成"点位可见 ⇒ 显示")。
|
|
// 先查 pointCode 会把"设备被本模式隐藏"误判成"点位可见 ⇒ 显示")。
|
|
@@ -231,19 +238,19 @@ function selectionVisible({ mode, selection, objects, markers, associatedDevices
|
|
|
const parent = (Array.isArray(objects) ? objects : []).find((item) =>
|
|
const parent = (Array.isArray(objects) ? objects : []).find((item) =>
|
|
|
item && item.kind === MAP_OBJECT_KIND.MONITORING_POINT && item.code === row.pointCode)
|
|
item && item.kind === MAP_OBJECT_KIND.MONITORING_POINT && item.code === row.pointCode)
|
|
|
return Boolean(parent && isAssociatedDeviceVisible(mode, row.status) &&
|
|
return Boolean(parent && isAssociatedDeviceVisible(mode, row.status) &&
|
|
|
- (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(parent, abnormalCodes, factIndex)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(parent, abnormalCodes, statusIndex)))
|
|
|
}
|
|
}
|
|
|
// 未关联设备:以地图对象身份判(基础设施整体隐藏;预警处置只认异常设备/预警标签)。
|
|
// 未关联设备:以地图对象身份判(基础设施整体隐藏;预警处置只认异常设备/预警标签)。
|
|
|
const object = (Array.isArray(objects) ? objects : [])
|
|
const object = (Array.isArray(objects) ? objects : [])
|
|
|
.find((item) => item && item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT && item.code === current.deviceCode)
|
|
.find((item) => item && item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT && item.code === current.deviceCode)
|
|
|
return Boolean(object && (mode !== MODE_LAYER.INFRASTRUCTURE) &&
|
|
return Boolean(object && (mode !== MODE_LAYER.INFRASTRUCTURE) &&
|
|
|
- (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionEquipment(object, abnormalCodes, factIndex)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionEquipment(object, abnormalCodes, statusIndex)))
|
|
|
}
|
|
}
|
|
|
if (current.pointCode) {
|
|
if (current.pointCode) {
|
|
|
const point = (Array.isArray(objects) ? objects : []).find((item) =>
|
|
const point = (Array.isArray(objects) ? objects : []).find((item) =>
|
|
|
item && item.kind === MAP_OBJECT_KIND.MONITORING_POINT && item.code === current.pointCode)
|
|
item && item.kind === MAP_OBJECT_KIND.MONITORING_POINT && item.code === current.pointCode)
|
|
|
return Boolean(point && mode !== MODE_LAYER.INFRASTRUCTURE &&
|
|
return Boolean(point && mode !== MODE_LAYER.INFRASTRUCTURE &&
|
|
|
- (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(point, abnormalCodes, factIndex)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(point, abnormalCodes, statusIndex)))
|
|
|
}
|
|
}
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
@@ -263,7 +270,7 @@ export function planModeLayers({
|
|
|
deviceFilter = null,
|
|
deviceFilter = null,
|
|
|
/** 设备标签事实(`deviceStatusStore.pools.devices`);未就绪时回退对象自身 `status`。 */
|
|
/** 设备标签事实(`deviceStatusStore.pools.devices`);未就绪时回退对象自身 `status`。 */
|
|
|
deviceFacts = null,
|
|
deviceFacts = null,
|
|
|
- /** 当前定位目标(`{ code }`):目标本身是地图对象时临时放行,基础设施模式除外。 */
|
|
|
|
|
|
|
+ /** 当前定位目标(`{ code, deviceCode? }`):目标本身是地图对象时临时放行,基础设施模式除外。 */
|
|
|
locateTarget = null,
|
|
locateTarget = null,
|
|
|
facilities,
|
|
facilities,
|
|
|
pipelines,
|
|
pipelines,
|
|
@@ -293,11 +300,11 @@ export function planModeLayers({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const factIndex = deviceFactIndex(deviceFacts)
|
|
|
|
|
- const source = visibleMapObjects(normalizedMode, objects, abnormalDevices, deviceFilter, factIndex, locateTarget)
|
|
|
|
|
|
|
+ const statusIndex = deviceDisplayStatusIndex(deviceFacts)
|
|
|
|
|
+ const source = visibleMapObjects(normalizedMode, objects, abnormalDevices, deviceFilter, statusIndex, locateTarget)
|
|
|
// 只有未关联设备需要按标签覆盖显示状态;监测点的视觉仍是后端聚合状态(CONTEXT.md)。
|
|
// 只有未关联设备需要按标签覆盖显示状态;监测点的视觉仍是后端聚合状态(CONTEXT.md)。
|
|
|
const statusOfObject = (item) => (item && item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT
|
|
const statusOfObject = (item) => (item && item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT
|
|
|
- ? displayStatusFor(item.code, item.status, factIndex)
|
|
|
|
|
|
|
+ ? displayStatusFor(item.code, item.status, statusIndex)
|
|
|
: (item && item.status) || '')
|
|
: (item && item.status) || '')
|
|
|
const pointPlan = planPointMarkers(source, statusOfObject)
|
|
const pointPlan = planPointMarkers(source, statusOfObject)
|
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
@@ -354,7 +361,7 @@ export function planModeLayers({
|
|
|
markers: pointPlan.markers,
|
|
markers: pointPlan.markers,
|
|
|
associatedDevices,
|
|
associatedDevices,
|
|
|
abnormalCodes,
|
|
abnormalCodes,
|
|
|
- factIndex,
|
|
|
|
|
|
|
+ statusIndex,
|
|
|
locateTarget,
|
|
locateTarget,
|
|
|
}),
|
|
}),
|
|
|
action: MODE_SELECTION.PRESERVE,
|
|
action: MODE_SELECTION.PRESERVE,
|