Browse Source

Merge remote-tracking branch 'origin/master'

zengy 1 month ago
parent
commit
a4a727dd40
34 changed files with 1835 additions and 207 deletions
  1. 4 0
      pipe-network-service/CONTEXT.md
  2. 49 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitFacilityGeometryController.java
  3. 3 1
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMapSnapshotController.java
  4. 2 2
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitMonitoringDistributionController.java
  5. 21 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitDeviceFactResolverTest.java
  6. 20 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringOverviewAdapterTest.java
  7. 2 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitWorkOrderReadAdapterTest.java
  8. 157 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityGeometryControllerTest.java
  9. 214 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityGeometryServiceTest.java
  10. 139 32
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringDistributionControllerTest.java
  11. 39 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringOverviewControllerTest.java
  12. 158 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitPipeNetworkCrossEndpointContractTest.java
  13. 191 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitPointStatusContractTest.java
  14. 46 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitPointStatusSnapshotSerializationTest.java
  15. 243 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitWorkOrderAssociationContractTest.java
  16. 76 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/geometry/CockpitFacilityGeometryResponse.java
  17. 135 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/geometry/CockpitFacilityGeometryService.java
  18. 9 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureBaseArchivesAdapter.java
  19. 3 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/BusinessCockpitMapSnapshotAdapter.java
  20. 8 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitMapSnapshot.java
  21. 9 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitMapSnapshotResponse.java
  22. 31 7
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitMapSnapshotService.java
  23. 5 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/map/CockpitUnassociatedEquipmentSummary.java
  24. 2 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringDistributionAdapter.java
  25. 4 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringOverviewAdapter.java
  26. 7 16
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionResponse.java
  27. 75 106
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionService.java
  28. 12 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionSnapshot.java
  29. 15 15
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewService.java
  30. 8 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewSnapshot.java
  31. 4 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/BusinessCockpitDeviceFactResolver.java
  32. 15 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitMonitoringPointDeviceSnapshot.java
  33. 96 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/point/CockpitPointStatusQuery.java
  34. 33 17
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/BusinessCockpitWorkOrderReadAdapter.java

+ 4 - 0
pipe-network-service/CONTEXT.md

@@ -202,6 +202,10 @@ _Avoid_:把工单主键、设备主键或事件编号当作设备业务编码
 报警记录进入处置流程后指向关联工单;工单同时指向设备。预警与报警仍是不同事件家族,预警需先通过其关联的报警才能推导工单,不能用事件名称或时间猜测。
 报警记录进入处置流程后指向关联工单;工单同时指向设备。预警与报警仍是不同事件家族,预警需先通过其关联的报警才能推导工单,不能用事件名称或时间猜测。
 _Avoid_:从工单标题、报警时间或旧的工单设备编码字段反推关系
 _Avoid_:从工单标题、报警时间或旧的工单设备编码字段反推关系
 
 
+**驾驶舱工单关联**:
+驾驶舱按报警与工单的一对一关系呈现关联事实;多个报警引用同一工单属于关联数据异常,不能任意选取一条充当主报警。未关联报警的工单仍是有效工单,须明确呈现未关联。
+_Avoid_:从多个关联报警中默认取首条、用缺少事件查询语境推断未关联
+
 **正式行业**:
 **正式行业**:
 驾驶舱筛选与统计使用供水、排水、燃气、井盖四类;井盖在当前设备类型树中是独立根类型,不应静默归入排水。
 驾驶舱筛选与统计使用供水、排水、燃气、井盖四类;井盖在当前设备类型树中是独立根类型,不应静默归入排水。
 _Avoid_:把井盖当作排水子类或非正式行业
 _Avoid_:把井盖当作排水子类或非正式行业

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

@@ -0,0 +1,49 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitErrorCategory;
+import com.zksy.cockpit.foundation.CockpitErrorPayload;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryService;
+import com.zksy.common.core.domain.AjaxResult;
+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.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.time.Clock;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
+@RestController
+public class CockpitFacilityGeometryController {
+    private final CockpitFacilityGeometryService service;
+    private final Clock clock;
+
+    public CockpitFacilityGeometryController(CockpitFacilityGeometryService service, Clock clock) {
+        this.service = service;
+        this.clock = clock;
+    }
+
+    @GetMapping("/api/cockpit/v1/infrastructure/geometry")
+    public ResponseEntity<AjaxResult> geometry() {
+        return ResponseEntity.ok(AjaxResult.success(service.load()));
+    }
+
+    @ExceptionHandler(RuntimeException.class)
+    public ResponseEntity<AjaxResult> handleReadFailure(HttpServletRequest request, RuntimeException exception) {
+        // Includes transaction begin/commit failures thrown outside service.load()'s body.
+        org.slf4j.LoggerFactory.getLogger(CockpitFacilityGeometryController.class)
+                .error("Facility geometry read failed", exception);
+        String requestId = request.getHeader("X-Request-Id");
+        if (requestId == null || requestId.trim().isEmpty()) {
+            requestId = IdUtils.fastSimpleUUID();
+        }
+        CockpitErrorPayload payload = new CockpitErrorPayload(CockpitErrorCategory.SERVER_ERROR,
+                "facility geometry source unavailable", requestId,
+                DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(clock.instant().atZone(ZoneId.of("Asia/Shanghai"))));
+        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+                .body(new AjaxResult(500, payload.getMessage(), payload));
+    }
+}

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

@@ -37,9 +37,11 @@ public class CockpitMapSnapshotController {
             @RequestParam(value = "industry", required = false) String industry,
             @RequestParam(value = "industry", required = false) String industry,
             @RequestParam(value = "district", required = false) String district,
             @RequestParam(value = "district", required = false) String district,
             @RequestParam(value = "deviceType", required = false) String deviceType,
             @RequestParam(value = "deviceType", required = false) String deviceType,
+            @RequestParam(value = "pointStatus", required = false) String[] pointStatus,
             @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
             @RequestHeader(value = REQUEST_ID_HEADER, required = false) String requestId) {
         CockpitMapSnapshotResponse response = mapSnapshotService.load(
         CockpitMapSnapshotResponse response = mapSnapshotService.load(
-                resolveRequestId(requestId), page, pageSize, snapshotAt, industry, district, deviceType);
+                resolveRequestId(requestId), page, pageSize, snapshotAt, industry, district, deviceType,
+                pointStatus == null ? null : String.join(",", pointStatus));
         return ResponseEntity.ok(AjaxResult.success(response));
         return ResponseEntity.ok(AjaxResult.success(response));
     }
     }
 
 

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

