瀏覽代碼

test(cockpit): district 成对正反证改用计数有差异的样本

合法片区 0 与 1 的事件数/工单数刻意不同(2 vs 1、2/3 vs 1/1),
让「参数收下了但没筛」这种缺陷必然打红,而不是靠同样的计数碰巧通过。
codex 1 周之前
父節點
當前提交
241618740a

+ 6 - 4
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitCurrentEventsControllerTest.java

@@ -308,8 +308,10 @@ class CockpitCurrentEventsControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(0))
                 .andExpect(jsonPath("$.data.filters.districtName").value("城南"))
-                .andExpect(jsonPath("$.data.pagination.total").value(1))
-                .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-002"));
+                // 计数真的不同(0→2 条、1→1 条),不是「收下参数但没筛」
+                .andExpect(jsonPath("$.data.pagination.total").value(2))
+                .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-001"))
+                .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-002"));
 
         mockMvc.perform(get(ENDPOINT).param("mode", "WARNING").param("district", "1"))
                 .andExpect(status().isOk())
@@ -322,7 +324,7 @@ class CockpitCurrentEventsControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(nullValue()))
                 .andExpect(jsonPath("$.data.filters.districtName").value("未分区"))
-                .andExpect(jsonPath("$.data.pagination.total").value(3));
+                .andExpect(jsonPath("$.data.pagination.total").value(2));
 
         // 不传=全域
         mockMvc.perform(get(ENDPOINT).param("mode", "WARNING"))
@@ -409,7 +411,7 @@ class CockpitCurrentEventsControllerTest {
                         warning("W-001", "燃气浓度预警", "GAS_CONCENTRATION", 1, "ACTIVE",
                                 "2026-09-02T09:50:00+08:00", "2026-09-02T09:52:00+08:00",
                                 "12.5", "mg/m³", "D-GAS-1", "燃气浓度计-001", "MP-A-001", "城区A-燃气1号点", "城区A-燃气1号点",
-                                "GAS_SENSOR", "110.360", "28.440", true),
+                                "GAS_SENSOR", "110.360", "28.440", true, 0),
                         warning("W-002", "燃气压力预警", "GAS_PRESSURE", 2, "ACTIVE",
                                 "2026-09-02T09:45:00+08:00", "2026-09-02T09:46:00+08:00",
                                 "0.32", "MPa", "D-GAS-2", "燃气浓度计-002", "MP-A-002", "城区A-燃气2号点", "城区A-燃气2号点",

+ 10 - 7
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitHandlingEfficiencyControllerTest.java

@@ -156,11 +156,12 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(0))
                 .andExpect(jsonPath("$.data.filters.districtName").value("城南"))
-                .andExpect(jsonPath("$.data.summary.totalEvents").value(1))
-                .andExpect(jsonPath("$.data.summary.handledCount").value(1))
-                .andExpect(jsonPath("$.data.summary.handlingEfficiency.numerator").value(1))
-                .andExpect(jsonPath("$.data.summary.handlingEfficiency.denominator").value(2))
-                .andExpect(jsonPath("$.data.workOrderStateCounts[5].count").value(1))
+                // 计数真的不同(0→2 条事件、2→1 条),不是「收下参数但没筛」
+                .andExpect(jsonPath("$.data.summary.totalEvents").value(2))
+                .andExpect(jsonPath("$.data.summary.handledCount").value(2))
+                .andExpect(jsonPath("$.data.summary.handlingEfficiency.numerator").value(2))
+                .andExpect(jsonPath("$.data.summary.handlingEfficiency.denominator").value(3))
+                .andExpect(jsonPath("$.data.workOrderStateCounts[5].count").value(2))
                 .andExpect(jsonPath("$.data.workOrderStateCounts[4].count").value(1))
                 .andExpect(jsonPath("$.data.workOrderStateCounts[0].count").value(0));
 
@@ -194,8 +195,8 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(nullValue()))
                 .andExpect(jsonPath("$.data.filters.districtName").value(nullValue()))
