| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- /**
- * 设施点(水厂 / 泵站 / 水源地 / 用水户 / 消火栓 / 闸门 / 调蓄设施 / 窨井)—— 票 68/04/06 的领域层。
- *
- * 与「管线与构件」(`domain/pipeNetwork.js`)分属不同对象域,不共用口径:
- * · 管线/构件来自 `/infrastructure/geometry`,每个 feature 带后端 `coordinateValidation`;
- * · 设施点类型来自设施台账:`/infrastructure/operating-information` 给出可枚举的设施实体
- * (`facilityId` + `facilityKind`),坐标取自 `/entities/{id}/detail` 的 `coordinates`。
- *
- * **准入纪律(票 07 的边界,写清差异而不是假装没有)**:
- * 实体详情不带几何图层那套 `coordinateValidation`,所以本层**不做**第二套范围校核、
- * 不纠偏、不补默认坐标 —— 有坐标(有限数字)就按设施点上图,没有就进「无地图位置」清单,
- * 与票 07「宁可不上图,也不摆一个假位置」同一条立场。该契约差异登记在票 68 的契约缺口里。
- *
- * 设施点类型与后端命名空间:
- * · `WATER_PLANT`(水厂)—— `facilityTypeDistribution` / 实体类别同名;
- * · `PUMP_STATION`(泵站)—— 后端两类 `WATER_PUMP_STATION` / `DRAINAGE_PUMP_STATION`
- * 在图例上并为一类,实体类别统一为 `PUMP_STATION`;
- * · `WATER_SOURCE`(水源地)—— 后方票 01 已补实体行与详情类别,与其余类型同链(票 02);
- * · `WATER_USER`(用水户)—— 票 05 起前端已按目标契约接入详情;旧载荷若未下发则如实留空。
- */
- import { NO_MAP_LOCATION_TEXT } from './coordinate.js'
- import { facilityStatusTone } from './entityDetail.js'
- import { districtQuery, industryQuery } from './filterOptions.js'
- // MANHOLE(维护者 2026-11-16):后端 CockpitEntityCategory 与详情服务已支持窨井,
- // 本白名单同步放行 —— 否则后端能回详情、界面却仍提示「设施类别未发布」。
- export const FACILITY_DETAIL_CATEGORIES = Object.freeze(['WATER_PLANT', 'PUMP_STATION', 'WATER_SOURCE', 'PIPE_NETWORK', 'DRAINAGE_GATE', 'DRAINAGE_STORAGE', 'WATER_USER', 'WATER_FIRE_HYDRANT', 'MANHOLE'])
- /** 设施点类型的稳定键(进 filterStore、data-* 断言面与测试,不用中文)。 */
- export const FACILITY_POINT_TYPE = Object.freeze({
- WATER_PLANT: 'WATER_PLANT',
- PUMP_STATION: 'PUMP_STATION',
- WATER_SOURCE: 'WATER_SOURCE',
- WATER_USER: 'WATER_USER',
- WATER_FIRE_HYDRANT: 'WATER_FIRE_HYDRANT',
- DRAINAGE_GATE: 'DRAINAGE_GATE',
- DRAINAGE_STORAGE: 'DRAINAGE_STORAGE',
- MANHOLE: 'MANHOLE',
- })
- /**
- * 展示词表(顺序=图例行顺序)。`symbol` 是图标语义名(`domain/icons.js` 注册),
- * 不在本层拼物理路径;`archiveCodes` 是基础档案 `facilityTypeDistribution[].code` 的归属。
- */
- export const FACILITY_POINT_TYPES = Object.freeze([
- {
- key: FACILITY_POINT_TYPE.WATER_PLANT,
- label: '水厂',
- unit: '座',
- symbol: 'facilityPlant',
- archiveCodes: ['WATER_PLANT'],
- detailCategory: 'WATER_PLANT',
- },
- {
- key: FACILITY_POINT_TYPE.PUMP_STATION,
- label: '泵站',
- unit: '座',
- symbol: 'facilityPump',
- archiveCodes: ['WATER_PUMP_STATION', 'DRAINAGE_PUMP_STATION'],
- detailCategory: 'PUMP_STATION',
- },
- {
- key: FACILITY_POINT_TYPE.WATER_FIRE_HYDRANT,
- label: '消火栓',
- unit: '座',
- // 票 06:专属图标后续补,先复用可辨的工程设施占位符号。
- symbol: 'pipeSpecial',
- archiveCodes: ['WATER_FIRE_HYDRANT'],
- detailCategory: 'WATER_FIRE_HYDRANT',
- },
- {
- key: FACILITY_POINT_TYPE.DRAINAGE_GATE,
- label: '闸门',
- unit: '座',
- symbol: 'pipeSpecial',
- archiveCodes: ['DRAINAGE_GATE'],
- detailCategory: 'DRAINAGE_GATE',
- },
- {
- key: FACILITY_POINT_TYPE.DRAINAGE_STORAGE,
- label: '调蓄设施',
- unit: '座',
- symbol: 'pipeSpecial',
- archiveCodes: ['DRAINAGE_STORAGE'],
- detailCategory: 'DRAINAGE_STORAGE',
- },
- {
- // 窨井(维护者 2026-11-16):与泵站/水厂同链 —— 点击先弹设施详情面板,
- // 面板里再由「查看详情」按钮进「地下管线详情视图」。
- key: FACILITY_POINT_TYPE.MANHOLE,
- label: '窨井',
- unit: '座',
- symbol: 'facilityManhole',
- archiveCodes: ['MANHOLE'],
- detailCategory: 'MANHOLE',
- },
- {
- key: FACILITY_POINT_TYPE.WATER_SOURCE,
- label: '水源地',
- unit: '处',
- symbol: 'facilitySource',
- archiveCodes: ['WATER_SOURCE'],
- // 票 02:后端已提供 WATER_SOURCE 详情类别并返回经纬度,水源地不再是有图例没点的类型。
- detailCategory: 'WATER_SOURCE',
- },
- {
- key: FACILITY_POINT_TYPE.WATER_USER,
- label: '用水户',
- unit: '户',
- symbol: 'facilityUser',
- archiveCodes: ['WATER_USER'],
- // 票 05:后端目标态已提供 WATER_USER 详情类别,用水户不再是有名无实的图例项。
- detailCategory: 'WATER_USER',
- },
- ])
- /** 设施点的两种落位(与 `domain/pipeNetwork.js` 的 blocked 同义:不上图 ≠ 不存在)。 */
- export const FACILITY_PLACEMENT = Object.freeze({
- DRAWN: 'drawn',
- NO_LOCATION: 'no-location',
- })
- /** 不上图原因(`reasonCode` 只进 data-* 与断言,`reasonText` 才上界面)。 */
- export const FACILITY_NO_LOCATION_REASON = Object.freeze({
- MISSING_COORDINATE: 'MISSING_COORDINATE',
- DETAIL_UNAVAILABLE: 'DETAIL_UNAVAILABLE',
- })
- /** 图例行的数据状态(决定 tooltip 的口径说明,不进色键)。 */
- export const FACILITY_LEGEND_STATE = Object.freeze({
- /** 实体可枚举且全部可上图。 */
- READY: 'ready',
- /** 实体可枚举,但有一部分没有坐标(进「无地图位置」)。 */
- PARTIAL: 'partial',
- /** 档案有计数,但 cockpit 没有下发可上图的实体。 */
- NO_ENTITY: 'no-entity',
- /** 档案都没有这个类型(后端未发布)。 */
- UNPUBLISHED: 'unpublished',
- /** 设施点图层本身没取到(不是「这里没有设施」)。 */
- UNAVAILABLE: 'unavailable',
- })
- const TYPE_META = new Map(FACILITY_POINT_TYPES.map((meta) => [meta.key, meta]))
- const ARCHIVE_TYPE = new Map(FACILITY_POINT_TYPES.flatMap((meta) => meta.archiveCodes.map((code) => [code, meta.key])))
- function text(value) {
- return typeof value === 'string' ? value.trim() : ''
- }
- /** 设施类型元数据;认不出的返回 null(调用方如实跳过,不猜)。 */
- export function facilityTypeMeta(type) {
- return TYPE_META.get(type) || null
- }
- /** 是否设施点类型之一(filterStore 的取值域)。 */
- export function isKnownFacilityType(type) {
- return TYPE_META.has(type)
- }
- /**
- * 后端设施类型 → 前端四类之一;认不出的返回空串(不硬塞进某一类)。
- * 泵站合并两类后端码;其余按同名映射。
- */
- export function normalizeFacilityType(value) {
- const code = text(value).toUpperCase()
- if (!code) return ''
- if (ARCHIVE_TYPE.has(code)) return ARCHIVE_TYPE.get(code)
- // 实体详情的 `category` 与设施台账的 `facilityKind` 都可能是 WATER_PLANT / PUMP_STATION。
- if (code === 'WATER_PLANT' || code === 'PUMP_STATION' || code === 'WATER_SOURCE'
- || code === 'WATER_USER' || code === 'WATER_FIRE_HYDRANT'
- || code === 'DRAINAGE_GATE' || code === 'DRAINAGE_STORAGE'
- || code === 'MANHOLE') return code
- return ''
- }
- /**
- * 运行信息指标 → 可枚举的设施实体行(去重,按 `facilityKind + facilityId`)。
- *
- * 为什么从运行信息枚举:cockpit 没有「设施列表」端点,而运行信息端点**每条指标对应一个设施**,
- * 行上带 `facilityId` / `facilityKind` / `facilityStatus` / `pointCodes`(票 73/65 已消费)。
- * 只取设施点类型;管线实体(`PIPE_NETWORK`)不属本层(管线有自己的几何图层)。
- *
- * @param {object} payload `/infrastructure/operating-information` 的 data
- * @returns {Array<{key:string,type:string,id:string,code:string,name:string,status:string,industry:string}>}
- */
- export function facilityRowsFromOperating(payload) {
- const blocks = payload && Array.isArray(payload.industries) ? payload.industries : []
- const rows = []
- const seen = new Set()
- for (const block of blocks) {
- // 真实载荷的行业名在 `block.industry.code`(不是 `block.code`),mock 同形。
- const industry = text(block && block.industry && block.industry.code) || text(block && block.code)
- const metrics = block && Array.isArray(block.metrics) ? block.metrics : []
- for (const metric of metrics) {
- const type = normalizeFacilityType(metric && metric.facilityKind)
- const id = text(metric && metric.facilityId)
- if (!type || !id) continue
- const key = type + '|' + id
- if (seen.has(key)) continue
- seen.add(key)
- const codes = metric && Array.isArray(metric.pointCodes) ? metric.pointCodes : []
- rows.push({
- key,
- type,
- id,
- code: text(codes[0]),
- name: text(metric && metric.metricName),
- status: metric && metric.facilityStatus !== null && metric.facilityStatus !== undefined
- ? String(metric.facilityStatus)
- : '',
- industry,
- // 片区的权威值来自台账行(设施档案没有片区字段时就是 null=未分区),不按编码前缀猜。
- district: metric && Number.isInteger(metric.district) ? metric.district : null,
- })
- }
- }
- return rows
- }
- /** 需要向实体详情补坐标的行(只有后端声明了实体类别的两类)。 */
- export function facilityDetailRequests(rows) {
- return (Array.isArray(rows) ? rows : [])
- .map((row) => ({ key: row.key, id: row.id, category: (facilityTypeMeta(row.type) || {}).detailCategory || '' }))
- .filter((request) => request.id && request.category)
- }
- /** 实体详情里的坐标:只认有限数字;null / 缺字段 / 非数字一律 null(不补 0、不猜)。 */
- function coordinateOf(detail) {
- const source = detail && detail.coordinates
- if (!source || typeof source !== 'object') return null
- const longitude = typeof source.longitude === 'number' && Number.isFinite(source.longitude) ? source.longitude : null
- const latitude = typeof source.latitude === 'number' && Number.isFinite(source.latitude) ? source.latitude : null
- return longitude === null || latitude === null ? null : { longitude, latitude }
- }
- /**
- * 设施行 + 实体详情 → 设施点(带落位结论)。
- *
- * `details` 是 `key → { ok, detail }` 的映射(key 与 `facilityRowsFromOperating()` 的 `key` 同)。
- * 详情失败与「详情成功但没有坐标」是两句不同的话,原因码分开记。
- *
- * @param {Array} rows `facilityRowsFromOperating()` 的输出
- * @param {object} details 实体详情结果映射
- * @returns {Array} 设施点(`placement` 为 drawn / no-location)
- */
- export function facilityPointsWithDetails(rows, details) {
- const source = details && typeof details === 'object' ? details : {}
- return (Array.isArray(rows) ? rows : []).map((row) => {
- const result = source[row.key] || null
- const detail = result && result.ok ? result.detail : null
- const coordinates = coordinateOf(detail)
- const drawn = coordinates !== null
- const reason = drawn
- ? { code: '', text: '' }
- : result && !result.ok
- ? { code: FACILITY_NO_LOCATION_REASON.DETAIL_UNAVAILABLE, text: '设施详情未取到,坐标不可用' }
- : { code: FACILITY_NO_LOCATION_REASON.MISSING_COORDINATE, text: '设施档案未登记坐标' }
- const status = detail && detail.status !== undefined && detail.status !== null ? String(detail.status) : row.status
- return {
- ...row,
- key: 'facility-point|' + row.type + '|' + row.id,
- code: text(detail && detail.code) || row.code,
- name: text(detail && detail.name) || row.name,
- status,
- // 状态色键与设施详情/运行信息面板同一份(`entityDetail.facilityStatusTone`),不另写一套。
- tone: facilityStatusTone(status),
- longitude: coordinates ? coordinates.longitude : null,
- latitude: coordinates ? coordinates.latitude : null,
- placement: drawn ? FACILITY_PLACEMENT.DRAWN : FACILITY_PLACEMENT.NO_LOCATION,
- reasonCode: reason.code,
- reasonText: reason.text,
- }
- })
- }
- /** 设施点 → 地图标记计划输入(只含可上图的行;形状由 markerPlan 决定,本层不拼素材)。 */
- export function facilityPointMarkers(points) {
- return (Array.isArray(points) ? points : [])
- .filter((row) => row && row.placement === FACILITY_PLACEMENT.DRAWN
- && typeof row.longitude === 'number' && Number.isFinite(row.longitude)
- && typeof row.latitude === 'number' && Number.isFinite(row.latitude))
- .map((row) => {
- const meta = facilityTypeMeta(row.type) || {}
- return {
- // 覆盖层节点池的键:用实体主键(现网两座水厂共用编码 WP001,编码做键会互相顶掉)。
- key: row.key,
- kind: 'facility-point',
- code: row.code || '',
- name: row.name || row.code || '设施名称未提供',
- type: row.type,
- symbol: meta.symbol || (FACILITY_DETAIL_CATEGORIES.includes(row.type) ? 'pipeSpecial' : ''),
- status: row.status,
- // 状态色键随标记下发(`facilityStatusTone` 的结果),渲染层不再自己判设施状态色。
- tone: row.tone || '',
- // 票 101:点击身份 —— 与「设施台账」卡片点击构造同一份 entity identity
- // (kind='facility' + 实体主键 + 类别)。缺主键/类别的行**不可点**(不伪装)。
- entityId: row.id || '',
- detailCategory: meta.detailCategory || (FACILITY_DETAIL_CATEGORIES.includes(row.type) ? row.type : ''),
- industry: row.industry || '',
- clickable: Boolean(row.id && FACILITY_DETAIL_CATEGORIES.includes(row.type)),
- longitude: row.longitude,
- latitude: row.latitude,
- }
- })
- }
- /** 选中集合归一:只保留设施点类型键、去重;空集合=不筛(与 pointStatus 的多选语义一致)。 */
- export function selectedFacilityTypes(selected) {
- const list = Array.isArray(selected) ? selected : []
- const result = new Set()
- for (const item of list) {
- const value = text(item).toUpperCase()
- if (isKnownFacilityType(value)) result.add(value)
- }
- return result
- }
- /**
- * 设施筛选(多选 OR):空数组=全部;认不出的键忽略。
- * 只裁设施点本身 —— 监测点/设备的筛选是另一个维度(`filterStore.pointStatus`),
- * 两类对象互不重叠,同时生效时并非「取交集」,而是各自裁剪(写进票面与图例说明)。
- *
- * 行业/片区是**全局条件**,与管线图层同一条纪律(`domain/pipeNetwork.js` 的
- * `filterPipeNetwork`):设施行带台账给的 `industry` 与 `district`,这里按同一张
- * 前后端映射表裁剪;认不出/缺失的如实归「未分区」,不按编码前缀猜。
- *
- * @param {Array} points 设施点
- * @param {Array} selected 设施类型集合(filterStore.facilityTypes)
- * @param {{industry?: string, scope?: string}} [filters] 全局行业/片区条件(前端键)
- */
- export function filterFacilityPoints(points, selected, filters = {}) {
- const list = Array.isArray(points) ? points : []
- const chosen = selectedFacilityTypes(selected)
- const industry = industryQuery(filters.industry)
- const district = districtQuery(filters.scope)
- return list.filter((row) => {
- if (!row) return false
- if (chosen.size && !chosen.has(row.type)) return false
- if (industry && row.industry !== industry) return false
- if (district === '') return true
- if (district === 'UNASSIGNED') return row.district === null
- return row.district === district
- })
- }
- function countOf(value) {
- const number = Number(value)
- return Number.isFinite(number) ? number : 0
- }
- /**
- * 设施点类型的档案口径与图层口径(图例与票面对账的唯一来源)。
- *
- * 两个计数**主语不同、都不随筛选变化**(与顶部状态图例「全局未筛口径」同一条纪律):
- * · `archiveCount` —— 基础档案 `facilityTypeDistribution` 的全局计数(后端未发布该类型=null,不是 0);
- * · `mappableCount` —— 当前设施点图层里真正能上图的条数(实体可枚举且坐标齐)。
- * `enumerableCount` 是「运行信息能枚举出的实体数」,与 `archiveCount` 的差如实留给
- * `archiveGapCount`(如排水泵站不在运行信息下发范围内),不拿它冒充完整。
- *
- * @param {object|null} archivePayload `/infrastructure/base-archives` 的 data(取不到=null)
- * @param {Array|null} points 设施点(图层失败=null,不是空数组)
- */
- export function facilityInventory(archivePayload, points) {
- const list = Array.isArray(points) ? points : null
- const distribution = archivePayload && Array.isArray(archivePayload.facilityTypeDistribution)
- ? archivePayload.facilityTypeDistribution
- : null
- return FACILITY_POINT_TYPES.map((meta) => {
- let archiveCount = null
- if (distribution) {
- // 档案类型码经同一个归一函数归到四类(真实 `WATER_PUMP_STATION`/mock `PUMP_STATION` 都认)。
- const matched = distribution.filter((row) => normalizeFacilityType(row && row.code) === meta.key)
- // 类型没出现在档案分布里=后端未发布该类型,不是「0 个」(票 05 的用水户按目标契约应出现)。
- archiveCount = matched.length ? matched.reduce((sum, row) => sum + countOf(row && row.count), 0) : null
- }
- const rows = list ? list.filter((row) => row && row.type === meta.key) : []
- const mappableCount = rows.filter((row) => row.placement === FACILITY_PLACEMENT.DRAWN).length
- const enumerableCount = rows.length
- let state
- if (!list) state = FACILITY_LEGEND_STATE.UNAVAILABLE
- else if (archiveCount === null && enumerableCount === 0) state = FACILITY_LEGEND_STATE.UNPUBLISHED
- else if (enumerableCount === 0) state = FACILITY_LEGEND_STATE.NO_ENTITY
- else if (mappableCount < enumerableCount) state = FACILITY_LEGEND_STATE.PARTIAL
- else state = FACILITY_LEGEND_STATE.READY
- return {
- key: meta.key,
- label: meta.label,
- unit: meta.unit,
- symbol: meta.symbol,
- archiveCount,
- enumerableCount,
- mappableCount,
- blockedCount: enumerableCount - mappableCount,
- archiveGapCount: archiveCount === null ? null : Math.max(0, archiveCount - enumerableCount),
- state,
- }
- })
- }
- /**
- * 设施图例行的图标(票 05 复验:图例中也要有对应图标)。
- *
- * 与运行信息九卡共用同一套 icon.kpi.* 资源:类型 → CockpitIcon 语义名一一对应,
- * 不再用旧的 pipeSpecial 泛指闸门/调蓄/消火栓(它未在图标注册表登记,等于没图标)。
- * 图例与九卡看见的是同一枚剪影、同一档语义色,靠结构而不是约定保持一致。
- */
- export const FACILITY_LEGEND_ICON = Object.freeze({
- PIPE_NETWORK: 'kpiPipeSegment',
- WATER_PLANT: 'kpiPlant',
- PUMP_STATION: 'kpiPump',
- WATER_SOURCE: 'kpiSource',
- WATER_USER: 'kpiUser',
- WATER_FIRE_HYDRANT: 'kpiHydrant',
- DRAINAGE_GATE: 'kpiGate',
- DRAINAGE_STORAGE: 'kpiStorage',
- MANHOLE: 'kpiManhole',
- })
- /** 管线三类档案码:管段数量=燃气/供水/排水三类之和。 */
- export const PIPE_ARCHIVE_CODES = Object.freeze(['GAS_PIPE', 'WATER_PIPE', 'DRAINAGE_PIPE'])
- /**
- * 基础档案的设施类型分布 → 九类设施计数(票 06)。
- *
- * 为什么不用运行信息行数:运行信息只下发“有指标”的设施,水厂/泵站/水源地会因能力值为空
- * 而缺席;拿它计数会把“后端没下发”读成“确实是 0”。基础档案的设施类型分布是计数口径,
- * 与「基础档案」面板同源。
- *
- * 缺失语义留给调用方:返回 `null` 表示档案里没有该类型(无筛选时=未发布,有筛选时=范围内没有),
- * 由面板按 `filtered` 决定显示「—」还是 0;本函数不替调用方猜。
- *
- * @param {Array|null} facilityTypes 档案 `facilityTypeDistribution` 归并后的 `{code,count}` 行
- * @returns {object|null} 九类计数(缺失为 null);输入不是数组时回 null(档案未取到)
- */
- export function facilityCountsFromArchive(facilityTypes) {
- const rows = Array.isArray(facilityTypes) ? facilityTypes : null
- if (!rows) return null
- const byCode = new Map()
- for (const row of rows) {
- const code = String((row && row.code) || '').trim().toUpperCase()
- if (!code) continue
- const count = Number(row.count)
- byCode.set(code, Number.isFinite(count) ? count : 0)
- }
- const sum = (codes) => {
- const present = codes.filter((code) => byCode.has(code))
- return present.length ? present.reduce((total, code) => total + byCode.get(code), 0) : null
- }
- const counts = { PIPE_NETWORK: sum(PIPE_ARCHIVE_CODES) }
- for (const meta of FACILITY_POINT_TYPES) counts[meta.key] = sum(meta.archiveCodes)
- return counts
- }
- function legendHint(row) {
- if (!row) return ''
- if (row.state === FACILITY_LEGEND_STATE.UNAVAILABLE) return '设施点数据未取到'
- if (row.state === FACILITY_LEGEND_STATE.UNPUBLISHED) return '后端尚未下发该类设施'
- if (row.state === FACILITY_LEGEND_STATE.NO_ENTITY && row.archiveCount !== null) {
- return '档案有 ' + row.archiveCount + ' ' + row.unit + ',但后端未下发可上图的设施实体'
- }
- if (row.state === FACILITY_LEGEND_STATE.PARTIAL && row.blockedCount > 0) {
- return row.blockedCount + ' ' + row.unit + '未登记坐标,已进「无地图位置」'
- }
- if (row.archiveGapCount > 0) {
- return '档案共 ' + row.archiveCount + ' ' + row.unit + ',其中 ' + row.archiveGapCount + ' ' + row.unit + '不在设施点台账下发范围'
- }
- return ''
- }
- /**
- * 设施图例行(独立块的数据源)。
- *
- * 计数口径(写进行 title,避免两个数被读成一套):
- * `count` = 全局未筛档案数(不随筛选变化;null=未发布/未取到);
- * `onMap` = 当前图层可上图数(不随筛选变化 —— 筛选只改标记显隐,不改这个数)。
- * 实际画到图上的条数由地图宿主的 `data-map-facility-points` 单独报(随筛选变化),
- * 两个数各说各的主语,不互相冒充。
- *
- * @param {Array} inventory `facilityInventory()` 的输出
- * @param {Array} selected filterStore 里选中的设施类型
- */
- export function facilityLegendRows(inventory, selected) {
- const chosen = selectedFacilityTypes(selected)
- return (Array.isArray(inventory) ? inventory : []).map((row) => {
- const hint = legendHint(row)
- const countText = row.archiveCount === null ? '—' : String(row.archiveCount)
- return {
- key: row.key,
- label: row.label,
- unit: row.unit,
- symbol: row.symbol,
- // 图例专用图标(与九卡同源);没有对应类型时留空,渲染层再回落到 symbol。
- icon: FACILITY_LEGEND_ICON[row.key] || '',
- count: row.archiveCount,
- countText,
- onMap: row.mappableCount,
- selected: chosen.has(row.key),
- state: row.state,
- hint,
- title: chosen.has(row.key)
- ? '取消「' + row.label + '」筛选(多选;计数为全局档案口径,不随筛选变化)' + (hint ? ';' + hint : '')
- : '按「' + row.label + '」筛选(多选;计数为全局档案口径,可上图 ' + row.mappableCount + ' ' + row.unit + ')' + (hint ? ';' + hint : ''),
- }
- })
- }
- /**
- * 设施点 → 「无地图位置」总览附加项(票 07 纪律:不上图也要在清单里,不静默丢弃)。
- * 与 `domain/coordinate.js` 的 `facilityCoordinateExtra()` 同形,由调用方合并。
- *
- * 票 03:这里**不设设施类型白名单** —— 闸门、调蓄、水户、消火栓一旦进入设施点序列,
- * 有坐标就上图、无坐标就自动进同一份清单;类型身份由各自的票负责登记,不在这里重复过滤。
- */
- export function facilityPointCoordinateExtra(points) {
- const list = Array.isArray(points) ? points : []
- const drawn = list.filter((row) => row && row.placement === FACILITY_PLACEMENT.DRAWN)
- const blocked = list.filter((row) => row && row.placement === FACILITY_PLACEMENT.NO_LOCATION)
- return {
- renderable: drawn.length,
- blockedEntries: blocked.map((row) => ({
- // key 用实体主键而不是编码:现网两座水厂共用编码 WP001,编码做键会互相顶掉。
- key: row.key || ('facility-point|' + row.type + '|' + row.id),
- kind: 'facility-point',
- code: row.code || '',
- name: row.name || row.code || '设施名称未提供',
- reasonCode: row.reasonCode || '',
- reasonText: row.reasonText || NO_MAP_LOCATION_TEXT,
- })),
- }
- }
|