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

feat(cockpit): 补齐设施后端接口与统一状态契约

Kazerin 2 недель назад
Родитель
Сommit
7b97d6202f
14 измененных файлов с 617 добавлено и 104 удалено
  1. 44 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/cockpit/CockpitDictController.java
  2. 90 3
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureBaseArchivesAdapterTest.java
  3. 3 3
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitInfrastructureOperatingInformationAdapterTest.java
  4. 1 1
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitOverviewInfrastructureAdapterTest.java
  5. 42 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitDictControllerTest.java
  6. 128 38
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitEntityDetailServiceTest.java
  7. 28 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityContractTest.java
  8. 2 2
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitFacilityCountCrossEndpointContractTest.java
  9. 2 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/entity/CockpitEntityCategory.java
  10. 96 24
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/entity/CockpitEntityDetailService.java
  11. 15 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitDictRow.java
  12. 36 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitFacilityContract.java
  13. 42 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureBaseArchivesAdapter.java
  14. 88 27
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureOperatingInformationAdapter.java

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

@@ -0,0 +1,44 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitDictRow;
+import com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.core.domain.entity.SysDictData;
+import com.zksy.system.service.ISysDictTypeService;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 驾驶舱域的字典透传端点:前端只读 /api/cockpit/v1,不直连管理平台。
+ * 返回 sys_dict_data 原行(dictValue/dictLabel),不在前端硬编码词表。
+ */
+@RestController
+@RequestMapping("/api/cockpit/v1/dict")
+public class CockpitDictController {
+    /** 只透传驾驶舱契约需要的字典,避免把后台任意字典暴露到公开端点。 */
+    private static final List<String> ALLOWED = Collections.singletonList("pump_station_type");
+
+    private final ISysDictTypeService dictTypeService;
+
+    public CockpitDictController(ISysDictTypeService dictTypeService) {
+        this.dictTypeService = dictTypeService;
+    }
+
+    @GetMapping("/{dictType}")
+    public ResponseEntity<AjaxResult> dictType(@PathVariable String dictType) {
+        if (!ALLOWED.contains(dictType)) {
+            return ResponseEntity.ok(AjaxResult.success(Collections.emptyList()));
+        }
+        List<SysDictData> rows = dictTypeService.selectDictDataByType(dictType);
+        List<CockpitDictRow> published = rows == null ? Collections.emptyList() : rows.stream()
+                .map(row -> new CockpitDictRow(row.getDictValue(), row.getDictLabel()))
+                .collect(Collectors.toList());
+        return ResponseEntity.ok(AjaxResult.success(published));
+    }
+}

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

@@ -1,15 +1,24 @@
 package com.zksy.web.controller.cockpit;
 package com.zksy.web.controller.cockpit;
 
 
+import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
+import com.zksy.WaterSupply.WaterSourceInfo.domain.WaterSourceInfo;
+import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
+import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.PipeNetworkBase;
+import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureBaseArchivesAdapter;
 import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureBaseArchivesAdapter;
 import com.zksy.cockpit.infrastructure.CockpitInfrastructureBaseArchivesSnapshot;
 import com.zksy.cockpit.infrastructure.CockpitInfrastructureBaseArchivesSnapshot;
+import com.zksy.cockpit.infrastructure.CockpitInfrastructureBaseArchivesSnapshot.SourceFacility;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageGateInfoService;
@@ -38,6 +47,8 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
     private PipeNetworkBaseService pipeNetworkBaseService;
     private PipeNetworkBaseService pipeNetworkBaseService;
     private DrainageGateInfoService gateService;
     private DrainageGateInfoService gateService;
     private DrainageStorageInfoService storageService;
     private DrainageStorageInfoService storageService;
+    private IWaterUserInfoService waterUserService;
+    private IWaterFireHydrantInfoService hydrantService;
     private BusinessCockpitInfrastructureBaseArchivesAdapter adapter;
     private BusinessCockpitInfrastructureBaseArchivesAdapter adapter;
 
 
     @BeforeEach
     @BeforeEach
@@ -47,10 +58,13 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
         pipeNetworkBaseService = mock(PipeNetworkBaseService.class);
         pipeNetworkBaseService = mock(PipeNetworkBaseService.class);
         gateService = mock(DrainageGateInfoService.class);
         gateService = mock(DrainageGateInfoService.class);
         storageService = mock(DrainageStorageInfoService.class);
         storageService = mock(DrainageStorageInfoService.class);
+        waterUserService = mock(IWaterUserInfoService.class);
+        hydrantService = mock(IWaterFireHydrantInfoService.class);
         adapter = new BusinessCockpitInfrastructureBaseArchivesAdapter(
         adapter = new BusinessCockpitInfrastructureBaseArchivesAdapter(
                 plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
                 plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
                 mock(com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService.class),
                 mock(com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService.class),
-                mock(com.zksy.base.service.ManholeBaseService.class));
+                mock(com.zksy.base.service.ManholeBaseService.class),
+                waterUserService, hydrantService);
     }
     }
 
 
     @Test
     @Test
@@ -86,7 +100,7 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
         CockpitInfrastructureBaseArchivesSnapshot snapshot = adapter.load();
         CockpitInfrastructureBaseArchivesSnapshot snapshot = adapter.load();
 
 
         assertEquals(4, snapshot.getFacilities().size());
         assertEquals(4, snapshot.getFacilities().size());
-        assertEquals(10, snapshot.getTypes().size());
+        assertEquals(12, snapshot.getTypes().size());
         assertEquals("DRAINAGE_STORAGE", snapshot.getTypes().get(6).getCode());
         assertEquals("DRAINAGE_STORAGE", snapshot.getTypes().get(6).getCode());
         // 设施表都没有 equipment_base.district 那种权威片区来源;本夹具的编码(PLANT-001/
         // 设施表都没有 equipment_base.district 那种权威片区来源;本夹具的编码(PLANT-001/
         // PUMP-001/PIPE-001/DRAIN-001)都不带片区前缀,故全部如实报未分区(票 81)。
         // PUMP-001/PIPE-001/DRAIN-001)都不带片区前缀,故全部如实报未分区(票 81)。
@@ -205,6 +219,79 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
                 "只有三条管线应带片区");
                 "只有三条管线应带片区");
     }
     }
 
 
+    /** 九类设施来源中的用水户、消火栓必须进入正式目录;缺编码行仍按 UNCLASSIFIED 哨兵保留。 */
+    @Test
+    void includesWaterUsersAndFireHydrantsWithStableSourceKeysAndUnclassifiedRows() {
+        WaterUserInfo user = new WaterUserInfo();
+        user.setId("USER-ID-1");
+        user.setUserCode("USER-001");
+        WaterUserInfo missingCode = new WaterUserInfo();
+        missingCode.setId("USER-ID-2");
+        WaterFireHydrantInfo hydrant = new WaterFireHydrantInfo();
+        hydrant.setHydrantId("HYDRANT-ID-1");
+        hydrant.setHydrantCode("HYDRANT-001");
+
+        when(plantService.list()).thenReturn(Collections.emptyList());
+        when(pumpStationService.list()).thenReturn(Collections.emptyList());
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.emptyList());
+        when(storageService.listAll()).thenReturn(Collections.emptyList());
+        when(waterUserService.list()).thenReturn(Arrays.asList(user, missingCode));
+        when(hydrantService.list()).thenReturn(Collections.singletonList(hydrant));
+
+        CockpitInfrastructureBaseArchivesSnapshot snapshot = adapter.load();
+
+        assertEquals(12, snapshot.getTypes().size());
+        assertEquals("WATER_USER", snapshot.getTypes().get(10).getCode());
+        assertEquals("WATER_SUPPLY", snapshot.getTypes().get(10).getIndustry());
+        assertEquals("WATER_FIRE_HYDRANT", snapshot.getTypes().get(11).getCode());
+        assertEquals("WATER_SUPPLY", snapshot.getTypes().get(11).getIndustry());
+        assertEquals(3, snapshot.getFacilities().size());
+
+        SourceFacility userFacility = facility(snapshot.getFacilities(), "USER-001");
+        assertEquals("water_user_info|USER-ID-1", userFacility.getSourceKey());
+        assertEquals("WATER_USER", userFacility.getTypeCode());
+        assertNull(userFacility.getDistrict(), "用水户编码没有片区语义");
+        SourceFacility hydrantFacility = facility(snapshot.getFacilities(), "HYDRANT-001");
+        assertEquals("water_fire_hydrant_info|HYDRANT-ID-1", hydrantFacility.getSourceKey());
+        assertEquals("WATER_FIRE_HYDRANT", hydrantFacility.getTypeCode());
+        assertNull(hydrantFacility.getDistrict(), "消火栓编码没有片区语义");
+
+        SourceFacility unclassified = snapshot.getFacilities().stream()
+                .filter(item -> "FACILITY_UNCLASSIFIED".equals(item.getTypeCode()))
+                .findFirst().orElseThrow(AssertionError::new);
+        assertTrue(unclassified.getCode().startsWith("MISSING_CODE:"));
+        assertTrue(unclassified.getSourceKey().startsWith("water_user_info|"));
+    }
+
+    /** 泵站类型物理字符串与字典码 0/1 必须同等归类,避免详情页认得、统计页丢失(评审修复)。 */
+    @Test void classifiesNumericStationTypeCodesLikePhysicalValues() {
+        IWaterPlantInfoService plants = mock(IWaterPlantInfoService.class);
+        IPumpStationInfoService stations = mock(IPumpStationInfoService.class);
+        PipeNetworkBaseService pipes = mock(PipeNetworkBaseService.class);
+        DrainageGateInfoService gates = mock(DrainageGateInfoService.class);
+        DrainageStorageInfoService storages = mock(DrainageStorageInfoService.class);
+        IWaterSourceInfoService sources = mock(IWaterSourceInfoService.class);
+        ManholeBaseService manholes = mock(ManholeBaseService.class);
+        IWaterUserInfoService users = mock(IWaterUserInfoService.class);
+        IWaterFireHydrantInfoService hydrants = mock(IWaterFireHydrantInfoService.class);
+        when(plants.list()).thenReturn(Collections.emptyList());
+        PumpStationInfo supply = new PumpStationInfo(); supply.setId("S0"); supply.setStationCode("PS-0"); supply.setStationType("0");
+        PumpStationInfo drainage = new PumpStationInfo(); drainage.setId("S1"); drainage.setStationCode("PS-1"); drainage.setStationType("1");
+        when(stations.list()).thenReturn(Arrays.asList(supply, drainage));
+        when(pipes.list()).thenReturn(Collections.emptyList());
+        when(gates.listAll()).thenReturn(Collections.emptyList());
+        when(storages.listAll()).thenReturn(Collections.emptyList());
+        when(sources.list()).thenReturn(Collections.emptyList());
+        when(manholes.list()).thenReturn(Collections.emptyList());
+        when(users.list()).thenReturn(Collections.emptyList());
+        when(hydrants.list()).thenReturn(Collections.emptyList());
+        CockpitInfrastructureBaseArchivesSnapshot snapshot = new BusinessCockpitInfrastructureBaseArchivesAdapter(
+                plants, stations, pipes, gates, storages, sources, manholes, users, hydrants).load();
+        assertEquals("WATER_PUMP_STATION", facility(snapshot.getFacilities(), "PS-0").getTypeCode());
+        assertEquals("DRAINAGE_PUMP_STATION", facility(snapshot.getFacilities(), "PS-1").getTypeCode());
+        assertTrue(snapshot.getFacilities().stream().noneMatch(f -> "FACILITY_UNCLASSIFIED".equals(f.getTypeCode())));
+    }
     private static CockpitInfrastructureBaseArchivesSnapshot.SourceFacility facility(
     private static CockpitInfrastructureBaseArchivesSnapshot.SourceFacility facility(
             List<CockpitInfrastructureBaseArchivesSnapshot.SourceFacility> facilities, String code) {
             List<CockpitInfrastructureBaseArchivesSnapshot.SourceFacility> facilities, String code) {
         return facilities.stream()
         return facilities.stream()
@@ -221,4 +308,4 @@ class BusinessCockpitInfrastructureBaseArchivesAdapterTest {
         pipe.setLength(new BigDecimal(length));
         pipe.setLength(new BigDecimal(length));
         return pipe;
         return pipe;
     }
     }
-}
+}

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