@@ -33,7 +33,7 @@ public class CockpitMonitoringDistributionController {
     public ResponseEntity<AjaxResult> monitoringDistribution(
     public ResponseEntity<AjaxResult> monitoringDistribution(
             @RequestParam(value = "industry", required = false) String industry,
             @RequestParam(value = "industry", required = false) String industry,
             @RequestParam(value = "deviceType", required = false) String deviceType,
             @RequestParam(value = "deviceType", required = false) String deviceType,
-            @RequestParam(value = "pointStatus", required = false) String pointStatus,
+            @RequestParam(value = "pointStatus", required = false) String[] pointStatus,
             // 范围维度自执行票 12 起为片区;旧自由串 region 不再是正式契约,签名里已去掉
             // 范围维度自执行票 12 起为片区;旧自由串 region 不再是正式契约,签名里已去掉
             @RequestParam(value = "district", required = false) String district,
             @RequestParam(value = "district", required = false) String district,
             @RequestParam(value = "page", defaultValue = "1") Integer page,
             @RequestParam(value = "page", defaultValue = "1") Integer page,
@@ -45,7 +45,7 @@ public class CockpitMonitoringDistributionController {
                         resolveRequestId(requestId),
                         resolveRequestId(requestId),
                         industry,
                         industry,
                         deviceType,
                         deviceType,
-                        pointStatus,
+                        pointStatus == null ? null : String.join(",", pointStatus),
                         district,
                         district,
                         page,
                         page,
                         pageSize,
                         pageSize,

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

@@ -24,6 +24,7 @@ import java.util.List;
 
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -131,6 +132,26 @@ class BusinessCockpitDeviceFactResolverTest {
         assertFalse(resolver.resolve(device("DEV-5"), null).isWarning(), "CLOSED 预警不算预警中");
         assertFalse(resolver.resolve(device("DEV-5"), null).isWarning(), "CLOSED 预警不算预警中");
     }
     }
 
 
+    @Test
+    void publishedOfflineAndMissingStatusAreDistinctAndDoNotDependOnTimestamp() {
+        EquipmentStatus offline = status(1, 0, 0);
+        offline.setStatusUpdateTime(null);
+        when(equipmentStatusService.getByDeviceCode("DEV-PUBLISHED")).thenReturn(offline);
+        assertEquals("OFFLINE", resolver.resolve(device("DEV-PUBLISHED"), null).getPublishedDeviceStatus());
+        assertNull(resolver.resolve(device("DEV-MISSING"), null).getPublishedDeviceStatus());
+    }
+
+    @Test
+    void cancelledStatusSevenNeverPublishesWorkOrderState() {
+        when(equipmentStatusService.getByDeviceCode("DEV-CANCELLED")).thenReturn(status(1, 0, 1));
+        when(workOrderService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(order(7)));
+        CockpitMonitoringPointDeviceSnapshot fact = resolver.resolve(device("DEV-CANCELLED"), null);
+        assertFalse(fact.isWorkOrderInProgress());
+        assertEquals("NORMAL", fact.getPublishedDeviceStatus());
+        assertEquals(CockpitMonitoringPointStatus.NORMAL,
+                CockpitMonitoringPointStatusResolver.resolve(Collections.singletonList(fact)));
+    }
+
     // ---- fixtures ----
     // ---- fixtures ----
 
 
     private static EquipmentBase device(String code) {
     private static EquipmentBase device(String code) {

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

@@ -140,6 +140,26 @@ class BusinessCockpitMonitoringOverviewAdapterTest {
                 .findFirst().orElseThrow().getIndustry());
                 .findFirst().orElseThrow().getIndustry());
     }
     }
 
 
+    @Test
+    void realEmptyPointsAndMissingDeviceTypesPublishDistinctAssociationFacts() {
+        stubPoints(Arrays.asList(point("P0", "EMPTY"), point("P1", "UNKNOWN")));
+        stubTypes(Collections.emptyList());
+        EquipmentBase bound = device("D", "BOUND", "99");
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(bound));
+        when(equipmentBaseService.getEquipmentByPoint("P0")).thenReturn(Collections.emptyList());
+        when(equipmentBaseService.getEquipmentByPoint("P1")).thenReturn(Arrays.asList(bound, bound));
+        CockpitMonitoringOverviewSnapshot snapshot = adapter.load();
+        assertNull(snapshot.getMonitoringPoints().get(0).getTypeCode());
+        assertEquals(0, snapshot.getMonitoringPoints().get(0).getAssociatedDeviceCount());
+        assertNull(snapshot.getMonitoringPoints().get(1).getTypeCode());
+        assertEquals(1, snapshot.getMonitoringPoints().get(1).getAssociatedDeviceCount());
+        CockpitMonitoringOverviewService service = new CockpitMonitoringOverviewService(
+                () -> snapshot, Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+        var response = service.load("empty-real", null, null);
+        assertEquals(1, response.getCounts().getMonitoringPointCount());
+        assertEquals(Collections.singletonList("EMPTY"), response.getMapFilter().getPointCodes());
+    }
+
     // ---- helpers ----
     // ---- helpers ----
 
 
     private static String stateOf(CockpitMonitoringOverviewSnapshot snapshot, String deviceCode) {
     private static String stateOf(CockpitMonitoringOverviewSnapshot snapshot, String deviceCode) {

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

@@ -86,6 +86,8 @@ class BusinessCockpitWorkOrderReadAdapterTest {
     void alarmEventResolvesByAlarmIdAndReturnsItsLinkedOrders() {
     void alarmEventResolvesByAlarmIdAndReturnsItsLinkedOrders() {
         AlarmData alarm = alarm(ALARM_ID, ALARM_NO, 279L);
         AlarmData alarm = alarm(ALARM_ID, ALARM_NO, 279L);
         when(alarmDataService.getById(ALARM_ID)).thenReturn(alarm);
         when(alarmDataService.getById(ALARM_ID)).thenReturn(alarm);
+        when(alarmDataService.list(any(LambdaQueryWrapper.class)))
+                .thenReturn(Collections.singletonList(alarm));
         when(workOrderService.list(any(LambdaQueryWrapper.class)))
         when(workOrderService.list(any(LambdaQueryWrapper.class)))
                 .thenReturn(Collections.singletonList(order(279L, "WO-279", 5)));
                 .thenReturn(Collections.singletonList(order(279L, "WO-279", 5)));
 
 

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

@@ -0,0 +1,157 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.base.service.GasPipePointService;
+import com.zksy.base.service.ManholeBaseService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Feature;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Properties;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryService;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+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.math.BigDecimal;
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.nullValue;
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+/** Standalone MVC tests lock JSON/routing, not the deployed authentication chain. */
+class CockpitFacilityGeometryControllerTest {
+    private static final String URL = "/api/cockpit/v1/infrastructure/geometry";
+    private CockpitFacilityGeometryService service;
+    private MockMvc mvc;
+
+    @BeforeEach
+    void setUp() {
+        service = mock(CockpitFacilityGeometryService.class);
+        mvc = MockMvcBuilders.standaloneSetup(new CockpitFacilityGeometryController(service,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC))).build();
+    }
+
+    @Test
+    void returnsGeoJsonInsideTheExistingAjaxEnvelopeWithoutRequiringAnAuthorizationHeader() throws Exception {
+        PipeNetworkBaseService networks = mock(PipeNetworkBaseService.class);
+        GasPipePointService points = mock(GasPipePointService.class);
+        ManholeBaseService manholes = mock(ManholeBaseService.class);
+        when(networks.list()).thenReturn(Collections.emptyList());
+        when(points.list()).thenReturn(Collections.emptyList());
+        when(manholes.list()).thenReturn(Collections.emptyList());
+        CockpitFacilityGeometryResponse response = new CockpitFacilityGeometryService(networks, points, manholes,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC)).load();
+        when(service.load()).thenReturn(response);
+        mvc.perform(get(URL))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(200))
+                .andExpect(jsonPath("$.data.type").value("FeatureCollection"))
+                .andExpect(jsonPath("$.data.features", hasSize(0)))
+                .andExpect(jsonPath("$.data.coverage", hasSize(9)))
+                .andExpect(jsonPath("$.data.coverage[4].state").value("UNAVAILABLE"));
+    }
+
+    @Test
+    void invalidGeometryIsExplicitJsonNullWithRawCoordinatesAndSameValidationShape() throws Exception {
+        Properties properties = new Properties("gas_pipe_point", "1", "G1", "阀门", "GAS", "GAS_PIPE_POINT",
+                null, "阀门", null, Collections.singletonList(Arrays.asList(null, new BigDecimal("28.4"))),
+                CockpitCoordinateValidator.validate(null, new BigDecimal("28.4"), true),
+                Collections.singletonList(CockpitCoordinateValidator.validate(null, new BigDecimal("28.4"), true)));
+        when(service.load()).thenReturn(new CockpitFacilityGeometryResponse("2026-10-12T10:00:00+08:00",
+                Collections.singletonList(new Feature("gas_pipe_point:1", null, properties)), Collections.emptyList()));
+        mvc.perform(get(URL))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.features[0].type").value("Feature"))
+                .andExpect(jsonPath("$.data.features[0].geometry").value(nullValue()))
+                .andExpect(jsonPath("$.data.features[0].properties.networkId").value(nullValue()))
+                .andExpect(jsonPath("$.data.features[0].properties.pointType").value("阀门"))
+                .andExpect(jsonPath("$.data.features[0].properties.sourceCoordinates[0][0]").value(nullValue()))
+                .andExpect(jsonPath("$.data.features[0].properties.coordinateValidation.state").value("INVALID"))
+                .andExpect(jsonPath("$.data.features[0].properties.coordinateValidation.reason").value("MISSING_LONGITUDE"))
+                .andExpect(jsonPath("$.data.features[0].properties.coordinateValidation.renderable").value(false))
+                .andExpect(jsonPath("$.data.features[0].properties.coordinateValidation.crs").value("WGS84"));
+    }
+
+    @Test
+    void sourceFailureReturns500AndStableCategoryRatherThanSuccess() throws Exception {
+        when(service.load()).thenThrow(new CockpitReadException("private database details"));
+        mvc.perform(get(URL).header("X-Request-Id", "geometry-failure"))
+                .andExpect(status().isInternalServerError())
+                .andExpect(jsonPath("$.code").value(500))
+                .andExpect(jsonPath("$.data.category").value("SERVER_ERROR"))
+                .andExpect(jsonPath("$.data.message").value("facility geometry source unavailable"))
+                .andExpect(jsonPath("$.data.requestId").value("geometry-failure"));
+    }
+
+    @Test
+    void serializesActualServicePointAndLineCoordinatesInLongitudeLatitudeOrder() throws Exception {
+        PipeNetworkBaseService networks = mock(PipeNetworkBaseService.class);
+        GasPipePointService points = mock(GasPipePointService.class);
+        ManholeBaseService manholes = mock(ManholeBaseService.class);
+        com.zksy.base.domain.PipeNetworkBase line = new com.zksy.base.domain.PipeNetworkBase();
+        line.setNetworkId("gas-line");
+        line.setNetworkType("0");
+        line.setStartLongitude(new BigDecimal("110.4"));
+        line.setStartLatitude(new BigDecimal("28.4"));
+        line.setEndLongitude(new BigDecimal("110.6"));
+        line.setEndLatitude(new BigDecimal("28.6"));
+        com.zksy.base.domain.GasPipePoint point = new com.zksy.base.domain.GasPipePoint();
+        point.setPointId(1L);
+        point.setPointType("三通");
+        point.setNetworkId("gas-line");
+        point.setLongitude(new BigDecimal("110.5"));
+        point.setLatitude(new BigDecimal("28.5"));
+        when(networks.list()).thenReturn(Collections.singletonList(line));
+        when(points.list()).thenReturn(Collections.singletonList(point));
+        when(manholes.list()).thenReturn(Collections.emptyList());
+        CockpitFacilityGeometryService actual = new CockpitFacilityGeometryService(networks, points, manholes,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC));
+        mvc = MockMvcBuilders.standaloneSetup(new CockpitFacilityGeometryController(actual,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC))).build();
+        mvc.perform(get(URL))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.features", hasSize(2)))
+                .andExpect(jsonPath("$.data.features[0].geometry.type").value("LineString"))
+                .andExpect(jsonPath("$.data.features[0].geometry.coordinates", hasSize(2)))
+                .andExpect(jsonPath("$.data.features[0].geometry.coordinates[0][0]").value(110.4))
+                .andExpect(jsonPath("$.data.features[0].geometry.coordinates[0][1]").value(28.4))
+                .andExpect(jsonPath("$.data.features[0].geometry.coordinates[1][0]").value(110.6))
+                .andExpect(jsonPath("$.data.features[0].geometry.coordinates[1][1]").value(28.6))
+                .andExpect(jsonPath("$.data.features[1].geometry.type").value("Point"))
+                .andExpect(jsonPath("$.data.features[1].geometry.coordinates", hasSize(2)))
+                .andExpect(jsonPath("$.data.features[1].geometry.coordinates[0]").value(110.5))
+                .andExpect(jsonPath("$.data.features[1].geometry.coordinates[1]").value(28.5))
+                .andExpect(jsonPath("$.data.features[1].properties.pointType").value("三通"))
+                .andExpect(jsonPath("$.data.features[1].properties.networkId").value("gas-line"))
+                .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.state").value("UNVERIFIED"))
+                .andExpect(jsonPath("$.data.features[1].properties.coordinateValidation.renderable").value(false));
+    }
+
+    @Test
+    void transactionProxyFailureIsAlsoMappedToSanitized500() throws Exception {
+        when(service.load()).thenThrow(new org.springframework.transaction.CannotCreateTransactionException(
+                "private connection detail"));
+        mvc.perform(get(URL).header("X-Request-Id", "transaction-failure"))
+                .andExpect(status().isInternalServerError())
+                .andExpect(jsonPath("$.code").value(500))
+                .andExpect(jsonPath("$.data.category").value("SERVER_ERROR"))
+                .andExpect(jsonPath("$.data.message").value("facility geometry source unavailable"))
+                .andExpect(jsonPath("$.data.requestId").value("transaction-failure"));
+    }
+
+    @Test
+    void postIsNotAWriteEntryPoint() throws Exception {
+        mvc.perform(post(URL)).andExpect(status().isMethodNotAllowed());
+        verifyNoInteractions(service);
+    }
+}

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

@@ -0,0 +1,214 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.base.domain.GasPipePoint;
+import com.zksy.base.domain.ManholeBase;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.GasPipePointService;
+import com.zksy.base.service.ManholeBaseService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Coverage;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Feature;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+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 java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+class CockpitFacilityGeometryServiceTest {
+    private PipeNetworkBaseService networks;
+    private GasPipePointService points;
+    private ManholeBaseService manholes;
+    private CockpitFacilityGeometryService service;
+
+    @BeforeEach
+    void setUp() {
+        networks = mock(PipeNetworkBaseService.class);
+        points = mock(GasPipePointService.class);
+        manholes = mock(ManholeBaseService.class);
+        when(networks.list()).thenReturn(Collections.emptyList());
+        when(points.list()).thenReturn(Collections.emptyList());
+        when(manholes.list()).thenReturn(Collections.emptyList());
+        service = new CockpitFacilityGeometryService(networks, points, manholes,
+                Clock.fixed(Instant.parse("2026-10-12T02:00:00Z"), ZoneOffset.UTC));
+    }
+
+    @Test
+    void readsAllThreeIndustriesAsActualTwoEndpointLinesWithoutInventingTopology() {
+        when(networks.list()).thenReturn(Arrays.asList(network("same-id", "0"), network("water", "2"),
+                network("drain", "1"), network("unknown", "3")));
+        GasPipePoint point = point(1L, "三通");
+        point.setNetworkId("same-id");
+        when(points.list()).thenReturn(Collections.singletonList(point));
+        ManholeBase manhole = new ManholeBase();
+        manhole.setManholeId("same-id");
+        manhole.setLongitude(new BigDecimal("110.5"));
+        manhole.setLatitude(new BigDecimal("28.5"));
+        when(manholes.list()).thenReturn(Collections.singletonList(manhole));
+
+        CockpitFacilityGeometryResponse response = service.load();
+        assertEquals("FeatureCollection", response.getType());
+        assertEquals("2026-10-12T10:00:00+08:00", response.getGeneratedAt());
+        assertEquals(6, response.getFeatures().size());
+        assertEquals(6, response.getFeatures().stream().map(Feature::getId).distinct().count());
+        assertEquals(Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE", "UNKNOWN", "GAS", "MANHOLE"),
+                response.getFeatures().stream().map(item -> item.getProperties().getIndustry()).collect(Collectors.toList()));
+        Feature gas = response.getFeatures().get(0);
+        assertEquals("LineString", gas.getGeometry().getType());
+        assertEquals(Arrays.asList(Arrays.asList(new BigDecimal("110.4"), new BigDecimal("28.4")),
+                Arrays.asList(new BigDecimal("110.6"), new BigDecimal("28.6"))), gas.getGeometry().getCoordinates());
+        assertEquals("GAS_PIPE", gas.getProperties().getTypeCode());
+        assertEquals("PIPE_UNCLASSIFIED", response.getFeatures().get(3).getProperties().getTypeCode());
+        assertEquals("3", response.getFeatures().get(3).getProperties().getNetworkType());
+        Feature component = response.getFeatures().get(4);
+        assertEquals("Point", component.getGeometry().getType());
+        assertEquals("三通", component.getProperties().getPointType());
+        assertEquals(gas.getProperties().getNetworkId(), component.getProperties().getNetworkId());
+        assertEquals(1, coverage(response, "UNKNOWN", "LineString").getRecordCount());
+        verify(networks).list();
+        verify(points).list();
+        verify(manholes).list();
+        verifyNoMoreInteractions(networks, points, manholes);
+    }
+
+    @Test
+    void preservesEveryComponentTypeIncludingUnknownAndMissingTypesWithoutFabricatingNodes() {
+        List<String> types = Arrays.asList("阀门", "调压", "计量", "阴极保护", "弯头", "三通", "其它", "未知原始值", null);
+        List<GasPipePoint> records = new java.util.ArrayList<>();
+        for (int i = 0; i < types.size(); i++) {
+            records.add(point((long) i, types.get(i)));
+        }
+        when(points.list()).thenReturn(records);
+        CockpitFacilityGeometryResponse response = service.load();
+        assertEquals(types, response.getFeatures().stream()
+                .map(item -> item.getProperties().getPointType()).collect(Collectors.toList()));
+        assertEquals(types.size(), response.getFeatures().size());
+        assertTrue(response.getFeatures().stream().allMatch(item -> item.getProperties().getNetworkId() == null));
+    }
+
+    @ParameterizedTest
+    @CsvSource({",28.4,MISSING_LONGITUDE", "110.4,,MISSING_LATITUDE", "181,28.4,LONGITUDE_OUT_OF_RANGE",
+            "-181,28.4,LONGITUDE_OUT_OF_RANGE", "110.4,91,LATITUDE_OUT_OF_RANGE",
+            "110.4,-91,LATITUDE_OUT_OF_RANGE", "0,0,ZERO_COORDINATE"})
+    void invalidPointsStayInTheCollectionWithNullGeometryAndSpecificReason(String longitude, String latitude,
+            String reason) {
+        GasPipePoint point = point(1L, "阀门");
+        point.setLongitude(decimal(longitude));
+        point.setLatitude(decimal(latitude));
+        when(points.list()).thenReturn(Collections.singletonList(point));
+        Feature feature = service.load().getFeatures().get(0);
+        assertNull(feature.getGeometry());
+        assertEquals("INVALID", feature.getProperties().getCoordinateValidation().getState());
+        assertEquals(reason, feature.getProperties().getCoordinateValidation().getReason());
+        assertFalse(feature.getProperties().getCoordinateValidation().isRenderable());
+        assertEquals(Arrays.asList(decimal(longitude), decimal(latitude)),
+                feature.getProperties().getSourceCoordinates().get(0));
+    }
+
+    @Test
+    void invalidEndIsNotMaskedByAnUnverifiedStartAndEntireLineHasNullGeometry() {
+        PipeNetworkBase line = network("bad-end", "1");
+        line.setEndLatitude(null);
+        when(networks.list()).thenReturn(Collections.singletonList(line));
+        CockpitFacilityGeometryResponse response = service.load();
+        Feature feature = response.getFeatures().get(0);
+        assertNull(feature.getGeometry());
+        assertEquals("MISSING_LATITUDE", feature.getProperties().getCoordinateValidation().getReason());
+        assertEquals("UNVERIFIED", feature.getProperties().getCoordinateValidations().get(0).getState());
+        assertEquals("INVALID", feature.getProperties().getCoordinateValidations().get(1).getState());
+        assertEquals(1, coverage(response, "DRAINAGE", "LineString").getRecordCount());
+        assertEquals(0, coverage(response, "DRAINAGE", "LineString").getGeometryCount());
+    }
+
+    @Test
+    void numericBoundsDoNotGrantCoordinateVerificationForAnySource() {
+        when(networks.list()).thenReturn(Collections.singletonList(network("line", "0")));
+        when(points.list()).thenReturn(Collections.singletonList(point(1L, "阀门")));
+        ManholeBase manhole = new ManholeBase();
+        manhole.setManholeId("well");
+        manhole.setLongitude(new BigDecimal("-180"));
+        manhole.setLatitude(new BigDecimal("90"));
+        when(manholes.list()).thenReturn(Collections.singletonList(manhole));
+        CockpitFacilityGeometryResponse response = service.load();
+        for (Feature feature : response.getFeatures()) {
+            assertNotNull(feature.getGeometry());
+            assertEquals("UNVERIFIED", feature.getProperties().getCoordinateValidation().getState());
+            assertEquals("UNVERIFIED_COORDINATE", feature.getProperties().getCoordinateValidation().getReason());
+            assertEquals("WGS84", feature.getProperties().getCoordinateValidation().getCrs());
+            assertFalse(feature.getProperties().getCoordinateValidation().isRenderable());
+        }
+        assertTrue(response.getCoverage().stream().allMatch(item -> item.getRenderableCount() == 0));
+    }
+
+    @Test
+    void emptySourcesAreDistinguishedFromUnsupportedIndustryGeometry() {
+        CockpitFacilityGeometryResponse response = service.load();
+        assertTrue(response.getFeatures().isEmpty());
+        assertEquals("EMPTY", coverage(response, "GAS", "Point").getState());
+        assertEquals("EMPTY", coverage(response, "WATER_SUPPLY", "LineString").getState());
+        assertEquals("TWO_ENDPOINTS_ONLY", coverage(response, "WATER_SUPPLY", "LineString").getReason());
+        assertEquals("UNAVAILABLE", coverage(response, "WATER_SUPPLY", "Point").getState());
+        assertEquals("NO_COMPONENT_SOURCE", coverage(response, "WATER_SUPPLY", "Point").getReason());
+        assertEquals("NO_TYPED_COMPONENT_SOURCE", coverage(response, "DRAINAGE", "Point").getReason());
+        assertEquals("NO_COMPONENT_TYPE", coverage(response, "MANHOLE", "Point").getReason());
+        assertEquals("NO_PIPELINE_SOURCE", coverage(response, "MANHOLE", "LineString").getReason());
+    }
+
+    @Test
+    void aFailedSourceNeverProducesAnEmptyOrPartialSuccess() {
+        when(networks.list()).thenReturn(Collections.singletonList(network("line", "0")));
+        when(points.list()).thenThrow(new IllegalStateException("private database detail"));
+        CockpitReadException failure = assertThrows(CockpitReadException.class, service::load);
+        assertEquals("facility geometry source unavailable", failure.getMessage());
+        verifyNoInteractions(manholes);
+    }
+
+    @Test
+    void aNullSourceIsAReadFailureRatherThanASuccessfulEmptyCollection() {
+        when(manholes.list()).thenReturn(null);
+        assertThrows(CockpitReadException.class, service::load);
+    }
+
+    private static Coverage coverage(CockpitFacilityGeometryResponse response, String industry, String geometry) {
+        return response.getCoverage().stream().filter(item -> industry.equals(item.getIndustry())
+                && geometry.equals(item.getGeometryType())).findFirst().orElseThrow();
+    }
+
+    private static PipeNetworkBase network(String id, String type) {
+        PipeNetworkBase network = new PipeNetworkBase();
+        network.setNetworkId(id);
+        network.setNetworkCode("code-" + id);
+        network.setNetworkType(type);
+        network.setStartLongitude(new BigDecimal("110.4"));
+        network.setStartLatitude(new BigDecimal("28.4"));
+        network.setEndLongitude(new BigDecimal("110.6"));
+        network.setEndLatitude(new BigDecimal("28.6"));
+        return network;
+    }
+
+    private static GasPipePoint point(Long id, String type) {
+        GasPipePoint point = new GasPipePoint();
+        point.setPointId(id);
+        point.setPointType(type);
+        point.setLongitude(new BigDecimal("110.4"));
+        point.setLatitude(new BigDecimal("28.4"));
+        return point;
+    }
+
+    private static BigDecimal decimal(String value) {
+        return value == null ? null : new BigDecimal(value);
+    }
+}

+ 139 - 32
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringDistributionControllerTest.java

@@ -63,7 +63,7 @@ class CockpitMonitoringDistributionControllerTest {
     }
     }
 
 
     @Test
     @Test
-    void distributionExposesEnvelopeSixStateDistributionDistrictIndustryTypeAndMapFilter() throws Exception {
+    void distributionExposesEnvelopeGlobalEightStateDistributionAndMapFilter() throws Exception {
         mockMvc.perform(get(ENDPOINT)
         mockMvc.perform(get(ENDPOINT)
                         .param("snapshotAt", SNAPSHOT_AT)
                         .param("snapshotAt", SNAPSHOT_AT)
                         .header("X-Request-Id", "monitoring-distribution-001"))
                         .header("X-Request-Id", "monitoring-distribution-001"))
@@ -76,7 +76,7 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(jsonPath("$.data.timezone").value("Asia/Shanghai"))
                 .andExpect(jsonPath("$.data.timezone").value("Asia/Shanghai"))
                 .andExpect(jsonPath("$.data.pagination.page").value(1))
                 .andExpect(jsonPath("$.data.pagination.page").value(1))
                 .andExpect(jsonPath("$.data.pagination.pageSize").value(500))
                 .andExpect(jsonPath("$.data.pagination.pageSize").value(500))
-                .andExpect(jsonPath("$.data.pagination.total").value(8))
+                .andExpect(jsonPath("$.data.pagination.total").value(9))
                 .andExpect(jsonPath("$.data.pagination.totalPages").value(1))
                 .andExpect(jsonPath("$.data.pagination.totalPages").value(1))
                 .andExpect(jsonPath("$.data.pagination.hasMore").value(false))
                 .andExpect(jsonPath("$.data.pagination.hasMore").value(false))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
@@ -91,31 +91,31 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(jsonPath("$.data.monitoringPoints[3].pointStatus").value("WORK_ORDER"))
                 .andExpect(jsonPath("$.data.monitoringPoints[3].pointStatus").value("WORK_ORDER"))
                 .andExpect(jsonPath("$.data.monitoringPoints[4].pointCode").value("P-WS-2"))
                 .andExpect(jsonPath("$.data.monitoringPoints[4].pointCode").value("P-WS-2"))
                 .andExpect(jsonPath("$.data.monitoringPoints[4].pointStatus").value("EMPTY"))
                 .andExpect(jsonPath("$.data.monitoringPoints[4].pointStatus").value("EMPTY"))
-                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(3)))
+                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(4)))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].deviceCode").value("EQ-FREE-001"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].deviceCode").value("EQ-FREE-001"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].pointStatus").value("NORMAL"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[0].pointStatus").value("NORMAL"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[1].deviceCode").value("EQ-FREE-002"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[1].deviceCode").value("EQ-FREE-002"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[1].pointStatus").value("WARNING"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[1].pointStatus").value("WARNING"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[2].deviceCode").value("EQ-FREE-003"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[2].deviceCode").value("EQ-FREE-003"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[2].pointStatus").value("OFFLINE"))
                 .andExpect(jsonPath("$.data.unassociatedEquipment[2].pointStatus").value("OFFLINE"))
-                .andExpect(jsonPath("$.data.pointStatusDistribution", hasSize(6)))
+                .andExpect(jsonPath("$.data.pointStatusDistribution", hasSize(8)))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].status").value("ALARM"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].status").value("ALARM"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[1].status").value("WARNING"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[1].status").value("WARNING"))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(2))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[2].status").value("WORK_ORDER"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[2].status").value("WORK_ORDER"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[2].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[2].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[3].status").value("NORMAL"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[3].status").value("NORMAL"))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(1))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(2))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[4].status").value("OFFLINE"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[4].status").value("OFFLINE"))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(2))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[5].status").value("EMPTY"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[5].status").value("EMPTY"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[5].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[5].count").value(1))
                 .andExpect(jsonPath("$.data.districtDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.districtDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.districtDistribution[0].district").value(0))
                 .andExpect(jsonPath("$.data.districtDistribution[0].district").value(0))
                 .andExpect(jsonPath("$.data.districtDistribution[0].districtName").value("城南"))
                 .andExpect(jsonPath("$.data.districtDistribution[0].districtName").value("城南"))
                 .andExpect(jsonPath("$.data.districtDistribution[0].pointCount").value(2))
                 .andExpect(jsonPath("$.data.districtDistribution[0].pointCount").value(2))
-                .andExpect(jsonPath("$.data.districtDistribution[0].deviceCount").value(4))
+                .andExpect(jsonPath("$.data.districtDistribution[0].deviceCount").value(5))
                 .andExpect(jsonPath("$.data.districtDistribution[1].district").value(1))
                 .andExpect(jsonPath("$.data.districtDistribution[1].district").value(1))
                 .andExpect(jsonPath("$.data.districtDistribution[1].districtName").value("城北"))
                 .andExpect(jsonPath("$.data.districtDistribution[1].districtName").value("城北"))
                 .andExpect(jsonPath("$.data.districtDistribution[1].pointCount").value(2))
                 .andExpect(jsonPath("$.data.districtDistribution[1].pointCount").value(2))
@@ -127,14 +127,14 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(jsonPath("$.data.industryDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.industryDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
                 .andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
                 .andExpect(jsonPath("$.data.industryDistribution[0].pointCount").value(2))
                 .andExpect(jsonPath("$.data.industryDistribution[0].pointCount").value(2))
-                .andExpect(jsonPath("$.data.industryDistribution[0].deviceCount").value(4))
+                .andExpect(jsonPath("$.data.industryDistribution[0].deviceCount").value(5))
                 .andExpect(jsonPath("$.data.industryDistribution[1].industry").value("WATER_SUPPLY"))
                 .andExpect(jsonPath("$.data.industryDistribution[1].industry").value("WATER_SUPPLY"))
                 .andExpect(jsonPath("$.data.industryDistribution[1].deviceCount").value(2))
                 .andExpect(jsonPath("$.data.industryDistribution[1].deviceCount").value(2))
                 .andExpect(jsonPath("$.data.industryDistribution[2].industry").value("DRAINAGE"))
                 .andExpect(jsonPath("$.data.industryDistribution[2].industry").value("DRAINAGE"))
                 .andExpect(jsonPath("$.data.industryDistribution[2].deviceCount").value(2))
                 .andExpect(jsonPath("$.data.industryDistribution[2].deviceCount").value(2))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(3)))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"))
-                .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceCount").value(4))
+                .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceCount").value(5))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[1].deviceType.code").value("SEWAGE_ENV"))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[1].deviceType.code").value("SEWAGE_ENV"))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[2].deviceType.code").value("WATER_SUPPLY_SENSOR"))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[2].deviceType.code").value("WATER_SUPPLY_SENSOR"))
                 .andExpect(jsonPath("$.data.mapFilter.industry").value(nullValue()))
                 .andExpect(jsonPath("$.data.mapFilter.industry").value(nullValue()))
@@ -144,11 +144,11 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(jsonPath("$.data.mapFilter.districtName").value(nullValue()))
                 .andExpect(jsonPath("$.data.mapFilter.districtName").value(nullValue()))
                 .andExpect(jsonPath("$.data.mapFilter.districtFilter").value("NONE"))
                 .andExpect(jsonPath("$.data.mapFilter.districtFilter").value("NONE"))
                 .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(5)))
                 .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(5)))
-                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(8)))
+                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(9)))
                 .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(1))
                 .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(1))
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(1))
                 .andExpect(jsonPath("$.data.excluded.typeKindMismatchCount").value(1))
                 .andExpect(jsonPath("$.data.excluded.nonFormalIndustryCount").value(1))
                 .andExpect(jsonPath("$.data.excluded.nonFormalIndustryCount").value(1))
-                .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(1))
+                .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
                 .andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
                 .andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
                 .andExpect(jsonPath("$.data.freshness.reason").value("READY"));
                 .andExpect(jsonPath("$.data.freshness.reason").value("READY"));
     }
     }
@@ -157,24 +157,24 @@ class CockpitMonitoringDistributionControllerTest {
     void associatedDevicesRenderAsOnePointAndPaginationMatchesStatusTotals() throws Exception {
     void associatedDevicesRenderAsOnePointAndPaginationMatchesStatusTotals() throws Exception {
         mockMvc.perform(get(ENDPOINT))
         mockMvc.perform(get(ENDPOINT))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.pagination.total").value(8))
+                .andExpect(jsonPath("$.data.pagination.total").value(9))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(5)))
-                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(3)));
+                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(4)));
     }
     }
 
 
     @Test
     @Test
     void industryFilterNarrowsDistributionAndMapFilter() throws Exception {
     void industryFilterNarrowsDistributionAndMapFilter() throws Exception {
         mockMvc.perform(get(ENDPOINT).param("industry", "GAS"))
         mockMvc.perform(get(ENDPOINT).param("industry", "GAS"))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.pagination.total").value(3))
+                .andExpect(jsonPath("$.data.pagination.total").value(4))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(2)))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(2)))
-                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(1)))
+                .andExpect(jsonPath("$.data.unassociatedEquipment", hasSize(2)))
                 .andExpect(jsonPath("$.data.mapFilter.industry").value("GAS"))
                 .andExpect(jsonPath("$.data.mapFilter.industry").value("GAS"))
                 .andExpect(jsonPath("$.data.industryDistribution", hasSize(1)))
                 .andExpect(jsonPath("$.data.industryDistribution", hasSize(1)))
                 .andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
                 .andExpect(jsonPath("$.data.industryDistribution[0].industry").value("GAS"))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(1))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[3].count").value(2))
                 .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1));
                 .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1));
     }
     }
 
 
@@ -182,7 +182,7 @@ class CockpitMonitoringDistributionControllerTest {
     void deviceTypeFilterNarrowsDistribution() throws Exception {
     void deviceTypeFilterNarrowsDistribution() throws Exception {
         mockMvc.perform(get(ENDPOINT).param("deviceType", "GAS_SENSOR"))
         mockMvc.perform(get(ENDPOINT).param("deviceType", "GAS_SENSOR"))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.pagination.total").value(3))
+                .andExpect(jsonPath("$.data.pagination.total").value(4))
                 .andExpect(jsonPath("$.data.mapFilter.deviceType").value("GAS_SENSOR"))
                 .andExpect(jsonPath("$.data.mapFilter.deviceType").value("GAS_SENSOR"))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(1)))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution", hasSize(1)))
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"));
                 .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value("GAS_SENSOR"));
@@ -194,13 +194,13 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.pagination.total").value(2))
                 .andExpect(jsonPath("$.data.pagination.total").value(2))
                 .andExpect(jsonPath("$.data.mapFilter.pointStatus").value("WARNING"))
                 .andExpect(jsonPath("$.data.mapFilter.pointStatus").value("WARNING"))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(0))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(2))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(0));
+                .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[1].count").value(1))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[4].count").value(1));
 
 
         mockMvc.perform(get(ENDPOINT))
         mockMvc.perform(get(ENDPOINT))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.pagination.total").value(8))
+                .andExpect(jsonPath("$.data.pagination.total").value(9))
                 .andExpect(jsonPath("$.data.mapFilter.pointStatus").value(nullValue()));
                 .andExpect(jsonPath("$.data.mapFilter.pointStatus").value(nullValue()));
     }
     }
 
 
@@ -253,7 +253,7 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.pagination.total").value(0))
                 .andExpect(jsonPath("$.data.pagination.total").value(0))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(0)))
                 .andExpect(jsonPath("$.data.monitoringPoints", hasSize(0)))
