Browse Source

Merge remote-tracking branch 'origin/master'

zengy 1 week ago
parent
commit
3990814f99
16 changed files with 1770 additions and 125 deletions
  1. 4 0
      AGENTS.md
  2. 36 0
      docs/agents/cockpit-controller-standard.md
  3. 3 2
      docs/cockpit/README.md
  4. 8 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitExceptionAdvice.java
  5. 48 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMapDisplayController.java
  6. 0 119
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitContractDictionaryTest.java
  7. 2 2
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityGeometryControllerTest.java
  8. 71 1
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityGeometryServiceTest.java
  9. 110 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMapDisplayControllerTest.java
  10. 321 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMapDisplayResponse.java
  11. 580 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMapDisplayService.java
  12. 197 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMemberCursor.java
  13. 1 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitErrorCategory.java
  14. 8 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitMemberCursorExpiredException.java
  15. 120 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/geometry/CockpitFacilityGeometryService.java
  16. 261 0
      pipe-network-service/zksy-system/src/test/java/com/zksy/cockpit/display/CockpitMapDisplayServiceTest.java

+ 4 - 0
AGENTS.md

@@ -14,6 +14,10 @@ Use the five default triage labels. See `docs/agents/triage-labels.md`.
 
 
 Use the multi-context layout. See `docs/agents/domain.md`.
 Use the multi-context layout. See `docs/agents/domain.md`.
 
 
+## 后端开发
+
+**涉及后端开发时先读** [`docs/agents/cockpit-controller-standard.md`](docs/agents/cockpit-controller-standard.md):驾驶舱接口变更必须遵守其 Controller 聚合、薄控制器与少建类规则;其他后端改动也遵守按功能聚合、无必要不拆类的原则,同时保持既有分层职责。
+
 ## SQL 变更
 ## SQL 变更
 
 
 **增量脚本与回滚脚本成对入 `sql/`。** 涉及数据库结构或数据改动的迭代,在 `sql/` 提交
 **增量脚本与回滚脚本成对入 `sql/`。** 涉及数据库结构或数据改动的迭代,在 `sql/` 提交

+ 36 - 0
docs/agents/cockpit-controller-standard.md

@@ -0,0 +1,36 @@
+# 驾驶舱后端 Controller 约定
+
+本约定以 `pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/` 当前格式为准;最近一次结构整理见提交 `9a092d0a`(删除无引用代码、提炼类级路由前缀)和 `d9b5431e`(按功能合并 Controller、提炼公共基类与异常出口)。新增或修改驾驶舱后端接口时必须遵守。
+
+## 类的组织
+
+- 按业务功能组织 Controller:同一功能的一组相关端点放在同一个功能类中,例如概览、地图、设备、事件、基础设施、监测、工单、视频。
+- 为新增端点先检查本目录现有 Controller;属于已有功能的端点直接加到对应类,不按端点数量拆类,也不复制已有功能类。
+- 只有职责确实独立、无法清晰归入现有功能类时才新建 Controller。新增前确认没有等价接口或已删除的重复实现,并在改动说明中写清独立边界。
+- 共享工具只放在 `BaseCockpitController`;统一错误映射只放在 `CockpitExceptionAdvice`。不要为单个端点新建纯转发类、工具类或重复的异常出口。
+- “同一功能尽量一个文件”针对同一职责的 Controller 端点聚合;不得为减少文件数把业务计算、数据库访问或事务流程塞进 Controller。业务逻辑留在现有 Service/领域层;只有存在独立职责、复用边界、事务边界或可验证契约时,才新增类。
+
+## Controller 结构
+
+- 包名使用 `com.zksy.web.controller.cockpit`,类名使用 `Cockpit<功能>Controller`。
+- 驾驶舱功能 Controller 使用 `@RestController` 和类级 `@RequestMapping("/api/cockpit/v1")`;方法映射只写功能后缀,如 `@GetMapping("/events/current")`。
+- 通过构造器注入依赖,依赖字段声明为 `private final`。沿用当前 Spring MVC、`ResponseEntity<AjaxResult>` 和 `AjaxResult.success(...)` 响应形式,除非接口契约明确要求不同 HTTP 状态或响应结构。
+- Controller 负责绑定和轻量规范化 HTTP 输入、调用 Service、包装响应;不直接写 SQL、访问 Mapper/Repository、编排业务事务或实现领域计算。
+- 驾驶舱接口通常透传可选 `X-Request-Id`,经 `resolveRequestId` 传给 Service;路径段需要解码时复用 `decodePathSegment`。新增行为先检查基类是否已有对应能力,不复制实现。
+
+## 校验与错误
+
+- 请求校验使用已有类型化异常,并交由 `CockpitExceptionAdvice` 转成统一错误响应;不在每个方法里捕获异常后手工拼接错误 JSON。
+- `@ExceptionHandler` 留在统一 Advice。仅当某个既有端点契约必须返回其专属错误载荷且不能由统一 Advice 表达时,才允许局部处理;需说明原因并复用该端点既有错误工厂。显示聚合端点已迁入统一 Advice(票 10),不再作为局部处理先例。
+- 只有确有专属请求约束时才在 Controller 做轻量校验;字段、授权范围、业务状态和数据完整性由相应 Service/领域层负责。
+
+## 修改前检查
+
+1. 先读本目录中功能最接近的 Controller、`BaseCockpitController`、`CockpitExceptionAdvice`。
+2. 搜索路由与调用方,确认不是重复接口;确认同功能端点应落入哪个现有类。
+3. 检查是否已有 Service、DTO、异常和公共工具可复用;只有满足上面的新建条件才加类。
+4. 修改后运行对应 `zksy-admin` 测试;涉及路由时验证映射与现有响应契约,避免意外改变 URL、HTTP 状态、请求 ID 或错误载荷。
+
+## 现存差异
+
+本目录存在格式不完全一致的历史代码:部分 Controller 使用通配 import 或长参数单行;视频端点覆盖请求 ID 解析并返回 201/202。新增代码以本约定和共享基类/Advice 为准;修改旧端点时只在任务涉及范围内逐步贴齐,不为纯格式统一做无关重写,不改变既有 API 契约。

+ 3 - 2
docs/cockpit/README.md

@@ -49,7 +49,7 @@
 
 
 | 用途 | 端点 |
 | 用途 | 端点 |
 | --- | --- |
 | --- | --- |
-| 地图分页快照(**地图取数路径**) | `GET /api/cockpit/v1/map/snapshot?page&pageSize&snapshotAt&industry&district&deviceType` |
+| 地图分页快照(**地图取数路径**) | `GET /api/cockpit/v1/map-snapshot?page&pageSize&snapshotAt&industry&district&deviceType` |
 | 监测点详情 | `GET /api/cockpit/v1/monitoring-points/{monitoringPointCode}?snapshotAt` |
 | 监测点详情 | `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` |
@@ -58,7 +58,7 @@
 | 工单时间线 | `GET /api/cockpit/v1/work-orders/{workOrderCode}/timeline` |
 | 工单时间线 | `GET /api/cockpit/v1/work-orders/{workOrderCode}/timeline` |
 | 设备详情聚合 | `GET /api/cockpit/v1/equipments/{deviceCode}/detail-aggregate` |
 | 设备详情聚合 | `GET /api/cockpit/v1/equipments/{deviceCode}/detail-aggregate` |
 | 新鲜度 | `GET /api/cockpit/v1/equipments/{deviceCode}/freshness` |
 | 新鲜度 | `GET /api/cockpit/v1/equipments/{deviceCode}/freshness` |
-| 契约自检 | `GET /api/cockpit/v1/map/foundation`、`GET /api/cockpit/v1/device-boundary` |
+| 契约自检 | `GET /api/cockpit/v1/foundation`、`GET /api/cockpit/v1/device-boundary` |
 
 
 ### 地图筛选路径(冻结结论)
 ### 地图筛选路径(冻结结论)
 
 
@@ -69,6 +69,7 @@
 - 服务端完成过滤,并在响应 `mapFilter{industry,district,districtName,districtFilter,deviceType,pointCodes,deviceCodes}` 回显**实际生效范围**(编码为过滤后全量、分页前,升序)。
 - 服务端完成过滤,并在响应 `mapFilter{industry,district,districtName,districtFilter,deviceType,pointCodes,deviceCodes}` 回显**实际生效范围**(编码为过滤后全量、分页前,升序)。
 - **`snapshotAt` 回显(执行票 62 补齐)**:`monitoring/distribution` 的 `data.snapshotAt` 回显本次响应依据的快照标记,与 `map-snapshot` 同形同义。该端点 `page > 1` 时**必须**带非空 `snapshotAt`(不带即 400 `INVALID_REQUEST`「监测分布分页参数不合法」)——此前响应不回显该值,调用方只能自己找时间戳猜,跨页对齐无从保证;现在第 1 页取回什么、后续页就原样回带什么。`page = 1` 可不带(后端据此开新快照)。
 - **`snapshotAt` 回显(执行票 62 补齐)**:`monitoring/distribution` 的 `data.snapshotAt` 回显本次响应依据的快照标记,与 `map-snapshot` 同形同义。该端点 `page > 1` 时**必须**带非空 `snapshotAt`(不带即 400 `INVALID_REQUEST`「监测分布分页参数不合法」)——此前响应不回显该值,调用方只能自己找时间戳猜,跨页对齐无从保证;现在第 1 页取回什么、后续页就原样回带什么。`page = 1` 可不带(后端据此开新快照)。
 - `coordinateValidation` 汇总是**当前筛选范围内的全量口径**(再切片分页);逐点/逐设备保留 `renderable=false` 的对象。
 - `coordinateValidation` 汇总是**当前筛选范围内的全量口径**(再切片分页);逐点/逐设备保留 `renderable=false` 的对象。
+- **显示聚合桶(票 06/07)**:`GET /api/cockpit/v1/map-display-buckets` 与 `/map-display-bucket-members`。响应 `statusVersion` / `statusSource=SNAPSHOT` 说明桶内状态摘要绑定哪份快照;WS 状态推送后调用方必须按受影响类别回退本地或等新 `statusVersion`,不能用同一快照的旧摘要覆盖刚推来的状态。设施无坐标源时该类别如实 `UNAVAILABLE`,不借设备/点位坐标。
 - 逐点 `industry` 由类型推导(口径同 distribution:类型可解析、`objectKind = SMART_DEVICE`、行业属正式行业);不可推导时为 `null`,**默认不排除对象**,仅在请求了 `industry`/`deviceType` 过滤时按推导结果筛选。
 - 逐点 `industry` 由类型推导(口径同 distribution:类型可解析、`objectKind = SMART_DEVICE`、行业属正式行业);不可推导时为 `null`,**默认不排除对象**,仅在请求了 `industry`/`deviceType` 过滤时按推导结果筛选。
 
 
 ### 片区(district)契约(执行票 12,2026-10-08)
 ### 片区(district)契约(执行票 12,2026-10-08)

+ 8 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitExceptionAdvice.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.CockpitInvalidCodeException;
 import com.zksy.cockpit.foundation.CockpitInvalidCodeException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitMemberCursorExpiredException;
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
 import com.zksy.cockpit.foundation.CockpitMonitoringPointNotFoundException;
@@ -64,6 +65,13 @@ public class CockpitExceptionAdvice {
         return error(HttpStatus.BAD_REQUEST, CockpitErrorCategory.SNAPSHOT_EXPIRED, exception.getMessage(), request);
         return error(HttpStatus.BAD_REQUEST, CockpitErrorCategory.SNAPSHOT_EXPIRED, exception.getMessage(), request);
     }
     }
 
 