@@ -162,8 +162,8 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
         when(gateService.listAll()).thenReturn(Collections.emptyList());
         when(gateService.listAll()).thenReturn(Collections.emptyList());
         when(storageService.listAll()).thenReturn(Collections.emptyList());
         when(storageService.listAll()).thenReturn(Collections.emptyList());
         when(manholeBaseService.list()).thenReturn(Arrays.asList(
         when(manholeBaseService.list()).thenReturn(Arrays.asList(
-                manhole("MH-001", "沅陵县窨井001", "FINE"),
-                manhole("MH-002", "沅陵县窨井002", "BROKEN")));
+                manhole("MH-001", "沅陵县窨井001", "0"),
+                manhole("MH-002", "沅陵县窨井002", "1")));
 
 
         CockpitInfrastructureOperatingInformationSnapshot snapshot = adapter.load();
         CockpitInfrastructureOperatingInformationSnapshot snapshot = adapter.load();
 
 
@@ -174,7 +174,7 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
         assertEquals("manhole_point_count", first.getMetricCode());
         assertEquals("manhole_point_count", first.getMetricCode());
         assertEquals("座", first.getUnit());
         assertEquals("座", first.getUnit());
         assertEquals(BigDecimal.ONE, first.getValue());
         assertEquals(BigDecimal.ONE, first.getValue());
-        assertEquals("MH-001", first.getFacilityId());
+        assertEquals("ID-MH-001", first.getFacilityId()); // 主键是稳定身份;业务码在 pointCodes
         assertFalse(first.isAbnormal(), "状态正常(0)不算异常");
         assertFalse(first.isAbnormal(), "状态正常(0)不算异常");
         assertTrue(snapshot.getMetrics().get(1).isAbnormal(), "非 0 状态如实标记为异常");
         assertTrue(snapshot.getMetrics().get(1).isAbnormal(), "非 0 状态如实标记为异常");
     }
     }

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

