Browse Source

feat(cockpit): 运行信息补齐九类设施实体行与水源地详情

票 01(设施全量上图)。运行信息是前端设施点图层唯一的实体来源,
此前水厂/泵站因能力值为空被跳过、水源地无实体循环,四类带坐标设施不上图。

- 水厂 currentCapacity、泵站 designFlow 为空仍下发实体行(值如实 null)。
- 水源地新增实体循环(一处一条,值 1、单位「处」、行业供水),复用既有逐设施口径。
- 实体详情新增 WATER_SOURCE 类别,按 water_source_info 主键回查经纬度。
- 缺主键的行 facilityId 如实为 null,不下发字符串 "null",避免详情 404/500。
- 删除票 01 引入的两个零调用兼容构造入口,保持代码精简。
- 回归:新增/扩展适配器与水源地详情单测;供水/排水泵站分别钉行业。
Kazerin 2 tuần trước cách đây
mục cha
commit
8f819a3d17

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

@@ -6,12 +6,19 @@ 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.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.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.infrastructure.BusinessCockpitInfrastructureOperatingInformationAdapter;
 import com.zksy.cockpit.infrastructure.BusinessCockpitInfrastructureOperatingInformationAdapter;
 import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationSnapshot;
 import com.zksy.cockpit.infrastructure.CockpitInfrastructureOperatingInformationSnapshot;
+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;
@@ -22,6 +29,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
+import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -179,6 +187,215 @@ class BusinessCockpitInfrastructureOperatingInformationAdapterTest {
         assertTrue(snapshot.getMetrics().get(1).isAbnormal(), "非 0 状态如实标记为异常");
         assertTrue(snapshot.getMetrics().get(1).isAbnormal(), "非 0 状态如实标记为异常");
     }
     }
 
 
