Просмотр исходного кода

feat(cockpit): 增加显示聚合桶与成员游标契约

新增 map-display-buckets / map-display-bucket-members:bbox+zoomBand 稳定地理格、设备/监测点独立桶、状态摘要、成员游标分页;设施坐标源不可用时按类降级为 UNAVAILABLE,不借其它类坐标。游标绑定快照、类别、组、筛选、搜索、排序偏移与过期时间,旧 map-snapshot 分页不变。
Kazerin 1 неделя назад
Родитель
Сommit
7be1b13f04

+ 16 - 2
docs/cockpit/README.md

@@ -20,7 +20,7 @@
 | 指标状态 | `NORMAL` `WARNING` `ALARM` `EXPIRED` `OFFLINE` `UNKNOWN` | 运行监测专用,`EXPIRED` 不与 `OFFLINE` 合并 |
 | 工单状态 | **当前运行时**:0待派单 1待接单 2已接单 3处理中 4待验收 5已结案 6延期中 7已取消 | 以当前 `WorkOrderStatusEnum`/`work_order.order_status` 为准;终态为 5、7,延期中为处理旁路。旧 ADR-0008 的“从 1 开始七态”只保留为历史决策,不得当作当前数据库编码 |
 | 新鲜度 | `CURRENT` `STALE` `EXPIRED` `EMPTY` `FAILED` | 每次响应携带 `freshness` |
-| 错误类别 | `UNAUTHORIZED` `SERVER_ERROR` `INVALID_REQUEST` `SNAPSHOT_EXPIRED` `NOT_FOUND` | 401/500/400/400/404 |
+| 错误类别 | `UNAUTHORIZED` `SERVER_ERROR` `INVALID_REQUEST` `SNAPSHOT_EXPIRED` `MEMBER_CURSOR_EXPIRED` `NOT_FOUND` | 401/500/400/400/400/404 |
 
 效率口径固定为 `basis = CLOSED_WORK_ORDERS_OVER_ELIGIBLE_WORK_ORDERS`:分子=状态 5(已结案)工单数,分母=状态 0–6 工单数之和(状态 7 已取消排除),工单范围=当前筛选内**全部工单**(按 `work_order.create_time` 界定时间窗口,不要求关联报警/事件);分母为 0 时回 `state=EMPTY` + `reason=NO_ELIGIBLE_WORK_ORDERS`,前端显示「不适用」而非 0%。同一个工单范围口径同时用于 `events/handling-efficiency`、`events/history-analysis`(汇总)与 `overview/warning-settings`(两个 family 共用一份范围读数);历史分析的小时桶与预警设置的日趋势仍是**事件**时间桶,与汇总处置率口径不同。旧 `CLOSED_WORK_ORDERS_OVER_TOTAL_EVENTS`(已结案 ÷ 事件总数)与「状态 6 / 事件总数」口径已废止。系统不判断预警真伪,契约中不存在任何准确率、误报率字段。
 
@@ -59,6 +59,20 @@
 | 设备详情聚合 | `GET /api/cockpit/v1/equipments/{deviceCode}/detail-aggregate` |
 | 新鲜度 | `GET /api/cockpit/v1/equipments/{deviceCode}/freshness` |
 | 契约自检 | `GET /api/cockpit/v1/foundation`、`GET /api/cockpit/v1/device-boundary` |
+| 显示聚合桶(票 06) | `GET /api/cockpit/v1/map-display-buckets?bbox&zoomBand&snapshotAt&industry&district&deviceType&pointStatus` |
+| 聚合桶成员分页(票 06) | `GET /api/cockpit/v1/map-display-bucket-members?cursor&search&pageSize` |
+
+### 显示聚合桶契约(票 06)
+
+服务端按视窗 `bbox=west,south,east,north`(WGS84、顺序校验、单边不超过 2 度)和 `zoomBand`(0–8,格边长对应 50km→10m)把三类对象落到**稳定地理桶**;返回桶的 `groupKey`、成员数、状态摘要、格范围、锚点和成员游标。响应不传投影矩阵,也不传完整成员数组。
+
+- `groupKey = 类别|zoomBand|cellX|cellY`;同一快照、同一格、同筛选下稳定。类别固定为 `UNASSOCIATED_EQUIPMENT` / `MONITORING_POINT` / `FACILITY_POINT`,三类独立,不跨类合并。
+- 设备/监测点复用 `map-snapshot` 的快照与筛选;成员游标绑定 `snapshotAt`、类别、`groupKey`、筛选指纹、搜索词、稳定排序偏移和过期时间(默认 600s)。游标被篡改/过期分别返回 `INVALID_REQUEST` / `MEMBER_CURSOR_EXPIRED`,不静默从头开始。
+- 成员排序:类别原生风险优先级 → 名称 → 编码;翻页按同一快照与同一排序偏移切片,不漏不重。搜索词由游标绑定,换词必须重新取桶。
+- **设施覆盖**:设施运营快照目前只有设施身份/状态,没有坐标。设施类返回 `coverage.state=UNAVAILABLE`、`reason=FACILITY_COORDINATE_SOURCE_UNAVAILABLE`、`version=updatedAt`,并如实给 `total`;不借用设备/点位坐标,调用方保留既有设施图层。来源调用失败时为 `FACILITY_SOURCE_UNAVAILABLE`。
+- 顶层 `partial` 只表示设备/监测点桶是否因快照页未取全;设施无坐标是**类别级**回退,由 `FACILITY_POINT.coverage` 表达,不把右上加载态永久标 partial。
+- 多节点部署需统一 `cockpit.display.cursor-secret`(默认值只适合单机/测试);`cockpit.display.cursor-ttl-seconds` 默认 600 秒。
+- 旧 `map-snapshot` 分页路径与响应保持不变;新端点只加显示聚合,不改旧分页语义。
 
 ### 地图筛选路径(冻结结论)
 