-                .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(0))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[0].count").value(1))
                 .andExpect(jsonPath("$.data.mapFilter.deviceType").value("NOT_A_TYPE"))
                 .andExpect(jsonPath("$.data.mapFilter.deviceType").value("NOT_A_TYPE"))
                 .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
                 .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
                 .andExpect(jsonPath("$.data.freshness.status").value("EMPTY"))
                 .andExpect(jsonPath("$.data.freshness.status").value("EMPTY"))
@@ -279,7 +279,7 @@ class CockpitMonitoringDistributionControllerTest {
                 .andExpect(jsonPath("$.code").value(400))
                 .andExpect(jsonPath("$.code").value(400))
                 .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
                 .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"))
                 .andExpect(jsonPath("$.data.message").value(
                 .andExpect(jsonPath("$.data.message").value(
-                        "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE or EMPTY"));
+                        "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE, EMPTY, UNKNOWN or UNASSOCIATED"));
 
 
         verifyNoInteractions(adapter);
         verifyNoInteractions(adapter);
     }
     }
@@ -351,8 +351,8 @@ class CockpitMonitoringDistributionControllerTest {
     void webSocketDeltaRecomputesStatusCountsAndIgnoresOldOrUnknownDeltas() {
     void webSocketDeltaRecomputesStatusCountsAndIgnoresOldOrUnknownDeltas() {
         CockpitMonitoringDistributionResponse initial = service.load(
         CockpitMonitoringDistributionResponse initial = service.load(
                 "delta-baseline", null, null, null, null, 1, 100, SNAPSHOT_AT);
                 "delta-baseline", null, null, null, null, 1, 100, SNAPSHOT_AT);
-        assertEquals(2, statusCount(initial, CockpitMonitoringPointStatus.OFFLINE));
-        assertEquals(1, statusCount(initial, CockpitMonitoringPointStatus.NORMAL));
+        assertEquals(1, statusCount(initial, CockpitMonitoringPointStatus.OFFLINE));
+        assertEquals(2, statusCount(initial, CockpitMonitoringPointStatus.NORMAL));
 
 
         CockpitMonitoringDistributionResponse applied = service.applyDeviceStatusDelta(
         CockpitMonitoringDistributionResponse applied = service.applyDeviceStatusDelta(
                 "delta-1", null, null, null, null, 1, 100, SNAPSHOT_AT,
                 "delta-1", null, null, null, null, 1, 100, SNAPSHOT_AT,
@@ -360,8 +360,8 @@ class CockpitMonitoringDistributionControllerTest {
                         "GAS-003", null, "ONLINE", "2026-09-02T09:59:00+08:00",
                         "GAS-003", null, "ONLINE", "2026-09-02T09:59:00+08:00",
                         "2026-09-02T10:05:00+08:00"));
                         "2026-09-02T10:05:00+08:00"));
 
 
-        assertEquals(1, statusCount(applied, CockpitMonitoringPointStatus.OFFLINE));
-        assertEquals(2, statusCount(applied, CockpitMonitoringPointStatus.NORMAL));
+        assertEquals(0, statusCount(applied, CockpitMonitoringPointStatus.OFFLINE));
+        assertEquals(3, statusCount(applied, CockpitMonitoringPointStatus.NORMAL));
 
 
         CockpitMonitoringDistributionResponse ignoredOld = service.applyDeviceStatusDelta(
         CockpitMonitoringDistributionResponse ignoredOld = service.applyDeviceStatusDelta(
                 "delta-2", null, null, null, null, 1, 100, SNAPSHOT_AT,
                 "delta-2", null, null, null, null, 1, 100, SNAPSHOT_AT,
@@ -369,8 +369,8 @@ class CockpitMonitoringDistributionControllerTest {
                         "GAS-003", null, "OFFLINE", "2026-09-02T09:59:00+08:00",
                         "GAS-003", null, "OFFLINE", "2026-09-02T09:59:00+08:00",
                         "2026-09-02T10:04:00+08:00"));
                         "2026-09-02T10:04:00+08:00"));
 
 
-        assertEquals(1, statusCount(ignoredOld, CockpitMonitoringPointStatus.OFFLINE));
-        assertEquals(2, statusCount(ignoredOld, CockpitMonitoringPointStatus.NORMAL));
+        assertEquals(0, statusCount(ignoredOld, CockpitMonitoringPointStatus.OFFLINE));
+        assertEquals(3, statusCount(ignoredOld, CockpitMonitoringPointStatus.NORMAL));
 
 
         CockpitMonitoringDistributionResponse ignoredUnknown = service.applyDeviceStatusDelta(
         CockpitMonitoringDistributionResponse ignoredUnknown = service.applyDeviceStatusDelta(
                 "delta-3", null, null, null, null, 1, 100, SNAPSHOT_AT,
                 "delta-3", null, null, null, null, 1, 100, SNAPSHOT_AT,
@@ -378,8 +378,115 @@ class CockpitMonitoringDistributionControllerTest {
                         "NO-SUCH-DEVICE", null, "ONLINE", "2026-09-02T09:59:00+08:00",
                         "NO-SUCH-DEVICE", null, "ONLINE", "2026-09-02T09:59:00+08:00",
                         "2026-09-02T10:06:00+08:00"));
                         "2026-09-02T10:06:00+08:00"));
 
 
-        assertEquals(1, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.OFFLINE));
-        assertEquals(2, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.NORMAL));
+        assertEquals(0, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.OFFLINE));
+        assertEquals(3, statusCount(ignoredUnknown, CockpitMonitoringPointStatus.NORMAL));
+    }
+
+    @Test
+    void sixEmptyUntypedPointsRemainInLedgerAndStatusTotalsWithoutVerifiedCoordinates() throws Exception {
+        List<CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint> points = new java.util.ArrayList<>();
+        for (String code : Arrays.asList("GS001", "GS002", "PS001", "PS002", "RQ001", "RQ002")) {
+            points.add(new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(
+                    code, code, null, null, new BigDecimal("110.399876"), new BigDecimal("28.458287"),
+                    false, Collections.emptyList()));
+        }
+        CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, SNAPSHOT_AT, Collections.emptyList(), points, Collections.emptyList());
+        when(adapter.load(null)).thenReturn(snapshot);
+        when(adapter.load(SNAPSHOT_AT)).thenReturn(snapshot);
+
+        mockMvc.perform(get(ENDPOINT).param("pointStatus", "EMPTY").param("pageSize", "2"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.pagination.total").value(6))
+                .andExpect(jsonPath("$.data.pagination.totalPages").value(3))
+                .andExpect(jsonPath("$.data.pagination.hasMore").value(true))
+                .andExpect(jsonPath("$.data.monitoringPoints", hasSize(2)))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].pointCode").value("GS001"))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].pointStatus").value("EMPTY"))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].industry").value(nullValue()))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].deviceType.code").value(nullValue()))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].coordinateValidation.renderable").value(false))
+                .andExpect(jsonPath("$.data.pointStatusDistribution[5].count").value(6))
+                .andExpect(jsonPath("$.data.districtDistribution[0].districtName").value("未分区"))
+                .andExpect(jsonPath("$.data.districtDistribution[0].pointCount").value(6))
+                .andExpect(jsonPath("$.data.industryDistribution[0].industry").value(nullValue()))
+                .andExpect(jsonPath("$.data.industryDistribution[0].pointCount").value(6))
+                .andExpect(jsonPath("$.data.deviceTypeDistribution[0].deviceType.code").value(nullValue()))
+                .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(6)))
+                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(0)))
+                .andExpect(jsonPath("$.data.excluded.unknownTypeCount").value(0))
+                .andExpect(jsonPath("$.data.excluded.invalidCoordinateCount").value(0))
+                .andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
+                .andExpect(jsonPath("$.data.freshness.reason").value("READY"));
+        mockMvc.perform(get(ENDPOINT).param("page", "3").param("pageSize", "2").param("snapshotAt", SNAPSHOT_AT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.pagination.total").value(6))
+                .andExpect(jsonPath("$.data.pagination.hasMore").value(false))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].pointCode").value("RQ001"));
+        mockMvc.perform(get(ENDPOINT).param("district", "UNASSIGNED"))
+                .andExpect(status().isOk()).andExpect(jsonPath("$.data.pagination.total").value(6));
+        for (String[] filter : Arrays.asList(new String[]{"industry", "GAS"},
+                new String[]{"deviceType", "GAS_SENSOR"}, new String[]{"district", "0"},
+                new String[]{"pointStatus", "NORMAL"})) {
+            mockMvc.perform(get(ENDPOINT).param(filter[0], filter[1]))
+                    .andExpect(status().isOk()).andExpect(jsonPath("$.data.pagination.total").value(0));
+        }
+    }
+
+    @Test
+    void coordinatesDoNotAffectStatisticsAndAssociatedDevicesNeverBecomeStandaloneMarkers() {
+        CockpitMonitoringPointDeviceSnapshot bound = device(
+                "BOUND", "关联设备", true, true, false, false, Collections.emptyList());
+        CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, SNAPSHOT_AT, fixture().getTypes(),
+                Collections.singletonList(new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(
+                        "P", "点位", 0, "GAS_SENSOR", null, null, false, Collections.singletonList(bound))),
+                Arrays.asList(smartDevice("BOUND", "关联设备", 1, "GAS_SENSOR", "110.4", "28.4", false,
+                                true, true, false, false, Collections.emptyList()),
+                        smartDevice("FREE", "独立设备", 1, "GAS_SENSOR", "181", "28.4", true,
+                                true, false, false, false, Collections.emptyList())));
+        when(adapter.load(null)).thenReturn(snapshot);
+        CockpitMonitoringDistributionResponse all = service.load("all", null, null, null, null, 1, 100, null);
+        assertEquals(2, all.getPagination().getTotal());
+        assertEquals(1, all.getUnassociatedEquipment().size());
+        assertEquals("FREE", all.getUnassociatedEquipment().get(0).getDeviceCode());
+        assertTrue(!all.getMonitoringPoints().get(0).getCoordinateValidation().isRenderable());
+        assertTrue(!all.getUnassociatedEquipment().get(0).getCoordinateValidation().isRenderable());
+        assertEquals(0, all.getExcluded().getInvalidCoordinateCount());
+        assertEquals("READY", all.getFreshness().getReason());
+        assertEquals(1, statusCount(all, CockpitMonitoringPointStatus.ALARM));
+        assertEquals(0, statusCount(all, CockpitMonitoringPointStatus.NORMAL));
+
+        CockpitMonitoringDistributionResponse normal = service.load("normal", null, null, "NORMAL", null, 1, 100, null);
+        assertEquals(Collections.singletonList("FREE"), normal.getMapFilter().getDeviceCodes());
+        assertTrue(normal.getMapFilter().getPointCodes().isEmpty());
+        CockpitMonitoringDistributionResponse district = service.load("district", null, null, null, "1", 1, 100, null);
+        assertEquals(1, district.getPagination().getTotal(), "被筛掉的点位不能让关联设备变成独立设备");
+        assertEquals(Collections.singletonList("FREE"), district.getMapFilter().getDeviceCodes());
+    }
+
+    @Test
+    void exclusionsCountEachRejectedObjectOnceRegardlessOfAssociatedDeviceCount() {
+        CockpitMonitoringPointDeviceSnapshot d = device("D", "设备", true, false, false, false, Collections.emptyList());
+        CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, SNAPSHOT_AT, fixture().getTypes(), Arrays.asList(
+                        point("EMPTY", "合法空点", null, null, "110.4", "28.4"),
+                        point("UNKNOWN", "未知类型", 0, "LEGACY", "110.4", "28.4", d, d, d),
+                        point("MISMATCH", "错种类", 0, "WATER_PLANT", "110.4", "28.4", d, d),
+                        point("NONFORMAL", "无行业", 0, "SMART_MANHOLE", "110.4", "28.4", d)), Arrays.asList(
+                        smartDevice("U", "未知", 0, "LEGACY", "110.4", "28.4", true, true, false, false, false, Collections.emptyList()),
+                        smartDevice("M", "错种类", 0, "WATER_PLANT", "110.4", "28.4", true, true, false, false, false, Collections.emptyList()),
+                        smartDevice("N", "无行业", 0, "SMART_MANHOLE", "110.4", "28.4", true, true, false, false, false, Collections.emptyList())));
+        when(adapter.load(null)).thenReturn(snapshot);
+        CockpitMonitoringDistributionResponse response = service.load("reconcile", null, null, null, null, 1, 100, null);
+        assertEquals(1, response.getPagination().getTotal());
+        assertEquals(1, statusCount(response, CockpitMonitoringPointStatus.EMPTY));
+        assertEquals(2, response.getExcluded().getUnknownTypeCount());
+        assertEquals(2, response.getExcluded().getTypeKindMismatchCount());
+        assertEquals(2, response.getExcluded().getNonFormalIndustryCount());
+        int excluded = response.getExcluded().getUnknownTypeCount() + response.getExcluded().getTypeKindMismatchCount()
+                + response.getExcluded().getNonFormalIndustryCount() + response.getExcluded().getInvalidCoordinateCount();
+        assertEquals(7, response.getPagination().getTotal() + excluded);
     }
     }
 
 
     private int statusCount(CockpitMonitoringDistributionResponse response,
     private int statusCount(CockpitMonitoringDistributionResponse response,

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

@@ -239,6 +239,45 @@ class CockpitMonitoringOverviewControllerTest {
         }
         }
     }
     }
 
 
