Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/EquipmentPointRel.java
#	pipe-network-service/zksy-system/src/main/java/com/zksy/base/domain/MonitorPoint.java
zengy 2 сар өмнө
parent
commit
af828ef4ba
37 өөрчлөгдсөн 2710 нэмэгдсэн , 134 устгасан
  1. 7 3
      audio-service/src/main/java/com/zksy/audio/service/NoiseLeakAlarmService.java
  2. 33 24
      docs/cockpit/README.md
  3. 14 3
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailController.java
  4. 3 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitDeviceFactResolverTest.java
  5. 4 2
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureBaseArchivesAdapterTest.java
  6. 5 3
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureOperatingInformationAdapterTest.java
  7. 308 2
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMapSnapshotAdapterTest.java
  8. 16 1
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringDistributionAdapterTest.java
  9. 143 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewInfrastructureAdapterTest.java
  10. 157 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewMonitoringAdapterTest.java
  11. 141 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewWarningSettingsAdapterTest.java
  12. 86 1
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitEquipmentDetailAggregateControllerTest.java
  13. 36 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMapSnapshotControllerTest.java
  14. 118 1
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailControllerTest.java
  15. 288 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailSnapshotContractTest.java
  16. 33 5
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitOverviewInfrastructureControllerTest.java
  17. 17 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitWorkOrderStateDictionaryTest.java
  18. 24 16
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/MonitoringServiceImpl.java
  19. 28 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/detail/CockpitEquipmentDetailAggregateService.java
  20. 25 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitSnapshotTime.java
  21. 5 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureBaseArchivesAdapter.java
  22. 6 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureOperatingInformationAdapter.java
  23. 125 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/BusinessCockpitMapSnapshotAdapter.java
  24. 12 6
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitMapSnapshotService.java
  25. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringDistributionAdapter.java
  26. 242 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewInfrastructureAdapter.java
  27. 258 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewMonitoringAdapter.java
  28. 283 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewWarningSettingsAdapter.java
  29. 27 13
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/CockpitOverviewInfrastructureService.java
  30. 27 16
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/CockpitOverviewMonitoringService.java
  31. 1 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/BusinessCockpitDeviceFactResolver.java
  32. 19 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitMonitoringPointDetailResponse.java
  33. 155 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitMonitoringPointDetailService.java
  34. 2 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/BusinessCockpitWorkOrderReadAdapter.java
  35. 21 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/CockpitWorkOrderStateDictionary.java
  36. 38 21
      pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/MonitoringServiceImplTest.java
  37. 2 4
      zk-api-service/src/main/java/com/zksy/api/mapper/DeviceContactApiMapper.java

+ 7 - 3
audio-service/src/main/java/com/zksy/audio/service/NoiseLeakAlarmService.java

@@ -148,7 +148,7 @@ public class NoiseLeakAlarmService {
             boolean newlyConfirmed = confirmedLeakEncode.add(encode);
             boolean newlyConfirmed = confirmedLeakEncode.add(encode);
             if (alarmCount == 1 || newlyConfirmed) {
             if (alarmCount == 1 || newlyConfirmed) {
                 run(encode, "一级漏失告警短信", () -> deviceNotifier.sendLevelOneSms(encode, "漏失报警", "RMS=" + rms));
                 run(encode, "一级漏失告警短信", () -> deviceNotifier.sendLevelOneSms(encode, "漏失报警", "RMS=" + rms));
-                if (saveLeakAlarm(encode, rms, count, lowerFreq, upperFreq)) {
+                if (saveLeakAlarm(encode, rms, count, maxValue, lowerFreq, upperFreq)) {
                     log.info("确认漏失告警: encode={}, 本次确认采用{}份独立采样", encode, count);
                     log.info("确认漏失告警: encode={}, 本次确认采用{}份独立采样", encode, count);
                 } else {
                 } else {
                     confirmedLeakEncode.remove(encode);
                     confirmedLeakEncode.remove(encode);
@@ -184,18 +184,22 @@ public class NoiseLeakAlarmService {
                 .le(NoiseInfo::getCenterFrequency, upperFreq));
                 .le(NoiseInfo::getCenterFrequency, upperFreq));
     }
     }
 
 
-    private boolean saveLeakAlarm(String encode, Integer rms, long count, double lowerFreq, double upperFreq) {
+    private boolean saveLeakAlarm(String encode, Integer rms, long count, Double maxValue,
+                                  double lowerFreq, double upperFreq) {
         AlarmData alarm = new AlarmData();
         AlarmData alarm = new AlarmData();
         alarm.setDeviceCode(encode);
         alarm.setDeviceCode(encode);
         alarm.setWarningType("漏失报警");
         alarm.setWarningType("漏失报警");
         alarm.setWarningCode(LEAK_WARNING_CODE);
         alarm.setWarningCode(LEAK_WARNING_CODE);
+        // 漏失告警只在 alarm_data 中保存 RMS 的越限上限;最小值仅用于恢复判断,不入库。
+        if (maxValue != null) {
+            alarm.setMaxValue(BigDecimal.valueOf(maxValue));
+        }
         if (rms != null) {
         if (rms != null) {
             alarm.setActualValue(BigDecimal.valueOf(rms));
             alarm.setActualValue(BigDecimal.valueOf(rms));
         }
         }
         alarm.setAlarmLevel(1);
         alarm.setAlarmLevel(1);
         alarm.setAlarmStatus(0);
         alarm.setAlarmStatus(0);
         alarm.setCreateTime(LocalDateTime.now());
         alarm.setCreateTime(LocalDateTime.now());
-        alarm.setCreateTime(LocalDateTime.now());
         alarm.setRemark(alarmCount == 1
         alarm.setRemark(alarmCount == 1
                 ? String.format("漏失监测单次独立采样确认:rms≥阈值且在漏失频段[%.0f,%.0f]Hz", lowerFreq, upperFreq)
                 ? String.format("漏失监测单次独立采样确认:rms≥阈值且在漏失频段[%.0f,%.0f]Hz", lowerFreq, upperFreq)
                 : String.format("漏失监测确认漏失:最近%d分钟内%d次采样rms≥阈值且在漏失频段[%.0f,%.0f]Hz",
                 : String.format("漏失监测确认漏失:最近%d分钟内%d次采样rms≥阈值且在漏失频段[%.0f,%.0f]Hz",

+ 33 - 24
docs/cockpit/README.md

@@ -1,6 +1,6 @@
 # 城市生命线驾驶舱后端契约:移交与联调手册
 # 城市生命线驾驶舱后端契约:移交与联调手册
 
 
-本手册面向 UE / 前端对接团队,记录 `/api/cockpit/v1/` 的目标契约、字典、分页、错误与实时增量口径,并给出联调检查表。**当前代码与数据库已于 2026-09-24 发生结构变化,旧冻结字典不能直接当成当前运行时验收结果;第 8 节的“当前重建基线”优先于历史描述。**对应的契约测试仍为 `CockpitContractIntegrationTest` 与 `CockpitContractDictionaryTest`,但目前工作树编译未通过,不能宣称这些测试已在新模型下通过。
+本手册面向 UE / 前端对接团队,记录 `/api/cockpit/v1/` 的目标契约、字典、分页、错误与实时增量口径,并给出联调检查表。**当前代码与数据库已于 2026-09-24 发生结构变化,旧冻结字典不能直接当成当前运行时验收结果;第 8 节的“当前重建基线”优先于历史描述。**对应的契约测试仍为 `CockpitContractIntegrationTest` 与 `CockpitContractDictionaryTest`(#69 起新增 `CockpitMonitoringPointDetailSnapshotContractTest` 覆盖跨端点同快照契约);第 3 行早期“工作树编译未通过”仅描述 2026-09-24 前的状态,当前可编译状态以第 8 节为准。
 
 
 ## 1. 契约总则
 ## 1. 契约总则
 
 
@@ -50,7 +50,7 @@
 | 用途 | 端点 |
 | 用途 | 端点 |
 | --- | --- |
 | --- | --- |
 | 地图分页快照(**地图取数路径**) | `GET /api/cockpit/v1/map-snapshot?page&pageSize&snapshotAt&industry&region&deviceType` |
 | 地图分页快照(**地图取数路径**) | `GET /api/cockpit/v1/map-snapshot?page&pageSize&snapshotAt&industry&region&deviceType` |
-| 监测点详情 | `GET /api/cockpit/v1/monitoring-points/{monitoringPointCode}` |
+| 监测点详情 | `GET /api/cockpit/v1/monitoring-points/{monitoringPointCode}?snapshotAt` |
 | 设备档案(含最新图片) | `GET /api/cockpit/v1/equipments/{deviceCode}/archive` |
 | 设备档案(含最新图片) | `GET /api/cockpit/v1/equipments/{deviceCode}/archive` |
 | 类型指标 | `GET /api/cockpit/v1/equipments/{deviceCode}/metrics/current`、`.../metrics/history` |
 | 类型指标 | `GET /api/cockpit/v1/equipments/{deviceCode}/metrics/current`、`.../metrics/history` |
 | 事件 | `GET /api/cockpit/v1/equipments/{deviceCode}/events/current`、`.../events/history` |
 | 事件 | `GET /api/cockpit/v1/equipments/{deviceCode}/events/current`、`.../events/history` |
@@ -65,7 +65,7 @@
 **全局行业/范围筛选落到地图,以 `map-snapshot` 为准**(本结论替代「以 `/monitoring/distribution` 为准」的候选路径):
 **全局行业/范围筛选落到地图,以 `map-snapshot` 为准**(本结论替代「以 `/monitoring/distribution` 为准」的候选路径):
 
 
 - 地图(跨四个模式常驻的中央一张图)只从 `map-snapshot` 取数;`/monitoring/distribution` 是运行监测模式「监测分布」面板的载荷,不作为地图取数路径。
 - 地图(跨四个模式常驻的中央一张图)只从 `map-snapshot` 取数;`/monitoring/distribution` 是运行监测模式「监测分布」面板的载荷,不作为地图取数路径。
-- `map-snapshot` 的目标契约接受 `industry`、`region`、`deviceType` 三个筛选入参;分页与 `snapshotAt` 语义不因筛选改变。**2026-09-24 人工裁定**:正式行业扩为 `GAS` / `WATER_SUPPLY` / `DRAINAGE` / `MANHOLE`(井盖为独立根类型);对外 `typeCode` 使用 `equipment_type.id` 的字符串形式,`type_name` 仅用于展示。`monitoring/overview` 与 `monitoring/situation` 已按此接受 `MANHOLE`;地图、分布、事件和基础设施服务仍校验旧三行业,不能把第四行业说成全接口可用。旧 `type_id/parent_type_id` 不是当前 schema 字段。
+- `map-snapshot` 的目标契约接受 `industry`、`region`、`deviceType` 三个筛选入参;分页与 `snapshotAt` 语义不因筛选改变。**2026-09-24 人工裁定**:正式行业扩为 `GAS` / `WATER_SUPPLY` / `DRAINAGE` / `MANHOLE`(井盖为独立根类型);对外 `typeCode` 使用 `equipment_type.id` 的字符串形式,`type_name` 仅用于展示。`monitoring/overview`、`monitoring/situation`、`map-snapshot`、`monitoring/distribution`、事件和基础设施服务均按该四行业口径校验;对外 `typeCode` 使用 `equipment_type.id` 的字符串形式,`type_name` 仅用于展示。旧 `type_id/parent_type_id` 不是当前 schema 字段。
 - 服务端完成过滤,并在响应 `mapFilter{industry,region,deviceType,pointCodes,deviceCodes}` 回显**实际生效范围**(编码为过滤后全量、分页前,升序)。
 - 服务端完成过滤,并在响应 `mapFilter{industry,region,deviceType,pointCodes,deviceCodes}` 回显**实际生效范围**(编码为过滤后全量、分页前,升序)。
 - `coordinateValidation` 汇总是**当前筛选范围内的全量口径**(再切片分页);逐点/逐设备保留 `renderable=false` 的对象。
 - `coordinateValidation` 汇总是**当前筛选范围内的全量口径**(再切片分页);逐点/逐设备保留 `renderable=false` 的对象。
 - 逐点 `industry` 由类型推导(口径同 distribution:类型可解析、`objectKind = SMART_DEVICE`、行业属正式行业);不可推导时为 `null`,**默认不排除对象**,仅在请求了 `industry`/`deviceType` 过滤时按推导结果筛选。`region` 空值在响应中归一为 `未分区`。
 - 逐点 `industry` 由类型推导(口径同 distribution:类型可解析、`objectKind = SMART_DEVICE`、行业属正式行业);不可推导时为 `null`,**默认不排除对象**,仅在请求了 `industry`/`deviceType` 过滤时按推导结果筛选。`region` 空值在响应中归一为 `未分区`。
@@ -75,7 +75,7 @@
 ## 4. 分页、快照与错误口径
 ## 4. 分页、快照与错误口径
 
 
 - `page` 默认 1;`pageSize` 默认 100(地图快照默认 500),上限 1000;越界返回 `INVALID_REQUEST`。
 - `page` 默认 1;`pageSize` 默认 100(地图快照默认 500),上限 1000;越界返回 `INVALID_REQUEST`。
-- `map-snapshot` 的 `page > 1` 必须携带同一 `snapshotAt`,否则 `SNAPSHOT_EXPIRED`;同一 `snapshotAt` 下分页结果稳定,监测点优先、已关联设备不重复出点。
+- `map-snapshot` 的 `page > 1` 必须携带**首屏无 token 请求签发**的同一 `snapshotAt`,否则 `SNAPSHOT_EXPIRED`;显式 token 仅复用已签发快照,缓存未命中不得按该时间重读当前库。同一 `snapshotAt` 下分页结果稳定,监测点优先、已关联设备不重复出点。
 - 无效或未验证坐标的对象保留在列表与详情中,但 `coordinateValidation.renderable = false`,禁止渲染。
 - 无效或未验证坐标的对象保留在列表与详情中,但 `coordinateValidation.renderable = false`,禁止渲染。
 - 成功但无数据返回 200(例如 `freshness.state = EMPTY`),不得用 5xx 表达空;仅上游读取失败才 `SERVER_ERROR`。
 - 成功但无数据返回 200(例如 `freshness.state = EMPTY`),不得用 5xx 表达空;仅上游读取失败才 `SERVER_ERROR`。
 - 时间范围口径:预设 `range` 取值 `LAST_24_HOURS` / `LAST_7_DAYS` / `LAST_30_DAYS`(`infrastructure/operating-information` 与 `overview/warning-settings` 同款);显式区间用 `startTime`/`endTime`(ISO-8601 带偏移,必须成对出现且 `startTime ≤ endTime`,回显 `range.type = CUSTOM`)。`overview/warning-settings` 不声明窗口时维持 `CURRENT_BASELINE`(`start`/`end` 为 `null`,趋势桶不筛选)。
 - 时间范围口径:预设 `range` 取值 `LAST_24_HOURS` / `LAST_7_DAYS` / `LAST_30_DAYS`(`infrastructure/operating-information` 与 `overview/warning-settings` 同款);显式区间用 `startTime`/`endTime`(ISO-8601 带偏移,必须成对出现且 `startTime ≤ endTime`,回显 `range.type = CUSTOM`)。`overview/warning-settings` 不声明窗口时维持 `CURRENT_BASELINE`(`start`/`end` 为 `null`,趋势桶不筛选)。
@@ -97,7 +97,13 @@
 | `coordinateValidation.renderable` | 只有可信校核来源存在且坐标有效时为 `true`;前端仅在此为 `true` 时绘制设备点位。 |
 | `coordinateValidation.renderable` | 只有可信校核来源存在且坐标有效时为 `true`;前端仅在此为 `true` 时绘制设备点位。 |
 | `coordinateValidation.crs` | 当前统一为 `WGS84`。 |
 | `coordinateValidation.crs` | 当前统一为 `WGS84`。 |
 
 
-当前 `equipment_base` 没有可信坐标校核字段,因此真实适配器透传设备坐标但按 `UNVERIFIED_COORDINATE` 降级,`renderable=false`;设备仍保留在详情清单中。点位详情与 `map-snapshot` 都从同一设备关联关系和设备编码集合构造,均不因离线状态或坐标不可渲染而静默删除设备。
+当前 `equipment_base` 没有可信坐标校核字段,因此真实适配器透传设备坐标但按 `UNVERIFIED_COORDINATE` 降级,`renderable=false`;设备仍保留在详情清单中。
+
+**跨端点同快照(#69)**:
+
+- 监测点详情接受可选查询参数 `snapshotAt`(ISO-8601、必须带 `+08:00`,语义与 `map-snapshot` 一致)。提供 `snapshotAt` 时,详情与地图按时间戳复用首次读取的地图快照;相同时间戳不会因两次请求之间的点位/设备关联变化而重新读取,详情 `devices[]` 与 `map-snapshot` 对应点位的 `deviceCodes` 集合一致(含离线设备、不重复、不静默丢失)。快照存于 Redis,保留至 `snapshotAt` 后 10 分钟的有效窗口结束,应用节点共享;单节点本地最多缓存 256 份以减少 Redis 读取。过期时返回 `SNAPSHOT_EXPIRED`;Redis/缓存不可用返回 `SERVER_ERROR`,调用方应分别刷新快照或提示上游暂不可用。
+- 未提供 `snapshotAt` 时走详情适配器路径(尽力模式):两个请求之间点位-设备关系变化时,详情与地图集合可能不一致,前端按决策票 05「跨端点尽力展示并提示可能不一致」处理。
+- **当前正式交付边界**:`equipment_base` 暂无可信坐标校核字段,现网关联设备均按 `UNVERIFIED_COORDINATE` 降级、`renderable=false`,前端准入规则下**只保留设备清单、不绘制设备位置**。可信坐标校核来源(如基于设备安装定位/人工复核的 `coordinateVerified` 字段)需另行排期,由后端在数据源就绪后接入并回填。
 
 
 ## 5. WebSocket 实时增量
 ## 5. WebSocket 实时增量
 
 
@@ -163,13 +169,15 @@ mvn -pl zksy-admin -am test -Dtest='Cockpit*Test'
 - 内存基线:`ry.sh` 默认 `-Xms512m -Xmx1024m`,如需在驾驶舱工作站与渲染任务共存,建议按实际并发上调堆上限。
 - 内存基线:`ry.sh` 默认 `-Xms512m -Xmx1024m`,如需在驾驶舱工作站与渲染任务共存,建议按实际并发上调堆上限。
 - 性能测量:本轮未做生产规模压测,属未验证项;建议在取得真实设备规模后,用同一 `snapshotAt` 对 `map-snapshot` 与 `monitoring/distribution` 做分页吞吐与前端渲染测量,再决定是否加投影或索引。
 - 性能测量:本轮未做生产规模压测,属未验证项;建议在取得真实设备规模后,用同一 `snapshotAt` 对 `map-snapshot` 与 `monitoring/distribution` 做分页吞吐与前端渲染测量,再决定是否加投影或索引。
 
 
-## 8. 当前重建基线(2026-09-24)
+## 8. 当前重建基线(2026-09-28)
 
 
-本节记录需求重同步时读取到的当前代码与 KingbaseES 事实。它覆盖并取代 2026-09-18 以前的真实库数量与旧字段假设;不表示当前 cockpit 适配器已经可运行。
+本节记录本轮读取到的当前代码、KingbaseES schema 事实和真实 HTTP 验收结果;它覆盖并取代 2026-09-18 以前的真实库数量与旧字段假设。认证验收使用本机 IntelliJ 启动的 `127.0.0.1:8301`,该实例通过 Nacos 连接当前 KingbaseES;`192.168.110.30:8301` 部署端口仍不可达。
 
 
 ### 当前数据库模型
 ### 当前数据库模型
 
 
-- `equipment_type` 当前列为 `id`、`type_name`、`parent_id`;旧 `type_id`、`parent_type_id` 不存在。已裁定对外 `typeCode = String(equipment_type.id)`;行业沿类型树上溯到根,正式行业为 `GAS`、`WATER_SUPPLY`、`DRAINAGE`、`MANHOLE`。`monitoring/overview` 与 `monitoring/situation` 已使用该映射;其余切片尚未改完。
+- `equipment_type` 当前列为 `id`、`type_name`、`parent_id`;旧 `type_id`、`parent_type_id` 不存在。对外 `typeCode = String(equipment_type.id)`;行业沿类型树上溯到根,正式行业为 `GAS`、`WATER_SUPPLY`、`DRAINAGE`、`MANHOLE`。
+- `monitor_point` 当前实际列为 `point_id`、`point_code`、`point_name`、`location`、`longitude`、`latitude`、`remark`、`create_by`、`create_time`、`update_by`、`update_time`、`del_flag`;`network_id`、`point_type`、`installation_date`、`status` 不存在。Java 实体保留这些兼容字段但以 `@TableField(exist = false)` 标记,驾驶舱不臆造这些值。
+- `equipment_point_rel` 当前实际列为 `rel_id`、`equipment_id`、`point_id`、`create_time`,没有 `del_flag`;Java 兼容字段不参与持久化映射,关联查询按当前表列执行。
 - `equipment_base.equipment_type_id` 指向 `equipment_type.id`;`equipment_type_name` 是查询补充字段,不是持久化列。
 - `equipment_base.equipment_type_id` 指向 `equipment_type.id`;`equipment_type_name` 是查询补充字段,不是持久化列。
 - `work_order` 当前以 `device_id` 关联 `equipment_base.equipment_id`,不再有 `device_code`、`alarm_id`、`case_id`、`hazard_id` 列;报警转工单使用 `alarm_data.work_order_id → work_order.order_id`,案例和隐患分别通过各自的 `work_order_id` 关系读取。
 - `work_order` 当前以 `device_id` 关联 `equipment_base.equipment_id`,不再有 `device_code`、`alarm_id`、`case_id`、`hazard_id` 列;报警转工单使用 `alarm_data.work_order_id → work_order.order_id`,案例和隐患分别通过各自的 `work_order_id` 关系读取。
 - `alarm_data` 持久化 `device_code`、`work_order_id`、`warning_code`、`alarm_level`、`alarm_status`、`create_time`、`audit_status` 等;设备名称、设备类型、坐标、工单补充字段属于查询投影,不是表列。
 - `alarm_data` 持久化 `device_code`、`work_order_id`、`warning_code`、`alarm_level`、`alarm_status`、`create_time`、`audit_status` 等;设备名称、设备类型、坐标、工单补充字段属于查询投影,不是表列。
@@ -177,25 +185,26 @@ mvn -pl zksy-admin -am test -Dtest='Cockpit*Test'
 
 
 ### 当前真实库只读观测
 ### 当前真实库只读观测
 
 
-当前 KingbaseES `app_user` 观测值:`work_order=1`、`alarm_data=3`、`early_warning=35`、`alarm_warning_rel=3`、`equipment_base=2`、`equipment_status=2`、`monitor_point=7`、`equipment_point_rel=20`、`case_info=2`、`hazard_hidden_account=12`。
-
-- 当前两台设备中,一台为离线报警,一台在线正常;当前样例不能代表生产规模。
-- 20 条点位关系中 10 条逻辑有效,但当前两台设备均无法匹配到有效关系行,旧的“设备回联 3 条/37 台设备”数字已失效。
-- 3 条报警中 1 条通过 `alarm_data.work_order_id` 关联当前唯一工单;35 条预警中仅 6 条能经设备台账和类型层级解析类型。
-- 点位仍存在空坐标与 `(12,12)` 等异常坐标;坐标校核字段仍未出现在当前表模型中。按最小修改与现有校验器复用原则,缺可信校核来源一律 `coordinateVerified=false`、`renderable=false`;单纯经纬度范围校验会放过 `(12,12)`,不得用它代替业务校核。新增区域边界校核需另行确认边界与坐标系来源。
+- 既有只读探查记录:`work_order=1`、`alarm_data=3`、`early_warning=35`、`alarm_warning_rel=3`、`equipment_base=2`、`equipment_status=2`、`monitor_point=7`、`equipment_point_rel=20`、`case_info=2`、`hazard_hidden_account=12`;这些数量是观测时点事实,不代表生产规模。
+- 点位仍存在空坐标与 `(12,12)` 等异常坐标;当前 schema 没有可信坐标校核字段。缺可信校核来源一律 `coordinateVerified=false`、`renderable=false`;单纯经纬度范围校验不能替代业务校核。
+- 真实 `map-snapshot` HTTP 响应在本轮样例中返回 `total=15`,分页样例包含 9 个点位对象和 7 个设备编码;设备关系与样本数据会随数据库内容变化,响应的 `snapshotAt` 是唯一分页依据。
 
 
 ### 当前代码可验收性
 ### 当前代码可验收性
 
 
-本工作树**已重新编译通过**,但仍不是 #63 的验收基线:
-
-- 旧编译阻断(`WorkOrder::getDeviceCode`、`EquipmentType.getTypeId/getParentTypeId`)在当前工作树中已不存在;`mvn -pl zksy-admin -am compile -q` 于 2026-09-24 通过。
-- `monitoring/overview` 与 `monitoring/situation` 已把 `MANHOLE` 纳入正式行业,并沿类型树上溯到根。定向测试 34 例 0 失败:两个控制器测试、两个真实适配器测试。
-- 地图、分布、事件、基础设施等服务仍拒绝 `MANHOLE`。工单对外字典仍是旧 1–7 模型。第 6 节检查表的真实登录态联调没有执行。
-- 历史“4/22 片已接真实库”只代表旧 schema 下的尝试,不能当作当前验收。
-- 人工澄清:“工单字典”指代码枚举 `WorkOrderStatusEnum`,不是独立数据库表;其当前取值为 0–7,与 ADR-0010 一致。只读查询 `app_user.sys_dict_type`/`sys_dict_data` 未发现工单状态字典项,无需再以数据库字典表为联调前置条件。
+- `mvn -pl zksy-admin -am compile -q` 通过;`mvn -pl zksy-admin -am test "-DfailIfNoTests=false" -q` 全量回归通过。
+- 地图、分布、事件、基础设施及概览服务当前均接受四个正式行业;地图快照通过 Redis 共享同一 `snapshotAt` 内容,带 10 分钟有效窗口、过期重校验和单节点 256 条本地缓存上限。
+- 本轮 `11e5d9a` 进一步修正深层 `equipment_type.parent_id` 行业上溯、`RELEASED` 当前预警状态、未知行业不计入正式总量并进入 excluded,以及 `work_order_log.oper_type` 0–10 操作码到运行时 0–7 工单状态的时间线映射。
+- 本轮 `3e9289d` 为点位详情响应补充统一 `freshness` 和 `staleReason`:同 `snapshotAt` 快照返回 `CURRENT`,未提供快照的尽力路径显式标记 `BEST_EFFORT_SOURCE`,过期仍返回 `SNAPSHOT_EXPIRED`。
+- 本轮 `7e0d2c8` 将基础档案、运行信息和总体概览的共用泵站读取统一为显式 `station_type IN (water_supply, drainage)`,避免供水/排水数据串读。
+- 本机真实登录态 HTTP 验收通过:登录成功;未认证请求返回 401 `UNAUTHORIZED`;4 个非法参数样例返回 400 `INVALID_REQUEST`;同一 `snapshotAt` 的 5 页地图请求总数稳定且点位不重复;点位详情和同一设备的 archive / metrics / events / work-orders / detail-aggregate / freshness 均返回 200 且 `readOnly=true`;列出的概览、基础设施、监测、事件和契约自检端点均返回 200 且只读。
+- 本轮真实登录态补充验收:16 个端点非法参数样例全部返回 400 `INVALID_REQUEST`;以真实 `deviceCode` `860347065467627` 依次请求 archive、metrics、events、work-orders、detail-aggregate、freshness,均返回 200、`readOnly=true` 并回显同一 canonical `deviceCode`。
+- 第 4 轮 `detail-aggregate` 的 MockMvc 故障注入证明:单条时间线失败保留其余成功时间线和档案/指标;返回其他工单的顶层或内层日志编码会被拒绝,聚合仍以 200 `PARTIAL` 返回未受影响分区。这是契约测试证据,未在真实服务上制造业务故障。
+- **验收边界**:上述 200/readOnly 证明当前本机实例的认证与响应契约,不等于 #63 全部切片的代表性真实数据、空/脏数据及故障场景均已验收。仓库保留 `Empty*Adapter` 作为 fallback;对应接口另有 `@Primary Business*Adapter`,不能仅凭空实现类仍存在就判断运行时未接线。目标部署实例仍需验收,issue 保持开启。
+- WebSocket `/ws/deviceStatus` 真实浏览器验收通过:发送 `cockpitSubscribe(scope=all)` 后收到 `cockpitSubscribed`,响应带 `serverUpdatedAt`;所有抽查时间戳为 `+08:00`。
+- 目标部署地址 `192.168.110.30:8301` TCP 不可达,因此没有把它当作本轮 HTTP 证据;生产部署实例、性能压测、银河麒麟与 Docker 实机验证仍未执行。
 
 
 ## 9. 已知边界与未验证项
 ## 9. 已知边界与未验证项
 
 
-- 当前工单运行时状态以 ADR-0010 的 0–7 八值枚举为权威;旧 cockpit 七态目录仍存在于响应模型/测试中,需先确认映射方案后才可宣称真实工单状态已对齐。
-- 本轮已对 KingbaseES 当前 schema 与数据做**只读探查**,但**未启动应用并完成第 6 节检查表 1–7 的真实登录态端到端联调**;生产规模性能、银河麒麟与 Docker 的实机验证仍为未执行项。
-- 本仓库的工作区可能包含与本契约无关的在途改动,联调前请确认部署来源是其预期提交。
+- 当前工单运行时状态以 ADR-0010 的 0–7 八值枚举为权威;旧 cockpit 七态目录仍存在于部分响应模型/测试中,需继续确认映射方案后才可宣称所有工单详情状态已完全对齐。
+- 本轮已完成本机 8301 真实登录态和当前 KingbaseES 的第 6 节检查表 1–7 主要路径验收,但目标部署端口不可达;生产规模性能、银河麒麟与 Docker 的实机验证仍为未执行项。
+- 认证凭据未写入仓库、文档或记忆库。

+ 14 - 3
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailController.java

@@ -5,6 +5,7 @@ import com.zksy.cockpit.foundation.CockpitInvalidCodeException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailResponse;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailResponse;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
 import com.zksy.common.core.domain.AjaxResult;
 import com.zksy.common.core.domain.AjaxResult;
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.util.UriUtils;
 import org.springframework.web.util.UriUtils;
 
 
@@ -38,16 +40,19 @@ public class CockpitMonitoringPointDetailController {
     @PreAuthorize("isAuthenticated()")
     @PreAuthorize("isAuthenticated()")
     public ResponseEntity<AjaxResult> monitoringPointDetail(
     public ResponseEntity<AjaxResult> monitoringPointDetail(
             @PathVariable("monitoringPointCode") String monitoringPointCode,
             @PathVariable("monitoringPointCode") String monitoringPointCode,
+            @RequestParam(value = "snapshotAt", required = false) String snapshotAt,
             @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
             @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
         CockpitMonitoringPointDetailResponse response = detailService.load(
         CockpitMonitoringPointDetailResponse response = detailService.load(
-                resolveRequestId(requestId), decodePathSegment(monitoringPointCode));
+                resolveRequestId(requestId), decodePathSegment(monitoringPointCode), snapshotAt);
         return ResponseEntity.ok(AjaxResult.success(response));
         return ResponseEntity.ok(AjaxResult.success(response));
     }
     }
 
 
     @ExceptionHandler(CockpitInvalidRequestException.class)
     @ExceptionHandler(CockpitInvalidRequestException.class)
-    public ResponseEntity<AjaxResult> handleInvalidRequest(HttpServletRequest request) {
+    public ResponseEntity<AjaxResult> handleInvalidRequest(
+            HttpServletRequest request,
+            CockpitInvalidRequestException exception) {
         return error(HttpStatus.BAD_REQUEST, detailService.invalidRequest(
         return error(HttpStatus.BAD_REQUEST, detailService.invalidRequest(
-                resolveRequestId(request.getHeader(REQUEST_ID_HEADER))));
+                resolveRequestId(request.getHeader(REQUEST_ID_HEADER)), exception.getMessage()));
     }
     }
 
 
     @ExceptionHandler(CockpitInvalidCodeException.class)
     @ExceptionHandler(CockpitInvalidCodeException.class)
@@ -68,6 +73,12 @@ public class CockpitMonitoringPointDetailController {
                 resolveRequestId(request.getHeader(REQUEST_ID_HEADER))));
                 resolveRequestId(request.getHeader(REQUEST_ID_HEADER))));
     }
     }
 
 
+    @ExceptionHandler(CockpitSnapshotExpiredException.class)
+    public ResponseEntity<AjaxResult> handleSnapshotExpired(HttpServletRequest request) {
+        return error(HttpStatus.BAD_REQUEST, detailService.snapshotExpired(
+                resolveRequestId(request.getHeader(REQUEST_ID_HEADER))));
+    }
+
     private ResponseEntity<AjaxResult> error(HttpStatus status, CockpitErrorPayload payload) {
     private ResponseEntity<AjaxResult> error(HttpStatus status, CockpitErrorPayload payload) {
         return ResponseEntity.status(status)
         return ResponseEntity.status(status)
                 .body(new AjaxResult(status.value(), payload.getMessage(), payload));
                 .body(new AjaxResult(status.value(), payload.getMessage(), payload));

+ 3 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitDeviceFactResolverTest.java

@@ -124,6 +124,9 @@ class BusinessCockpitDeviceFactResolverTest {
 
 
         assertTrue(resolver.resolve(device("DEV-5"), null).isWarning(), "小写 processing 也视为预警中");
         assertTrue(resolver.resolve(device("DEV-5"), null).isWarning(), "小写 processing 也视为预警中");
 
 
+        when(earlyWarningService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(warning("released")));
+        assertTrue(resolver.resolve(device("DEV-5"), null).isWarning(), "RELEASED 已发布预警仍为当前预警");
+
         when(earlyWarningService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(warning("CLOSED")));
         when(earlyWarningService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(warning("CLOSED")));
         assertFalse(resolver.resolve(device("DEV-5"), null).isWarning(), "CLOSED 预警不算预警中");
         assertFalse(resolver.resolve(device("DEV-5"), null).isWarning(), "CLOSED 预警不算预警中");
     }
     }

+ 4 - 2
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureBaseArchivesAdapterTest.java

@@ -1,5 +1,6 @@
 package com.zksy.web.controller.cockpit;
 package com.zksy.web.controller.cockpit;
 
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
@@ -24,6 +25,7 @@ import java.util.Collections;
 
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -73,7 +75,7 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
         drainage.setFacilityType("调蓄设施");
         drainage.setFacilityType("调蓄设施");
 
 
         when(plantService.list()).thenReturn(Collections.singletonList(plant));
         when(plantService.list()).thenReturn(Collections.singletonList(plant));
-        when(pumpStationService.list()).thenReturn(Collections.singletonList(pump));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(pump));
         when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(pipe));
         when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(pipe));
         when(engineeringFacilityService.list()).thenReturn(Collections.singletonList(drainage));
         when(engineeringFacilityService.list()).thenReturn(Collections.singletonList(drainage));
 
 
@@ -113,7 +115,7 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
         PipeNetworkBase gas = pipe("GAS-PIPE", "燃气管线", "GAS", "500");
         PipeNetworkBase gas = pipe("GAS-PIPE", "燃气管线", "GAS", "500");
         PipeNetworkBase unknown = pipe("UNKNOWN-PIPE", "未知管线", "99", "500");
         PipeNetworkBase unknown = pipe("UNKNOWN-PIPE", "未知管线", "99", "500");
         when(plantService.list()).thenReturn(Collections.emptyList());
         when(plantService.list()).thenReturn(Collections.emptyList());
-        when(pumpStationService.list()).thenReturn(Collections.emptyList());
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.emptyList());
         when(pipeNetworkBaseService.list()).thenReturn(Arrays.asList(drainage, gas, unknown));
         when(pipeNetworkBaseService.list()).thenReturn(Arrays.asList(drainage, gas, unknown));
         when(engineeringFacilityService.list()).thenReturn(Collections.emptyList());
         when(engineeringFacilityService.list()).thenReturn(Collections.emptyList());
 
 

+ 5 - 3
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureOperatingInformationAdapterTest.java

@@ -1,5 +1,6 @@
 package com.zksy.web.controller.cockpit;
 package com.zksy.web.controller.cockpit;
 
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
@@ -23,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -77,7 +79,7 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
         facility.setUpdateTime(LocalDateTime.parse("2026-09-02T09:56:00"));
         facility.setUpdateTime(LocalDateTime.parse("2026-09-02T09:56:00"));
 
 
         when(plantService.list()).thenReturn(Collections.singletonList(plant));
         when(plantService.list()).thenReturn(Collections.singletonList(plant));
-        when(pumpStationService.list()).thenReturn(Collections.singletonList(pump));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(pump));
         when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(pipe));
         when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(pipe));
         when(engineeringFacilityService.list()).thenReturn(Collections.singletonList(facility));
         when(engineeringFacilityService.list()).thenReturn(Collections.singletonList(facility));
 
 