@@ -84,7 +98,7 @@
 
 ## 4. 分页、快照与错误口径
 
-- `page` 默认 1;`pageSize` 默认 100(地图快照默认 500),上限 1000;越界返回 `INVALID_REQUEST`。
+- `page` 默认 1;`pageSize` 默认 100(地图快照默认 500),上限 1000;越界返回 `INVALID_REQUEST`。显示聚合成员分页是独立口径:默认 20、上限 100。
 - `map-snapshot` 的 `page > 1` 必须携带**首屏无 token 请求签发**的同一 `snapshotAt`,否则 `SNAPSHOT_EXPIRED`;显式 token 仅复用已签发快照,缓存未命中不得按该时间重读当前库。同一 `snapshotAt` 下分页结果稳定,监测点优先、已关联设备不重复出点。
 - 坐标不可上图的对象(结构非法,或落在主场景区外)保留在列表与详情中,但 `coordinateValidation.renderable = false`,禁止渲染。
 - **坐标准入(2026-10-12 维护者裁定,取代此前的「人工校核前置」)**:入库坐标即视为可信来源,判据为「结构合法 + 落在主场景区范围内」。判定顺序:缺经度/缺纬度/经度越界/纬度越界/零坐标 → 各自的 `INVALID` 原因;数值合法但落在主场景区外 → `INVALID` / `OUTSIDE_PRIMARY_AREA`;其余 → `VALID` / `renderable=true`。

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

@@ -0,0 +1,96 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.display.CockpitMapDisplayResponse;
+import com.zksy.cockpit.display.CockpitMapDisplayService;
+import com.zksy.cockpit.foundation.CockpitErrorPayload;
+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 com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.utils.StringUtils;
+import com.zksy.common.utils.uuid.IdUtils;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+@RestController
+public class CockpitMapDisplayController {
+    private static final String REQUEST_ID_HEADER = "X-Request-Id";
+
+    private final CockpitMapDisplayService displayService;
+
+    public CockpitMapDisplayController(CockpitMapDisplayService displayService) {
+        this.displayService = displayService;
+    }
+
+    @GetMapping("/api/cockpit/v1/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("/api/cockpit/v1/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));
+    }
+
+    @ExceptionHandler(CockpitInvalidRequestException.class)
+    public ResponseEntity<AjaxResult> handleInvalidRequest(
+            HttpServletRequest request, CockpitInvalidRequestException exception) {
+        return badRequest(displayService.invalidRequest(resolveRequestId(request.getHeader(REQUEST_ID_HEADER)),
+                exception.getMessage()));
+    }
+
+    @ExceptionHandler(CockpitMemberCursorExpiredException.class)
+    public ResponseEntity<AjaxResult> handleCursorExpired(
+            HttpServletRequest request, CockpitMemberCursorExpiredException exception) {
+        return badRequest(displayService.cursorExpired(resolveRequestId(request.getHeader(REQUEST_ID_HEADER)),
+                exception.getMessage()));
+    }
+
+    @ExceptionHandler(CockpitSnapshotExpiredException.class)
+    public ResponseEntity<AjaxResult> handleSnapshotExpired(HttpServletRequest request) {
+        return badRequest(displayService.snapshotExpired(
+                resolveRequestId(request.getHeader(REQUEST_ID_HEADER))));
+    }
+
+    @ExceptionHandler(CockpitReadException.class)
+    public ResponseEntity<AjaxResult> handleReadFailure(HttpServletRequest request) {
+        CockpitErrorPayload payload = displayService.serverError(
+                resolveRequestId(request.getHeader(REQUEST_ID_HEADER)));
+        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+                .body(new AjaxResult(HttpStatus.INTERNAL_SERVER_ERROR.value(), payload.getMessage(), payload));
+    }
+
+    private ResponseEntity<AjaxResult> badRequest(CockpitErrorPayload payload) {
+        return ResponseEntity.status(HttpStatus.BAD_REQUEST)
+                .body(new AjaxResult(HttpStatus.BAD_REQUEST.value(), payload.getMessage(), payload));
+    }
+
+    private String resolveRequestId(String requestId) {
+        return StringUtils.isNotEmpty(requestId) ? requestId : IdUtils.fastSimpleUUID();
+    }
+}

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

@@ -76,7 +76,8 @@ class CockpitContractDictionaryTest {
                 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.asList("UNAUTHORIZED", "SERVER_ERROR", "INVALID_REQUEST", "SNAPSHOT_EXPIRED",
+                        "MEMBER_CURSOR_EXPIRED", "NOT_FOUND"),
                 Arrays.stream(CockpitErrorCategory.values()).map(Enum::name).collect(Collectors.toList()));
     }
 
@@ -86,6 +87,7 @@ class CockpitContractDictionaryTest {
                 CockpitFoundationController.class,
                 CockpitFreshnessController.class,
                 CockpitMapSnapshotController.class,
+                CockpitMapDisplayController.class,
                 CockpitMonitoringPointDetailController.class,
                 CockpitEquipmentDetailAggregateController.class,
                 CockpitEquipmentArchiveController.class,

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

@@ -0,0 +1,315 @@
+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 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, 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.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 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; }
+    }
+}

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

@@ -0,0 +1,572 @@
+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, 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 = mapSnapshotService.load(
+                    requestId, page, SNAPSHOT_PAGE_SIZE, token,
+                    industry, district, deviceType, pointStatus);
+            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,
     INVALID_REQUEST,
     SNAPSHOT_EXPIRED,
+    MEMBER_CURSOR_EXPIRED,
     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);
+    }
+}

+ 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());
+    }
+}