@@ -78,7 +78,7 @@ class BusinessCockpitOverviewInfrastructureAdapterTest {
 
 
         CockpitOverviewInfrastructureSnapshot snapshot = adapter.load();
         CockpitOverviewInfrastructureSnapshot snapshot = adapter.load();
 
 
-        assertEquals(12, snapshot.getTypes().size());
+        assertEquals(14, snapshot.getTypes().size()); // 设施目录新增用水户与消火栓两类
         assertEquals("2026-09-02T09:59:50+08:00", snapshot.getUpdatedAt());
         assertEquals("2026-09-02T09:59:50+08:00", snapshot.getUpdatedAt());
 
 
         long deviceCount = snapshot.getCounts().stream()
         long deviceCount = snapshot.getCounts().stream()

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

@@ -0,0 +1,42 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.common.core.domain.entity.SysDictData;
+import com.zksy.system.service.ISysDictTypeService;
+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.util.Arrays;
+
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+class CockpitDictControllerTest {
+    private final ISysDictTypeService dictTypeService = mock(ISysDictTypeService.class);
+    private MockMvc mvc;
+
+    @BeforeEach void setup() { mvc = MockMvcBuilders.standaloneSetup(new CockpitDictController(dictTypeService)).build(); }
+
+    @Test void exposesPumpStationTypeDictionaryUnderCockpitDomain() throws Exception {
+        SysDictData supply = new SysDictData(); supply.setDictType("pump_station_type"); supply.setDictValue("0"); supply.setDictLabel("供水泵站");
+        SysDictData drainage = new SysDictData(); drainage.setDictType("pump_station_type"); drainage.setDictValue("1"); drainage.setDictLabel("排水泵站");
+        when(dictTypeService.selectDictDataByType("pump_station_type")).thenReturn(Arrays.asList(supply, drainage));
+        mvc.perform(get("/api/cockpit/v1/dict/pump_station_type"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(200))
+                .andExpect(jsonPath("$.data[0].dictValue").value("0"))
+                .andExpect(jsonPath("$.data[0].dictLabel").value("供水泵站"))
+                .andExpect(jsonPath("$.data[1].dictValue").value("1"));
+        verify(dictTypeService).selectDictDataByType("pump_station_type");
+    }
+
+    @Test void missingDictionaryIsEmptyNotError() throws Exception {
+        when(dictTypeService.selectDictDataByType("unknown_type")).thenReturn(null);
+        mvc.perform(get("/api/cockpit/v1/dict/unknown_type"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(200))
+                .andExpect(jsonPath("$.data.length()").value(0));
+    }
+}

+ 128 - 38
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitEntityDetailServiceTest.java

@@ -1,13 +1,18 @@
 package com.zksy.web.controller.cockpit;
 package com.zksy.web.controller.cockpit;
 
 
+import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.base.domain.*;
 import com.zksy.base.domain.*;
 import com.zksy.base.service.*;
 import com.zksy.base.service.*;
 import com.zksy.cockpit.entity.*;
 import com.zksy.cockpit.entity.*;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageGateInfo;
+import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
@@ -25,7 +30,9 @@ class CockpitEntityDetailServiceTest {
     private final HazardHiddenAccountService hazards = mock(HazardHiddenAccountService.class);
     private final HazardHiddenAccountService hazards = mock(HazardHiddenAccountService.class);
     private final RiskAssessmentService risks = mock(RiskAssessmentService.class);
     private final RiskAssessmentService risks = mock(RiskAssessmentService.class);
     private final ManholeBaseService manholes = mock(ManholeBaseService.class);
     private final ManholeBaseService manholes = mock(ManholeBaseService.class);
-    private final CockpitEntityDetailService service = new CockpitEntityDetailService(pipes, plants, stations, equipment, gates, storages, equipmentStatuses, hazards, risks, manholes);
+    private final IWaterUserInfoService users = mock(IWaterUserInfoService.class);
+    private final IWaterFireHydrantInfoService hydrants = mock(IWaterFireHydrantInfoService.class);
+    private final CockpitEntityDetailService service = new CockpitEntityDetailService(pipes, plants, stations, equipment, gates, storages, equipmentStatuses, hazards, risks, manholes, users, hydrants);
 
 
     @Test void resolvesEverySupportedCategoryWithStableAttributes() {
     @Test void resolvesEverySupportedCategoryWithStableAttributes() {
         PipeNetworkBase pipe = new PipeNetworkBase(); pipe.setNetworkId("p1"); pipe.setNetworkCode("PN1"); pipe.setNetworkName("管网"); pipe.setMaterial("PE"); when(pipes.getById("p1")).thenReturn(pipe);
         PipeNetworkBase pipe = new PipeNetworkBase(); pipe.setNetworkId("p1"); pipe.setNetworkCode("PN1"); pipe.setNetworkName("管网"); pipe.setMaterial("PE"); when(pipes.getById("p1")).thenReturn(pipe);
@@ -56,44 +63,127 @@ class CockpitEntityDetailServiceTest {
         assertEquals("HIGH", service.load("q", "protection-target", "r1").getAttributes().get("riskLevel"));
         assertEquals("HIGH", service.load("q", "protection-target", "r1").getAttributes().get("riskLevel"));
     }
     }
 
 
-    /**
-     * 窨井详情(维护者 2026-11-16)。
-     *
-     * <p>原话:「设施台账中的窨井卡片无法展开详情,提示为『设施类别未发布,无法展开详情』」。
-     * 根因是后端枚举与 switch 都没有 MANHOLE —— 前端白名单只是第二道门。
-     * 本用例钉住:category=MANHOLE 能解析、能按 manhole_base 主键取到详情,
-     * 且井深/形状/材质/权属这些窨井专有字段如实下发。</p>
-     */
-    @Test void resolvesManholeCategoryWithItsOwnAttributes() {
-        ManholeBase manhole = new ManholeBase();
-        manhole.setManholeId("mh-1");
-        manhole.setManholeCode("YL-YJ-002");
-        manhole.setManholeName("沅陵县窨井002");
-        manhole.setManholeDepth(new java.math.BigDecimal("12.0"));
-        manhole.setManholeShape("0");
-        manhole.setMaterial("铁");
-        manhole.setOwnershipUnit("沅陵县燃气公司");
-        manhole.setLocation("龙兴路");
-        manhole.setLongitude(new java.math.BigDecimal("110.440"));
-        manhole.setLatitude(new java.math.BigDecimal("28.450"));
-        manhole.setStatus("0");
-        when(manholes.getById("mh-1")).thenReturn(manhole);
+  /**
+   * 窨井详情(维护者 2026-11-16)。
+   *
+   * <p>原话:「设施台账中的窨井卡片无法展开详情,提示为『设施类别未发布,无法展开详情』」。
+   * 根因是后端枚举与 switch 都没有 MANHOLE —— 前端白名单只是第二道门。
+   * 本用例钉住:category=MANHOLE 能解析、能按 manhole_base 主键取到详情,
+   * 且井深/形状/材质/权属这些窨井专有字段如实下发。</p>
+   */
+  @Test void resolvesManholeCategoryWithItsOwnAttributes() {
+      ManholeBase manhole = new ManholeBase();
+      manhole.setManholeId("mh-1");
+      manhole.setManholeCode("YL-YJ-002");
+      manhole.setManholeName("沅陵县窨井002");
+      manhole.setManholeDepth(new java.math.BigDecimal("12.0"));
+      manhole.setManholeShape("0");
+      manhole.setMaterial("铁");
+      manhole.setOwnershipUnit("沅陵县燃气公司");
+      manhole.setLocation("龙兴路");
+      manhole.setLongitude(new java.math.BigDecimal("110.440"));
+      manhole.setLatitude(new java.math.BigDecimal("28.450"));
+      manhole.setStatus("0");
+      when(manholes.getById("mh-1")).thenReturn(manhole);
 
 
-        CockpitEntityDetailResponse detail = service.load("q", "MANHOLE", "mh-1");
+      CockpitEntityDetailResponse detail = service.load("q", "MANHOLE", "mh-1");
 
 
-        assertEquals("MANHOLE", detail.getCategory());
-        assertEquals("YL-YJ-002", detail.getCode());
-        assertEquals("沅陵县窨井002", detail.getName());
-        assertEquals(new java.math.BigDecimal("12.0"), detail.getAttributes().get("manholeDepth"));
-        assertEquals("铁", detail.getAttributes().get("material"));
-        assertEquals("沅陵县燃气公司", detail.getAttributes().get("ownershipUnit"));
-        assertEquals(new java.math.BigDecimal("110.440"), detail.getCoordinates().getLongitude());
-        assertEquals(new java.math.BigDecimal("28.450"), detail.getCoordinates().getLatitude());
-    }
+      assertEquals("MANHOLE", detail.getCategory());
+      assertEquals("YL-YJ-002", detail.getCode());
+      assertEquals("沅陵县窨井002", detail.getName());
+      assertEquals(new java.math.BigDecimal("12.0"), detail.getAttributes().get("manholeDepth"));
+      assertEquals("铁", detail.getAttributes().get("material"));
+      assertEquals("沅陵县燃气公司", detail.getAttributes().get("ownershipUnit"));
+      assertEquals(new java.math.BigDecimal("110.440"), detail.getCoordinates().getLongitude());
+      assertEquals(new java.math.BigDecimal("28.450"), detail.getCoordinates().getLatitude());
+  }
 
 
-    @Test void rejectsUnknownCategoryAndMissingEntity() {
-        assertThrows(RuntimeException.class, () -> service.load("q", "OTHER", "x"));
-        assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "PIPE_NETWORK", "missing"));
-        assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "MANHOLE", "missing"));
-    }
+  @Test void rejectsUnknownCategoryAndMissingEntity() {
+      assertThrows(RuntimeException.class, () -> service.load("q", "OTHER", "x"));
+      assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "PIPE_NETWORK", "missing"));
+      assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "MANHOLE", "missing"));
+      assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "WATER_USER", "missing"));
+      assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "WATER_FIRE_HYDRANT", "missing"));
+  }
+
+  /** 四个新增详情类别各走自己的 loader,并下发各自真实字段与规范化状态。 */
+  @Test void resolvesFourNewDetailCategories() {
+      DrainageGateInfo gate = new DrainageGateInfo();
+      gate.setFacilityId("g-new"); gate.setFacilityCode("G-NEW"); gate.setFacilityName("排水闸门");
+      gate.setStatus("检修"); gate.setLocation("东堤");
+      when(gates.getEntityById("g-new")).thenReturn(gate);
+      CockpitEntityDetailResponse gateDetail = service.load("q", "drainage-gate", "g-new");
+      assertEquals("DRAINAGE_GATE", gateDetail.getCategory());
+      assertEquals("G-NEW", gateDetail.getCode());
+      assertEquals("1", gateDetail.getStatus());
+
+      DrainageStorageInfo storage = new DrainageStorageInfo();
+      storage.setFacilityId("s-new"); storage.setFacilityCode("S-NEW"); storage.setFacilityName("调蓄池");
+      storage.setStatus("0"); storage.setStorageCapacity(new java.math.BigDecimal("500"));
+      when(storages.getEntityById("s-new")).thenReturn(storage);
+      CockpitEntityDetailResponse storageDetail = service.load("q", "DRAINAGE_STORAGE", "s-new");
+      assertEquals("DRAINAGE_STORAGE", storageDetail.getCategory());
+      assertEquals("0", storageDetail.getStatus());
+      assertEquals(new java.math.BigDecimal("500"), storageDetail.getAttributes().get("storageCapacity"));
+
+      WaterUserInfo user = new WaterUserInfo();
+      user.setId("u-new"); user.setUserCode("USER_NEW"); user.setUserName("某用水户"); user.setUserType("居民");
+      user.setAddress("人民路1号"); user.setContactPerson("张三"); user.setContactPhone("13800138000");
+      user.setMeterNumber("M-NEW"); user.setInitialReading(new java.math.BigDecimal("0.00"));
+      user.setCurrentReading(new java.math.BigDecimal("125.50"));
+      user.setAnnualWaterConsumption(new java.math.BigDecimal("180.00")); user.setStatus("欠费"); user.setRemark("用水备注");
+      user.setLongitude(new java.math.BigDecimal("110.100")); user.setLatitude(new java.math.BigDecimal("28.100"));
+      when(users.getById("u-new")).thenReturn(user);
+      CockpitEntityDetailResponse userDetail = service.load("q", "WATER_USER", "u-new");
+      assertEquals("WATER_USER", userDetail.getCategory());
+      assertEquals("USER_NEW", userDetail.getCode());
+      assertEquals("某用水户", userDetail.getName());
+      assertEquals("1", userDetail.getStatus());
+      assertEquals("居民", userDetail.getAttributes().get("userType"));
+      assertEquals("人民路1号", userDetail.getAttributes().get("address"));
+      assertEquals("张三", userDetail.getAttributes().get("contactPerson"));
+      assertEquals("M-NEW", userDetail.getAttributes().get("meterNumber"));
+      assertEquals(new java.math.BigDecimal("180.00"), userDetail.getAttributes().get("annualWaterConsumption"));
+      assertEquals(new java.math.BigDecimal("110.100"), userDetail.getCoordinates().getLongitude());
+      assertEquals(new java.math.BigDecimal("28.100"), userDetail.getCoordinates().getLatitude());
+
+      WaterFireHydrantInfo hydrant = new WaterFireHydrantInfo();
+      hydrant.setHydrantId("h-new"); hydrant.setHydrantCode("FH-NEW"); hydrant.setHydrantName("中山路消火栓");
+      hydrant.setHydrantType("0"); hydrant.setModel("SS100"); hydrant.setInletPipeDiameter("DN100");
+      hydrant.setOutletSpec("2xDN65"); hydrant.setOwnershipUnit("自来水公司"); hydrant.setMaintenanceUnit("消防救援大队");
+      hydrant.setPrincipal("李四"); hydrant.setContactPhone("13900139000"); hydrant.setLocation("中山路");
+      hydrant.setStatus("0"); hydrant.setRemark("消火栓备注");
+      hydrant.setLongitude(new java.math.BigDecimal("110.200")); hydrant.setLatitude(new java.math.BigDecimal("28.200"));
+      when(hydrants.getById("h-new")).thenReturn(hydrant);
+      CockpitEntityDetailResponse hydrantDetail = service.load("q", "WATER_FIRE_HYDRANT", "h-new");
+      assertEquals("WATER_FIRE_HYDRANT", hydrantDetail.getCategory());
+      assertEquals("FH-NEW", hydrantDetail.getCode());
+      assertEquals("中山路消火栓", hydrantDetail.getName());
+      assertEquals("0", hydrantDetail.getStatus());
+      assertEquals("0", hydrantDetail.getAttributes().get("hydrantType"));
+      assertEquals("DN100", hydrantDetail.getAttributes().get("inletPipeDiameter"));
+      assertEquals("消防救援大队", hydrantDetail.getAttributes().get("maintenanceUnit"));
+      assertEquals("中山路", hydrantDetail.getAttributes().get("location"));
+      assertEquals(new java.math.BigDecimal("110.200"), hydrantDetail.getCoordinates().getLongitude());
+      assertEquals(new java.math.BigDecimal("28.200"), hydrantDetail.getCoordinates().getLatitude());
+  }
+
+  /** 旧状态值归一为 0/1;泵站 stationType 由 water_supply/drainage 归一为字典码 0/1。 */
+  @Test void publishesNormalizedStatusAndPumpStationTypeCode() {
+      PumpStationInfo supply = new PumpStationInfo();
+      supply.setId("ps-supply"); supply.setStationCode("PS-S"); supply.setStationName("供水泵站");
+      supply.setStationType("water_supply"); supply.setStatus("0");
+      when(stations.getById("ps-supply")).thenReturn(supply);
+      CockpitEntityDetailResponse supplyDetail = service.load("q", "PUMP_STATION", "ps-supply");
+      assertEquals("0", supplyDetail.getStatus());
+      assertEquals("0", supplyDetail.getAttributes().get("stationType"));
+
+      PumpStationInfo drainage = new PumpStationInfo();
+      drainage.setId("ps-drain"); drainage.setStationCode("PS-D"); drainage.setStationName("排水泵站");
+      drainage.setStationType("drainage"); drainage.setStatus("检修");
+      when(stations.getById("ps-drain")).thenReturn(drainage);
+      CockpitEntityDetailResponse drainageDetail = service.load("q", "PUMP_STATION", "ps-drain");
+      assertEquals("1", drainageDetail.getStatus());
+      assertEquals("1", drainageDetail.getAttributes().get("stationType"));
+  }
 }
 }

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