+    @ExceptionHandler(CockpitMemberCursorExpiredException.class)
+    public ResponseEntity<AjaxResult> memberCursorExpired(CockpitMemberCursorExpiredException exception,
+            HttpServletRequest request) {
+        return error(HttpStatus.BAD_REQUEST, CockpitErrorCategory.MEMBER_CURSOR_EXPIRED,
+                exception.getMessage(), request);
+    }
+
     @ExceptionHandler({CockpitDeviceNotFoundException.class, CockpitEntityNotFoundException.class, CockpitMonitoringPointNotFoundException.class})
     @ExceptionHandler({CockpitDeviceNotFoundException.class, CockpitEntityNotFoundException.class, CockpitMonitoringPointNotFoundException.class})
     public ResponseEntity<AjaxResult> notFound(RuntimeException exception, HttpServletRequest request) {
     public ResponseEntity<AjaxResult> notFound(RuntimeException exception, HttpServletRequest request) {
         return error(HttpStatus.NOT_FOUND, CockpitErrorCategory.NOT_FOUND, exception.getMessage(), request);
         return error(HttpStatus.NOT_FOUND, CockpitErrorCategory.NOT_FOUND, exception.getMessage(), request);

+ 48 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMapDisplayController.java

@@ -0,0 +1,48 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.display.CockpitMapDisplayResponse;
+import com.zksy.cockpit.display.CockpitMapDisplayService;
+import com.zksy.common.core.domain.AjaxResult;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api/cockpit/v1")
+public class CockpitMapDisplayController extends BaseCockpitController {
+    private final CockpitMapDisplayService displayService;
+
+    public CockpitMapDisplayController(CockpitMapDisplayService displayService) {
+        this.displayService = displayService;
+    }
+
+    @GetMapping("/map-display-buckets")
+    public ResponseEntity<AjaxResult> buckets(
+            @RequestParam(value = "bbox", required = false) String bbox,
+            @RequestParam(value = "zoomBand", required = false) Integer zoomBand,
+            @RequestParam(value = "snapshotAt", required = false) String snapshotAt,
+            @RequestParam(value = "industry", required = false) String industry,
+            @RequestParam(value = "district", required = false) String district,
+            @RequestParam(value = "deviceType", required = false) String deviceType,
+            @RequestParam(value = "pointStatus", required = false) String[] pointStatus,
+            @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
+        CockpitMapDisplayResponse response = displayService.buckets(resolveRequestId(requestId),
+                bbox, zoomBand, snapshotAt, industry, district, deviceType,
+                pointStatus == null ? null : String.join(",", pointStatus));
+        return ResponseEntity.ok(AjaxResult.success(response));
+    }
+
+    @GetMapping("/map-display-bucket-members")
+    public ResponseEntity<AjaxResult> members(
+            @RequestParam(value = "cursor", required = false) String cursor,
+            @RequestParam(value = "search", required = false) String search,
+            @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
+            @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
+        CockpitMapDisplayResponse.Members response = displayService.members(resolveRequestId(requestId),
+                cursor, search, pageSize);
+        return ResponseEntity.ok(AjaxResult.success(response));
+    }
+}

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

@@ -1,119 +0,0 @@
-package com.zksy.web.controller.cockpit;
-
-import com.zksy.cockpit.event.CockpitEventLevelColor;
-import com.zksy.cockpit.foundation.CockpitErrorCategory;
-import com.zksy.cockpit.foundation.CockpitFreshnessStatus;
-import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
-import com.zksy.cockpit.workorder.CockpitWorkOrderState;
-import com.zksy.cockpit.workorder.CockpitWorkOrderStateDictionary;
-import org.junit.jupiter.api.Test;
-
-import java.lang.reflect.Method;
-import java.time.Clock;
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.util.Arrays;
-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.assertTrue;
-
-/**
- * Freezes the shared dictionaries and cross-cutting rules the cockpit contract
- * depends on, so a handoff to the front-end / UE team has an executable baseline.
- */
-class CockpitContractDictionaryTest {
-
-    private static final String COCKPIT_PACKAGE = "com.zksy.web.controller.cockpit.";
-
-    @Test
-    void workOrderDictionaryMatchesRuntimeZeroToSevenStatesWithoutDeprecatedStates() {
-        List<CockpitWorkOrderState> states = CockpitWorkOrderStateDictionary.states();
-        assertEquals(8, states.size());
-        assertEquals(
-                Arrays.asList("待派单", "待接单", "已接单", "处理中", "待验收", "已结案", "延期中", "已取消"),
-                states.stream().map(CockpitWorkOrderState::getName).collect(Collectors.toList()));
-        assertEquals(0, CockpitWorkOrderStateDictionary.byCode(0).getCode());
-        assertEquals(7, CockpitWorkOrderStateDictionary.byCode(7).getCode());
-        // Legacy codes map onto the same 0-7 baseline instead of a ninth state.
-        assertEquals(0, CockpitWorkOrderStateDictionary.byLegacyCode(1).getCode());
-        assertEquals(5, CockpitWorkOrderStateDictionary.byLegacyCode(6).getCode());
-        assertEquals(7, CockpitWorkOrderStateDictionary.byLegacyCode(7).getCode());
-        assertEquals(7, CockpitWorkOrderStateDictionary.byLegacyCode(99).getCode());
-    }
-
-    @Test
-    void levelColourDictionaryIsOneRedTwoYellowThreeBlueFourGreen() {
-        assertEquals("RED", CockpitEventLevelColor.resolve(1));
-        assertEquals("YELLOW", CockpitEventLevelColor.resolve(2));
-        assertEquals("BLUE", CockpitEventLevelColor.resolve(3));
-        assertEquals("GREEN", CockpitEventLevelColor.resolve(4));
-        assertEquals("UNKNOWN", CockpitEventLevelColor.resolve(9));
-        // 字典编码入口(字符串)与归一化入口(Integer)同词表
-        assertEquals("RED", CockpitEventLevelColor.resolve("1"));
-        assertEquals("GREEN", CockpitEventLevelColor.resolve("4"));
-        assertEquals("UNKNOWN", CockpitEventLevelColor.resolve("9"));
-        assertEquals("UNKNOWN", CockpitEventLevelColor.resolve((Integer) null));
-        assertEquals("UNKNOWN", CockpitEventLevelColor.resolve((String) null));
-    }
-
-    @Test
-    void monitoringPointStatusDictionaryKeepsSixStatesInPrecedenceOrder() {
-        List<CockpitMonitoringPointStatus> statuses =
-                Arrays.asList(CockpitMonitoringPointStatus.values());
-        assertEquals(
-                Arrays.asList("ALARM", "WARNING", "WORK_ORDER", "NORMAL", "OFFLINE", "EMPTY"),
-                statuses.stream().map(Enum::name).collect(Collectors.toList()));
-        assertEquals(1, CockpitMonitoringPointStatus.ALARM.getPriority());
-        assertEquals(6, CockpitMonitoringPointStatus.EMPTY.getPriority());
-    }
-
-    @Test
-    void freshnessAndErrorCategoriesAreFrozen() {
-        assertEquals(
-                Arrays.asList("CURRENT", "STALE", "EXPIRED", "EMPTY", "FAILED"),
-                Arrays.stream(CockpitFreshnessStatus.values()).map(Enum::name).collect(Collectors.toList()));
-        assertEquals(
-                Arrays.asList("UNAUTHORIZED", "SERVER_ERROR", "INVALID_REQUEST", "SNAPSHOT_EXPIRED", "NOT_FOUND"),
-                Arrays.stream(CockpitErrorCategory.values()).map(Enum::name).collect(Collectors.toList()));
-    }
-
-    @Test
-    void everyCockpitControllerBindingIsAnExplicitlyNamedGet() throws Exception {
-        Class<?>[] controllers = {
-                CockpitMapController.class,
-                CockpitMonitoringController.class,
-                CockpitEquipmentController.class,
-                CockpitWorkOrderController.class,
-                CockpitInfrastructureController.class,
-                CockpitEventController.class,
-                CockpitOverviewController.class
-        };
-        for (Class<?> controller : controllers) {
-            assertTrue(controller.getName().startsWith(COCKPIT_PACKAGE)
-                            || controller.getName().startsWith("com.zksy.web.controller.cockpit"),
-                    controller + " must live in the cockpit controller package");
-            for (Method method : controller.getDeclaredMethods()) {
-                if (method.isAnnotationPresent(org.springframework.web.bind.annotation.GetMapping.class)) {
-                    String[] values = method
-                            .getAnnotation(org.springframework.web.bind.annotation.GetMapping.class).value();
-                    assertTrue(values.length == 1 && !values[0].trim().isEmpty(),
-                            controller.getSimpleName() + "#" + method.getName()
-                                    + " must declare an explicit path");
-                    assertFalse(method.isAnnotationPresent(
-                                    org.springframework.web.bind.annotation.PostMapping.class),
-                            controller.getSimpleName() + "#" + method.getName()
-                                    + " must not expose a mutation mapping");
-                }
-            }
-        }
-    }
-
-    @Test
-    void cockpitClockIsInjectibleSoEverySliceSharesOneTimezoneBoundary() {
-        Clock clock = Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC);
-        assertEquals(Instant.parse("2026-09-02T02:00:00Z"), clock.instant());
-    }
-}

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

@@ -67,7 +67,7 @@ class CockpitFacilityGeometryControllerTest {
                 .andExpect(jsonPath("$.code").value(200))
                 .andExpect(jsonPath("$.code").value(200))
                 .andExpect(jsonPath("$.data.type").value("FeatureCollection"))
                 .andExpect(jsonPath("$.data.type").value("FeatureCollection"))
                 .andExpect(jsonPath("$.data.features", hasSize(0)))
                 .andExpect(jsonPath("$.data.features", hasSize(0)))
-                .andExpect(jsonPath("$.data.coverage", hasSize(9)))
+                .andExpect(jsonPath("$.data.coverage", hasSize(17)))
                 .andExpect(jsonPath("$.data.coverage[4].state").value("UNAVAILABLE"));
                 .andExpect(jsonPath("$.data.coverage[4].state").value("UNAVAILABLE"));
     }
     }
 
 