+    @Test
+    void sixEmptyUntypedPointsAreCountedAndEchoedWithoutFabricatingDevicesOrIndustry() throws Exception {
+        List<CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint> points = new ArrayList<>();
+        for (String code : Arrays.asList("GS001", "GS002", "PS001", "PS002", "RQ001", "RQ002")) {
+            points.add(new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(code, null, 0));
+        }
+        when(adapter.load()).thenReturn(new CockpitMonitoringOverviewSnapshot(
+                "2026-09-02T09:59:50+08:00", Collections.emptyList(), Collections.emptyList(), points));
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.counts.monitoringPointCount").value(6))
+                .andExpect(jsonPath("$.data.counts.equipmentCount").value(0))
+                .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(6)))
+                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(0)))
+                .andExpect(jsonPath("$.data.status.denominator").value(0))
+                .andExpect(jsonPath("$.data.onlineRate.state").value("EMPTY"))
+                .andExpect(jsonPath("$.data.freshness.status").value("CURRENT"))
+                .andExpect(jsonPath("$.data.freshness.reason").value("READY"));
+        for (String[] filter : Arrays.asList(new String[]{"industry", "GAS"}, new String[]{"deviceType", "GAS_SENSOR"})) {
+            mockMvc.perform(get(ENDPOINT).param(filter[0], filter[1]))
+                    .andExpect(status().isOk())
+                    .andExpect(jsonPath("$.data.counts.monitoringPointCount").value(0))
+                    .andExpect(jsonPath("$.data.mapFilter.pointCodes", hasSize(0)));
+        }
+    }
+
+    @Test
+    void unknownOrMixedTypeWithDevicesIsNotReinterpretedAsAnEmptyPoint() {
+        when(adapter.load()).thenReturn(new CockpitMonitoringOverviewSnapshot(
+                "2026-09-02T09:59:50+08:00", fixture().getTypes(), Collections.emptyList(), Arrays.asList(
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint("EMPTY", null, 0),
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint("MIXED", null, 2),
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint("LEGACY", null),
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint("FACILITY", "WATER_PLANT", 0))));
+        CockpitMonitoringOverviewResponse response = service.load("points", null, null);
+        assertEquals(1, response.getCounts().getMonitoringPointCount());
+        assertEquals(Collections.singletonList("EMPTY"), response.getMapFilter().getPointCodes());
+    }
+
     private static CockpitMonitoringOverviewSnapshot fixture() {
     private static CockpitMonitoringOverviewSnapshot fixture() {
         return new CockpitMonitoringOverviewSnapshot(
         return new CockpitMonitoringOverviewSnapshot(
                 "2026-09-02T09:59:50+08:00",
                 "2026-09-02T09:59:50+08:00",

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

@@ -0,0 +1,158 @@
+package com.zksy.web.controller.cockpit;
+
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
+import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
+import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
+import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.base.service.ManholeBaseService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.device.BusinessCockpitDeviceBoundaryAdapter;
+import com.zksy.cockpit.device.CockpitDeviceBoundaryService;
+import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureBaseArchivesAdapter;
+import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureManagementInformationAdapter;
+import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureOperatingInformationAdapter;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureBaseArchivesService;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureManagementInformationService;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationService;
+import com.zksy.cockpit.overview.BusinessCockpitOverviewInfrastructureAdapter;
+import com.zksy.cockpit.overview.CockpitOverviewInfrastructureService;
+import com.zksy.drainage.service.EngineeringFacilityService;
+import org.apache.ibatis.builder.MapperBuilderAssistant;
+import org.junit.jupiter.api.BeforeAll;
+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.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/** 同一份管网数据贯通五套真实适配器与服务,锁定行业计数及未知项排除口径。 */
+class CockpitPipeNetworkCrossEndpointContractTest {
+    private static final Clock CLOCK = Clock.fixed(Instant.parse("2026-10-12T00:00:00Z"), ZoneOffset.UTC);
+    private static final ObjectMapper JSON = new ObjectMapper();
+
+    @BeforeAll
+    static void initializeLambdaCache() {
+        TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""),
+                WaterPumpStation.class);
+    }
+
+    @Test
+    void numericAndHistoricalTypesHaveEqualIndustryCountsAcrossFiveEndpoints() {
+        assertCrossEndpointCounts(Arrays.asList("0", "1", "2", "gas", "drainage", "water"), 0);
+    }
+
+    @Test
+    void unknownTypesIncludingRemovedCodeThreeAreCountedRatherThanLost() {
+        assertCrossEndpointCounts(Arrays.asList("0", "1", "2", "gas", "drainage", "water", "3", "99", null), 3);
+    }
+
+    private void assertCrossEndpointCounts(List<String> types, int unknown) {
+        PipeNetworkBaseService pipes = mock(PipeNetworkBaseService.class);
+        List<PipeNetworkBase> source = new ArrayList<>();
+        for (int i = 0; i < types.size(); i++) {
+            PipeNetworkBase pipe = new PipeNetworkBase();
+            pipe.setNetworkCode("PIPE-" + i);
+            pipe.setNetworkName("管网" + i);
+            pipe.setNetworkType(types.get(i));
+            pipe.setLength(BigDecimal.valueOf(1000));
+            source.add(pipe);
+        }
+        when(pipes.list()).thenReturn(source);
+        IWaterPlantInfoService plants = mock(IWaterPlantInfoService.class);
+        IWaterPumpStationService stations = mock(IWaterPumpStationService.class);
+        EngineeringFacilityService engineering = mock(EngineeringFacilityService.class);
+        EquipmentTypeService equipmentTypes = mock(EquipmentTypeService.class);
+        EquipmentBaseService equipment = mock(EquipmentBaseService.class);
+
+        // 只替换表读取;类型解析、未知计数、行业归属与响应构造全部走真实代码。
+        JsonNode archives = JSON.valueToTree(new CockpitInfrastructureBaseArchivesService(
+                new BusinessCockpitInfrastructureBaseArchivesAdapter(plants, stations, pipes, engineering, CLOCK),
+                CLOCK).load("archives", null, null, null, null));
+        JsonNode management = JSON.valueToTree(new CockpitInfrastructureManagementInformationService(
+                new BusinessCockpitInfrastructureManagementInformationAdapter(equipment, equipmentTypes,
+                        mock(ManholeBaseService.class), pipes, mock(IWaterSourceInfoService.class)),
+                CLOCK).load("management", null, null));
+        JsonNode operating = JSON.valueToTree(new CockpitInfrastructureOperatingInformationService(
+                new BusinessCockpitInfrastructureOperatingInformationAdapter(plants, stations, pipes, engineering),
+                CLOCK, 60).load("operating", null, null, null, null));
+        JsonNode overview = JSON.valueToTree(new CockpitOverviewInfrastructureService(
+                new BusinessCockpitOverviewInfrastructureAdapter(equipmentTypes, equipment, pipes, plants, stations),
+                CLOCK).load("overview"));
+        JsonNode boundary = JSON.valueToTree(new CockpitDeviceBoundaryService(
+                new BusinessCockpitDeviceBoundaryAdapter(equipmentTypes, equipment, pipes), CLOCK).load("boundary"));
+
+        Map<String, Integer> expected = new HashMap<>();
+        expected.put("GAS", 2);
+        expected.put("WATER_SUPPLY", 2);
+        expected.put("DRAINAGE", 2);
+        expected.put("MANHOLE", 0);
+        Map<String, Integer> archiveCounts = zeroCounts();
+        for (JsonNode row : archives.path("industryDistribution")) {
+            archiveCounts.put(row.path("code").asText(), row.path("count").asInt());
+        }
+        assertEquals(expected, archiveCounts, "基础档案不能漏计 0/1 管网");
+        Map<String, Integer> managementCounts = zeroCounts();
+        for (JsonNode row : management.path("districtIndustry")) {
+            managementCounts.merge(row.path("industry").asText(), row.path("facilityCount").asInt(), Integer::sum);
+        }
+        assertEquals(expected, managementCounts, "管理信息与基础档案的管网行业计数必须一致");
+        Map<String, Integer> operatingCounts = zeroCounts();
+        for (JsonNode row : operating.path("industries")) {
+            int count = 0;
+            for (JsonNode metric : row.path("metrics")) {
+                if (metric.path("metricCode").asText().endsWith("_pipe_network_length")) {
+                    count++;
+                }
+            }
+            operatingCounts.put(row.path("industry").path("code").asText(), count);
+        }
+        assertEquals(expected, operatingCounts, "运行信息的管网指标条数必须与其它端点一致");
+        Map<String, Integer> overviewCounts = zeroCounts();
+        for (JsonNode row : overview.path("industries")) {
+            overviewCounts.put(row.path("code").asText(), row.path("facilityCount").asInt());
+        }
+        assertEquals(expected, overviewCounts, "总体概览不得把管网行业置空");
+        Map<String, Integer> boundaryCounts = zeroCounts();
+        for (JsonNode row : boundary.path("facilities")) {
+            if (row.path("formalScope").asBoolean()) {
+                boundaryCounts.merge(row.path("industry").asText(), 1, Integer::sum);
+            }
+        }
+        assertEquals(expected, boundaryCounts, "设备边界设施不能借用设备类型命名空间");
+
+        assertEquals(6, archives.path("totals").path("facilityCount").asInt());
+        assertEquals(6, management.path("totals").path("facilityCount").asInt());
+        assertEquals(6, overview.path("totals").path("facilityCount").asInt());
+        assertEquals(types.size(), boundary.path("statistics").path("facilityCount").asInt());
+        assertEquals(unknown, archives.path("excluded").path("unknownTypeCount").asInt());
+        assertEquals(unknown, management.path("excluded").path("unknownIndustryCount").asInt());
+        assertEquals(unknown, operating.path("excluded").path("unknownIndustryCount").asInt());
+        assertEquals(unknown, overview.path("excluded").path("unknownTypeCount").asInt());
+        assertEquals(unknown, boundary.path("statistics").path("unknownTypeCount").asInt());
+    }
+
+    private static Map<String, Integer> zeroCounts() {
+        Map<String, Integer> result = new HashMap<>();
+        for (String industry : Arrays.asList("GAS", "WATER_SUPPLY", "DRAINAGE", "MANHOLE")) {
+            result.put(industry, 0);
+        }
+        return result;
+    }
+}

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

@@ -0,0 +1,191 @@
+package com.zksy.web.controller.cockpit;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.zksy.cockpit.map.*;
+import com.zksy.cockpit.monitoring.*;
+import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
+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.request.MockHttpServletRequestBuilder;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+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.mockito.Mockito.*;
+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;
+
+/** 同一事实集穿过两个真实控制器/服务,锁定 HTTP 绑定、回显、分页前计数和匹配语义。 */
+class CockpitPointStatusContractTest {
+    private static final String TOKEN = "2026-09-02T10:00:00+08:00";
+    private static final String MAP = "/api/cockpit/v1/map-snapshot";
+    private static final String DISTRIBUTION = "/api/cockpit/v1/monitoring/distribution";
+    private final ObjectMapper json = new ObjectMapper();
+    private MockMvc mvc;
+    private CockpitMapSnapshotAdapter mapAdapter;
+    private CockpitMonitoringDistributionAdapter distributionAdapter;
+
+    @BeforeEach
+    void setUp() {
+        Clock clock = Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC);
+        mapAdapter = mock(CockpitMapSnapshotAdapter.class);
+        distributionAdapter = mock(CockpitMonitoringDistributionAdapter.class);
+        when(mapAdapter.load(any())).thenReturn(mapFixture());
+        when(distributionAdapter.load(any())).thenReturn(distributionFixture());
+        mvc = MockMvcBuilders.standaloneSetup(
+                new CockpitMapSnapshotController(new CockpitMapSnapshotService(mapAdapter, clock)),
+                new CockpitMonitoringDistributionController(
+                        new CockpitMonitoringDistributionService(distributionAdapter, clock))).build();
+    }
+
+    @Test
+    void csvAndRepeatedParametersAreOrDeduplicatedAndEchoedIdentically() throws Exception {
+        for (String endpoint : Arrays.asList(MAP, DISTRIBUTION)) {
+            JsonNode result = read(endpoint, "WARNING,ALARM", "ALARM");
+            assertEquals("ALARM,WARNING", result.path("mapFilter").path("pointStatus").asText());
+            assertEquals(3, total(result));
+            assertEquals(2, result.path("monitoringPoints").size());
+            assertEquals(1, result.path("unassociatedEquipment").size());
+            assertEquals("D-A", result.path("unassociatedEquipment").get(0).path("deviceCode").asText());
+            assertEquals(3, result.path("mapFilter").path("deviceCodes").size());
+        }
+        assertEquals(read(MAP, "ALARM,WARNING").path("mapFilter"),
+                read(DISTRIBUTION, "WARNING", "ALARM").path("mapFilter"));
+    }
+
+    @Test
+    void globalEightBucketsDoNotChangeWithAnyFilterOrPageAndNeverDoubleCountDevices() throws Exception {
+        JsonNode baseline = read(MAP);
+        JsonNode counts = baseline.path("pointStatusDistribution");
+        assertEquals(8, counts.size());
+        assertEquals(1, count(counts, "ALARM"));
+        assertEquals(1, count(counts, "WARNING"));
+        assertEquals(1, count(counts, "NORMAL"));
+        assertEquals(1, count(counts, "EMPTY"));
+        assertEquals(0, count(counts, "UNKNOWN"));
+        assertEquals(4, count(counts, "UNASSOCIATED"));
+        int sum = 0;
+        for (JsonNode row : counts) sum += row.path("count").asInt();
+        assertEquals(8, sum);
+        for (String endpoint : Arrays.asList(MAP, DISTRIBUTION)) {
+            assertEquals(8, total(read(endpoint)));
+            assertEquals(counts, read(endpoint, "ALARM").path("pointStatusDistribution"));
+            JsonNode filtered = response(get(endpoint).param("pointStatus", "ALARM")
+                    .param("industry", "GAS").param("district", "0").param("deviceType", "GAS_SENSOR")
+                    .param("pageSize", "1").param("page", "2").param("snapshotAt", TOKEN));
+            assertEquals(2, total(filtered));
+            assertEquals(counts, filtered.path("pointStatusDistribution"));
+            JsonNode empty = response(get(endpoint).param("deviceType", "NOT_A_TYPE"));
+            assertEquals(0, total(empty));
+            assertEquals(counts, empty.path("pointStatusDistribution"));
+        }
+    }
+
+    @Test
+    void emptyUnknownAndUnassociatedUseTheirOwnObjectSemantics() throws Exception {
+        for (String endpoint : Arrays.asList(MAP, DISTRIBUTION)) {
+            JsonNode empty = read(endpoint, "EMPTY");
+            assertEquals(1, total(empty));
+            assertEquals("P-E", empty.path("monitoringPoints").get(0).path("pointCode").asText());
+            assertEquals(0, empty.path("unassociatedEquipment").size());
+            JsonNode unknown = read(endpoint, "UNKNOWN");
+            assertEquals(1, total(unknown));
+            assertEquals("D-U", unknown.path("unassociatedEquipment").get(0).path("deviceCode").asText());
+            assertEquals("UNKNOWN", unknown.path("unassociatedEquipment").get(0).path("deviceStatus").asText());
+            assertEquals(0, unknown.path("monitoringPoints").size());
+            assertEquals(4, total(read(endpoint, "UNASSOCIATED")));
+            JsonNode onlyAlarmDevices = read(endpoint, "UNASSOCIATED", "ALARM");
+            assertEquals(1, total(onlyAlarmDevices));
+            assertEquals(0, onlyAlarmDevices.path("monitoringPoints").size());
+            assertEquals(1, total(read(endpoint, "UNASSOCIATED,UNKNOWN")));
+            // 明确离线不能冒充 UNKNOWN;EMPTY 不适用于设备自身。
+            assertEquals("D-O", read(endpoint, "UNASSOCIATED,OFFLINE")
+                    .path("unassociatedEquipment").get(0).path("deviceCode").asText());
+            assertEquals(0, total(read(endpoint, "UNASSOCIATED,EMPTY")));
+        }
+    }
+
+    @Test
+    void invalidValuesIncludingOneBadRepeatedParameterAreRejectedBeforeReading() throws Exception {
+        for (String endpoint : Arrays.asList(MAP, DISTRIBUTION)) {
+            for (String value : Arrays.asList("BOGUS", "ALARM,BOGUS", "ALARM,", "EMPTY,,WARNING")) {
+                mvc.perform(get(endpoint).param("pointStatus", value))
+                        .andExpect(status().isBadRequest())
+                        .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"));
+            }
+            mvc.perform(get(endpoint).param("pointStatus", "ALARM", "BOGUS"))
+                    .andExpect(status().isBadRequest())
+                    .andExpect(jsonPath("$.data.category").value("INVALID_REQUEST"));
+        }
+        verifyNoInteractions(mapAdapter, distributionAdapter);
+    }
+
+    private JsonNode read(String endpoint, String... statuses) throws Exception {
+        MockHttpServletRequestBuilder request = get(endpoint);
+        if (statuses.length > 0) request.param("pointStatus", statuses);
+        return response(request);
+    }
+
+    private JsonNode response(MockHttpServletRequestBuilder request) throws Exception {
+        String content = mvc.perform(request).andExpect(status().isOk())
+                .andReturn().getResponse().getContentAsString();
+        return json.readTree(content).path("data");
+    }
+
+    private static int total(JsonNode data) {
+        return data.has("pagination") ? data.path("pagination").path("total").asInt() : data.path("total").asInt();
+    }
+
+    private static int count(JsonNode rows, String status) {
+        for (JsonNode row : rows) if (status.equals(row.path("status").asText())) return row.path("count").asInt();
+        throw new AssertionError("Missing bucket: " + status);
+    }
+
+    private static List<CockpitMonitoringPointDeviceSnapshot> devices(String code) {
+        if ("P-E".equals(code)) return Collections.emptyList();
+        return Collections.singletonList(new CockpitMonitoringPointDeviceSnapshot(
+                "D-" + code, code, "传感器", true, "P-A".equals(code), "P-W".equals(code), false,
+                Collections.emptyList(), null)); // 缺状态时间不代表未发布。
+    }
+
+    private static CockpitMapSnapshot mapFixture() {
+        List<CockpitMapSnapshot.SourceMonitoringPoint> points = new java.util.ArrayList<>();
+        for (String code : Arrays.asList("P-A", "P-W", "P-E", "P-N")) {
+            points.add(new CockpitMapSnapshot.SourceMonitoringPoint(code, code, 0,
+                    "P-E".equals(code) ? null : "GAS_SENSOR", null, null, false, devices(code)));
+        }
+        List<CockpitMapSnapshot.SourceSmartDevice> devices = new java.util.ArrayList<>();
+        for (String code : Arrays.asList("D-A", "D-N", "D-O", "D-U", "D-P-A")) {
+            devices.add(new CockpitMapSnapshot.SourceSmartDevice(code, code, 0, "GAS_SENSOR", null, null, false,
+                    "D-A".equals(code) ? "ALARM" : "D-O".equals(code) ? "OFFLINE" : "D-U".equals(code) ? null : "NORMAL"));
+        }
+        return new CockpitMapSnapshot(TOKEN, Collections.singletonList(
+                new CockpitMapSnapshot.SourceType("GAS_SENSOR", "传感器", "GAS", "SMART_DEVICE")), points, devices);
+    }
+
+    private static CockpitMonitoringDistributionSnapshot distributionFixture() {
+        List<CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint> points = new java.util.ArrayList<>();
+        for (String code : Arrays.asList("P-A", "P-W", "P-E", "P-N")) {
+            points.add(new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(code, code, 0,
+                    "P-E".equals(code) ? null : "GAS_SENSOR", null, null, false, devices(code)));
+        }
+        List<CockpitMonitoringDistributionSnapshot.SourceSmartDevice> devices = new java.util.ArrayList<>();
+        for (String code : Arrays.asList("D-A", "D-N", "D-O", "D-U", "D-P-A")) {
+            devices.add(new CockpitMonitoringDistributionSnapshot.SourceSmartDevice(code, code, 0, "GAS_SENSOR",
+                    null, null, false, !"D-O".equals(code), "D-A".equals(code), false, false,
+                    Collections.emptyList(), null, !"D-U".equals(code)));
+        }
+        return new CockpitMonitoringDistributionSnapshot(TOKEN, TOKEN, Collections.singletonList(
+                new CockpitMonitoringDistributionSnapshot.SourceType("GAS_SENSOR", "传感器", "GAS", "SMART_DEVICE")), points, devices);
+    }
+}

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

@@ -0,0 +1,46 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+import com.zksy.cockpit.map.CockpitMapSnapshot;
+import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
+import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
+import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
+import com.zksy.framework.config.FastJson2JsonRedisSerializer;
+import org.junit.jupiter.api.Test;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collections;
+import static org.junit.jupiter.api.Assertions.*;
+
+class CockpitPointStatusSnapshotSerializationTest {
+    private final FastJson2JsonRedisSerializer<Object> serializer = new FastJson2JsonRedisSerializer<>(Object.class);
+
+    @Test
+    void publishedAndMissingDeviceStatesSurviveTheRealRedisSerializer() {
+        CockpitMonitoringPointDeviceSnapshot unpublished = new CockpitMonitoringPointDeviceSnapshot(
+                "BOUND", "设备", null, null, null, CockpitCoordinateValidator.validate(null, null, false),
+                false, false, false, false, Collections.emptyList(), null, false);
+        CockpitMapSnapshot snapshot = new CockpitMapSnapshot("2026-09-02T10:00:00+08:00", Collections.emptyList(),
+                Collections.singletonList(new CockpitMapSnapshot.SourceMonitoringPoint(
+                        "P", "点位", null, null, null, null, false, Collections.singletonList(unpublished))),
+                Arrays.asList(new CockpitMapSnapshot.SourceSmartDevice("ALARM", "报警", null, null, null, null, false, "ALARM"),
+                        new CockpitMapSnapshot.SourceSmartDevice("UNKNOWN", "未发布", null, null, null, null, false, null)));
+        CockpitMapSnapshot restored = (CockpitMapSnapshot) serializer.deserialize(serializer.serialize(snapshot));
+        assertEquals("ALARM", restored.getSmartDevices().get(0).getDeviceStatus());
+        assertNull(restored.getSmartDevices().get(1).getDeviceStatus());
+        assertFalse(restored.getMonitoringPoints().get(0).getDevices().get(0).isStatusPublished());
+        // 新设备发布标记不改变既有点位六态聚合。
+        assertEquals(CockpitMonitoringPointStatus.OFFLINE,
+                CockpitMonitoringPointStatusResolver.resolve(restored.getMonitoringPoints().get(0).getDevices()));
+    }
+
+    @Test
+    void legacySnapshotWithoutNewFieldsDoesNotInventDeviceStatus() {
+        String payload = "{\"@type\":\"com.zksy.cockpit.map.CockpitMapSnapshot\","
+                + "\"snapshotAt\":\"2026-09-02T10:00:00+08:00\",\"types\":[],\"monitoringPoints\":[],"
+                + "\"smartDevices\":[{\"deviceCode\":\"LEGACY\",\"deviceName\":\"旧设备\",\"coordinateVerified\":false}]}";
+        CockpitMapSnapshot restored = (CockpitMapSnapshot) serializer.deserialize(payload.getBytes(StandardCharsets.UTF_8));
+        assertEquals("LEGACY", restored.getSmartDevices().get(0).getDeviceCode());
+        assertNull(restored.getSmartDevices().get(0).getDeviceStatus());
+    }
+}

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

@@ -0,0 +1,243 @@
+package com.zksy.web.controller.cockpit;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.zksy.base.alarm.domain.AlarmData;
+import com.zksy.base.alarm.service.AlarmDataService;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.mapper.EquipmentBaseMapper;
+import com.zksy.base.warning.mapper.AlarmWarningRelMapper;
+import com.zksy.base.warning.service.EarlyWarningService;
+import com.zksy.cockpit.workorder.BusinessCockpitWorkOrderReadAdapter;
+import com.zksy.cockpit.workorder.CockpitWorkOrderReadService;
+import com.zksy.ops.domain.WorkOrder;
+import com.zksy.ops.service.WorkOrderService;
+import org.apache.ibatis.builder.MapperBuilderAssistant;
+import org.apache.ibatis.exceptions.PersistenceException;
+import org.springframework.dao.DataAccessResourceFailureException;
+import org.apache.ibatis.session.Configuration;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.ResultActions;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+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;
+
+/** 真实适配器贯穿三个 HTTP 入口,锁定执行票 21 的关联口径。 */
+class CockpitWorkOrderAssociationContractTest {
+    private static final String DEVICE_CODE = "21119740";
+    private static final String EQUIPMENT_ID = "equipment-id";
+    private static final String ORDER_CODE = "WO202610101511303516";
+    private static final String ALARM_ID = "cd57be42bd18d02f7d3390fb98539b93";
+    private static final String ALARM_NO = "BJ202610101511305660";
+    private static final String ASSOCIATED_AT = "2026-10-10T15:11:30+08:00";
+    private static final String BASE = "/api/cockpit/v1";
+
+    private WorkOrderService workOrderService;
+    private AlarmDataService alarmDataService;
+    private LambdaQueryChainWrapper<WorkOrder> orderQuery;
+    private MockMvc mockMvc;
+    private WorkOrder linkedOrder;
+    private AlarmData linkedAlarm;
+
+    @BeforeEach
+    @SuppressWarnings("unchecked")
+    void setUp() {
+        for (Class<?> entity : Arrays.asList(EquipmentBase.class, WorkOrder.class, AlarmData.class)) {
+            TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new Configuration(), ""), entity);
+        }
+        workOrderService = mock(WorkOrderService.class);
+        alarmDataService = mock(AlarmDataService.class);
+        EquipmentBaseMapper equipmentMapper = mock(EquipmentBaseMapper.class);
+        EquipmentBase equipment = new EquipmentBase();
+        equipment.setEquipmentId(EQUIPMENT_ID);
+        equipment.setEquipmentCode(DEVICE_CODE);
+        when(equipmentMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(equipment);
+        when(equipmentMapper.selectById(EQUIPMENT_ID)).thenReturn(equipment);
+
+        linkedOrder = order(279L, ORDER_CODE);
+        linkedAlarm = new AlarmData();
+        linkedAlarm.setId(ALARM_ID);
+        linkedAlarm.setAlarmNo(ALARM_NO);
+        linkedAlarm.setWorkOrderId(279L);
+        when(workOrderService.list(any(LambdaQueryWrapper.class)))
+                .thenReturn(Collections.singletonList(linkedOrder));
+        when(alarmDataService.list(any(LambdaQueryWrapper.class)))
+                .thenReturn(Collections.singletonList(linkedAlarm));
+        when(alarmDataService.getById(ALARM_ID)).thenReturn(linkedAlarm);
+        when(workOrderService.listLogs(279L)).thenReturn(Collections.emptyList());
+        orderQuery = mock(LambdaQueryChainWrapper.class);
+        when(workOrderService.lambdaQuery()).thenReturn(orderQuery);
+        when(orderQuery.eq(any(), any())).thenReturn(orderQuery);
+        when(orderQuery.one()).thenReturn(linkedOrder);
+
+        BusinessCockpitWorkOrderReadAdapter adapter = new BusinessCockpitWorkOrderReadAdapter(
+                workOrderService, mock(EarlyWarningService.class), mock(AlarmWarningRelMapper.class),
+                alarmDataService, equipmentMapper);
+        CockpitWorkOrderReadService service = new CockpitWorkOrderReadService(
+                adapter, Clock.fixed(Instant.parse("2026-10-10T07:11:30Z"), ZoneOffset.UTC));
+        mockMvc = MockMvcBuilders.standaloneSetup(new CockpitWorkOrderReadController(service)).build();
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    void sameOrderHasIdenticalAssociationAcrossDeviceAlarmAndTimeline() throws Exception {
+        expectLinked(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")),
+                "$.data.workOrders[0]")
+                .andExpect(jsonPath("$.data.unassociatedWorkOrderCount").value(0));
+        expectLinked(mockMvc.perform(get(BASE + "/events/ALARM/" + ALARM_ID + "/work-orders")),
+                "$.data.workOrders[0]")
+                .andExpect(jsonPath("$.data.eventCode").value(ALARM_ID))
+                .andExpect(jsonPath("$.data.unassociatedWorkOrderCount").value(0));
+        expectLinked(mockMvc.perform(get(BASE + "/work-orders/" + ORDER_CODE + "/timeline")),
+                "$.data.workOrder")
+                .andExpect(jsonPath("$.data.timelineEntries", hasSize(0)));
+
+        // 三个入口均反查真实工单主键,不能靠设备、工单号或时间猜测。
+        ArgumentCaptor<LambdaQueryWrapper<AlarmData>> queries = ArgumentCaptor.forClass(LambdaQueryWrapper.class);
+        verify(alarmDataService, times(3)).list(queries.capture());
+        for (LambdaQueryWrapper<AlarmData> query : queries.getAllValues()) {
+            assertTrue(query.getSqlSegment().contains("work_order_id IN"));
+            assertEquals(Collections.singletonList(279L),
+                    new java.util.ArrayList<>(query.getParamNameValuePairs().values()));
+        }
+    }
+
+    @Test
+    void alarmNumberAliasReturnsTheSameAssociationAsDeviceAndTimeline() throws Exception {
+        expectLinked(mockMvc.perform(get(BASE + "/events/ALARM/" + ALARM_NO + "/work-orders")),
+                "$.data.workOrders[0]")
+                .andExpect(jsonPath("$.data.eventCode").value(ALARM_ID));
+        expectLinked(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")),
+                "$.data.workOrders[0]");
+        expectLinked(mockMvc.perform(get(BASE + "/work-orders/" + ORDER_CODE + "/timeline")),
+                "$.data.workOrder");
+        ArgumentCaptor<LambdaQueryWrapper<AlarmData>> queries = ArgumentCaptor.forClass(LambdaQueryWrapper.class);
+        verify(alarmDataService, times(4)).list(queries.capture());
+        LambdaQueryWrapper<AlarmData> aliasQuery = queries.getAllValues().get(0);
+        assertTrue(aliasQuery.getSqlSegment().contains("alarm_no ="));
+        assertEquals(Collections.singletonList(ALARM_NO),
+                new java.util.ArrayList<>(aliasQuery.getParamNameValuePairs().values()));
+    }
+
+    @Test
+    void unlinkedOrderIsExplicitlyFalseInDeviceAndTimelineAndAbsentFromAlarm() throws Exception {
+        when(alarmDataService.list(any(LambdaQueryWrapper.class))).thenReturn(Collections.emptyList());
+        linkedAlarm.setWorkOrderId(null);
+        expectUnlinked(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")),
+                "$.data.workOrders[0]")
+                .andExpect(jsonPath("$.data.unassociatedWorkOrderCount").value(1));
+        expectUnlinked(mockMvc.perform(get(BASE + "/work-orders/" + ORDER_CODE + "/timeline")),
+                "$.data.workOrder");
+        mockMvc.perform(get(BASE + "/events/ALARM/" + ALARM_ID + "/work-orders"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.workOrders", hasSize(0)))
+                .andExpect(jsonPath("$.data.state").value("EMPTY"));
+    }
+
+    @Test
+    void anotherOrderOnSameDeviceDoesNotInheritLinkedOrdersAlarm() throws Exception {
+        WorkOrder orphan = order(281L, "WO-UNLINKED");
+        List<WorkOrder> orders = Arrays.asList(linkedOrder, orphan);
+        when(workOrderService.list(any(LambdaQueryWrapper.class))).thenReturn(orders);
+        expectLinked(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")),
+                "$.data.workOrders[0]");
+        expectUnlinked(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")),
+                "$.data.workOrders[1]")
+                .andExpect(jsonPath("$.data.unassociatedWorkOrderCount").value(1));
+        when(orderQuery.one()).thenReturn(orphan);
+        expectUnlinked(mockMvc.perform(get(BASE + "/work-orders/WO-UNLINKED/timeline")),
+                "$.data.workOrder");
+    }
+
+    @Test
+    void missingOrderReturnsNotFoundBeforeReadingAssociations() throws Exception {
+        when(orderQuery.one()).thenReturn(null);
+        mockMvc.perform(get(BASE + "/work-orders/MISSING/timeline"))
+                .andExpect(status().isNotFound());
+        verify(alarmDataService, never()).list(any(LambdaQueryWrapper.class));
+    }
+
+    @Test
+    void duplicateAlarmReferencesFailAcrossAllScopesRegardlessOfOrder() throws Exception {
+        AlarmData otherAlarm = new AlarmData();
+        otherAlarm.setId("another-alarm");
+        otherAlarm.setWorkOrderId(279L);
+        when(alarmDataService.getById(otherAlarm.getId())).thenReturn(otherAlarm);
+        for (List<AlarmData> alarms : Arrays.asList(
+                Arrays.asList(linkedAlarm, otherAlarm), Arrays.asList(otherAlarm, linkedAlarm))) {
+            when(alarmDataService.list(any(LambdaQueryWrapper.class))).thenReturn(alarms);
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/work-orders/" + ORDER_CODE + "/timeline")));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/events/ALARM/" + ALARM_ID + "/work-orders")));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/events/ALARM/" + otherAlarm.getId() + "/work-orders")));
+        }
+    }
+
+    @Test
+    void databaseAssociationReadFailureDoesNotBecomeSuccessfulUnassociatedOrder() throws Exception {
+        for (RuntimeException failure : Arrays.asList(
+                new DataAccessResourceFailureException("database unavailable"),
+                new PersistenceException("association query failed"))) {
+            org.mockito.Mockito.doThrow(failure).when(alarmDataService).list(any(LambdaQueryWrapper.class));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/equipments/" + DEVICE_CODE + "/work-orders")));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/work-orders/" + ORDER_CODE + "/timeline")));
+            expectAssociationFailure(mockMvc.perform(get(BASE + "/events/ALARM/" + ALARM_ID + "/work-orders")));
+        }
+    }
+
+    private static ResultActions expectAssociationFailure(ResultActions result) throws Exception {
+        return result.andExpect(status().isInternalServerError())
+                .andExpect(jsonPath("$.data.category").value("SERVER_ERROR"))
+                .andExpect(jsonPath("$.data.workOrder").doesNotExist())
+                .andExpect(jsonPath("$.data.workOrders").doesNotExist());
+    }
+
+    private static ResultActions expectLinked(ResultActions result, String path) throws Exception {
+        return result.andExpect(status().isOk())
+                .andExpect(jsonPath(path + ".workOrderCode").value(ORDER_CODE))
+                .andExpect(jsonPath(path + ".associatedWithCurrentEvent").value(true))
+                .andExpect(jsonPath(path + ".eventAssociation.eventSource").value("ALARM"))
+                .andExpect(jsonPath(path + ".eventAssociation.eventCode").value(ALARM_ID))
+                .andExpect(jsonPath(path + ".eventAssociation.associatedAt").value(ASSOCIATED_AT));
+    }
+
+    private static ResultActions expectUnlinked(ResultActions result, String path) throws Exception {
+        return result.andExpect(status().isOk())
+                .andExpect(jsonPath(path + ".associatedWithCurrentEvent").value(false))
+                .andExpect(jsonPath(path + ".eventAssociation").value(nullValue()));
+    }
+
+    private static WorkOrder order(Long id, String code) {
+        WorkOrder order = new WorkOrder();
+        order.setOrderId(id);
+        order.setOrderNo(code);
+        order.setDeviceId(EQUIPMENT_ID);
+        order.setOrderStatus(5);
+        order.setCreateTime(Date.from(Instant.parse("2026-10-10T07:11:30Z")));
+        return order;
+    }
+}

