Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

林仔 před 5 dny
rodič
revize
528b601c8d

+ 1 - 0
.idea/encodings.xml

@@ -19,6 +19,7 @@
     <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/telemetry-service/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/video-service/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/water-level-service/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/zk-api-service/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/zk-common/src/main/java" charset="UTF-8" />

+ 5 - 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, Collections.singletonList(Arrays.asList(null, new BigDecimal("28.4"))),
+                null, 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",
@@ -73,6 +73,7 @@ class CockpitFacilityGeometryControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.features[0].type").value("Feature"))
                 .andExpect(jsonPath("$.data.features[0].geometry").value(nullValue()))
+                .andExpect(jsonPath("$.data.features[0].properties.networkLevel").value(nullValue()))
                 .andExpect(jsonPath("$.data.features[0].properties.networkId").value(nullValue()))
                 .andExpect(jsonPath("$.data.features[0].properties.pointType").value("阀门"))
                 .andExpect(jsonPath("$.data.features[0].properties.sourceCoordinates[0][0]").value(nullValue()))
@@ -101,6 +102,7 @@ class CockpitFacilityGeometryControllerTest {
         com.zksy.base.domain.PipeNetworkBase line = new com.zksy.base.domain.PipeNetworkBase();
         line.setNetworkId("gas-line");
         line.setNetworkType("0");
+        line.setDiameter(new BigDecimal("400.50"));
         line.setStartLongitude(new BigDecimal("110.360"));
         line.setStartLatitude(new BigDecimal("28.420"));
         line.setEndLongitude(new BigDecimal("110.420"));
@@ -122,6 +124,8 @@ class CockpitFacilityGeometryControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.features", hasSize(2)))
                 .andExpect(jsonPath("$.data.features[0].geometry.type").value("LineString"))
+                .andExpect(jsonPath("$.data.features[0].properties.diameter").value(400.50))
+                .andExpect(jsonPath("$.data.features[1].properties.diameter").value(nullValue()))
                 .andExpect(jsonPath("$.data.features[0].geometry.coordinates", hasSize(2)))
                 .andExpect(jsonPath("$.data.features[0].geometry.coordinates[0][0]").value(110.360))
                 .andExpect(jsonPath("$.data.features[0].geometry.coordinates[0][1]").value(28.420))

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

@@ -84,6 +84,80 @@ class CockpitFacilityGeometryServiceTest {
         verifyNoMoreInteractions(networks, points, manholes);
     }
 
+    @Test
+    void exposesReportedDiameterInMillimetresAndKeepsMissingDiameterExplicit() {
+        PipeNetworkBase known = network("known-diameter", "0");
+        known.setDiameter(new BigDecimal("400.50"));
+        PipeNetworkBase missing = network("missing-diameter", "0");
+        PipeNetworkBase zero = network("zero-diameter", "0");
+        zero.setDiameter(BigDecimal.ZERO);
+        GasPipePoint point = point(7L, "阀门");
+        point.setDiameter(new BigDecimal("125.25"));
+        ManholeBase well = new ManholeBase();
+        well.setManholeId("well");
+        well.setLongitude(new BigDecimal("110.440"));
+        well.setLatitude(new BigDecimal("28.450"));
+        when(networks.list()).thenReturn(Arrays.asList(known, missing, zero));
+        when(points.list()).thenReturn(Collections.singletonList(point));
+        when(manholes.list()).thenReturn(Collections.singletonList(well));
+        com.fasterxml.jackson.databind.JsonNode json = new com.fasterxml.jackson.databind.ObjectMapper()
+                .valueToTree(service.load());
+        com.fasterxml.jackson.databind.JsonNode properties = json.get("features").get(0).get("properties");
+        assertTrue(properties.has("diameter"));
+        assertEquals(400.50, properties.get("diameter").asDouble());
+        assertTrue(json.get("features").get(1).get("properties").has("diameter"));
+        assertTrue(json.get("features").get(1).get("properties").get("diameter").isNull());
+        assertEquals(0, json.get("features").get(2).get("properties").get("diameter").asInt());
+        assertEquals(125.25, json.get("features").get(3).get("properties").get("diameter").asDouble());
+        assertTrue(json.get("features").get(4).get("properties").get("diameter").isNull());
+        assertEquals(new BigDecimal("400.50"), known.getDiameter());
+        assertNull(missing.getDiameter());
+        verify(networks).list();
+        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 exposesNetworkLevelForDrainageAndDefaultsLegacyMissingLevelWithoutMutatingSource() {
+        PipeNetworkBase sewage = network("level-zero", "1");
+        sewage.setNetworkLevel("0");
+        PipeNetworkBase rain = network("level-one", "1");
+        rain.setNetworkLevel("1");
+        PipeNetworkBase legacy = network("level-missing", "1");
+        PipeNetworkBase blank = network("level-blank", "1");
+        blank.setNetworkLevel("  ");
+        PipeNetworkBase gas = network("gas-level-one", "0");
+        gas.setNetworkLevel("1");
+        when(networks.list()).thenReturn(Arrays.asList(sewage, rain, legacy, blank, gas));
+        com.fasterxml.jackson.databind.JsonNode json = new com.fasterxml.jackson.databind.ObjectMapper().valueToTree(service.load());
+        assertEquals("0", json.get("features").get(0).get("properties").get("networkLevel").asText());
+        assertEquals("1", json.get("features").get(1).get("properties").get("networkLevel").asText());
+        assertEquals("0", json.get("features").get(2).get("properties").get("networkLevel").asText());
+        assertEquals("0", json.get("features").get(3).get("properties").get("networkLevel").asText());
+        assertEquals("GAS", json.get("features").get(4).get("properties").get("industry").asText());
+        assertEquals("1", json.get("features").get(4).get("properties").get("networkLevel").asText());
+        assertNull(legacy.getNetworkLevel());
+        assertEquals("  ", blank.getNetworkLevel());
+        verify(networks).list();
+        verifyNoMoreInteractions(networks);
+    }
+
     @Test
     void preservesEveryComponentTypeIncludingUnknownAndMissingTypesWithoutFabricatingNodes() {
         List<String> types = Arrays.asList("阀门", "调压", "计量", "阴极保护", "弯头", "三通", "其它", "未知原始值", null);

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

@@ -50,10 +50,18 @@ public class CockpitFacilityGeometryResponse {
         private final String industry;
         private final String typeCode;
         private final String networkType;
+        /** Drainage subtype: 0 sewage (legacy default), 1 rainwater; ignored by other industries. */
+        @JsonInclude(JsonInclude.Include.ALWAYS)
+        private final String networkLevel;
         @JsonInclude(JsonInclude.Include.ALWAYS)
         private final String pointType;
         @JsonInclude(JsonInclude.Include.ALWAYS)
         private final String networkId;
+        /** 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;

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

@@ -53,20 +53,22 @@ 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(), "LineString", Arrays.asList(
+                        "DRAINAGE".equals(industry) && (network.getNetworkLevel() == null || network.getNetworkLevel().trim().isEmpty())
+                                ? "0" : network.getNetworkLevel(),
+                        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",
+                        point.getPointName(), "GAS", "GAS_PIPE_POINT", null, null, point.getPointType(),
+                        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(), "Point",
+                        manhole.getManholeName(), "MANHOLE", "MANHOLE", null, null, null,
+                        manhole.getNetworkId(), null, null, "Point",
                         Collections.singletonList(pair(manhole.getLongitude(), manhole.getLatitude()))));
             }
             List<Coverage> coverage = new ArrayList<>();
@@ -94,7 +96,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, String geometryType,
+            String typeCode, String networkType, String networkLevel, 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)))
@@ -105,8 +107,8 @@ public class CockpitFacilityGeometryService {
         // Invalid GeoJSON coordinates cannot be represented as an empty or invented geometry.
         Geometry geometry = "INVALID".equals(overall.getState()) ? null : new Geometry(geometryType,
                 "Point".equals(geometryType) ? coordinates.get(0) : coordinates);
-        Properties properties = new Properties(source, sourceId, code, name, industry, typeCode, networkType,
-                pointType, networkId, coordinates, overall, validations);
+        Properties properties = new Properties(source, sourceId, code, name, industry, typeCode, networkType, networkLevel,
+                pointType, networkId, diameter, remark, coordinates, overall, validations);
         return new Feature(source + ":" + sourceId, geometry, properties);
     }