@@ -151,7 +151,7 @@ class CockpitFacilityGeometryControllerTest {
                 .andExpect(jsonPath("$.data.features[1].geometry.coordinates[0]").value(110.440))
                 .andExpect(jsonPath("$.data.features[1].geometry.coordinates[0]").value(110.440))
                 .andExpect(jsonPath("$.data.features[1].geometry.coordinates[1]").value(28.450))
                 .andExpect(jsonPath("$.data.features[1].geometry.coordinates[1]").value(28.450))
                 .andExpect(jsonPath("$.data.features[1].properties.industry").value("MANHOLE"))
                 .andExpect(jsonPath("$.data.features[1].properties.industry").value("MANHOLE"))
-                .andExpect(jsonPath("$.data.features[1].properties.networkId").value("gas-line"))
+                .andExpect(jsonPath("$.data.features[1].properties.networkId").value(nullValue()))
                 // 2026-10-12 契约:区内坐标自动准入 → VALID/可上图。
                 // 2026-10-12 契约:区内坐标自动准入 → VALID/可上图。
                 .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.state").value("VALID"))
                 .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.state").value("VALID"))
                 .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.renderable").value(true));
                 .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.renderable").value(true));

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

@@ -4,6 +4,20 @@ import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.watersupply.domain.PumpStationInfo;
+import com.zksy.watersupply.domain.WaterFireHydrantInfo;
+import com.zksy.watersupply.domain.WaterPlantInfo;
+import com.zksy.watersupply.domain.WaterSourceInfo;
+import com.zksy.watersupply.domain.WaterUserInfo;
+import com.zksy.watersupply.service.IPumpStationInfoService;
+import com.zksy.watersupply.service.IWaterFireHydrantInfoService;
+import com.zksy.watersupply.service.IWaterPlantInfoService;
+import com.zksy.watersupply.service.IWaterSourceInfoService;
+import com.zksy.watersupply.service.IWaterUserInfoService;
+import com.zksy.drainage.domain.DrainageGateInfo;
+import com.zksy.drainage.domain.DrainageStorageInfo;
+import com.zksy.drainage.service.DrainageGateInfoService;
+import com.zksy.drainage.service.DrainageStorageInfoService;
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.foundation.CockpitReadException;
 import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse;
 import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse;
 import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Coverage;
 import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Coverage;
@@ -249,7 +263,7 @@ class CockpitFacilityGeometryServiceTest {
     void emptySourcesAreDistinguishedFromUnsupportedIndustryGeometry() {
     void emptySourcesAreDistinguishedFromUnsupportedIndustryGeometry() {
         CockpitFacilityGeometryResponse response = service.load();
         CockpitFacilityGeometryResponse response = service.load();
         assertTrue(response.getFeatures().isEmpty());
         assertTrue(response.getFeatures().isEmpty());
-        assertEquals("EMPTY", coverage(response, "GAS", "Point").getState());
+        assertEquals("UNAVAILABLE", coverage(response, "GAS", "Point").getState());
         assertEquals("EMPTY", coverage(response, "WATER_SUPPLY", "LineString").getState());
         assertEquals("EMPTY", coverage(response, "WATER_SUPPLY", "LineString").getState());
         assertEquals("TWO_ENDPOINTS_ONLY", coverage(response, "WATER_SUPPLY", "LineString").getReason());
         assertEquals("TWO_ENDPOINTS_ONLY", coverage(response, "WATER_SUPPLY", "LineString").getReason());
         assertEquals("UNAVAILABLE", coverage(response, "WATER_SUPPLY", "Point").getState());
         assertEquals("UNAVAILABLE", coverage(response, "WATER_SUPPLY", "Point").getState());
@@ -273,6 +287,62 @@ class CockpitFacilityGeometryServiceTest {
         assertThrows(CockpitReadException.class, service::load);
         assertThrows(CockpitReadException.class, service::load);
     }
     }
 
 
+
+    @Test
+    void exposesAllFacilityPointTypesFromTheSingleGeometryEndpoint() {
+        IWaterPlantInfoService plants = mock(IWaterPlantInfoService.class);
+        IPumpStationInfoService stations = mock(IPumpStationInfoService.class);
+        IWaterSourceInfoService sources = mock(IWaterSourceInfoService.class);
+        IWaterUserInfoService users = mock(IWaterUserInfoService.class);
+        IWaterFireHydrantInfoService hydrants = mock(IWaterFireHydrantInfoService.class);
+        DrainageGateInfoService gates = mock(DrainageGateInfoService.class);
+        DrainageStorageInfoService storages = mock(DrainageStorageInfoService.class);
+
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setId("plant-1"); plant.setPlantCode("WP-1"); plant.setPlantName("水厂");
+        plant.setLongitude(new BigDecimal("110.44")); plant.setLatitude(new BigDecimal("28.45"));
+        PumpStationInfo pump = new PumpStationInfo();
+        pump.setId("pump-1"); pump.setStationCode("PS-1"); pump.setStationName("泵站");
+        pump.setStationType("0"); pump.setLongitude(new BigDecimal("110.45")); pump.setLatitude(new BigDecimal("28.46"));
+        WaterSourceInfo source = new WaterSourceInfo();
+        source.setId("source-1"); source.setSourceId("WS-1"); source.setSourceName("水源地");
+        source.setLongitude(new BigDecimal("110.46")); source.setLatitude(new BigDecimal("28.47"));
+        WaterUserInfo user = new WaterUserInfo();
+        user.setId("user-1"); user.setUserCode("WU-1"); user.setUserName("用水户");
+        user.setLongitude(new BigDecimal("110.47")); user.setLatitude(new BigDecimal("28.48"));
+        WaterFireHydrantInfo hydrant = new WaterFireHydrantInfo();
+        hydrant.setHydrantId("hydrant-1"); hydrant.setHydrantCode("WH-1"); hydrant.setHydrantName("消火栓");
+        hydrant.setLongitude(new BigDecimal("110.48")); hydrant.setLatitude(new BigDecimal("28.49"));
+        DrainageGateInfo gate = new DrainageGateInfo();
+        gate.setFacilityId("gate-1"); gate.setFacilityCode("DG-1"); gate.setFacilityName("闸门");
+        gate.setLongitude(new BigDecimal("110.49")); gate.setLatitude(new BigDecimal("28.50"));
+        DrainageStorageInfo storage = new DrainageStorageInfo();
+        storage.setFacilityId("storage-1"); storage.setFacilityCode("DS-1"); storage.setFacilityName("调蓄");
+        storage.setLongitude(new BigDecimal("110.50")); storage.setLatitude(new BigDecimal("28.51"));
+
+        when(plants.list()).thenReturn(Collections.singletonList(plant));
+        when(stations.list()).thenReturn(Collections.singletonList(pump));
+        when(sources.list()).thenReturn(Collections.singletonList(source));
+        when(users.list()).thenReturn(Collections.singletonList(user));
+        when(hydrants.list()).thenReturn(Collections.singletonList(hydrant));
+        when(gates.list()).thenReturn(Collections.singletonList(gate));
+        when(storages.list()).thenReturn(Collections.singletonList(storage));
+
+        CockpitFacilityGeometryService facilityService = new CockpitFacilityGeometryService(
+                networks, manholes, plants, stations, sources, users, hydrants, gates, storages,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC));
+        CockpitFacilityGeometryResponse response = facilityService.load();
+        List<String> types = response.getFeatures().stream()
+                .map(item -> item.getProperties().getTypeCode()).collect(Collectors.toList());
+        assertTrue(types.containsAll(Arrays.asList("WATER_PLANT", "PUMP_STATION", "WATER_SOURCE",
+                "WATER_USER", "WATER_FIRE_HYDRANT", "DRAINAGE_GATE", "DRAINAGE_STORAGE")));
+        assertEquals("Point", response.getFeatures().get(0).getGeometry().getType());
+        assertEquals("plant-1", response.getFeatures().get(0).getProperties().getSourceId());
+        assertEquals("WATER_SUPPLY", response.getFeatures().get(0).getProperties().getIndustry());
+        assertEquals("VALID", response.getFeatures().get(0).getProperties().getCoordinateValidation().getState());
+        assertTrue(coverage(response, "WATER_SUPPLY", "Point") != null);
+    }
+
     private static Coverage coverage(CockpitFacilityGeometryResponse response, String industry, String geometry) {
     private static Coverage coverage(CockpitFacilityGeometryResponse response, String industry, String geometry) {
         return response.getCoverage().stream().filter(item -> industry.equals(item.getIndustry())
         return response.getCoverage().stream().filter(item -> industry.equals(item.getIndustry())
                 && geometry.equals(item.getGeometryType())).findFirst().orElseThrow();
                 && geometry.equals(item.getGeometryType())).findFirst().orElseThrow();

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

@@ -0,0 +1,110 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.display.CockpitMapDisplayResponse;
+import com.zksy.cockpit.display.CockpitMapDisplayService;
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitMemberCursorExpiredException;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.util.Collections;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+class CockpitMapDisplayControllerTest {
+    private static final String SNAPSHOT = "2026-11-25T10:00:00+08:00";
+    private static final Clock CLOCK = Clock.fixed(
+            Instant.parse("2026-11-25T02:00:00Z"), ZoneOffset.ofHours(8));
+
+    private CockpitMapDisplayService service;
+    private MockMvc mockMvc;
+
+    @BeforeEach
+    void setUp() {
+        service = mock(CockpitMapDisplayService.class);
+        mockMvc = MockMvcBuilders.standaloneSetup(new CockpitMapDisplayController(service))
+                .setControllerAdvice(new CockpitExceptionAdvice(CLOCK))
+                .build();
+    }
+
+    @Test
+    void classLevelRouteKeepsBucketsUrlAndPayload() throws Exception {
+        when(service.buckets(anyString(), anyString(), any(), any(), any(), any(), any(), any()))
+                .thenReturn(response());
+        mockMvc.perform(get("/api/cockpit/v1/map-display-buckets")
+                        .header("X-Request-Id", "display-request-001")
+                        .param("bbox", "110.39,28.43,110.4,28.44")
+                        .param("zoomBand", "4"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(200))
+                .andExpect(jsonPath("$.data.requestId").value("display-request-001"))
+                .andExpect(jsonPath("$.data.contract").value("display-buckets-v1"))
+                .andExpect(jsonPath("$.data.statusVersion").value(SNAPSHOT));
+    }
+
+    @Test
+    void invalidRequestUsesUnifiedAdvice() throws Exception {
+        when(service.buckets(anyString(), anyString(), any(), any(), any(), any(), any(), any()))
+                .thenThrow(new CockpitInvalidRequestException("bbox 格式不合法"));
+        mockMvc.perform(get("/api/cockpit/v1/map-display-buckets")
+                        .header("X-Request-Id", "display-request-002")
+                        .param("bbox", "bad")
+                        .param("zoomBand", "4"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
+                .andExpect(jsonPath("$.data.message").value("bbox 格式不合法"))
+                .andExpect(jsonPath("$.data.requestId").value("display-request-002"));
+    }
+
+    @Test
+    void cursorExpiredUsesUnifiedAdvice() throws Exception {
+        when(service.members(anyString(), anyString(), any(), any()))
+                .thenThrow(new CockpitMemberCursorExpiredException("成员游标已失效,请重新加载聚合桶"));
+        mockMvc.perform(get("/api/cockpit/v1/map-display-bucket-members")
+                        .header("X-Request-Id", "display-request-003")
+                        .param("cursor", "expired"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.data.category").value("MEMBER_CURSOR_EXPIRED"))
+                .andExpect(jsonPath("$.data.message").value("成员游标已失效,请重新加载聚合桶"));
+    }
+
+    @Test
+    void snapshotExpiredAndReadFailureKeepExistingCategories() throws Exception {
+        when(service.buckets(anyString(), anyString(), any(), any(), any(), any(), any(), any()))
+                .thenThrow(new CockpitSnapshotExpiredException("地图快照已失效,请重新加载"));
+        mockMvc.perform(get("/api/cockpit/v1/map-display-buckets")
+                        .param("bbox", "110.39,28.43,110.4,28.44")
+                        .param("zoomBand", "4"))
+                .andExpect(status().isBadRequest())
+                .andExpect(jsonPath("$.data.category").value("SNAPSHOT_EXPIRED"))
+                .andExpect(jsonPath("$.data.message").value("地图快照已失效,请重新加载"));
+
+        when(service.members(anyString(), anyString(), any(), any()))
+                .thenThrow(new CockpitReadException("显示聚合数据暂不可用"));
+        mockMvc.perform(get("/api/cockpit/v1/map-display-bucket-members")
+                        .param("cursor", "c"))
+                .andExpect(status().isInternalServerError())
+                .andExpect(jsonPath("$.data.category").value("SERVER_ERROR"))
+                .andExpect(jsonPath("$.data.message").value("显示聚合数据暂不可用"));
+    }
+
+    private static CockpitMapDisplayResponse response() {
+        return new CockpitMapDisplayResponse("display-request-001", SNAPSHOT, SNAPSHOT, 4,
+                "110.39,28.43,110.4,28.44", 1000, false,
+                new CockpitMapDisplayResponse.Filters(null, null, null, "NONE", null, null),
+                Collections.emptyList());
+    }
+}

+ 321 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMapDisplayResponse.java

@@ -0,0 +1,321 @@
+package com.zksy.cockpit.display;
+
+import java.util.List;
+
+/**
+ * 驾驶舱显示聚合桶与成员页的显式契约。
+ *
+ * <p>桶只带汇总与游标,不带完整成员数组;成员按游标分页读取,避免把全量点位/设备/设施塞进一次响应。
+ * 设施与设备/监测点各自独立:某类覆盖不足时该类 {@code coverage} 明确降级,不拿其它类补齐。
+ */
+public class CockpitMapDisplayResponse {
+    public static final String CONTRACT = "display-buckets-v1";
+    public static final String MEMBER_CONTRACT = "display-members-v1";
+
+    private final String requestId;
+    private final String apiVersion;
+    private final String contract;
+    private final boolean readOnly;
+    private final boolean partial;
+    private final String snapshotAt;
+    private final String statusVersion;
+    private final String statusSource;
+    private final int zoomBand;
+    private final String bbox;
+    private final int cellMeters;
+    private final Filters filters;
+    private final List<ClassBuckets> classes;
+
+    public CockpitMapDisplayResponse(String requestId, String snapshotAt, String statusVersion, int zoomBand,
+            String bbox, int cellMeters, boolean partial, Filters filters, List<ClassBuckets> classes) {
+        this.requestId = requestId;
+        this.apiVersion = "v1";
+        this.contract = CONTRACT;
+        this.readOnly = true;
+        this.partial = partial;
+        this.snapshotAt = snapshotAt;
+        this.statusVersion = statusVersion;
+        this.statusSource = "SNAPSHOT";
+        this.zoomBand = zoomBand;
+        this.bbox = bbox;
+        this.cellMeters = cellMeters;
+        this.filters = filters;
+        this.classes = classes;
+    }
+
+    public String getRequestId() { return requestId; }
+    public String getApiVersion() { return apiVersion; }
+    public String getContract() { return contract; }
+    public boolean isReadOnly() { return readOnly; }
+    public boolean isPartial() { return partial; }
+    public String getSnapshotAt() { return snapshotAt; }
+    public String getStatusVersion() { return statusVersion; }
+    public String getStatusSource() { return statusSource; }
+    public int getZoomBand() { return zoomBand; }
+    public String getBbox() { return bbox; }
+    public int getCellMeters() { return cellMeters; }
+    public Filters getFilters() { return filters; }
+    public List<ClassBuckets> getClasses() { return classes; }
+
+    public static class Filters {
+        private final String industry;
+        private final Integer district;
+        private final String districtName;
+        private final String districtFilter;
+        private final String deviceType;
+        private final String pointStatus;
+
+        public Filters(String industry, Integer district, String districtName, String districtFilter,
+                String deviceType, String pointStatus) {
+            this.industry = industry;
+            this.district = district;
+            this.districtName = districtName;
+            this.districtFilter = districtFilter;
+            this.deviceType = deviceType;
+            this.pointStatus = pointStatus;
+        }
+
+        public String getIndustry() { return industry; }
+        public Integer getDistrict() { return district; }
+        public String getDistrictName() { return districtName; }
+        public String getDistrictFilter() { return districtFilter; }
+        public String getDeviceType() { return deviceType; }
+        public String getPointStatus() { return pointStatus; }
+    }
+
+    public static class ClassBuckets {
+        private final String kind;
+        private final Coverage coverage;
+        private final List<Bucket> buckets;
+
+        public ClassBuckets(String kind, Coverage coverage, List<Bucket> buckets) {
+            this.kind = kind;
+            this.coverage = coverage;
+            this.buckets = buckets;
+        }
+
+        public String getKind() { return kind; }
+        public Coverage getCoverage() { return coverage; }
+        public List<Bucket> getBuckets() { return buckets; }
+    }
+
+    public static class Coverage {
+        private final String state;
+        private final String reason;
+        private final String version;
+        private final int total;
+        private final int mapped;
+
+        public Coverage(String state, String reason, String version, int total, int mapped) {
+            this.state = state;
+            this.reason = reason;
+            this.version = version;
+            this.total = total;
+            this.mapped = mapped;
+        }
+
+        public String getState() { return state; }
+        public String getReason() { return reason; }
+        public String getVersion() { return version; }
+        public int getTotal() { return total; }
+        public int getMapped() { return mapped; }
+    }
+
+    public static class Bucket {
+        private final String groupKey;
+        private final String kind;
+        private final int memberCount;
+        private final StatusSummary statusSummary;
+        private final Bounds bounds;
+        private final Anchor anchor;
+        private final String memberCursor;
+
+        public Bucket(String groupKey, String kind, int memberCount, StatusSummary statusSummary,
+                Bounds bounds, Anchor anchor, String memberCursor) {
+            this.groupKey = groupKey;
+            this.kind = kind;
+            this.memberCount = memberCount;
+            this.statusSummary = statusSummary;
+            this.bounds = bounds;
+            this.anchor = anchor;
+            this.memberCursor = memberCursor;
+        }
+
+        public String getGroupKey() { return groupKey; }
+        public String getKind() { return kind; }
+        public int getMemberCount() { return memberCount; }
+        public StatusSummary getStatusSummary() { return statusSummary; }
+        public Bounds getBounds() { return bounds; }
+        public Anchor getAnchor() { return anchor; }
+        public String getMemberCursor() { return memberCursor; }
+    }
+
+    public static class StatusSummary {
+        private final String primaryStatus;
+        private final String primaryLabel;
+        private final int primaryCount;
+        private final int abnormalCount;
+        private final int otherAbnormalCount;
+        private final List<StatusCount> counts;
+
+        public StatusSummary(String primaryStatus, String primaryLabel, int primaryCount,
+                int abnormalCount, int otherAbnormalCount, List<StatusCount> counts) {
+            this.primaryStatus = primaryStatus;
+            this.primaryLabel = primaryLabel;
+            this.primaryCount = primaryCount;
+            this.abnormalCount = abnormalCount;
+            this.otherAbnormalCount = otherAbnormalCount;
+            this.counts = counts;
+        }
+
+        public String getPrimaryStatus() { return primaryStatus; }
+        public String getPrimaryLabel() { return primaryLabel; }
+        public int getPrimaryCount() { return primaryCount; }
+        public int getAbnormalCount() { return abnormalCount; }
+        public int getOtherAbnormalCount() { return otherAbnormalCount; }
+        public List<StatusCount> getCounts() { return counts; }
+    }
+
+    public static class StatusCount {
+        private final String status;
+        private final String label;
+        private final int count;
+
+        public StatusCount(String status, String label, int count) {
+            this.status = status;
+            this.label = label;
+            this.count = count;
+        }
+
+        public String getStatus() { return status; }
+        public String getLabel() { return label; }
+        public int getCount() { return count; }
+    }
+
+    public static class Bounds {
+        private final double west;
+        private final double south;
+        private final double east;
+        private final double north;
+
+        public Bounds(double west, double south, double east, double north) {
+            this.west = west;
+            this.south = south;
+            this.east = east;
+            this.north = north;
+        }
+
+        public double getWest() { return west; }
+        public double getSouth() { return south; }
+        public double getEast() { return east; }
+        public double getNorth() { return north; }
+    }
+
+    public static class Anchor {
+        private final double longitude;
+        private final double latitude;
+
+        public Anchor(double longitude, double latitude) {
+            this.longitude = longitude;
+            this.latitude = latitude;
+        }
+
+        public double getLongitude() { return longitude; }
+        public double getLatitude() { return latitude; }
+    }
+
+    public static class Members {
+        private final String requestId;
+        private final String apiVersion;
+        private final String contract;
+        private final boolean readOnly;
+        private final String snapshotAt;
+        private final String kind;
+        private final String groupKey;
+        private final String search;
+        private final int offset;
+        private final int pageSize;
+        private final int total;
+        private final List<Member> items;
+        private final String nextCursor;
+
+        public Members(String requestId, String snapshotAt, String kind, String groupKey, String search,
+                int offset, int pageSize, int total, List<Member> items, String nextCursor) {
+            this.requestId = requestId;
+            this.apiVersion = "v1";
+            this.contract = MEMBER_CONTRACT;
+            this.readOnly = true;
+            this.snapshotAt = snapshotAt;
+            this.kind = kind;
+            this.groupKey = groupKey;
+            this.search = search;
+            this.offset = offset;
+            this.pageSize = pageSize;
+            this.total = total;
+            this.items = items;
+            this.nextCursor = nextCursor;
+        }
+
+        public String getRequestId() { return requestId; }
+        public String getApiVersion() { return apiVersion; }
+        public String getContract() { return contract; }
+        public boolean isReadOnly() { return readOnly; }
+        public String getSnapshotAt() { return snapshotAt; }
+        public String getKind() { return kind; }
+        public String getGroupKey() { return groupKey; }
+        public String getSearch() { return search; }
+        public int getOffset() { return offset; }
+        public int getPageSize() { return pageSize; }
+        public int getTotal() { return total; }
+        public List<Member> getItems() { return items; }
+        public String getNextCursor() { return nextCursor; }
+    }
+
+    public static class Member {
+        private final String kind;
+        private final String code;
+        private final String name;
+        private final String status;
+        private final String statusLabel;
+        private final int priority;
+        private final double longitude;
+        private final double latitude;
+        private final String industry;
+        private final String typeCode;
+        private final String typeName;
+        private final Integer district;
+        private final String districtName;
+
+        public Member(String kind, String code, String name, String status, String statusLabel, int priority,
+                double longitude, double latitude, String industry, String typeCode, String typeName,
+                Integer district, String districtName) {
+            this.kind = kind;
+            this.code = code;
+            this.name = name;
+            this.status = status;
+            this.statusLabel = statusLabel;
+            this.priority = priority;
+            this.longitude = longitude;
+            this.latitude = latitude;
+            this.industry = industry;
+            this.typeCode = typeCode;
+            this.typeName = typeName;
+            this.district = district;
+            this.districtName = districtName;
+        }
+
+        public String getKind() { return kind; }
+        public String getCode() { return code; }
+        public String getName() { return name; }
+        public String getStatus() { return status; }
+        public String getStatusLabel() { return statusLabel; }
+        public int getPriority() { return priority; }
+        public double getLongitude() { return longitude; }
+        public double getLatitude() { return latitude; }
+        public String getIndustry() { return industry; }
+        public String getTypeCode() { return typeCode; }
+        public String getTypeName() { return typeName; }
+        public Integer getDistrict() { return district; }
+        public String getDistrictName() { return districtName; }
+    }
+}

+ 580 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMapDisplayService.java

@@ -0,0 +1,580 @@
+package com.zksy.cockpit.display;
+
+import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
+import com.zksy.cockpit.foundation.CockpitErrorCategory;
+import com.zksy.cockpit.foundation.CockpitErrorPayload;
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationAdapter;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationSnapshot;
+import com.zksy.cockpit.map.CockpitMapSnapshotResponse;
+import com.zksy.cockpit.map.CockpitMapSnapshotService;
+import com.zksy.cockpit.map.CockpitMonitoringPointSummary;
+import com.zksy.cockpit.map.CockpitUnassociatedEquipmentSummary;
+import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.time.Clock;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * 服务端显示聚合:按 bbox + zoomBand 把点位/设备落到稳定地理桶,成员用游标分页。
+ *
+ * <p>地理桶的 groupKey 只由类别、缩放档、格坐标决定;同一快照下可复用、可验证,不依赖前端投影矩阵。
+ *
+ * <p>设施运营快照只有设施身份/状态,没有坐标;不能拿设备或点位坐标补齐。
+ * 因此设施类返回 UNAVAILABLE + reason + 来源版本,调用方保留既有设施图层,而不是假装完整。
+ */
+@Service
+public class CockpitMapDisplayService {
+    public static final String KIND_EQUIPMENT = "UNASSOCIATED_EQUIPMENT";
+    public static final String KIND_POINT = "MONITORING_POINT";
+    public static final String KIND_FACILITY = "FACILITY_POINT";
+
+    private static final int SNAPSHOT_PAGE_SIZE = 1000;
+    private static final int MAX_SNAPSHOT_PAGES = 1000;
+    private static final int DEFAULT_MEMBER_PAGE_SIZE = 20;
+    private static final int MAX_MEMBER_PAGE_SIZE = 100;
+    private static final int DEFAULT_CURSOR_TTL_SECONDS = 600;
+    private static final double MAX_BBOX_SPAN_DEGREES = 2.0;
+    private static final double METERS_PER_DEGREE = 111320.0;
+    private static final double[] CELL_METERS = new double[] {
+            50000, 20000, 8000, 3000, 1000, 300, 100, 30, 10
+    };
+    private static final Map<String, Integer> DEVICE_PRIORITY = new HashMap<>();
+    private static final Map<String, String> DEVICE_LABEL = new HashMap<>();
+    static {
+        DEVICE_PRIORITY.put("ALARM", 1);
+        DEVICE_PRIORITY.put("WORK_ORDER", 2);
+        DEVICE_PRIORITY.put("WARNING", 3);
+        DEVICE_PRIORITY.put("NORMAL", 4);
+        DEVICE_PRIORITY.put("OFFLINE", 5);
+        DEVICE_PRIORITY.put("UNKNOWN", 6);
+        DEVICE_LABEL.put("ALARM", "报警");
+        DEVICE_LABEL.put("WORK_ORDER", "工单处置");
+        DEVICE_LABEL.put("WARNING", "预警");
+        DEVICE_LABEL.put("NORMAL", "正常");
+        DEVICE_LABEL.put("OFFLINE", "离线");
+        DEVICE_LABEL.put("UNKNOWN", "状态未发布");
+
+    }
+
+    private final CockpitMapSnapshotService mapSnapshotService;
+    private final CockpitInfrastructureOperatingInformationAdapter facilityAdapter;
+    private final Clock clock;
+    private final String cursorSecret;
+    private final int cursorTtlSeconds;
+
+    public CockpitMapDisplayService(
+            CockpitMapSnapshotService mapSnapshotService,
+            CockpitInfrastructureOperatingInformationAdapter facilityAdapter,
+            Clock clock,
+            @Value("${cockpit.display.cursor-secret:cockpit-display-cursor-v1}") String cursorSecret,
+            @Value("${cockpit.display.cursor-ttl-seconds:600}") int cursorTtlSeconds) {
+        this.mapSnapshotService = mapSnapshotService;
+        this.facilityAdapter = facilityAdapter;
+        this.clock = clock;
+        this.cursorSecret = cursorSecret == null ? "" : cursorSecret;
+        this.cursorTtlSeconds = cursorTtlSeconds < 1 ? DEFAULT_CURSOR_TTL_SECONDS : cursorTtlSeconds;
+    }
+
+    public CockpitMapDisplayResponse buckets(String requestId, String bboxText, Integer zoomBand,
+            String snapshotAt, String industry, String district, String deviceType, String pointStatus) {
+        BBox bbox = parseBbox(bboxText);
+        int band = validateZoomBand(zoomBand);
+        Rows rows = loadRows(requestId, snapshotAt, industry, district, deviceType, pointStatus);
+        String filterHash = CockpitMemberCursor.filterHash(industry, district, deviceType, pointStatus);
+        Instant now = clock.instant();
+
+        List<CockpitMapDisplayResponse.ClassBuckets> classes = new ArrayList<>();
+        CockpitMapDisplayResponse.ClassBuckets equipment = buildClass(
+                KIND_EQUIPMENT, rows.equipment, rows.complete, bbox, band, rows.snapshotAt, filterHash,
+                industry, district, deviceType, pointStatus, now);
+        CockpitMapDisplayResponse.ClassBuckets points = buildClass(
+                KIND_POINT, rows.points, rows.complete, bbox, band, rows.snapshotAt, filterHash,
+                industry, district, deviceType, pointStatus, now);
+        CockpitMapDisplayResponse.ClassBuckets facilities = new CockpitMapDisplayResponse.ClassBuckets(
+                KIND_FACILITY, facilityCoverage(), Collections.emptyList());
+        classes.add(equipment);
+        classes.add(points);
+        classes.add(facilities);
+
+        // 顶层 partial 只表示设备/监测点桶是否因快照页未取全;设施无坐标是**类别级**回退,
+        // 由 facilities.coverage 明确表达,不能让右上加载态永远停在 partial。
+        boolean partial = !"COMPLETE".equals(equipment.getCoverage().getState())
+                || !"COMPLETE".equals(points.getCoverage().getState());
+        CockpitMapSnapshotResponse.MapFilter filter = rows.filter;
+        CockpitMapDisplayResponse.Filters filters = new CockpitMapDisplayResponse.Filters(
+                filter == null ? null : filter.getIndustry(),
+                filter == null ? null : filter.getDistrict(),
+                filter == null ? null : filter.getDistrictName(),
+                filter == null ? null : filter.getDistrictFilter(),
+                filter == null ? null : filter.getDeviceType(),
+                filter == null ? null : filter.getPointStatus());
+        return new CockpitMapDisplayResponse(
+                requestId, rows.snapshotAt, rows.snapshotAt, band, bbox.echo(),
+                (int) cellMeters(band), partial, filters, classes);
+    }
+
+    public CockpitMapDisplayResponse.Members members(String requestId, String cursorToken,
+            String search, Integer pageSize) {
+        int safePageSize = pageSize == null ? DEFAULT_MEMBER_PAGE_SIZE : pageSize;
+        if (safePageSize < 1 || safePageSize > MAX_MEMBER_PAGE_SIZE) {
+            throw new CockpitInvalidRequestException("成员分页大小必须在 1 到 100 之间");
+        }
+        CockpitMemberCursor cursor = CockpitMemberCursor.decode(
+                cursorToken, cursorSecret, clock.instant());
+        if (!KIND_EQUIPMENT.equals(cursor.getKind()) && !KIND_POINT.equals(cursor.getKind())) {
+            throw new CockpitInvalidRequestException("成员游标类别不支持,请重新加载聚合桶");
+        }
+        String requestedSearch = normalizeSearch(search);
+        String effectiveSearch;
+        int offset;
+        if (!requestedSearch.isEmpty()) {
+            if (!cursor.getSearch().isEmpty() && !cursor.getSearch().equals(requestedSearch)) {
+                throw new CockpitInvalidRequestException("成员搜索条件与游标不一致,请重新加载聚合桶");
+            }
+            effectiveSearch = requestedSearch;
+            offset = cursor.getSearch().isEmpty() ? 0 : cursor.getOffset();
+        } else {
+            effectiveSearch = cursor.getSearch();
+            offset = cursor.getOffset();
+        }
+
+        if (!CockpitMemberCursor.filterHash(cursor.getIndustry(), cursor.getDistrict(),
+                cursor.getDeviceType(), cursor.getPointStatus()).equals(cursor.getFilterHash())) {
+            throw new CockpitInvalidRequestException("成员游标筛选指纹不匹配,请重新加载聚合桶");
+        }
+        Rows rows = loadRows(requestId, cursor.getSnapshotAt(), cursor.getIndustry(), cursor.getDistrict(),
+                cursor.getDeviceType(), cursor.getPointStatus());
+        List<Row> classRows = KIND_EQUIPMENT.equals(cursor.getKind()) ? rows.equipment : rows.points;
+        List<Row> bucketRows = classRows.stream()
+                .filter(Row::mapped)
+                .filter(row -> groupKeyForBand(cursor.getGroupKey(), row))
+                .collect(Collectors.toList());
+        if (!effectiveSearch.isEmpty()) {
+            bucketRows = bucketRows.stream()
+                    .filter(row -> matchesSearch(row, effectiveSearch))
+                    .collect(Collectors.toList());
+        }
+        sortRows(bucketRows);
+        int total = bucketRows.size();
+        int from = Math.min(offset, total);
+        int to = Math.min(from + safePageSize, total);
+        List<CockpitMapDisplayResponse.Member> items = bucketRows.subList(from, to).stream()
+                .map(Row::member).collect(Collectors.toList());
+        String nextCursor = to < total
+                ? CockpitMemberCursor.encode(rows.snapshotAt, cursor.getKind(), cursor.getGroupKey(),
+                        cursor.getFilterHash(), cursor.getIndustry(), cursor.getDistrict(),
+                        cursor.getDeviceType(), cursor.getPointStatus(), effectiveSearch, to,
+                        clock.instant(), cursorTtlSeconds, cursorSecret)
+                : null;
+        return new CockpitMapDisplayResponse.Members(requestId, rows.snapshotAt, cursor.getKind(),
+                cursor.getGroupKey(), effectiveSearch, from, safePageSize, total, items, nextCursor);
+    }
+
+    public CockpitErrorPayload invalidRequest(String requestId, String message) {
+        return new CockpitErrorPayload(CockpitErrorCategory.INVALID_REQUEST, message, requestId, businessTime());
+    }
+
+    public CockpitErrorPayload cursorExpired(String requestId, String message) {
+        return new CockpitErrorPayload(CockpitErrorCategory.MEMBER_CURSOR_EXPIRED, message, requestId, businessTime());
+    }
+
+    public CockpitErrorPayload snapshotExpired(String requestId) {
+        return new CockpitErrorPayload(CockpitErrorCategory.SNAPSHOT_EXPIRED,
+                "地图快照已失效,请重新加载", requestId, businessTime());
+    }
+
+    public CockpitErrorPayload serverError(String requestId) {
+        return new CockpitErrorPayload(CockpitErrorCategory.SERVER_ERROR,
+                "显示聚合数据暂不可用", requestId, businessTime());
+    }
+
+    private CockpitMapDisplayResponse.ClassBuckets buildClass(String kind, List<Row> source, boolean complete,
+            BBox bbox, int band, String snapshotAt, String filterHash,
+            String filterIndustry, String filterDistrict, String filterDeviceType, String filterPointStatus,
+            Instant now) {
+        List<Row> mapped = source.stream().filter(Row::mapped).collect(Collectors.toList());
+        Map<String, List<Row>> cells = new LinkedHashMap<>();
+        for (Row row : mapped) {
+            String key = groupKey(kind, band, row);
+            cells.computeIfAbsent(key, ignored -> new ArrayList<>()).add(row);
+        }
+        List<CockpitMapDisplayResponse.Bucket> buckets = new ArrayList<>();
+        for (Map.Entry<String, List<Row>> entry : cells.entrySet()) {
+            CockpitMapDisplayResponse.Bounds cell = bounds(entry.getKey());
+            // 桶是完整地理格:只要格与视窗相交就返回整格成员,成员页才不会比桶计数多出界外点。
+            if (!bbox.intersects(cell)) {
+                continue;
+            }
+            List<Row> members = entry.getValue();
+            sortRows(members);
+            String cursor = CockpitMemberCursor.encode(snapshotAt, kind, entry.getKey(), filterHash,
+                    filterIndustry, filterDistrict, filterDeviceType, filterPointStatus,
+                    "", 0, now, cursorTtlSeconds, cursorSecret);
+            buckets.add(new CockpitMapDisplayResponse.Bucket(entry.getKey(), kind, members.size(),
+                    statusSummary(members, kind), cell, anchor(members), cursor));
+        }
+        buckets.sort(Comparator.comparing(CockpitMapDisplayResponse.Bucket::getGroupKey));
+        return new CockpitMapDisplayResponse.ClassBuckets(kind,
+                new CockpitMapDisplayResponse.Coverage(complete ? "COMPLETE" : "PARTIAL", null,
+                        snapshotAt, source.size(), mapped.size()),
+                buckets);
+    }
+
+    private CockpitMapDisplayResponse.Coverage facilityCoverage() {
+        try {
+            CockpitInfrastructureOperatingInformationSnapshot snapshot = facilityAdapter.load();
+            if (snapshot == null) {
+                return new CockpitMapDisplayResponse.Coverage(
+                        "UNAVAILABLE", "FACILITY_SOURCE_UNAVAILABLE", null, 0, 0);
+            }
+            Set<String> ids = new HashSet<>();
+            for (CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric : snapshot.getMetrics()) {
+                if (metric.getFacilityId() != null && !metric.getFacilityId().trim().isEmpty()) {
+                    ids.add(metric.getFacilityId());
+                }
+            }
+            return new CockpitMapDisplayResponse.Coverage("UNAVAILABLE",
+                    "FACILITY_COORDINATE_SOURCE_UNAVAILABLE", snapshot.getUpdatedAt(), ids.size(), 0);
+        } catch (RuntimeException exception) {
+            return new CockpitMapDisplayResponse.Coverage(
+                    "UNAVAILABLE", "FACILITY_SOURCE_UNAVAILABLE", null, 0, 0);
+        }
+    }
+
+    private Rows loadRows(String requestId, String snapshotAt, String industry, String district,
+            String deviceType, String pointStatus) {
+        List<CockpitMonitoringPointSummary> points = new ArrayList<>();
+        List<CockpitUnassociatedEquipmentSummary> equipment = new ArrayList<>();
+        String token = snapshotAt;
+        String actualSnapshotAt = null;
+        CockpitMapSnapshotResponse.MapFilter filter = null;
+        boolean complete = false;
+        for (int page = 1; page <= MAX_SNAPSHOT_PAGES; page += 1) {
+            CockpitMapSnapshotResponse response;
+            try {
+                response = mapSnapshotService.load(
+                        requestId, page, SNAPSHOT_PAGE_SIZE, token,
+                        industry, district, deviceType, pointStatus);
+            } catch (CockpitSnapshotExpiredException exception) {
+                // 保持旧 Controller 的错误载荷口径,不把底层英文/内部原因透给调用方。
+                throw new CockpitSnapshotExpiredException("地图快照已失效,请重新加载");
+            } catch (CockpitReadException exception) {
+                throw new CockpitReadException("显示聚合数据暂不可用");
+            }
+            actualSnapshotAt = response.getSnapshotAt();
+            filter = response.getMapFilter();
+            points.addAll(response.getMonitoringPoints());
+            equipment.addAll(response.getUnassociatedEquipment());
+            if (response.isComplete()) {
+                complete = true;
+                break;
+            }
+            token = response.getSnapshotAt();
+        }
+        if (actualSnapshotAt == null) {
+            throw new CockpitSnapshotExpiredException("地图快照已失效,请重新加载");
+        }
+        if (!complete) {
+            // 不静默截断:返回半份桶会让成员数和业务总数同时失真。
+            throw new CockpitReadException("显示聚合数据暂不可用");
+        }
+        return new Rows(actualSnapshotAt, true, points, equipment, filter);
+    }
+
+    private static CockpitMapDisplayResponse.StatusSummary statusSummary(List<Row> members, String kind) {
+        Map<String, Integer> counts = new LinkedHashMap<>();
+        for (Row row : members) {
+            counts.put(row.status, counts.getOrDefault(row.status, 0) + 1);
+        }
+        List<CockpitMapDisplayResponse.StatusCount> rows = counts.entrySet().stream()
+                .map(entry -> new CockpitMapDisplayResponse.StatusCount(entry.getKey(),
+                        label(entry.getKey()), entry.getValue()))
+                .sorted(Comparator.comparingInt(item -> priority(kind, item.getStatus())))
+                .collect(Collectors.toList());
+        if (rows.isEmpty()) {
+            return new CockpitMapDisplayResponse.StatusSummary("UNKNOWN", "状态未发布", 0, 0, 0, rows);
+        }
+        CockpitMapDisplayResponse.StatusCount primary = rows.get(0);
+        int abnormal = 0;
+        for (CockpitMapDisplayResponse.StatusCount item : rows) {
+            if (priority(kind, item.getStatus()) <= 3) {
+                abnormal += item.getCount();
+            }
+        }
+        int other = abnormal - (priority(kind, primary.getStatus()) <= 3 ? primary.getCount() : 0);
+        return new CockpitMapDisplayResponse.StatusSummary(primary.getStatus(), primary.getLabel(),
+                primary.getCount(), abnormal, Math.max(0, other), rows);
+    }
+
+    private static void sortRows(List<Row> rows) {
+        rows.sort(Comparator.comparingInt((Row row) -> row.priority)
+                .thenComparing(row -> safe(row.name))
+                .thenComparing(row -> safe(row.code)));
+    }
+
+    private static CockpitMapDisplayResponse.Anchor anchor(List<Row> rows) {
+        double longitude = 0;
+        double latitude = 0;
+        for (Row row : rows) {
+            longitude += row.longitude;
+            latitude += row.latitude;
+        }
+        return new CockpitMapDisplayResponse.Anchor(longitude / rows.size(), latitude / rows.size());
+    }
+
+    private static String groupKey(String kind, int band, Row row) {
+        double step = cellMeters(band) / METERS_PER_DEGREE;
+        int x = (int) Math.floor((row.longitude + 180.0) / step);
+        int y = (int) Math.floor((row.latitude + 90.0) / step);
+        return kind + "|" + band + "|" + x + "|" + y;
+    }
+
+    private static boolean groupKeyForBand(String groupKey, Row row) {
+        String[] parts = groupKey.split("\\|", -1);
+        if (parts.length != 4) {
+            return false;
+        }
+        try {
+            int band = Integer.parseInt(parts[1]);
+            if (band < 0 || band >= CELL_METERS.length) {
+                return false;
+            }
+            return groupKey(parts[0], band, row).equals(groupKey);
+        } catch (NumberFormatException exception) {
+            return false;
+        }
+    }
+
+    private static CockpitMapDisplayResponse.Bounds bounds(String groupKey) {
+        String[] parts = groupKey.split("\\|", -1);
+        int band = Integer.parseInt(parts[1]);
+        int x = Integer.parseInt(parts[2]);
+        int y = Integer.parseInt(parts[3]);
+        double step = cellMeters(band) / METERS_PER_DEGREE;
+        double west = -180.0 + x * step;
+        double south = -90.0 + y * step;
+        return new CockpitMapDisplayResponse.Bounds(west, south, west + step, south + step);
+    }
+
+    private static boolean matchesSearch(Row row, String search) {
+        String needle = normalizeSearch(search);
+        return safe(row.name).toLowerCase().contains(needle)
+                || safe(row.code).toLowerCase().contains(needle);
+    }
+
+    private static String normalizeSearch(String value) {
+        return value == null ? "" : value.trim().toLowerCase();
+    }
+
+    private static int validateZoomBand(Integer zoomBand) {
+        if (zoomBand == null || zoomBand < 0 || zoomBand >= CELL_METERS.length) {
+            throw new CockpitInvalidRequestException("zoomBand 必须在 0 到 8 之间");
+        }
+        return zoomBand;
+    }
+
+    private static double cellMeters(int band) {
+        return CELL_METERS[band];
+    }
+
+    private static BBox parseBbox(String value) {
+        if (value == null || value.trim().isEmpty()) {
+            throw new CockpitInvalidRequestException("bbox 不能为空,格式为 west,south,east,north");
+        }
+        String[] parts = value.split(",", -1);
+        if (parts.length != 4) {
+            throw new CockpitInvalidRequestException("bbox 格式不合法,应为 west,south,east,north");
+        }
+        BigDecimal west;
+        BigDecimal south;
+        BigDecimal east;
+        BigDecimal north;
+        try {
+            west = new BigDecimal(parts[0].trim());
+            south = new BigDecimal(parts[1].trim());
+            east = new BigDecimal(parts[2].trim());
+            north = new BigDecimal(parts[3].trim());
+        } catch (NumberFormatException exception) {
+            throw new CockpitInvalidRequestException("bbox 坐标必须是数字");
+        }
+        if (west.doubleValue() < -180 || east.doubleValue() > 180
+                || south.doubleValue() < -90 || north.doubleValue() > 90
+                || west.compareTo(east) >= 0 || south.compareTo(north) >= 0) {
+            throw new CockpitInvalidRequestException("bbox 坐标越界或顺序不合法");
+        }
+        if (east.subtract(west).doubleValue() > MAX_BBOX_SPAN_DEGREES
+                || north.subtract(south).doubleValue() > MAX_BBOX_SPAN_DEGREES) {
+            throw new CockpitInvalidRequestException("bbox 范围不能超过 2 度");
+        }
+        return new BBox(west.doubleValue(), south.doubleValue(), east.doubleValue(), north.doubleValue(),
+                west.stripTrailingZeros().toPlainString() + "," + south.stripTrailingZeros().toPlainString()
+                        + "," + east.stripTrailingZeros().toPlainString() + "," + north.stripTrailingZeros().toPlainString());
+    }
+
+    private static String label(String status) {
+        String label = DEVICE_LABEL.get(status);
+        if (label != null) {
+            return label;
+        }
+        for (CockpitMonitoringPointStatus item : CockpitMonitoringPointStatus.values()) {
+            if (item.name().equals(status)) {
+                return item.getLabel();
+            }
+        }
+        return "状态未发布";
+    }
+
+    private static int priority(String kind, String status) {
+        if (KIND_POINT.equals(kind)) {
+            for (CockpitMonitoringPointStatus item : CockpitMonitoringPointStatus.values()) {
+                if (item.name().equals(status)) {
+                    return item.getPriority();
+                }
+            }
+            return 999;
+        }
+        return DEVICE_PRIORITY.getOrDefault(status, 999);
+    }
+
+    private String businessTime() {
+        return OffsetDateTime.now(clock).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
+    }
+
+    private static String safe(String value) {
+        return value == null ? "" : value;
+    }
+
+    private static class Row {
+        private final String kind;
+        private final String code;
+        private final String name;
+        private final String status;
+        private final String statusLabel;
+        private final int priority;
+        private final double longitude;
+        private final double latitude;
+        private final String industry;
+        private final String typeCode;
+        private final String typeName;
+        private final Integer district;
+        private final String districtName;
+        private final boolean mapped;
+
+        private Row(String kind, String code, String name, String status, String statusLabel, int priority,
+                double longitude, double latitude, String industry, String typeCode, String typeName,
+                Integer district, String districtName, boolean mapped) {
+            this.kind = kind;
+            this.code = code;
+            this.name = name;
+            this.status = status;
+            this.statusLabel = statusLabel;
+            this.priority = priority;
+            this.longitude = longitude;
+            this.latitude = latitude;
+            this.industry = industry;
+            this.typeCode = typeCode;
+            this.typeName = typeName;
+            this.district = district;
+            this.districtName = districtName;
+            this.mapped = mapped;
+        }
+
+        private boolean mapped() { return mapped; }
+
+        private CockpitMapDisplayResponse.Member member() {
+            return new CockpitMapDisplayResponse.Member(kind, code, name, status, statusLabel, priority,
+                    longitude, latitude, industry, typeCode, typeName, district, districtName);
+        }
+    }
+
+    private static class Rows {
+        private final String snapshotAt;
+        private final boolean complete;
+        private final List<Row> points;
+        private final List<Row> equipment;
+        private final CockpitMapSnapshotResponse.MapFilter filter;
+
+        private Rows(String snapshotAt, boolean complete, List<CockpitMonitoringPointSummary> points,
+                List<CockpitUnassociatedEquipmentSummary> equipment,
+                CockpitMapSnapshotResponse.MapFilter filter) {
+            this.snapshotAt = snapshotAt;
+            this.complete = complete;
+            this.points = points.stream().map(CockpitMapDisplayService::pointRow).collect(Collectors.toList());
+            this.equipment = equipment.stream().map(CockpitMapDisplayService::equipmentRow).collect(Collectors.toList());
+            this.filter = filter;
+        }
+    }
+
+    private static Row pointRow(CockpitMonitoringPointSummary point) {
+        CockpitCoordinateValidation validation = point.getCoordinateValidation();
+        boolean mapped = validation != null && validation.isRenderable()
+                && point.getLongitude() != null && point.getLatitude() != null;
+        CockpitMonitoringPointStatus status = point.getPointStatus();
+        return new Row(KIND_POINT, point.getPointCode(), point.getPointName(),
+                status == null ? "UNKNOWN" : status.name(),
+                status == null ? "状态未发布" : status.getLabel(),
+                status == null ? 999 : status.getPriority(),
+                number(point.getLongitude()), number(point.getLatitude()),
+                point.getIndustry(), point.getTypeCode(), point.getTypeName(),
+                point.getDistrict(), point.getDistrictName(), mapped);
+    }
+
+    private static Row equipmentRow(CockpitUnassociatedEquipmentSummary equipment) {
+        CockpitCoordinateValidation validation = equipment.getCoordinateValidation();
+        boolean mapped = validation != null && validation.isRenderable()
+                && equipment.getLongitude() != null && equipment.getLatitude() != null;
+        String status = equipment.getDeviceStatus() == null ? "UNKNOWN" : equipment.getDeviceStatus();
+        return new Row(KIND_EQUIPMENT, equipment.getDeviceCode(), equipment.getDeviceName(),
+                status, label(status), priority(KIND_EQUIPMENT, status),
+                number(equipment.getLongitude()), number(equipment.getLatitude()),
+                equipment.getIndustry(), equipment.getTypeCode(), equipment.getTypeName(),
+                equipment.getDistrict(), equipment.getDistrictName(), mapped);
+    }
+
+    private static double number(BigDecimal value) {
+        return value == null ? 0 : value.doubleValue();
+    }
+
+    private static class BBox {
+        private final double west;
+        private final double south;
+        private final double east;
+        private final double north;
+        private final String echo;
+
+        private BBox(double west, double south, double east, double north, String echo) {
+            this.west = west;
+            this.south = south;
+            this.east = east;
+            this.north = north;
+            this.echo = echo;
+        }
+
+        private boolean intersects(CockpitMapDisplayResponse.Bounds bounds) {
+            return bounds.getEast() >= west && bounds.getWest() <= east
+                    && bounds.getNorth() >= south && bounds.getSouth() <= north;
+        }
+
+        private String echo() { return echo; }
+    }
+
+}

+ 197 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/display/CockpitMemberCursor.java

@@ -0,0 +1,197 @@
+package com.zksy.cockpit.display;
+
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitMemberCursorExpiredException;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.time.Instant;
+import java.util.Base64;
+
+/**
+ * 成员游标:把来源版本、类别、组、筛选、搜索、稳定排序偏移和过期时间绑在一起。
+ *
+ * <p>服务端不保存游标会话;同一快照下重新读取成员,靠签名和版本校验防篡改/防串页。
+ * 游标不是安全凭证,但它必须能明确告诉调用方「这个偏移属于哪一份快照与哪一组」。
+ */
+public final class CockpitMemberCursor {
+    static final String VERSION = "1";
+    private static final Base64.Encoder URL_ENCODER = Base64.getUrlEncoder().withoutPadding();
+    private static final Base64.Decoder URL_DECODER = Base64.getUrlDecoder();
+
+    private final String snapshotAt;
+    private final String kind;
+    private final String groupKey;
+    private final String filterHash;
+    private final String industry;
+    private final String district;
+    private final String deviceType;
+    private final String pointStatus;
+    private final String search;
+    private final int offset;
+    private final long expiresAt;
+
+    private CockpitMemberCursor(String snapshotAt, String kind, String groupKey, String filterHash,
+            String industry, String district, String deviceType, String pointStatus,
+            String search, int offset, long expiresAt) {
+        this.snapshotAt = snapshotAt;
+        this.kind = kind;
+        this.groupKey = groupKey;
+        this.filterHash = filterHash;
+        this.industry = industry;
+        this.district = district;
+        this.deviceType = deviceType;
+        this.pointStatus = pointStatus;
+        this.search = search;
+        this.offset = offset;
+        this.expiresAt = expiresAt;
+    }
+
+    public String getSnapshotAt() { return snapshotAt; }
+    public String getKind() { return kind; }
+    public String getGroupKey() { return groupKey; }
+    public String getFilterHash() { return filterHash; }
+    public String getIndustry() { return industry; }
+    public String getDistrict() { return district; }
+    public String getDeviceType() { return deviceType; }
+    public String getPointStatus() { return pointStatus; }
+    public String getSearch() { return search; }
+    public int getOffset() { return offset; }
+    public long getExpiresAt() { return expiresAt; }
+
+    public static String encode(String snapshotAt, String kind, String groupKey, String filterHash,
+            String industry, String district, String deviceType, String pointStatus,
+            String search, int offset, Instant now, int ttlSeconds, String secret) {
+        long expiresAt = now.getEpochSecond() + Math.max(1, ttlSeconds);
+        String[] fields = new String[] {
+                VERSION,
+                snapshotAt == null ? "" : snapshotAt,
+                kind == null ? "" : kind,
+                groupKey == null ? "" : groupKey,
+                filterHash == null ? "" : filterHash,
+                industry == null ? "" : industry,
+                district == null ? "" : district,
+                deviceType == null ? "" : deviceType,
+                pointStatus == null ? "" : pointStatus,
+                URL_ENCODER.encodeToString((search == null ? "" : search).getBytes(StandardCharsets.UTF_8)),
+                Integer.toString(Math.max(0, offset)),
+                Long.toString(expiresAt)
+        };
+        StringBuilder payload = new StringBuilder();
+        for (int i = 0; i < fields.length; i++) {
+            if (i > 0) {
+                payload.append('|');
+            }
+            payload.append(urlEncode(fields[i]));
+        }
+        String body = payload.toString();
+        return URL_ENCODER.encodeToString(body.getBytes(StandardCharsets.UTF_8))
+                + "." + URL_ENCODER.encodeToString(sign(body, secret));
+    }
+
+    public static CockpitMemberCursor decode(String token, String secret, Instant now) {
+        if (token == null || token.trim().isEmpty()) {
+            throw new CockpitInvalidRequestException("成员游标不能为空");
+        }
+        String[] parts = token.trim().split("\\.", -1);
+        if (parts.length != 2) {
+            throw invalid();
+        }
+        String body;
+        byte[] signature;
+        try {
+            body = new String(URL_DECODER.decode(parts[0]), StandardCharsets.UTF_8);
+            signature = URL_DECODER.decode(parts[1]);
+        } catch (IllegalArgumentException exception) {
+            throw invalid();
+        }
+        if (!MessageDigest.isEqual(sign(body, secret), signature)) {
+            throw invalid();
+        }
+        String[] fields = body.split("\\|", -1);
+        if (fields.length != 12 || !VERSION.equals(urlDecode(fields[0]))) {
+            throw invalid();
+        }
+        try {
+            String snapshotAt = urlDecode(fields[1]);
+            String kind = urlDecode(fields[2]);
+            String groupKey = urlDecode(fields[3]);
+            String filterHash = urlDecode(fields[4]);
+            String industry = urlDecode(fields[5]);
+            String district = urlDecode(fields[6]);
+            String deviceType = urlDecode(fields[7]);
+            String pointStatus = urlDecode(fields[8]);
+            String search = new String(URL_DECODER.decode(urlDecode(fields[9])), StandardCharsets.UTF_8);
+            int offset = Integer.parseInt(urlDecode(fields[10]));
+            long expiresAt = Long.parseLong(urlDecode(fields[11]));
+            if (snapshotAt.isEmpty() || kind.isEmpty() || groupKey.isEmpty() || offset < 0) {
+                throw invalid();
+            }
+            if (expiresAt < now.getEpochSecond()) {
+                throw new CockpitMemberCursorExpiredException("成员游标已失效,请重新加载聚合桶");
+            }
+            return new CockpitMemberCursor(snapshotAt, kind, groupKey, filterHash,
+                    industry, district, deviceType, pointStatus, search, offset, expiresAt);
+        } catch (NumberFormatException exception) {
+            throw invalid();
+        } catch (IllegalArgumentException exception) {
+            throw invalid();
+        }
+    }
+
+    /** 筛选指纹:同一组、同一快照但筛选变了,旧游标不得继续翻页。 */
+    public static String filterHash(String industry, String district, String deviceType, String pointStatus) {
+        String raw = nullToEmpty(industry) + "|" + nullToEmpty(district)
+                + "|" + nullToEmpty(deviceType) + "|" + nullToEmpty(pointStatus);
+        try {
+            MessageDigest digest = MessageDigest.getInstance("SHA-256");
+            byte[] hash = digest.digest(raw.getBytes(StandardCharsets.UTF_8));
+            StringBuilder result = new StringBuilder(hash.length * 2);
+            for (byte value : hash) {
+                result.append(String.format("%02x", value & 0xff));
+            }
+            return result.toString();
+        } catch (Exception exception) {
+            throw new IllegalStateException("SHA-256 unavailable", exception);
+        }
+    }
+
+    private static byte[] sign(String body, String secret) {
+        try {
+            Mac mac = Mac.getInstance("HmacSHA256");
+            mac.init(new SecretKeySpec((secret == null ? "" : secret).getBytes(StandardCharsets.UTF_8),
+                    "HmacSHA256"));
+            return mac.doFinal(body.getBytes(StandardCharsets.UTF_8));
+        } catch (Exception exception) {
+            throw new IllegalStateException("HmacSHA256 unavailable", exception);
+        }
+    }
+
+    private static String urlEncode(String value) {
+        try {
+            return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
+        } catch (Exception exception) {
+            throw new IllegalStateException(exception);
+        }
+    }
+
+    private static String urlDecode(String value) {
+        try {
+            return URLDecoder.decode(value, StandardCharsets.UTF_8.name());
+        } catch (Exception exception) {
+            throw invalid();
+        }
+    }
+
+    private static CockpitInvalidRequestException invalid() {
+        return new CockpitInvalidRequestException("成员游标不合法,请重新加载聚合桶");
+    }
+
+    private static String nullToEmpty(String value) {
+        return value == null ? "" : value;
+    }
+}

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

@@ -5,5 +5,6 @@ public enum CockpitErrorCategory {
     SERVER_ERROR,
     SERVER_ERROR,
     INVALID_REQUEST,
     INVALID_REQUEST,
     SNAPSHOT_EXPIRED,
     SNAPSHOT_EXPIRED,
+    MEMBER_CURSOR_EXPIRED,
     NOT_FOUND
     NOT_FOUND
 }
 }

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

@@ -0,0 +1,8 @@
+package com.zksy.cockpit.foundation;
+
+/** 成员游标过期/被替换时抛出;调用方必须重新取聚合桶,不能继续用旧偏移。 */
+public class CockpitMemberCursorExpiredException extends RuntimeException {
+    public CockpitMemberCursorExpiredException(String message) {
+        super(message);
+    }
+}

+ 120 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/geometry/CockpitFacilityGeometryService.java

@@ -4,6 +4,21 @@ import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.watersupply.domain.PumpStationInfo;
+import com.zksy.watersupply.domain.WaterFireHydrantInfo;
+import com.zksy.watersupply.domain.WaterPlantInfo;
+import com.zksy.watersupply.domain.WaterSourceInfo;
+import com.zksy.watersupply.domain.WaterUserInfo;
+import com.zksy.watersupply.service.IPumpStationInfoService;
+import com.zksy.watersupply.service.IWaterFireHydrantInfoService;
+import com.zksy.watersupply.service.IWaterPlantInfoService;
+import com.zksy.watersupply.service.IWaterSourceInfoService;
+import com.zksy.watersupply.service.IWaterUserInfoService;
+import com.zksy.drainage.domain.DrainageGateInfo;
+import com.zksy.drainage.domain.DrainageStorageInfo;
+import com.zksy.drainage.service.DrainageGateInfoService;
+import com.zksy.drainage.service.DrainageStorageInfoService;
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
@@ -30,15 +45,39 @@ import java.util.stream.Collectors;
 public class CockpitFacilityGeometryService {
 public class CockpitFacilityGeometryService {
     private final PipeNetworkBaseService networks;
     private final PipeNetworkBaseService networks;
     private final ManholeBaseService manholes;
     private final ManholeBaseService manholes;
+    private final IWaterPlantInfoService plants;
+    private final IPumpStationInfoService stations;
+    private final IWaterSourceInfoService waterSources;
+    private final IWaterUserInfoService waterUsers;
+    private final IWaterFireHydrantInfoService hydrants;
+    private final DrainageGateInfoService gates;
+    private final DrainageStorageInfoService storages;
     private final Clock clock;
     private final Clock clock;
 
 
+    /** Spring 注入使用全依赖构造器;保留三参构造器给既有单测/直接实例化。 */
+    @org.springframework.beans.factory.annotation.Autowired
     public CockpitFacilityGeometryService(PipeNetworkBaseService networks,
     public CockpitFacilityGeometryService(PipeNetworkBaseService networks,
-            ManholeBaseService manholes, Clock clock) {
+            ManholeBaseService manholes, IWaterPlantInfoService plants,
+            IPumpStationInfoService stations, IWaterSourceInfoService waterSources,
+            IWaterUserInfoService waterUsers, IWaterFireHydrantInfoService hydrants,
+            DrainageGateInfoService gates, DrainageStorageInfoService storages, Clock clock) {
         this.networks = networks;
         this.networks = networks;
         this.manholes = manholes;
         this.manholes = manholes;
+        this.plants = plants;
+        this.stations = stations;
+        this.waterSources = waterSources;
+        this.waterUsers = waterUsers;
+        this.hydrants = hydrants;
+        this.gates = gates;
+        this.storages = storages;
         this.clock = clock;
         this.clock = clock;
     }
     }
 
 
+    public CockpitFacilityGeometryService(PipeNetworkBaseService networks,
+            ManholeBaseService manholes, Clock clock) {
+        this(networks, manholes, null, null, null, null, null, null, null, clock);
+    }
+
     @Transactional(readOnly = true)
     @Transactional(readOnly = true)
     public CockpitFacilityGeometryResponse load() {
     public CockpitFacilityGeometryResponse load() {
         try {
         try {
@@ -61,6 +100,7 @@ public class CockpitFacilityGeometryService {
                         null, null, null, "Point",
                         null, null, null, "Point",
                         Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
                         Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
             }
             }
+            addFacilityFeatures(features);
             List<Coverage> coverage = new ArrayList<>();
             List<Coverage> coverage = new ArrayList<>();
             for (String industry : Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE")) {
             for (String industry : Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE")) {
                 coverage.add(coverage(features, industry, "pipe_network_base", "LineString", "TWO_ENDPOINTS_ONLY"));
                 coverage.add(coverage(features, industry, "pipe_network_base", "LineString", "TWO_ENDPOINTS_ONLY"));
@@ -75,6 +115,7 @@ public class CockpitFacilityGeometryService {
             coverage.add(new Coverage("MANHOLE", null, "LineString", "UNAVAILABLE",
             coverage.add(new Coverage("MANHOLE", null, "LineString", "UNAVAILABLE",
                     "NO_PIPELINE_SOURCE", 0, 0, 0));
                     "NO_PIPELINE_SOURCE", 0, 0, 0));
             coverage.add(coverage(features, "UNKNOWN", "pipe_network_base", "LineString", "UNKNOWN_NETWORK_TYPE"));
             coverage.add(coverage(features, "UNKNOWN", "pipe_network_base", "LineString", "UNKNOWN_NETWORK_TYPE"));
+            addFacilityCoverage(coverage, features);
             String generatedAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
             String generatedAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
                     clock.instant().atZone(ZoneId.of("Asia/Shanghai")));
                     clock.instant().atZone(ZoneId.of("Asia/Shanghai")));
             return new CockpitFacilityGeometryResponse(generatedAt, features, coverage);
             return new CockpitFacilityGeometryResponse(generatedAt, features, coverage);
@@ -86,6 +127,84 @@ public class CockpitFacilityGeometryService {
         }
         }
     }
     }
 
 
+
+    /** 设施台账的 Point Feature:坐标来自各设施表自身字段,不另外回查 entity detail。 */
+    private void addFacilityFeatures(List<Feature> features) {
+        if (plants != null) {
+            for (WaterPlantInfo v : plants.list()) {
+                if (v != null) addPointFeature(features, "water_plant_info", v.getId(), v.getPlantCode(),
+                        v.getPlantName(), "WATER_SUPPLY", "WATER_PLANT", v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (stations != null) {
+            for (PumpStationInfo v : stations.list()) {
+                if (v == null) continue;
+                String typeCode = CockpitFacilityContract.pumpStationTypeCode(v.getStationType());
+                String industry = "1".equals(typeCode) ? "DRAINAGE" : "WATER_SUPPLY";
+                addPointFeature(features, "pump_station_info", v.getId(), v.getStationCode(),
+                        v.getStationName(), industry, "PUMP_STATION", v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (waterSources != null) {
+            for (WaterSourceInfo v : waterSources.list()) {
+                if (v != null) addPointFeature(features, "water_source_info", v.getId(), v.getSourceId(),
+                        v.getSourceName(), "WATER_SUPPLY", "WATER_SOURCE", v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (waterUsers != null) {
+            for (WaterUserInfo v : waterUsers.list()) {
+                if (v != null) addPointFeature(features, "water_user_info", v.getId(), v.getUserCode(),
+                        v.getUserName(), "WATER_SUPPLY", "WATER_USER", v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (hydrants != null) {
+            for (WaterFireHydrantInfo v : hydrants.list()) {
+                if (v != null) addPointFeature(features, "water_fire_hydrant_info", v.getHydrantId(),
+                        v.getHydrantCode(), v.getHydrantName(), "WATER_SUPPLY", "WATER_FIRE_HYDRANT",
+                        v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (gates != null) {
+            for (DrainageGateInfo v : gates.list()) {
+                if (v != null) addPointFeature(features, "drainage_gate_info", v.getFacilityId(),
+                        v.getFacilityCode(), v.getFacilityName(), "DRAINAGE", "DRAINAGE_GATE",
+                        v.getLongitude(), v.getLatitude());
+            }
+        }
+        if (storages != null) {
+            for (DrainageStorageInfo v : storages.list()) {
+                if (v != null) addPointFeature(features, "drainage_storage_info", v.getFacilityId(),
+                        v.getFacilityCode(), v.getFacilityName(), "DRAINAGE", "DRAINAGE_STORAGE",
+                        v.getLongitude(), v.getLatitude());
+            }
+        }
+    }
+
+    private static void addPointFeature(List<Feature> features, String source, String sourceId, String code,
+            String name, String industry, String typeCode, java.math.BigDecimal longitude,
+            java.math.BigDecimal latitude) {
+        if (sourceId == null || sourceId.trim().isEmpty()) return;
+        List<List<java.math.BigDecimal>> coordinates = Collections.singletonList(pair(longitude, latitude));
+        CockpitCoordinateValidation validation = validate(longitude, latitude);
+        Geometry geometry = "INVALID".equals(validation.getState()) ? null
+                : new Geometry("Point", coordinates.get(0));
+        Properties properties = new Properties(source, sourceId.trim(), code, name, industry, typeCode,
+                null, null, typeCode, null, null, null, coordinates, validation,
+                Collections.singletonList(validation));
+        features.add(new Feature(source + ":" + sourceId.trim(), geometry, properties));
+    }
+
+    private static void addFacilityCoverage(List<Coverage> coverage, List<Feature> features) {
+        coverage.add(coverage(features, "WATER_SUPPLY", "water_plant_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "WATER_SUPPLY", "pump_station_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "DRAINAGE", "pump_station_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "WATER_SUPPLY", "water_source_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "WATER_SUPPLY", "water_user_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "WATER_SUPPLY", "water_fire_hydrant_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "DRAINAGE", "drainage_gate_info", "Point", "FACILITY_POINT"));
+        coverage.add(coverage(features, "DRAINAGE", "drainage_storage_info", "Point", "FACILITY_POINT"));
+    }
+
     private static Feature feature(String source, String sourceId, String code, String name, String industry,
     private static Feature feature(String source, String sourceId, String code, String name, String industry,
             String typeCode, String networkType, String networkLevel, String pointType, String networkId, BigDecimal diameter, String remark, String geometryType,
             String typeCode, String networkType, String networkLevel, String pointType, String networkId, BigDecimal diameter, String remark, String geometryType,
             List<List<BigDecimal>> coordinates) {
             List<List<BigDecimal>> coordinates) {

+ 261 - 0
pipe-network-service/zksy-system/src/test/java/com/zksy/cockpit/display/CockpitMapDisplayServiceTest.java

@@ -0,0 +1,261 @@
+package com.zksy.cockpit.display;
+
+import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import com.zksy.cockpit.foundation.CockpitMemberCursorExpiredException;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationAdapter;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationSnapshot;
+import com.zksy.cockpit.map.CockpitCoordinateValidationSummary;
+import com.zksy.cockpit.map.CockpitMapSnapshotAdapter;
+import com.zksy.cockpit.map.CockpitMapSnapshotResponse;
+import com.zksy.cockpit.map.CockpitMapSnapshotService;
+import com.zksy.cockpit.map.CockpitMonitoringPointSummary;
+import com.zksy.cockpit.map.CockpitUnassociatedEquipmentSummary;
+import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
+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.List;
+
+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;
+
+class CockpitMapDisplayServiceTest {
+    private static final String SNAPSHOT = "2026-11-25T10:00:00+08:00";
+    private static final Clock CLOCK = Clock.fixed(
+            Instant.parse("2026-11-25T02:00:00Z"), ZoneOffset.ofHours(8));
+    private static final String BBOX = "110.39,28.43,110.40,28.44";
+
+    @Test
+    void bucketsStayIndependentAndCarryStatusSummary() {
+        CockpitMapDisplayService service = service(CLOCK);
+
+        CockpitMapDisplayResponse response = service.buckets(
+                "req-1", BBOX, 4, null, null, null, null, null);
+
+        assertEquals("display-buckets-v1", response.getContract());
+        assertEquals(4, response.getZoomBand());
+        assertFalse(response.isPartial(), "设备/监测点快照完整时顶层 partial 应为 false");
+        // 设施无坐标只在设施类 coverage 降级,不把整个地图加载态永久标 partial。
+        assertEquals(3, response.getClasses().size());
+        CockpitMapDisplayResponse.ClassBuckets equipment = response.getClasses().get(0);
+        CockpitMapDisplayResponse.ClassBuckets points = response.getClasses().get(1);
+        CockpitMapDisplayResponse.ClassBuckets facilities = response.getClasses().get(2);
+        assertEquals(CockpitMapDisplayService.KIND_EQUIPMENT, equipment.getKind());
+        assertEquals(CockpitMapDisplayService.KIND_POINT, points.getKind());
+        assertEquals(CockpitMapDisplayService.KIND_FACILITY, facilities.getKind());
+
+        assertEquals(1, equipment.getBuckets().size());
+        assertEquals(1, points.getBuckets().size());
+        assertEquals(2, equipment.getBuckets().get(0).getMemberCount());
+        assertEquals(2, points.getBuckets().get(0).getMemberCount());
+        assertEquals("ALARM", points.getBuckets().get(0).getStatusSummary().getPrimaryStatus());
+        assertEquals("报警", points.getBuckets().get(0).getStatusSummary().getPrimaryLabel());
+        assertEquals(1, points.getBuckets().get(0).getStatusSummary().getOtherAbnormalCount());
+        assertEquals(1, equipment.getBuckets().get(0).getStatusSummary().getOtherAbnormalCount());
+        assertNotNull(points.getBuckets().get(0).getMemberCursor());
+        assertEquals("UNAVAILABLE", facilities.getCoverage().getState());
+        assertEquals("FACILITY_COORDINATE_SOURCE_UNAVAILABLE", facilities.getCoverage().getReason());
+        assertEquals(2, facilities.getCoverage().getTotal());
+        assertEquals(0, facilities.getCoverage().getMapped());
+        assertTrue(facilities.getBuckets().isEmpty());
+
+        CockpitMapDisplayResponse again = service.buckets(
+                "req-2", BBOX, 4, response.getSnapshotAt(), null, null, null, null);
+        assertEquals(points.getBuckets().get(0).getGroupKey(), again.getClasses().get(1).getBuckets().get(0).getGroupKey());
+    }
+
+    @Test
+    void memberCursorPagesWithoutDuplicatesAndBindsSearch() {
+        CockpitMapDisplayService service = service(CLOCK);
+        CockpitMapDisplayResponse response = service.buckets(
+                "req-1", BBOX, 4, null, null, null, null, null);
+        String cursor = response.getClasses().get(1).getBuckets().get(0).getMemberCursor();
+
+        assertEquals(2, response.getClasses().get(1).getBuckets().get(0).getMemberCount());
+        CockpitMapDisplayResponse.Members first = service.members("req-1", cursor, null, 1);
+        assertEquals(2, first.getTotal());
+        assertEquals(1, first.getItems().size());
+        assertNotNull(first.getNextCursor());
+
+        CockpitMapDisplayResponse.Members second = service.members(
+                "req-1", first.getNextCursor(), null, 1);
+        assertEquals(1, second.getItems().size());
+        assertFalse(first.getItems().get(0).getCode().equals(second.getItems().get(0).getCode()));
+        assertNull(second.getNextCursor());
+
+        CockpitMapDisplayResponse.Members search = service.members("req-1", cursor, "P", 1);
+        assertEquals(2, search.getTotal());
+        assertEquals("P1", search.getItems().get(0).getCode());
+        assertNotNull(search.getNextCursor());
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> service.members("req-1", search.getNextCursor(), "P1", 10));
+    }
+
+    @Test
+    void expiredOrTamperedCursorIsExplicit() {
+        CockpitMapDisplayService service = service(CLOCK);
+        CockpitMapDisplayResponse response = service.buckets(
+                "req-1", BBOX, 4, null, null, null, null, null);
+        String cursor = response.getClasses().get(0).getBuckets().get(0).getMemberCursor();
+
+        Clock later = Clock.fixed(Instant.parse("2026-11-25T02:11:00Z"), ZoneOffset.ofHours(8));
+        CockpitMapDisplayService expiredService = service(later);
+        assertThrows(CockpitMemberCursorExpiredException.class,
+                () -> expiredService.members("req-1", cursor, null, 20));
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> service.members("req-1", cursor + "x", null, 20));
+    }
+
+    @Test
+    void facilityCoverageNeverBorrowsOtherCoordinates() {
+        CockpitMapDisplayService service = service(CLOCK);
+        CockpitMapDisplayResponse response = service.buckets(
+                "req-1", BBOX, 4, null, null, null, null, null);
+        CockpitMapDisplayResponse.Coverage coverage = response.getClasses().get(2).getCoverage();
+        assertEquals("UNAVAILABLE", coverage.getState());
+        assertEquals("FACILITY_COORDINATE_SOURCE_UNAVAILABLE", coverage.getReason());
+        assertEquals("2026-11-25T09:00:00+08:00", coverage.getVersion());
+        assertEquals(2, coverage.getTotal());
+        assertTrue(response.getClasses().get(2).getBuckets().isEmpty());
+    }
+
+    @Test
+    void multiPageSnapshotKeepsBucketCountAndMemberTotalConsistent() {
+        CockpitMapDisplayService service = pagedService();
+        CockpitMapDisplayResponse response = service.buckets(
+                "req-paged", BBOX, 4, null, null, null, null, null);
+        CockpitMapDisplayResponse.Bucket pointBucket = response.getClasses().get(1).getBuckets().get(0);
+        CockpitMapDisplayResponse.Bucket deviceBucket = response.getClasses().get(0).getBuckets().get(0);
+        assertEquals(2, pointBucket.getMemberCount());
+        assertEquals(2, deviceBucket.getMemberCount());
+
+        CockpitMapDisplayResponse.Members page = service.members(
+                "req-paged", pointBucket.getMemberCursor(), null, 10);
+        assertEquals(pointBucket.getMemberCount(), page.getTotal());
+        assertEquals(2, page.getItems().size());
+    }
+
+    @Test
+    void cursorRejectsFilterFingerprintMismatch() {
+        CockpitMapDisplayService service = service(CLOCK);
+        String mismatched = CockpitMemberCursor.encode(SNAPSHOT, CockpitMapDisplayService.KIND_POINT,
+                "MONITORING_POINT|4|0|0", "bad-fingerprint", "WATER_SUPPLY", null, null, null,
+                "", 0, CLOCK.instant(), 600, "test-secret");
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> service.members("req", mismatched, null, 20));
+    }
+
+    @Test
+    void bboxAndZoomBandAreValidated() {
+        CockpitMapDisplayService service = service(CLOCK);
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> service.buckets("req", "110.40,28.43,110.39,28.44", 4, null, null, null, null, null));
+        assertThrows(CockpitInvalidRequestException.class,
+                () -> service.buckets("req", BBOX, 9, null, null, null, null, null));
+    }
+
+    private static CockpitMapDisplayService pagedService() {
+        CockpitMapSnapshotResponse first = pageResponse(1, false,
+                Collections.singletonList(point("P1", "取水点一", CockpitMonitoringPointStatus.ALARM, 110.3980, 28.4340)),
+                Collections.singletonList(device("E1", "设备一", "ALARM", 110.39805, 28.43405)));
+        CockpitMapSnapshotResponse second = pageResponse(2, true,
+                Collections.singletonList(point("P2", "取水点二", CockpitMonitoringPointStatus.WARNING, 110.3981, 28.4341)),
+                Collections.singletonList(device("E2", "设备二", "WARNING", 110.39815, 28.43415)));
+        CockpitMapSnapshotAdapter adapter = snapshotAt -> null;
+        CockpitMapSnapshotService snapshotService = new CockpitMapSnapshotService(adapter, CLOCK) {
+            @Override
+            public CockpitMapSnapshotResponse load(String requestId, Integer pageNumber, Integer pageSize,
+                    String snapshotAt, String industry, String district, String deviceType, String pointStatus) {
+                return pageNumber != null && pageNumber > 1 ? second : first;
+            }
+        };
+        CockpitInfrastructureOperatingInformationAdapter facilityAdapter = () ->
+                new CockpitInfrastructureOperatingInformationSnapshot("2026-11-25T09:00:00+08:00",
+                        Collections.emptyList());
+        return new CockpitMapDisplayService(snapshotService, facilityAdapter, CLOCK, "test-secret", 600);
+    }
+
+    private static CockpitMapSnapshotResponse pageResponse(int page, boolean complete,
+            List<CockpitMonitoringPointSummary> points,
+            List<CockpitUnassociatedEquipmentSummary> equipment) {
+        return new CockpitMapSnapshotResponse("req", "v1", true, page, 1, SNAPSHOT,
+                4, SNAPSHOT, complete, points, equipment,
+                new CockpitCoordinateValidationSummary("WGS84", 4, 4, 0, 0),
+                new CockpitMapSnapshotResponse.MapFilter(null, null, "NONE", null, null,
+                        Arrays.asList("P1", "P2"), Arrays.asList("E1", "E2")),
+                Collections.emptyList());
+    }
+
+    private static CockpitMapDisplayService service(Clock clock) {
+        CockpitMapSnapshotResponse page = page();
+        CockpitMapSnapshotAdapter adapter = snapshotAt -> null;
+        CockpitMapSnapshotService snapshotService = new CockpitMapSnapshotService(adapter, clock) {
+            @Override
+            public CockpitMapSnapshotResponse load(String requestId, Integer pageNumber, Integer pageSize,
+                    String snapshotAt, String industry, String district, String deviceType, String pointStatus) {
+                return page;
+            }
+        };
+        CockpitInfrastructureOperatingInformationAdapter facilityAdapter = () ->
+                new CockpitInfrastructureOperatingInformationSnapshot("2026-11-25T09:00:00+08:00",
+                        Arrays.asList(
+                                metric("F1", "厂区A"),
+                                metric("F1", "厂区A-流量"),
+                                metric("F2", "泵站B")));
+        return new CockpitMapDisplayService(snapshotService, facilityAdapter, clock,
+                "test-secret", 600);
+    }
+
+    private static CockpitMapSnapshotResponse page() {
+        List<CockpitMonitoringPointSummary> points = Arrays.asList(
+                point("P1", "取水点一", CockpitMonitoringPointStatus.ALARM, 110.3980, 28.4340),
+                point("P2", "取水点二", CockpitMonitoringPointStatus.WARNING, 110.3981, 28.4341),
+                point("P3", "范围外", CockpitMonitoringPointStatus.NORMAL, 110.5000, 28.5000));
+        List<CockpitUnassociatedEquipmentSummary> equipment = Arrays.asList(
+                device("E1", "设备一", "ALARM", 110.39805, 28.43405),
+                device("E2", "设备二", "WARNING", 110.39815, 28.43415),
+                device("E3", "范围外设备", "NORMAL", 110.5000, 28.5000));
+        return new CockpitMapSnapshotResponse("req", "v1", true, 1, 1000, SNAPSHOT,
+                points.size() + equipment.size(), SNAPSHOT, true, points, equipment,
+                new CockpitCoordinateValidationSummary("WGS84", 6, 6, 0, 0),
+                new CockpitMapSnapshotResponse.MapFilter(null, null, "NONE", null, null,
+                        Arrays.asList("P1", "P2", "P3"), Arrays.asList("E1", "E2", "E3")),
+                Collections.emptyList());
+    }
+
+    private static CockpitMonitoringPointSummary point(String code, String name,
+            CockpitMonitoringPointStatus status, double longitude, double latitude) {
+        return new CockpitMonitoringPointSummary(code, name, status, Collections.emptyList(),
+                Collections.emptyList(), 0, "WATER_SUPPLY", "TYPE", "类型",
+                BigDecimal.valueOf(longitude), BigDecimal.valueOf(latitude), valid());
+    }
+
+    private static CockpitUnassociatedEquipmentSummary device(String code, String name, String status,
+            double longitude, double latitude) {
+        return new CockpitUnassociatedEquipmentSummary(code, name, 0, "WATER_SUPPLY",
+                "TYPE", "类型", BigDecimal.valueOf(longitude), BigDecimal.valueOf(latitude),
+                valid(), status);
+    }
+
+    private static CockpitCoordinateValidation valid() {
+        return new CockpitCoordinateValidation("VALID", null, true, "WGS84");
+    }
+
+    private static CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric(
+            String facilityId, String name) {
+        return new CockpitInfrastructureOperatingInformationSnapshot.SourceMetric(
+                facilityId + "-metric", name, "FLOW", "m3/h", "WATER_SUPPLY",
+                BigDecimal.ONE, BigDecimal.TEN, SNAPSHOT, false,
+                Collections.emptyList(), facilityId, "WATER_PLANT", "0", Collections.emptyList());
+    }
+}