|
@@ -8,6 +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'
|
|
|
|
|
|
|
|
export const MODE_LAYER = {
|
|
export const MODE_LAYER = {
|
|
|
OVERVIEW: 'overview',
|
|
OVERVIEW: 'overview',
|
|
@@ -90,24 +91,61 @@ function abnormalStatusMap(abnormalDevices) {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设备编码 → 显示状态;标签池没覆盖到的设备回退到后端单一状态(不猜、不放行)。
|
|
|
|
|
+ * @param {string} code 设备编码
|
|
|
|
|
+ * @param {string} fallback 后端单一状态(地图对象自身 `status`)
|
|
|
|
|
+ * @param {Map<string, object>} factIndex `deviceFactIndex()` 的产物
|
|
|
|
|
+ */
|
|
|
|
|
+function displayStatusFor(code, fallback, factIndex) {
|
|
|
|
|
+ const key = String(code || '').trim()
|
|
|
|
|
+ const fact = key && factIndex ? factIndex.get(key) : null
|
|
|
|
|
+ if (!fact) return fallback || ''
|
|
|
|
|
+ return displayDeviceStatus(fact.base, fact.tags) || fallback || ''
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 定位揭示:目标本身是地图对象时,绕过当前模式/图例筛选临时放行。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 「定位」的语义是让目标可见,不是只把相机开过去;但基础设施模式整体不呈现监测设备,
|
|
|
|
|
+ * 该模式不破例。目标是否真能上图仍由 `planPointMarkers` 的坐标准入裁决,这里不伪造。
|
|
|
|
|
+ * @param {Array} visible 已按模式/标签筛过的对象
|
|
|
|
|
+ * @param {Array} objects 未筛的地图摘要对象
|
|
|
|
|
+ * @param {string} mode 一级模式
|
|
|
|
|
+ * @param {{code:string}|null} locateTarget 当前定位目标
|
|
|
|
|
+ */
|
|
|
|
|
+function withLocateTarget(visible, objects, mode, locateTarget) {
|
|
|
|
|
+ if (!locateTarget || mode === MODE_LAYER.INFRASTRUCTURE) return visible
|
|
|
|
|
+ const code = String(locateTarget.code || '').trim()
|
|
|
|
|
+ if (!code) return visible
|
|
|
|
|
+ const target = (Array.isArray(objects) ? objects : []).find((object) => object && object.code === code)
|
|
|
|
|
+ if (!target) return visible
|
|
|
|
|
+ if (visible.some((object) => object && object.code === target.code)) return visible
|
|
|
|
|
+ return [...visible, target]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 预警处置模式的点位判据(两条路径取并集):
|
|
* 预警处置模式的点位判据(两条路径取并集):
|
|
|
* · **自身状态**是业务异常(报警/预警/工单处置)—— 工单处置只有这条路径可得;
|
|
* · **自身状态**是业务异常(报警/预警/工单处置)—— 工单处置只有这条路径可得;
|
|
|
* · 它挂着的**设备**命中设备侧异常集(票 46 规格 Q8 的设备证据口径,保留)。
|
|
* · 它挂着的**设备**命中设备侧异常集(票 46 规格 Q8 的设备证据口径,保留)。
|
|
|
*/
|
|
*/
|
|
|
-function isAttentionPoint(object, abnormalCodes) {
|
|
|
|
|
|
|
+function isAttentionPoint(object, abnormalCodes, factIndex) {
|
|
|
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
|
|
|
- return Array.isArray(object.deviceCodes) && object.deviceCodes.some((code) => abnormalCodes.has(code))
|
|
|
|
|
|
|
+ if (!Array.isArray(object.deviceCodes)) return false
|
|
|
|
|
+ // 设备侧标签事实优先于「异常设备清单」:后者只装四态快照,本次实测 0 条 WARNING,
|
|
|
|
|
+ // 但仍可能有一台设备在 `/events/current` 里带预警标签(#108 已锁的标签口径)。
|
|
|
|
|
+ if (object.deviceCodes.some((code) => isAttentionPointStatus(displayStatusFor(code, '', factIndex)))) return true
|
|
|
|
|
+ return object.deviceCodes.some((code) => abnormalCodes.has(code))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 未关联设备同口径:自身状态是业务异常,或命中设备侧异常集。 */
|
|
/** 未关联设备同口径:自身状态是业务异常,或命中设备侧异常集。 */
|
|
|
-function isAttentionEquipment(object, abnormalCodes) {
|
|
|
|
|
|
|
+function isAttentionEquipment(object, abnormalCodes, factIndex) {
|
|
|
if (!object) return false
|
|
if (!object) return false
|
|
|
- return isAttentionPointStatus(object.status) || abnormalCodes.has(object.code)
|
|
|
|
|
|
|
+ return isAttentionPointStatus(displayStatusFor(object.code, object.status, factIndex)) || abnormalCodes.has(object.code)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter) {
|
|
|
|
|
|
|
+function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter, factIndex, locateTarget) {
|
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
|
const source = Array.isArray(objects) ? objects : []
|
|
const source = Array.isArray(objects) ? objects : []
|
|
|
// 设备标签筛选:点位只要有任一关联设备命中即显示(监测点是设备聚合点);
|
|
// 设备标签筛选:点位只要有任一关联设备命中即显示(监测点是设备聚合点);
|
|
@@ -127,17 +165,17 @@ function visibleMapObjects(mode, objects, abnormalDevices, deviceFilter) {
|
|
|
|
|
|
|
|
if (mode === MODE_LAYER.INFRASTRUCTURE) return []
|
|
if (mode === MODE_LAYER.INFRASTRUCTURE) return []
|
|
|
if (mode === MODE_LAYER.WARNING_RESPONSE) {
|
|
if (mode === MODE_LAYER.WARNING_RESPONSE) {
|
|
|
- return 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)
|
|
|
|
|
- if (object.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT) return isAttentionEquipment(object, abnormalCodes)
|
|
|
|
|
|
|
+ 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)
|
|
|
return false
|
|
return false
|
|
|
- })
|
|
|
|
|
|
|
+ }), source, mode, locateTarget)
|
|
|
}
|
|
}
|
|
|
- return tagFiltered.filter((object) => object && (
|
|
|
|
|
|
|
+ return withLocateTarget(tagFiltered.filter((object) => object && (
|
|
|
object.kind === MAP_OBJECT_KIND.MONITORING_POINT ||
|
|
object.kind === MAP_OBJECT_KIND.MONITORING_POINT ||
|
|
|
object.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT
|
|
object.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT
|
|
|
- ))
|
|
|
|
|
|
|
+ )), source, mode, locateTarget)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function planNonPointLayers({ mode, entered, facilities, pipelines, facilityPoints, degradedNotes }) {
|
|
function planNonPointLayers({ mode, entered, facilities, pipelines, facilityPoints, degradedNotes }) {
|
|
@@ -169,9 +207,15 @@ function planNonPointLayers({ mode, entered, facilities, pipelines, facilityPoin
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function selectionVisible({ mode, selection, objects, markers, associatedDevices, abnormalCodes }) {
|
|
|
|
|
|
|
+function selectionVisible({ mode, selection, objects, markers, associatedDevices, abnormalCodes, factIndex, locateTarget }) {
|
|
|
const current = selection || {}
|
|
const current = selection || {}
|
|
|
if (!current.level || current.level === 'none') return false
|
|
if (!current.level || current.level === 'none') return false
|
|
|
|
|
+ // 定位目标本身必须可见(#127):定位的语义是「让目标可见」,不是只把相机开过去。
|
|
|
|
|
+ // 基础设施模式整体不呈现监测设备,该模式不破例。
|
|
|
|
|
+ if (locateTarget && mode !== MODE_LAYER.INFRASTRUCTURE) {
|
|
|
|
|
+ const targetCode = String(locateTarget.code || '').trim()
|
|
|
|
|
+ if (targetCode && (current.deviceCode === targetCode || (!current.deviceCode && current.pointCode === targetCode))) return true
|
|
|
|
|
+ }
|
|
|
// 设备级选择**优先看设备**(设备级选择仍保留 pointCode 供"返回点位"用,
|
|
// 设备级选择**优先看设备**(设备级选择仍保留 pointCode 供"返回点位"用,
|
|
|
// 先查 pointCode 会把"设备被本模式隐藏"误判成"点位可见 ⇒ 显示")。
|
|
// 先查 pointCode 会把"设备被本模式隐藏"误判成"点位可见 ⇒ 显示")。
|
|
|
if (current.deviceCode) {
|
|
if (current.deviceCode) {
|
|
@@ -187,19 +231,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)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(parent, abnormalCodes, factIndex)))
|
|
|
}
|
|
}
|
|
|
- // 未关联设备:以地图对象身份判(基础设施整体隐藏;预警处置只认异常设备)。
|
|
|
|
|
|
|
+ // 未关联设备:以地图对象身份判(基础设施整体隐藏;预警处置只认异常设备/预警标签)。
|
|
|
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)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionEquipment(object, abnormalCodes, factIndex)))
|
|
|
}
|
|
}
|
|
|
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)))
|
|
|
|
|
|
|
+ (mode !== MODE_LAYER.WARNING_RESPONSE || isAttentionPoint(point, abnormalCodes, factIndex)))
|
|
|
}
|
|
}
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
@@ -217,6 +261,10 @@ export function planModeLayers({
|
|
|
abnormalDevices,
|
|
abnormalDevices,
|
|
|
/** 命中所选设备标签的设备编码集(null=不筛)。筛选与图例同一口径(维护者 2026-11-05)。 */
|
|
/** 命中所选设备标签的设备编码集(null=不筛)。筛选与图例同一口径(维护者 2026-11-05)。 */
|
|
|
deviceFilter = null,
|
|
deviceFilter = null,
|
|
|
|
|
+ /** 设备标签事实(`deviceStatusStore.pools.devices`);未就绪时回退对象自身 `status`。 */
|
|
|
|
|
+ deviceFacts = null,
|
|
|
|
|
+ /** 当前定位目标(`{ code }`):目标本身是地图对象时临时放行,基础设施模式除外。 */
|
|
|
|
|
+ locateTarget = null,
|
|
|
facilities,
|
|
facilities,
|
|
|
pipelines,
|
|
pipelines,
|
|
|
facilityPoints,
|
|
facilityPoints,
|
|
@@ -245,8 +293,13 @@ export function planModeLayers({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const source = visibleMapObjects(normalizedMode, objects, abnormalDevices, deviceFilter)
|
|
|
|
|
- const pointPlan = planPointMarkers(source)
|
|
|
|
|
|
|
+ const factIndex = deviceFactIndex(deviceFacts)
|
|
|
|
|
+ const source = visibleMapObjects(normalizedMode, objects, abnormalDevices, deviceFilter, factIndex, locateTarget)
|
|
|
|
|
+ // 只有未关联设备需要按标签覆盖显示状态;监测点的视觉仍是后端聚合状态(CONTEXT.md)。
|
|
|
|
|
+ const statusOfObject = (item) => (item && item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT
|
|
|
|
|
+ ? displayStatusFor(item.code, item.status, factIndex)
|
|
|
|
|
+ : (item && item.status) || '')
|
|
|
|
|
+ const pointPlan = planPointMarkers(source, statusOfObject)
|
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
const abnormalCodes = abnormalCodeSet(abnormalDevices)
|
|
|
const abnormalDataReady = hasArray(abnormalDevices)
|
|
const abnormalDataReady = hasArray(abnormalDevices)
|
|
|
if (normalizedMode === MODE_LAYER.WARNING_RESPONSE && !abnormalDataReady) {
|
|
if (normalizedMode === MODE_LAYER.WARNING_RESPONSE && !abnormalDataReady) {
|
|
@@ -301,6 +354,8 @@ export function planModeLayers({
|
|
|
markers: pointPlan.markers,
|
|
markers: pointPlan.markers,
|
|
|
associatedDevices,
|
|
associatedDevices,
|
|
|
abnormalCodes,
|
|
abnormalCodes,
|
|
|
|
|
+ factIndex,
|
|
|
|
|
+ locateTarget,
|
|
|
}),
|
|
}),
|
|
|
action: MODE_SELECTION.PRESERVE,
|
|
action: MODE_SELECTION.PRESERVE,
|
|
|
},
|
|
},
|