@@ -97,7 +99,7 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
 
 
         CockpitInfrastructureOperatingInformationSnapshot.SourceMetric pipeMetric =
         CockpitInfrastructureOperatingInformationSnapshot.SourceMetric pipeMetric =
                 snapshot.getMetrics().stream()
                 snapshot.getMetrics().stream()
-                        .filter(item -> "water_supply_pipe_length".equals(item.getMetricCode()))
+                        .filter(item -> "water_supply_pipe_network_length".equals(item.getMetricCode()))
                         .findFirst()
                         .findFirst()
                         .orElseThrow(AssertionError::new);
                         .orElseThrow(AssertionError::new);
         assertEquals(new BigDecimal("2500"), pipeMetric.getValue());
         assertEquals(new BigDecimal("2500"), pipeMetric.getValue());
@@ -119,7 +121,7 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
         PipeNetworkBase gas = pipe("GAS-PIPE", "燃气管线", "GAS", "500");
         PipeNetworkBase gas = pipe("GAS-PIPE", "燃气管线", "GAS", "500");
         PipeNetworkBase unknown = pipe("UNKNOWN-PIPE", "未知管线", "99", "500");
         PipeNetworkBase unknown = pipe("UNKNOWN-PIPE", "未知管线", "99", "500");
         when(plantService.list()).thenReturn(Collections.emptyList());
         when(plantService.list()).thenReturn(Collections.emptyList());
-        when(pumpStationService.list()).thenReturn(Collections.emptyList());
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.emptyList());
         when(pipeNetworkBaseService.list()).thenReturn(Arrays.asList(drainage, gas, unknown));
         when(pipeNetworkBaseService.list()).thenReturn(Arrays.asList(drainage, gas, unknown));
         when(engineeringFacilityService.list()).thenReturn(Collections.emptyList());
         when(engineeringFacilityService.list()).thenReturn(Collections.emptyList());
 
 

+ 308 - 2
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMapSnapshotAdapterTest.java

@@ -6,13 +6,21 @@ import com.zksy.base.domain.MonitorPoint;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.MonitorPointService;
 import com.zksy.base.service.MonitorPointService;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.map.BusinessCockpitMapSnapshotAdapter;
 import com.zksy.cockpit.map.BusinessCockpitMapSnapshotAdapter;
 import com.zksy.cockpit.map.CockpitMapSnapshot;
 import com.zksy.cockpit.map.CockpitMapSnapshot;
 import com.zksy.cockpit.map.CockpitMapSnapshotService;
 import com.zksy.cockpit.map.CockpitMapSnapshotService;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
+import com.zksy.cockpit.point.CockpitMonitoringPointDetailAdapter;
+import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
+import com.zksy.cockpit.point.CockpitMonitoringPointDeviceCard;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
+import com.zksy.framework.config.FastJson2JsonRedisSerializer;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.time.Clock;
 import java.time.Clock;
