فهرست منبع

feat(cockpit): 设施点独立聚合与三类同位置避让

设施点作为第三类独立命名空间接入聚合:状态走设施 0/1(正常/异常,异常不写成设备报警),类型走设施类型短字(厂/泵/源/户/消/闸/蓄/井),混合用「混」;组身份用 type+entityId 的完整 key(编码可重复),选中设施按 key 移出并保留单体标记/详情。三类徽章同位置时按类固定角度做小三角偏移并加细引线指回真实锚点,进出带缓冲;标签避让/深度序号/成员面板均使用徽章视觉位置。
ChenJZ 1 روز پیش
والد
کامیت
7bdb58e342
2فایلهای تغییر یافته به همراه283 افزوده شده و 53 حذف شده
  1. 163 23
      src/modules/cockpit/domain/pointAggregation.js
  2. 120 30
      src/modules/cockpit/services/markerOverlay.js

+ 163 - 23
src/modules/cockpit/domain/pointAggregation.js

@@ -1,12 +1,12 @@
 /**
- * 屏幕拥挤聚合:未关联设备(03)与监测点(04)共用一套分组/成员表/缩放接缝。
+ * 屏幕拥挤聚合:未关联设备(03)、监测点(04)、设施点(05)共用一套分组/成员表/缩放接缝。
  *
  * 纯函数、不 import Vue/Cesium/DOM:输入是**已经投影到窗口坐标**的对象行
  * (服务层/overlay 每帧用同一枚 projectToWindow 投影),输出是稳定的聚合组与成员表。
  *
  * 第一性原理:
  *   · 聚合只表达**显示拥挤**,不改变成员的真实坐标、身份、状态或统计口径;
- *   · 三类对象各有独立命名空间,本文件只聚设备与监测点,绝不跨类合并;
+ *   · 三类对象各有独立命名空间,绝不跨类合并;
  *   · 组身份 = 类别命名空间 + 成员编码集合(排序后拼接),成员不变 groupKey 稳定;
  *   · 状态优先级按类别原生词表:设备五态(报警>工单>预警)与点位六态(报警>预警>工单)
  *     不共用一张表;
@@ -17,6 +17,8 @@
 // 未关联设备的“原生状态”是设备五态(不是点位六态):色/词/优先级都走设备表,
 // 否则工单处置与预警的先后会被点位表带反(设备规则:报警 > 工单处置 > 预警)。
 import { deviceVisualForStatus } from './deviceStatus.js'
+import { facilityTypeMeta } from './facilityPoints.js'
+import { facilityVisualStatus } from './facilityStatus.js'
 import { industryLabel } from './filterOptions.js'
 import { ringEffectFor } from './markerMetrics.js'
 import { PIPE_PALETTE } from './pipeVisual.js'
@@ -26,6 +28,8 @@ import { visualForStatus } from './pointStatus.js'
 export const AGGREGATE_KIND = 'unassociated-equipment-aggregate'
 /** 监测点聚合符号的 kind:与设备聚合**独立命名空间**,同位置也不跨类合并。 */
 export const POINT_AGGREGATE_KIND = 'monitoring-point-aggregate'
+/** 设施点聚合符号的 kind:第三类独立命名空间。 */
+export const FACILITY_AGGREGATE_KIND = 'facility-point-aggregate'
 
 /** 默认屏幕合并阈值(px):小于该距离视为拥挤。 */
 export const DEFAULT_MIN_SEPARATION_PX = 22
@@ -71,6 +75,29 @@ const TYPE_CHAR = {
     MANHOLE: '井',
 }
 
