Przeglądaj źródła

fix(cockpit): expose raw pipe remarks for drainage colors (#32)

Kazerin 6 dni temu
rodzic
commit
1d1461a50c

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

@@ -64,7 +64,7 @@ class CockpitFacilityGeometryControllerTest {
     @Test
     void invalidGeometryIsExplicitJsonNullWithRawCoordinatesAndSameValidationShape() throws Exception {
         Properties properties = new Properties("gas_pipe_point", "1", "G1", "阀门", "GAS", "GAS_PIPE_POINT",
-                null, "阀门", null, null, Collections.singletonList(Arrays.asList(null, new BigDecimal("28.4"))),
+                null, "阀门", null, null, null, Collections.singletonList(Arrays.asList(null, new BigDecimal("28.4"))),
                 CockpitCoordinateValidator.validate(null, new BigDecimal("28.4"), true),
                 Collections.singletonList(CockpitCoordinateValidator.validate(null, new BigDecimal("28.4"), true)));
         when(service.load()).thenReturn(new CockpitFacilityGeometryResponse("2026-10-12T10:00:00+08:00",

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

@@ -116,6 +116,23 @@ class CockpitFacilityGeometryServiceTest {
         verifyNoMoreInteractions(networks);
     }
 
+    @Test
+    void exposesRawRemarkForDrainageColorClassificationWithoutGuessingFromName() {
+        PipeNetworkBase rain = network("rain-remark", "1");
+        rain.setNetworkName("名称不得代替备注");
+        rain.setRemark("雨水");
+        PipeNetworkBase sewage = network("sewage-remark", "1");
+        sewage.setRemark("污水");
+        PipeNetworkBase missing = network("missing-remark", "1");
+        when(networks.list()).thenReturn(Arrays.asList(rain, sewage, missing));
+        com.fasterxml.jackson.databind.JsonNode json = new com.fasterxml.jackson.databind.ObjectMapper()
+                .valueToTree(service.load());
+        assertEquals("雨水", json.get("features").get(0).get("properties").get("remark").asText());
+        assertEquals("污水", json.get("features").get(1).get("properties").get("remark").asText());
+        assertTrue(json.get("features").get(2).get("properties").has("remark"));
+        assertTrue(json.get("features").get(2).get("properties").get("remark").isNull());
+    }
+
     @Test
     void preservesEveryComponentTypeIncludingUnknownAndMissingTypesWithoutFabricatingNodes() {
         List<String> types = Arrays.asList("阀门", "调压", "计量", "阴极保护", "弯头", "三通", "其它", "未知原始值", null);

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

@@ -57,6 +57,8 @@ public class CockpitFacilityGeometryResponse {
         /** Original reported diameter in millimetres; null means not supplied. */
         @JsonInclude(JsonInclude.Include.ALWAYS)
         private final BigDecimal diameter;
+        @JsonInclude(JsonInclude.Include.ALWAYS)
+        private final String remark;
         // Raw pairs remain available for objects whose GeoJSON geometry must be null.
         private final List<List<BigDecimal>> sourceCoordinates;
         private final CockpitCoordinateValidation coordinateValidation;

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

@@ -53,20 +53,20 @@ public class CockpitFacilityGeometryService {
                 features.add(feature("pipe_network_base", network.getNetworkId(), network.getNetworkCode(),
                         network.getNetworkName(), industry == null ? "UNKNOWN" : industry,
                         CockpitPipeNetworkType.typeCodeOf(network.getNetworkType()), network.getNetworkType(),
-                        null, network.getNetworkId(), network.getDiameter(), "LineString", Arrays.asList(
+                        null, network.getNetworkId(), network.getDiameter(), network.getRemark(), "LineString", Arrays.asList(
                                 pair(network.getStartLongitude(), network.getStartLatitude()),
                                 pair(network.getEndLongitude(), network.getEndLatitude()))));
             }
             for (GasPipePoint point : Objects.requireNonNull(gasPoints.list())) {
                 features.add(feature("gas_pipe_point", String.valueOf(point.getPointId()), point.getPointCode(),
                         point.getPointName(), "GAS", "GAS_PIPE_POINT", null, point.getPointType(),
-                        point.getNetworkId(), point.getDiameter(), "Point",
+                        point.getNetworkId(), point.getDiameter(), null, "Point",
                         Collections.singletonList(pair(point.getLongitude(), point.getLatitude()))));
             }
             for (ManholeBase manhole : Objects.requireNonNull(manholes.list())) {
                 features.add(feature("manhole_base", manhole.getManholeId(), manhole.getManholeCode(),
                         manhole.getManholeName(), "MANHOLE", "MANHOLE", null, null,
-                        manhole.getNetworkId(), null, "Point",
+                        manhole.getNetworkId(), null, null, "Point",
                         Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
             }
             List<Coverage> coverage = new ArrayList<>();
@@ -94,7 +94,7 @@ public class CockpitFacilityGeometryService {
     }
 
     private static Feature feature(String source, String sourceId, String code, String name, String industry,
-            String typeCode, String networkType, String pointType, String networkId, BigDecimal diameter, String geometryType,
+            String typeCode, String networkType, String pointType, String networkId, BigDecimal diameter, String remark, String geometryType,
             List<List<BigDecimal>> coordinates) {
         List<CockpitCoordinateValidation> validations = coordinates.stream()
                 .map(pair -> validate(pair.get(0), pair.get(1)))
@@ -106,7 +106,7 @@ public class CockpitFacilityGeometryService {
         Geometry geometry = "INVALID".equals(overall.getState()) ? null : new Geometry(geometryType,
                 "Point".equals(geometryType) ? coordinates.get(0) : coordinates);
         Properties properties = new Properties(source, sourceId, code, name, industry, typeCode, networkType,
-                pointType, networkId, diameter, coordinates, overall, validations);
+                pointType, networkId, diameter, remark, coordinates, overall, validations);
         return new Feature(source + ":" + sourceId, geometry, properties);
     }