@@ -21,15 +29,22 @@ import java.time.ZoneOffset;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
 /**
 /**
@@ -127,7 +142,7 @@ class BusinessCockpitMapSnapshotAdapterTest {
         stubTypes(Collections.singletonList(type(99, "mystery_type", "未知类型", "9")));
         stubTypes(Collections.singletonList(type(99, "mystery_type", "未知类型", "9")));
         stubDevices(Collections.emptyList(), Collections.emptyList());
         stubDevices(Collections.emptyList(), Collections.emptyList());
 
 
-        CockpitMapSnapshot snapshot = adapter.load("2026-09-02T10:00:00+08:00");
+        CockpitMapSnapshot snapshot = adapter.load(null);
 
 
         assertEquals(1, snapshot.getTypes().size());
         assertEquals(1, snapshot.getTypes().size());
         assertNull(snapshot.getTypes().get(0).getIndustry(), "未知类型根不得静默归类");
         assertNull(snapshot.getTypes().get(0).getIndustry(), "未知类型根不得静默归类");
@@ -146,7 +161,298 @@ class BusinessCockpitMapSnapshotAdapterTest {
                 "窨井根映射为 MANHOLE 传值,交由服务层判非正式行业,而非在适配器吞掉");
                 "窨井根映射为 MANHOLE 传值,交由服务层判非正式行业,而非在适配器吞掉");
     }
     }
 
 
-    // ---- stubbing helpers ----
+    @Test
+    void nestedEquipmentTypeResolvesIndustryFromRoot() {
+        stubPoints(Collections.emptyList());
+        stubTypes(Arrays.asList(
+                type(4, "manhole_root", "窨井设备", "0"),
+                type(40, "manhole_family", "窨井监测族", "4"),
+                type(41, "manhole_sensor", "窨井传感器", "40")));
+        stubDevices(Collections.emptyList(), Collections.emptyList());
+
+        CockpitMapSnapshot snapshot = adapter.load(null);
+
+        assertEquals("MANHOLE", snapshot.getTypes().stream()
+                .filter(item -> "41".equals(item.getCode()))
+                .findFirst().orElseThrow(AssertionError::new).getIndustry());
+    }
+
+    @Test
+    void sameSnapshotAtReusesTheFirstSourceSnapshotAfterRelationsChange() {
+        String snapshotAt = "2026-09-02T10:00:00+08:00";
+        MonitorPoint point = point("P-1", "POINT-1", "点位一", new BigDecimal("110.4"), new BigDecimal("28.4"));
+        EquipmentType equipmentType = type(11, "pressure", "压力计", "1");
+        EquipmentBase firstDevice = device("D-1", "DEVICE-1", "设备一", "11",
+                new BigDecimal("110.401"), new BigDecimal("28.401"));
+        EquipmentBase secondDevice = device("D-2", "DEVICE-2", "设备二", "11",
+                new BigDecimal("110.402"), new BigDecimal("28.402"));
+        stubPoints(Collections.singletonList(point));
+        stubTypes(Collections.singletonList(equipmentType));
+        stubDevices(Collections.singletonList(firstDevice), Collections.singletonList(firstDevice));
+        when(deviceFactResolver.resolve(any(), anyString())).thenAnswer(invocation -> {
+            EquipmentBase device = invocation.getArgument(0);
+            return fact(device.getEquipmentCode());
+        });
+
+        CockpitMapSnapshot first = adapter.load(null);
+        assertEquals(snapshotAt, first.getSnapshotAt());
+
+        stubDevices(Collections.singletonList(secondDevice), Collections.singletonList(secondDevice));
+        CockpitMapSnapshot second = adapter.load(snapshotAt);
+
+        assertEquals(Collections.singletonList("DEVICE-1"),
+                first.getMonitoringPoints().get(0).getDevices().stream()
+                        .map(CockpitMonitoringPointDeviceSnapshot::getDeviceCode)
+                        .collect(java.util.stream.Collectors.toList()));
+        assertEquals(Collections.singletonList("DEVICE-1"),
+                second.getMonitoringPoints().get(0).getDevices().stream()
+                        .map(CockpitMonitoringPointDeviceSnapshot::getDeviceCode)
+                        .collect(java.util.stream.Collectors.toList()),
+                "同一 snapshotAt 必须复用首次读取的点位设备关系");
+    }
+
+    @Test
+    void mapSnapshotRoundTripsThroughRedisJsonSerializer() {
+        CockpitMonitoringPointDeviceSnapshot device = new CockpitMonitoringPointDeviceSnapshot(
+                "DEVICE-1", "设备一", "压力计", new BigDecimal("110.4"), new BigDecimal("28.4"),
+                CockpitCoordinateValidator.validate(
+                        new BigDecimal("110.4"), new BigDecimal("28.4"), false),
+                false, false, false, false, Collections.emptyList(), null);
+        CockpitMapSnapshot snapshot = new CockpitMapSnapshot("2026-09-02T10:00:00+08:00",
+                Collections.emptyList(),
+                Collections.singletonList(new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "POINT-1", "点位一", null, null, null, null, false,
+                        Collections.singletonList(device))),
+                Collections.emptyList());
+        FastJson2JsonRedisSerializer<Object> serializer = new FastJson2JsonRedisSerializer<>(Object.class);
+
+        Object restored = serializer.deserialize(serializer.serialize(snapshot));
+
+        assertTrue(restored instanceof CockpitMapSnapshot);
+        CockpitMapSnapshot restoredSnapshot = (CockpitMapSnapshot) restored;
+        CockpitMonitoringPointDeviceSnapshot restoredDevice =
+                restoredSnapshot.getMonitoringPoints().get(0).getDevices().get(0);
+        assertEquals("DEVICE-1", restoredDevice.getDeviceCode());
+        assertEquals(new BigDecimal("110.4"), restoredDevice.getLongitude());
+        assertEquals("UNVERIFIED", restoredDevice.getCoordinateValidation().getState());
+        assertEquals("UNVERIFIED_COORDINATE", restoredDevice.getCoordinateValidation().getReason());
+        assertFalse(restoredDevice.getCoordinateValidation().isRenderable());
+        assertFalse(restoredDevice.isOnline());
+    }
+
+    @Test
+    void separateAdaptersShareTheFirstSnapshotThroughRedis() {
+        RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
+        ValueOperations<Object, Object> values = mock(ValueOperations.class);
+        Map<Object, Object> sharedValues = new ConcurrentHashMap<>();
+        when(sharedRedis.opsForValue()).thenReturn(values);
+        when(values.get(any())).thenAnswer(invocation -> sharedValues.get(invocation.getArgument(0)));
+        when(values.setIfAbsent(any(), any(), anyLong(), eq(java.util.concurrent.TimeUnit.SECONDS)))
+                .thenAnswer(invocation -> sharedValues.putIfAbsent(
+                        invocation.getArgument(0), invocation.getArgument(1)) == null);
+
+        String snapshotAt = "2026-09-02T10:00:00+08:00";
+        MonitorPoint point = point("P-1", "POINT-1", "点位一", null, null);
+        EquipmentBase firstDevice = device("D-1", "DEVICE-1", "设备一", "11", null, null);
+        EquipmentBase changedDevice = device("D-2", "DEVICE-2", "设备二", "11", null, null);
+        stubPoints(Collections.singletonList(point));
+        stubTypes(Collections.singletonList(type(11, "pressure", "压力计", "1")));
+        stubDevices(Collections.singletonList(firstDevice), Collections.singletonList(firstDevice));
+        when(deviceFactResolver.resolve(any(), anyString())).thenAnswer(invocation ->
+                fact(invocation.<EquipmentBase>getArgument(0).getEquipmentCode()));
+        BusinessCockpitMapSnapshotAdapter firstAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
+
+        CockpitMapSnapshot first = firstAdapter.load(null);
+        assertEquals(snapshotAt, first.getSnapshotAt());
+        verify(values).setIfAbsent(eq("cockpit:map-snapshot:" + snapshotAt), any(), eq(600L),
+                eq(java.util.concurrent.TimeUnit.SECONDS));
+        stubDevices(Collections.singletonList(changedDevice), Collections.singletonList(changedDevice));
+        BusinessCockpitMapSnapshotAdapter secondAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
+        CockpitMapSnapshot second = secondAdapter.load(snapshotAt);
+
+        assertEquals("DEVICE-1", first.getMonitoringPoints().get(0).getDevices().get(0).getDeviceCode());
+        assertEquals("DEVICE-1", second.getMonitoringPoints().get(0).getDevices().get(0).getDeviceCode());
+    }
+
+    @Test
+    void mapPaginationKeepsDeviceCodesFromTheSameSnapshot() {
+        String snapshotAt = "2026-09-02T10:00:00+08:00";
+        MonitorPoint firstPoint = point("P-1", "POINT-1", "点位一", null, null);
+        MonitorPoint secondPoint = point("P-2", "POINT-2", "点位二", null, null);
+        EquipmentBase firstDevice = device("D-1", "DEVICE-1", "设备一", "11", null, null);
+        EquipmentBase secondDevice = device("D-2", "DEVICE-2", "设备二", "11", null, null);
+        stubPoints(Arrays.asList(firstPoint, secondPoint));
+        stubTypes(Collections.singletonList(type(11, "pressure", "压力计", "1")));
+        when(equipmentBaseService.list()).thenReturn(Arrays.asList(firstDevice, secondDevice));
+        when(equipmentBaseService.getEquipmentByPoint("P-1"))
+                .thenReturn(Collections.singletonList(firstDevice));
+        when(equipmentBaseService.getEquipmentByPoint("P-2"))
+                .thenReturn(Collections.singletonList(secondDevice));
+        when(deviceFactResolver.resolve(any(), anyString())).thenAnswer(invocation ->
+                fact(invocation.<EquipmentBase>getArgument(0).getEquipmentCode()));
+        CockpitMapSnapshotService service = new CockpitMapSnapshotService(adapter,
+                Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+
+        var firstPage = service.load("req", 1, 1, null, null, null, null);
+        assertEquals(snapshotAt, firstPage.getSnapshotAt());
+        when(equipmentBaseService.getEquipmentByPoint("P-2"))
+                .thenReturn(Collections.singletonList(firstDevice));
+        var secondPage = service.load("req", 2, 1, snapshotAt, null, null, null);
+
+        CockpitMonitoringPointDetailService detailService = new CockpitMonitoringPointDetailService(
+                mock(CockpitMonitoringPointDetailAdapter.class), adapter,
+                Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+        var detail = detailService.load("req", "POINT-2", snapshotAt);
+
+        assertEquals("POINT-2", secondPage.getMonitoringPoints().get(0).getPointCode());
+        assertEquals(Collections.singletonList("DEVICE-2"),
+                secondPage.getMonitoringPoints().get(0).getDeviceCodes());
+        assertEquals(secondPage.getMonitoringPoints().get(0).getDeviceCodes(),
+                detail.getDevices().stream()
+                        .map(CockpitMonitoringPointDeviceCard::getDeviceCode)
+                        .collect(java.util.stream.Collectors.toList()));
+    }
+
+    @Test
+    void redisTtlRoundsUpToTheSnapshotExpiryBoundary() {
+        RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
+        ValueOperations<Object, Object> values = mock(ValueOperations.class);
+        when(sharedRedis.opsForValue()).thenReturn(values);
+        when(values.get(any())).thenReturn(null);
+        when(values.setIfAbsent(any(), any(), anyLong(), eq(java.util.concurrent.TimeUnit.SECONDS)))
+                .thenReturn(Boolean.TRUE);
+        when(monitorPointService.list()).thenReturn(Collections.emptyList());
+        when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
+        when(equipmentTypeService.list()).thenReturn(Collections.emptyList());
+        Clock advancingClock = mock(Clock.class);
+        when(advancingClock.getZone()).thenReturn(ZoneOffset.UTC);
+        when(advancingClock.instant()).thenReturn(
+                Instant.parse("2026-09-02T02:00:00.900Z"),
+                Instant.parse("2026-09-02T02:00:00.900Z"),
+                Instant.parse("2026-09-02T02:00:00.950Z"),
+                Instant.parse("2026-09-02T02:00:00.950Z"));
+        BusinessCockpitMapSnapshotAdapter fractionalClockAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                advancingClock, sharedRedis);
+
+        CockpitMapSnapshot issued = fractionalClockAdapter.load(null);
+
+        verify(values).setIfAbsent(eq("cockpit:map-snapshot:" + issued.getSnapshotAt()), any(), eq(600L),
+                eq(java.util.concurrent.TimeUnit.SECONDS));
+    }
+
+    @Test
+    void snapshotThatExpiresDuringBuildIsNotPublishedToRedis() {
+        RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
+        ValueOperations<Object, Object> values = mock(ValueOperations.class);
+        Clock advancingClock = mock(Clock.class);
+        when(sharedRedis.opsForValue()).thenReturn(values);
+        when(values.get(any())).thenReturn(null);
+        when(advancingClock.getZone()).thenReturn(ZoneOffset.UTC);
+        when(advancingClock.instant()).thenReturn(
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:10:00.001Z"));
+        when(monitorPointService.list()).thenReturn(Collections.emptyList());
+        when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
+        when(equipmentTypeService.list()).thenReturn(Collections.emptyList());
+        BusinessCockpitMapSnapshotAdapter expiringAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                advancingClock, sharedRedis);
+
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> expiringAdapter.load(null));
+        verify(values, never()).setIfAbsent(any(), any(), anyLong(), any());
+    }
+
+    @Test
+    void cachedSnapshotIsRejectedWhenClockExpiresBeforeReturn() {
+        Clock advancingClock = mock(Clock.class);
+        when(advancingClock.getZone()).thenReturn(ZoneOffset.UTC);
+        when(advancingClock.instant()).thenReturn(
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:00:00Z"),
+                Instant.parse("2026-09-02T02:09:59.999Z"),
+                Instant.parse("2026-09-02T02:10:00.001Z"));
+        when(monitorPointService.list()).thenReturn(Collections.emptyList());
+        when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
+        when(equipmentTypeService.list()).thenReturn(Collections.emptyList());
+        BusinessCockpitMapSnapshotAdapter advancingAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver, advancingClock);
+        String snapshotAt = "2026-09-02T10:00:00+08:00";
+        advancingAdapter.load(null);
+
+        assertThrows(CockpitSnapshotExpiredException.class, () -> advancingAdapter.load(snapshotAt));
+    }
+
+    @Test
+    void unissuedSnapshotAtIsExpiredWithoutReadingCurrentRelations() {
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> adapter.load("2026-09-02T10:00:01+08:00"));
+
+        verifyNoInteractions(monitorPointService, equipmentBaseService, equipmentTypeService);
+    }
+
+    @Test
+    void missingSharedSnapshotAtIsExpiredWithoutRebuilding() {
+        RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
+        ValueOperations<Object, Object> values = mock(ValueOperations.class);
+        when(sharedRedis.opsForValue()).thenReturn(values);
+        when(values.get(any())).thenReturn(null);
+        BusinessCockpitMapSnapshotAdapter sharedAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
+
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> sharedAdapter.load("2026-09-02T10:00:01+08:00"));
+
+        verify(values, never()).setIfAbsent(any(), any(), anyLong(), any());
+        verifyNoInteractions(monitorPointService, equipmentBaseService, equipmentTypeService);
+    }
+
+    @Test
+    void expiredSnapshotAtIsRejectedInsteadOfLoadingCurrentRelations() {
+        when(monitorPointService.list()).thenReturn(Collections.emptyList());
+
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> adapter.load("2026-09-02T09:50:00+08:00"));
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> adapter.load("2026-09-02T09:49:59+08:00"));
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> adapter.load("2026-09-02T10:10:00+08:00"));
+    }
+
+    @Test
+    void differentSnapshotAtReadsASeparateSourceSnapshot() {
+        String firstSnapshotAt = "2026-09-02T10:00:00+08:00";
+        String secondSnapshotAt = "2026-09-02T10:01:00+08:00";
+        MonitorPoint point = point("P-1", "POINT-1", "点位一", new BigDecimal("110.4"), new BigDecimal("28.4"));
+        stubPoints(Collections.singletonList(point));
+        stubTypes(Collections.singletonList(type(11, "pressure", "压力计", "1")));
+        EquipmentBase firstDevice = device("D-1", "DEVICE-1", "设备一", "11", null, null);
+        EquipmentBase secondDevice = device("D-2", "DEVICE-2", "设备二", "11", null, null);
+        stubDevices(Collections.singletonList(firstDevice), Collections.singletonList(firstDevice));
+        when(deviceFactResolver.resolve(any(), anyString())).thenAnswer(invocation ->
+                fact(invocation.<EquipmentBase>getArgument(0).getEquipmentCode()));
+
+        CockpitMapSnapshot first = adapter.load(null);
+        stubDevices(Collections.singletonList(secondDevice), Collections.singletonList(secondDevice));
+        BusinessCockpitMapSnapshotAdapter laterAdapter = new BusinessCockpitMapSnapshotAdapter(
+                monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
+                Clock.fixed(Instant.parse("2026-09-02T02:01:00Z"), ZoneOffset.UTC));
+        CockpitMapSnapshot second = laterAdapter.load(null);
+
+        assertEquals(firstSnapshotAt, first.getSnapshotAt());
+        assertEquals(secondSnapshotAt, second.getSnapshotAt());
+        assertEquals("DEVICE-1", first.getMonitoringPoints().get(0).getDevices().get(0).getDeviceCode());
+        assertEquals("DEVICE-2", second.getMonitoringPoints().get(0).getDevices().get(0).getDeviceCode());
+    }
 
 
     private void stubPoints(List<MonitorPoint> points) {
     private void stubPoints(List<MonitorPoint> points) {
         when(monitorPointService.list()).thenReturn(points);
         when(monitorPointService.list()).thenReturn(points);

+ 16 - 1
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringDistributionAdapterTest.java

@@ -112,7 +112,22 @@ class BusinessCockpitMonitoringDistributionAdapterTest {
                 .findFirst().orElseThrow().getIndustry());
                 .findFirst().orElseThrow().getIndustry());
     }
     }
 
 
-    // ---- stubbing helpers ----
+    @Test
+    void nestedEquipmentTypeResolvesIndustryFromRoot() {
+        stubPoints(Collections.emptyList());
+        stubTypes(Arrays.asList(
+                type(4, "4", "窨井设备", "0"),
+                type(40, "40", "窨井监测族", "4"),
+                type(41, "41", "窨井传感器", "40")));
+        stubDevices(Collections.emptyList(), Collections.emptyList());
+
+        CockpitMonitoringDistributionSnapshot snapshot = adapter.load(null);
+
+        assertEquals("MANHOLE", snapshot.getTypes().stream()
+                .filter(item -> "41".equals(item.getCode()))
+                .findFirst().orElseThrow(AssertionError::new).getIndustry());
+    }
+
 
 
     private void stubPoints(List<MonitorPoint> points) {
     private void stubPoints(List<MonitorPoint> points) {
         when(monitorPointService.list()).thenReturn(points);
         when(monitorPointService.list()).thenReturn(points);

+ 143 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewInfrastructureAdapterTest.java

@@ -0,0 +1,143 @@
+package com.zksy.web.controller.cockpit;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
+import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
+import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
+import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
+import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.overview.BusinessCockpitOverviewInfrastructureAdapter;
+import com.zksy.cockpit.overview.CockpitOverviewInfrastructureSnapshot;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class BusinessCockpitOverviewInfrastructureAdapterTest {
+
+    private EquipmentTypeService equipmentTypeService;
+    private EquipmentBaseService equipmentBaseService;
+    private PipeNetworkBaseService pipeNetworkBaseService;
+    private IWaterPlantInfoService plantService;
+    private IWaterPumpStationService pumpStationService;
+    private BusinessCockpitOverviewInfrastructureAdapter adapter;
+
+    @BeforeEach
+    void setUp() {
+        equipmentTypeService = mock(EquipmentTypeService.class);
+        equipmentBaseService = mock(EquipmentBaseService.class);
+        pipeNetworkBaseService = mock(PipeNetworkBaseService.class);
+        plantService = mock(IWaterPlantInfoService.class);
+        pumpStationService = mock(IWaterPumpStationService.class);
+        adapter = new BusinessCockpitOverviewInfrastructureAdapter(
+                equipmentTypeService, equipmentBaseService, pipeNetworkBaseService,
+                plantService, pumpStationService);
+    }
+
+    @Test
+    void countsDevicesByTypeAndFacilitiesByNetworkTypeWithLengthInKm() {
+        EquipmentType gasRoot = type(3, "燃气", 0);
+        EquipmentType gasSensor = type(11, "燃气浓度计", 3);
+        when(equipmentTypeService.list()).thenReturn(Arrays.asList(gasRoot, gasSensor));
+
+        EquipmentBase first = device("E-1", "GAS-001", 11);
+        EquipmentBase second = device("E-2", "GAS-002", 11);
+        second.setUpdateTime(LocalDateTime.parse("2026-09-02T09:59:50"));
+        when(equipmentBaseService.list()).thenReturn(Arrays.asList(first, second));
+
+        PipeNetworkBase facility = new PipeNetworkBase();
+        facility.setNetworkId("N-1");
+        facility.setNetworkCode("PIPE-001");
+        facility.setNetworkName("城北主管网");
+        facility.setNetworkType("主管");
+        facility.setLength(new BigDecimal("5000"));
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(facility));
+
+        CockpitOverviewInfrastructureSnapshot snapshot = adapter.load();
+
+        assertEquals(3, snapshot.getTypes().size());
+        assertEquals("2026-09-02T09:59:50+08:00", snapshot.getUpdatedAt());
+
+        long deviceCount = snapshot.getCounts().stream()
+                .filter(count -> "SMART_DEVICE".equals(count.getObjectKind())
+                        && "11".equals(count.getTypeCode()))
+                .mapToInt(CockpitOverviewInfrastructureSnapshot.SourceCount::getCount)
+                .sum();
+        assertEquals(2, deviceCount);
+
+        CockpitOverviewInfrastructureSnapshot.SourceCount facilityCount = snapshot.getCounts().stream()
+                .filter(count -> "FACILITY".equals(count.getObjectKind()))
+                .findFirst().orElseThrow(AssertionError::new);
+        assertEquals("主管", facilityCount.getTypeCode());
+        assertEquals(1, facilityCount.getCount());
+        assertEquals(0, new BigDecimal("5.000").compareTo(facilityCount.getValue().getLengthKm()));
+        assertEquals("km", facilityCount.getValue().getScale());
+        assertNull(facilityCount.getValue().getRange());
+    }
+
+    @Test
+    void countsWaterPlantsAndSharedPumpStationsSeparately() {
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setPlantCode("WP-1");
+        plant.setUpdateTime(LocalDateTime.parse("2026-09-03T08:00:00"));
+        when(plantService.list()).thenReturn(Collections.singletonList(plant));
+
+        WaterPumpStation water = new WaterPumpStation();
+        water.setStationCode("PS-1");
+        water.setStationType(PumpStationType.WATER_SUPPLY);
+        WaterPumpStation drainage = new WaterPumpStation();
+        drainage.setStationCode("PS-2");
+        drainage.setStationType(PumpStationType.DRAINAGE);
+        WaterPumpStation unclassified = new WaterPumpStation();
+        unclassified.setStationCode("PS-3");
+        unclassified.setStationType("unknown");
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Arrays.asList(water, drainage, unclassified));
+
+        CockpitOverviewInfrastructureSnapshot snapshot = adapter.load();
+        assertEquals("2026-09-03T08:00:00+08:00", snapshot.getUpdatedAt());
+        assertEquals(3, snapshot.getCounts().size());
+        assertEquals("WATER_PLANT", snapshot.getCounts().get(0).getTypeCode());
+        assertEquals("WATER_PUMP_STATION", snapshot.getCounts().get(1).getTypeCode());
+        assertEquals("DRAINAGE_PUMP_STATION", snapshot.getCounts().get(2).getTypeCode());
+        assertEquals("DRAINAGE", snapshot.getTypes().get(2).getIndustry());
+        verify(equipmentTypeService, times(1)).list();
+        verify(equipmentBaseService, times(1)).list();
+        verify(pipeNetworkBaseService, times(1)).list();
+        verify(plantService, times(1)).list();
+        verify(pumpStationService, times(1)).list(any(Wrapper.class));
+    }
+
+    private static EquipmentType type(int id, String name, int parentId) {
+        EquipmentType type = new EquipmentType();
+        type.setId(id);
+        type.setTypeName(name);
+        type.setParentId(parentId);
+        return type;
+    }
+
+    private static EquipmentBase device(String id, String code, int typeId) {
+        EquipmentBase device = new EquipmentBase();
+        device.setEquipmentId(id);
+        device.setEquipmentCode(code);
+        device.setEquipmentName(code);
+        device.setEquipmentTypeId(typeId);
+        return device;
+    }
+}

+ 157 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewMonitoringAdapterTest.java

@@ -0,0 +1,157 @@
+package com.zksy.web.controller.cockpit;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.EquipmentStatus;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.domain.MonitorPoint;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.gas.domain.GasMonitorData;
+import com.zksy.base.gas.service.GasMonitorDataService;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.EquipmentStatusService;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.base.service.MonitorPointService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.base.water.service.WaterMonitorDataService;
+import com.zksy.cockpit.overview.BusinessCockpitOverviewMonitoringAdapter;
+import com.zksy.cockpit.overview.CockpitOverviewMonitoringSnapshot;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class BusinessCockpitOverviewMonitoringAdapterTest {
+
+    private static final String GAS_CODE = "GAS-001";
+
+    private EquipmentTypeService equipmentTypeService;
+    private EquipmentBaseService equipmentBaseService;
+    private MonitorPointService monitorPointService;
+    private PipeNetworkBaseService pipeNetworkBaseService;
+    private EquipmentStatusService equipmentStatusService;
+    private GasMonitorDataService gasMonitorDataService;
+    private WaterMonitorDataService waterMonitorDataService;
+    private BusinessCockpitOverviewMonitoringAdapter adapter;
+
+    @BeforeEach
+    void setUp() {
+        equipmentTypeService = mock(EquipmentTypeService.class);
+        equipmentBaseService = mock(EquipmentBaseService.class);
+        monitorPointService = mock(MonitorPointService.class);
+        pipeNetworkBaseService = mock(PipeNetworkBaseService.class);
+        equipmentStatusService = mock(EquipmentStatusService.class);
+        gasMonitorDataService = mock(GasMonitorDataService.class);
+        waterMonitorDataService = mock(WaterMonitorDataService.class);
+        adapter = new BusinessCockpitOverviewMonitoringAdapter(
+                equipmentTypeService, equipmentBaseService, monitorPointService,
+                pipeNetworkBaseService, equipmentStatusService,
+                gasMonitorDataService, waterMonitorDataService);
+
+        EquipmentType gasRoot = type(3, "燃气", 0);
+        EquipmentType gasSensor = type(11, "燃气浓度计", 3);
+        when(equipmentTypeService.list()).thenReturn(Arrays.asList(gasRoot, gasSensor));
+    }
+
+    @Test
+    void mapsDeviceStatePointTypeAndMetricFreshness() {
+        EquipmentBase device = device("E-1", GAS_CODE, 11);
+        device.setUpdateTime(LocalDateTime.parse("2026-09-02T09:59:50"));
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(device));
+
+        MonitorPoint point = new MonitorPoint();
+        point.setPointId("P-1");
+        point.setPointCode("MP-1");
+        when(monitorPointService.list()).thenReturn(Collections.singletonList(point));
+        when(equipmentBaseService.getEquipmentByPoint("P-1"))
+                .thenReturn(Collections.singletonList(device));
+
+        EquipmentStatus status = new EquipmentStatus();
+        status.setStatusId(1);
+        status.setEquipmentId("E-1");
+        status.setOnlineStatus(1);
+        when(equipmentStatusService.getByDeviceCode(GAS_CODE)).thenReturn(status);
+
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+
+        GasMonitorData frame = new GasMonitorData();
+        frame.setId("F-1");
+        frame.setCreateTime(LocalDateTime.parse("2026-09-02T09:00:00"));
+        when(gasMonitorDataService.list(any(LambdaQueryWrapper.class)))
+                .thenReturn(Collections.singletonList(frame));
+        when(waterMonitorDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+
+        CockpitOverviewMonitoringSnapshot snapshot = adapter.load();
+
+        assertEquals("2026-09-02T09:59:50+08:00", snapshot.getUpdatedAt());
+        assertEquals("ONLINE", snapshot.getDevices().get(0).getMonitoringState());
+        assertEquals("11", snapshot.getMonitoringPoints().get(0).getTypeCode());
+        assertEquals("CURRENT", snapshot.getMetricFreshness().getStatus());
+        assertEquals("2026-09-02T09:00:00+08:00", snapshot.getMetricFreshness().getUpdatedAt());
+    }
+
+    @Test
+    void deviceWithoutStatusStaysUnknownAndPointWithoutUniqueTypeIsNull() {
+        EquipmentBase device = device("E-1", GAS_CODE, 11);
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(device));
+        when(equipmentStatusService.getByDeviceCode(GAS_CODE)).thenReturn(null);
+
+        MonitorPoint point = new MonitorPoint();
+        point.setPointId("P-1");
+        point.setPointCode("PO-1");
+        when(monitorPointService.list()).thenReturn(Collections.singletonList(point));
+        when(equipmentBaseService.getEquipmentByPoint("P-1")).thenReturn(Collections.emptyList());
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gasMonitorDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+        when(waterMonitorDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+
+        CockpitOverviewMonitoringSnapshot snapshot = adapter.load();
+
+        assertNull(snapshot.getDevices().get(0).getMonitoringState());
+        assertNull(snapshot.getMonitoringPoints().get(0).getTypeCode());
+        assertNull(snapshot.getMetricFreshness());
+    }
+
+    @Test
+    void countsAllInfrastructureFacilities() {
+        when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
+        when(monitorPointService.list()).thenReturn(Collections.emptyList());
+        PipeNetworkBase facility = new PipeNetworkBase();
+        facility.setNetworkId("N-1");
+        facility.setNetworkCode("PIPE-001");
+        facility.setNetworkType("主管");
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.singletonList(facility));
+        when(gasMonitorDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+        when(waterMonitorDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+
+        CockpitOverviewMonitoringSnapshot snapshot = adapter.load();
+
+        assertEquals(1, snapshot.getInfrastructureFacilityCount());
+        assertEquals("主管", snapshot.getMonitoringFacilities().get(0).getTypeCode());
+    }
+
+    private static EquipmentType type(int id, String name, int parentId) {
+        EquipmentType type = new EquipmentType();
+        type.setId(id);
+        type.setTypeName(name);
+        type.setParentId(parentId);
+        return type;
+    }
+
+    private static EquipmentBase device(String id, String code, int typeId) {
+        EquipmentBase device = new EquipmentBase();
+        device.setEquipmentId(id);
+        device.setEquipmentCode(code);
+        device.setEquipmentName(code);
+        device.setEquipmentTypeId(typeId);
+        return device;
+    }
+}

+ 141 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewWarningSettingsAdapterTest.java

@@ -0,0 +1,141 @@
+package com.zksy.web.controller.cockpit;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.zksy.base.alarm.domain.AlarmData;
+import com.zksy.base.alarm.service.AlarmDataService;
+import com.zksy.base.warning.domain.AlarmWarningRel;
+import com.zksy.base.warning.domain.EarlyWarning;
+import com.zksy.base.warning.mapper.AlarmWarningRelMapper;
+import com.zksy.base.warning.service.EarlyWarningService;
+import com.zksy.cockpit.overview.BusinessCockpitOverviewWarningSettingsAdapter;
+import com.zksy.cockpit.overview.CockpitOverviewWarningSettingsSnapshot;
+import com.zksy.ops.domain.WorkOrder;
+import com.zksy.ops.service.WorkOrderService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class BusinessCockpitOverviewWarningSettingsAdapterTest {
+
+    private EarlyWarningService earlyWarningService;
+    private AlarmDataService alarmDataService;
+    private AlarmWarningRelMapper alarmWarningRelMapper;
+    private WorkOrderService workOrderService;
+    private BusinessCockpitOverviewWarningSettingsAdapter adapter;
+
+    @BeforeEach
+    void setUp() {
+        earlyWarningService = mock(EarlyWarningService.class);
+        alarmDataService = mock(AlarmDataService.class);
+        alarmWarningRelMapper = mock(AlarmWarningRelMapper.class);
+        workOrderService = mock(WorkOrderService.class);
+        adapter = new BusinessCockpitOverviewWarningSettingsAdapter(
+                earlyWarningService, alarmDataService, alarmWarningRelMapper, workOrderService);
+    }
+
+    @Test
+    void bridgesWarningWorkOrderThroughRelationAndAggregatesTrend() {
+        EarlyWarning warning = new EarlyWarning();
+        warning.setWarningId("WARN-ID-001");
+        warning.setWarningNo("W-001");
+        warning.setDeviceCode("GAS-001");
+        warning.setPublishTime(LocalDateTime.parse("2026-09-02T09:00:00"));
+        when(earlyWarningService.list()).thenReturn(Collections.singletonList(warning));
+
+        AlarmData alarm = new AlarmData();
+        alarm.setId("A-001");
+        alarm.setDeviceCode("GAS-001");
+        alarm.setWorkOrderId(1001L);
+        alarm.setCreateTime(LocalDateTime.parse("2026-09-02T10:00:00"));
+        when(alarmDataService.list()).thenReturn(Collections.singletonList(alarm));
+
+        AlarmWarningRel relation = new AlarmWarningRel();
+        relation.setRelId("R-1");
+        relation.setWarningId("WARN-ID-001");
+        relation.setAlarmId("A-001");
+        when(alarmWarningRelMapper.selectList(any(QueryWrapper.class)))
+                .thenReturn(Collections.singletonList(relation));
+
+        WorkOrder order = new WorkOrder();
+        order.setOrderId(1001L);
+        order.setOrderNo("WO-001");
+        order.setOrderStatus(5);
+        order.setCreateTime(Timestamp.valueOf("2026-09-02 10:10:00"));
+        when(workOrderService.list()).thenReturn(Collections.singletonList(order));
+
+        CockpitOverviewWarningSettingsSnapshot snapshot = adapter.load();
+
+        assertEquals(2, snapshot.getEvents().size());
+        CockpitOverviewWarningSettingsSnapshot.SourceEvent alarmEvent = snapshot.getEvents().get(0);
+        assertEquals("ALARM", alarmEvent.getEventFamily());
+        assertEquals("A-001", alarmEvent.getEventCode());
+        assertEquals("WO-001", alarmEvent.getWorkOrderCode());
+        assertEquals(Integer.valueOf(5), alarmEvent.getWorkOrderState());
+
+        CockpitOverviewWarningSettingsSnapshot.SourceEvent warningEvent = snapshot.getEvents().get(1);
+        assertEquals("WARNING", warningEvent.getEventFamily());
+        assertEquals("W-001", warningEvent.getEventCode());
+        assertEquals("WO-001", warningEvent.getWorkOrderCode());
+        assertEquals(Integer.valueOf(5), warningEvent.getWorkOrderState());
+
+        CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint warningTrend = snapshot.getTrendPoints().stream()
+                .filter(point -> "WARNING".equals(point.getEventFamily()))
+                .findFirst().orElseThrow(AssertionError::new);
+        assertEquals("2026-09-02", warningTrend.getBucket());
+        assertEquals(1, warningTrend.getTotal());
+        assertEquals(1, warningTrend.getHandled());
+
+        CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint alarmTrend = snapshot.getTrendPoints().stream()
+                .filter(point -> "ALARM".equals(point.getEventFamily()))
+                .findFirst().orElseThrow(AssertionError::new);
+        assertEquals(1, alarmTrend.getTotal());
+        assertEquals(1, alarmTrend.getHandled());
+    }
+
+    @Test
+    void alarmWithoutWorkOrderStaysUnlinkedAndUnhandled() {
+        when(earlyWarningService.list()).thenReturn(Collections.emptyList());
+        AlarmData alarm = new AlarmData();
+        alarm.setId("A-001");
+        alarm.setDeviceCode("GAS-001");
+        alarm.setCreateTime(LocalDateTime.parse("2026-09-02T10:00:00"));
+        when(alarmDataService.list()).thenReturn(Collections.singletonList(alarm));
+        when(alarmWarningRelMapper.selectList(any(QueryWrapper.class)))
+                .thenReturn(Collections.emptyList());
+        when(workOrderService.list()).thenReturn(Collections.emptyList());
+
+        CockpitOverviewWarningSettingsSnapshot snapshot = adapter.load();
+
+        CockpitOverviewWarningSettingsSnapshot.SourceEvent alarmEvent = snapshot.getEvents().get(0);
+        assertNull(alarmEvent.getWorkOrderCode());
+        assertNull(alarmEvent.getWorkOrderState());
+        CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint alarmTrend = snapshot.getTrendPoints().get(0);
+        assertEquals(1, alarmTrend.getTotal());
+        assertEquals(0, alarmTrend.getHandled());
+    }
+
+    @Test
+    void emptySourcesStillProduceEmptySnapshotWithoutNpe() {
+        when(earlyWarningService.list()).thenReturn(Collections.emptyList());
+        when(alarmDataService.list()).thenReturn(Collections.emptyList());
+        when(alarmWarningRelMapper.selectList(any(QueryWrapper.class)))
+                .thenReturn(Collections.emptyList());
+        when(workOrderService.list()).thenReturn(Collections.emptyList());
+
+        CockpitOverviewWarningSettingsSnapshot snapshot = adapter.load();
+
+        assertEquals(0, snapshot.getEvents().size());
+        assertEquals(0, snapshot.getTrendPoints().size());
+        assertNull(snapshot.getUpdatedAt());
+    }
+}

+ 86 - 1
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitEquipmentDetailAggregateControllerTest.java

@@ -172,6 +172,87 @@ class CockpitEquipmentDetailAggregateControllerTest {
                 .andExpect(jsonPath("$.data.latestImage.state").value("SUCCESS"));
                 .andExpect(jsonPath("$.data.latestImage.state").value("SUCCESS"));
     }
     }
 
 
+    @Test
+    void failedTimelineRetainsOtherTimelineAndIndependentSections() throws Exception {
+        stubArchive();
+        stubEventSection();
+        when(metricsService.loadCurrent("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(metricsResponse("CURRENT", "READY"));
+        CockpitWorkOrderSummary first = workOrderSummary();
+        CockpitWorkOrderSummary second = workOrderSummary("WO-2026090200002");
+        when(workOrderService.loadByDevice("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(workOrderResponse(DEVICE_CODE, "READY", "READY", Arrays.asList(first, second)));
+        when(workOrderService.loadTimeline("detail-aggregate-001", first.getWorkOrderCode()))
+                .thenReturn(timelineResponse(first));
+        when(workOrderService.loadTimeline("detail-aggregate-001", second.getWorkOrderCode()))
+                .thenThrow(new CockpitReadException("timeline read failed"));
+
+        mockMvc.perform(get("/api/cockpit/v1/equipments/" + DEVICE_CODE + "/detail-aggregate")
+                        .header("X-Request-Id", "detail-aggregate-001"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.aggregateState").value("PARTIAL"))
+                .andExpect(jsonPath("$.data.archive.state").value("SUCCESS"))
+                .andExpect(jsonPath("$.data.metrics.state").value("SUCCESS"))
+                .andExpect(jsonPath("$.data.workOrders.state").value("SUCCESS"))
+                .andExpect(jsonPath("$.data.workOrders.data", hasSize(2)))
+                .andExpect(jsonPath("$.data.timelines.state").value("FAILED"))
+                .andExpect(jsonPath("$.data.timelines.reason").value("TIMELINE_FAILURE"))
+                .andExpect(jsonPath("$.data.timelines.data", hasSize(1)))
+                .andExpect(jsonPath("$.data.timelines.data[0].workOrderCode").value(first.getWorkOrderCode()));
+    }
+
+    @Test
+    void foreignTimelineDoesNotLeakIntoAggregate() throws Exception {
+        stubArchive();
+        stubEventSection();
+        when(metricsService.loadCurrent("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(metricsResponse("CURRENT", "READY"));
+        CockpitWorkOrderSummary first = workOrderSummary();
+        CockpitWorkOrderSummary second = workOrderSummary("WO-2026090200002");
+        when(workOrderService.loadByDevice("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(workOrderResponse(DEVICE_CODE, "READY", "READY", Arrays.asList(first, second)));
+        when(workOrderService.loadTimeline("detail-aggregate-001", first.getWorkOrderCode()))
+                .thenReturn(timelineResponse(first));
+        when(workOrderService.loadTimeline("detail-aggregate-001", second.getWorkOrderCode()))
+                .thenReturn(timelineResponse(first));
+
+        mockMvc.perform(get("/api/cockpit/v1/equipments/" + DEVICE_CODE + "/detail-aggregate")
+                        .header("X-Request-Id", "detail-aggregate-001"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.aggregateState").value("PARTIAL"))
+                .andExpect(jsonPath("$.data.workOrders.data", hasSize(2)))
+                .andExpect(jsonPath("$.data.timelines.state").value("FAILED"))
+                .andExpect(jsonPath("$.data.timelines.data", hasSize(1)))
+                .andExpect(jsonPath("$.data.timelines.data[0].workOrderCode").value(first.getWorkOrderCode()));
+    }
+
+    @Test
+    void timelineWithForeignLogEntryIsRejected() throws Exception {
+        stubArchive();
+        stubEventSection();
+        when(metricsService.loadCurrent("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(metricsResponse("CURRENT", "READY"));
+        CockpitWorkOrderSummary summary = workOrderSummary();
+        when(workOrderService.loadByDevice("detail-aggregate-001", DEVICE_CODE))
+                .thenReturn(workOrderResponse(DEVICE_CODE, "READY", "READY", Collections.singletonList(summary)));
+        when(workOrderService.loadTimeline("detail-aggregate-001", summary.getWorkOrderCode()))
+                .thenReturn(new CockpitWorkOrderTimelineResponse(
+                        "detail-aggregate-001", "v1", true, summary.getWorkOrderCode(),
+                        CockpitWorkOrderStateDictionary.states(), summary,
+                        Collections.singletonList(new CockpitWorkOrderTimelineEntry(
+                                1L, "WO-OTHER", 4, "待验收", "提交验收", "处理异常", "系统",
+                                "2026-09-02T09:00:00+08:00"))));
+
+        mockMvc.perform(get("/api/cockpit/v1/equipments/" + DEVICE_CODE + "/detail-aggregate")
+                        .header("X-Request-Id", "detail-aggregate-001"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.aggregateState").value("PARTIAL"))
+                .andExpect(jsonPath("$.data.archive.state").value("SUCCESS"))
+                .andExpect(jsonPath("$.data.workOrders.state").value("SUCCESS"))
+                .andExpect(jsonPath("$.data.timelines.state").value("FAILED"))
+                .andExpect(jsonPath("$.data.timelines.data").doesNotExist());
+    }
+
     @Test
     @Test
     void staleMetricsRemainVisibleWithIndependentStaleState() throws Exception {
     void staleMetricsRemainVisibleWithIndependentStaleState() throws Exception {
         stubArchive();
         stubArchive();
@@ -326,8 +407,12 @@ class CockpitEquipmentDetailAggregateControllerTest {
     }
     }
 
 
     private CockpitWorkOrderSummary workOrderSummary() {
     private CockpitWorkOrderSummary workOrderSummary() {
+        return workOrderSummary("WO-2026090200001");
+    }
+
+    private CockpitWorkOrderSummary workOrderSummary(String code) {
         return new CockpitWorkOrderSummary(
         return new CockpitWorkOrderSummary(
-                "WO-2026090200001", DEVICE_CODE, 1, "处理异常", 4, "处理中",
+                code, DEVICE_CODE, 1, "处理异常", 4, "处理中",
                 "2026-09-02T09:00:00+08:00", "2026-09-02T10:00:00+08:00",
                 "2026-09-02T09:00:00+08:00", "2026-09-02T10:00:00+08:00",
                 "2026-09-03T09:00:00+08:00", null,
                 "2026-09-03T09:00:00+08:00", null,
                 new CockpitWorkOrderEventAssociation("ALARM", "ALM-20260902-001", "2026-09-02T10:00:00+08:00"));
                 new CockpitWorkOrderEventAssociation("ALARM", "ALM-20260902-001", "2026-09-02T10:00:00+08:00"));

+ 36 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMapSnapshotControllerTest.java

@@ -281,6 +281,18 @@ class CockpitMapSnapshotControllerTest {
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].coordinateValidation.reason").value("ZERO_COORDINATE"));
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].coordinateValidation.reason").value("ZERO_COORDINATE"));
     }
     }
 
 
+    @Test
+    void pageAfterFirstRequiresIssuedSnapshotAt() throws Exception {
+        mockMvc.perform(get("/api/cockpit/v1/map-snapshot")
+                        .param("page", "2")
+                        .param("pageSize", "1"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("SNAPSHOT_EXPIRED"));
+
+        verifyNoInteractions(adapter);
+    }
+
     @Test
     @Test
     void invalidPaginationReturnsTypedBadRequestBeforeReadAdapterIsCalled() throws Exception {
     void invalidPaginationReturnsTypedBadRequestBeforeReadAdapterIsCalled() throws Exception {
         mockMvc.perform(get("/api/cockpit/v1/map-snapshot")
         mockMvc.perform(get("/api/cockpit/v1/map-snapshot")
@@ -306,6 +318,30 @@ class CockpitMapSnapshotControllerTest {
         verifyNoInteractions(adapter);
         verifyNoInteractions(adapter);
     }
     }
 
 
+    @Test
+    void nonBusinessOffsetSnapshotTimestampReturnsTypedBadRequest() throws Exception {
+        mockMvc.perform(get("/api/cockpit/v1/map-snapshot")
+                        .param("snapshotAt", "2026-09-02T02:00:00Z"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
+                .andExpect(jsonPath("$.data.message").value("地图快照分页参数不合法"));
+
+        verifyNoInteractions(adapter);
+    }
+
+    @Test
+    void missingIssuedSnapshotDoesNotBecomeAnEmptyMap() throws Exception {
+        when(adapter.load(SNAPSHOT_AT)).thenReturn(null);
+
+        mockMvc.perform(get("/api/cockpit/v1/map-snapshot")
+                        .param("page", "2")
+                        .param("snapshotAt", SNAPSHOT_AT))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("SNAPSHOT_EXPIRED"));
+    }
+
     @Test
     @Test
     void expiredSnapshotReturnsTypedBadRequestAndDoesNotPretendToBeEmpty() throws Exception {
     void expiredSnapshotReturnsTypedBadRequestAndDoesNotPretendToBeEmpty() throws Exception {
         when(adapter.load("2026-09-02T09:00:00+08:00"))
         when(adapter.load("2026-09-02T09:00:00+08:00"))

+ 118 - 1
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailControllerTest.java

@@ -1,6 +1,8 @@
 package com.zksy.web.controller.cockpit;
 package com.zksy.web.controller.cockpit;
 
 
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.map.CockpitMapSnapshot;
+import com.zksy.cockpit.map.CockpitMapSnapshotAdapter;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetail;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetail;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailAdapter;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailAdapter;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
 import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
@@ -33,13 +35,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 class CockpitMonitoringPointDetailControllerTest {
 class CockpitMonitoringPointDetailControllerTest {
 
 
     private CockpitMonitoringPointDetailAdapter adapter;
     private CockpitMonitoringPointDetailAdapter adapter;
+    private CockpitMapSnapshotAdapter mapAdapter;
     private MockMvc mockMvc;
     private MockMvc mockMvc;
 
 
     @BeforeEach
     @BeforeEach
     void setUp() {
     void setUp() {
         adapter = mock(CockpitMonitoringPointDetailAdapter.class);
         adapter = mock(CockpitMonitoringPointDetailAdapter.class);
+        mapAdapter = mock(CockpitMapSnapshotAdapter.class);
         CockpitMonitoringPointDetailService service = new CockpitMonitoringPointDetailService(
         CockpitMonitoringPointDetailService service = new CockpitMonitoringPointDetailService(
-                adapter,
+                adapter, mapAdapter,
                 Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
                 Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
         CockpitMonitoringPointDetailController controller = new CockpitMonitoringPointDetailController(service);
         CockpitMonitoringPointDetailController controller = new CockpitMonitoringPointDetailController(service);
         mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
         mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
@@ -62,6 +66,8 @@ class CockpitMonitoringPointDetailControllerTest {
                 .andExpect(jsonPath("$.data.requestId").value("point-detail-request-001"))
                 .andExpect(jsonPath("$.data.requestId").value("point-detail-request-001"))
                 .andExpect(jsonPath("$.data.apiVersion").value("v1"))
                 .andExpect(jsonPath("$.data.apiVersion").value("v1"))
                 .andExpect(jsonPath("$.data.readOnly").value(true))
                 .andExpect(jsonPath("$.data.readOnly").value(true))
+                .andExpect(jsonPath("$.data.freshness").value("CURRENT"))
+                .andExpect(jsonPath("$.data.staleReason").value("BEST_EFFORT_SOURCE"))
                 .andExpect(jsonPath("$.data.monitoringPointCode").value("MP-001"))
                 .andExpect(jsonPath("$.data.monitoringPointCode").value("MP-001"))
                 .andExpect(jsonPath("$.data.monitoringPointName").value("供水干管监测点"))
                 .andExpect(jsonPath("$.data.monitoringPointName").value("供水干管监测点"))
                 .andExpect(jsonPath("$.data.pointStatus").value("ALARM"))
                 .andExpect(jsonPath("$.data.pointStatus").value("ALARM"))
@@ -190,6 +196,117 @@ class CockpitMonitoringPointDetailControllerTest {
         verifyNoInteractions(adapter);
         verifyNoInteractions(adapter);
     }
     }
 
 
+    @Test
+    void detailWithSnapshotAtReadsFromMapSnapshotSource() throws Exception {
+        CockpitMapSnapshot snapshot = new CockpitMapSnapshot(
+                "2026-09-02T10:00:00+08:00", Collections.emptyList(),
+                Collections.singletonList(new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-SNAP", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.singletonList(
+                                device("EQ-001", true, false, false, true, Collections.emptyList())))),
+                Collections.emptyList());
+        when(mapAdapter.load("2026-09-02T10:00:00+08:00")).thenReturn(snapshot);
+
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "2026-09-02T10:00:00+08:00"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.monitoringPointCode").value("MP-SNAP"))
+                .andExpect(jsonPath("$.data.freshness").value("CURRENT"))
+                .andExpect(jsonPath("$.data.staleReason").doesNotExist())
+                .andExpect(jsonPath("$.data.devices[0].deviceCode").value("EQ-001"));
+
+        verifyNoInteractions(adapter);
+    }
+
+    @Test
+    void missingIssuedSnapshotDoesNotBecomePointNotFound() throws Exception {
+        when(mapAdapter.load("2026-09-02T10:00:00+08:00")).thenReturn(null);
+
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "2026-09-02T10:00:00+08:00"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("SNAPSHOT_EXPIRED"));
+
+        verifyNoInteractions(adapter);
+    }
+
+    @Test
+    void detailWithMismatchedSnapshotAtReturnsSnapshotExpired() throws Exception {
+        CockpitMapSnapshot snapshot = new CockpitMapSnapshot(
+                "2026-09-02T11:00:00+08:00", Collections.emptyList(),
+                Collections.singletonList(new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-SNAP", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.emptyList())),
+                Collections.emptyList());
+        when(mapAdapter.load("2026-09-02T10:00:00+08:00")).thenReturn(snapshot);
+
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "2026-09-02T10:00:00+08:00"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("SNAPSHOT_EXPIRED"))
+                .andExpect(jsonPath("$.data.message").value("监测点详情快照已过期,请刷新后重试"));
+
+        verifyNoInteractions(adapter);
+    }
+
+    @Test
+    void detailWithMalformedSnapshotAtReturnsInvalidRequest() throws Exception {
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "not-a-timestamp"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
+                .andExpect(jsonPath("$.data.message").value("监测点快照参数不合法"));
+    }
+
+    @Test
+    void detailWithNonBusinessOffsetSnapshotAtReturnsInvalidRequest() throws Exception {
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "2026-09-02T02:00:00Z"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
+                .andExpect(jsonPath("$.data.message").value("监测点快照参数不合法"));
+
+        verifyNoInteractions(adapter);
+        verifyNoInteractions(mapAdapter);
+    }
+
+    @Test
+    void detailWithBlankSnapshotAtReturnsInvalidRequest() throws Exception {
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", ""))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.code").value(400))
+                .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
+                .andExpect(jsonPath("$.data.message").value("监测点快照参数不合法"));
+
+        verifyNoInteractions(adapter);
+        verifyNoInteractions(mapAdapter);
+    }
+
+    @Test
+    void detailSnapshotNormalizesDeviceCodeBeforeReturningCards() throws Exception {
+        CockpitMapSnapshot snapshot = new CockpitMapSnapshot(
+                "2026-09-02T10:00:00+08:00", Collections.emptyList(),
+                Collections.singletonList(new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-SNAP", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.singletonList(
+                                device(" EQ-001 ", true, false, false, true, Collections.emptyList())))),
+                Collections.emptyList());
+        when(mapAdapter.load("2026-09-02T10:00:00+08:00")).thenReturn(snapshot);
+
+        mockMvc.perform(get("/api/cockpit/v1/monitoring-points/MP-SNAP")
+                        .param("snapshotAt", "2026-09-02T10:00:00+08:00"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.devices[0].deviceCode").value("EQ-001"));
+    }
+
     @Test
     @Test
     void controllerOnlyExposesAuthenticatedReadOnlyOperations() {
     void controllerOnlyExposesAuthenticatedReadOnlyOperations() {
         assertTrue(Arrays.stream(CockpitMonitoringPointDetailController.class.getDeclaredMethods())
         assertTrue(Arrays.stream(CockpitMonitoringPointDetailController.class.getDeclaredMethods())

+ 288 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringPointDetailSnapshotContractTest.java

@@ -0,0 +1,288 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import com.zksy.cockpit.map.CockpitMapSnapshot;
+import com.zksy.cockpit.map.CockpitMapSnapshotAdapter;
+import com.zksy.cockpit.map.CockpitMapSnapshotService;
+import com.zksy.cockpit.map.CockpitMonitoringPointSummary;
+import com.zksy.cockpit.point.CockpitMonitoringPointDetailAdapter;
+import com.zksy.cockpit.point.CockpitMonitoringPointDetailResponse;
+import com.zksy.cockpit.point.CockpitMonitoringPointDetailService;
+import com.zksy.cockpit.point.CockpitMonitoringPointDeviceCard;
+import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
+
+/**
+ * 跨端点同快照契约:同一 snapshotAt 下,监测点详情 devices[] 与 map-snapshot
+ * 对应点位的 deviceCodes 集合必须一致(含离线设备、不重复、不静默丢失),
+ * 且详情设备坐标/校验对象与快照同源。
+ */
+class CockpitMonitoringPointDetailSnapshotContractTest {
+
+    private static final String SNAPSHOT_AT = "2026-09-02T10:00:00+08:00";
+    private static final Clock CLOCK =
+            Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC);
+
+    private CockpitMonitoringPointDetailAdapter detailAdapter;
+    private CockpitMapSnapshotAdapter mapAdapter;
+    private CockpitMonitoringPointDetailService detailService;
+    private CockpitMapSnapshotService mapService;
+
+    @BeforeEach
+    void setUp() {
+        detailAdapter = mock(CockpitMonitoringPointDetailAdapter.class);
+        mapAdapter = mock(CockpitMapSnapshotAdapter.class);
+        detailService = new CockpitMonitoringPointDetailService(detailAdapter, mapAdapter, CLOCK);
+        mapService = new CockpitMapSnapshotService(mapAdapter, CLOCK);
+    }
+
+    @Test
+    void detailDevicesMatchMapSnapshotDeviceCodesAtSameSnapshotIncludingOffline() {
+        CockpitMapSnapshot snapshot = snapshotWith(SNAPSHOT_AT,
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-001", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Arrays.asList(
+                                device("EQ-003", "110.142", "28.453", false, true, false, false, true),
+                                device("EQ-001", "110.143", "28.454", false, true, true, false, true),
+                                device("EQ-005", "110.144", "28.455", false, false, false, true, true),
+                                device("EQ-002", "110.145", "28.456", false, true, false, false, false),
+                                device("EQ-004", null, null, false, false, false, false, false))));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001", SNAPSHOT_AT);
+        assertNotNull(response);
+
+        List<String> detailDeviceCodes = response.getDevices().stream()
+                .map(CockpitMonitoringPointDeviceCard::getDeviceCode)
+                .sorted(Comparator.nullsLast(String::compareTo))
+                .collect(Collectors.toList());
+
+        List<CockpitMonitoringPointSummary> points = mapService.load(
+                "req", 1, 500, SNAPSHOT_AT, null, null, null).getMonitoringPoints();
+        assertEquals(1, points.size());
+        List<String> mapDeviceCodes = points.get(0).getDeviceCodes().stream()
+                .sorted(Comparator.nullsLast(String::compareTo))
+                .collect(Collectors.toList());
+
+        assertEquals(5, detailDeviceCodes.size(), "详情必须包含全部关联设备");
+        assertEquals(mapDeviceCodes, detailDeviceCodes,
+                "同一 snapshotAt 下详情设备集合必须与 map-snapshot deviceCodes 一致(含离线、不重复)");
+        assertEquals(detailDeviceCodes.stream().distinct().count(), detailDeviceCodes.size(),
+                "详情设备集合不得重复");
+        assertTrue(mapDeviceCodes.contains("EQ-002"), "离线设备必须在集合中");
+        assertTrue(detailDeviceCodes.contains("EQ-004"), "缺坐标设备必须在集合中");
+    }
+
+    @Test
+    void detailCoordinatesAndValidationArePreservedFromSnapshotSource() {
+        CockpitMapSnapshot snapshot = snapshotWith(SNAPSHOT_AT,
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-001", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Arrays.asList(
+                                device("EQ-VALID", "110.142", "28.453", false, true, true, false, false),
+                                device("EQ-MISSING", null, null, false, false, false, false, false),
+                                device("EQ-INVALID", "200.000", "28.453", true, true, false, false, false),
+                                device("EQ-UNVERIFIED", "110.146", "28.457", false, true, false, false, false))));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001", SNAPSHOT_AT);
+
+        List<CockpitMonitoringPointDeviceCard> devices = response.getDevices();
+        assertEquals(4, devices.size());
+
+        CockpitMonitoringPointDeviceCard valid = byCode(devices, "EQ-VALID");
+        assertEquals(new BigDecimal("110.142"), valid.getLongitude());
+        assertEquals(new BigDecimal("28.453"), valid.getLatitude());
+        assertEquals("UNVERIFIED", valid.getCoordinateValidation().getState());
+        assertFalse(valid.getCoordinateValidation().isRenderable());
+
+        CockpitMonitoringPointDeviceCard missing = byCode(devices, "EQ-MISSING");
+        assertNull(missing.getLongitude());
+        assertNull(missing.getLatitude());
+        assertFalse(missing.getCoordinateValidation().isRenderable());
+        assertEquals("UNVERIFIED_COORDINATE", missing.getCoordinateValidation().getReason());
+
+        CockpitMonitoringPointDeviceCard invalid = byCode(devices, "EQ-INVALID");
+        assertEquals("INVALID", invalid.getCoordinateValidation().getState());
+        assertEquals("LONGITUDE_OUT_OF_RANGE", invalid.getCoordinateValidation().getReason());
+        assertFalse(invalid.getCoordinateValidation().isRenderable());
+
+        CockpitMonitoringPointDeviceCard unverified = byCode(devices, "EQ-UNVERIFIED");
+        assertEquals("UNVERIFIED", unverified.getCoordinateValidation().getState());
+        assertEquals("UNVERIFIED_COORDINATE", unverified.getCoordinateValidation().getReason());
+        assertFalse(unverified.getCoordinateValidation().isRenderable());
+    }
+
+    @Test
+    void snapshotTimestampMismatchFailsLikeMapSnapshot() {
+        CockpitMapSnapshot snapshot = snapshotWith("2026-09-02T11:00:00+08:00",
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-001", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.emptyList()));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        assertThrows(CockpitSnapshotExpiredException.class,
+                () -> detailService.load("req", "MP-001", SNAPSHOT_AT));
+    }
+
+    @Test
+    void snapshotMissingPointReturnsNullLikeAdapterPath() {
+        CockpitMapSnapshot snapshot = snapshotWith(SNAPSHOT_AT,
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-OTHER", "另一个点位", null, "11",
+                        new BigDecimal("110.1"), new BigDecimal("28.4"), false,
+                        Collections.emptyList()));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        assertThrows(com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException.class,
+                () -> detailService.load("req", "MP-404", SNAPSHOT_AT));
+        verifyNoInteractions(detailAdapter);
+    }
+
+    @Test
+    void withoutSnapshotAtFallsBackToDetailAdapterPath() {
+        when(detailAdapter.load("MP-001"))
+                .thenReturn(new com.zksy.cockpit.point.CockpitMonitoringPointDetail(
+                        "MP-001", "供水干管监测点",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.singletonList(device("EQ-001", "110.142", "28.453",
+                                false, true, false, false, false))));
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001", null);
+        assertNotNull(response);
+        assertEquals(1, response.getDevices().size());
+        assertEquals("EQ-001", response.getDevices().get(0).getDeviceCode());
+    }
+
+    @Test
+    void twoParameterLoadDelegatesToNullSnapshotAt() {
+        when(detailAdapter.load("MP-001"))
+                .thenReturn(new com.zksy.cockpit.point.CockpitMonitoringPointDetail(
+                        "MP-001", "供水干管监测点",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.singletonList(device("EQ-001", "110.142", "28.453",
+                                false, true, false, false, false))));
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001");
+        assertNotNull(response);
+        assertEquals(1, response.getDevices().size());
+    }
+
+    @Test
+    void malformedSnapshotAtFailsLikeMapSnapshotBeforeReading() {
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> detailService.load("req", "MP-001", "not-a-timestamp"));
+        verifyNoInteractions(mapAdapter);
+        verifyNoInteractions(detailAdapter);
+    }
+
+    @Test
+    void duplicateAndBlankDeviceCodesAreNormalizedLikeMapSnapshot() {
+        CockpitMapSnapshot snapshot = snapshotWith(SNAPSHOT_AT,
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-001", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Arrays.asList(
+                                device("EQ-001", "110.142", "28.453", false, true, false, false, false),
+                                device(" EQ-001 ", "110.143", "28.454", false, true, false, false, false),
+                                device(null, "110.144", "28.455", false, false, false, false, false),
+                                device("", "110.145", "28.456", false, false, false, false, false),
+                                device("EQ-002", null, null, false, false, false, false, false))));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001", SNAPSHOT_AT);
+
+        List<String> detailDeviceCodes = response.getDevices().stream()
+                .map(CockpitMonitoringPointDeviceCard::getDeviceCode)
+                .sorted(Comparator.nullsLast(String::compareTo))
+                .collect(Collectors.toList());
+
+        List<CockpitMonitoringPointSummary> points = mapService.load(
+                "req", 1, 500, SNAPSHOT_AT, null, null, null).getMonitoringPoints();
+        List<String> mapDeviceCodes = points.get(0).getDeviceCodes().stream()
+                .sorted(Comparator.nullsLast(String::compareTo))
+                .collect(Collectors.toList());
+
+        assertEquals(Arrays.asList("EQ-001", "EQ-002"), detailDeviceCodes,
+                "详情必须按 map 口径去重 trim 滤空码:EQ-001 只出现一次,空码/空白码剔除");
+        assertEquals(mapDeviceCodes, detailDeviceCodes,
+                "重复/空码数据下详情与 map-snapshot 集合仍必须一致");
+    }
+
+    @Test
+    void verifiedValidCoordinatesRender() {
+        CockpitMapSnapshot snapshot = snapshotWith(SNAPSHOT_AT,
+                new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "MP-001", "供水干管监测点", null, "11",
+                        new BigDecimal("110.141"), new BigDecimal("28.452"), false,
+                        Collections.singletonList(
+                                device("EQ-VERIFIED", "110.142", "28.453",
+                                        true, true, false, false, false))));
+        when(mapAdapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        CockpitMonitoringPointDetailResponse response =
+                detailService.load("req", "MP-001", SNAPSHOT_AT);
+
+        CockpitMonitoringPointDeviceCard verified = byCode(response.getDevices(), "EQ-VERIFIED");
+        assertEquals(new BigDecimal("110.142"), verified.getLongitude());
+        assertEquals(new BigDecimal("28.453"), verified.getLatitude());
+        assertEquals("VALID", verified.getCoordinateValidation().getState());
+        assertTrue(verified.getCoordinateValidation().isRenderable());
+    }
+
+    private static CockpitMapSnapshot snapshotWith(String snapshotAt,
+            CockpitMapSnapshot.SourceMonitoringPoint point) {
+        return new CockpitMapSnapshot(snapshotAt, Collections.emptyList(),
+                Collections.singletonList(point), Collections.emptyList());
+    }
+
+    private static CockpitMonitoringPointDeviceCard byCode(
+            List<CockpitMonitoringPointDeviceCard> devices, String code) {
+        return devices.stream()
+                .filter(device -> code.equals(device.getDeviceCode()))
+                .findFirst()
+                .orElseThrow(() -> new AssertionError("missing device " + code));
+    }
+
+    private static CockpitMonitoringPointDeviceSnapshot device(String code, String longitude, String latitude,
+            boolean coordinateVerified, boolean online, boolean alarm, boolean warning,
+            boolean workOrderInProgress) {
+        return new CockpitMonitoringPointDeviceSnapshot(
+                code, code + "设备", "压力计",
+                longitude == null ? null : new BigDecimal(longitude),
+                latitude == null ? null : new BigDecimal(latitude),
+                coordinateVerified,
+                online, alarm, warning, workOrderInProgress,
+                Collections.emptyList(), null);
+    }
+}