+ 76 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/geometry/CockpitFacilityGeometryResponse.java

@@ -0,0 +1,76 @@
+package com.zksy.cockpit.geometry;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/** GeoJSON with explicit source coverage and coordinate eligibility as foreign members. */
+@Getter
+public class CockpitFacilityGeometryResponse {
+    private final String type = "FeatureCollection";
+    private final String generatedAt;
+    private final List<Feature> features;
+    private final List<Coverage> coverage;
+
+    public CockpitFacilityGeometryResponse(String generatedAt, List<Feature> features, List<Coverage> coverage) {
+        this.generatedAt = generatedAt;
+        this.features = features;
+        this.coverage = coverage;
+    }
+
+    @Getter
+    @AllArgsConstructor
+    public static class Feature {
+        private final String type = "Feature";
+        private final String id;
+        @JsonInclude(JsonInclude.Include.ALWAYS)
+        private final Geometry geometry;
+        private final Properties properties;
+    }
+
+    @Getter
+    @AllArgsConstructor
+    public static class Geometry {
+        private final String type;
+        // Point: [lon, lat]; LineString: [[lon, lat], [lon, lat]].
+        private final List<?> coordinates;
+    }
+
+    @Getter
+    @AllArgsConstructor
+    public static class Properties {
+        private final String source;
+        private final String sourceId;
+        private final String code;
+        private final String name;
+        private final String industry;
+        private final String typeCode;
+        private final String networkType;
+        @JsonInclude(JsonInclude.Include.ALWAYS)
+        private final String pointType;
+        @JsonInclude(JsonInclude.Include.ALWAYS)
+        private final String networkId;
+        // Raw pairs remain available for objects whose GeoJSON geometry must be null.
+        private final List<List<BigDecimal>> sourceCoordinates;
+        private final CockpitCoordinateValidation coordinateValidation;
+        // In source order; one for Point, start/end for LineString.
+        private final List<CockpitCoordinateValidation> coordinateValidations;
+    }
+
+    @Getter
+    @AllArgsConstructor
+    public static class Coverage {
+        private final String industry;
+        private final String source;
+        private final String geometryType;
+        private final String state;
+        private final String reason;
+        private final int recordCount;
+        private final int geometryCount;
+        private final int renderableCount;
+    }
+}

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

@@ -0,0 +1,135 @@
+package com.zksy.cockpit.geometry;
+
+import com.zksy.base.domain.GasPipePoint;
+import com.zksy.base.domain.ManholeBase;
+import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.GasPipePointService;
+import com.zksy.base.service.ManholeBaseService;
+import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Coverage;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Feature;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Geometry;
+import com.zksy.cockpit.geometry.CockpitFacilityGeometryResponse.Properties;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.time.Clock;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class CockpitFacilityGeometryService {
+    private final PipeNetworkBaseService networks;
+    private final GasPipePointService gasPoints;
+    private final ManholeBaseService manholes;
+    private final Clock clock;
+
+    public CockpitFacilityGeometryService(PipeNetworkBaseService networks, GasPipePointService gasPoints,
+            ManholeBaseService manholes, Clock clock) {
+        this.networks = networks;
+        this.gasPoints = gasPoints;
+        this.manholes = manholes;
+        this.clock = clock;
+    }
+
+    @Transactional(readOnly = true)
+    public CockpitFacilityGeometryResponse load() {
+        try {
+            List<Feature> features = new ArrayList<>();
+            // IService.list() honours each entity's @TableLogic (del_flag=0).
+            for (PipeNetworkBase network : Objects.requireNonNull(networks.list())) {
+                String industry = CockpitPipeNetworkType.industryOf(network.getNetworkType());
+                features.add(feature("pipe_network_base", network.getNetworkId(), network.getNetworkCode(),
+                        network.getNetworkName(), industry == null ? "UNKNOWN" : industry,
+                        CockpitPipeNetworkType.typeCodeOf(network.getNetworkType()), network.getNetworkType(),
+                        null, network.getNetworkId(), "LineString", Arrays.asList(
+                                pair(network.getStartLongitude(), network.getStartLatitude()),
+                                pair(network.getEndLongitude(), network.getEndLatitude()))));
+            }
+            for (GasPipePoint point : Objects.requireNonNull(gasPoints.list())) {
+                features.add(feature("gas_pipe_point", String.valueOf(point.getPointId()), point.getPointCode(),
+                        point.getPointName(), "GAS", "GAS_PIPE_POINT", null, point.getPointType(),
+                        point.getNetworkId(), "Point",
+                        Collections.singletonList(pair(point.getLongitude(), point.getLatitude()))));
+            }
+            for (ManholeBase manhole : Objects.requireNonNull(manholes.list())) {
+                features.add(feature("manhole_base", manhole.getManholeId(), manhole.getManholeCode(),
+                        manhole.getManholeName(), "MANHOLE", "MANHOLE", null, null,
+                        manhole.getNetworkId(), "Point",
+                        Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
+            }
+            List<Coverage> coverage = new ArrayList<>();
+            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, "GAS", "gas_pipe_point", "Point", null));
+            coverage.add(new Coverage("WATER_SUPPLY", null, "Point", "UNAVAILABLE",
+                    "NO_COMPONENT_SOURCE", 0, 0, 0));
+            coverage.add(new Coverage("DRAINAGE", null, "Point", "UNAVAILABLE",
+                    "NO_TYPED_COMPONENT_SOURCE", 0, 0, 0));
+            coverage.add(coverage(features, "MANHOLE", "manhole_base", "Point", "NO_COMPONENT_TYPE"));
+            coverage.add(new Coverage("MANHOLE", null, "LineString", "UNAVAILABLE",
+                    "NO_PIPELINE_SOURCE", 0, 0, 0));
+            coverage.add(coverage(features, "UNKNOWN", "pipe_network_base", "LineString", "UNKNOWN_NETWORK_TYPE"));
+            String generatedAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
+                    clock.instant().atZone(ZoneId.of("Asia/Shanghai")));
+            return new CockpitFacilityGeometryResponse(generatedAt, features, coverage);
+        } catch (RuntimeException exception) {
+            // Never turn a failed source into an empty/partial successful collection.
+            org.slf4j.LoggerFactory.getLogger(CockpitFacilityGeometryService.class)
+                    .error("Facility geometry source read failed", exception);
+            throw new CockpitReadException("facility geometry source unavailable");
+        }
+    }
+
+    private static Feature feature(String source, String sourceId, String code, String name, String industry,
+            String typeCode, String networkType, String pointType, String networkId, String geometryType,
+            List<List<BigDecimal>> coordinates) {
+        List<CockpitCoordinateValidation> validations = coordinates.stream()
+                .map(pair -> validate(pair.get(0), pair.get(1)))
+                .collect(Collectors.toList());
+        CockpitCoordinateValidation overall = validations.stream()
+                .filter(validation -> "INVALID".equals(validation.getState()))
+                .findFirst().orElse(validations.get(0));
+        // Invalid GeoJSON coordinates cannot be represented as an empty or invented geometry.
+        Geometry geometry = "INVALID".equals(overall.getState()) ? null : new Geometry(geometryType,
+                "Point".equals(geometryType) ? coordinates.get(0) : coordinates);
+        Properties properties = new Properties(source, sourceId, code, name, industry, typeCode, networkType,
+                pointType, networkId, coordinates, overall, validations);
+        return new Feature(source + ":" + sourceId, geometry, properties);
+    }
+
+    private static CockpitCoordinateValidation validate(BigDecimal longitude, BigDecimal latitude) {
+        // Structural errors must remain distinguishable even without a verification flag.
+        CockpitCoordinateValidation structural = CockpitCoordinateValidator.validate(longitude, latitude, true);
+        return structural.isRenderable()
+                ? CockpitCoordinateValidator.validate(longitude, latitude, false) : structural;
+    }
+
+    private static List<BigDecimal> pair(BigDecimal longitude, BigDecimal latitude) {
+        return Arrays.asList(longitude, latitude);
+    }
+
+    private static Coverage coverage(List<Feature> features, String industry, String source,
+            String geometryType, String reason) {
+        List<Feature> records = features.stream().filter(feature ->
+                industry.equals(feature.getProperties().getIndustry())
+                        && source.equals(feature.getProperties().getSource())).collect(Collectors.toList());
+        int geometryCount = (int) records.stream().filter(feature -> feature.getGeometry() != null).count();
+        int renderableCount = (int) records.stream()
+                .filter(feature -> feature.getProperties().getCoordinateValidation().isRenderable()).count();
+        return new Coverage(industry, source, geometryType, records.isEmpty() ? "EMPTY" : "AVAILABLE",
+                reason, records.size(), geometryCount, renderableCount);
+    }
+}

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

@@ -47,9 +47,15 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
     private static final List<CockpitInfrastructureBaseArchivesSnapshot.SourceType> TYPES = Arrays.asList(
     private static final List<CockpitInfrastructureBaseArchivesSnapshot.SourceType> TYPES = Arrays.asList(
             type("WATER_PLANT", "水厂", "WATER_SUPPLY"),
             type("WATER_PLANT", "水厂", "WATER_SUPPLY"),
             type("WATER_PUMP_STATION", "供水泵站", "WATER_SUPPLY"),
             type("WATER_PUMP_STATION", "供水泵站", "WATER_SUPPLY"),
-            type("WATER_PIPE", "供水管线", "WATER_SUPPLY"),
-            type("GAS_PIPE", "燃气管线", "GAS"),
-            type("DRAINAGE_PIPE", "排水管线", "DRAINAGE"),
+            type(CockpitPipeNetworkType.WATER_PIPE,
+                    CockpitPipeNetworkType.nameOf(CockpitPipeNetworkType.WATER_PIPE),
+                    CockpitPipeNetworkType.industryOfTypeCode(CockpitPipeNetworkType.WATER_PIPE)),
+            type(CockpitPipeNetworkType.GAS_PIPE,
+                    CockpitPipeNetworkType.nameOf(CockpitPipeNetworkType.GAS_PIPE),
+                    CockpitPipeNetworkType.industryOfTypeCode(CockpitPipeNetworkType.GAS_PIPE)),
+            type(CockpitPipeNetworkType.DRAINAGE_PIPE,
+                    CockpitPipeNetworkType.nameOf(CockpitPipeNetworkType.DRAINAGE_PIPE),
+                    CockpitPipeNetworkType.industryOfTypeCode(CockpitPipeNetworkType.DRAINAGE_PIPE)),
             type("DRAINAGE_GATE", "排水闸门", "DRAINAGE"),
             type("DRAINAGE_GATE", "排水闸门", "DRAINAGE"),
             type("DRAINAGE_STORAGE", "排水调蓄设施", "DRAINAGE"),
             type("DRAINAGE_STORAGE", "排水调蓄设施", "DRAINAGE"),
             type("DRAINAGE_PUMP_STATION", "排水泵站", "DRAINAGE"));
             type("DRAINAGE_PUMP_STATION", "排水泵站", "DRAINAGE"));

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

@@ -257,7 +257,9 @@ public class BusinessCockpitMapSnapshotAdapter implements CockpitMapSnapshotAdap
                     type == null || type.getId() == null ? null : String.valueOf(type.getId()),
                     type == null || type.getId() == null ? null : String.valueOf(type.getId()),
                     device.getLongitude(),
                     device.getLongitude(),
                     device.getLatitude(),
                     device.getLatitude(),
-                    false));
+                    false,
+                    deviceFactResolver.resolve(device, type == null ? null : type.getTypeName())
+                            .getPublishedDeviceStatus()));
         }
         }
 
 
         List<CockpitMapSnapshot.SourceType> sourceTypes = types.values().stream()
         List<CockpitMapSnapshot.SourceType> sourceTypes = types.values().stream()

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