@@ -0,0 +1,28 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CockpitFacilityContractTest {
+    @Test void facilityStatusPublishesOnlyZeroOrOne() {
+        assertEquals("0", CockpitFacilityContract.normalizeStatus("0"));
+        assertEquals("0", CockpitFacilityContract.normalizeStatus("NORMAL"));
+        for (String legacy : new String[]{"1", "2", "3", "欠费", "检修", "water_supply"}) {
+            assertEquals("1", CockpitFacilityContract.normalizeStatus(legacy));
+        }
+        assertNull(CockpitFacilityContract.normalizeStatus(null));
+        assertNull(CockpitFacilityContract.normalizeStatus("  "));
+        assertFalse(CockpitFacilityContract.isAbnormalStatus("0"));
+        assertTrue(CockpitFacilityContract.isAbnormalStatus("2"));
+    }
+
+    @Test void pumpStationTypePublishesDictionaryCodes() {
+        assertEquals("0", CockpitFacilityContract.pumpStationTypeCode("water_supply"));
+        assertEquals("1", CockpitFacilityContract.pumpStationTypeCode("drainage"));
+        assertEquals("0", CockpitFacilityContract.pumpStationTypeCode("0"));
+        assertEquals("1", CockpitFacilityContract.pumpStationTypeCode("1"));
+        assertNull(CockpitFacilityContract.pumpStationTypeCode("unknown"));
+    }
+}

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

@@ -80,7 +80,7 @@ class CockpitFacilityCountCrossEndpointContractTest {
         when(manholes.list()).thenReturn(Collections.singletonList(manhole));
         when(manholes.list()).thenReturn(Collections.singletonList(manhole));
         CockpitFacilityCatalog catalog = new BusinessCockpitInfrastructureBaseArchivesAdapter(
         CockpitFacilityCatalog catalog = new BusinessCockpitInfrastructureBaseArchivesAdapter(
                 plants, stations, pipes, gates, storages, sources, manholes);
                 plants, stations, pipes, gates, storages, sources, manholes);
-        assertThreeEndpoints(catalog, 10, 4);
+        assertThreeEndpoints(catalog, 12, 3);
     }
     }
 
 
     @Test
     @Test