+/** 设施类型短字(同质单一类型时用;混合用「混」)。 */
+const FACILITY_TYPE_CHAR = {
+    WATER_PLANT: '厂',
+    PUMP_STATION: '泵',
+    WATER_SOURCE: '源',
+    WATER_USER: '户',
+    WATER_FIRE_HYDRANT: '消',
+    DRAINAGE_GATE: '闸',
+    DRAINAGE_STORAGE: '蓄',
+    MANHOLE: '井',
+}
+
+/**
+ * 设施状态视觉:设施只有 0 正常 / 1 异常(后端统一码值),不得借用设备工单/预警/离线词表;
+ * 异常文案是「异常」而不是设备「报警」。
+ */
+function facilityStatusVisual(status) {
+    const key = facilityVisualStatus(status)
+    if (key === 'ALARM') return { key, priority: 1, tone: 'lv1', label: '异常' }
+    if (key === 'NORMAL') return { key, priority: 2, tone: 'lv4', label: '正常' }
+    return { key: 'UNKNOWN', priority: 3, tone: 'neutral', label: '状态未发布' }
+}
+
 /**
  * 单体标签是否被聚合徽章覆盖(标签避让判据)。
  * @param {{x:number,y:number}} pos 单体标签锚点(宿主相对窗口坐标)
@@ -158,6 +185,10 @@ const CATEGORY_PROFILE = {
         toneFallback: 'point-unassociated',
         visualOf: deviceVisualForStatus,
         effectOf: (status) => deviceVisualForStatus(status).effect || '',
+        typeKeyOf: (member) => member.industry || '',
+        typeLabelOf: (key) => industryLabel(key) || (key || '未标注'),
+        typeCharOf: (key) => typeCharOf(key, '设'),
+        typeColorOf: (key) => typeColorOf(key),
     },
     'monitoring-point': {
         key: 'monitoring-point',
@@ -175,6 +206,32 @@ const CATEGORY_PROFILE = {
             const ring = ringEffectFor(status)
             return ring ? ring.effect : ''
         },
+        typeKeyOf: (member) => member.industry || '',
+        typeLabelOf: (key) => industryLabel(key) || (key || '未标注'),
+        typeCharOf: (key) => typeCharOf(key, '点'),
+        typeColorOf: (key) => typeColorOf(key),
+    },
+    'facility-point': {
+        key: 'facility-point',
+        memberKind: 'facility-point',
+        aggregateKind: FACILITY_AGGREGATE_KIND,
+        category: '设施点',
+        noun: '个设施点',
+        fallbackTypeChar: '设',
+        fallbackTypeLabel: '设施',
+        toneFallback: 'neutral',
+        // 设施状态不借用设备词表:1=异常、0=正常,未发布保持未知。
+        visualOf: facilityStatusVisual,
+        // 单体设施异常在现有渲染里是 pulse;聚合组同样只挂一套,文案仍是「异常」。
+        effectOf: (status) => (facilityVisualStatus(status) === 'ALARM' ? 'pulse' : ''),
+        typeKeyOf: (member) => member.type || '',
+        typeLabelOf: (key) => {
+            const meta = facilityTypeMeta(key)
+            return meta ? meta.label : (key || '设施')
+        },
+        typeCharOf: (key) => FACILITY_TYPE_CHAR[key] || '设',
+        // 设施没有行业色语义,统一用系统青色;混合类型回中性灰(不冒充某一类)。
+        typeColorOf: () => '#01abea',
     },
 }
 
@@ -200,20 +257,25 @@ function isCandidate(item, profile) {
  * 点位:报警 > 预警 > 工单处置 > 正常 > 离线 > 无设备 > 未发布。
  */
 export function statusPriority(status, profile = EQUIPMENT_PROFILE) {
-    const visual = profile.visualOf(status || '')
+    const value = status === undefined || status === null ? '' : status
+    const visual = profile.visualOf(value)
     return Number.isFinite(visual.priority) ? visual.priority : 999
 }
 
 function statusSummaryOf(members, profile) {
     const counts = {}
     for (const member of members) {
-        const key = member.status || 'UNKNOWN'
+        // 0 是设施的合法状态码,不能用 `|| 'UNKNOWN'` 把数字 0 吃掉。
+        const raw = member.status
+        const key = raw === undefined || raw === null || raw === '' ? 'UNKNOWN' : String(raw)
         counts[key] = (counts[key] || 0) + 1
     }
     const statuses = Object.keys(counts).map((status) => {
         const visual = profile.visualOf(status)
         return {
             status,
+            // 视觉词(设施 1→ALARM)供角标/特效取 profile;文案仍是设施「异常」,不写成设备「报警」。
+            visualKey: visual.key || status,
             count: counts[status],
             priority: Number.isFinite(visual.priority) ? visual.priority : 999,
             tone: visual.tone,
@@ -265,30 +327,32 @@ export function worldSpanMeters(bounds) {
 }
 
 function buildGroup(rawMembers, profile) {
-    const members = rawMembers.slice().sort((a, b) => String(a.code).localeCompare(String(b.code)))
+    // 设施编码可重复(真实身份是 type+entityId 的 key);排序与组身份都用 key 兜底。
+    const members = rawMembers.slice().sort((a, b) => String(a.code).localeCompare(String(b.code))
+        || String(a.key || '').localeCompare(String(b.key || '')))
     const screen = {
         x: members.reduce((sum, item) => sum + item.screen.x, 0) / members.length,
         y: members.reduce((sum, item) => sum + item.screen.y, 0) / members.length,
     }
     const screenBox = screenBounds(members)
     const boundsWorld = worldBounds(members)
-    const codes = members.map((item) => String(item.code || ''))
-    // 类型维度:未关联设备的“类型”就是它的行业(燃气/供水/排水/窨井);同质用该类型图案,
-    // 混合则用通用图案(规格:不得长期显示过期类别语义)。
-    const industryCounts = new Map()
+    const identities = members.map((item) => String(item.key || item.code || ''))
+    // 类型维度:设备/监测点看行业(燃气/供水/排水/窨井),设施点看设施类型(水厂/泵站/…);
+    // 同质用该类型短字/图案,混合用通用(规格:不得长期显示过期类别语义)。
+    const typeCounts = new Map()
     for (const member of members) {
-        const key = member.industry || ''
-        industryCounts.set(key, (industryCounts.get(key) || 0) + 1)
+        const key = profile.typeKeyOf(member) || ''
+        typeCounts.set(key, (typeCounts.get(key) || 0) + 1)
     }
-    const industrySummary = [...industryCounts.entries()]
-        .map(([key, count]) => ({ key, count, label: industryLabel(key) || (key || '未标注') }))
+    const industrySummary = [...typeCounts.entries()]
+        .map(([key, count]) => ({ key, count, label: profile.typeLabelOf(key) || (key || '未标注') }))
         .sort((a, b) => b.count - a.count || a.key.localeCompare(b.key))
     const mixedIndustry = industrySummary.length > 1
     const statusSummary = statusSummaryOf(members, profile)
     return {
         kind: profile.aggregateKind,
-        // 组身份 = 类别命名空间 + 成员编码集合(成员不变则稳定,相机微移不抖)。
-        groupKey: profile.aggregateKind + '|' + codes.join(','),
+        // 组身份 = 类别命名空间 + 成员身份集合(设施用 key,设备/点位用 code;成员不变则稳定)。
+        groupKey: profile.aggregateKind + '|' + identities.join(','),
         statusProfile: profile.key,
         memberKind: profile.memberKind,
         category: profile.category,
@@ -314,10 +378,10 @@ function buildGroup(rawMembers, profile) {
         mixedIndustry,
         primaryIndustry: industrySummary.length ? industrySummary[0].key : '',
         typeLabel: mixedIndustry ? '混合' : (industrySummary.length ? industrySummary[0].label : profile.fallbackTypeLabel),
-        // 徽章中央大字:混合=混、同质=行业短字(燃/水/排/井),认不出=类别兜底(设备「设」/点位「点」)。
-        typeChar: mixedIndustry ? '混' : typeCharOf(industrySummary.length ? industrySummary[0].key : '', profile.fallbackTypeChar),
-        // 类型色语义:同质用行业色;混合用中性色(避免冒充某一行业)。
-        typeColor: mixedIndustry ? PIPE_PALETTE.UNKNOWN.color : typeColorOf(industrySummary.length ? industrySummary[0].key : ''),
+        // 徽章中央大字:混合=混、同质=类型短字(燃/水/排/井,设施为厂/泵/源/户/…)。
+        typeChar: mixedIndustry ? '混' : profile.typeCharOf(industrySummary.length ? industrySummary[0].key : ''),
+        // 类型色语义:同质按类别(行业色/设施青);混合用中性色。
+        typeColor: mixedIndustry ? PIPE_PALETTE.UNKNOWN.color : profile.typeColorOf(industrySummary.length ? industrySummary[0].key : ''),
     }
 }
 
@@ -336,8 +400,10 @@ function groupByScreen(items, categoryKey, { minSeparationPx = DEFAULT_MIN_SEPAR
     const profile = CATEGORY_PROFILE[categoryKey] || EQUIPMENT_PROFILE
     const list = (Array.isArray(items) ? items : []).filter((item) => isCandidate(item, profile))
     const selected = typeof selectedCode === 'string' ? selectedCode : ''
-    const pool = list.filter((item) => String(item.code || '') !== selected)
-    const selectedRow = selected ? (list.find((item) => String(item.code) === selected) || null) : null
+    // 设施点的选中身份是完整 key(类型+实体 id),设备/点位用 code;两者都认。
+    const isSelected = (item) => String(item.code || '') === selected || (item.key !== undefined && String(item.key) === selected)
+    const pool = list.filter((item) => !isSelected(item))
+    const selectedRow = selected ? (list.find(isSelected) || null) : null
     if (!pool.length) return { groups: [], selected: selectedRow }
 
     const threshold = Number.isFinite(minSeparationPx) && minSeparationPx > 0 ? minSeparationPx : DEFAULT_MIN_SEPARATION_PX
@@ -412,6 +478,13 @@ export function groupMonitoringPointsByScreen(items, options = {}) {
     return groupByScreen(items, 'monitoring-point', options)
 }
 
+/**
+ * 设施点的屏幕聚合(05):独立命名空间;状态走设施 0/1 词表,类型走设施类型表。
+ */
+export function groupFacilityPointsByScreen(items, options = {}) {
+    return groupByScreen(items, 'facility-point', options)
+}
+
 /**
  * 聚合徽章的可显示描述(规格 69–72)。
  *
@@ -446,7 +519,7 @@ export function aggregateBadge(group) {
         abnormal,
         otherAbnormalCount: summary.otherAbnormalCount || 0,
         // 特效:与最高优先级异常一致;无异常不挂特效。每组最多一套(由徽章节点承载,不叠加成员环)。
-        effectStatus: abnormal ? abnormal.status : '',
+        effectStatus: abnormal ? (abnormal.visualKey || abnormal.status) : '',
         effect: abnormal ? abnormal.effect : '',
         // 类型:同质给具体行业(图案),混合给通用(typeLabel=混合、industryKey 为空)。
         mixedIndustry: Boolean(group.mixedIndustry),
@@ -465,6 +538,70 @@ export function aggregateBadge(group) {
     }
 }
 
+/** 三类徽章的固定顺序(跨类避让角度按它取,缺类也不会让其它类换角度)。 */
+export const BADGE_CLASS_ORDER = Object.freeze(['unassociated-equipment', 'monitoring-point', 'facility-point'])
+
+/**
+ * 三类徽章同位置避让:同一锚点附近的不同类徽章做固定小三角偏移,并用细引线指回真实锚点。
+ *
+ * 第一性原理:三类对象是**独立命名空间**,不能合并;但同一个屏幕位置最多呈现三个徽章,
+ * 否则会互相压住。偏移角按类固定(设备上、监测点右下、设施左下),缺类不改变其它类的角度;
+ * 进入用紧阈值、离开用缓冲(previousKeys),避免边界来回摆动。
+ *
+ * @param {Array} groups 徽章组(需 memberKind / groupKey / screen)
+ * @param {{radius?:number, enterPx?:number, exitPx?:number, previousKeys?:Set<string>}} [options]
+ * @returns {Map<string,{dx:number,dy:number,x:number,y:number,anchorX:number,anchorY:number,offset:boolean,leader:boolean}>}
+ */
+export function planBadgeOffsets(groups, { radius = 24, enterPx = 14, exitPx = 20, previousKeys = new Set() } = {}) {
+    const list = (Array.isArray(groups) ? groups : []).filter((group) => group && group.groupKey
+        && group.screen && Number.isFinite(group.screen.x) && Number.isFinite(group.screen.y))
+    const classIndex = (group) => {
+        const index = BADGE_CLASS_ORDER.indexOf(group.memberKind)
+        return index >= 0 ? index : BADGE_CLASS_ORDER.length
+    }
+    list.sort((a, b) => classIndex(a) - classIndex(b) || String(a.groupKey).localeCompare(String(b.groupKey)))
+    const clusters = []
+    for (const group of list) {
+        let target = null
+        let best = Number.POSITIVE_INFINITY
+        for (const cluster of clusters) {
+            const distance = Math.hypot(group.screen.x - cluster.anchor.x, group.screen.y - cluster.anchor.y)
+            const wasOffset = previousKeys.has(group.groupKey) || cluster.keys.some((key) => previousKeys.has(key))
+            const limit = wasOffset ? exitPx : enterPx
+            if (distance <= limit && distance < best) {
+                target = cluster
+                best = distance
+            }
+        }
+        if (!target) {
+            target = { anchor: { x: group.screen.x, y: group.screen.y }, groups: [], keys: [] }
+            clusters.push(target)
+        }
+        target.groups.push(group)
+        target.keys.push(group.groupKey)
+    }
+    const layout = new Map()
+    for (const cluster of clusters) {
+        const single = cluster.groups.length === 1
+        for (const group of cluster.groups) {
+            const angle = single ? 0 : (-90 + classIndex(group) * 120) * Math.PI / 180
+            const dx = single ? 0 : Math.cos(angle) * radius
+            const dy = single ? 0 : Math.sin(angle) * radius
+            layout.set(group.groupKey, {
+                dx,
+                dy,
+                x: cluster.anchor.x + dx,
+                y: cluster.anchor.y + dy,
+                anchorX: cluster.anchor.x,
+                anchorY: cluster.anchor.y,
+                offset: !single,
+                leader: !single,
+            })
+        }
+    }
+    return layout
+}
+
 /** 该组是否还能靠缩放拆开:屏幕离散且真实跨度都够大。 */
 export function canZoomAggregate(group, { minSpreadPx = DEFAULT_MIN_SPREAD_PX, minSpanMeters = DEFAULT_MIN_SPAN_METERS } = {}) {
     if (!group || group.count < 2) return false
@@ -496,11 +633,14 @@ export function planMemberList(group, { query = '', sort = 'risk' } = {}) {
     const profile = CATEGORY_PROFILE[group && group.statusProfile] || EQUIPMENT_PROFILE
     const priorities = (group && group.statusPriorities) || {}
     const rows = filtered.map((item) => {
-        const visual = profile.visualOf(item.status || '')
+        // 0 是设施合法状态码,不能用 `|| ''` 吃掉。
+        const visual = profile.visualOf(item.status === undefined || item.status === null ? '' : item.status)
         return {
             ...item,
             statusLabel: visual.label,
             statusTone: visual.tone,
+            // 设备/监测点给行业词;设施点给设施类型词(水厂/泵站/…)。
+            typeLabel: profile.typeLabelOf(profile.typeKeyOf(item)),
             industryLabel: industryLabel(item.industry) || (item.industry || '未标注'),
         }
     })

+ 120 - 30
src/modules/cockpit/services/markerOverlay.js

@@ -49,7 +49,7 @@ import {
 // 票 83:几何读数(本体宽 / 绘制宽 / pad)与计划读数同一出口,走查不读 DOM 内部结构。
 import { markerGeometryDataset } from '../domain/markerPlan.js'
 // 本票:未关联设备的屏幕拥挤聚合(纯 domain;本层只负责投影/渲染/点击)。
-import { AGGREGATE_BADGE, AGGREGATE_KIND, aggregateBadge, canZoomAggregate, groupMonitoringPointsByScreen, groupUnassociatedByScreen, labelOccludedByAggregates, planMemberList, rankByDepth } from '../domain/pointAggregation.js'
+import { AGGREGATE_BADGE, AGGREGATE_KIND, aggregateBadge, canZoomAggregate, groupFacilityPointsByScreen, groupMonitoringPointsByScreen, groupUnassociatedByScreen, labelOccludedByAggregates, planBadgeOffsets, planMemberList, rankByDepth } from '../domain/pointAggregation.js'
 
 /**
  * 类名单源:注入的特效 CSS(下方模板串)与 DOM 构建(buildNode/mount)共用同一组常量。
@@ -554,6 +554,12 @@ let aggregateSelectedCode = ''
 let lastAggregateGroups = []
 /** 监测点聚合的上一帧分组(与设备分组分开,互不串用迟滞历史)。 */
 let lastPointAggregateGroups = []
+/** 设施点聚合的上一帧分组。 */
+let lastFacilityAggregateGroups = []
+/** 当前帧三类徽章的避让布局(徽章视觉位置/锚点/引线)。 */
+let currentBadgeLayout = new Map()
+/** 上一帧处于偏移状态的徽章:边界用更大阈值退出,避免来回摆动。 */
+let previousBadgeOffsetKeys = new Set()
 /** 成员列表面板(宿主子节点,单例,跟随聚合徽章)。 */
 let memberListEl = null
 let memberListGroupKey = ''
@@ -1115,7 +1121,7 @@ function buildUnassociatedAggregateNode(key, badge, tones) {
     return { root, countEl, typeEl, statusEl, labelEl: label, fxHost, fp: badgeFingerprint(badge) }
 }
 
-function renderAggregates(groups, tones) {
+function renderAggregates(groups, tones, layout = new Map()) {
     aggregateGroups.clear()
     const active = new Set()
     for (const group of groups || []) {
@@ -1127,15 +1133,48 @@ function renderAggregates(groups, tones) {
         let record = aggregatePool.get(key)
         const fp = badgeFingerprint(badge)
         if (!record || record.fp !== fp) {
-            if (record && record.root.parentNode) record.root.parentNode.removeChild(record.root)
+            if (record) {
+                if (record.root.parentNode) record.root.parentNode.removeChild(record.root)
+                if (record.leader && record.leader.parentNode) record.leader.parentNode.removeChild(record.leader)
+            }
             record = buildUnassociatedAggregateNode(key, badge, tones)
+            record.leader = null
             aggregatePool.set(key, record)
             hostNode.appendChild(record.root)
         }
         // 深度排序:徽章用本帧全局序号(组内最近成员的距离已参与排序),不再绝对置顶。
         const badgeZ = String((depthRanks.get(group.groupKey) || 1) * 2)
         if (record.root.style.zIndex !== badgeZ) record.root.style.zIndex = badgeZ
-        const transform = 'translate(' + group.screen.x + 'px, ' + group.screen.y + 'px) translate(-50%, -50%)'
+        // 跨类避让:同位置三类徽章按固定小三角偏移;偏移时用细引线指回真实锚点。
+        const visual = layout.get(key) || {
+            x: group.screen.x, y: group.screen.y,
+            anchorX: group.screen.x, anchorY: group.screen.y,
+            dx: 0, dy: 0, offset: false, leader: false,
+        }
+        if (!record.leader) {
+            record.leader = document.createElement('div')
+            record.leader.className = 'marker-overlay-aggregate-leader'
+            record.leader.style.cssText = 'position:absolute;height:1px;background:rgba(120,200,255,0.5);transform-origin:0 50%;pointer-events:none;box-shadow:0 0 4px rgba(1,171,234,0.45);'
+            hostNode.appendChild(record.leader)
+        }
+        if (visual.leader) {
+            const dx = visual.x - visual.anchorX
+            const dy = visual.y - visual.anchorY
+            const length = Math.hypot(dx, dy)
+            const angle = Math.atan2(dy, dx)
+            record.leader.style.display = 'block'
+            record.leader.style.left = visual.anchorX + 'px'
+            record.leader.style.top = visual.anchorY + 'px'
+            record.leader.style.width = length + 'px'
+            record.leader.style.transform = 'rotate(' + angle + 'rad)'
+            record.leader.style.zIndex = String(Number(badgeZ) - 1)
+        } else if (record.leader.style.display !== 'none') {
+            record.leader.style.display = 'none'
+        }
+        record.root.dataset.aggregateDx = String(Math.round(visual.dx || 0))
+        record.root.dataset.aggregateDy = String(Math.round(visual.dy || 0))
+        record.root.dataset.aggregateLeader = visual.leader ? 'yes' : 'no'
+        const transform = 'translate(' + visual.x + 'px, ' + visual.y + 'px) translate(-50%, -50%)'
         if (record.root.style.transform !== transform) record.root.style.transform = transform
         if (record.root.style.display !== 'block') record.root.style.display = 'block'
         // 走查读数(不参与业务):数量/离散/可缩放/最高异常/+N/类型/特效。
@@ -1152,9 +1191,11 @@ function renderAggregates(groups, tones) {
     for (const [key, record] of aggregatePool.entries()) {
         if (active.has(key)) continue
         record.root.style.display = 'none'
+        if (record.leader && record.leader.style.display !== 'none') record.leader.style.display = 'none'
         // 组身份随相机移动而变,池会积累失效徽章;超过上限就真正销毁(避免长会话 DOM 泄漏)。
         if (aggregatePool.size > 240) {
             if (record.root.parentNode) record.root.parentNode.removeChild(record.root)
+            if (record.leader && record.leader.parentNode) record.leader.parentNode.removeChild(record.leader)
             aggregatePool.delete(key)
         }
     }
@@ -1210,10 +1251,12 @@ function positionMemberList(group) {
     const height = 340
     const hostW = hostNode.clientWidth || 900
     const hostH = hostNode.clientHeight || 700
-    let x = group.screen.x + 24
-    if (x + width > hostW - 12) x = group.screen.x - width - 24
+    // 面板贴着徽章的**视觉位置**(跨类避让后可能已偏移),仍以真实锚点为基准留出偏移量。
+    const visual = currentBadgeLayout.get(group.groupKey) || group.screen
+    let x = visual.x + 24
+    if (x + width > hostW - 12) x = visual.x - width - 24
     x = Math.max(12, Math.min(hostW - width - 12, x))
-    let y = group.screen.y - 36
+    let y = visual.y - 36
     y = Math.max(12, Math.min(hostH - height - 12, y))
     const left = x + 'px'
     const top = y + 'px'
@@ -1229,6 +1272,7 @@ function renderMemberRows(group) {
         card.type = 'button'
         card.className = 'aggregate-panel__card'
         card.dataset.memberCode = row.code
+        card.dataset.memberKey = row.key || ''
         card.addEventListener('click', (event) => {
             event.stopPropagation()
             // 设备:本地立刻把成员移出聚合;监测点:由详情选择驱动 selectedPointCode,
@@ -1237,7 +1281,8 @@ function renderMemberRows(group) {
             if (memberKind === 'unassociated-equipment') aggregateSelectedCode = row.code
             const onPick = memberListOnPick
             closeMemberList()
-            if (typeof onPick === 'function') onPick({ kind: memberKind, code: row.code, key: memberKind + '|' + row.code })
+            // 设施点的身份是完整 key(类型+实体 id),设备/点位用 kind|code。
+            if (typeof onPick === 'function') onPick({ kind: memberKind, code: row.code, key: row.key || (memberKind + '|' + row.code) })
         })
         const top = document.createElement('span')
         top.className = 'aggregate-panel__card-top'
@@ -1263,7 +1308,7 @@ function renderMemberRows(group) {
         meta.textContent = row.code + ' · '
         const type = document.createElement('span')
         type.className = 'aggregate-panel__type'
-        type.textContent = row.industryLabel || '未标注'
+        type.textContent = row.typeLabel || row.industryLabel || '未标注'
         meta.appendChild(type)
         card.appendChild(top)
         card.appendChild(meta)
@@ -1407,7 +1452,22 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
         const pos = projectToWindow(marker.longitude, marker.latitude)
         if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) windowPositions.set(`${marker.kind}|${marker.code}`, pos)
     }
-    // 03 未关联设备 / 04 监测点:各自独立命名空间,同位置也不跨类合并。
+    // 设施/构件的投影也先算一次:聚合、深度排序、渲染共用同一份(不再每帧投两遍)。
+    const facilityPositions = new Map()
+    for (const facility of facilities || []) {
+        const key = facility.key || `facility-point|${facility.code}`
+        if (!Number.isFinite(facility.longitude) || !Number.isFinite(facility.latitude)) continue
+        const pos = projectToWindow(facility.longitude, facility.latitude)
+        if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) facilityPositions.set(key, pos)
+    }
+    const componentPositions = new Map()
+    for (const component of pipeComponentsVisible === false ? [] : (pipeComponents || [])) {
+        const key = component.key || `pipe-component|${component.code}`
+        if (!Number.isFinite(component.longitude) || !Number.isFinite(component.latitude)) continue
+        const pos = projectToWindow(component.longitude, component.latitude)
+        if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) componentPositions.set(key, pos)
+    }
+    // 03 未关联设备 / 04 监测点 / 05 设施点:各自独立命名空间,同位置也不跨类合并。
     const aggregateRows = []
     const pointAggregateRows = []
     for (const marker of markers || []) {
@@ -1441,32 +1501,58 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
         previousGroups: lastPointAggregateGroups,
     })
     lastPointAggregateGroups = pointAggregateResult.groups
-    const badgeGroups = [...aggregateResult.groups, ...pointAggregateResult.groups]
-        .filter((group) => group.count > 1)
+    // 05 设施点:独立命名空间;选中设施用完整 key 移出,保留单体标记与设施详情。
+    const facilityAggregateRows = []
+    for (const facility of facilities || []) {
+        const key = facility.key || `facility-point|${facility.code}`
+        const pos = facilityPositions.get(key)
+        if (!pos) continue
+        facilityAggregateRows.push({
+            kind: 'facility-point',
+            key,
+            code: facility.code,
+            name: facility.name || '',
+            status: facility.status,
+            type: facility.type || facility.facilityType || '',
+            industry: facility.industry || '',
+            longitude: facility.longitude,
+            latitude: facility.latitude,
+            entityId: facility.entityId || '',
+            detailCategory: facility.detailCategory || '',
+            clickable: facility.clickable !== false,
+            screen: pos,
+        })
+    }
+    if (!facilityAggregateRows.length) lastFacilityAggregateGroups = []
+    const facilityAggregateResult = groupFacilityPointsByScreen(facilityAggregateRows, {
+        selectedCode: typeof selectedFacilityKey === 'string' ? selectedFacilityKey : '',
+        previousGroups: lastFacilityAggregateGroups,
+    })
+    lastFacilityAggregateGroups = facilityAggregateResult.groups
+    const badgeGroups = [
+        ...aggregateResult.groups,
+        ...pointAggregateResult.groups,
+        ...facilityAggregateResult.groups,
+    ].filter((group) => group.count > 1)
     const groupedMemberKeys = new Set()
     for (const group of badgeGroups) {
-        for (const member of group.members) groupedMemberKeys.add(`${group.memberKind}|${member.code}`)
+        for (const member of group.members) {
+            // 设施成员的 key 已含类型+实体 id;设备/点位沿用 kind|code。
+            groupedMemberKeys.add(member.key || `${group.memberKind}|${member.code}`)
+        }
     }
-    // 标签避让(2026-11-24):聚合徽章优先;徽章附近的单体名称标签默认折叠,hover 到该单体时展开。
-    const badgeCenters = badgeGroups.map((group) => group.screen)
+    // 跨类避让:同位置三类徽章做固定小三角偏移,细引线指回真实锚点;进出有缓冲。
+    const badgeLayout = planBadgeOffsets(badgeGroups, { previousKeys: previousBadgeOffsetKeys })
+    previousBadgeOffsetKeys = new Set([...badgeLayout.entries()]
+        .filter(([, layout]) => layout.leader)
+        .map(([key]) => key))
+    currentBadgeLayout = badgeLayout
+    // 标签避让(2026-11-24):聚合徽章优先;用徽章**视觉位置**(含跨类偏移)折标签。
+    const badgeCenters = badgeGroups.map((group) => badgeLayout.get(group.groupKey) || group.screen)
     const labelBlockedByAggregate = (pos) => labelOccludedByAggregates(pos, badgeCenters)
 
     // 深度排序(2026-11-25):先收集本帧全部可见对象,一次全局排序分配**唯一**序号;
     // 不再逐条算 z(同 z 会退回 DOM 顺序,徽章重建就会闪)。距离近似时沿用上一帧顺序。
-    const facilityPositions = new Map()
-    for (const facility of facilities || []) {
-        const key = facility.key || `facility-point|${facility.code}`
-        if (!Number.isFinite(facility.longitude) || !Number.isFinite(facility.latitude)) continue
-        const pos = projectToWindow(facility.longitude, facility.latitude)
-        if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) facilityPositions.set(key, pos)
-    }
-    const componentPositions = new Map()
-    for (const component of pipeComponentsVisible === false ? [] : (pipeComponents || [])) {
-        const key = component.key || `pipe-component|${component.code}`
-        if (!Number.isFinite(component.longitude) || !Number.isFinite(component.latitude)) continue
-        const pos = projectToWindow(component.longitude, component.latitude)
-        if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) componentPositions.set(key, pos)
-    }
     const depthEntries = []
     for (const marker of markers || []) {
         if (!marker) continue
@@ -1569,7 +1655,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
     }
 
     // 本票:聚合徽章(未关联设备按屏幕拥挤合并后的显示入口)。
-    renderAggregates(badgeGroups, tones)
+    renderAggregates(badgeGroups, tones, badgeLayout)
 
     // 关联设备(票 47 维护者反馈②根因:设备是独立 billboard 图层,此前 DOM 只渲染
     // 摘要标记计划、关联设备根本没进 DOM)。行由引擎每帧投影产出(屏幕坐标真值 +
@@ -1734,6 +1820,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
     // 计划行已由 store 按设施类型 + 全局行业/片区筛好;这里只按一级模式显隐(计划层收口)。
     for (const facility of facilities || []) {
         const key = facility.key || `facility-point|${facility.code}`
+        if (groupedMemberKeys.has(key)) { hidePooledNode(key); continue }
         wanted.add(key)
         if (!Number.isFinite(facility.longitude) || !Number.isFinite(facility.latitude)) { hidePooledNode(key); continue }
         const windowPos = facilityPositions.get(key)
@@ -1925,6 +2012,9 @@ export function unmountMarkerOverlay() {
     aggregateSelectedCode = ''
     lastAggregateGroups = []
     lastPointAggregateGroups = []
+    lastFacilityAggregateGroups = []
+    currentBadgeLayout = new Map()
+    previousBadgeOffsetKeys = new Set()
     pool.clear()
 }