@@ -105,9 +105,15 @@ public class CockpitMapSnapshot {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final boolean coordinateVerified;
         private final boolean coordinateVerified;
+        private final String deviceStatus;
 
 
         public SourceSmartDevice(String deviceCode, String deviceName, Integer district, String typeCode,
         public SourceSmartDevice(String deviceCode, String deviceName, Integer district, String typeCode,
                 BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified) {
                 BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified) {
+            this(deviceCode, deviceName, district, typeCode, longitude, latitude, coordinateVerified, null);
+        }
+
+        public SourceSmartDevice(String deviceCode, String deviceName, Integer district, String typeCode,
+                BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified, String deviceStatus) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.district = district;
             this.district = district;
@@ -115,8 +121,10 @@ public class CockpitMapSnapshot {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateVerified = coordinateVerified;
             this.coordinateVerified = coordinateVerified;
+            this.deviceStatus = deviceStatus;
         }
         }
 
 
+        public String getDeviceStatus() { return deviceStatus; }
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceName() { return deviceName; }
         public String getDeviceName() { return deviceName; }
         public Integer getDistrict() { return district; }
         public Integer getDistrict() { return district; }

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

@@ -1,6 +1,7 @@
 package com.zksy.cockpit.map;
 package com.zksy.cockpit.map;
 
 
 import java.util.List;
 import java.util.List;
+import com.zksy.cockpit.point.CockpitPointStatusQuery;
 
 
 public class CockpitMapSnapshotResponse {
 public class CockpitMapSnapshotResponse {
     private final String requestId;
     private final String requestId;
@@ -16,13 +17,14 @@ public class CockpitMapSnapshotResponse {
     private final List<CockpitUnassociatedEquipmentSummary> unassociatedEquipment;
     private final List<CockpitUnassociatedEquipmentSummary> unassociatedEquipment;
     private final CockpitCoordinateValidationSummary coordinateValidation;
     private final CockpitCoordinateValidationSummary coordinateValidation;
     private final MapFilter mapFilter;
     private final MapFilter mapFilter;
+    private final List<CockpitPointStatusQuery.Count> pointStatusDistribution;
 
 
     public CockpitMapSnapshotResponse(String requestId, String apiVersion, boolean readOnly, int page, int pageSize,
     public CockpitMapSnapshotResponse(String requestId, String apiVersion, boolean readOnly, int page, int pageSize,
             String snapshotAt, int total, String batchUpdatedAt, boolean complete,
             String snapshotAt, int total, String batchUpdatedAt, boolean complete,
             List<CockpitMonitoringPointSummary> monitoringPoints,
             List<CockpitMonitoringPointSummary> monitoringPoints,
             List<CockpitUnassociatedEquipmentSummary> unassociatedEquipment,
             List<CockpitUnassociatedEquipmentSummary> unassociatedEquipment,
             CockpitCoordinateValidationSummary coordinateValidation,
             CockpitCoordinateValidationSummary coordinateValidation,
-            MapFilter mapFilter) {
+            MapFilter mapFilter, List<CockpitPointStatusQuery.Count> pointStatusDistribution) {
         this.requestId = requestId;
         this.requestId = requestId;
         this.apiVersion = apiVersion;
         this.apiVersion = apiVersion;
         this.readOnly = readOnly;
         this.readOnly = readOnly;
@@ -36,6 +38,7 @@ public class CockpitMapSnapshotResponse {
         this.unassociatedEquipment = unassociatedEquipment;
         this.unassociatedEquipment = unassociatedEquipment;
         this.coordinateValidation = coordinateValidation;
         this.coordinateValidation = coordinateValidation;
         this.mapFilter = mapFilter;
         this.mapFilter = mapFilter;
+        this.pointStatusDistribution = pointStatusDistribution;
     }
     }
 
 
     public String getRequestId() { return requestId; }
     public String getRequestId() { return requestId; }
@@ -50,6 +53,7 @@ public class CockpitMapSnapshotResponse {
     public List<CockpitMonitoringPointSummary> getMonitoringPoints() { return monitoringPoints; }
     public List<CockpitMonitoringPointSummary> getMonitoringPoints() { return monitoringPoints; }
     public List<CockpitUnassociatedEquipmentSummary> getUnassociatedEquipment() { return unassociatedEquipment; }
     public List<CockpitUnassociatedEquipmentSummary> getUnassociatedEquipment() { return unassociatedEquipment; }
     public CockpitCoordinateValidationSummary getCoordinateValidation() { return coordinateValidation; }
     public CockpitCoordinateValidationSummary getCoordinateValidation() { return coordinateValidation; }
+    public List<CockpitPointStatusQuery.Count> getPointStatusDistribution() { return pointStatusDistribution; }
     public MapFilter getMapFilter() { return mapFilter; }
     public MapFilter getMapFilter() { return mapFilter; }
 
 
     /**
     /**
@@ -66,10 +70,11 @@ public class CockpitMapSnapshotResponse {
         private final String districtName;
         private final String districtName;
         private final String districtFilter;
         private final String districtFilter;
         private final String deviceType;
         private final String deviceType;
+        private final String pointStatus;
         private final List<String> pointCodes;
         private final List<String> pointCodes;
         private final List<String> deviceCodes;
         private final List<String> deviceCodes;
 
 
-        public MapFilter(String industry, Integer district, String districtFilter, String deviceType,
+        public MapFilter(String industry, Integer district, String districtFilter, String deviceType, String pointStatus,
                 List<String> pointCodes, List<String> deviceCodes) {
                 List<String> pointCodes, List<String> deviceCodes) {
             this.industry = industry;
             this.industry = industry;
             this.district = district;
             this.district = district;
@@ -77,6 +82,7 @@ public class CockpitMapSnapshotResponse {
             this.districtName = district == null ? null
             this.districtName = district == null ? null
                     : com.zksy.cockpit.foundation.CockpitDistrict.nameOf(district);
                     : com.zksy.cockpit.foundation.CockpitDistrict.nameOf(district);
             this.deviceType = deviceType;
             this.deviceType = deviceType;
+            this.pointStatus = pointStatus;
             this.pointCodes = pointCodes;
             this.pointCodes = pointCodes;
             this.deviceCodes = deviceCodes;
             this.deviceCodes = deviceCodes;
         }
         }
@@ -88,6 +94,7 @@ public class CockpitMapSnapshotResponse {
         public String getDistrictName() { return districtName; }
         public String getDistrictName() { return districtName; }
         /** `NONE`(未筛)/ `ASSIGNED`(按片区)/ `UNASSIGNED`(只看未分区)。 */
         /** `NONE`(未筛)/ `ASSIGNED`(按片区)/ `UNASSIGNED`(只看未分区)。 */
         public String getDistrictFilter() { return districtFilter; }
         public String getDistrictFilter() { return districtFilter; }
+        public String getPointStatus() { return pointStatus; }
         public String getDeviceType() { return deviceType; }
         public String getDeviceType() { return deviceType; }
         public List<String> getPointCodes() { return pointCodes; }
         public List<String> getPointCodes() { return pointCodes; }
         public List<String> getDeviceCodes() { return deviceCodes; }
         public List<String> getDeviceCodes() { return deviceCodes; }

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

@@ -11,6 +11,7 @@ import com.zksy.cockpit.foundation.CockpitSnapshotTime;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
+import com.zksy.cockpit.point.CockpitPointStatusQuery;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -55,6 +56,12 @@ public class CockpitMapSnapshotService {
      */
      */
     public CockpitMapSnapshotResponse load(String requestId, Integer page, Integer pageSize, String snapshotAt,
     public CockpitMapSnapshotResponse load(String requestId, Integer page, Integer pageSize, String snapshotAt,
             String industry, String district, String deviceType) {
             String industry, String district, String deviceType) {
+        return load(requestId, page, pageSize, snapshotAt, industry, district, deviceType, null);
+    }
+
+    public CockpitMapSnapshotResponse load(String requestId, Integer page, Integer pageSize, String snapshotAt,
+            String industry, String district, String deviceType, String pointStatus) {
+        CockpitPointStatusQuery statusQuery = CockpitPointStatusQuery.parse(pointStatus);
         int safePage = page == null ? 1 : page;
         int safePage = page == null ? 1 : page;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
         validatePagination(safePage, safePageSize, snapshotAt);
         validatePagination(safePage, safePageSize, snapshotAt);
@@ -86,6 +93,15 @@ public class CockpitMapSnapshotService {
                 snapshot, types, selectedIndustry, selectedDistrict, selectedDeviceType);
                 snapshot, types, selectedIndustry, selectedDistrict, selectedDeviceType);
         List<CockpitUnassociatedEquipmentSummary> equipment = unassociatedEquipment(
         List<CockpitUnassociatedEquipmentSummary> equipment = unassociatedEquipment(
                 snapshot, types, selectedIndustry, selectedDistrict, selectedDeviceType);
                 snapshot, types, selectedIndustry, selectedDistrict, selectedDeviceType);
+        CockpitPointStatusQuery.Distribution global = new CockpitPointStatusQuery.Distribution();
+        monitoringPoints(snapshot, types, null, CockpitDistrict.parseQuery(null), null)
+                .forEach(point -> global.addPoint(point.getPointStatus()));
+        unassociatedEquipment(snapshot, types, null, CockpitDistrict.parseQuery(null), null)
+                .forEach(device -> global.addUnassociatedDevice());
+        points = points.stream().filter(point -> statusQuery.matchesPoint(point.getPointStatus()))
+                .collect(Collectors.toList());
+        equipment = equipment.stream().filter(device -> statusQuery.matchesDevice(device.getDeviceStatus()))
+                .collect(Collectors.toList());
         int total = points.size() + equipment.size();
         int total = points.size() + equipment.size();
         int fromIndex = Math.min((safePage - 1) * safePageSize, total);
         int fromIndex = Math.min((safePage - 1) * safePageSize, total);
         int toIndex = Math.min(fromIndex + safePageSize, total);
         int toIndex = Math.min(fromIndex + safePageSize, total);
@@ -109,7 +125,8 @@ public class CockpitMapSnapshotService {
                 pagePoints,
                 pagePoints,
                 pageEquipment,
                 pageEquipment,
                 coordinateValidation(points, equipment),
                 coordinateValidation(points, equipment),
-                mapFilter(selectedIndustry, selectedDistrict, selectedDeviceType, points, equipment));
+                mapFilter(selectedIndustry, selectedDistrict, selectedDeviceType, statusQuery.echo(), points, equipment),
+                global.rows());
     }
     }
 
 
     public CockpitErrorPayload invalidRequest(String requestId, String message) {
     public CockpitErrorPayload invalidRequest(String requestId, String message) {
@@ -237,6 +254,7 @@ public class CockpitMapSnapshotService {
         }
         }
         return snapshot.getMonitoringPoints().stream()
         return snapshot.getMonitoringPoints().stream()
                 .filter(Objects::nonNull)
                 .filter(Objects::nonNull)
+                .filter(source -> !isBlank(source.getPointCode()))
                 .filter(source -> matchesFilters(
                 .filter(source -> matchesFilters(
                         industry, district, deviceType, source.getTypeCode(), source.getDistrict(), types))
                         industry, district, deviceType, source.getTypeCode(), source.getDistrict(), types))
                 .map(source -> monitoringPoint(source, types))
                 .map(source -> monitoringPoint(source, types))
@@ -250,7 +268,8 @@ public class CockpitMapSnapshotService {
             Map<String, CockpitMapSnapshot.SourceType> types) {
             Map<String, CockpitMapSnapshot.SourceType> types) {
         List<CockpitMonitoringPointDeviceSnapshot> devices = source.getDevices() == null
         List<CockpitMonitoringPointDeviceSnapshot> devices = source.getDevices() == null
                 ? Collections.emptyList()
                 ? Collections.emptyList()
-                : source.getDevices();
+                : source.getDevices().stream().filter(Objects::nonNull)
+                        .filter(device -> !isBlank(device.getDeviceCode())).collect(Collectors.toList());
         CockpitMonitoringPointStatus pointStatus = CockpitMonitoringPointStatusResolver.resolve(devices);
         CockpitMonitoringPointStatus pointStatus = CockpitMonitoringPointStatusResolver.resolve(devices);
         List<String> deviceCodes = devices.stream()
         List<String> deviceCodes = devices.stream()
                 .filter(Objects::nonNull)
                 .filter(Objects::nonNull)
@@ -287,8 +306,8 @@ public class CockpitMapSnapshotService {
         Set<String> associatedDeviceCodes = associatedDeviceCodes(snapshot);
         Set<String> associatedDeviceCodes = associatedDeviceCodes(snapshot);
         return snapshot.getSmartDevices().stream()
         return snapshot.getSmartDevices().stream()
                 .filter(Objects::nonNull)
                 .filter(Objects::nonNull)
-                .filter(device -> device.getDeviceCode() == null
-                        || !associatedDeviceCodes.contains(device.getDeviceCode()))
+                .filter(device -> !isBlank(device.getDeviceCode()))
+                .filter(device -> !associatedDeviceCodes.contains(device.getDeviceCode().trim()))
                 .filter(source -> matchesFilters(
                 .filter(source -> matchesFilters(
                         industry, district, deviceType, source.getTypeCode(), source.getDistrict(), types))
                         industry, district, deviceType, source.getTypeCode(), source.getDistrict(), types))
                 .map(source -> unassociatedEquipment(source, types))
                 .map(source -> unassociatedEquipment(source, types))
@@ -302,11 +321,15 @@ public class CockpitMapSnapshotService {
             return Collections.emptySet();
             return Collections.emptySet();
         }
         }
         return snapshot.getMonitoringPoints().stream()
         return snapshot.getMonitoringPoints().stream()
+                .filter(Objects::nonNull)
                 .map(CockpitMapSnapshot.SourceMonitoringPoint::getDevices)
                 .map(CockpitMapSnapshot.SourceMonitoringPoint::getDevices)
                 .filter(Objects::nonNull)
                 .filter(Objects::nonNull)
                 .flatMap(List::stream)
                 .flatMap(List::stream)
+                .filter(Objects::nonNull)
                 .map(CockpitMonitoringPointDeviceSnapshot::getDeviceCode)
                 .map(CockpitMonitoringPointDeviceSnapshot::getDeviceCode)
                 .filter(Objects::nonNull)
                 .filter(Objects::nonNull)
+                .map(String::trim)
+                .filter(code -> !code.isEmpty())
                 .collect(Collectors.toSet());
                 .collect(Collectors.toSet());
     }
     }
 
 
@@ -324,11 +347,12 @@ public class CockpitMapSnapshotService {
                 source.getLongitude(),
                 source.getLongitude(),
                 source.getLatitude(),
                 source.getLatitude(),
                 CockpitCoordinateValidator.validate(
                 CockpitCoordinateValidator.validate(
-                        source.getLongitude(), source.getLatitude(), source.isCoordinateVerified()));
+                        source.getLongitude(), source.getLatitude(), source.isCoordinateVerified()),
+                CockpitPointStatusQuery.deviceBucket(source.getDeviceStatus()));
     }
     }
 
 
     private static CockpitMapSnapshotResponse.MapFilter mapFilter(
     private static CockpitMapSnapshotResponse.MapFilter mapFilter(
-            String industry, CockpitDistrict.Query district, String deviceType,
+            String industry, CockpitDistrict.Query district, String deviceType, String pointStatus,
             List<CockpitMonitoringPointSummary> points,
             List<CockpitMonitoringPointSummary> points,
             List<CockpitUnassociatedEquipmentSummary> equipment) {
             List<CockpitUnassociatedEquipmentSummary> equipment) {
         Set<String> pointCodes = new LinkedHashSet<>();
         Set<String> pointCodes = new LinkedHashSet<>();
@@ -354,7 +378,7 @@ public class CockpitMapSnapshotService {
                 industry,
                 industry,
                 district.active() ? district.code() : null,
                 district.active() ? district.code() : null,
                 !district.active() ? "NONE" : (district.unassignedOnly() ? "UNASSIGNED" : "ASSIGNED"),
                 !district.active() ? "NONE" : (district.unassignedOnly() ? "UNASSIGNED" : "ASSIGNED"),
-                deviceType, sorted(pointCodes), sorted(deviceCodes));
+                deviceType, pointStatus, sorted(pointCodes), sorted(deviceCodes));
     }
     }
 
 
     private static List<String> sorted(Set<String> values) {
     private static List<String> sorted(Set<String> values) {

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

@@ -15,10 +15,12 @@ public class CockpitUnassociatedEquipmentSummary {
     private final BigDecimal longitude;
     private final BigDecimal longitude;
     private final BigDecimal latitude;
     private final BigDecimal latitude;
     private final CockpitCoordinateValidation coordinateValidation;
     private final CockpitCoordinateValidation coordinateValidation;
+    private final String deviceStatus;
 
 
     public CockpitUnassociatedEquipmentSummary(String deviceCode, String deviceName,
     public CockpitUnassociatedEquipmentSummary(String deviceCode, String deviceName,
             Integer district, String industry, String typeCode, String typeName,
             Integer district, String industry, String typeCode, String typeName,
-            BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation) {
+            BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
+            String deviceStatus) {
         this.deviceCode = deviceCode;
         this.deviceCode = deviceCode;
         this.deviceName = deviceName;
         this.deviceName = deviceName;
         this.district = CockpitDistrict.codeOf(district);
         this.district = CockpitDistrict.codeOf(district);
@@ -28,8 +30,10 @@ public class CockpitUnassociatedEquipmentSummary {
         this.longitude = longitude;
         this.longitude = longitude;
         this.latitude = latitude;
         this.latitude = latitude;
         this.coordinateValidation = coordinateValidation;
         this.coordinateValidation = coordinateValidation;
+        this.deviceStatus = deviceStatus;
     }
     }
 
 
+    public String getDeviceStatus() { return deviceStatus; }
     public String getDeviceCode() { return deviceCode; }
     public String getDeviceCode() { return deviceCode; }
     public String getDeviceName() { return deviceName; }
     public String getDeviceName() { return deviceName; }
     /** 片区编码(0-城南 1-城北 2-太常);未分区为 {@code null}。 */
     /** 片区编码(0-城南 1-城北 2-太常);未分区为 {@code null}。 */

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

@@ -137,7 +137,8 @@ public class BusinessCockpitMonitoringDistributionAdapter implements CockpitMoni
                     fact.isWarning(),
                     fact.isWarning(),
                     fact.isWorkOrderInProgress(),
                     fact.isWorkOrderInProgress(),
                     fact.getStatusReasons(),
                     fact.getStatusReasons(),
-                    fact.getStatusTime()));
+                    fact.getStatusTime(),
+                    fact.isStatusPublished()));
         }
         }
 
 
         List<CockpitMonitoringDistributionSnapshot.SourceType> sourceTypes = types.values().stream()
         List<CockpitMonitoringDistributionSnapshot.SourceType> sourceTypes = types.values().stream()

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

@@ -82,10 +82,12 @@ public class BusinessCockpitMonitoringOverviewAdapter implements CockpitMonitori
             }
             }
             String pointCode = point.getPointCode().trim();
             String pointCode = point.getPointCode().trim();
             Set<String> deviceTypes = new LinkedHashSet<>();
             Set<String> deviceTypes = new LinkedHashSet<>();
+            Set<String> boundDeviceCodes = new LinkedHashSet<>();
             for (EquipmentBase bound : safeList(equipmentBaseService.getEquipmentByPoint(point.getPointId()))) {
             for (EquipmentBase bound : safeList(equipmentBaseService.getEquipmentByPoint(point.getPointId()))) {
                 if (bound == null || isBlank(bound.getEquipmentCode())) {
                 if (bound == null || isBlank(bound.getEquipmentCode())) {
                     continue;
                     continue;
                 }
                 }
+                boundDeviceCodes.add(bound.getEquipmentCode().trim());
                 pointCodeByDevice.putIfAbsent(bound.getEquipmentCode().trim(), pointCode);
                 pointCodeByDevice.putIfAbsent(bound.getEquipmentCode().trim(), pointCode);
                 if (bound.getEquipmentTypeId() == null) {
                 if (bound.getEquipmentTypeId() == null) {
                     continue;
                     continue;
@@ -97,7 +99,8 @@ public class BusinessCockpitMonitoringOverviewAdapter implements CockpitMonitori
             }
             }
             sourcePoints.add(new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
             sourcePoints.add(new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
                     pointCode,
                     pointCode,
-                    deviceTypes.size() == 1 ? deviceTypes.iterator().next() : null));
+                    deviceTypes.size() == 1 ? deviceTypes.iterator().next() : null,
+                    boundDeviceCodes.size()));
         }
         }
 
 
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> devices = new ArrayList<>();
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> devices = new ArrayList<>();

+ 7 - 16
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionResponse.java