-                .andExpect(jsonPath("$.data.summary.totalEvents").value(2))
-                .andExpect(jsonPath("$.data.summary.handlingEfficiency.denominator").value(4));
+                .andExpect(jsonPath("$.data.summary.totalEvents").value(3))
+                .andExpect(jsonPath("$.data.summary.handlingEfficiency.denominator").value(5));
     }
 
     @Test
@@ -705,11 +706,13 @@ class CockpitHandlingEfficiencyControllerTest {
                         warningWithDistrict("EW-U", 1, "2026-09-02T10:10:00+08:00", "GAS_SENSOR", "D-GAS-3", "燃气浓度计-003", null)),
                 Arrays.asList(
                         alarm("EA-S", 1, "2026-09-02T08:20:00+08:00", "GAS_SENSOR", "D-GAS-1", "燃气浓度计-001", 0),
+                        alarm("EA-S2", 1, "2026-09-02T10:20:00+08:00", "GAS_SENSOR", "D-GAS-4", "燃气浓度计-004", 0),
                         alarm("EA-T", 1, "2026-09-02T09:20:00+08:00", "GAS_SENSOR", "D-GAS-2", "燃气浓度计-002", 2)),
                 Collections.emptyList(),
                 Arrays.asList(
                         scopeOrder("WO-S5", 5, "GAS_SENSOR", 0),
                         scopeOrder("WO-S4", 4, "GAS_SENSOR", 0),
+                        scopeOrder("WO-S6", 5, "GAS_SENSOR", 0),
                         scopeOrder("WO-T", 5, "GAS_SENSOR", 2),
                         scopeOrder("WO-U", 0, "GAS_SENSOR", null)));
     }

+ 6 - 4
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitHistoryAnalysisControllerTest.java

@@ -128,9 +128,11 @@ class CockpitHistoryAnalysisControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(0))
                 .andExpect(jsonPath("$.data.filters.districtName").value("城南"))
-                .andExpect(jsonPath("$.data.summary.eventCount").value(1))
-                .andExpect(jsonPath("$.data.events", hasSize(1)))
+                // 计数真的不同(0→2 条、1→1 条),不是「收下参数但没筛」
+                .andExpect(jsonPath("$.data.summary.eventCount").value(2))
+                .andExpect(jsonPath("$.data.events", hasSize(2)))
                 .andExpect(jsonPath("$.data.events[0].eventNo").value("HW-002"))
+                .andExpect(jsonPath("$.data.events[1].eventNo").value("HW-001"))
                 .andExpect(jsonPath("$.data.summary.handlingEfficiency.numerator").value(1))
                 .andExpect(jsonPath("$.data.summary.handlingEfficiency.denominator").value(2));
 
@@ -155,7 +157,7 @@ class CockpitHistoryAnalysisControllerTest {
                 .andExpect(status().isOk())
                 .andExpect(jsonPath("$.data.filters.district").value(nullValue()))
                 .andExpect(jsonPath("$.data.filters.districtName").value("未分区"))
-                .andExpect(jsonPath("$.data.summary.eventCount").value(3));
+                .andExpect(jsonPath("$.data.summary.eventCount").value(2));
 
         // 不传=全域(双字段都为空,不是「未分区」)
         mockMvc.perform(get(ENDPOINT)
@@ -466,7 +468,7 @@ class CockpitHistoryAnalysisControllerTest {
                         new CockpitHistoryAnalysisSnapshot.SourceType(
                                 "SMART_MANHOLE", "智能井盖", null, "SMART_DEVICE")),
                 Arrays.asList(
-                        warning("HW-001", 1, "2026-09-01T23:30:00+08:00", "GAS_SENSOR", "D-GAS-1"),
+                        warning("HW-001", 1, "2026-09-01T23:30:00+08:00", "GAS_SENSOR", "D-GAS-1", 0),
                         warning("HW-002", 2, "2026-09-02T00:15:00+08:00", "GAS_SENSOR", "D-GAS-2", 0),
                         warning("HW-003", 2, "2026-09-02T00:45:00+08:00", "WATER_SUPPLY_SENSOR", "D-WS-1", 1),
                         warning("HW-004", 4, "2026-09-02T01:20:00+08:00", "SEWAGE_ENV", "D-DR-1"),