+ 33 - 5
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitOverviewInfrastructureControllerTest.java

@@ -52,8 +52,8 @@ class CockpitOverviewInfrastructureControllerTest {
         mockMvc.perform(get("/api/cockpit/v1/overview/infrastructure"))
         mockMvc.perform(get("/api/cockpit/v1/overview/infrastructure"))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(3))
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(3))
-                .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(14))
-                .andExpect(jsonPath("$.data.industries", hasSize(3)))
+                .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(12))
+                .andExpect(jsonPath("$.data.industries", hasSize(4)))
                 .andExpect(jsonPath("$.data.industries[0].code").value("GAS"))
                 .andExpect(jsonPath("$.data.industries[0].code").value("GAS"))
                 .andExpect(jsonPath("$.data.industries[0].facilityCount").value(0))
                 .andExpect(jsonPath("$.data.industries[0].facilityCount").value(0))
                 .andExpect(jsonPath("$.data.industries[0].smartDeviceCount").value(3))
                 .andExpect(jsonPath("$.data.industries[0].smartDeviceCount").value(3))
@@ -67,7 +67,7 @@ class CockpitOverviewInfrastructureControllerTest {
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[0].count").value(4))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[0].count").value(4))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[1].code").value("SEWAGE_ENVIRONMENT_SENSOR"))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[1].code").value("SEWAGE_ENVIRONMENT_SENSOR"))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[1].count").value(5))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes[1].count").value(5))
-                .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(8))
+                .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(10))
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(5));
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(5));
     }
     }
 
 