@@ -105,7 +105,7 @@ class CockpitFacilityCountCrossEndpointContractTest {
         Map<String, Integer> expected = new HashMap<>();
         Map<String, Integer> expected = new HashMap<>();
         expected.put("GAS", total == 0 ? 0 : 1);
         expected.put("GAS", total == 0 ? 0 : 1);
         expected.put("WATER_SUPPLY", total == 0 ? 0 : 4);
         expected.put("WATER_SUPPLY", total == 0 ? 0 : 4);
-        expected.put("DRAINAGE", total == 0 ? 0 : 4);
+        expected.put("DRAINAGE", total == 0 ? 0 : 6);
         expected.put("MANHOLE", total == 0 ? 0 : 1);
         expected.put("MANHOLE", total == 0 ? 0 : 1);
         assertEquals(expected, industryCounts(archives, "industryDistribution", "code", "count"));
         assertEquals(expected, industryCounts(archives, "industryDistribution", "code", "count"));
         assertEquals(expected, industryCounts(overview, "industries", "code", "facilityCount"));
         assertEquals(expected, industryCounts(overview, "industries", "code", "facilityCount"));

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

@@ -5,7 +5,8 @@ import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import java.util.Locale;
 import java.util.Locale;
 
 
 public enum CockpitEntityCategory {
 public enum CockpitEntityCategory {
-    PIPE_NETWORK, WATER_PLANT, PUMP_STATION, ENGINEERING_FACILITY, MANHOLE, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
+    PIPE_NETWORK, WATER_PLANT, PUMP_STATION, ENGINEERING_FACILITY, DRAINAGE_GATE, DRAINAGE_STORAGE,
+    WATER_USER, WATER_FIRE_HYDRANT, MANHOLE, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
 
 
     public static CockpitEntityCategory parse(String value) {
     public static CockpitEntityCategory parse(String value) {
         if (value == null || value.trim().isEmpty()) {
         if (value == null || value.trim().isEmpty()) {

+ 96 - 24
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/entity/CockpitEntityDetailService.java

@@ -4,6 +4,10 @@ import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 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.base.domain.HazardHiddenAccount;
 import com.zksy.base.domain.HazardHiddenAccount;
@@ -17,6 +21,7 @@ import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.RiskAssessmentService;
 import com.zksy.base.service.RiskAssessmentService;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
 import com.zksy.cockpit.foundation.CockpitDistrictPrefix;
 import com.zksy.cockpit.foundation.CockpitDistrictPrefix;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
@@ -45,14 +50,18 @@ public class CockpitEntityDetailService {
     private final HazardHiddenAccountService hazards;
     private final HazardHiddenAccountService hazards;
     private final RiskAssessmentService risks;
     private final RiskAssessmentService risks;
     private final ManholeBaseService manholes;
     private final ManholeBaseService manholes;
+    private final IWaterUserInfoService users;
+    private final IWaterFireHydrantInfoService hydrants;
 
 
     public CockpitEntityDetailService(PipeNetworkBaseService pipes, IWaterPlantInfoService plants,
     public CockpitEntityDetailService(PipeNetworkBaseService pipes, IWaterPlantInfoService plants,
             IPumpStationInfoService stations, EquipmentBaseService equipment,
             IPumpStationInfoService stations, EquipmentBaseService equipment,
             DrainageGateInfoService gates, DrainageStorageInfoService storages,
             DrainageGateInfoService gates, DrainageStorageInfoService storages,
-            EquipmentStatusService equipmentStatuses, HazardHiddenAccountService hazards, RiskAssessmentService risks, ManholeBaseService manholes) {
+            EquipmentStatusService equipmentStatuses, HazardHiddenAccountService hazards, RiskAssessmentService risks, ManholeBaseService manholes,
+            IWaterUserInfoService users, IWaterFireHydrantInfoService hydrants) {
         this.pipes = pipes; this.plants = plants; this.stations = stations;
         this.pipes = pipes; this.plants = plants; this.stations = stations;
         this.equipment = equipment; this.gates = gates; this.storages = storages;
         this.equipment = equipment; this.gates = gates; this.storages = storages;
         this.equipmentStatuses = equipmentStatuses; this.hazards = hazards; this.risks = risks; this.manholes = manholes;
         this.equipmentStatuses = equipmentStatuses; this.hazards = hazards; this.risks = risks; this.manholes = manholes;
+        this.users = users; this.hydrants = hydrants;
     }
     }
 
 
     public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
     public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
@@ -64,6 +73,10 @@ public class CockpitEntityDetailService {
             case WATER_PLANT: return plant(requestId, id);
             case WATER_PLANT: return plant(requestId, id);
             case PUMP_STATION: return station(requestId, id);
             case PUMP_STATION: return station(requestId, id);
             case ENGINEERING_FACILITY: return engineeringFacility(requestId, id);
             case ENGINEERING_FACILITY: return engineeringFacility(requestId, id);
+            case DRAINAGE_GATE: return drainageGate(requestId, id);
+            case DRAINAGE_STORAGE: return drainageStorage(requestId, id);
+            case WATER_USER: return waterUser(requestId, id);
+            case WATER_FIRE_HYDRANT: return waterFireHydrant(requestId, id);
             case MANHOLE: return manhole(requestId, id);
             case MANHOLE: return manhole(requestId, id);
             case EMERGENCY_RESOURCE: return resource(requestId, id);
             case EMERGENCY_RESOURCE: return resource(requestId, id);
             case HAZARD: return hazard(requestId, id);
             case HAZARD: return hazard(requestId, id);
@@ -79,7 +92,7 @@ public class CockpitEntityDetailService {
         put(a,"managementUnit",v.getManagementUnit()); put(a,"lengthMeters",v.getLength()); put(a,"diameterMillimeters",v.getDiameter());
         put(a,"managementUnit",v.getManagementUnit()); put(a,"lengthMeters",v.getLength()); put(a,"diameterMillimeters",v.getDiameter());
         put(a,"material",v.getMaterial()); put(a,"buildDate",v.getBuildDate()); put(a,"remark",v.getRemark());
         put(a,"material",v.getMaterial()); put(a,"buildDate",v.getBuildDate()); put(a,"remark",v.getRemark());
         Integer district = CockpitDistrictPrefix.codeOf(v.getNetworkCode());
         Integer district = CockpitDistrictPrefix.codeOf(v.getNetworkCode());
-        return response(requestId,"PIPE_NETWORK",v.getNetworkId(),v.getNetworkCode(),v.getNetworkName(),v.getStatus(),
+        return response(requestId,"PIPE_NETWORK",v.getNetworkId(),v.getNetworkCode(),v.getNetworkName(),CockpitFacilityContract.normalizeStatus(v.getStatus()),
                 v.getLocation(),district,new CockpitEntityDetailResponse.Coordinates(v.getStartLongitude(),v.getStartLatitude(),v.getEndLongitude(),v.getEndLatitude()),a,v.getUpdateTime());
                 v.getLocation(),district,new CockpitEntityDetailResponse.Coordinates(v.getStartLongitude(),v.getStartLatitude(),v.getEndLongitude(),v.getEndLatitude()),a,v.getUpdateTime());
     }
     }
 
 
@@ -88,16 +101,16 @@ public class CockpitEntityDetailService {
         Map<String,Object> a=map(); put(a,"waterSourceType",v.getWaterSourceType()); put(a,"designCapacity",v.getDesignCapacity());
         Map<String,Object> a=map(); put(a,"waterSourceType",v.getWaterSourceType()); put(a,"designCapacity",v.getDesignCapacity());
         put(a,"currentCapacity",v.getCurrentCapacity()); put(a,"treatmentProcess",v.getTreatmentProcess()); put(a,"commissionDate",v.getCommissionDate());
         put(a,"currentCapacity",v.getCurrentCapacity()); put(a,"treatmentProcess",v.getTreatmentProcess()); put(a,"commissionDate",v.getCommissionDate());
         put(a,"waterQualityStandard",v.getWaterQualityStandard()); put(a,"principal",v.getPrincipal()); put(a,"contactPhone",v.getContactPhone()); put(a,"remark",v.getRemark());
         put(a,"waterQualityStandard",v.getWaterQualityStandard()); put(a,"principal",v.getPrincipal()); put(a,"contactPhone",v.getContactPhone()); put(a,"remark",v.getRemark());
-        return response(requestId,"WATER_PLANT",String.valueOf(v.getId()),v.getPlantCode(),v.getPlantName(),v.getStatus(),v.getLocation(),null,
+        return response(requestId,"WATER_PLANT",String.valueOf(v.getId()),v.getPlantCode(),v.getPlantName(),CockpitFacilityContract.normalizeStatus(v.getStatus()),v.getLocation(),null,
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(),v.getLatitude(),null,null),a,v.getUpdateTime());
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(),v.getLatitude(),null,null),a,v.getUpdateTime());
     }
     }
 
 
     private CockpitEntityDetailResponse station(String requestId, String id) {
     private CockpitEntityDetailResponse station(String requestId, String id) {
         PumpStationInfo v=stations.getById(id); if(v==null) throw missing();
         PumpStationInfo v=stations.getById(id); if(v==null) throw missing();
-        Map<String,Object>a=map(); put(a,"stationType",v.getStationType()); put(a,"pumpCount",v.getPumpCount()); put(a,"designFlow",v.getDesignFlow());
+        Map<String,Object>a=map(); put(a,"stationType",CockpitFacilityContract.pumpStationTypeCode(v.getStationType())); put(a,"pumpCount",v.getPumpCount()); put(a,"designFlow",v.getDesignFlow());
         put(a,"designHead",v.getDesignHead()); put(a,"powerCapacity",v.getPowerCapacity()); put(a,"commissionDate",v.getCommissionDate());
         put(a,"designHead",v.getDesignHead()); put(a,"powerCapacity",v.getPowerCapacity()); put(a,"commissionDate",v.getCommissionDate());
         put(a,"principal",v.getPrincipal()); put(a,"contactPhone",v.getContactPhone()); put(a,"remark",v.getRemark());
         put(a,"principal",v.getPrincipal()); put(a,"contactPhone",v.getContactPhone()); put(a,"remark",v.getRemark());
-        return response(requestId,"PUMP_STATION",String.valueOf(v.getId()),v.getStationCode(),v.getStationName(),v.getStatus(),v.getLocation(),null,
+        return response(requestId,"PUMP_STATION",String.valueOf(v.getId()),v.getStationCode(),v.getStationName(),CockpitFacilityContract.normalizeStatus(v.getStatus()),v.getLocation(),null,
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(),v.getLatitude(),null,null),a,v.getUpdateTime());
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(),v.getLatitude(),null,null),a,v.getUpdateTime());
     }
     }
 
 
@@ -105,28 +118,44 @@ public class CockpitEntityDetailService {
     private CockpitEntityDetailResponse engineeringFacility(String requestId, String id) {
     private CockpitEntityDetailResponse engineeringFacility(String requestId, String id) {
         // 闸门与调蓄设施分表存储,id 全局唯一:先查闸门,未命中再查调蓄
         // 闸门与调蓄设施分表存储,id 全局唯一:先查闸门,未命中再查调蓄
         com.zksy.drainage.domain.DrainageGateInfo gate = gates.getEntityById(id);
         com.zksy.drainage.domain.DrainageGateInfo gate = gates.getEntityById(id);
-        if (gate != null) {
-            Map<String,Object> a = drainageFacilityAttributes(gate);
-            put(a, "facilityType", "gate");
-            put(a, "designHead", gate.getDesignHead());
-            return response(requestId, "DRAINAGE_GATE", gate.getFacilityId(), gate.getFacilityCode(),
-                    gate.getFacilityName(), gate.getStatus(), gate.getLocation(), null,
-                    new CockpitEntityDetailResponse.Coordinates(gate.getLongitude(), gate.getLatitude(), null, null),
-                    a, gate.getUpdateTime());
-        }
+        if (gate != null) return gateDetail(requestId, gate);
         com.zksy.drainage.domain.DrainageStorageInfo storage = storages.getEntityById(id);
         com.zksy.drainage.domain.DrainageStorageInfo storage = storages.getEntityById(id);
-        if (storage != null) {
-            Map<String,Object> a = drainageFacilityAttributes(storage);
-            put(a, "facilityType", "storage");
-            put(a, "storageCapacity", storage.getStorageCapacity());
-            return response(requestId, "DRAINAGE_STORAGE", storage.getFacilityId(), storage.getFacilityCode(),
-                    storage.getFacilityName(), storage.getStatus(), storage.getLocation(), null,
-                    new CockpitEntityDetailResponse.Coordinates(storage.getLongitude(), storage.getLatitude(), null, null),
-                    a, storage.getUpdateTime());
-        }
+        if (storage != null) return storageDetail(requestId, storage);
         throw missing();
         throw missing();
     }
     }
 
 
+    private CockpitEntityDetailResponse drainageGate(String requestId, String id) {
+        com.zksy.drainage.domain.DrainageGateInfo gate = gates.getEntityById(id);
+        if (gate == null) throw missing();
+        return gateDetail(requestId, gate);
+    }
+
+    private CockpitEntityDetailResponse drainageStorage(String requestId, String id) {
+        com.zksy.drainage.domain.DrainageStorageInfo storage = storages.getEntityById(id);
+        if (storage == null) throw missing();
+        return storageDetail(requestId, storage);
+    }
+
+    private CockpitEntityDetailResponse gateDetail(String requestId, com.zksy.drainage.domain.DrainageGateInfo gate) {
+        Map<String,Object> a = drainageFacilityAttributes(gate);
+        put(a, "facilityType", "gate");
+        put(a, "designHead", gate.getDesignHead());
+        return response(requestId, "DRAINAGE_GATE", gate.getFacilityId(), gate.getFacilityCode(),
+                gate.getFacilityName(), CockpitFacilityContract.normalizeStatus(gate.getStatus()), gate.getLocation(), null,
+                new CockpitEntityDetailResponse.Coordinates(gate.getLongitude(), gate.getLatitude(), null, null),
+                a, gate.getUpdateTime());
+    }
+
+    private CockpitEntityDetailResponse storageDetail(String requestId, com.zksy.drainage.domain.DrainageStorageInfo storage) {
+        Map<String,Object> a = drainageFacilityAttributes(storage);
+        put(a, "facilityType", "storage");
+        put(a, "storageCapacity", storage.getStorageCapacity());
+        return response(requestId, "DRAINAGE_STORAGE", storage.getFacilityId(), storage.getFacilityCode(),
+                storage.getFacilityName(), CockpitFacilityContract.normalizeStatus(storage.getStatus()), storage.getLocation(), null,
+                new CockpitEntityDetailResponse.Coordinates(storage.getLongitude(), storage.getLatitude(), null, null),
+                a, storage.getUpdateTime());
+    }
+
     private Map<String,Object> drainageFacilityAttributes(DrainageFacilityBase v) {
     private Map<String,Object> drainageFacilityAttributes(DrainageFacilityBase v) {
         Map<String,Object> a = map();
         Map<String,Object> a = map();
         put(a, "facilityLevel", v.getFacilityLevel());
         put(a, "facilityLevel", v.getFacilityLevel());
@@ -139,6 +168,49 @@ public class CockpitEntityDetailService {
         return a;
         return a;
     }
     }
 
 
+    private CockpitEntityDetailResponse waterUser(String requestId, String id) {
+        WaterUserInfo v = users.getById(id);
+        if (v == null) throw missing();
+        Map<String,Object> a = map();
+        put(a, "userCode", v.getUserCode());
+        put(a, "userName", v.getUserName());
+        put(a, "userType", v.getUserType());
+        put(a, "address", v.getAddress());
+        put(a, "contactPerson", v.getContactPerson());
+        put(a, "contactPhone", v.getContactPhone());
+        put(a, "meterNumber", v.getMeterNumber());
+        put(a, "initialReading", v.getInitialReading());
+        put(a, "currentReading", v.getCurrentReading());
+        put(a, "annualWaterConsumption", v.getAnnualWaterConsumption());
+        put(a, "remark", v.getRemark());
+        return response(requestId, "WATER_USER", v.getId(), v.getUserCode(), v.getUserName(),
+                CockpitFacilityContract.normalizeStatus(v.getStatus()), null, null,
+                new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
+                a, v.getUpdateTime());
+    }
+
+    private CockpitEntityDetailResponse waterFireHydrant(String requestId, String id) {
+        WaterFireHydrantInfo v = hydrants.getById(id);
+        if (v == null) throw missing();
+        Map<String,Object> a = map();
+        put(a, "hydrantCode", v.getHydrantCode());
+        put(a, "hydrantName", v.getHydrantName());
+        put(a, "hydrantType", v.getHydrantType());
+        put(a, "model", v.getModel());
+        put(a, "inletPipeDiameter", v.getInletPipeDiameter());
+        put(a, "outletSpec", v.getOutletSpec());
+        put(a, "ownershipUnit", v.getOwnershipUnit());
+        put(a, "maintenanceUnit", v.getMaintenanceUnit());
+        put(a, "principal", v.getPrincipal());
+        put(a, "contactPhone", v.getContactPhone());
+        put(a, "location", v.getLocation());
+        put(a, "remark", v.getRemark());
+        return response(requestId, "WATER_FIRE_HYDRANT", v.getHydrantId(), v.getHydrantCode(), v.getHydrantName(),
+                CockpitFacilityContract.normalizeStatus(v.getStatus()), v.getLocation(), null,
+                new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
+                a, v.getUpdateTime());
+    }
+
 
 
     /**
     /**
      * 窨井详情(维护者 2026-11-16)。
      * 窨井详情(维护者 2026-11-16)。
@@ -157,7 +229,7 @@ public class CockpitEntityDetailService {
         put(a, "ownershipUnit", v.getOwnershipUnit());
         put(a, "ownershipUnit", v.getOwnershipUnit());
         put(a, "remark", v.getRemark());
         put(a, "remark", v.getRemark());
         return response(requestId, "MANHOLE", v.getManholeId(), v.getManholeCode(), v.getManholeName(),
         return response(requestId, "MANHOLE", v.getManholeId(), v.getManholeCode(), v.getManholeName(),
-                v.getStatus(), v.getLocation(), null,
+                CockpitFacilityContract.normalizeStatus(v.getStatus()), v.getLocation(), null,
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
                 new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
                 a, v.getUpdateTime());
                 a, v.getUpdateTime());
     }
     }

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

@@ -0,0 +1,15 @@
+package com.zksy.cockpit.foundation;
+
+/** 驾驶舱字典行:只对外发布码值与文案,不暴露后台字典的审计/样式字段。 */
+public class CockpitDictRow {
+    private final String dictValue;
+    private final String dictLabel;
+
+    public CockpitDictRow(String dictValue, String dictLabel) {
+        this.dictValue = dictValue;
+        this.dictLabel = dictLabel;
+    }
+
+    public String getDictValue() { return dictValue; }
+    public String getDictLabel() { return dictLabel; }
+}

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

@@ -0,0 +1,36 @@
+package com.zksy.cockpit.foundation;
+
+/**
+ * 驾驶舱设施对外的统一契约:状态只发布 0=正常 / 1=异常;泵站类型只发布字典 0/1。
+ * 后端物理列仍保留逐表旧值(停产、欠费、检修、water_supply/drainage),
+ * 统一归一只在这里做一次,避免各适配器各写一套。
+ */
+public final class CockpitFacilityContract {
+    private CockpitFacilityContract() {}
+
+    /** 旧值中仍代表正常的取值;其余非空值一律归为异常。空白值不发布,由前端如实显示未发布。 */
+    public static String normalizeStatus(String raw) {
+        String value = raw == null ? "" : raw.trim();
+        if (value.isEmpty()) return null;
+        return isNormal(value) ? "0" : "1";
+    }
+
+    public static boolean isAbnormalStatus(String raw) {
+        String value = raw == null ? "" : raw.trim();
+        return !value.isEmpty() && !isNormal(value);
+    }
+
+    /** 泵站物理类型 → sys_dict_data(pump_station_type) 的展示码。 */
+    public static String pumpStationTypeCode(String physical) {
+        if (physical == null) return null;
+        String value = physical.trim();
+        if ("0".equals(value) || "water_supply".equalsIgnoreCase(value)) return "0";
+        if ("1".equals(value) || "drainage".equalsIgnoreCase(value)) return "1";
+        return null;
+    }
+
+    private static boolean isNormal(String value) {
+        return "0".equals(value) || "NORMAL".equalsIgnoreCase(value)
+                || "RUNNING".equalsIgnoreCase(value) || "ACTIVE".equalsIgnoreCase(value);
+    }
+}

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

@@ -1,5 +1,7 @@
 package com.zksy.cockpit.infrastructure;
 package com.zksy.cockpit.infrastructure;
 
 
+import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
@@ -7,16 +9,20 @@ import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.WaterSourceInfo.domain.WaterSourceInfo;
 import com.zksy.WaterSupply.WaterSourceInfo.domain.WaterSourceInfo;
 import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
 import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.cockpit.foundation.CockpitDistrictPrefix;
 import com.zksy.cockpit.foundation.CockpitDistrictPrefix;
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -34,7 +40,7 @@ import java.util.stream.Collectors;
 
 
 /**
 /**
  * 三个驾驶舱设施统计端点的权威设施目录(执行票 31)。
  * 三个驾驶舱设施统计端点的权威设施目录(执行票 31)。
- * 包含管网、水厂、供排水泵站、排水工程设施、水源地与窨井的合法记录并集。
+ * 包含管网、水厂、供排水泵站、排水工程设施、水源地、窨井、用水户与消火栓的合法记录并集。
  * 片区只由**管线编码前缀**推出(见 {@link #districtOf}),其余设施没有可信来源、如实保持 null;
  * 片区只由**管线编码前缀**推出(见 {@link #districtOf}),其余设施没有可信来源、如实保持 null;
  * 未知类型或缺编码行以哨兵保留到 excluded。
  * 未知类型或缺编码行以哨兵保留到 excluded。
  */
  */
@@ -54,7 +60,9 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
             type("DRAINAGE_STORAGE", "排水调蓄设施", "DRAINAGE"),
             type("DRAINAGE_STORAGE", "排水调蓄设施", "DRAINAGE"),
             type("DRAINAGE_PUMP_STATION", "排水泵站", "DRAINAGE"),
             type("DRAINAGE_PUMP_STATION", "排水泵站", "DRAINAGE"),
             type("WATER_SOURCE", "水源地", "WATER_SUPPLY"),
             type("WATER_SOURCE", "水源地", "WATER_SUPPLY"),
-            type("MANHOLE", "窨井", "MANHOLE"));
+            type("MANHOLE", "窨井", "MANHOLE"),
+            type("WATER_USER", "用水户", "WATER_SUPPLY"),
+            type("WATER_FIRE_HYDRANT", "消火栓", "WATER_SUPPLY"));
     /** 编码带片区前缀的类型:仅 {@code pipe_network_base} 的三种管线。 */
     /** 编码带片区前缀的类型:仅 {@code pipe_network_base} 的三种管线。 */
     private static final List<String> PIPE_TYPES = Arrays.asList(
     private static final List<String> PIPE_TYPES = Arrays.asList(
             CockpitPipeNetworkType.WATER_PIPE, CockpitPipeNetworkType.GAS_PIPE, CockpitPipeNetworkType.DRAINAGE_PIPE);
             CockpitPipeNetworkType.WATER_PIPE, CockpitPipeNetworkType.GAS_PIPE, CockpitPipeNetworkType.DRAINAGE_PIPE);
@@ -66,11 +74,23 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
     private final DrainageStorageInfoService storages;
     private final DrainageStorageInfoService storages;
     private final IWaterSourceInfoService sources;
     private final IWaterSourceInfoService sources;
     private final ManholeBaseService manholes;
     private final ManholeBaseService manholes;
+    private final IWaterUserInfoService users;
+    private final IWaterFireHydrantInfoService hydrants;
 
 
+    /** 兼容旧调用的构造入口;新设施来源按空集处理,不改动既有口径。 */
     public BusinessCockpitInfrastructureBaseArchivesAdapter(
     public BusinessCockpitInfrastructureBaseArchivesAdapter(
             IWaterPlantInfoService plants, IPumpStationInfoService stations,
             IWaterPlantInfoService plants, IPumpStationInfoService stations,
             PipeNetworkBaseService pipes, DrainageGateInfoService gates, DrainageStorageInfoService storages,
             PipeNetworkBaseService pipes, DrainageGateInfoService gates, DrainageStorageInfoService storages,
             IWaterSourceInfoService sources, ManholeBaseService manholes) {
             IWaterSourceInfoService sources, ManholeBaseService manholes) {
+        this(plants, stations, pipes, gates, storages, sources, manholes, null, null);
+    }
+
+    @Autowired
+    public BusinessCockpitInfrastructureBaseArchivesAdapter(
+            IWaterPlantInfoService plants, IPumpStationInfoService stations,
+            PipeNetworkBaseService pipes, DrainageGateInfoService gates, DrainageStorageInfoService storages,
+            IWaterSourceInfoService sources, ManholeBaseService manholes,
+            IWaterUserInfoService users, IWaterFireHydrantInfoService hydrants) {
         this.plants = plants;
         this.plants = plants;
         this.stations = stations;
         this.stations = stations;
         this.pipes = pipes;
         this.pipes = pipes;
@@ -78,6 +98,8 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
         this.storages = storages;
         this.storages = storages;
         this.sources = sources;
         this.sources = sources;
         this.manholes = manholes;
         this.manholes = manholes;
+        this.users = users;
+        this.hydrants = hydrants;
     }
     }
 
 
     @Override
     @Override
@@ -94,9 +116,11 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
         for (PumpStationInfo station : safeList(stations.list())) {
         for (PumpStationInfo station : safeList(stations.list())) {
             updatedAt = latest(updatedAt, station.getUpdateTime());
             updatedAt = latest(updatedAt, station.getUpdateTime());
             updatedAt = latest(updatedAt, station.getCreateTime());
             updatedAt = latest(updatedAt, station.getCreateTime());
-            String stationType = trimToNull(station.getStationType());
-            String type = PumpStationType.DRAINAGE.equalsIgnoreCase(stationType) ? "DRAINAGE_PUMP_STATION"
-                    : PumpStationType.WATER_SUPPLY.equalsIgnoreCase(stationType) ? "WATER_PUMP_STATION" : UNCLASSIFIED;
+            // 泵站类型可能是物理字符串(water_supply/drainage)或字典码(0/1);共用契约归一,
+            // 避免详情页认得、统计页却归为未分类的左右分裂。
+            String stationTypeCode = CockpitFacilityContract.pumpStationTypeCode(station.getStationType());
+            String type = "1".equals(stationTypeCode) ? "DRAINAGE_PUMP_STATION"
+                    : "0".equals(stationTypeCode) ? "WATER_PUMP_STATION" : UNCLASSIFIED;
             add(facilities, key("pump_station", station.getId(), station.getStationCode()), station.getStationCode(), type, null, station.getCommissionDate(), null);
             add(facilities, key("pump_station", station.getId(), station.getStationCode()), station.getStationCode(), type, null, station.getCommissionDate(), null);
         }
         }
         for (PipeNetworkBase pipe : safeList(pipes.list())) {
         for (PipeNetworkBase pipe : safeList(pipes.list())) {
@@ -132,6 +156,19 @@ public class BusinessCockpitInfrastructureBaseArchivesAdapter
             updatedAt = latest(updatedAt, manhole.getCreateTime());
             updatedAt = latest(updatedAt, manhole.getCreateTime());
             add(facilities, key("manhole_base", manhole.getManholeId(), manhole.getManholeCode()), manhole.getManholeCode(), "MANHOLE", null, null, null);
             add(facilities, key("manhole_base", manhole.getManholeId(), manhole.getManholeCode()), manhole.getManholeCode(), "MANHOLE", null, null, null);
         }
         }
+        // 用水户/消火栓与窨井同一口径:一张业务表一种正式类型,编码用业务码而非 UUID。
+        for (WaterUserInfo user : safeList(users == null ? null : users.list())) {
+            updatedAt = latest(updatedAt, user.getUpdateTime());
+            updatedAt = latest(updatedAt, user.getCreateTime());
+            add(facilities, key("water_user_info", user.getId(), user.getUserCode()),
+                    user.getUserCode(), "WATER_USER", null, null, null);
+        }
+        for (WaterFireHydrantInfo hydrant : safeList(hydrants == null ? null : hydrants.list())) {
+            updatedAt = latest(updatedAt, hydrant.getUpdateTime());
+            updatedAt = latest(updatedAt, hydrant.getCreateTime());
+            add(facilities, key("water_fire_hydrant_info", hydrant.getHydrantId(), hydrant.getHydrantCode()),
+                    hydrant.getHydrantCode(), "WATER_FIRE_HYDRANT", null, null, null);
+        }
         return new CockpitInfrastructureBaseArchivesSnapshot(
         return new CockpitInfrastructureBaseArchivesSnapshot(
                 updatedAt == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(updatedAt.atZone(BUSINESS_ZONE)),
                 updatedAt == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(updatedAt.atZone(BUSINESS_ZONE)),
                 TYPES, facilities);
                 TYPES, facilities);

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

@@ -1,21 +1,27 @@
 package com.zksy.cockpit.infrastructure;
 package com.zksy.cockpit.infrastructure;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
+import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.WaterPlantInfo.service.IWaterPlantInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationType;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.service.IPumpStationInfoService;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
+import com.zksy.cockpit.foundation.CockpitFacilityContract;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.cockpit.foundation.CockpitPipeNetworkType;
 import com.zksy.drainage.domain.DrainageFacilityBase;
 import com.zksy.drainage.domain.DrainageFacilityBase;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageGateInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.domain.DrainageStorageInfo;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageGateInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
 import com.zksy.drainage.service.DrainageStorageInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -35,7 +41,7 @@ import java.util.stream.Collectors;
  *
  *
  * <p>指标只由现有业务实体中明确存在的当前值生成。现有模型没有统一历史采样表,
  * <p>指标只由现有业务实体中明确存在的当前值生成。现有模型没有统一历史采样表,
  * 因此不会合成趋势点;更新时间取每条源记录的更新时间,缺失时保持空值交由契约层
  * 因此不会合成趋势点;更新时间取每条源记录的更新时间,缺失时保持空值交由契约层
- * 使用服务端时间补齐。
+ * 使用服务端时间补齐。状态只发布契约归一值(0/1/null),物理列原值不做修改。
  */
  */
 @Component
 @Component
 @Primary
 @Primary
@@ -51,7 +57,10 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
     private final DrainageGateInfoService gateService;
     private final DrainageGateInfoService gateService;
     private final DrainageStorageInfoService storageService;
     private final DrainageStorageInfoService storageService;
     private final ManholeBaseService manholeBaseService;
     private final ManholeBaseService manholeBaseService;
+    private final IWaterUserInfoService userService;
+    private final IWaterFireHydrantInfoService hydrantService;
 
 
+    /** 兼容旧调用的构造入口;新设施来源按空集处理,不改动既有口径。 */
     public BusinessCockpitInfrastructureOperatingInformationAdapter(
     public BusinessCockpitInfrastructureOperatingInformationAdapter(
             IWaterPlantInfoService plantService,
             IWaterPlantInfoService plantService,
             IPumpStationInfoService pumpStationService,
             IPumpStationInfoService pumpStationService,
@@ -59,12 +68,28 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
             DrainageGateInfoService gateService,
             DrainageGateInfoService gateService,
             DrainageStorageInfoService storageService,
             DrainageStorageInfoService storageService,
             ManholeBaseService manholeBaseService) {
             ManholeBaseService manholeBaseService) {
+        this(plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
+                manholeBaseService, null, null);
+    }
+
+    @Autowired
+    public BusinessCockpitInfrastructureOperatingInformationAdapter(
+            IWaterPlantInfoService plantService,
+            IPumpStationInfoService pumpStationService,
+            PipeNetworkBaseService pipeNetworkBaseService,
+            DrainageGateInfoService gateService,
+            DrainageStorageInfoService storageService,
+            ManholeBaseService manholeBaseService,
+            IWaterUserInfoService userService,
+            IWaterFireHydrantInfoService hydrantService) {
         this.plantService = plantService;
         this.plantService = plantService;
         this.pumpStationService = pumpStationService;
         this.pumpStationService = pumpStationService;
         this.pipeNetworkBaseService = pipeNetworkBaseService;
         this.pipeNetworkBaseService = pipeNetworkBaseService;
         this.gateService = gateService;
         this.gateService = gateService;
         this.storageService = storageService;
         this.storageService = storageService;
         this.manholeBaseService = manholeBaseService;
         this.manholeBaseService = manholeBaseService;
+        this.userService = userService;
+        this.hydrantService = hydrantService;
     }
     }
 
 
     @Override
     @Override
@@ -86,14 +111,15 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     plant.getCurrentCapacity(),
                     plant.getCurrentCapacity(),
                     plant.getDesignCapacity(),
                     plant.getDesignCapacity(),
                     sampledAt,
                     sampledAt,
-                    abnormalStatus(plant.getStatus()),
-                    plant.getPlantCode(), String.valueOf(plant.getId()), "WATER_PLANT", plant.getStatus()));
+                    CockpitFacilityContract.isAbnormalStatus(plant.getStatus()),
+                    plant.getPlantCode(), String.valueOf(plant.getId()), "WATER_PLANT",
+                    CockpitFacilityContract.normalizeStatus(plant.getStatus())));
         }
         }
 
 
         for (PumpStationInfo station : safeList(pumpStationService.list(
         for (PumpStationInfo station : safeList(pumpStationService.list(
                 new LambdaQueryWrapper<PumpStationInfo>()
                 new LambdaQueryWrapper<PumpStationInfo>()
                         .in(PumpStationInfo::getStationType,
                         .in(PumpStationInfo::getStationType,
-                                PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE)))) {
+                                PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE, "0", "1")))) {
             if (station == null || isBlank(station.getStationCode()) || station.getDesignFlow() == null) {
             if (station == null || isBlank(station.getStationCode()) || station.getDesignFlow() == null) {
                 continue;
                 continue;
             }
             }
@@ -112,8 +138,9 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     station.getDesignFlow(),
                     station.getDesignFlow(),
                     null,
                     null,
                     sampledAt,
                     sampledAt,
-                    abnormalStatus(station.getStatus()),
-                    station.getStationCode(), String.valueOf(station.getId()), "PUMP_STATION", station.getStatus()));
+                    CockpitFacilityContract.isAbnormalStatus(station.getStatus()),
+                    station.getStationCode(), String.valueOf(station.getId()), "PUMP_STATION",
+                    CockpitFacilityContract.normalizeStatus(station.getStatus())));
         }
         }
 
 
         for (PipeNetworkBase pipe : safeList(pipeNetworkBaseService.list())) {
         for (PipeNetworkBase pipe : safeList(pipeNetworkBaseService.list())) {
@@ -134,8 +161,9 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     pipe.getLength(),
                     pipe.getLength(),
                     null,
                     null,
                     sampledAt,
                     sampledAt,
-                    abnormalStatus(pipe.getStatus()),
-                    pipe.getNetworkCode(), pipe.getNetworkId(), "PIPE_NETWORK", pipe.getStatus()));
+                    CockpitFacilityContract.isAbnormalStatus(pipe.getStatus()),
+                    pipe.getNetworkCode(), pipe.getNetworkId(), "PIPE_NETWORK",
+                    CockpitFacilityContract.normalizeStatus(pipe.getStatus())));
         }
         }
 
 
         for (DrainageFacilityBase facility : safeList(gateService.listAll())) {
         for (DrainageFacilityBase facility : safeList(gateService.listAll())) {
@@ -165,8 +193,50 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     BigDecimal.ONE,
                     BigDecimal.ONE,
                     null,
                     null,
                     sampledAt,
                     sampledAt,
-                    abnormalStatus(manhole.getStatus()),
-                    manhole.getManholeCode(), manhole.getManholeId(), "MANHOLE", manhole.getStatus()));
+                    CockpitFacilityContract.isAbnormalStatus(manhole.getStatus()),
+                    manhole.getManholeCode(), manhole.getManholeId(), "MANHOLE",
+                    CockpitFacilityContract.normalizeStatus(manhole.getStatus())));
+        }
+
+        // 用水户/消火栓与窨井同一口径:一个设施一条指标,供前端设施台账枚举两类独立设施;
+        // 单位分别为「户」「座」,行业统一供水,状态只发布归一值。
+        for (WaterUserInfo user : safeList(userService == null ? null : userService.list())) {
+            if (user == null || isBlank(user.getUserCode())) {
+                continue;
+            }
+            String sampledAt = format(user.getUpdateTime());
+            latestUpdatedAt = latest(latestUpdatedAt, sampledAt);
+            metrics.add(metric(
+                    "water_user_point_count",
+                    isBlank(user.getUserName()) ? "用水户" : user.getUserName(),
+                    "CAPACITY",
+                    "户",
+                    "WATER_SUPPLY",
+                    BigDecimal.ONE,
+                    null,
+                    sampledAt,
+                    CockpitFacilityContract.isAbnormalStatus(user.getStatus()),
+                    user.getUserCode(), user.getId(), "WATER_USER",
+                    CockpitFacilityContract.normalizeStatus(user.getStatus())));
+        }
+        for (WaterFireHydrantInfo hydrant : safeList(hydrantService == null ? null : hydrantService.list())) {
+            if (hydrant == null || isBlank(hydrant.getHydrantCode())) {
+                continue;
+            }
+            String sampledAt = format(hydrant.getUpdateTime());
+            latestUpdatedAt = latest(latestUpdatedAt, sampledAt);
+            metrics.add(metric(
+                    "water_fire_hydrant_point_count",
+                    isBlank(hydrant.getHydrantName()) ? "消火栓" : hydrant.getHydrantName(),
+                    "CAPACITY",
+                    "座",
+                    "WATER_SUPPLY",
+                    BigDecimal.ONE,
+                    null,
+                    sampledAt,
+                    CockpitFacilityContract.isAbnormalStatus(hydrant.getStatus()),
+                    hydrant.getHydrantCode(), hydrant.getHydrantId(), "WATER_FIRE_HYDRANT",
+                    CockpitFacilityContract.normalizeStatus(hydrant.getStatus())));
         }
         }
 
 
         return new CockpitInfrastructureOperatingInformationSnapshot(latestUpdatedAt, metrics);
         return new CockpitInfrastructureOperatingInformationSnapshot(latestUpdatedAt, metrics);