@@ -3,6 +3,7 @@ package com.zksy.cockpit.monitoring;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
+import com.zksy.cockpit.point.CockpitPointStatusQuery;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
@@ -19,7 +20,7 @@ public class CockpitMonitoringDistributionResponse {
     private final List<DistrictDistribution> districtDistribution;
     private final List<DistrictDistribution> districtDistribution;
     private final List<IndustryDistribution> industryDistribution;
     private final List<IndustryDistribution> industryDistribution;
     private final List<DeviceTypeDistribution> deviceTypeDistribution;
     private final List<DeviceTypeDistribution> deviceTypeDistribution;
-    private final List<PointStatusCount> pointStatusDistribution;
+    private final List<CockpitPointStatusQuery.Count> pointStatusDistribution;
     private final MapFilter mapFilter;
     private final MapFilter mapFilter;
     private final Pagination pagination;
     private final Pagination pagination;
     private final List<MonitoringPointMarker> monitoringPoints;
     private final List<MonitoringPointMarker> monitoringPoints;
@@ -38,7 +39,7 @@ public class CockpitMonitoringDistributionResponse {
             List<DistrictDistribution> districtDistribution,
             List<DistrictDistribution> districtDistribution,
             List<IndustryDistribution> industryDistribution,
             List<IndustryDistribution> industryDistribution,
             List<DeviceTypeDistribution> deviceTypeDistribution,
             List<DeviceTypeDistribution> deviceTypeDistribution,
-            List<PointStatusCount> pointStatusDistribution,
+            List<CockpitPointStatusQuery.Count> pointStatusDistribution,
             MapFilter mapFilter,
             MapFilter mapFilter,
             Pagination pagination,
             Pagination pagination,
             List<MonitoringPointMarker> monitoringPoints,
             List<MonitoringPointMarker> monitoringPoints,
@@ -74,7 +75,7 @@ public class CockpitMonitoringDistributionResponse {
     public List<DistrictDistribution> getDistrictDistribution() { return districtDistribution; }
     public List<DistrictDistribution> getDistrictDistribution() { return districtDistribution; }
     public List<IndustryDistribution> getIndustryDistribution() { return industryDistribution; }
     public List<IndustryDistribution> getIndustryDistribution() { return industryDistribution; }
     public List<DeviceTypeDistribution> getDeviceTypeDistribution() { return deviceTypeDistribution; }
     public List<DeviceTypeDistribution> getDeviceTypeDistribution() { return deviceTypeDistribution; }
-    public List<PointStatusCount> getPointStatusDistribution() { return pointStatusDistribution; }
+    public List<CockpitPointStatusQuery.Count> getPointStatusDistribution() { return pointStatusDistribution; }
     public MapFilter getMapFilter() { return mapFilter; }
     public MapFilter getMapFilter() { return mapFilter; }
     public Pagination getPagination() { return pagination; }
     public Pagination getPagination() { return pagination; }
     public List<MonitoringPointMarker> getMonitoringPoints() { return monitoringPoints; }
     public List<MonitoringPointMarker> getMonitoringPoints() { return monitoringPoints; }
@@ -220,19 +221,6 @@ public class CockpitMonitoringDistributionResponse {
         public String getName() { return name; }
         public String getName() { return name; }
     }
     }
 
 
-    public static class PointStatusCount {
-        private final CockpitMonitoringPointStatus status;
-        private final int count;
-
-        public PointStatusCount(CockpitMonitoringPointStatus status, int count) {
-            this.status = status;
-            this.count = count;
-        }
-
-        public CockpitMonitoringPointStatus getStatus() { return status; }
-        public int getCount() { return count; }
-    }
-
     /**
     /**
      * 生效范围回显。片区维度自执行票 12 起为 {@code district}:
      * 生效范围回显。片区维度自执行票 12 起为 {@code district}:
      * 「未筛」与「只看未分区」的编码都是 {@code null},靠 {@code districtFilter}
      * 「未筛」与「只看未分区」的编码都是 {@code null},靠 {@code districtFilter}
@@ -368,6 +356,9 @@ public class CockpitMonitoringDistributionResponse {
         }
         }
 
 
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
+        public String getDeviceStatus() {
+            return CockpitPointStatusQuery.deviceBucket(pointStatus == null ? null : pointStatus.name());
+        }
         public String getDeviceName() { return deviceName; }
         public String getDeviceName() { return deviceName; }
         public Integer getDistrict() { return district; }
         public Integer getDistrict() { return district; }
         public String getDistrictName() { return districtName; }
         public String getDistrictName() { return districtName; }

+ 75 - 106
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionService.java

@@ -11,6 +11,7 @@ import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatus;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
 import com.zksy.cockpit.point.CockpitMonitoringPointStatusResolver;
+import com.zksy.cockpit.point.CockpitPointStatusQuery;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -32,10 +33,8 @@ import java.util.Set;
 /**
 /**
  * Read-only aggregation for 运行监测 / 监测分布.
  * Read-only aggregation for 运行监测 / 监测分布.
  *
  *
- * <p>All distribution statistics use the map rendering scope: monitoring points with
- * valid verified coordinates render once regardless of how many devices they carry;
- * unassociated smart devices render as their own marker only when coordinates are
- * valid and verified. Non-renderable objects are counted in excluded.invalidCoordinateCount.
+ * <p>业务对象参与计数、台账与筛选,坐标校验仅决定能否上图。
+ * 八桶分布取全局未筛全集(六态/UNKNOWN 数点位,UNASSOCIATED 数未关联设备)。
  */
  */
 @Service
 @Service
 public class CockpitMonitoringDistributionService {
 public class CockpitMonitoringDistributionService {
@@ -75,7 +74,7 @@ public class CockpitMonitoringDistributionService {
             Integer pageSize,
             Integer pageSize,
             String snapshotAt) {
             String snapshotAt) {
         String selectedIndustry = resolveIndustry(industry);
         String selectedIndustry = resolveIndustry(industry);
-        CockpitMonitoringPointStatus selectedStatus = resolvePointStatus(pointStatus);
+        CockpitPointStatusQuery selectedStatus = CockpitPointStatusQuery.parse(pointStatus);
         CockpitDistrict.Query selectedDistrict = resolveDistrict(district);
         CockpitDistrict.Query selectedDistrict = resolveDistrict(district);
         int safePage = page == null ? 1 : page;
         int safePage = page == null ? 1 : page;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
@@ -103,7 +102,7 @@ public class CockpitMonitoringDistributionService {
             String snapshotAt,
             String snapshotAt,
             CockpitMonitoringDistributionDeviceStatusDelta delta) {
             CockpitMonitoringDistributionDeviceStatusDelta delta) {
         String selectedIndustry = resolveIndustry(industry);
         String selectedIndustry = resolveIndustry(industry);
-        CockpitMonitoringPointStatus selectedStatus = resolvePointStatus(pointStatus);
+        CockpitPointStatusQuery selectedStatus = CockpitPointStatusQuery.parse(pointStatus);
         CockpitDistrict.Query selectedDistrict = resolveDistrict(district);
         CockpitDistrict.Query selectedDistrict = resolveDistrict(district);
         int safePage = page == null ? 1 : page;
         int safePage = page == null ? 1 : page;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
         int safePageSize = pageSize == null ? DEFAULT_PAGE_SIZE : pageSize;
@@ -232,7 +231,7 @@ public class CockpitMonitoringDistributionService {
             String requestId,
             String requestId,
             String selectedIndustry,
             String selectedIndustry,
             String deviceType,
             String deviceType,
-            CockpitMonitoringPointStatus selectedStatus,
+            CockpitPointStatusQuery selectedStatus,
             CockpitDistrict.Query selectedDistrict,
             CockpitDistrict.Query selectedDistrict,
             int page,
             int page,
             int pageSize) {
             int pageSize) {
@@ -248,6 +247,8 @@ public class CockpitMonitoringDistributionService {
         List<Marker> deviceMarkers = new ArrayList<>();
         List<Marker> deviceMarkers = new ArrayList<>();
         Set<String> pointCodes = new LinkedHashSet<>();
         Set<String> pointCodes = new LinkedHashSet<>();
         Set<String> deviceCodes = new LinkedHashSet<>();
         Set<String> deviceCodes = new LinkedHashSet<>();
+        Set<String> associatedCodes = new LinkedHashSet<>();
+        CockpitPointStatusQuery.Distribution global = new CockpitPointStatusQuery.Distribution();
 
 
         if (snapshot.getMonitoringPoints() != null) {
         if (snapshot.getMonitoringPoints() != null) {
             for (CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint point : snapshot.getMonitoringPoints()) {
             for (CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint point : snapshot.getMonitoringPoints()) {
@@ -255,57 +256,39 @@ public class CockpitMonitoringDistributionService {
                     continue;
                     continue;
                 }
                 }
                 CockpitMonitoringDistributionSnapshot.SourceType type = resolveType(types, point.getTypeCode());
                 CockpitMonitoringDistributionSnapshot.SourceType type = resolveType(types, point.getTypeCode());
-                String mismatch = classify(type);
-                List<CockpitMonitoringPointDeviceSnapshot> devices = safeDevices(point.getDevices());
-                if (mismatch != null) {
-                    int amount = devices.size();
-                    if (UNKNOWN_TYPE.equals(mismatch)) {
-                        unknownTypeCount += amount;
-                    } else if (TYPE_KIND_MISMATCH.equals(mismatch)) {
-                        typeKindMismatchCount += amount;
-                    } else {
-                        nonFormalIndustryCount += amount;
-                    }
-                    continue;
-                }
-                if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
-                    continue;
-                }
-                if (!isBlank(deviceType) && !deviceType.trim().equals(type.getCode())) {
-                    continue;
-                }
-                CockpitCoordinateValidation validation = CockpitCoordinateValidator.validate(
-                        point.getLongitude(), point.getLatitude(), point.isCoordinateVerified());
-                if (!validation.isRenderable()) {
-                    invalidCoordinateCount++;
-                    continue;
-                }
-                // 点位片区按「经其上挂设备归纳」取得(适配器已归纳,这里只做归一与筛选)
-                Integer markerDistrict = CockpitDistrict.codeOf(point.getDistrict());
-                if (!CockpitDistrict.matches(selectedDistrict, markerDistrict)) {
-                    continue;
-                }
                 List<CockpitMonitoringPointDeviceSnapshot> effective = new ArrayList<>();
                 List<CockpitMonitoringPointDeviceSnapshot> effective = new ArrayList<>();
-                for (CockpitMonitoringPointDeviceSnapshot device : devices) {
-                    if (device == null || isBlank(device.getDeviceCode())) {
-                        continue;
-                    }
-                    CockpitMonitoringPointDeviceSnapshot applied = effectiveDevice(device);
-                    effective.add(applied);
-                    deviceCodes.add(applied.getDeviceCode().trim());
+                for (CockpitMonitoringPointDeviceSnapshot device : safeDevices(point.getDevices())) {
+                    if (device == null || isBlank(device.getDeviceCode())) continue;
+                    associatedCodes.add(device.getDeviceCode().trim());
+                    effective.add(effectiveDevice(device));
                 }
                 }
                 CockpitMonitoringPointStatus status = CockpitMonitoringPointStatusResolver.resolve(effective);
                 CockpitMonitoringPointStatus status = CockpitMonitoringPointStatusResolver.resolve(effective);
-                if (selectedStatus != null && selectedStatus != status) {
+                global.addPoint(status);
+                String mismatch = classify(type);
+                boolean emptyPointWithUnknownType = UNKNOWN_TYPE.equals(mismatch) && effective.isEmpty();
+                if (mismatch != null && !emptyPointWithUnknownType) {
+                    if (UNKNOWN_TYPE.equals(mismatch)) unknownTypeCount++;
+                    else if (TYPE_KIND_MISMATCH.equals(mismatch)) typeKindMismatchCount++;
+                    else nonFormalIndustryCount++;
                     continue;
                     continue;
                 }
                 }
+                String markerIndustry = industryOf(type);
+                String markerTypeCode = point.getTypeCode();
+                Integer markerDistrict = CockpitDistrict.codeOf(point.getDistrict());
+                if (!matchesFilters(selectedIndustry, deviceType, selectedDistrict,
+                        markerIndustry, point.getTypeCode(), markerDistrict, type)
+                        || !selectedStatus.matchesPoint(status)) continue;
+                CockpitCoordinateValidation validation = CockpitCoordinateValidator.validate(
+                        point.getLongitude(), point.getLatitude(), point.isCoordinateVerified());
+                deviceCodes.addAll(codes(effective));
                 pointCodes.add(point.getPointCode().trim());
                 pointCodes.add(point.getPointCode().trim());
                 pointMarkers.add(new Marker(
                 pointMarkers.add(new Marker(
                         point.getPointCode().trim(),
                         point.getPointCode().trim(),
                         point.getPointName(),
                         point.getPointName(),
                         markerDistrict,
                         markerDistrict,
-                        type.getIndustry(),
-                        type.getCode(),
-                        type.getName(),
+                        markerIndustry,
+                        markerTypeCode,
+                        type == null ? null : type.getName(),
                         status,
                         status,
                         CockpitMonitoringPointStatusResolver.summaryReasons(status, effective),
                         CockpitMonitoringPointStatusResolver.summaryReasons(status, effective),
                         point.getLongitude(),
                         point.getLongitude(),
@@ -321,39 +304,27 @@ public class CockpitMonitoringDistributionService {
                 if (device == null || isBlank(device.getDeviceCode())) {
                 if (device == null || isBlank(device.getDeviceCode())) {
                     continue;
                     continue;
                 }
                 }
+                if (associatedCodes.contains(device.getDeviceCode().trim())) continue;
+                global.addUnassociatedDevice();
                 CockpitMonitoringDistributionSnapshot.SourceType type = resolveType(types, device.getTypeCode());
                 CockpitMonitoringDistributionSnapshot.SourceType type = resolveType(types, device.getTypeCode());
                 String mismatch = classify(type);
                 String mismatch = classify(type);
                 if (mismatch != null) {
                 if (mismatch != null) {
-                    if (UNKNOWN_TYPE.equals(mismatch)) {
-                        unknownTypeCount++;
-                    } else if (TYPE_KIND_MISMATCH.equals(mismatch)) {
-                        typeKindMismatchCount++;
-                    } else {
-                        nonFormalIndustryCount++;
-                    }
-                    continue;
-                }
-                if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
-                    continue;
-                }
-                if (!isBlank(deviceType) && !deviceType.trim().equals(type.getCode())) {
+                    if (UNKNOWN_TYPE.equals(mismatch)) unknownTypeCount++;
+                    else if (TYPE_KIND_MISMATCH.equals(mismatch)) typeKindMismatchCount++;
+                    else nonFormalIndustryCount++;
                     continue;
                     continue;
                 }
                 }
+                String markerIndustry = industryOf(type);
+                String markerTypeCode = device.getTypeCode();
+                Integer markerDistrict = CockpitDistrict.codeOf(device.getDistrict());
+                if (!matchesFilters(selectedIndustry, deviceType, selectedDistrict,
+                        markerIndustry, device.getTypeCode(), markerDistrict, type)) continue;
                 CockpitCoordinateValidation validation = CockpitCoordinateValidator.validate(
                 CockpitCoordinateValidation validation = CockpitCoordinateValidator.validate(
                         device.getLongitude(), device.getLatitude(), device.isCoordinateVerified());
                         device.getLongitude(), device.getLatitude(), device.isCoordinateVerified());
-                if (!validation.isRenderable()) {
-                    invalidCoordinateCount++;
-                    continue;
-                }
-                // 设备自身片区(equipment_base.district)即权威来源
-                Integer markerDistrict = CockpitDistrict.codeOf(device.getDistrict());
-                if (!CockpitDistrict.matches(selectedDistrict, markerDistrict)) {
-                    continue;
-                }
                 CockpitMonitoringPointDeviceSnapshot fact = new CockpitMonitoringPointDeviceSnapshot(
                 CockpitMonitoringPointDeviceSnapshot fact = new CockpitMonitoringPointDeviceSnapshot(
                         device.getDeviceCode().trim(),
                         device.getDeviceCode().trim(),
                         device.getDeviceName(),
                         device.getDeviceName(),
-                        type.getName(),
+                        type == null ? null : type.getName(),
                         device.getLongitude(),
                         device.getLongitude(),
                          device.getLatitude(),
                          device.getLatitude(),
                          validation,
                          validation,
@@ -362,23 +333,24 @@ public class CockpitMonitoringDistributionService {
                         device.isWarning(),
                         device.isWarning(),
                         device.isWorkOrderInProgress(),
                         device.isWorkOrderInProgress(),
                         device.getStatusReasons(),
                         device.getStatusReasons(),
-                        device.getStatusTime());
+                        device.getStatusTime(), device.isStatusPublished());
                 CockpitMonitoringPointDeviceSnapshot applied = effectiveDevice(fact);
                 CockpitMonitoringPointDeviceSnapshot applied = effectiveDevice(fact);
-                CockpitMonitoringPointStatus status = CockpitMonitoringPointStatusResolver.deviceStatus(applied);
-                if (selectedStatus != null && selectedStatus != status) {
-                    continue;
-                }
+                String publishedStatus = publishedStatus(applied);
+                CockpitMonitoringPointStatus status = "UNKNOWN".equals(publishedStatus)
+                        ? null : CockpitMonitoringPointStatus.valueOf(publishedStatus);
+                if (!selectedStatus.matchesDevice(publishedStatus)) continue;
                 deviceCodes.add(applied.getDeviceCode().trim());
                 deviceCodes.add(applied.getDeviceCode().trim());
                 deviceMarkers.add(new Marker(
                 deviceMarkers.add(new Marker(
                         applied.getDeviceCode().trim(),
                         applied.getDeviceCode().trim(),
                         applied.getDeviceName(),
                         applied.getDeviceName(),
                         markerDistrict,
                         markerDistrict,
-                        type.getIndustry(),
-                        type.getCode(),
-                        type.getName(),
+                        markerIndustry,
+                        markerTypeCode,
+                        type == null ? null : type.getName(),
                         status,
                         status,
-                        CockpitMonitoringPointStatusResolver.summaryReasons(
-                                status, Collections.singletonList(applied)),
+                        status == null ? applied.getStatusReasons()
+                                : CockpitMonitoringPointStatusResolver.summaryReasons(
+                                        status, Collections.singletonList(applied)),
                         device.getLongitude(),
                         device.getLongitude(),
                         device.getLatitude(),
                         device.getLatitude(),
                         validation,
                         validation,
@@ -394,18 +366,15 @@ public class CockpitMonitoringDistributionService {
         Map<Integer, Accumulator> byDistrict = new LinkedHashMap<>();
         Map<Integer, Accumulator> byDistrict = new LinkedHashMap<>();
         Map<String, Accumulator> byIndustry = new LinkedHashMap<>();
         Map<String, Accumulator> byIndustry = new LinkedHashMap<>();
         Map<String, Accumulator> byType = new LinkedHashMap<>();
         Map<String, Accumulator> byType = new LinkedHashMap<>();
-        int[] statusCounts = new int[CockpitMonitoringPointStatus.values().length];
         for (Marker marker : pointMarkers) {
         for (Marker marker : pointMarkers) {
             accumulate(byDistrict, marker.district, marker);
             accumulate(byDistrict, marker.district, marker);
             accumulate(byIndustry, marker.industry, marker);
             accumulate(byIndustry, marker.industry, marker);
             accumulate(byType, marker.typeCode, marker);
             accumulate(byType, marker.typeCode, marker);
-            statusCounts[marker.status.ordinal()]++;
         }
         }
         for (Marker marker : deviceMarkers) {
         for (Marker marker : deviceMarkers) {
             accumulate(byDistrict, marker.district, marker);
             accumulate(byDistrict, marker.district, marker);
             accumulate(byIndustry, marker.industry, marker);
             accumulate(byIndustry, marker.industry, marker);
             accumulate(byType, marker.typeCode, marker);
             accumulate(byType, marker.typeCode, marker);
-            statusCounts[marker.status.ordinal()]++;
         }
         }
 
 
         List<CockpitMonitoringDistributionResponse.DistrictDistribution> districtRows =
         List<CockpitMonitoringDistributionResponse.DistrictDistribution> districtRows =
@@ -414,12 +383,7 @@ public class CockpitMonitoringDistributionService {
                 industryRows(byIndustry);
                 industryRows(byIndustry);
         List<CockpitMonitoringDistributionResponse.DeviceTypeDistribution> typeRows =
         List<CockpitMonitoringDistributionResponse.DeviceTypeDistribution> typeRows =
                 typeRows(byType);
                 typeRows(byType);
-        List<CockpitMonitoringDistributionResponse.PointStatusCount> statusRows =
-                new ArrayList<>();
-        for (CockpitMonitoringPointStatus status : CockpitMonitoringPointStatus.values()) {
-            statusRows.add(new CockpitMonitoringDistributionResponse.PointStatusCount(
-                    status, statusCounts[status.ordinal()]));
-        }
+        List<CockpitPointStatusQuery.Count> statusRows = global.rows();
 
 
         int total = pointMarkers.size() + deviceMarkers.size();
         int total = pointMarkers.size() + deviceMarkers.size();
         int totalPages = total == 0 ? 0 : (total + pageSize - 1) / pageSize;
         int totalPages = total == 0 ? 0 : (total + pageSize - 1) / pageSize;
@@ -441,7 +405,7 @@ public class CockpitMonitoringDistributionService {
             pageDevices.add(marker.toUnassociatedEquipmentMarker());
             pageDevices.add(marker.toUnassociatedEquipmentMarker());
         }
         }
 
 
-        boolean hasResolved = !deviceCodes.isEmpty();
+        boolean hasResolved = total > 0;
         String updatedAt = isBlank(snapshot.getUpdatedAt()) ? businessTime() : snapshot.getUpdatedAt();
         String updatedAt = isBlank(snapshot.getUpdatedAt()) ? businessTime() : snapshot.getUpdatedAt();
 
 
         return new CockpitMonitoringDistributionResponse(
         return new CockpitMonitoringDistributionResponse(
@@ -465,7 +429,7 @@ public class CockpitMonitoringDistributionService {
                 new CockpitMonitoringDistributionResponse.MapFilter(
                 new CockpitMonitoringDistributionResponse.MapFilter(
                         selectedIndustry,
                         selectedIndustry,
                         isBlank(deviceType) ? null : deviceType.trim(),
                         isBlank(deviceType) ? null : deviceType.trim(),
-                        selectedStatus == null ? null : selectedStatus.name(),
+                        selectedStatus.echo(),
                         // 未筛与「只看未分区」的编码都是 null,靠 districtFilter 区分(口径同 map-snapshot)
                         // 未筛与「只看未分区」的编码都是 null,靠 districtFilter 区分(口径同 map-snapshot)
                         selectedDistrict.code(),
                         selectedDistrict.code(),
                         !selectedDistrict.active() ? "NONE"
                         !selectedDistrict.active() ? "NONE"
@@ -499,7 +463,10 @@ public class CockpitMonitoringDistributionService {
                 source.isWarning(),
                 source.isWarning(),
                 source.isWorkOrderInProgress(),
                 source.isWorkOrderInProgress(),
                 source.getStatusReasons(),
                 source.getStatusReasons(),
-                source.getStatusTime());
+                source.getStatusTime(),
+                runtime == null || runtime.serverUpdatedAt == null
+                        ? source.isStatusPublished()
+                        : "ONLINE".equals(runtime.monitoringState) || "OFFLINE".equals(runtime.monitoringState));
     }
     }
 
 
     /**
     /**
@@ -634,18 +601,20 @@ public class CockpitMonitoringDistributionService {
         return query;
         return query;
     }
     }
 
 
-    private static CockpitMonitoringPointStatus resolvePointStatus(String pointStatus) {
-        if (isBlank(pointStatus)) {
-            return null;
-        }
-        String resolved = pointStatus.trim();
-        for (CockpitMonitoringPointStatus status : CockpitMonitoringPointStatus.values()) {
-            if (status.name().equals(resolved)) {
-                return status;
-            }
-        }
-        throw new CockpitInvalidRequestException(
-                "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE or EMPTY");
+    private String industryOf(CockpitMonitoringDistributionSnapshot.SourceType type) {
+        return classify(type) == null ? type.getIndustry() : null;
+    }
+
+    private static boolean matchesFilters(String industry, String deviceType, CockpitDistrict.Query district,
+            String actualIndustry, String typeCode, Integer actualDistrict,
+            CockpitMonitoringDistributionSnapshot.SourceType type) {
+        return (industry == null || industry.equals(actualIndustry))
+                && (isBlank(deviceType) || (type != null && deviceType.trim().equals(typeCode)))
+                && CockpitDistrict.matches(district, actualDistrict);
+    }
+
+    private static String publishedStatus(CockpitMonitoringPointDeviceSnapshot device) {
+        return CockpitPointStatusQuery.deviceBucket(device.getPublishedDeviceStatus());
     }
     }
 
 
     private static void validatePagination(int page, int pageSize, String snapshotAt) {
     private static void validatePagination(int page, int pageSize, String snapshotAt) {
@@ -819,7 +788,7 @@ public class CockpitMonitoringDistributionService {
             } else {
             } else {
                 deviceCount++;
                 deviceCount++;
             }
             }
-            statusCounts[marker.status.ordinal()]++;
+            if (marker.status != null) statusCounts[marker.status.ordinal()]++;
             if (typeName == null) {
             if (typeName == null) {
                 typeName = marker.typeName;
                 typeName = marker.typeName;
             }
             }

+ 12 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionSnapshot.java

@@ -173,6 +173,7 @@ public class CockpitMonitoringDistributionSnapshot {
         private final boolean workOrderInProgress;
         private final boolean workOrderInProgress;
         private final List<String> statusReasons;
         private final List<String> statusReasons;
         private final String statusTime;
         private final String statusTime;
+        private final boolean statusPublished;
 
 
         public SourceSmartDevice(
         public SourceSmartDevice(
                 String deviceCode,
                 String deviceCode,
@@ -188,6 +189,14 @@ public class CockpitMonitoringDistributionSnapshot {
                 boolean workOrderInProgress,
                 boolean workOrderInProgress,
                 List<String> statusReasons,
                 List<String> statusReasons,
                 String statusTime) {
                 String statusTime) {
+            this(deviceCode, deviceName, district, typeCode, longitude, latitude, coordinateVerified,
+                    online, alarm, warning, workOrderInProgress, statusReasons, statusTime, true);
+        }
+
+        public SourceSmartDevice(String deviceCode, String deviceName, Integer district, String typeCode,
+                BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified,
+                boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
+                List<String> statusReasons, String statusTime, boolean statusPublished) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.district = district;
             this.district = district;
@@ -201,6 +210,7 @@ public class CockpitMonitoringDistributionSnapshot {
             this.workOrderInProgress = workOrderInProgress;
             this.workOrderInProgress = workOrderInProgress;
             this.statusReasons = statusReasons;
             this.statusReasons = statusReasons;
             this.statusTime = statusTime;
             this.statusTime = statusTime;
+            this.statusPublished = statusPublished;
         }
         }
 
 
         public String getDeviceCode() {
         public String getDeviceCode() {
@@ -252,6 +262,8 @@ public class CockpitMonitoringDistributionSnapshot {
             return statusReasons;
             return statusReasons;
         }
         }
 
 
+        public boolean isStatusPublished() { return statusPublished; }
+
         public String getStatusTime() {
         public String getStatusTime() {
             return statusTime;
             return statusTime;
         }
         }

+ 15 - 15
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewService.java

@@ -135,7 +135,7 @@ public class CockpitMonitoringOverviewService {
         int typeKindMismatchCount = 0;
         int typeKindMismatchCount = 0;
         int nonFormalIndustryCount = 0;
         int nonFormalIndustryCount = 0;
         Map<String, TypeAccumulator> typeAccumulators = new LinkedHashMap<>();
         Map<String, TypeAccumulator> typeAccumulators = new LinkedHashMap<>();
-        Set<String> selectedPointCodes = new LinkedHashSet<>();
+        Set<String> selectedPointCodes = selectMonitoringPointCodes(snapshot, selectedIndustry, deviceType, types);
         Set<String> selectedDeviceCodes = new LinkedHashSet<>();
         Set<String> selectedDeviceCodes = new LinkedHashSet<>();
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> selectedDevices = new ArrayList<>();
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> selectedDevices = new ArrayList<>();
 
 
@@ -178,12 +178,9 @@ public class CockpitMonitoringOverviewService {
 
 
             selectedDevices.add(snapshotDevice(snapshot, runtime.deviceCode));
             selectedDevices.add(snapshotDevice(snapshot, runtime.deviceCode));
             selectedDeviceCodes.add(runtime.deviceCode);
             selectedDeviceCodes.add(runtime.deviceCode);
-            if (!isBlank(runtime.pointCode)) {
-                selectedPointCodes.add(runtime.pointCode.trim());
-            }
         }
         }
 
 
-        int monitoringPointCount = countMonitoringPoints(snapshot, selectedIndustry, deviceType, types);
+        int monitoringPointCount = selectedPointCodes.size();
         int denominator = online + offline + stale;
         int denominator = online + offline + stale;
         BigDecimal rate = denominator == 0
         BigDecimal rate = denominator == 0
                 ? BigDecimal.ZERO.setScale(4)
                 ? BigDecimal.ZERO.setScale(4)
@@ -191,10 +188,11 @@ public class CockpitMonitoringOverviewService {
                         .divide(BigDecimal.valueOf(denominator), 4, RoundingMode.HALF_UP);
                         .divide(BigDecimal.valueOf(denominator), 4, RoundingMode.HALF_UP);
         String rateState = denominator == 0 ? "EMPTY" : "AVAILABLE";
         String rateState = denominator == 0 ? "EMPTY" : "AVAILABLE";
         String rateReason = denominator == 0 ? "NO_RESOLVED_DEVICES" : null;
         String rateReason = denominator == 0 ? "NO_RESOLVED_DEVICES" : null;
-        String freshnessStatus = denominator == 0
+        boolean hasObjects = monitoringPointCount > 0 || !selectedDeviceCodes.isEmpty();
+        String freshnessStatus = !hasObjects
                 ? CockpitFreshnessStatus.EMPTY.name()
                 ? CockpitFreshnessStatus.EMPTY.name()
                 : stale == 0 ? CockpitFreshnessStatus.CURRENT.name() : CockpitFreshnessStatus.STALE.name();
                 : stale == 0 ? CockpitFreshnessStatus.CURRENT.name() : CockpitFreshnessStatus.STALE.name();
-        String freshnessReason = denominator == 0
+        String freshnessReason = !hasObjects
                 ? "NO_RESOLVED_DEVICES"
                 ? "NO_RESOLVED_DEVICES"
                 : stale == 0 ? "READY" : "STALE_SAMPLES";
                 : stale == 0 ? "READY" : "STALE_SAMPLES";
 
 
@@ -263,33 +261,35 @@ public class CockpitMonitoringOverviewService {
         return null;
         return null;
     }
     }
 
 
-    private static int countMonitoringPoints(
+    private static Set<String> selectMonitoringPointCodes(
             CockpitMonitoringOverviewSnapshot snapshot,
             CockpitMonitoringOverviewSnapshot snapshot,
             String selectedIndustry,
             String selectedIndustry,
             String selectedDeviceType,
             String selectedDeviceType,
             Map<String, CockpitMonitoringOverviewSnapshot.SourceType> types) {
             Map<String, CockpitMonitoringOverviewSnapshot.SourceType> types) {
+        Set<String> unique = new LinkedHashSet<>();
         if (snapshot == null || snapshot.getMonitoringPoints() == null) {
         if (snapshot == null || snapshot.getMonitoringPoints() == null) {
-            return 0;
+            return unique;
         }
         }
-        Set<String> unique = new LinkedHashSet<>();
         for (CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint point : snapshot.getMonitoringPoints()) {
         for (CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint point : snapshot.getMonitoringPoints()) {
             if (point == null || isBlank(point.getPointCode())) {
             if (point == null || isBlank(point.getPointCode())) {
                 continue;
                 continue;
             }
             }
             CockpitMonitoringOverviewSnapshot.SourceType type = isBlank(point.getTypeCode())
             CockpitMonitoringOverviewSnapshot.SourceType type = isBlank(point.getTypeCode())
-                    ? null : types.get(point.getTypeCode());
-            if (type == null || !SMART_DEVICE.equals(type.getObjectKind())) {
+                    ? null : types.get(point.getTypeCode().trim());
+            boolean emptyPointWithUnknownType = type == null && point.getAssociatedDeviceCount() == 0;
+            if (!emptyPointWithUnknownType && (type == null || !SMART_DEVICE.equals(type.getObjectKind())
+                    || !INDUSTRIES.contains(type.getIndustry()))) {
                 continue;
                 continue;
             }
             }
-            if (selectedIndustry != null && !selectedIndustry.equals(type.getIndustry())) {
+            if (selectedIndustry != null && (type == null || !selectedIndustry.equals(type.getIndustry()))) {
                 continue;
                 continue;
             }
             }
-            if (!isBlank(selectedDeviceType) && !selectedDeviceType.trim().equals(point.getTypeCode())) {
+            if (!isBlank(selectedDeviceType) && (type == null || !selectedDeviceType.trim().equals(type.getCode()))) {
                 continue;
                 continue;
             }
             }
             unique.add(point.getPointCode().trim());
             unique.add(point.getPointCode().trim());
         }
         }
-        return unique.size();
+        return unique;
     }
     }
 
 
     private static Map<String, CockpitMonitoringOverviewSnapshot.SourceType> types(
     private static Map<String, CockpitMonitoringOverviewSnapshot.SourceType> types(

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

@@ -73,13 +73,21 @@ public class CockpitMonitoringOverviewSnapshot {
     public static class SourceMonitoringPoint {
     public static class SourceMonitoringPoint {
         private final String pointCode;
         private final String pointCode;
         private final String typeCode;
         private final String typeCode;
+        /** -1 means an older adapter did not publish the association fact. */
+        private final int associatedDeviceCount;
 
 
         public SourceMonitoringPoint(String pointCode, String typeCode) {
         public SourceMonitoringPoint(String pointCode, String typeCode) {
+            this(pointCode, typeCode, -1);
+        }
+
+        public SourceMonitoringPoint(String pointCode, String typeCode, int associatedDeviceCount) {
             this.pointCode = pointCode;
             this.pointCode = pointCode;
             this.typeCode = typeCode;
             this.typeCode = typeCode;
+            this.associatedDeviceCount = associatedDeviceCount;
         }
         }
 
 
         public String getPointCode() { return pointCode; }
         public String getPointCode() { return pointCode; }
         public String getTypeCode() { return typeCode; }
         public String getTypeCode() { return typeCode; }
+        public int getAssociatedDeviceCount() { return associatedDeviceCount; }
     }
     }
 }
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentStatus;
 import com.zksy.base.domain.EquipmentStatus;
+import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.service.EarlyWarningService;
 import com.zksy.base.warning.service.EarlyWarningService;
@@ -77,7 +78,7 @@ public class BusinessCockpitDeviceFactResolver {
                 deviceTypeName,
                 deviceTypeName,
                  device.getLongitude(),
                  device.getLongitude(),
                  device.getLatitude(),
                  device.getLatitude(),
-                 false,
+                 CockpitCoordinateValidator.validate(device.getLongitude(), device.getLatitude(), false),
                 online,
                 online,
                 alarm,
                 alarm,
                 hasOpenWarning(deviceCode),
                 hasOpenWarning(deviceCode),
@@ -86,7 +87,8 @@ public class BusinessCockpitDeviceFactResolver {
                 status == null || status.getStatusUpdateTime() == null
                 status == null || status.getStatusUpdateTime() == null
                         ? null
                         ? null
                         : TIME_FORMATTER.format(status.getStatusUpdateTime()
                         : TIME_FORMATTER.format(status.getStatusUpdateTime()
-                                .atZone(BUSINESS_ZONE).toOffsetDateTime()));
+                                .atZone(BUSINESS_ZONE).toOffsetDateTime()),
+                status != null);
     }
     }
 
 
     private boolean hasOpenWarning(String deviceCode) {
     private boolean hasOpenWarning(String deviceCode) {

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

@@ -19,6 +19,7 @@ public class CockpitMonitoringPointDeviceSnapshot {
     private final boolean workOrderInProgress;
     private final boolean workOrderInProgress;
     private final List<String> statusReasons;
     private final List<String> statusReasons;
     private final String statusTime;
     private final String statusTime;
+    private final boolean statusPublished;
 
 
     public CockpitMonitoringPointDeviceSnapshot(String deviceCode, String deviceName, String deviceTypeName,
     public CockpitMonitoringPointDeviceSnapshot(String deviceCode, String deviceName, String deviceTypeName,
             boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
             boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
@@ -40,6 +41,14 @@ public class CockpitMonitoringPointDeviceSnapshot {
             BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
             BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
             boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
             boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
             List<String> statusReasons, String statusTime) {
             List<String> statusReasons, String statusTime) {
+        this(deviceCode, deviceName, deviceTypeName, longitude, latitude, coordinateValidation,
+                online, alarm, warning, workOrderInProgress, statusReasons, statusTime, true);
+    }
+
+    public CockpitMonitoringPointDeviceSnapshot(String deviceCode, String deviceName, String deviceTypeName,
+            BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
+            boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
+            List<String> statusReasons, String statusTime, boolean statusPublished) {
         this.deviceCode = deviceCode;
         this.deviceCode = deviceCode;
         this.deviceName = deviceName;
         this.deviceName = deviceName;
         this.deviceTypeName = deviceTypeName;
         this.deviceTypeName = deviceTypeName;
@@ -52,6 +61,7 @@ public class CockpitMonitoringPointDeviceSnapshot {
         this.workOrderInProgress = workOrderInProgress;
         this.workOrderInProgress = workOrderInProgress;
         this.statusReasons = statusReasons;
         this.statusReasons = statusReasons;
         this.statusTime = statusTime;
         this.statusTime = statusTime;
+        this.statusPublished = statusPublished;
     }
     }
 
 
     public String getDeviceCode() { return deviceCode; }
     public String getDeviceCode() { return deviceCode; }
@@ -66,4 +76,9 @@ public class CockpitMonitoringPointDeviceSnapshot {
     public boolean isWorkOrderInProgress() { return workOrderInProgress; }
     public boolean isWorkOrderInProgress() { return workOrderInProgress; }
     public List<String> getStatusReasons() { return statusReasons; }
     public List<String> getStatusReasons() { return statusReasons; }
     public String getStatusTime() { return statusTime; }
     public String getStatusTime() { return statusTime; }
+    public boolean isStatusPublished() { return statusPublished; }
+    /** 未发布状态与明确离线分离;点位六态聚合仍沿用既有解析器。 */
+    public String getPublishedDeviceStatus() {
+        return statusPublished ? CockpitMonitoringPointStatusResolver.deviceStatus(this).name() : null;
+    }
 }
 }

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

@@ -0,0 +1,96 @@
+package com.zksy.cockpit.point;
+
+import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/** 八桶查询与全局分布。六态/UNKNOWN 数点位,UNASSOCIATED 数未关联设备,互不重复。 */
+public final class CockpitPointStatusQuery {
+    public static final List<String> BUCKETS = Collections.unmodifiableList(Arrays.asList(
+            "ALARM", "WARNING", "WORK_ORDER", "NORMAL", "OFFLINE", "EMPTY", "UNKNOWN", "UNASSOCIATED"));
+    private static final List<String> DEVICE_STATUSES = Arrays.asList(
+            "ALARM", "WARNING", "WORK_ORDER", "NORMAL", "OFFLINE");
+    private final List<String> selected;
+
+    private CockpitPointStatusQuery(List<String> selected) {
+        this.selected = selected;
+    }
+
+    public static CockpitPointStatusQuery parse(String raw) {
+        Set<String> values = new LinkedHashSet<>();
+        if (raw != null && !raw.trim().isEmpty()) {
+            for (String token : raw.split(",", -1)) {
+                String value = token.trim();
+                if (!BUCKETS.contains(value)) {
+                    throw new CockpitInvalidRequestException(
+                            "pointStatus must be ALARM, WARNING, WORK_ORDER, NORMAL, OFFLINE, EMPTY, UNKNOWN or UNASSOCIATED");
+                }
+                values.add(value);
+            }
+        }
+        // 同一集合不因入参顺序不同而有不同回显。
+        List<String> selected = new ArrayList<>(BUCKETS);
+        selected.retainAll(values);
+        return new CockpitPointStatusQuery(Collections.unmodifiableList(selected));
+    }
+
+    public String echo() {
+        return selected.isEmpty() ? null : String.join(",", selected);
+    }
+
+    public boolean matchesPoint(CockpitMonitoringPointStatus status) {
+        return !selected.contains("UNASSOCIATED")
+                && (selected.isEmpty() || selected.contains(pointBucket(status)));
+    }
+
+    public boolean matchesDevice(String status) {
+        return selected.isEmpty()
+                || (selected.size() == 1 && selected.contains("UNASSOCIATED"))
+                || selected.contains(deviceBucket(status));
+    }
+
+    public static String pointBucket(CockpitMonitoringPointStatus status) {
+        return status == null ? "UNKNOWN" : status.name();
+    }
+
+    public static String deviceBucket(String status) {
+        return status != null && DEVICE_STATUSES.contains(status) ? status : "UNKNOWN";
+    }
+
+    public static class Count {
+        private final String status;
+        private final int count;
+
+        public Count(String status, int count) {
+            this.status = status;
+            this.count = count;
+        }
+
+        public String getStatus() { return status; }
+        public int getCount() { return count; }
+    }
+
+    public static class Distribution {
+        private final int[] counts = new int[BUCKETS.size()];
+
+        public void addPoint(CockpitMonitoringPointStatus status) {
+            counts[BUCKETS.indexOf(pointBucket(status))]++;
+        }
+
+        public void addUnassociatedDevice() {
+            counts[BUCKETS.indexOf("UNASSOCIATED")]++;
+        }
+
+        public List<Count> rows() {
+            List<Count> rows = new ArrayList<>();
+            for (int index = 0; index < BUCKETS.size(); index++) {
+                rows.add(new Count(BUCKETS.get(index), counts[index]));
+            }
+            return rows;
+        }
+    }
+}

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

@@ -12,7 +12,10 @@ import com.zksy.base.warning.domain.AlarmWarningRel;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.mapper.AlarmWarningRelMapper;
 import com.zksy.base.warning.mapper.AlarmWarningRelMapper;
 import com.zksy.base.warning.service.EarlyWarningService;
 import com.zksy.base.warning.service.EarlyWarningService;
+import com.zksy.cockpit.foundation.CockpitReadException;
+import org.apache.ibatis.exceptions.PersistenceException;
 import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.Primary;
+import org.springframework.dao.DataAccessException;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.time.ZoneId;
 import java.time.ZoneId;
@@ -63,16 +66,14 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
         // (alarm_data.work_order_id = work_order.order_id,经真实库核实),
         // (alarm_data.work_order_id = work_order.order_id,经真实库核实),
         // 未关联任何报警的工单以 associatedWithCurrentEvent=false 显式标出 ——
         // 未关联任何报警的工单以 associatedWithCurrentEvent=false 显式标出 ——
         // 前端据此提示「未关联当前报警」,而不是从 null 反推(执行票 12 范围 1)。
         // 前端据此提示「未关联当前报警」,而不是从 null 反推(执行票 12 范围 1)。
+        return new CockpitWorkOrderReadSnapshot(deviceCode, null, null, toAlarmSummaries(orders));
+    }
+
+    private List<CockpitWorkOrderSummary> toAlarmSummaries(List<WorkOrder> orders) {
         Map<Long, AlarmData> alarmByOrderId = alarmsByOrderId(orders);
         Map<Long, AlarmData> alarmByOrderId = alarmsByOrderId(orders);
-        List<CockpitWorkOrderSummary> summaries = orders.stream()
-                .map(order -> {
-                    AlarmData alarm = alarmByOrderId.get(order.getOrderId());
-                    return alarm == null
-                            ? toSummary(order, null, null, false)
-                            : toSummary(order, "ALARM", alarmReference(alarm), true);
-                })
+        return orders.stream()
+                .map(order -> toAlarmSummary(order, alarmByOrderId.get(order.getOrderId())))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
-        return new CockpitWorkOrderReadSnapshot(deviceCode, null, null, summaries);
     }
     }
 
 
     /**
     /**
@@ -142,12 +143,20 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
         if (orderIds.isEmpty()) {
         if (orderIds.isEmpty()) {
             return Collections.emptyMap();
             return Collections.emptyMap();
         }
         }
+        List<AlarmData> alarms;
+        try {
+            alarms = alarmDataService.list(new LambdaQueryWrapper<AlarmData>()
+                    .in(AlarmData::getWorkOrderId, orderIds));
+        } catch (DataAccessException | PersistenceException exception) {
+            throw new CockpitReadException("work order association read failed");
+        }
         Map<Long, AlarmData> result = new LinkedHashMap<>();
         Map<Long, AlarmData> result = new LinkedHashMap<>();
-        for (AlarmData alarm : alarmDataService.list(new LambdaQueryWrapper<AlarmData>()
-                .in(AlarmData::getWorkOrderId, orderIds))) {
+        for (AlarmData alarm : alarms) {
             if (alarm != null && alarm.getWorkOrderId() != null) {
             if (alarm != null && alarm.getWorkOrderId() != null) {
-                // 同一工单若被多条报警引用,取最先返回的一条即可(不臆造「主报警」规则)。
-                result.putIfAbsent(alarm.getWorkOrderId(), alarm);
+                // 工单与报警按一对一消费;多条引用是数据异常,不静默选取主报警。
+                if (result.putIfAbsent(alarm.getWorkOrderId(), alarm) != null) {
+                    throw new CockpitReadException("multiple alarms reference the same work order");
+                }
             }
             }
         }
         }
         return result;
         return result;
@@ -167,9 +176,7 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
             // 回显的 eventCode 用报警真实单号(与请求标识一致的可读值)。
             // 回显的 eventCode 用报警真实单号(与请求标识一致的可读值)。
             String resolvedEventCode = alarm == null ? eventCode : alarmReference(alarm);
             String resolvedEventCode = alarm == null ? eventCode : alarmReference(alarm);
             return new CockpitWorkOrderReadSnapshot(null, eventSource, resolvedEventCode,
             return new CockpitWorkOrderReadSnapshot(null, eventSource, resolvedEventCode,
-                    orders.stream()
-                            .map(order -> toSummary(order, eventSource, resolvedEventCode, true))
-                            .collect(Collectors.toList()));
+                    toAlarmSummaries(orders));
         }
         }
         if ("WARNING".equals(eventSource)) {
         if ("WARNING".equals(eventSource)) {
             EarlyWarning warning = earlyWarningService.lambdaQuery()
             EarlyWarning warning = earlyWarningService.lambdaQuery()
@@ -209,8 +216,17 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
         List<CockpitWorkOrderTimelineEntry> entries = logs.stream()
         List<CockpitWorkOrderTimelineEntry> entries = logs.stream()
                 .map(log -> toTimelineEntry(order, log))
                 .map(log -> toTimelineEntry(order, log))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
-        // 时间线单张工单:无「当前报警」语境,关联标记同设备维度。
-        return new CockpitWorkOrderTimelineSnapshot(toSummary(order, null, null, false), entries);
+        // 时间线与设备维度按同一真实关联键解析,不因缺少事件查询参数而标为未关联。
+        AlarmData alarm = alarmsByOrderId(Collections.singletonList(order)).get(order.getOrderId());
+        return new CockpitWorkOrderTimelineSnapshot(toAlarmSummary(order, alarm), entries);
+    }
+
+    private CockpitWorkOrderSummary toAlarmSummary(WorkOrder order, AlarmData alarm) {
+        boolean associated = alarm != null && order.getOrderId() != null
+                && order.getOrderId().equals(alarm.getWorkOrderId());
+        return associated
+                ? toSummary(order, "ALARM", alarmReference(alarm), true)
+                : toSummary(order, null, null, false);
     }
     }
 
 
     private CockpitWorkOrderSummary toSummary(
     private CockpitWorkOrderSummary toSummary(