@@ -85,7 +85,7 @@ class CockpitOverviewInfrastructureControllerTest {
                 .andExpect(jsonPath("$.data.readOnly").value(true))
                 .andExpect(jsonPath("$.data.readOnly").value(true))
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(1))
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(1))
                 .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(1))
                 .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(1))
-                .andExpect(jsonPath("$.data.industries", org.hamcrest.Matchers.hasSize(3)))
+                .andExpect(jsonPath("$.data.industries", org.hamcrest.Matchers.hasSize(4)))
                 .andExpect(jsonPath("$.data.industries[0].code").value("GAS"))
                 .andExpect(jsonPath("$.data.industries[0].code").value("GAS"))
                 .andExpect(jsonPath("$.data.industries[1].code").value("WATER_SUPPLY"))
                 .andExpect(jsonPath("$.data.industries[1].code").value("WATER_SUPPLY"))
                 .andExpect(jsonPath("$.data.industries[1].facilityCount").value(1))
                 .andExpect(jsonPath("$.data.industries[1].facilityCount").value(1))
@@ -137,13 +137,41 @@ class CockpitOverviewInfrastructureControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(0))
                 .andExpect(jsonPath("$.data.totals.facilityCount").value(0))
                 .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(0))
                 .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(0))
-                .andExpect(jsonPath("$.data.industries", hasSize(3)))
+                .andExpect(jsonPath("$.data.industries", hasSize(4)))
                 .andExpect(jsonPath("$.data.industries[0].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[0].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[0].deviceTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[0].deviceTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[1].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[1].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[1].deviceTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[1].deviceTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[2].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[2].facilityTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes", hasSize(0)))
                 .andExpect(jsonPath("$.data.industries[2].deviceTypes", hasSize(0)))
+                .andExpect(jsonPath("$.data.industries[3].code").value("MANHOLE"))
+                .andExpect(jsonPath("$.data.industries[3].facilityTypes", hasSize(0)))
+                .andExpect(jsonPath("$.data.industries[3].deviceTypes", hasSize(0)))
+                .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(0))
+                .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(0));
+    }
+
+    @Test
+    void sameTypeCodeAcrossObjectKindsIsResolvedIndependently() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitOverviewInfrastructureSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Arrays.asList(
+                        new CockpitOverviewInfrastructureSnapshot.SourceType(
+                                "1", "设备一", "GAS", null, "SMART_DEVICE"),
+                        new CockpitOverviewInfrastructureSnapshot.SourceType(
+                                "1", "设施一", "WATER_SUPPLY", null, "FACILITY")),
+                Arrays.asList(
+                        new CockpitOverviewInfrastructureSnapshot.SourceCount("SMART_DEVICE", "1", 2),
+                        new CockpitOverviewInfrastructureSnapshot.SourceCount("FACILITY", "1", 3))));
+
+        mockMvc.perform(get("/api/cockpit/v1/overview/infrastructure"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.totals.facilityCount").value(3))
+                .andExpect(jsonPath("$.data.totals.smartDeviceCount").value(2))
+                .andExpect(jsonPath("$.data.industries[0].facilityCount").value(0))
+                .andExpect(jsonPath("$.data.industries[0].smartDeviceCount").value(2))
+                .andExpect(jsonPath("$.data.industries[1].facilityCount").value(3))
+                .andExpect(jsonPath("$.data.industries[1].smartDeviceCount").value(0))
                 .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(0))
                 .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(0))
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(0));
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(0));
     }
     }

+ 17 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitWorkOrderStateDictionaryTest.java

@@ -0,0 +1,17 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.workorder.CockpitWorkOrderStateDictionary;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class CockpitWorkOrderStateDictionaryTest {
+
+    @Test
+    void mapsOperationLogsToCurrentRuntimeStates() {
+        assertEquals(0, CockpitWorkOrderStateDictionary.byOperationCode(0, 0).getCode());
+        assertEquals(3, CockpitWorkOrderStateDictionary.byOperationCode(6, 3).getCode());
+        assertEquals(6, CockpitWorkOrderStateDictionary.byOperationCode(9, 6).getCode());
+        assertEquals(3, CockpitWorkOrderStateDictionary.byOperationCode(10, 3).getCode());
+    }
+}

+ 24 - 16
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/MonitoringServiceImpl.java