@@ -204,22 +274,20 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
     }
     }
 
 
     private static String pumpIndustry(String stationType) {
     private static String pumpIndustry(String stationType) {
-        if (PumpStationType.WATER_SUPPLY.equalsIgnoreCase(trimToNull(stationType))) {
-            return "WATER_SUPPLY";
-        }
-        if (PumpStationType.DRAINAGE.equalsIgnoreCase(trimToNull(stationType))) {
-            return "DRAINAGE";
-        }
+        String code = CockpitFacilityContract.pumpStationTypeCode(stationType);
+        if ("0".equals(code)) return "WATER_SUPPLY";
+        if ("1".equals(code)) return "DRAINAGE";
         return null;
         return null;
     }
     }
 
 
-    /** 排水设施是点要素,每个设施计 1 个点;闸门/调蓄共用实现,仅 typeCode 不同 */
+    /** 排水设施是点要素,每个设施计 1 个点;闸门/调蓄共用实现,facilityKind 按 typeCode 分开。 */
     private void addDrainageFacilityMetric(
     private void addDrainageFacilityMetric(
             List<CockpitInfrastructureOperatingInformationSnapshot.SourceMetric> metrics,
             List<CockpitInfrastructureOperatingInformationSnapshot.SourceMetric> metrics,
             DrainageFacilityBase facility, String typeCode) {
             DrainageFacilityBase facility, String typeCode) {
         if (facility == null || isBlank(facility.getFacilityId())) {
         if (facility == null || isBlank(facility.getFacilityId())) {
             return;
             return;
         }
         }
+        String facilityKind = "gate".equals(typeCode) ? "DRAINAGE_GATE" : "DRAINAGE_STORAGE";
         metrics.add(metric(
         metrics.add(metric(
                 "drainage_" + typeCode + "_point_count",
                 "drainage_" + typeCode + "_point_count",
                 isBlank(facility.getFacilityName()) ? "排水设施点数" : facility.getFacilityName() + "点数",
                 isBlank(facility.getFacilityName()) ? "排水设施点数" : facility.getFacilityName() + "点数",
@@ -229,8 +297,9 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                 BigDecimal.ONE,
                 BigDecimal.ONE,
                 null,
                 null,
                 format(facility.getUpdateTime()),
                 format(facility.getUpdateTime()),
-                false,
-                facility.getFacilityId(), facility.getFacilityId(), "DRAINAGE_FACILITY", facility.getStatus()));
+                CockpitFacilityContract.isAbnormalStatus(facility.getStatus()),
+                facility.getFacilityId(), facility.getFacilityId(), facilityKind,
+                CockpitFacilityContract.normalizeStatus(facility.getStatus())));
     }
     }
 
 
     /** 行业为空的未分类项用 {@code unknown_} 前缀,避免空指针并保持编码可读。 */
     /** 行业为空的未分类项用 {@code unknown_} 前缀,避免空指针并保持编码可读。 */
@@ -238,14 +307,6 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
         return (industry == null ? "unknown" : industry.toLowerCase()) + "_" + suffix;
         return (industry == null ? "unknown" : industry.toLowerCase()) + "_" + suffix;
     }
     }
 
 
-    private static boolean abnormalStatus(String status) {
-        String normalized = trimToNull(status);
-        return normalized != null && !"0".equals(normalized)
-                && !"NORMAL".equalsIgnoreCase(normalized)
-                && !"RUNNING".equalsIgnoreCase(normalized)
-                && !"ACTIVE".equalsIgnoreCase(normalized);
-    }
-
     private static String format(LocalDateTime time) {
     private static String format(LocalDateTime time) {
         return time == null ? null : TIME_FORMATTER.format(time.atZone(BUSINESS_ZONE).toOffsetDateTime());
         return time == null ? null : TIME_FORMATTER.format(time.atZone(BUSINESS_ZONE).toOffsetDateTime());
     }
     }