+    /**
+     * 水厂即使没有当前供水能力,也必须下发设施实体行(外部依赖票 01)。
+     *
+     * <p>旧实现把 {@code currentCapacity == null} 当作跳过条件,前端设施点图层只从运行信息
+     * 实体行枚举,于是库里带坐标的水厂永不上图。能力值如实为 null,不拿 0 冒充。</p>
+     */
+    @Test
+    void emitsWaterPlantEntityRowWhenCurrentCapacityMissing() {
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setId("7");
+        plant.setPlantCode("PLANT-007");
+        plant.setPlantName("第二水厂");
+        plant.setCurrentCapacity(null);
+        plant.setDesignCapacity(new BigDecimal("12.00"));
+        plant.setStatus("0");
+        plant.setUpdateTime(LocalDateTime.parse("2026-11-18T09:00:00"));
+
+        when(plantService.list()).thenReturn(Collections.singletonList(plant));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.emptyList());
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.emptyList());
+        when(storageService.listAll()).thenReturn(Collections.emptyList());
+        when(manholeBaseService.list()).thenReturn(Collections.emptyList());
+
+        CockpitInfrastructureOperatingInformationSnapshot snapshot = adapter.load();
+
+        assertEquals(1, snapshot.getMetrics().size(), "能力值为空不能丢弃水厂实体行");
+        CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric = snapshot.getMetrics().get(0);
+        assertEquals("water_plant_current_supply", metric.getMetricCode());
+        assertEquals("WATER_PLANT", metric.getFacilityKind());
+        assertEquals("7", metric.getFacilityId());
+        assertNull(metric.getValue(), "缺失的当前能力如实为 null");
+        assertEquals(new BigDecimal("12.00"), metric.getCapacityValue());
+        assertEquals("PLANT-007", metric.getPointCodes().get(0));
+    }
+
+    /**
+     * 主键缺失时 facilityId 如实为 null,绝不下发字符串 "null"
+     * (票 01 判据 4:实体行的 facilityId 要能用于详情查询,不出现 404/500)。
+     */
+    @Test
+    void waterPlantWithoutPrimaryKeyHasNoQueryableFacilityId() {
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setId(null);
+        plant.setPlantCode("PLANT-NOID");
+        plant.setPlantName("无主键水厂");
+        when(plantService.list()).thenReturn(Collections.singletonList(plant));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.emptyList());
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.emptyList());
+        when(storageService.listAll()).thenReturn(Collections.emptyList());
+        when(manholeBaseService.list()).thenReturn(Collections.emptyList());
+
+        CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric =
+                adapter.load().getMetrics().get(0);
+        assertNull(metric.getFacilityId(), "缺主键的行不能冒充可回查的 facilityId");
+    }
+
+    /** 缺业务编码的水厂仍不产指标(没有稳定身份就无法回查详情)。 */
+    @Test
+    void skipsWaterPlantWithoutBusinessCode() {
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setId("8");
+        plant.setPlantName("无编号水厂");
+        plant.setCurrentCapacity(new BigDecimal("3.00"));
+        when(plantService.list()).thenReturn(Collections.singletonList(plant));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.emptyList());
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.emptyList());
+        when(storageService.listAll()).thenReturn(Collections.emptyList());
+        when(manholeBaseService.list()).thenReturn(Collections.emptyList());
+
+        assertTrue(adapter.load().getMetrics().isEmpty());
+    }
+
+    /**
+     * 泵站即使没有设计流量,也必须下发设施实体行(外部依赖票 01);
+     * 设计流量如实为 null,不拿 0 冒充。
+     */
+    @Test
+    void emitsPumpStationEntityRowWhenDesignFlowMissing() {
+        PumpStationInfo pump = new PumpStationInfo();
+        pump.setId("11");
+        pump.setStationCode("PS-011");
+        pump.setStationName("城南加压泵站");
+        pump.setStationType(PumpStationType.WATER_SUPPLY);
+        pump.setDesignFlow(null);
+        pump.setStatus("检修");
+        pump.setUpdateTime(LocalDateTime.parse("2026-11-18T09:00:00"));
+
+        when(plantService.list()).thenReturn(Collections.emptyList());
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Collections.singletonList(pump));
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.emptyList());
+        when(storageService.listAll()).thenReturn(Collections.emptyList());
+        when(manholeBaseService.list()).thenReturn(Collections.emptyList());
+
+        CockpitInfrastructureOperatingInformationSnapshot snapshot = adapter.load();
+
+        assertEquals(1, snapshot.getMetrics().size(), "设计流量为空不能丢弃泵站实体行");
+        CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric = snapshot.getMetrics().get(0);
+        assertEquals("water_supply_pump_station_design_flow", metric.getMetricCode());
+        assertEquals("PUMP_STATION", metric.getFacilityKind());
+        assertEquals("11", metric.getFacilityId());
+        assertNull(metric.getValue());
+        assertTrue(metric.isAbnormal(), "状态「检修」如实标记异常");
+    }
+
+    /**
+     * 九类设施必须各下发一条可枚举的实体行(外部依赖票 01)。
+     *
+     * <p>前端设施点图层唯一的实体来源就是这个端点的 {@code facilityKind + facilityId}:
+     * 少一类,图例上有这一类、图上却没有点。这里按当前库的类别清单(水厂、供水泵站、
+     * 排水泵站、水源地、闸门、调蓄设施、消火栓、用水户、窨井)各造一条,钉住九类全覆盖,
+     * 并要求每条都带可用于详情回查的稳定主键。</p>
+     */
+    @Test
+    void enumeratesEntityRowsForAllNineFacilityCategories() {
+        IWaterSourceInfoService waterSourceService = mock(IWaterSourceInfoService.class);
+        IWaterUserInfoService waterUserService = mock(IWaterUserInfoService.class);
+        IWaterFireHydrantInfoService hydrantService = mock(IWaterFireHydrantInfoService.class);
+        BusinessCockpitInfrastructureOperatingInformationAdapter fullAdapter =
+                new BusinessCockpitInfrastructureOperatingInformationAdapter(
+                        plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
+                        manholeBaseService, waterUserService, hydrantService, waterSourceService);
+
+        WaterPlantInfo plant = new WaterPlantInfo();
+        plant.setId("1"); plant.setPlantCode("WP001"); plant.setPlantName("一水厂");
+        plant.setCurrentCapacity(null);
+        PumpStationInfo supply = new PumpStationInfo();
+        supply.setId("2"); supply.setStationCode("PS001"); supply.setStationName("供水泵站");
+        supply.setStationType(PumpStationType.WATER_SUPPLY); supply.setDesignFlow(null);
+        PumpStationInfo drainage = new PumpStationInfo();
+        drainage.setId("3"); drainage.setStationCode("PS002"); drainage.setStationName("排水泵站");
+        drainage.setStationType(PumpStationType.DRAINAGE);
+        DrainageGateInfo gate = new DrainageGateInfo();
+        gate.setFacilityId("g-1"); gate.setFacilityCode("G001"); gate.setFacilityName("闸门");
+        DrainageStorageInfo storage = new DrainageStorageInfo();
+        storage.setFacilityId("s-1"); storage.setFacilityCode("S001"); storage.setFacilityName("调蓄池");
+        WaterSourceInfo source = new WaterSourceInfo();
+        source.setId("ws-1"); source.setSourceId("WS001"); source.setSourceName("洮水水源地");
+        source.setLongitude(new BigDecimal("110.440")); source.setLatitude(new BigDecimal("28.450"));
+        WaterUserInfo user = new WaterUserInfo();
+        user.setId("u-1"); user.setUserCode("U001"); user.setUserName("自来水公司");
+        WaterFireHydrantInfo hydrant = new WaterFireHydrantInfo();
+        hydrant.setHydrantId("h-1"); hydrant.setHydrantCode("FH001"); hydrant.setHydrantName("中山路消火栓");
+        ManholeBase manhole = manhole("MH-001", "沅陵县窨井001", "0");
+
+        when(plantService.list()).thenReturn(Collections.singletonList(plant));
+        when(pumpStationService.list(any(Wrapper.class))).thenReturn(Arrays.asList(supply, drainage));
+        when(pipeNetworkBaseService.list()).thenReturn(Collections.emptyList());
+        when(gateService.listAll()).thenReturn(Collections.singletonList(gate));
+        when(storageService.listAll()).thenReturn(Collections.singletonList(storage));
+        when(manholeBaseService.list()).thenReturn(Collections.singletonList(manhole));
+        when(waterSourceService.list()).thenReturn(Collections.singletonList(source));
+        when(waterUserService.list()).thenReturn(Collections.singletonList(user));
+        when(hydrantService.list()).thenReturn(Collections.singletonList(hydrant));
+
+        List<CockpitInfrastructureOperatingInformationSnapshot.SourceMetric> metrics =
+                fullAdapter.load().getMetrics();
+
+        List<String> kinds = metrics.stream()
+                .map(CockpitInfrastructureOperatingInformationSnapshot.SourceMetric::getFacilityKind)
+                .sorted().collect(Collectors.toList());
+        assertEquals(Arrays.asList(
+                        "DRAINAGE_GATE", "DRAINAGE_STORAGE", "MANHOLE", "PUMP_STATION", "PUMP_STATION",
+                        "WATER_FIRE_HYDRANT", "WATER_PLANT", "WATER_SOURCE", "WATER_USER"),
+                kinds, "九类设施(泵站按供水/排水两条)都要有实体行,一条都不能少");
+        // 两条泵站分别落到供水/排水行业,供水泵站与排水泵站各 1 条(票 01 判据 1)。
+        assertEquals(Arrays.asList("DRAINAGE", "WATER_SUPPLY"), metrics.stream()
+                .filter(metric -> "PUMP_STATION".equals(metric.getFacilityKind()))
+                .map(CockpitInfrastructureOperatingInformationSnapshot.SourceMetric::getIndustry)
+                .sorted().collect(Collectors.toList()),
+                "供水泵站与排水泵站都要有实体行且行业归属正确");
+        for (CockpitInfrastructureOperatingInformationSnapshot.SourceMetric metric : metrics) {
+            assertTrue(metric.getFacilityId() != null && !metric.getFacilityId().trim().isEmpty()
+                            && !"null".equals(metric.getFacilityId()),
+                    metric.getFacilityKind() + " 的 facilityId 必须能用于详情回查");
+            assertTrue(Arrays.asList("WATER_PLANT", "PUMP_STATION", "WATER_SOURCE", "WATER_USER",
+                            "WATER_FIRE_HYDRANT", "DRAINAGE_GATE", "DRAINAGE_STORAGE", "MANHOLE")
+                            .contains(metric.getFacilityKind()),
+                    "facilityKind 必须是前端可枚举的设施点类别");
+        }
+        CockpitInfrastructureOperatingInformationSnapshot.SourceMetric waterSource = metrics.stream()
+                .filter(metric -> "WATER_SOURCE".equals(metric.getFacilityKind()))
+                .findFirst().orElseThrow(AssertionError::new);
+        assertEquals("ws-1", waterSource.getFacilityId(), "水源地用主键作实体身份,与详情查询同源");
+        assertEquals("WATER_SUPPLY", waterSource.getIndustry());
+        assertEquals("处", waterSource.getUnit());
+        assertEquals("洮水水源地", waterSource.getMetricName());
+        assertEquals(BigDecimal.ONE, waterSource.getValue());
+        assertEquals("WS001", waterSource.getPointCodes().get(0));
+    }
+
+    /** 水源地缺业务编号时不产实体行(与其他类别同一纪律:无稳定编码不上图)。 */
+    @Test
+    void skipsWaterSourceWithoutBusinessCode() {
+        IWaterSourceInfoService waterSourceService = mock(IWaterSourceInfoService.class);
+        BusinessCockpitInfrastructureOperatingInformationAdapter fullAdapter =
+                new BusinessCockpitInfrastructureOperatingInformationAdapter(
+                        plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
+                        manholeBaseService, null, null, waterSourceService);
+        WaterSourceInfo source = new WaterSourceInfo();
+        source.setId("ws-2"); source.setSourceName("无编号水源地");
+        when(waterSourceService.list()).thenReturn(Collections.singletonList(source));
+
+        assertTrue(fullAdapter.load().getMetrics().isEmpty());
+    }
+
     /** 没有窨井时不产指标(不拿 0 凑数)。 */
     /** 没有窨井时不产指标(不拿 0 凑数)。 */
     @Test
     @Test
     void emitsNoManholeMetricWhenThereAreNone() {
     void emitsNoManholeMetricWhenThereAreNone() {

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

@@ -4,6 +4,8 @@ import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
 import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
 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.WaterSourceInfo.domain.WaterSourceInfo;
+import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
 import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
 import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
 import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 import com.zksy.WaterSupply.WaterUserInfo.service.IWaterUserInfoService;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
 import com.zksy.WaterSupply.PumpStationInfo.domain.PumpStationInfo;
@@ -32,7 +34,8 @@ class CockpitEntityDetailServiceTest {
     private final ManholeBaseService manholes = mock(ManholeBaseService.class);
     private final ManholeBaseService manholes = mock(ManholeBaseService.class);
     private final IWaterUserInfoService users = mock(IWaterUserInfoService.class);
     private final IWaterUserInfoService users = mock(IWaterUserInfoService.class);
     private final IWaterFireHydrantInfoService hydrants = mock(IWaterFireHydrantInfoService.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);
+    private final IWaterSourceInfoService waterSources = mock(IWaterSourceInfoService.class);
+    private final CockpitEntityDetailService service = new CockpitEntityDetailService(pipes, plants, stations, equipment, gates, storages, equipmentStatuses, hazards, risks, manholes, users, hydrants, waterSources);
 
 
     @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);
@@ -168,6 +171,49 @@ class CockpitEntityDetailServiceTest {
       assertEquals(new java.math.BigDecimal("28.200"), hydrantDetail.getCoordinates().getLatitude());
       assertEquals(new java.math.BigDecimal("28.200"), hydrantDetail.getCoordinates().getLatitude());
   }
   }
 
 
+  /**
+   * 水源地详情(外部依赖票 01)。
+   *
+   * <p>原话:「当前所有设施都带有坐标点,理应全部上图,例如水厂、泵站、水源地」。
+   * 水源地此前既没有实体行、也没有详情类别 —— 前端白名单里 detailCategory 只能留空。
+   * 本用例钉住 category=WATER_SOURCE 可解析、能按 water_source_info 主键取到经纬度,
+   * 且水源地专有字段(保护等级/水质等级/水源类型)如实下发。</p>
+   */
+  @Test void resolvesWaterSourceCategoryWithCoordinates() {
+      WaterSourceInfo source = new WaterSourceInfo();
+      source.setId("ws-1");
+      source.setSourceId("WS001");
+      source.setSourceName("洮水水源地");
+      source.setWaterType("地表水");
+      source.setProtectionLevel("一级");
+      source.setWaterQualityLevel("Ⅱ类");
+      source.setUnit("沅陵县供水公司");
+      source.setAddress("洮水镇河边");
+      source.setLongitude(new java.math.BigDecimal("110.440"));
+      source.setLatitude(new java.math.BigDecimal("28.450"));
+      source.setStatus("0");
+      when(waterSources.getById("ws-1")).thenReturn(source);
+
+      CockpitEntityDetailResponse detail = service.load("q", "WATER_SOURCE", "ws-1");
+
+      assertEquals("WATER_SOURCE", detail.getCategory());
+      assertEquals("ws-1", detail.getId());
+      assertEquals("WS001", detail.getCode());
+      assertEquals("洮水水源地", detail.getName());
+      assertEquals("0", detail.getStatus());
+      assertEquals(new java.math.BigDecimal("110.440"), detail.getCoordinates().getLongitude());
+      assertEquals(new java.math.BigDecimal("28.450"), detail.getCoordinates().getLatitude());
+      assertEquals("地表水", detail.getAttributes().get("waterType"));
+      assertEquals("一级", detail.getAttributes().get("protectionLevel"));
+      assertEquals("Ⅱ类", detail.getAttributes().get("waterQualityLevel"));
+      assertEquals("沅陵县供水公司", detail.getAttributes().get("unit"));
+  }
+
+  /** 水源地主键不存在 → 404 语义(NOT_FOUND),不是 500。 */
+  @Test void rejectsMissingWaterSource() {
+      assertThrows(CockpitEntityNotFoundException.class, () -> service.load("q", "WATER_SOURCE", "missing"));
+  }
+
   /** 旧状态值归一为 0/1;泵站 stationType 由 water_supply/drainage 归一为字典码 0/1。 */
   /** 旧状态值归一为 0/1;泵站 stationType 由 water_supply/drainage 归一为字典码 0/1。 */
   @Test void publishesNormalizedStatusAndPumpStationTypeCode() {
   @Test void publishesNormalizedStatusAndPumpStationTypeCode() {
       PumpStationInfo supply = new PumpStationInfo();
       PumpStationInfo supply = new PumpStationInfo();

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

@@ -5,7 +5,7 @@ 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, DRAINAGE_GATE, DRAINAGE_STORAGE,
+    PIPE_NETWORK, WATER_PLANT, PUMP_STATION, WATER_SOURCE, ENGINEERING_FACILITY, DRAINAGE_GATE, DRAINAGE_STORAGE,
     WATER_USER, WATER_FIRE_HYDRANT, MANHOLE, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
     WATER_USER, WATER_FIRE_HYDRANT, MANHOLE, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
 
 
     public static CockpitEntityCategory parse(String value) {
     public static CockpitEntityCategory parse(String value) {

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

@@ -2,6 +2,8 @@ package com.zksy.cockpit.entity;
 
 
 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.WaterSourceInfo.domain.WaterSourceInfo;
+import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
 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.domain.WaterFireHydrantInfo;
@@ -29,6 +31,7 @@ import com.zksy.cockpit.foundation.CockpitInvalidRequestException;
 import com.zksy.drainage.domain.DrainageFacilityBase;
 import com.zksy.drainage.domain.DrainageFacilityBase;
 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.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
@@ -52,16 +55,18 @@ public class CockpitEntityDetailService {
     private final ManholeBaseService manholes;
     private final ManholeBaseService manholes;
     private final IWaterUserInfoService users;
     private final IWaterUserInfoService users;
     private final IWaterFireHydrantInfoService hydrants;
     private final IWaterFireHydrantInfoService hydrants;
+    private final IWaterSourceInfoService waterSources;
 
 
+    @Autowired
     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) {
+            IWaterUserInfoService users, IWaterFireHydrantInfoService hydrants, IWaterSourceInfoService waterSources) {
         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;
+        this.users = users; this.hydrants = hydrants; this.waterSources = waterSources;
     }
     }
 
 
     public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
     public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
@@ -72,6 +77,7 @@ public class CockpitEntityDetailService {
             case PIPE_NETWORK: return pipe(requestId, id);
             case PIPE_NETWORK: return pipe(requestId, id);
             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 WATER_SOURCE: return waterSource(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_GATE: return drainageGate(requestId, id);
             case DRAINAGE_STORAGE: return drainageStorage(requestId, id);
             case DRAINAGE_STORAGE: return drainageStorage(requestId, id);
@@ -115,6 +121,30 @@ public class CockpitEntityDetailService {
     }
     }
 
 
 
 
+    /**
+     * 水源地详情(票 01):前端设施点图层从运行信息枚举到 WATER_SOURCE 后,需要按
+     * {@code water_source_info} 主键回查经纬度上图。字段只取该表真实存在的列;
+     * 水源地编码不带片区前缀,片区如实为 null=未分区。
+     */
+    private CockpitEntityDetailResponse waterSource(String requestId, String id) {
+        WaterSourceInfo v = waterSources == null ? null : waterSources.getById(id);
+        if (v == null) throw missing();
+        Map<String,Object> a = map();
+        put(a, "sourceType", v.getSourceType());
+        put(a, "unit", v.getUnit());
+        put(a, "address", v.getAddress());
+        put(a, "waterType", v.getWaterType());
+        put(a, "protectionLevel", v.getProtectionLevel());
+        put(a, "waterQualityLevel", v.getWaterQualityLevel());
+        put(a, "protectionScope", v.getProtectionScope());
+        put(a, "reportTime", v.getReportTime());
+        put(a, "remark", v.getRemark());
+        return response(requestId, "WATER_SOURCE", v.getId(), v.getSourceId(), v.getSourceName(),
+                CockpitFacilityContract.normalizeStatus(v.getStatus()), v.getAddress(), null,
+                new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
+                a, v.getUpdateTime());
+    }
+
     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);

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

@@ -5,6 +5,8 @@ import com.zksy.WaterSupply.WaterFireHydrantInfo.domain.WaterFireHydrantInfo;
 import com.zksy.WaterSupply.WaterFireHydrantInfo.service.IWaterFireHydrantInfoService;
 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.WaterSourceInfo.domain.WaterSourceInfo;
+import com.zksy.WaterSupply.WaterSourceInfo.service.IWaterSourceInfoService;
 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;
@@ -59,6 +61,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
     private final ManholeBaseService manholeBaseService;
     private final ManholeBaseService manholeBaseService;
     private final IWaterUserInfoService userService;
     private final IWaterUserInfoService userService;
     private final IWaterFireHydrantInfoService hydrantService;
     private final IWaterFireHydrantInfoService hydrantService;
+    private final IWaterSourceInfoService waterSourceService;
 
 
     /** 兼容旧调用的构造入口;新设施来源按空集处理,不改动既有口径。 */
     /** 兼容旧调用的构造入口;新设施来源按空集处理,不改动既有口径。 */
     public BusinessCockpitInfrastructureOperatingInformationAdapter(
     public BusinessCockpitInfrastructureOperatingInformationAdapter(
@@ -69,7 +72,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
             DrainageStorageInfoService storageService,
             DrainageStorageInfoService storageService,
             ManholeBaseService manholeBaseService) {
             ManholeBaseService manholeBaseService) {
         this(plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
         this(plantService, pumpStationService, pipeNetworkBaseService, gateService, storageService,
-                manholeBaseService, null, null);
+                manholeBaseService, null, null, null);
     }
     }
 
 
     @Autowired
     @Autowired
@@ -81,7 +84,8 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
             DrainageStorageInfoService storageService,
             DrainageStorageInfoService storageService,
             ManholeBaseService manholeBaseService,
             ManholeBaseService manholeBaseService,
             IWaterUserInfoService userService,
             IWaterUserInfoService userService,
-            IWaterFireHydrantInfoService hydrantService) {
+            IWaterFireHydrantInfoService hydrantService,
+            IWaterSourceInfoService waterSourceService) {
         this.plantService = plantService;
         this.plantService = plantService;
         this.pumpStationService = pumpStationService;
         this.pumpStationService = pumpStationService;
         this.pipeNetworkBaseService = pipeNetworkBaseService;
         this.pipeNetworkBaseService = pipeNetworkBaseService;
@@ -90,14 +94,17 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
         this.manholeBaseService = manholeBaseService;
         this.manholeBaseService = manholeBaseService;
         this.userService = userService;
         this.userService = userService;
         this.hydrantService = hydrantService;
         this.hydrantService = hydrantService;
+        this.waterSourceService = waterSourceService;
     }
     }
 
 
     @Override
     @Override
     public CockpitInfrastructureOperatingInformationSnapshot load() {
     public CockpitInfrastructureOperatingInformationSnapshot load() {
         List<CockpitInfrastructureOperatingInformationSnapshot.SourceMetric> metrics = new ArrayList<>();
         List<CockpitInfrastructureOperatingInformationSnapshot.SourceMetric> metrics = new ArrayList<>();
         String latestUpdatedAt = null;
         String latestUpdatedAt = null;
+        // 票 01:运行信息是前端设施点图层唯一的实体来源。水厂没有当前能力时**仍要下发实体行**
+        // (值如实为 null),否则库里带坐标的水厂永远不会上图、也不进「无地图位置」清单。
         for (WaterPlantInfo plant : safeList(plantService.list())) {
         for (WaterPlantInfo plant : safeList(plantService.list())) {
-            if (plant == null || isBlank(plant.getPlantCode()) || plant.getCurrentCapacity() == null) {
+            if (plant == null || isBlank(plant.getPlantCode())) {
                 continue;
                 continue;
             }
             }
             String sampledAt = format(plant.getUpdateTime());
             String sampledAt = format(plant.getUpdateTime());
@@ -112,7 +119,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     plant.getDesignCapacity(),
                     plant.getDesignCapacity(),
                     sampledAt,
                     sampledAt,
                     CockpitFacilityContract.isAbnormalStatus(plant.getStatus()),
                     CockpitFacilityContract.isAbnormalStatus(plant.getStatus()),
-                    plant.getPlantCode(), String.valueOf(plant.getId()), "WATER_PLANT",
+                    plant.getPlantCode(), facilityKey(plant.getId()), "WATER_PLANT",
                     CockpitFacilityContract.normalizeStatus(plant.getStatus())));
                     CockpitFacilityContract.normalizeStatus(plant.getStatus())));
         }
         }
 
 