@@ -69,13 +69,14 @@ public class MonitoringServiceImpl implements MonitoringService {
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<String, RadarData> radarMap = selectLatestRadar(devices, startTime, endTime, flowMin, flowMax);
         Map<String, RadarData> radarMap = selectLatestRadar(devices, startTime, endTime, flowMin, flowMax);
         Map<String, TelemetryData> telemetryMap = selectLatestTelemetry(devices, startTime, endTime, flowMin, flowMax);
         Map<String, TelemetryData> telemetryMap = selectLatestTelemetry(devices, startTime, endTime, flowMin, flowMax);
+        boolean measurementFiltered = startTime != null || endTime != null || flowMin != null || flowMax != null;
 
 
         List<FlowMonitoringVO> allRows = new ArrayList<>();
         List<FlowMonitoringVO> allRows = new ArrayList<>();
         for (EquipmentBase device : devices) {
         for (EquipmentBase device : devices) {
             String code = device.getEquipmentCode();
             String code = device.getEquipmentCode();
             RadarData radar = radarMap.get(code);
             RadarData radar = radarMap.get(code);
             TelemetryData telemetry = telemetryMap.get(code);
             TelemetryData telemetry = telemetryMap.get(code);
-            if (radar == null && telemetry == null) {
+            if (measurementFiltered && radar == null && telemetry == null) {
                 continue;
                 continue;
             }
             }
 
 
@@ -87,7 +88,7 @@ public class MonitoringServiceImpl implements MonitoringService {
                 vo.setInstantFlow(radar.getMeter1InstantFlow());
                 vo.setInstantFlow(radar.getMeter1InstantFlow());
                 vo.setFlowSpeed(radar.getFlowSpeed());
                 vo.setFlowSpeed(radar.getFlowSpeed());
                 vo.setMonitorTime(radar.getCreateTime());
                 vo.setMonitorTime(radar.getCreateTime());
-            } else {
+            } else if (telemetry != null) {
                 vo.setDataSource(TELEMETRY_SOURCE);
                 vo.setDataSource(TELEMETRY_SOURCE);
                 vo.setInstantFlow(telemetry.getMeter1InstantFlow());
                 vo.setInstantFlow(telemetry.getMeter1InstantFlow());
                 vo.setPositiveTotal(telemetry.getMeter1PositiveTotal());
                 vo.setPositiveTotal(telemetry.getMeter1PositiveTotal());
@@ -113,6 +114,7 @@ public class MonitoringServiceImpl implements MonitoringService {
 
 
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<String, FirefightingPressure> pressureMap = new HashMap<>();
         Map<String, FirefightingPressure> pressureMap = new HashMap<>();
+        boolean measurementFiltered = startTime != null || endTime != null || pressureMin != null || pressureMax != null;
         List<String> deviceCodes = deviceCodes(devices);
         List<String> deviceCodes = deviceCodes(devices);
         if (!deviceCodes.isEmpty()) {
         if (!deviceCodes.isEmpty()) {
             List<FirefightingPressure> records = firefightingPressureMapper.selectList(
             List<FirefightingPressure> records = firefightingPressureMapper.selectList(
@@ -128,13 +130,15 @@ public class MonitoringServiceImpl implements MonitoringService {
         List<PressureMonitoringVO> allRows = new ArrayList<>();
         List<PressureMonitoringVO> allRows = new ArrayList<>();
         for (EquipmentBase device : devices) {
         for (EquipmentBase device : devices) {
             FirefightingPressure pressure = pressureMap.get(device.getEquipmentCode());
             FirefightingPressure pressure = pressureMap.get(device.getEquipmentCode());
-            if (pressure == null) {
+            if (measurementFiltered && pressure == null) {
                 continue;
                 continue;
             }
             }
             PressureMonitoringVO vo = new PressureMonitoringVO();
             PressureMonitoringVO vo = new PressureMonitoringVO();
             fillBaseFields(vo, device, typeMap.get(device.getEquipmentTypeId()));
             fillBaseFields(vo, device, typeMap.get(device.getEquipmentTypeId()));
-            vo.setPressureValue(pressure.getPressureValue());
-            vo.setMonitorTime(pressure.getCreateTime());
+            if (pressure != null) {
+                vo.setPressureValue(pressure.getPressureValue());
+                vo.setMonitorTime(pressure.getCreateTime());
+            }
             allRows.add(vo);
             allRows.add(vo);
         }
         }
         return pageOf(allRows, pageNum, pageSize);
         return pageOf(allRows, pageNum, pageSize);
@@ -153,6 +157,7 @@ public class MonitoringServiceImpl implements MonitoringService {
 
 
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<Integer, EquipmentType> typeMap = selectTypeMap(devices);
         Map<String, NoiseInfo> noiseMap = new HashMap<>();
         Map<String, NoiseInfo> noiseMap = new HashMap<>();
+        boolean measurementFiltered = startTime != null || endTime != null || powerMin != null || powerMax != null;
         List<String> deviceCodes = deviceCodes(devices);
         List<String> deviceCodes = deviceCodes(devices);
         if (!deviceCodes.isEmpty()) {
         if (!deviceCodes.isEmpty()) {
             List<NoiseInfo> records = noiseInfoMapper.selectList(
             List<NoiseInfo> records = noiseInfoMapper.selectList(
@@ -168,16 +173,18 @@ public class MonitoringServiceImpl implements MonitoringService {
         List<LeakageMonitoringVO> allRows = new ArrayList<>();
         List<LeakageMonitoringVO> allRows = new ArrayList<>();
         for (EquipmentBase device : devices) {
         for (EquipmentBase device : devices) {
             NoiseInfo noise = noiseMap.get(device.getEquipmentCode());
             NoiseInfo noise = noiseMap.get(device.getEquipmentCode());
-            if (noise == null) {
+            if (measurementFiltered && noise == null) {
                 continue;
                 continue;
             }
             }
             LeakageMonitoringVO vo = new LeakageMonitoringVO();
             LeakageMonitoringVO vo = new LeakageMonitoringVO();
             fillBaseFields(vo, device, typeMap.get(device.getEquipmentTypeId()));
             fillBaseFields(vo, device, typeMap.get(device.getEquipmentTypeId()));
-            vo.setPower(noise.getPower());
-            vo.setGain(noise.getGain());
-            vo.setRms(noise.getRms());
-            vo.setCenterFrequency(noise.getCenterFrequency());
-            vo.setMonitorTime(noise.getCreateTime());
+            if (noise != null) {
+                vo.setPower(noise.getPower());
+                vo.setGain(noise.getGain());
+                vo.setRms(noise.getRms());
+                vo.setCenterFrequency(noise.getCenterFrequency());
+                vo.setMonitorTime(noise.getCreateTime());
+            }
             allRows.add(vo);
             allRows.add(vo);
         }
         }
         return pageOf(allRows, pageNum, pageSize);
         return pageOf(allRows, pageNum, pageSize);
@@ -515,16 +522,17 @@ public class MonitoringServiceImpl implements MonitoringService {
 
 
     /** Restrict monitoring pages and trends to the canonical water-supply monitoring types. */
     /** Restrict monitoring pages and trends to the canonical water-supply monitoring types. */
     private Set<Integer> selectMonitoringTypeIds(String monitorKind) {
     private Set<Integer> selectMonitoringTypeIds(String monitorKind) {
-        Integer typeId;
+        Set<Integer> typeIds;
         switch (monitorKind) {
         switch (monitorKind) {
             case "pressure":
             case "pressure":
-                typeId = EquipmentTypeEnum.PRESSURE_GAUGE.getId();
+                typeIds = Set.of(EquipmentTypeEnum.PRESSURE_GAUGE.getId(),
+                        EquipmentTypeEnum.FIRE_HYDRANT_PRESSURE_TERMINAL.getId());
                 break;
                 break;
             case "leakage":
             case "leakage":
-                typeId = EquipmentTypeEnum.LEAK_MONITOR.getId();
+                typeIds = Collections.singleton(EquipmentTypeEnum.LEAK_MONITOR.getId());
                 break;
                 break;
             case "flow":
             case "flow":
-                typeId = EquipmentTypeEnum.ULTRASONIC_FLOWMETER.getId();
+                typeIds = Collections.singleton(EquipmentTypeEnum.ULTRASONIC_FLOWMETER.getId());
                 break;
                 break;
             default:
             default:
                 return Collections.emptySet();
                 return Collections.emptySet();
@@ -538,7 +546,7 @@ public class MonitoringServiceImpl implements MonitoringService {
             return Collections.emptySet();
             return Collections.emptySet();
         }
         }
         return types.stream()
         return types.stream()
-                .filter(type -> typeId.equals(type.getId())
+                .filter(type -> typeIds.contains(type.getId())
                         && EquipmentTypeEnum.ROOT_WATER_SUPPLY_DEVICE.getId().equals(type.getParentId()))
                         && EquipmentTypeEnum.ROOT_WATER_SUPPLY_DEVICE.getId().equals(type.getParentId()))
                 .map(EquipmentType::getId)
                 .map(EquipmentType::getId)
                 .collect(Collectors.toSet());
                 .collect(Collectors.toSet());

+ 28 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/detail/CockpitEquipmentDetailAggregateService.java

@@ -17,6 +17,7 @@ import com.zksy.cockpit.type.CockpitTypeMetricsService;
 import com.zksy.cockpit.workorder.CockpitWorkOrderReadResponse;
 import com.zksy.cockpit.workorder.CockpitWorkOrderReadResponse;
 import com.zksy.cockpit.workorder.CockpitWorkOrderReadService;
 import com.zksy.cockpit.workorder.CockpitWorkOrderReadService;
 import com.zksy.cockpit.workorder.CockpitWorkOrderSummary;
 import com.zksy.cockpit.workorder.CockpitWorkOrderSummary;
+import com.zksy.cockpit.workorder.CockpitWorkOrderTimelineEntry;
 import com.zksy.cockpit.workorder.CockpitWorkOrderTimelineResponse;
 import com.zksy.cockpit.workorder.CockpitWorkOrderTimelineResponse;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -221,10 +222,18 @@ public class CockpitEquipmentDetailAggregateService {
         boolean failed = false;
         boolean failed = false;
         boolean hasData = false;
         boolean hasData = false;
         for (CockpitWorkOrderSummary summary : workOrders.getData()) {
         for (CockpitWorkOrderSummary summary : workOrders.getData()) {
+            if (summary == null || isBlank(summary.getWorkOrderCode())) {
+                failed = true;
+                continue;
+            }
             try {
             try {
                 CockpitWorkOrderTimelineResponse response =
                 CockpitWorkOrderTimelineResponse response =
                         workOrderService.loadTimeline(requestId, summary.getWorkOrderCode());
                         workOrderService.loadTimeline(requestId, summary.getWorkOrderCode());
                 if (response != null) {
                 if (response != null) {
+                    if (!matchesTimeline(summary, response)) {
+                        failed = true;
+                        continue;
+                    }
                     timelines.add(response);
                     timelines.add(response);
                     hasData = true;
                     hasData = true;
                 }
                 }
@@ -242,6 +251,25 @@ public class CockpitEquipmentDetailAggregateService {
         return CockpitSectionResult.success(timelines);
         return CockpitSectionResult.success(timelines);
     }
     }
 
 
+    private static boolean matchesTimeline(
+            CockpitWorkOrderSummary requested, CockpitWorkOrderTimelineResponse response) {
+        String code = requested.getWorkOrderCode();
+        CockpitWorkOrderSummary returned = response.getWorkOrder();
+        if (!Objects.equals(code, response.getWorkOrderCode())
+                || returned == null
+                || !Objects.equals(code, returned.getWorkOrderCode())
+                || !Objects.equals(requested.getDeviceCode(), returned.getDeviceCode())
+                || response.getTimelineEntries() == null) {
+            return false;
+        }
+        for (CockpitWorkOrderTimelineEntry entry : response.getTimelineEntries()) {
+            if (entry == null || !Objects.equals(code, entry.getWorkOrderCode())) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     private CockpitSectionResult<CockpitEquipmentImage> loadLatestImage(
     private CockpitSectionResult<CockpitEquipmentImage> loadLatestImage(
             CockpitSectionResult<CockpitEquipmentArchive> archive) {
             CockpitSectionResult<CockpitEquipmentArchive> archive) {
         if (archive.getState() == CockpitSectionState.FAILED) {
         if (archive.getState() == CockpitSectionState.FAILED) {

+ 25 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitSnapshotTime.java

@@ -0,0 +1,25 @@
+package com.zksy.cockpit.foundation;
+
+import java.time.DateTimeException;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+
+/** Shared validation for cockpit snapshot timestamps. */
+public final class CockpitSnapshotTime {
+    private static final ZoneOffset BUSINESS_OFFSET = ZoneOffset.ofHours(8);
+
+    private CockpitSnapshotTime() {
+    }
+
+    public static OffsetDateTime parseBusinessOffset(String value) {
+        OffsetDateTime parsed = OffsetDateTime.parse(value);
+        if (!usesBusinessOffset(parsed)) {
+            throw new DateTimeException("snapshot timestamp must use +08:00");
+        }
+        return parsed;
+    }
+
+    public static boolean usesBusinessOffset(OffsetDateTime value) {
+        return value != null && BUSINESS_OFFSET.equals(value.getOffset());
+    }
+}

+ 5 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureBaseArchivesAdapter.java

@@ -1,5 +1,6 @@
 package com.zksy.cockpit.infrastructure;
 package com.zksy.cockpit.infrastructure;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
@@ -90,7 +91,10 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
     }
     }
 
 
     private void addPumpStations(List<CockpitInfrastructureBaseArchivesSnapshot.SourceFacility> facilities) {
     private void addPumpStations(List<CockpitInfrastructureBaseArchivesSnapshot.SourceFacility> facilities) {
-        for (WaterPumpStation station : safeList(pumpStationService.list())) {
+        for (WaterPumpStation station : safeList(pumpStationService.list(
+                new LambdaQueryWrapper<WaterPumpStation>()
+                        .in(WaterPumpStation::getStationType,
+                                PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE)))) {
             String code = trimToNull(station.getStationCode());
             String code = trimToNull(station.getStationCode());
             if (code == null) {
             if (code == null) {
                 continue;
                 continue;

+ 6 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureOperatingInformationAdapter.java

@@ -1,5 +1,6 @@
 package com.zksy.cockpit.infrastructure;
 package com.zksy.cockpit.infrastructure;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
 import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
@@ -77,7 +78,10 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     plant.getPlantCode()));
                     plant.getPlantCode()));
         }
         }
 
 
-        for (WaterPumpStation station : safeList(pumpStationService.list())) {
+        for (WaterPumpStation station : safeList(pumpStationService.list(
+                new LambdaQueryWrapper<WaterPumpStation>()
+                        .in(WaterPumpStation::getStationType,
+                                PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE)))) {
             if (station == null || isBlank(station.getStationCode()) || station.getDesignFlow() == null) {
             if (station == null || isBlank(station.getStationCode()) || station.getDesignFlow() == null) {
                 continue;
                 continue;
             }
             }
@@ -111,7 +115,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
             String sampledAt = format(pipe.getUpdateTime());
             String sampledAt = format(pipe.getUpdateTime());
             latestUpdatedAt = latest(latestUpdatedAt, sampledAt);
             latestUpdatedAt = latest(latestUpdatedAt, sampledAt);
             metrics.add(metric(
             metrics.add(metric(
-                    metricCode(industry, "pipe_length"),
+                    metricCode(industry, "pipe_network_length"),
                     isBlank(pipe.getNetworkName()) ? "管网长度" : pipe.getNetworkName() + "长度",
                     isBlank(pipe.getNetworkName()) ? "管网长度" : pipe.getNetworkName() + "长度",
                     "CAPACITY",
                     "CAPACITY",
                     "m",
                     "m",

+ 125 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/BusinessCockpitMapSnapshotAdapter.java

@@ -6,13 +6,22 @@ import com.zksy.base.domain.MonitorPoint;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.MonitorPointService;
 import com.zksy.base.service.MonitorPointService;
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import com.zksy.cockpit.foundation.CockpitSnapshotTime;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.time.Clock;
 import java.time.Clock;
+import java.time.DateTimeException;
+import java.time.Duration;
+import java.time.OffsetDateTime;
 import java.time.ZoneId;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -24,6 +33,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Objects;
 import java.util.Set;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -39,6 +51,10 @@ import java.util.stream.Collectors;
  *   <li>类型字典:{@code equipment_type}(行业由 {@code parent_id} 根推导:1 供水、2 排水、3 燃气、4 窨井)。</li>
  *   <li>类型字典:{@code equipment_type}(行业由 {@code parent_id} 根推导:1 供水、2 排水、3 燃气、4 窨井)。</li>
  * </ul>
  * </ul>
  *
  *
+ * <p>无 {@code snapshotAt} 的首屏请求固定首次读取结果;显式 token 只查询已签发的版本,
+ * 缺失或过期时拒绝,不用当前数据冒充旧快照。地图与详情端点通过共享快照存储复用该版本,
+ * 进程本地缓存只用于减少 Redis 访问,不负责定义跨实例一致性。
+ *
  * <p><b>如实接线,不臆造</b>:现网没有「坐标是否已校核」字段,故一律按未校核(
  * <p><b>如实接线,不臆造</b>:现网没有「坐标是否已校核」字段,故一律按未校核(
  * {@code coordinateVerified=false})上报,由冻结字典裁决为不可渲染;不为了「图上有东西」而伪造校验状态。
  * {@code coordinateVerified=false})上报,由冻结字典裁决为不可渲染;不为了「图上有东西」而伪造校验状态。
  * 现网 {@code monitor_point} 也没有行业/类型列,点位的 {@code typeCode} 只能在其关联设备类型唯一时推导。
  * 现网 {@code monitor_point} 也没有行业/类型列,点位的 {@code typeCode} 只能在其关联设备类型唯一时推导。
@@ -49,29 +65,136 @@ public class BusinessCockpitMapSnapshotAdapter implements CockpitMapSnapshotAdap
 
 
     private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
     private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
     private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
     private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
+    private static final Duration SNAPSHOT_RETENTION = Duration.ofMinutes(10);
+    private static final int MAX_CACHED_SNAPSHOTS = 256;
 
 
     private final MonitorPointService monitorPointService;
     private final MonitorPointService monitorPointService;
     private final EquipmentBaseService equipmentBaseService;
     private final EquipmentBaseService equipmentBaseService;
     private final EquipmentTypeService equipmentTypeService;
     private final EquipmentTypeService equipmentTypeService;
     private final BusinessCockpitDeviceFactResolver deviceFactResolver;
     private final BusinessCockpitDeviceFactResolver deviceFactResolver;
     private final Clock clock;
     private final Clock clock;
+    private final RedisTemplate<Object, Object> redisTemplate;
+    private final ConcurrentMap<String, CockpitMapSnapshot> snapshots = new ConcurrentHashMap<>();
 
 
+    @Autowired
     public BusinessCockpitMapSnapshotAdapter(
     public BusinessCockpitMapSnapshotAdapter(
             MonitorPointService monitorPointService,
             MonitorPointService monitorPointService,
             EquipmentBaseService equipmentBaseService,
             EquipmentBaseService equipmentBaseService,
             EquipmentTypeService equipmentTypeService,
             EquipmentTypeService equipmentTypeService,
             BusinessCockpitDeviceFactResolver deviceFactResolver,
             BusinessCockpitDeviceFactResolver deviceFactResolver,
-            Clock clock) {
+            Clock clock,
+            RedisTemplate<Object, Object> redisTemplate) {
         this.monitorPointService = monitorPointService;
         this.monitorPointService = monitorPointService;
         this.equipmentBaseService = equipmentBaseService;
         this.equipmentBaseService = equipmentBaseService;
         this.equipmentTypeService = equipmentTypeService;
         this.equipmentTypeService = equipmentTypeService;
         this.deviceFactResolver = deviceFactResolver;
         this.deviceFactResolver = deviceFactResolver;
         this.clock = clock;
         this.clock = clock;
+        this.redisTemplate = redisTemplate;
+    }
+
+    public BusinessCockpitMapSnapshotAdapter(
+            MonitorPointService monitorPointService,
+            EquipmentBaseService equipmentBaseService,
+            EquipmentTypeService equipmentTypeService,
+            BusinessCockpitDeviceFactResolver deviceFactResolver,
+            Clock clock) {
+        this(monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver, clock, null);
     }
     }
 
 
     @Override
     @Override
     public CockpitMapSnapshot load(String snapshotAt) {
     public CockpitMapSnapshot load(String snapshotAt) {
         String resolvedSnapshotAt = snapshotAt == null ? businessTime() : snapshotAt;
         String resolvedSnapshotAt = snapshotAt == null ? businessTime() : snapshotAt;
+        OffsetDateTime requestedAt = parseSnapshotAt(resolvedSnapshotAt);
+        OffsetDateTime now = OffsetDateTime.now(clock);
+        validateSnapshotWindow(requestedAt, now, "snapshot timestamp outside retention window");
+
+        snapshots.keySet().removeIf(cachedAt ->
+                !OffsetDateTime.parse(cachedAt).isAfter(now.minus(SNAPSHOT_RETENTION)));
+        CockpitMapSnapshot cached = snapshots.get(resolvedSnapshotAt);
+        if (cached != null) {
+            validateSnapshotWindow(requestedAt, OffsetDateTime.now(clock), "snapshot timestamp expired during load");
+            return cached;
+        }
+
+        String cacheKey = "cockpit:map-snapshot:" + resolvedSnapshotAt;
+        if (redisTemplate != null) {
+            try {
+                CockpitMapSnapshot shared = (CockpitMapSnapshot) redisTemplate.opsForValue().get(cacheKey);
+                if (shared != null) {
+                    cacheLocally(resolvedSnapshotAt, shared);
+                    validateSnapshotWindow(requestedAt, OffsetDateTime.now(clock),
+                            "snapshot timestamp expired during load");
+                    return shared;
+                }
+            } catch (CockpitSnapshotExpiredException exception) {
+                throw exception;
+            } catch (RuntimeException exception) {
+                throw new CockpitReadException("snapshot cache unavailable");
+            }
+        }
+        if (snapshotAt != null) {
+            throw new CockpitSnapshotExpiredException("snapshot not found");
+        }
+        if (redisTemplate == null && snapshots.size() >= MAX_CACHED_SNAPSHOTS) {
+            throw new CockpitReadException("snapshot cache capacity reached");
+        }
+
+        CockpitMapSnapshot built = buildSnapshot(resolvedSnapshotAt);
+        OffsetDateTime writeTime = OffsetDateTime.now(clock);
+        validateSnapshotWindow(requestedAt, writeTime, "snapshot timestamp expired during load");
+        if (redisTemplate != null) {
+            try {
+                Duration remaining = Duration.between(writeTime, requestedAt.plus(SNAPSHOT_RETENTION));
+                long ttlSeconds = Math.max(1,
+                        remaining.getSeconds() + (remaining.getNano() > 0 ? 1 : 0));
+                Boolean stored = redisTemplate.opsForValue()
+                        .setIfAbsent(cacheKey, built, ttlSeconds, TimeUnit.SECONDS);
+                if (!Boolean.TRUE.equals(stored)) {
+                    CockpitMapSnapshot shared = (CockpitMapSnapshot) redisTemplate.opsForValue().get(cacheKey);
+                    if (shared == null) {
+                        throw new CockpitReadException("snapshot cache unavailable");
+                    }
+                    validateSnapshotWindow(requestedAt, OffsetDateTime.now(clock),
+                            "snapshot timestamp expired during load");
+                    built = shared;
+                }
+            } catch (CockpitSnapshotExpiredException | CockpitReadException exception) {
+                throw exception;
+            } catch (RuntimeException exception) {
+                throw new CockpitReadException("snapshot cache unavailable");
+            }
+        }
+        cacheLocally(resolvedSnapshotAt, built);
+        CockpitMapSnapshot result = snapshots.getOrDefault(resolvedSnapshotAt, built);
+        validateSnapshotWindow(requestedAt, OffsetDateTime.now(clock),
+                "snapshot timestamp expired during load");
+        return result;
+    }
+
+    private static OffsetDateTime parseSnapshotAt(String value) {
+        try {
+            return CockpitSnapshotTime.parseBusinessOffset(value);
+        } catch (DateTimeException exception) {
+            throw new CockpitInvalidRequestException("snapshot timestamp must use ISO-8601 +08:00");
+        }
+    }
+
+    private void cacheLocally(String snapshotAt, CockpitMapSnapshot snapshot) {
+        synchronized (snapshots) {
+            if (snapshots.containsKey(snapshotAt) || snapshots.size() < MAX_CACHED_SNAPSHOTS) {
+                snapshots.putIfAbsent(snapshotAt, snapshot);
+            }
+        }
+    }
+    private static void validateSnapshotWindow(
+            OffsetDateTime requestedAt, OffsetDateTime now, String message) {
+        if (!requestedAt.isAfter(now.minus(SNAPSHOT_RETENTION))
+                || !requestedAt.isBefore(now.plus(SNAPSHOT_RETENTION))) {
+            throw new CockpitSnapshotExpiredException(message);
+        }
+    }
+
+    private CockpitMapSnapshot buildSnapshot(String resolvedSnapshotAt) {
 
 
         Map<Integer, EquipmentType> types = equipmentTypes();
         Map<Integer, EquipmentType> types = equipmentTypes();
         List<MonitorPoint> points = safeList(monitorPointService.list());
         List<MonitorPoint> points = safeList(monitorPointService.list());
@@ -137,7 +260,7 @@ public class BusinessCockpitMapSnapshotAdapter implements CockpitMapSnapshotAdap
                 .map(type -> new CockpitMapSnapshot.SourceType(
                 .map(type -> new CockpitMapSnapshot.SourceType(
                         String.valueOf(type.getId()),
                         String.valueOf(type.getId()),
                         type.getTypeName(),
                         type.getTypeName(),
-                        CockpitTypeIndustry.industryOf(type),
+                        CockpitTypeIndustry.industryOf(type, types),
                         "SMART_DEVICE"))
                         "SMART_DEVICE"))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
 
 

+ 12 - 6
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitMapSnapshotService.java

@@ -6,6 +6,7 @@ import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import com.zksy.cockpit.foundation.CockpitSnapshotTime;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
@@ -13,10 +14,9 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.time.Clock;
 import java.time.Clock;
-import java.time.OffsetDateTime;
+import java.time.DateTimeException;
 import java.time.ZoneId;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
@@ -62,7 +62,10 @@ public class CockpitMapSnapshotService {
 
 
         CockpitMapSnapshot snapshot = adapter.load(snapshotAt);
         CockpitMapSnapshot snapshot = adapter.load(snapshotAt);
         if (snapshot == null) {
         if (snapshot == null) {
-            snapshot = CockpitMapSnapshot.empty(resolveSnapshotAt(snapshotAt));
+            if (snapshotAt != null) {
+                throw new CockpitSnapshotExpiredException("snapshot not found");
+            }
+            snapshot = CockpitMapSnapshot.empty(resolveSnapshotAt(null));
         }
         }
         if (snapshot.getSnapshotAt() == null) {
         if (snapshot.getSnapshotAt() == null) {
             throw new CockpitSnapshotExpiredException("snapshot timestamp missing");
             throw new CockpitSnapshotExpiredException("snapshot timestamp missing");
@@ -127,9 +130,12 @@ public class CockpitMapSnapshotService {
     }
     }
 
 
     private static void validatePagination(int page, int pageSize, String snapshotAt) {
     private static void validatePagination(int page, int pageSize, String snapshotAt) {
-        if (page < 1 || pageSize < 1 || pageSize > MAX_PAGE_SIZE || (page > 1 && isBlank(snapshotAt))) {
+        if (page < 1 || pageSize < 1 || pageSize > MAX_PAGE_SIZE) {
             throw new CockpitInvalidRequestException("地图快照分页参数不合法");
             throw new CockpitInvalidRequestException("地图快照分页参数不合法");
         }
         }
+        if (page > 1 && isBlank(snapshotAt)) {
+            throw new CockpitSnapshotExpiredException("snapshot token required for later pages");
+        }
     }
     }
 
 
     private static void validateSnapshotAt(String snapshotAt) {
     private static void validateSnapshotAt(String snapshotAt) {
@@ -137,8 +143,8 @@ public class CockpitMapSnapshotService {
             return;
             return;
         }
         }
         try {
         try {
-            OffsetDateTime.parse(snapshotAt);
-        } catch (DateTimeParseException exception) {
+            CockpitSnapshotTime.parseBusinessOffset(snapshotAt);
+        } catch (DateTimeException exception) {
             throw new CockpitInvalidRequestException("地图快照分页参数不合法");
             throw new CockpitInvalidRequestException("地图快照分页参数不合法");
         }
         }
     }
     }

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringDistributionAdapter.java

@@ -139,7 +139,7 @@ public class BusinessCockpitMonitoringDistributionAdapter implements CockpitMoni
                 .map(type -> new CockpitMonitoringDistributionSnapshot.SourceType(
                 .map(type -> new CockpitMonitoringDistributionSnapshot.SourceType(
                         String.valueOf(type.getId()),
                         String.valueOf(type.getId()),
                         type.getTypeName(),
                         type.getTypeName(),
-                        CockpitTypeIndustry.industryOf(type),
+                        CockpitTypeIndustry.industryOf(type, types),
                         "SMART_DEVICE"))
                         "SMART_DEVICE"))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
 
 

+ 242 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewInfrastructureAdapter.java

@@ -0,0 +1,242 @@
+package com.zksy.cockpit.overview;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
+import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
+import com.zksy.WaterSupply.WaterPumpStation.domain.PumpStationType;
+import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
+import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.foundation.CockpitTypeIndustry;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 总体概览-基础设施 真实数据适配器(BT-5)。
+ *
+ * <p>智能设备按 {@code equipment_type} 分组计数({@code objectKind=SMART_DEVICE});
+ * 水厂和泵站分别取自其设施台账,共用泵站按 {@code station_type} 区分供水/排水。
+ * 管网设施按 {@code pipe_network_base.network_type} 分组计数({@code objectKind=FACILITY})。
+ * 管网类型无可信行业字典,{@code industry} 如实为 {@code null};设施长度由 {@code length}(米)换算公里。
+ * {@code updatedAt} 取各台账最新更新时间。
+ */
+@Component
+@Primary
+public class BusinessCockpitOverviewInfrastructureAdapter
+        implements CockpitOverviewInfrastructureAdapter {
+
+    private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
+
+    private final EquipmentTypeService equipmentTypeService;
+    private final EquipmentBaseService equipmentBaseService;
+    private final PipeNetworkBaseService pipeNetworkBaseService;
+    private final IWaterPlantInfoService plantService;
+    private final IWaterPumpStationService pumpStationService;
+
+    public BusinessCockpitOverviewInfrastructureAdapter(
+            EquipmentTypeService equipmentTypeService,
+            EquipmentBaseService equipmentBaseService,
+            PipeNetworkBaseService pipeNetworkBaseService,
+            IWaterPlantInfoService plantService,
+            IWaterPumpStationService pumpStationService) {
+        this.equipmentTypeService = equipmentTypeService;
+        this.equipmentBaseService = equipmentBaseService;
+        this.pipeNetworkBaseService = pipeNetworkBaseService;
+        this.plantService = plantService;
+        this.pumpStationService = pumpStationService;
+    }
+
+    @Override
+    public CockpitOverviewInfrastructureSnapshot load() {
+        List<EquipmentType> equipmentTypes = safeList(equipmentTypeService.list());
+        Map<Integer, EquipmentType> types = equipmentTypes(equipmentTypes);
+
+        List<CockpitOverviewInfrastructureSnapshot.SourceType> sourceTypes = new ArrayList<>();
+        for (EquipmentType type : equipmentTypes) {
+            if (type == null || type.getId() == null) {
+                continue;
+            }
+            sourceTypes.add(new CockpitOverviewInfrastructureSnapshot.SourceType(
+                    String.valueOf(type.getId()),
+                    type.getTypeName(),
+                    CockpitTypeIndustry.industryOf(type, types),
+                    null,
+                    "SMART_DEVICE"));
+        }
+
+        List<EquipmentBase> devices = safeList(equipmentBaseService.list());
+        List<CockpitOverviewInfrastructureSnapshot.SourceCount> counts = new ArrayList<>();
+        Map<Integer, Integer> deviceCountByType = new LinkedHashMap<>();
+        for (EquipmentBase device : devices) {
+            if (device == null || device.getEquipmentTypeId() == null) {
+                continue;
+            }
+            deviceCountByType.merge(device.getEquipmentTypeId(), 1, Integer::sum);
+        }
+        for (Map.Entry<Integer, Integer> entry : deviceCountByType.entrySet()) {
+            counts.add(new CockpitOverviewInfrastructureSnapshot.SourceCount(
+                    "SMART_DEVICE", String.valueOf(entry.getKey()), entry.getValue()));
+        }
+
+        Map<String, FacilityAggregate> facilityByType = new LinkedHashMap<>();
+        List<PipeNetworkBase> facilities = safeList(pipeNetworkBaseService.list());
+        for (PipeNetworkBase facility : facilities) {
+            if (facility == null) {
+                continue;
+            }
+            String typeCode = trimToNull(facility.getNetworkType());
+            if (typeCode == null) {
+                continue;
+            }
+            FacilityAggregate aggregate = facilityByType.computeIfAbsent(typeCode, key -> new FacilityAggregate());
+            aggregate.count++;
+            if (facility.getLength() != null) {
+                aggregate.lengthMeters = aggregate.lengthMeters == null
+                        ? BigDecimal.ZERO : aggregate.lengthMeters;
+                aggregate.lengthMeters = aggregate.lengthMeters.add(facility.getLength());
+            }
+        }
+        for (Map.Entry<String, FacilityAggregate> entry : facilityByType.entrySet()) {
+            String typeCode = entry.getKey();
+            FacilityAggregate aggregate = entry.getValue();
+            sourceTypes.add(new CockpitOverviewInfrastructureSnapshot.SourceType(
+                    typeCode, typeCode, null, null, "FACILITY"));
+            BigDecimal lengthKm = aggregate.lengthMeters == null
+                    ? null : aggregate.lengthMeters.divide(BigDecimal.valueOf(1000), 3, RoundingMode.HALF_UP);
+            counts.add(new CockpitOverviewInfrastructureSnapshot.SourceCount(
+                    "FACILITY", typeCode, aggregate.count,
+                    new CockpitOverviewInfrastructureSnapshot.SourceValue(lengthKm, "km", null)));
+        }
+
+        List<WaterPlantInfo> plants = safeList(plantService.list());
+        int plantCount = 0;
+        for (WaterPlantInfo plant : plants) {
+            if (!isBlank(plant.getPlantCode())) {
+                plantCount++;
+            }
+        }
+        addFacilityCount(sourceTypes, counts, "WATER_PLANT", "水厂", "WATER_SUPPLY", plantCount);
+
+        List<WaterPumpStation> stations = safeList(pumpStationService.list(
+                new LambdaQueryWrapper<WaterPumpStation>()
+                        .in(WaterPumpStation::getStationType,
+                                PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE)));
+        int waterStationCount = 0;
+        int drainageStationCount = 0;
+        for (WaterPumpStation station : stations) {
+            if (isBlank(station.getStationCode())) {
+                continue;
+            }
+            String stationType = trimToNull(station.getStationType());
+            if (PumpStationType.WATER_SUPPLY.equalsIgnoreCase(stationType)) {
+                waterStationCount++;
+            } else if (PumpStationType.DRAINAGE.equalsIgnoreCase(stationType)) {
+                drainageStationCount++;
+            }
+        }
+        addFacilityCount(sourceTypes, counts, "WATER_PUMP_STATION", "供水泵站", "WATER_SUPPLY", waterStationCount);
+        addFacilityCount(sourceTypes, counts, "DRAINAGE_PUMP_STATION", "排水泵站", "DRAINAGE", drainageStationCount);
+
+        LocalDateTime updatedAt = null;
+        for (EquipmentBase device : devices) {
+            if (device == null) {
+                continue;
+            }
+            updatedAt = latest(updatedAt, device.getUpdateTime());
+            updatedAt = latest(updatedAt, device.getCreateTime());
+        }
+        for (PipeNetworkBase facility : facilities) {
+            if (facility == null) {
+                continue;
+            }
+            updatedAt = latest(updatedAt, facility.getUpdateTime());
+            updatedAt = latest(updatedAt, facility.getCreateTime());
+        }
+        for (WaterPlantInfo plant : plants) {
+            updatedAt = latest(updatedAt, plant.getUpdateTime());
+            updatedAt = latest(updatedAt, plant.getCreateTime());
+        }
+        for (WaterPumpStation station : stations) {
+            updatedAt = latest(updatedAt, station.getUpdateTime());
+            updatedAt = latest(updatedAt, station.getCreateTime());
+        }
+
+        return new CockpitOverviewInfrastructureSnapshot(
+                offsetTime(updatedAt), sourceTypes, counts);
+    }
+
+    private static void addFacilityCount(
+            List<CockpitOverviewInfrastructureSnapshot.SourceType> types,
+            List<CockpitOverviewInfrastructureSnapshot.SourceCount> counts,
+            String code, String name, String industry, int count) {
+        if (count == 0) {
+            return;
+        }
+        types.add(new CockpitOverviewInfrastructureSnapshot.SourceType(code, name, industry, null, "FACILITY"));
+        counts.add(new CockpitOverviewInfrastructureSnapshot.SourceCount("FACILITY", code, count));
+    }
+
+    private static Map<Integer, EquipmentType> equipmentTypes(List<EquipmentType> values) {
+        Map<Integer, EquipmentType> result = new HashMap<>();
+        for (EquipmentType type : values) {
+            if (type != null && type.getId() != null) {
+                result.put(type.getId(), type);
+            }
+        }
+        return result;
+    }
+
+    private static LocalDateTime latest(LocalDateTime current, LocalDateTime candidate) {
+        if (candidate == null) {
+            return current;
+        }
+        if (current == null || candidate.isAfter(current)) {
+            return candidate;
+        }
+        return current;
+    }
+
+    private static String offsetTime(LocalDateTime value) {
+        return value == null ? null : TIME_FORMATTER.format(value.atZone(BUSINESS_ZONE).toOffsetDateTime());
+    }
+
+    private static String trimToNull(String value) {
+        if (value == null || value.trim().isEmpty()) {
+            return null;
+        }
+        return value.trim();
+    }
+
+    private static boolean isBlank(String value) {
+        return value == null || value.trim().isEmpty();
+    }
+
+    private static <T> List<T> safeList(List<T> value) {
+        return value == null ? Collections.emptyList() : value.stream().filter(Objects::nonNull).collect(Collectors.toList());
+    }
+
+    private static class FacilityAggregate {
+        private int count;
+        private BigDecimal lengthMeters;
+    }
+}

+ 258 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewMonitoringAdapter.java

@@ -0,0 +1,258 @@
+package com.zksy.cockpit.overview;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.domain.EquipmentStatus;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.domain.MonitorPoint;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.gas.domain.GasMonitorData;
+import com.zksy.base.gas.service.GasMonitorDataService;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.EquipmentStatusService;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.base.service.MonitorPointService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.base.water.domain.WaterMonitorData;
+import com.zksy.base.water.service.WaterMonitorDataService;
+import com.zksy.cockpit.foundation.CockpitTypeIndustry;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * 总体概览-运行监测 真实数据适配器(BT-5)。
+ *
+ * <p>设备来自 {@code equipment_base},监测状态取 {@code equipment_status}(在线→ONLINE、离线→OFFLINE,
+ * 缺失→未知,不产生 STALE——现网无样本过期依据);监测点经 {@code getEquipmentByPoint} 关联设备,
+ * 仅当点内设备类型唯一时推导类型编码;设施按 {@code pipe_network_base.network_type} 计为 FACILITY。
+ * 指标新鲜度取燃气/水位监测表最新入库时间(无帧 → 不提供)。
+ */
+@Component
+@Primary
+public class BusinessCockpitOverviewMonitoringAdapter
+        implements CockpitOverviewMonitoringAdapter {
+
+    private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
+
+    private final EquipmentTypeService equipmentTypeService;
+    private final EquipmentBaseService equipmentBaseService;
+    private final MonitorPointService monitorPointService;
+    private final PipeNetworkBaseService pipeNetworkBaseService;
+    private final EquipmentStatusService equipmentStatusService;
+    private final GasMonitorDataService gasMonitorDataService;
+    private final WaterMonitorDataService waterMonitorDataService;
+
+    public BusinessCockpitOverviewMonitoringAdapter(
+            EquipmentTypeService equipmentTypeService,
+            EquipmentBaseService equipmentBaseService,
+            MonitorPointService monitorPointService,
+            PipeNetworkBaseService pipeNetworkBaseService,
+            EquipmentStatusService equipmentStatusService,
+            GasMonitorDataService gasMonitorDataService,
+            WaterMonitorDataService waterMonitorDataService) {
+        this.equipmentTypeService = equipmentTypeService;
+        this.equipmentBaseService = equipmentBaseService;
+        this.monitorPointService = monitorPointService;
+        this.pipeNetworkBaseService = pipeNetworkBaseService;
+        this.equipmentStatusService = equipmentStatusService;
+        this.gasMonitorDataService = gasMonitorDataService;
+        this.waterMonitorDataService = waterMonitorDataService;
+    }
+
+    @Override
+    public CockpitOverviewMonitoringSnapshot load() {
+        Map<Integer, EquipmentType> types = equipmentTypes();
+
+        List<CockpitOverviewMonitoringSnapshot.SourceType> sourceTypes = new ArrayList<>();
+        for (EquipmentType type : safeList(equipmentTypeService.list())) {
+            if (type == null || type.getId() == null) {
+                continue;
+            }
+            sourceTypes.add(new CockpitOverviewMonitoringSnapshot.SourceType(
+                    String.valueOf(type.getId()),
+                    type.getTypeName(),
+                    CockpitTypeIndustry.industryOf(type, types),
+                    null,
+                    "SMART_DEVICE"));
+        }
+        Set<String> facilityTypeCodes = new LinkedHashSet<>();
+        List<CockpitOverviewMonitoringSnapshot.SourceMonitoringFacility> monitoringFacilities = new ArrayList<>();
+        int infrastructureFacilityCount = 0;
+        for (PipeNetworkBase facility : safeList(pipeNetworkBaseService.list())) {
+            if (facility == null || isBlank(facility.getNetworkCode())) {
+                continue;
+            }
+            infrastructureFacilityCount++;
+            String typeCode = trimToNull(facility.getNetworkType());
+            if (typeCode != null) {
+                facilityTypeCodes.add(typeCode);
+            }
+            monitoringFacilities.add(new CockpitOverviewMonitoringSnapshot.SourceMonitoringFacility(
+                    facility.getNetworkCode().trim(), typeCode));
+        }
+        for (String typeCode : facilityTypeCodes) {
+            sourceTypes.add(new CockpitOverviewMonitoringSnapshot.SourceType(
+                    typeCode, typeCode, null, null, "FACILITY"));
+        }
+
+        Map<String, String> pointTypeByCode = pointTypes(safeList(monitorPointService.list()));
+        List<CockpitOverviewMonitoringSnapshot.SourceMonitoringPoint> monitoringPoints = new ArrayList<>();
+        for (MonitorPoint point : safeList(monitorPointService.list())) {
+            if (point == null || isBlank(point.getPointCode())) {
+                continue;
+            }
+            monitoringPoints.add(new CockpitOverviewMonitoringSnapshot.SourceMonitoringPoint(
+                    point.getPointCode().trim(), pointTypeByCode.get(point.getPointCode().trim())));
+        }
+
+        List<CockpitOverviewMonitoringSnapshot.SourceDevice> sourceDevices = new ArrayList<>();
+        LocalDateTime updatedAt = null;
+        for (EquipmentBase device : safeList(equipmentBaseService.list())) {
+            if (device == null || isBlank(device.getEquipmentCode())) {
+                continue;
+            }
+            updatedAt = latest(updatedAt, device.getUpdateTime());
+            updatedAt = latest(updatedAt, device.getCreateTime());
+            sourceDevices.add(new CockpitOverviewMonitoringSnapshot.SourceDevice(
+                    device.getEquipmentCode().trim(),
+                    device.getEquipmentTypeId() == null ? null : String.valueOf(device.getEquipmentTypeId()),
+                    monitoringState(device.getEquipmentCode().trim())));
+        }
+
+        LocalDateTime metricUpdatedAt = metricUpdatedAt();
+        CockpitOverviewMonitoringSnapshot.SourceMetricFreshness metricFreshness =
+                metricUpdatedAt == null ? null
+                        : new CockpitOverviewMonitoringSnapshot.SourceMetricFreshness(
+                                "CURRENT", offsetTime(metricUpdatedAt));
+
+        return new CockpitOverviewMonitoringSnapshot(
+                offsetTime(updatedAt),
+                metricFreshness,
+                sourceTypes,
+                sourceDevices,
+                monitoringPoints,
+                monitoringFacilities,
+                infrastructureFacilityCount);
+    }
+
+    private Map<String, String> pointTypes(List<MonitorPoint> points) {
+        Map<String, String> result = new HashMap<>();
+        for (MonitorPoint point : points) {
+            if (point == null || isBlank(point.getPointId())) {
+                continue;
+            }
+            Set<String> types = new LinkedHashSet<>();
+            try {
+                for (EquipmentBase device : safeList(equipmentBaseService.getEquipmentByPoint(point.getPointId()))) {
+                    if (device != null && device.getEquipmentTypeId() != null) {
+                        types.add(String.valueOf(device.getEquipmentTypeId()));
+                    }
+                }
+            } catch (RuntimeException ignored) {
+                continue;
+            }
+            if (types.size() == 1 && point.getPointCode() != null) {
+                result.put(point.getPointCode().trim(), types.iterator().next());
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 监测状态:在线/离线取自 {@code equipment_status.online_status};缺失 → null(未知),
+     * 不产生 STALE(无样本过期依据)。
+     */
+    private String monitoringState(String deviceCode) {
+        EquipmentStatus status = null;
+        try {
+            status = equipmentStatusService.getByDeviceCode(deviceCode);
+        } catch (Exception ignored) {
+            return null;
+        }
+        if (status == null || status.getOnlineStatus() == null) {
+            return null;
+        }
+        return Integer.valueOf(1).equals(status.getOnlineStatus()) ? "ONLINE" : "OFFLINE";
+    }
+
+    private LocalDateTime metricUpdatedAt() {
+        LocalDateTime latestGas = latestCreateTime(gasMonitorDataService);
+        LocalDateTime latestWater = latestCreateTime(waterMonitorDataService);
+        return latest(latestGas, latestWater);
+    }
+
+    private LocalDateTime latestCreateTime(GasMonitorDataService service) {
+        List<GasMonitorData> rows = safeList(service.list(
+                new LambdaQueryWrapper<GasMonitorData>()
+                        .orderByDesc(GasMonitorData::getCreateTime)
+                        .last("limit 1")));
+        if (rows.isEmpty() || rows.get(0).getCreateTime() == null) {
+            return null;
+        }
+        return rows.get(0).getCreateTime();
+    }
+
+    private LocalDateTime latestCreateTime(WaterMonitorDataService service) {
+        List<WaterMonitorData> rows = safeList(service.list(
+                new LambdaQueryWrapper<WaterMonitorData>()
+                        .orderByDesc(WaterMonitorData::getCreateTime)
+                        .last("limit 1")));
+        if (rows.isEmpty() || rows.get(0).getCreateTime() == null) {
+            return null;
+        }
+        return rows.get(0).getCreateTime();
+    }
+
+    private Map<Integer, EquipmentType> equipmentTypes() {
+        Map<Integer, EquipmentType> result = new HashMap<>();
+        for (EquipmentType type : safeList(equipmentTypeService.list())) {
+            if (type != null && type.getId() != null) {
+                result.put(type.getId(), type);
+            }
+        }
+        return result;
+    }
+
+    private static LocalDateTime latest(LocalDateTime current, LocalDateTime candidate) {
+        if (candidate == null) {
+            return current;
+        }
+        if (current == null || candidate.isAfter(current)) {
+            return candidate;
+        }
+        return current;
+    }
+
+    private static String offsetTime(LocalDateTime value) {
+        return value == null ? null : TIME_FORMATTER.format(value.atZone(BUSINESS_ZONE).toOffsetDateTime());
+    }
+
+    private static String trimToNull(String value) {
+        if (value == null || value.trim().isEmpty()) {
+            return null;
+        }
+        return value.trim();
+    }
+
+    private static <T> List<T> safeList(List<T> value) {
+        return value == null ? Collections.emptyList() : value.stream().filter(Objects::nonNull).collect(Collectors.toList());
+    }
+
+    private static boolean isBlank(String value) {
+        return value == null || value.trim().isEmpty();
+    }
+}

+ 283 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/BusinessCockpitOverviewWarningSettingsAdapter.java

@@ -0,0 +1,283 @@
+package com.zksy.cockpit.overview;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.zksy.base.alarm.domain.AlarmData;
+import com.zksy.base.alarm.service.AlarmDataService;
+import com.zksy.base.warning.domain.AlarmWarningRel;
+import com.zksy.base.warning.domain.EarlyWarning;
+import com.zksy.base.warning.mapper.AlarmWarningRelMapper;
+import com.zksy.base.warning.service.EarlyWarningService;
+import com.zksy.ops.domain.WorkOrder;
+import com.zksy.ops.service.WorkOrderService;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 总体概览-预警设置 真实数据适配器(BT-5)。
+ *
+ * <p>报警事件来自 {@code alarm_data}(经 {@code work_order_id → work_order.order_id} 关联工单);
+ * 预警事件来自 {@code early_warning},工单经
+ * {@code alarm_warning_rel.warning_id → alarm_data.work_order_id → work_order} 桥接(README 冻结关联)。
+ * 趋势桶按业务时区日期({@code yyyy-MM-dd})聚合,已处理 = 关联工单已结案(状态 5)。
+ * {@code updatedAt} 取事件与工单的最新时间。
+ */
+@Component
+@Primary
+public class BusinessCockpitOverviewWarningSettingsAdapter
+        implements CockpitOverviewWarningSettingsAdapter {
+
+    private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final DateTimeFormatter BUCKET_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+    private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
+    private static final int WORK_ORDER_HANDLED = 5;
+
+    private final EarlyWarningService earlyWarningService;
+    private final AlarmDataService alarmDataService;
+    private final AlarmWarningRelMapper alarmWarningRelMapper;
+    private final WorkOrderService workOrderService;
+
+    public BusinessCockpitOverviewWarningSettingsAdapter(
+            EarlyWarningService earlyWarningService,
+            AlarmDataService alarmDataService,
+            AlarmWarningRelMapper alarmWarningRelMapper,
+            WorkOrderService workOrderService) {
+        this.earlyWarningService = earlyWarningService;
+        this.alarmDataService = alarmDataService;
+        this.alarmWarningRelMapper = alarmWarningRelMapper;
+        this.workOrderService = workOrderService;
+    }
+
+    @Override
+    public CockpitOverviewWarningSettingsSnapshot load() {
+        List<EarlyWarning> warnings = safeList(earlyWarningService.list());
+        List<AlarmData> alarms = safeList(alarmDataService.list());
+        List<AlarmWarningRel> relations = safeList(alarmWarningRelMapper.selectList(new QueryWrapper<AlarmWarningRel>()));
+        List<WorkOrder> orders = safeList(workOrderService.list());
+
+        Map<Long, WorkOrder> orderByOrderId = new HashMap<>();
+        for (WorkOrder order : orders) {
+            if (order != null && order.getOrderId() != null) {
+                orderByOrderId.put(order.getOrderId(), order);
+            }
+        }
+
+        Map<String, List<String>> warningNosByAlarmId = new HashMap<>();
+        Map<String, String> warningNoById = new HashMap<>();
+        for (EarlyWarning warning : warnings) {
+            if (warning == null || isBlank(warning.getWarningId()) || isBlank(warning.getWarningNo())) {
+                continue;
+            }
+            warningNoById.put(warning.getWarningId(), warning.getWarningNo().trim());
+        }
+        for (AlarmWarningRel relation : relations) {
+            if (relation == null || isBlank(relation.getAlarmId())) {
+                continue;
+            }
+            String warningNo = warningNoById.get(relation.getWarningId());
+            if (warningNo != null) {
+                warningNosByAlarmId.computeIfAbsent(relation.getAlarmId(), key -> new ArrayList<>()).add(warningNo);
+            }
+        }
+
+        List<CockpitOverviewWarningSettingsSnapshot.SourceEvent> events = new ArrayList<>();
+        LocalDateTime updatedAt = null;
+
+        for (AlarmData alarm : alarms) {
+            if (alarm == null || isBlank(alarm.getId())) {
+                continue;
+            }
+            updatedAt = latest(updatedAt, alarm.getUpdateTime());
+            updatedAt = latest(updatedAt, alarm.getCreateTime());
+            WorkOrder order = alarm.getWorkOrderId() == null ? null : orderByOrderId.get(alarm.getWorkOrderId());
+            if (order != null) {
+                updatedAt = latest(updatedAt, toLocal(order.getUpdateTime()));
+                updatedAt = latest(updatedAt, toLocal(order.getCreateTime()));
+            }
+            events.add(new CockpitOverviewWarningSettingsSnapshot.SourceEvent(
+                    "ALARM",
+                    alarm.getId().trim(),
+                    trimToNull(alarm.getDeviceCode()),
+                    order == null ? null : order.getOrderNo(),
+                    order == null || order.getOrderStatus() == null ? null : order.getOrderStatus()));
+        }
+
+        for (EarlyWarning warning : warnings) {
+            if (warning == null || isBlank(warning.getWarningNo())) {
+                continue;
+            }
+            updatedAt = latest(updatedAt, warning.getUpdateTime());
+            updatedAt = latest(updatedAt, warning.getPublishTime());
+            List<String> linkedAlarmIds = new ArrayList<>();
+            for (AlarmWarningRel relation : relations) {
+                if (relation != null && warning.getWarningId() != null
+                        && warning.getWarningId().equals(relation.getWarningId())) {
+                    linkedAlarmIds.add(relation.getAlarmId());
+                }
+            }
+            WorkOrder order = null;
+            for (String alarmId : linkedAlarmIds) {
+                AlarmData alarm = alarms.stream()
+                        .filter(candidate -> candidate != null && alarmId != null && alarmId.equals(candidate.getId()))
+                        .findFirst().orElse(null);
+                if (alarm != null && alarm.getWorkOrderId() != null) {
+                    order = orderByOrderId.get(alarm.getWorkOrderId());
+                    if (order != null) {
+                        break;
+                    }
+                }
+            }
+            if (order != null) {
+                updatedAt = latest(updatedAt, toLocal(order.getUpdateTime()));
+                updatedAt = latest(updatedAt, toLocal(order.getCreateTime()));
+            }
+            events.add(new CockpitOverviewWarningSettingsSnapshot.SourceEvent(
+                    "WARNING",
+                    warning.getWarningNo().trim(),
+                    trimToNull(warning.getDeviceCode()),
+                    order == null ? null : order.getOrderNo(),
+                    order == null || order.getOrderStatus() == null ? null : order.getOrderStatus()));
+        }
+
+        List<CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint> trendPoints = new ArrayList<>();
+        addBucket(trendPoints, "WARNING", bucketFor(warnings, alarms, warningNosByAlarmId, orderByOrderId));
+        addBucket(trendPoints, "ALARM", bucketFor(alarms, orderByOrderId));
+
+        return new CockpitOverviewWarningSettingsSnapshot(offsetTime(updatedAt), events, trendPoints);
+    }
+
+    private Map<String, Counter> bucketFor(
+            List<EarlyWarning> warnings,
+            List<AlarmData> alarms,
+            Map<String, List<String>> warningNosByAlarmId,
+            Map<Long, WorkOrder> orderByOrderId) {
+        Map<String, Counter> buckets = new LinkedHashMap<>();
+        for (EarlyWarning warning : warnings) {
+            if (warning == null || isBlank(warning.getWarningNo())) {
+                continue;
+            }
+            LocalDateTime time = firstNonNull(warning.getPublishTime(), warning.getCreateTime());
+            if (time == null) {
+                continue;
+            }
+            Counter counter = buckets.computeIfAbsent(bucket(time), key -> new Counter());
+            counter.total++;
+            if (isHandledWarning(warning, warningNosByAlarmId, alarms, orderByOrderId)) {
+                counter.handled++;
+            }
+        }
+        return buckets;
+    }
+
+    private Map<String, Counter> bucketFor(List<AlarmData> alarms, Map<Long, WorkOrder> orderByOrderId) {
+        Map<String, Counter> buckets = new LinkedHashMap<>();
+        for (AlarmData alarm : alarms) {
+            if (alarm == null || isBlank(alarm.getId())) {
+                continue;
+            }
+            LocalDateTime time = firstNonNull(alarm.getUpdateTime(), alarm.getCreateTime());
+            if (time == null) {
+                continue;
+            }
+            Counter counter = buckets.computeIfAbsent(bucket(time), key -> new Counter());
+            counter.total++;
+            WorkOrder order = alarm.getWorkOrderId() == null ? null : orderByOrderId.get(alarm.getWorkOrderId());
+            if (order != null && WORK_ORDER_HANDLED == order.getOrderStatus()) {
+                counter.handled++;
+            }
+        }
+        return buckets;
+    }
+
+    private boolean isHandledWarning(
+            EarlyWarning warning,
+            Map<String, List<String>> warningNosByAlarmId,
+            List<AlarmData> alarms,
+            Map<Long, WorkOrder> orderByOrderId) {
+        if (warning.getWarningId() == null) {
+            return false;
+        }
+        for (AlarmData alarm : alarms) {
+            if (alarm == null || alarm.getWorkOrderId() == null) {
+                continue;
+            }
+            List<String> linked = warningNosByAlarmId.get(alarm.getId());
+            if (linked != null && linked.contains(warning.getWarningNo().trim())) {
+                WorkOrder order = orderByOrderId.get(alarm.getWorkOrderId());
+                if (order != null && WORK_ORDER_HANDLED == order.getOrderStatus()) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private void addBucket(
+            List<CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint> trendPoints,
+            String family,
+            Map<String, Counter> buckets) {
+        for (Map.Entry<String, Counter> entry : buckets.entrySet()) {
+            trendPoints.add(new CockpitOverviewWarningSettingsSnapshot.SourceTrendPoint(
+                    family, entry.getKey(), entry.getValue().total, entry.getValue().handled));
+        }
+    }
+
+    private static String bucket(LocalDateTime time) {
+        return BUCKET_FORMATTER.format(time.atZone(BUSINESS_ZONE).toLocalDate());
+    }
+
+    private static LocalDateTime firstNonNull(LocalDateTime primary, LocalDateTime fallback) {
+        return primary != null ? primary : fallback;
+    }
+
+    private static LocalDateTime toLocal(java.util.Date value) {
+        return value == null ? null
+                : LocalDateTime.ofInstant(value.toInstant(), BUSINESS_ZONE);
+    }
+
+    private static LocalDateTime latest(LocalDateTime current, LocalDateTime candidate) {
+        if (candidate == null) {
+            return current;
+        }
+        if (current == null || candidate.isAfter(current)) {
+            return candidate;
+        }
+        return current;
+    }
+
+    private static String offsetTime(LocalDateTime value) {
+        return value == null ? null : TIME_FORMATTER.format(value.atZone(BUSINESS_ZONE).toOffsetDateTime());
+    }
+
+    private static String trimToNull(String value) {
+        if (value == null || value.trim().isEmpty()) {
+            return null;
+        }
+        return value.trim();
+    }
+
+    private static <T> List<T> safeList(List<T> value) {
+        return value == null ? Collections.emptyList() : value.stream().filter(Objects::nonNull).collect(Collectors.toList());
+    }
+
+    private static boolean isBlank(String value) {
+        return value == null || value.trim().isEmpty();
+    }
+
+    private static class Counter {
+        private int total;
+        private int handled;
+    }
+}

+ 27 - 13
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/CockpitOverviewInfrastructureService.java

@@ -35,34 +35,47 @@ public class CockpitOverviewInfrastructureService {
         String updatedAt = snapshot == null || isBlank(snapshot.getUpdatedAt())
         String updatedAt = snapshot == null || isBlank(snapshot.getUpdatedAt())
                 ? serverUpdatedAt
                 ? serverUpdatedAt
                 : snapshot.getUpdatedAt();
                 : snapshot.getUpdatedAt();
-        CockpitOverviewInfrastructureResponse.Freshness freshness =
-                new CockpitOverviewInfrastructureResponse.Freshness(
-                        "CURRENT", snapshot == null ? null : snapshot.getUpdatedAt(), serverUpdatedAt);
         TotalsBuilder totals = new TotalsBuilder();
         TotalsBuilder totals = new TotalsBuilder();
         List<IndustryBuilder> industryBuilders = new ArrayList<>();
         List<IndustryBuilder> industryBuilders = new ArrayList<>();
         industryBuilders.add(new IndustryBuilder("GAS", "gas", "燃气"));
         industryBuilders.add(new IndustryBuilder("GAS", "gas", "燃气"));
         industryBuilders.add(new IndustryBuilder("WATER_SUPPLY", "waterSupply", "供水"));
         industryBuilders.add(new IndustryBuilder("WATER_SUPPLY", "waterSupply", "供水"));
         industryBuilders.add(new IndustryBuilder("DRAINAGE", "drainage", "排水"));
         industryBuilders.add(new IndustryBuilder("DRAINAGE", "drainage", "排水"));
+        industryBuilders.add(new IndustryBuilder("MANHOLE", "manhole", "窨井"));
         int unknownTypeCount = 0;
         int unknownTypeCount = 0;
         int typeKindMismatchCount = 0;
         int typeKindMismatchCount = 0;
 
 
         if (snapshot != null && snapshot.getCounts() != null) {
         if (snapshot != null && snapshot.getCounts() != null) {
-            Map<String, CockpitOverviewInfrastructureSnapshot.SourceType> types = types(snapshot);
+            Map<String, Map<String, CockpitOverviewInfrastructureSnapshot.SourceType>> types = types(snapshot);
             for (CockpitOverviewInfrastructureSnapshot.SourceCount count : snapshot.getCounts()) {
             for (CockpitOverviewInfrastructureSnapshot.SourceCount count : snapshot.getCounts()) {
                 if (count == null || isBlank(count.getTypeCode())) {
                 if (count == null || isBlank(count.getTypeCode())) {
                     continue;
                     continue;
                 }
                 }
-                CockpitOverviewInfrastructureSnapshot.SourceType type = types.get(count.getTypeCode());
+                Map<String, CockpitOverviewInfrastructureSnapshot.SourceType> byCode = types.get(count.getObjectKind());
+                CockpitOverviewInfrastructureSnapshot.SourceType type =
+                        byCode == null ? null : byCode.get(count.getTypeCode());
                 if (type == null) {
                 if (type == null) {
-                    unknownTypeCount += count.getCount();
-                } else if (!Objects.equals(count.getObjectKind(), type.getObjectKind())) {
-                    typeKindMismatchCount += count.getCount();
+                    boolean wrongKind = types.values().stream()
+                            .anyMatch(group -> group.containsKey(count.getTypeCode()));
+                    if (wrongKind) {
+                        typeKindMismatchCount += count.getCount();
+                    } else {
+                        unknownTypeCount += count.getCount();
+                    }
                 } else {
                 } else {
-                    addResolvedCount(count, type, industryBuilders, totals);
+                    if (industryBuilders.stream().noneMatch(candidate ->
+                            candidate.getCode().equals(type.getIndustry()))) {
+                        unknownTypeCount += count.getCount();
+                    } else {
+                        addResolvedCount(count, type, industryBuilders, totals);
+                    }
                 }
                 }
             }
             }
         }
         }
 
 
+        CockpitOverviewInfrastructureResponse.Freshness freshness =
+                new CockpitOverviewInfrastructureResponse.Freshness(
+                        totals.facilityCount == 0 && totals.smartDeviceCount == 0 ? "EMPTY" : "CURRENT",
+                        snapshot == null ? null : snapshot.getUpdatedAt(), serverUpdatedAt);
         return new CockpitOverviewInfrastructureResponse(
         return new CockpitOverviewInfrastructureResponse(
                 requestId,
                 requestId,
                 "v1",
                 "v1",
@@ -84,15 +97,16 @@ public class CockpitOverviewInfrastructureService {
                 businessTime());
                 businessTime());
     }
     }
 
 
-    private static Map<String, CockpitOverviewInfrastructureSnapshot.SourceType> types(
+    private static Map<String, Map<String, CockpitOverviewInfrastructureSnapshot.SourceType>> types(
             CockpitOverviewInfrastructureSnapshot snapshot) {
             CockpitOverviewInfrastructureSnapshot snapshot) {
         if (snapshot.getTypes() == null) {
         if (snapshot.getTypes() == null) {
             return Collections.emptyMap();
             return Collections.emptyMap();
         }
         }
-        Map<String, CockpitOverviewInfrastructureSnapshot.SourceType> types = new LinkedHashMap<>();
+        Map<String, Map<String, CockpitOverviewInfrastructureSnapshot.SourceType>> types = new LinkedHashMap<>();
         for (CockpitOverviewInfrastructureSnapshot.SourceType type : snapshot.getTypes()) {
         for (CockpitOverviewInfrastructureSnapshot.SourceType type : snapshot.getTypes()) {
-            if (type != null && !isBlank(type.getCode())) {
-                types.put(type.getCode(), type);
+            if (type != null && !isBlank(type.getCode()) && !isBlank(type.getObjectKind())) {
+                types.computeIfAbsent(type.getObjectKind(), key -> new LinkedHashMap<>())
+                        .put(type.getCode(), type);
             }
             }
         }
         }
         return types;
         return types;

+ 27 - 16
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/overview/CockpitOverviewMonitoringService.java

@@ -133,7 +133,7 @@ public class CockpitOverviewMonitoringService {
             String selectedIndustry,
             String selectedIndustry,
             RuntimeState currentState) {
             RuntimeState currentState) {
         CockpitOverviewMonitoringSnapshot snapshot = currentState.getSnapshot();
         CockpitOverviewMonitoringSnapshot snapshot = currentState.getSnapshot();
-        Map<String, CockpitOverviewMonitoringSnapshot.SourceType> types = types(snapshot);
+        Map<String, Map<String, CockpitOverviewMonitoringSnapshot.SourceType>> types = types(snapshot);
         List<CockpitOverviewMonitoringSnapshot.SourceDevice> selectedDevices = new ArrayList<>();
         List<CockpitOverviewMonitoringSnapshot.SourceDevice> selectedDevices = new ArrayList<>();
         Map<String, Integer> distributionCounts = new LinkedHashMap<>();
         Map<String, Integer> distributionCounts = new LinkedHashMap<>();
         Map<String, CockpitOverviewMonitoringSnapshot.SourceType> distributionTypes = new LinkedHashMap<>();
         Map<String, CockpitOverviewMonitoringSnapshot.SourceType> distributionTypes = new LinkedHashMap<>();
@@ -149,13 +149,18 @@ public class CockpitOverviewMonitoringService {
                 unknownTypeCount++;
                 unknownTypeCount++;
                 continue;
                 continue;
             }
             }
-            CockpitOverviewMonitoringSnapshot.SourceType type = types.get(device.getTypeCode());
-            if (type == null || !isFormal(type)) {
-                unknownTypeCount++;
+            CockpitOverviewMonitoringSnapshot.SourceType type = typeOf(types, "SMART_DEVICE", device.getTypeCode());
+            if (type == null) {
+                CockpitOverviewMonitoringSnapshot.SourceType other = typeOf(types, "FACILITY", device.getTypeCode());
+                if (isFormal(other)) {
+                    typeKindMismatchCount++;
+                } else {
+                    unknownTypeCount++;
+                }
                 continue;
                 continue;
             }
             }
-            if (!"SMART_DEVICE".equals(type.getObjectKind())) {
-                typeKindMismatchCount++;
+            if (!isFormal(type)) {
+                unknownTypeCount++;
                 continue;
                 continue;
             }
             }
             if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
             if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
@@ -276,7 +281,7 @@ public class CockpitOverviewMonitoringService {
             CockpitOverviewMonitoringSnapshot snapshot,
             CockpitOverviewMonitoringSnapshot snapshot,
             List<T> sources,
             List<T> sources,
             java.util.function.Function<T, String> typeCodeGetter,
             java.util.function.Function<T, String> typeCodeGetter,
-            Map<String, CockpitOverviewMonitoringSnapshot.SourceType> types,
+            Map<String, Map<String, CockpitOverviewMonitoringSnapshot.SourceType>> types,
             String selectedIndustry,
             String selectedIndustry,
             String expectedKind) {
             String expectedKind) {
         if (snapshot == null || sources == null) {
         if (snapshot == null || sources == null) {
@@ -288,11 +293,9 @@ public class CockpitOverviewMonitoringService {
                 continue;
                 continue;
             }
             }
             String typeCode = typeCodeGetter.apply(source);
             String typeCode = typeCodeGetter.apply(source);
-            CockpitOverviewMonitoringSnapshot.SourceType type = isBlank(typeCode) ? null : types.get(typeCode);
-            if (type == null) {
-                continue;
-            }
-            if (!isFormal(type) || !expectedKind.equals(type.getObjectKind())) {
+            CockpitOverviewMonitoringSnapshot.SourceType type =
+                    isBlank(typeCode) ? null : typeOf(types, expectedKind, typeCode);
+            if (!isFormal(type)) {
                 continue;
                 continue;
             }
             }
             if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
             if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
@@ -309,15 +312,23 @@ public class CockpitOverviewMonitoringService {
                 && FORMAL_INDUSTRIES.contains(type.getIndustry());
                 && FORMAL_INDUSTRIES.contains(type.getIndustry());
     }
     }
 
 
-    private static Map<String, CockpitOverviewMonitoringSnapshot.SourceType> types(
+    private static CockpitOverviewMonitoringSnapshot.SourceType typeOf(
+            Map<String, Map<String, CockpitOverviewMonitoringSnapshot.SourceType>> types,
+            String objectKind, String code) {
+        Map<String, CockpitOverviewMonitoringSnapshot.SourceType> byCode = types.get(objectKind);
+        return byCode == null ? null : byCode.get(code);
+    }
+
+    private static Map<String, Map<String, CockpitOverviewMonitoringSnapshot.SourceType>> types(
             CockpitOverviewMonitoringSnapshot snapshot) {
             CockpitOverviewMonitoringSnapshot snapshot) {
         if (snapshot == null || snapshot.getTypes() == null) {
         if (snapshot == null || snapshot.getTypes() == null) {
             return Collections.emptyMap();
             return Collections.emptyMap();
         }
         }
-        Map<String, CockpitOverviewMonitoringSnapshot.SourceType> types = new LinkedHashMap<>();
+        Map<String, Map<String, CockpitOverviewMonitoringSnapshot.SourceType>> types = new LinkedHashMap<>();
         for (CockpitOverviewMonitoringSnapshot.SourceType type : snapshot.getTypes()) {
         for (CockpitOverviewMonitoringSnapshot.SourceType type : snapshot.getTypes()) {
-            if (type != null && !isBlank(type.getCode())) {
-                types.putIfAbsent(type.getCode(), type);
+            if (type != null && !isBlank(type.getCode()) && !isBlank(type.getObjectKind())) {
+                types.computeIfAbsent(type.getObjectKind(), key -> new LinkedHashMap<>())
+                        .putIfAbsent(type.getCode(), type);
             }
             }
         }
         }
         return types;
         return types;

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/BusinessCockpitDeviceFactResolver.java

@@ -34,7 +34,7 @@ public class BusinessCockpitDeviceFactResolver {
 
 
     /** 未关闭的预警状态:现网取值含 PENDING/PROCESSING 等。 */
     /** 未关闭的预警状态:现网取值含 PENDING/PROCESSING 等。 */
     private static final Set<String> OPEN_WARNING_STATUS = new LinkedHashSet<>(
     private static final Set<String> OPEN_WARNING_STATUS = new LinkedHashSet<>(
-            Arrays.asList("PENDING", "PROCESSING", "HANDLING"));
+            Arrays.asList("PENDING", "PROCESSING", "HANDLING", "RELEASED"));
 
 
     private final EquipmentStatusService equipmentStatusService;
     private final EquipmentStatusService equipmentStatusService;
     private final EarlyWarningService earlyWarningService;
     private final EarlyWarningService earlyWarningService;

+ 19 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitMonitoringPointDetailResponse.java

@@ -1,6 +1,7 @@
 package com.zksy.cockpit.point;
 package com.zksy.cockpit.point;
 
 
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
+import com.zksy.cockpit.foundation.CockpitFreshnessStatus;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -8,6 +9,8 @@ public class CockpitMonitoringPointDetailResponse {
     private final String requestId;
     private final String requestId;
     private final String apiVersion;
     private final String apiVersion;
     private final boolean readOnly;
     private final boolean readOnly;
+    private final CockpitFreshnessStatus freshness;
+    private final String staleReason;
     private final String monitoringPointCode;
     private final String monitoringPointCode;
     private final String monitoringPointName;
     private final String monitoringPointName;
     private final CockpitMonitoringPointStatus pointStatus;
     private final CockpitMonitoringPointStatus pointStatus;
@@ -24,9 +27,23 @@ public class CockpitMonitoringPointDetailResponse {
             CockpitMonitoringPointDeviceStatistics deviceStatistics,
             CockpitMonitoringPointDeviceStatistics deviceStatistics,
             List<CockpitMonitoringPointDeviceCard> devices, CockpitCoordinateValidation coordinateValidation,
             List<CockpitMonitoringPointDeviceCard> devices, CockpitCoordinateValidation coordinateValidation,
             List<CockpitMonitoringPointStatusEntry> statusDictionary) {
             List<CockpitMonitoringPointStatusEntry> statusDictionary) {
+        this(requestId, apiVersion, readOnly, CockpitFreshnessStatus.CURRENT, null,
+                monitoringPointCode, monitoringPointName, pointStatus, statusReasons, deviceStatistics,
+                devices, coordinateValidation, statusDictionary);
+    }
+
+    public CockpitMonitoringPointDetailResponse(String requestId, String apiVersion, boolean readOnly,
+            CockpitFreshnessStatus freshness, String staleReason,
+            String monitoringPointCode, String monitoringPointName, CockpitMonitoringPointStatus pointStatus,
+            List<CockpitMonitoringPointStatusReason> statusReasons,
+            CockpitMonitoringPointDeviceStatistics deviceStatistics,
+            List<CockpitMonitoringPointDeviceCard> devices, CockpitCoordinateValidation coordinateValidation,
+            List<CockpitMonitoringPointStatusEntry> statusDictionary) {
         this.requestId = requestId;
         this.requestId = requestId;
         this.apiVersion = apiVersion;
         this.apiVersion = apiVersion;
         this.readOnly = readOnly;
         this.readOnly = readOnly;
+        this.freshness = freshness;
+        this.staleReason = staleReason;
         this.monitoringPointCode = monitoringPointCode;
         this.monitoringPointCode = monitoringPointCode;
         this.monitoringPointName = monitoringPointName;
         this.monitoringPointName = monitoringPointName;
         this.pointStatus = pointStatus;
         this.pointStatus = pointStatus;
@@ -41,6 +58,8 @@ public class CockpitMonitoringPointDetailResponse {
     public String getRequestId() { return requestId; }
     public String getRequestId() { return requestId; }
     public String getApiVersion() { return apiVersion; }
     public String getApiVersion() { return apiVersion; }
     public boolean isReadOnly() { return readOnly; }
     public boolean isReadOnly() { return readOnly; }
+    public CockpitFreshnessStatus getFreshness() { return freshness; }
+    public String getStaleReason() { return staleReason; }
     public String getMonitoringPointCode() { return monitoringPointCode; }
     public String getMonitoringPointCode() { return monitoringPointCode; }
     public String getMonitoringPointName() { return monitoringPointName; }
     public String getMonitoringPointName() { return monitoringPointName; }
     public CockpitMonitoringPointStatus getPointStatus() { return pointStatus; }
     public CockpitMonitoringPointStatus getPointStatus() { return pointStatus; }

+ 155 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitMonitoringPointDetailService.java

@@ -4,40 +4,81 @@ import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
+import com.zksy.cockpit.foundation.CockpitFreshnessStatus;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import com.zksy.cockpit.foundation.CockpitSnapshotTime;
+import com.zksy.cockpit.map.CockpitMapSnapshot;
+import com.zksy.cockpit.map.CockpitMapSnapshotAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.time.Clock;
 import java.time.Clock;
+import java.time.DateTimeException;
 import java.time.ZoneId;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 @Service
 @Service
 public class CockpitMonitoringPointDetailService {
 public class CockpitMonitoringPointDetailService {
     private final CockpitMonitoringPointDetailAdapter adapter;
     private final CockpitMonitoringPointDetailAdapter adapter;
+    private final CockpitMapSnapshotAdapter mapSnapshotAdapter;
     private final Clock clock;
     private final Clock clock;
 
 
     public CockpitMonitoringPointDetailService(CockpitMonitoringPointDetailAdapter adapter, Clock clock) {
     public CockpitMonitoringPointDetailService(CockpitMonitoringPointDetailAdapter adapter, Clock clock) {
+        this(adapter, null, clock);
+    }
+
+    @Autowired
+    public CockpitMonitoringPointDetailService(CockpitMonitoringPointDetailAdapter adapter,
+            CockpitMapSnapshotAdapter mapSnapshotAdapter, Clock clock) {
         this.adapter = adapter;
         this.adapter = adapter;
+        this.mapSnapshotAdapter = mapSnapshotAdapter;
         this.clock = clock;
         this.clock = clock;
     }
     }
 
 
     public CockpitMonitoringPointDetailResponse load(String requestId, String monitoringPointCode) {
     public CockpitMonitoringPointDetailResponse load(String requestId, String monitoringPointCode) {
+        return load(requestId, monitoringPointCode, null);
+    }
+
+    /**
+     * 加载监测点详情。
+     *
+     * <p>传入 {@code snapshotAt}(且装配了 {@link CockpitMapSnapshotAdapter})时走跨端点同快照路径:
+     * 从与 {@code map-snapshot} 同一适配器的同一份快照中按点位编码取设备集合,保证同一
+     * {@code snapshotAt} 下详情 {@code devices[]} 与地图对应点位 {@code deviceCodes} 同源一致
+     * (含离线设备,不重复、不静默丢失)。未传 {@code snapshotAt} 时回退到原详情适配器路径。
+     */
+    public CockpitMonitoringPointDetailResponse load(String requestId, String monitoringPointCode,
+            String snapshotAt) {
         if (isBlank(monitoringPointCode)) {
         if (isBlank(monitoringPointCode)) {
-            throw new CockpitInvalidRequestException("monitoring point code is required");
+            throw new CockpitInvalidRequestException("监测点编码不能为空");
+        }
+        String normalizedCode = monitoringPointCode.trim();
+        if (snapshotAt != null) {
+            validateSnapshotAt(snapshotAt);
+        }
+        CockpitMonitoringPointDetail detail;
+        if (snapshotAt != null) {
+            if (mapSnapshotAdapter == null) {
+                throw new CockpitSnapshotExpiredException("snapshot source unavailable");
+            }
+            detail = loadFromSnapshot(normalizedCode, snapshotAt);
+        } else {
+            detail = adapter.load(normalizedCode);
         }
         }
-        CockpitMonitoringPointDetail detail = adapter.load(monitoringPointCode.trim());
         if (detail == null) {
         if (detail == null) {
             throw new CockpitMonitoringPointNotFoundException("monitoring point not found");
             throw new CockpitMonitoringPointNotFoundException("monitoring point not found");
         }
         }
 
 
-        List<CockpitMonitoringPointDeviceSnapshot> devices = detail.getDevices() == null
-                ? Collections.emptyList()
-                : detail.getDevices();
+        List<CockpitMonitoringPointDeviceSnapshot> devices = normalizeDevices(detail.getDevices());
         CockpitMonitoringPointStatus pointStatus =
         CockpitMonitoringPointStatus pointStatus =
                 CockpitMonitoringPointStatusResolver.resolve(devices);
                 CockpitMonitoringPointStatusResolver.resolve(devices);
         CockpitCoordinateValidation coordinateValidation = CockpitCoordinateValidator.validate(
         CockpitCoordinateValidation coordinateValidation = CockpitCoordinateValidator.validate(
@@ -47,6 +88,8 @@ public class CockpitMonitoringPointDetailService {
                 requestId,
                 requestId,
                 "v1",
                 "v1",
                 true,
                 true,
+                CockpitFreshnessStatus.CURRENT,
+                isBlank(snapshotAt) ? "BEST_EFFORT_SOURCE" : null,
                 detail.getMonitoringPointCode(),
                 detail.getMonitoringPointCode(),
                 detail.getMonitoringPointName(),
                 detail.getMonitoringPointName(),
                 pointStatus,
                 pointStatus,
@@ -57,6 +100,37 @@ public class CockpitMonitoringPointDetailService {
                 statusDictionary());
                 statusDictionary());
     }
     }
 
 
+    private CockpitMonitoringPointDetail loadFromSnapshot(String monitoringPointCode, String snapshotAt) {
+        CockpitMapSnapshot snapshot = mapSnapshotAdapter.load(snapshotAt);
+        if (snapshot == null) {
+            throw new CockpitSnapshotExpiredException("snapshot not found");
+        }
+        if (snapshot.getSnapshotAt() == null) {
+            throw new CockpitSnapshotExpiredException("snapshot timestamp missing");
+        }
+        if (!snapshotAt.equals(snapshot.getSnapshotAt())) {
+            throw new CockpitSnapshotExpiredException("snapshot timestamp changed");
+        }
+        List<CockpitMapSnapshot.SourceMonitoringPoint> points = snapshot.getMonitoringPoints() == null
+                ? Collections.emptyList()
+                : snapshot.getMonitoringPoints();
+        for (CockpitMapSnapshot.SourceMonitoringPoint point : points) {
+            if (point == null) {
+                continue;
+            }
+            if (monitoringPointCode.equals(trimToNull(point.getPointCode()))) {
+                return new CockpitMonitoringPointDetail(
+                        point.getPointCode(),
+                        point.getPointName(),
+                        point.getLongitude(),
+                        point.getLatitude(),
+                        point.isCoordinateVerified(),
+                        point.getDevices() == null ? Collections.emptyList() : point.getDevices());
+            }
+        }
+        return null;
+    }
+
     public CockpitErrorPayload invalidRequest(String requestId) {
     public CockpitErrorPayload invalidRequest(String requestId) {
         return new CockpitErrorPayload(
         return new CockpitErrorPayload(
                 CockpitErrorCategory.INVALID_REQUEST,
                 CockpitErrorCategory.INVALID_REQUEST,
@@ -65,6 +139,14 @@ public class CockpitMonitoringPointDetailService {
                 businessTime());
                 businessTime());
     }
     }
 
 
+    public CockpitErrorPayload invalidRequest(String requestId, String message) {
+        return new CockpitErrorPayload(
+                CockpitErrorCategory.INVALID_REQUEST,
+                isBlank(message) ? "监测点编码不能为空" : message,
+                requestId,
+                businessTime());
+    }
+
     public CockpitErrorPayload invalidCode(String requestId) {
     public CockpitErrorPayload invalidCode(String requestId) {
         return new CockpitErrorPayload(
         return new CockpitErrorPayload(
                 CockpitErrorCategory.INVALID_REQUEST,
                 CockpitErrorCategory.INVALID_REQUEST,
@@ -89,16 +171,84 @@ public class CockpitMonitoringPointDetailService {
                 businessTime());
                 businessTime());
     }
     }
 
 
+    public CockpitErrorPayload snapshotExpired(String requestId) {
+        return new CockpitErrorPayload(
+                CockpitErrorCategory.SNAPSHOT_EXPIRED,
+                "监测点详情快照已过期,请刷新后重试",
+                requestId,
+                businessTime());
+    }
+
     private static List<CockpitMonitoringPointStatusEntry> statusDictionary() {
     private static List<CockpitMonitoringPointStatusEntry> statusDictionary() {
         return Arrays.stream(CockpitMonitoringPointStatus.values())
         return Arrays.stream(CockpitMonitoringPointStatus.values())
                 .map(CockpitMonitoringPointStatusEntry::new)
                 .map(CockpitMonitoringPointStatusEntry::new)
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
     }
     }
 
 
+    /**
+     * 与 map-snapshot 的 deviceCodes 构造保持同一规范化口径:滤 null/空码、trim、
+     * 按首次出现去重。保证同一 snapshotAt 下详情 devices[].deviceCode 与地图
+     * monitoringPoints[].deviceCodes 集合一致(含离线设备、不重复、不静默丢失)。
+     */
+    private static List<CockpitMonitoringPointDeviceSnapshot> normalizeDevices(
+            List<CockpitMonitoringPointDeviceSnapshot> devices) {
+        if (devices == null) {
+            return Collections.emptyList();
+        }
+        Map<String, CockpitMonitoringPointDeviceSnapshot> byCode = new LinkedHashMap<>();
+        for (CockpitMonitoringPointDeviceSnapshot device : devices) {
+            if (device == null) {
+                continue;
+            }
+            String code = trimToNull(device.getDeviceCode());
+            if (code == null) {
+                continue;
+            }
+            byCode.putIfAbsent(code, canonicalDevice(device, code));
+        }
+        return new ArrayList<>(byCode.values());
+    }
+
+    private static CockpitMonitoringPointDeviceSnapshot canonicalDevice(
+            CockpitMonitoringPointDeviceSnapshot device, String code) {
+        return new CockpitMonitoringPointDeviceSnapshot(
+                code,
+                device.getDeviceName(),
+                device.getDeviceTypeName(),
+                device.getLongitude(),
+                device.getLatitude(),
+                device.getCoordinateValidation(),
+                device.isOnline(),
+                device.isAlarm(),
+                device.isWarning(),
+                device.isWorkOrderInProgress(),
+                device.getStatusReasons(),
+                device.getStatusTime());
+    }
+
+    /**
+     * 与 map-snapshot 对齐:snapshotAt 必须是可解析的带偏移 ISO-8601 时间戳,
+     * 否则按无效请求(INVALID_REQUEST 400)拒绝,避免畸形时间戳落入 404/200。
+     */
+    private static void validateSnapshotAt(String snapshotAt) {
+        if (snapshotAt == null) {
+            return;
+        }
+        try {
+            CockpitSnapshotTime.parseBusinessOffset(snapshotAt);
+        } catch (DateTimeException exception) {
+            throw new CockpitInvalidRequestException("监测点快照参数不合法");
+        }
+    }
+
     private static boolean isBlank(String value) {
     private static boolean isBlank(String value) {
         return value == null || value.trim().isEmpty();
         return value == null || value.trim().isEmpty();
     }
     }
 
 
+    private static String trimToNull(String value) {
+        return isBlank(value) ? null : value.trim();
+    }
+
     private String businessTime() {
     private String businessTime() {
         return DateTimeFormatter.ISO_OFFSET_DATE_TIME
         return DateTimeFormatter.ISO_OFFSET_DATE_TIME
                 .format(clock.instant().atZone(ZoneId.of("Asia/Shanghai")));
                 .format(clock.instant().atZone(ZoneId.of("Asia/Shanghai")));

+ 2 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/BusinessCockpitWorkOrderReadAdapter.java

@@ -149,7 +149,8 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
     }
     }
 
 
     private CockpitWorkOrderTimelineEntry toTimelineEntry(WorkOrder order, WorkOrderLogVO log) {
     private CockpitWorkOrderTimelineEntry toTimelineEntry(WorkOrder order, WorkOrderLogVO log) {
-        CockpitWorkOrderState state = CockpitWorkOrderStateDictionary.byLegacyCode(log.getOperType());
+        CockpitWorkOrderState state = CockpitWorkOrderStateDictionary.byOperationCode(
+                log.getOperType(), order.getOrderStatus());
         return new CockpitWorkOrderTimelineEntry(
         return new CockpitWorkOrderTimelineEntry(
                 log.getLogId(),
                 log.getLogId(),
                 order.getOrderNo(),
                 order.getOrderNo(),

+ 21 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/CockpitWorkOrderStateDictionary.java

@@ -44,6 +44,27 @@ public final class CockpitWorkOrderStateDictionary {
         return code == null ? null : BY_CODE.get(code);
         return code == null ? null : BY_CODE.get(code);
     }
     }
 
 
+    /** 将工单操作日志操作码映射为操作完成后的当前运行时状态。 */
+    public static CockpitWorkOrderState byOperationCode(Integer operationCode, Integer currentStateCode) {
+        if (operationCode == null) {
+            return byCode(currentStateCode);
+        }
+        switch (operationCode) {
+            case 0: return byCode(0); // 创建:待派单
+            case 1: return byCode(1); // 派单:待接单
+            case 2: return byCode(2); // 接单:已接单
+            case 3: return byCode(3); // 处置:处理中
+            case 4: return byCode(4); // 提交验收:待验收
+            case 5: return byCode(5); // 验收通过:已结案
+            case 6: return byCode(3); // 验收驳回:回到处理中
+            case 7: return byCode(7); // 取消:已取消
+            case 8: return byCode(3); // 申请延期:仍在处理中
+            case 9: return byCode(6); // 延期通过:延期中
+            case 10: return byCode(3); // 延期驳回:回到处理中
+            default: return byCode(currentStateCode);
+        }
+    }
+
     /**
     /**
      * 迁移期兼容:把旧编码(1 待派单 … 6 已结案、7 已取消)转换到运行时 0–7 编码。
      * 迁移期兼容:把旧编码(1 待派单 … 6 已结案、7 已取消)转换到运行时 0–7 编码。
      * 旧 1–6 映射到新 0–5(旧 6 已结案 → 新 5 已结案);旧 7 已取消 → 新 7 已取消;
      * 旧 1–6 映射到新 0–5(旧 6 已结案 → 新 5 已结案);旧 7 已取消 → 新 7 已取消;

+ 38 - 21
pipe-network-service/zksy-system/src/test/java/com/zksy/base/service/impl/MonitoringServiceImplTest.java

@@ -82,7 +82,8 @@ class MonitoringServiceImplTest {
                 type(1, "供水", 0),
                 type(1, "供水", 0),
                 type(11, "供水流量计", 1),
                 type(11, "供水流量计", 1),
                 type(12, "供水压力计", 1),
                 type(12, "供水压力计", 1),
-                type(13, "供水漏失监测器", 1)
+                type(13, "供水漏失监测器", 1),
+                type(14, "消火栓压力监测终端", 1)
         ));
         ));
         when(radarDataMapper.selectList(any())).thenReturn(Collections.emptyList());
         when(radarDataMapper.selectList(any())).thenReturn(Collections.emptyList());
         when(telemetryDataMapper.selectList(any())).thenReturn(Collections.emptyList());
         when(telemetryDataMapper.selectList(any())).thenReturn(Collections.emptyList());
@@ -161,7 +162,7 @@ class MonitoringServiceImplTest {
     }
     }
 
 
     @Test
     @Test
-    void leakagePaginationExcludesDevicesWithoutQualifyingMeasurements() {
+    void leakagePaginationKeepsUnmeasuredDevicesWhenNoMeasurementFilterIsApplied() {
         when(equipmentBaseMapper.selectList(any())).thenReturn(Arrays.asList(
         when(equipmentBaseMapper.selectList(any())).thenReturn(Arrays.asList(
                 device("leakage-1", "WS-LK-1", "漏失监测点1", "13", BASE_TIME),
                 device("leakage-1", "WS-LK-1", "漏失监测点1", "13", BASE_TIME),
                 device("leakage-2", "WS-LK-2", "漏失监测点2", "13", BASE_TIME.minusMinutes(1))
                 device("leakage-2", "WS-LK-2", "漏失监测点2", "13", BASE_TIME.minusMinutes(1))
@@ -173,36 +174,52 @@ class MonitoringServiceImplTest {
         Page<LeakageMonitoringVO> page = service.getLeakageMonitorPage(
         Page<LeakageMonitoringVO> page = service.getLeakageMonitorPage(
                 1, 10, null, null, null, null, null, null, null);
                 1, 10, null, null, null, null, null, null, null);
 
 
-        assertEquals(1, page.getTotal());
-        assertEquals(1, page.getRecords().size());
+        assertEquals(2, page.getTotal());
+        assertEquals(2, page.getRecords().size());
         assertEquals("leakage-1", page.getRecords().get(0).getEquipmentId());
         assertEquals("leakage-1", page.getRecords().get(0).getEquipmentId());
         assertEquals(12D, page.getRecords().get(0).getPower());
         assertEquals(12D, page.getRecords().get(0).getPower());
         assertEquals(BASE_TIME, page.getRecords().get(0).getMonitorTime());
         assertEquals(BASE_TIME, page.getRecords().get(0).getMonitorTime());
+        assertEquals("leakage-2", page.getRecords().get(1).getEquipmentId());
+        assertEquals(null, page.getRecords().get(1).getPower());
+        assertEquals(null, page.getRecords().get(1).getMonitorTime());
+
+        Page<LeakageMonitoringVO> filtered = service.getLeakageMonitorPage(
+                1, 10, null, null, null, null, null, 10D, null);
+        assertEquals(1, filtered.getTotal());
+        assertEquals("leakage-1", filtered.getRecords().get(0).getEquipmentId());
     }
     }
 
 
     @Test
     @Test
-    void monitoringPagesReturnAnEmptyPageWhenThereIsNoMeasurementData() {
-        when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
-                device("flow-empty", "WS-FLOW-EMPTY", "无数据监测点", "11", BASE_TIME)
-        ));
-
+    void monitoringPagesKeepFourWaterDevicesInTheirTypesWithoutMeasurements() {
+        when(equipmentBaseMapper.selectList(any())).thenAnswer(invocation -> {
+            LambdaQueryWrapper<EquipmentBase> wrapper = invocation.getArgument(0);
+            Set<Object> allowedTypeIds = flattenWrapperValues(wrapper);
+            return Arrays.asList(
+                    device("flow", "TEST-FLOW", "测试流量计", "11", BASE_TIME),
+                    device("pressure", "TEST-PRESSURE", "测试压力计", "12", BASE_TIME),
+                    device("leakage", "TEST-LEAK", "测试漏失监测01", "13", BASE_TIME),
+                    device("hydrant", "TEST-HYDRANT", "测试消火栓", "14", BASE_TIME),
+                    device("drainage", "DRAIN-FLOW", "排水流量计", "17", BASE_TIME)
+            ).stream().filter(device -> allowedTypeIds.contains(device.getEquipmentTypeId()))
+                    .collect(Collectors.toList());
+        });
         Page<FlowMonitoringVO> flow = service.getFlowMonitorPage(1, 10, null, null, null, null, null, null, null);
         Page<FlowMonitoringVO> flow = service.getFlowMonitorPage(1, 10, null, null, null, null, null, null, null);
-        assertEquals(0, flow.getTotal());
-        assertTrue(flow.getRecords().isEmpty());
+        assertEquals(1, flow.getTotal());
+        assertEquals("测试流量计", flow.getRecords().get(0).getEquipmentName());
+        assertEquals(null, flow.getRecords().get(0).getInstantFlow());
+        assertEquals(null, flow.getRecords().get(0).getMonitorTime());
 
 
-        when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
-                device("pressure-empty", "WS-PR-EMPTY", "无数据监测点", "12", BASE_TIME)
-        ));
         Page<PressureMonitoringVO> pressure = service.getPressureMonitorPage(1, 10, null, null, null, null, null, null, null);
         Page<PressureMonitoringVO> pressure = service.getPressureMonitorPage(1, 10, null, null, null, null, null, null, null);
-        assertEquals(0, pressure.getTotal());
-        assertTrue(pressure.getRecords().isEmpty());
+        assertEquals(2, pressure.getTotal());
+        assertEquals(Set.of("测试压力计", "测试消火栓"), pressure.getRecords().stream()
+                .map(PressureMonitoringVO::getEquipmentName).collect(Collectors.toSet()));
+        assertTrue(pressure.getRecords().stream().allMatch(row -> row.getPressureValue() == null && row.getMonitorTime() == null));
 
 
-        when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
-                device("leakage-empty", "WS-LK-EMPTY", "无数据监测点", "13", BASE_TIME)
-        ));
         Page<LeakageMonitoringVO> leakage = service.getLeakageMonitorPage(1, 10, null, null, null, null, null, null, null);
         Page<LeakageMonitoringVO> leakage = service.getLeakageMonitorPage(1, 10, null, null, null, null, null, null, null);
-        assertEquals(0, leakage.getTotal());
-        assertTrue(leakage.getRecords().isEmpty());
+        assertEquals(1, leakage.getTotal());
+        assertEquals("测试漏失监测01", leakage.getRecords().get(0).getEquipmentName());
+        assertEquals(null, leakage.getRecords().get(0).getPower());
+        assertEquals(null, leakage.getRecords().get(0).getMonitorTime());
     }
     }
 
 
     @Test
     @Test

+ 2 - 4
zk-api-service/src/main/java/com/zksy/api/mapper/DeviceContactApiMapper.java

@@ -5,13 +5,11 @@ import org.apache.ibatis.annotations.Select;
 import java.util.List;
 import java.util.List;
 
 
 public interface DeviceContactApiMapper {
 public interface DeviceContactApiMapper {
-    /** 台账编码先关联设备主键,沿用维护人员和状态负责人的联系人来源。 */
+    /** 按台账编码查询维护记录联系人和台账负责人电话,状态表不存储负责人。 */
     @Select("SELECT m.maintain_person_phone FROM app_user.equipment_base b "
     @Select("SELECT m.maintain_person_phone FROM app_user.equipment_base b "
             + "JOIN app_user.equipment_maintain m ON m.equipment_id = b.equipment_id "
             + "JOIN app_user.equipment_maintain m ON m.equipment_id = b.equipment_id "
             + "WHERE b.equipment_code = #{deviceCode} "
             + "WHERE b.equipment_code = #{deviceCode} "
-            + "UNION SELECT u.phonenumber FROM app_user.equipment_base b "
-            + "JOIN app_user.equipment_status s ON s.equipment_id = b.equipment_id AND s.del_flag = '0' "
-            + "JOIN app_user.sys_user u ON u.user_id = s.user_id AND u.del_flag = '0' "
+            + "UNION SELECT b.maintainer_phone FROM app_user.equipment_base b "
             + "WHERE b.equipment_code = #{deviceCode}")
             + "WHERE b.equipment_code = #{deviceCode}")
     List<String> selectPhonesByDeviceCode(@Param("deviceCode") String deviceCode);
     List<String> selectPhonesByDeviceCode(@Param("deviceCode") String deviceCode);
 }
 }