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

feat(cockpit): 实体详情支持窨井类别

Kazerin 2 недель назад
Родитель
Сommit
78ece6945c

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

@@ -22,7 +22,8 @@ class CockpitEntityDetailServiceTest {
     private final EquipmentStatusService equipmentStatuses = mock(EquipmentStatusService.class);
     private final HazardHiddenAccountService hazards = mock(HazardHiddenAccountService.class);
     private final RiskAssessmentService risks = mock(RiskAssessmentService.class);
-    private final CockpitEntityDetailService service = new CockpitEntityDetailService(pipes, plants, stations, equipment, engineering, equipmentStatuses, hazards, risks);
+    private final ManholeBaseService manholes = mock(ManholeBaseService.class);
+    private final CockpitEntityDetailService service = new CockpitEntityDetailService(pipes, plants, stations, equipment, engineering, equipmentStatuses, hazards, risks, manholes);
 
     @Test void resolvesEverySupportedCategoryWithStableAttributes() {
         PipeNetworkBase pipe = new PipeNetworkBase(); pipe.setNetworkId("p1"); pipe.setNetworkCode("PN1"); pipe.setNetworkName("管网"); pipe.setMaterial("PE"); when(pipes.getById("p1")).thenReturn(pipe);
@@ -52,8 +53,44 @@ class CockpitEntityDetailServiceTest {
         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);
+
+        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());
+    }
+
     @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"));
     }
 }

+ 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;
 
 public enum CockpitEntityCategory {
-    PIPE_NETWORK, WATER_PLANT, PUMP_STATION, ENGINEERING_FACILITY, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
+    PIPE_NETWORK, WATER_PLANT, PUMP_STATION, ENGINEERING_FACILITY, MANHOLE, EMERGENCY_RESOURCE, HAZARD, PROTECTION_TARGET;
 
     public static CockpitEntityCategory parse(String value) {
         if (value == null || value.trim().isEmpty()) {

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

@@ -7,11 +7,13 @@ import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentStatus;
 import com.zksy.base.domain.HazardHiddenAccount;
+import com.zksy.base.domain.ManholeBase;
 import com.zksy.base.domain.PipeNetworkBase;
 import com.zksy.base.domain.RiskAssessment;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.service.HazardHiddenAccountService;
+import com.zksy.base.service.ManholeBaseService;
 import com.zksy.base.service.PipeNetworkBaseService;
 import com.zksy.base.service.RiskAssessmentService;
 import com.zksy.cockpit.foundation.CockpitDistrict;
@@ -40,12 +42,13 @@ public class CockpitEntityDetailService {
     private final EquipmentStatusService equipmentStatuses;
     private final HazardHiddenAccountService hazards;
     private final RiskAssessmentService risks;
+    private final ManholeBaseService manholes;
 
     public CockpitEntityDetailService(PipeNetworkBaseService pipes, IWaterPlantInfoService plants,
             IWaterPumpStationService stations, EquipmentBaseService equipment,
-            EngineeringFacilityService engineeringFacilities, EquipmentStatusService equipmentStatuses, HazardHiddenAccountService hazards, RiskAssessmentService risks) {
+            EngineeringFacilityService engineeringFacilities, EquipmentStatusService equipmentStatuses, HazardHiddenAccountService hazards, RiskAssessmentService risks, ManholeBaseService manholes) {
         this.pipes = pipes; this.plants = plants; this.stations = stations;
-        this.equipment = equipment; this.engineeringFacilities = engineeringFacilities; this.equipmentStatuses = equipmentStatuses; this.hazards = hazards; this.risks = risks;
+        this.equipment = equipment; this.engineeringFacilities = engineeringFacilities; this.equipmentStatuses = equipmentStatuses; this.hazards = hazards; this.risks = risks; this.manholes = manholes;
     }
 
     public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
@@ -57,6 +60,7 @@ public class CockpitEntityDetailService {
             case WATER_PLANT: return plant(requestId, id);
             case PUMP_STATION: return station(requestId, id);
             case ENGINEERING_FACILITY: return engineeringFacility(requestId, id);
+            case MANHOLE: return manhole(requestId, id);
             case EMERGENCY_RESOURCE: return resource(requestId, id);
             case HAZARD: return hazard(requestId, id);
             case PROTECTION_TARGET: return target(requestId, id);
@@ -115,6 +119,29 @@ public class CockpitEntityDetailService {
     }
 
 
+    /**
+     * 窨井详情(维护者 2026-11-16)。
+     *
+     * <p>字段只取 `manhole_base` 真实存在的列:井深/形状/材质/权属单位是窨井专有属性,
+     * 不拿别的设施的字段凑数(缺就如实为 null)。片区与管线一样按编码前缀推导 ——
+     * 窨井编码 `YL-YJ-001` 不带片区前缀,所以这里恒为 null=未分区。</p>
+     */
+    private CockpitEntityDetailResponse manhole(String requestId, String id) {
+        ManholeBase v = manholes.getById(id);
+        if (v == null) throw missing();
+        Map<String,Object> a = map();
+        put(a, "manholeDepth", v.getManholeDepth());
+        put(a, "manholeShape", v.getManholeShape());
+        put(a, "material", v.getMaterial());
+        put(a, "ownershipUnit", v.getOwnershipUnit());
+        put(a, "networkId", v.getNetworkId());
+        put(a, "remark", v.getRemark());
+        return response(requestId, "MANHOLE", v.getManholeId(), v.getManholeCode(), v.getManholeName(),
+                v.getStatus(), v.getLocation(), null,
+                new CockpitEntityDetailResponse.Coordinates(v.getLongitude(), v.getLatitude(), null, null),
+                a, v.getUpdateTime());
+    }
+
     private java.util.List<Map<String,Object>> linkedDevices(String value) {
         java.util.List<Map<String,Object>> rows = new java.util.ArrayList<>();
         if (blank(value)) return rows;