@@ -120,7 +127,8 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                 new LambdaQueryWrapper<PumpStationInfo>()
                 new LambdaQueryWrapper<PumpStationInfo>()
                         .in(PumpStationInfo::getStationType,
                         .in(PumpStationInfo::getStationType,
                                 PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE, "0", "1")))) {
                                 PumpStationType.WATER_SUPPLY, PumpStationType.DRAINAGE, "0", "1")))) {
-            if (station == null || isBlank(station.getStationCode()) || station.getDesignFlow() == null) {
+            // 票 01:泵站同水厂 —— 设计流量为空不再跳过,只保留「无业务编码不产实体行」这一条门槛。
+            if (station == null || isBlank(station.getStationCode())) {
                 continue;
                 continue;
             }
             }
             String industry = pumpIndustry(station.getStationType());
             String industry = pumpIndustry(station.getStationType());
@@ -139,7 +147,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     null,
                     null,
                     sampledAt,
                     sampledAt,
                     CockpitFacilityContract.isAbnormalStatus(station.getStatus()),
                     CockpitFacilityContract.isAbnormalStatus(station.getStatus()),
-                    station.getStationCode(), String.valueOf(station.getId()), "PUMP_STATION",
+                    station.getStationCode(), facilityKey(station.getId()), "PUMP_STATION",
                     CockpitFacilityContract.normalizeStatus(station.getStatus())));
                     CockpitFacilityContract.normalizeStatus(station.getStatus())));
         }
         }
 
 
@@ -239,6 +247,29 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     CockpitFacilityContract.normalizeStatus(hydrant.getStatus())));
                     CockpitFacilityContract.normalizeStatus(hydrant.getStatus())));
         }
         }
 
 
+        // 水源地(票 01):此前本端点完全没有水源地的实体循环,图例有这一类、图上却没有点。
+        // 与用水户/消火栓同一口径:一处水源地一条实体行,值固定 1、单位「处」,行业供水。
+        for (WaterSourceInfo source : safeList(waterSourceService == null
+                ? null : waterSourceService.list())) {
+            if (source == null || isBlank(source.getSourceId())) {
+                continue;
+            }
+            String sampledAt = format(source.getUpdateTime());
+            latestUpdatedAt = latest(latestUpdatedAt, sampledAt);
+            metrics.add(metric(
+                    "water_source_point_count",
+                    isBlank(source.getSourceName()) ? "水源地" : source.getSourceName(),
+                    "CAPACITY",
+                    "处",
+                    "WATER_SUPPLY",
+                    BigDecimal.ONE,
+                    null,
+                    sampledAt,
+                    CockpitFacilityContract.isAbnormalStatus(source.getStatus()),
+                    source.getSourceId(), source.getId(), "WATER_SOURCE",
+                    CockpitFacilityContract.normalizeStatus(source.getStatus())));
+        }
+
         return new CockpitInfrastructureOperatingInformationSnapshot(latestUpdatedAt, metrics);
         return new CockpitInfrastructureOperatingInformationSnapshot(latestUpdatedAt, metrics);
     }
     }
 
 
@@ -302,6 +333,14 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                 CockpitFacilityContract.normalizeStatus(facility.getStatus())));
                 CockpitFacilityContract.normalizeStatus(facility.getStatus())));
     }
     }
 
 
+    /**
+     * 实体主键 → 可回查详情的 {@code facilityId}。票 01 起能力值为空的行也要下发,
+     * 缺主键的行没有稳定身份(详情无从寻址),如实不产实体行 —— 与「无业务编码不产行」同一条门槛。
+     */
+    private static String facilityKey(Object id) {
+        return id == null ? null : String.valueOf(id).trim();
+    }
+
     /** 行业为空的未分类项用 {@code unknown_} 前缀,避免空指针并保持编码可读。 */
     /** 行业为空的未分类项用 {@code unknown_} 前缀,避免空指针并保持编码可读。 */
     private static String metricCode(String industry, String suffix) {
     private static String metricCode(String industry, String suffix) {
         return (industry == null ? "unknown" : industry.toLowerCase()) + "_" + suffix;
         return (industry == null ? "unknown" : industry.toLowerCase()) + "_" + suffix;