Forráskód Böngészése

fix(cockpit): 预警历史/效率/分析排除草稿预警

草稿(DRAFT)是保存了但未发布的编辑稿,却进入了历史分析的逐事件行与小时桶、
处置效率的六态分布与处置率分母、多维分析的维度计数 —— 这也是前端过滤后
pagination.total 与可见行对不上的根因。

- WarningWorkflow.isDraft:状态为空/缺失不算草稿,与总览计数判据同语义
- 三个服务在预警事实构造处排除草稿,同一份 facts 派生的读数因此全口径一致
- 多维分析快照补 status 字段:该端点此前的快照不带状态,无从判断草稿
- 回归:历史/效率/分析三处 controller 测试覆盖「草稿被排除、空状态保留」;
  效率夹具的 DRAFT 行保留在快照里,断言改为 8 条 / DRAFT 桶计 0

整包 zksy-admin+zksy-system 319 项中 4 项失败为既有红点
(CollectionRecordAssessmentServiceTest 2、LegacyPipeTableRetirementTest 1、
PipeNetworkStatusDictionaryContractTest 1),暂存本次改动后同批复现,与本票无关。
Kazerin 4 napja
szülő
commit
fe25731a5f

+ 1 - 0
docs/cockpit/README.md

@@ -100,6 +100,7 @@
 - `monitoring/overview` 的 `devices[]` 是**逐设备台账行**(2026-10-22 追加):每行 = `deviceCode` / `deviceName` / `deviceType{code,name}` / `industry` / `monitoringState` / `monitoringPointCode` / `sampledAt` / `createdAt`,顺序为后端遍历顺序(稳定,调用方不重排)。**行数恒等于 `counts.equipmentCount`**(同一遍历产出,不是第二个口径),筛选(`industry`/`deviceType`)生效时两者同步收窄。它与 `monitoring/situation` 的 `abnormalEquipment[]` **不是一回事**:后者只装异常四态(WARNING/ALARM/EXPIRED/OFFLINE)设备,是「异常清单」;前者是**全部**智能设备的台账。缺值一律 `null`(`deviceName`/`monitoringPointCode`/`createdAt`),不拿编码冒充、不填 0。
 - `monitoring/overview` 的 `devices[]` 是**逐设备台账行**(2026-10-22 追加):每行 = `deviceCode` / `deviceName` / `deviceType{code,name}` / `industry` / `monitoringState` / `monitoringPointCode` / `sampledAt` / `createdAt`,顺序为后端遍历顺序(稳定,调用方不重排)。**行数恒等于 `counts.equipmentCount`**(同一遍历产出,不是第二个口径),筛选(`industry`/`deviceType`)生效时两者同步收窄。它与 `monitoring/situation` 的 `abnormalEquipment[]` **不是一回事**:后者只装异常四态(WARNING/ALARM/EXPIRED/OFFLINE)设备,是「异常清单」;前者是**全部**智能设备的台账。缺值一律 `null`(`deviceName`/`monitoringPointCode`/`createdAt`),不拿编码冒充、不填 0。
 - 事件坐标按同一自动准入判定(不再依赖 `coordinateVerified`):区内且数值合法 → `VALID` / `renderable=true`。报警族在数据可得时另带 `thresholdMinValue`/`thresholdMaxValue`(预警族为 `null`)。
 - 事件坐标按同一自动准入判定(不再依赖 `coordinateVerified`):区内且数值合法 → `VALID` / `renderable=true`。报警族在数据可得时另带 `thresholdMinValue`/`thresholdMaxValue`(预警族为 `null`)。
 - `events/history-analysis` 同时返回两块内容:`rows[]` 是**小时桶聚合行**(趋势与行级处置率口径,不携带逐事件坐标/阈值);`events[]` 是**逐事件行**(票 61 新增,形状与 `events/current` 的 `EventItem` 同构),按 `eventTime` 倒序、同时间按 `eventNo` 升序,由 `page`/`pageSize`(默认 1/100,上限 1000)分页,元数据在 `pagination` 中,`pagination.total` 即窗口内事件总数。逐事件坐标仍只在 `events/current` 提供,历史逐事件行的 `coordinateValidation` 为 `null`。
 - `events/history-analysis` 同时返回两块内容:`rows[]` 是**小时桶聚合行**(趋势与行级处置率口径,不携带逐事件坐标/阈值);`events[]` 是**逐事件行**(票 61 新增,形状与 `events/current` 的 `EventItem` 同构),按 `eventTime` 倒序、同时间按 `eventNo` 升序,由 `page`/`pageSize`(默认 1/100,上限 1000)分页,元数据在 `pagination` 中,`pagination.total` 即窗口内事件总数。逐事件坐标仍只在 `events/current` 提供,历史逐事件行的 `coordinateValidation` 为 `null`。
+- 预警族三个事件端点(`events/history-analysis`、`events/handling-efficiency`、`events/multidimensional-analysis`)一律排除**草稿**(`DRAFT`)预警(票 126):草稿只是未发布的编辑稿,不进逐事件行、不进小时桶/六态分布/维度桶、不计 `pagination.total`,也**不进** `warningHandlingEfficiency` 的分母。判据与总览计数同一条——`status IS NULL OR UPPER(TRIM(status)) <> 'DRAFT'`,即状态为空/缺失的行**保留**,不因词表缺口被丢掉。`events/current` 的口径不同(排除 DRAFT 与 CLOSED),两处各自成立、互不覆盖。
 
 
 ### 监测点详情设备坐标
 ### 监测点详情设备坐标
 
 

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

@@ -89,10 +89,11 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(jsonPath("$.data.eventFamily").value("WARNING"))
                 .andExpect(jsonPath("$.data.eventFamily").value("WARNING"))
                 .andExpect(jsonPath("$.data.filters.eventFamily").value("WARNING"))
                 .andExpect(jsonPath("$.data.filters.eventFamily").value("WARNING"))
                 .andExpect(jsonPath("$.data.filters.workOrderState").value(nullValue()))
                 .andExpect(jsonPath("$.data.filters.workOrderState").value(nullValue()))
-                // 事件口径两族共用(真实计数,不是第二轮读数)。
-                .andExpect(jsonPath("$.data.summary.totalEvents").value(9))
+                // 事件口径两族共用(真实计数,不是第二轮读数);EW-008 是草稿,已按票 126 排除。
+                .andExpect(jsonPath("$.data.summary.totalEvents").value(8))
                 .andExpect(jsonPath("$.data.summary.linkedWorkOrderCount").value(6))
                 .andExpect(jsonPath("$.data.summary.linkedWorkOrderCount").value(6))
-                .andExpect(jsonPath("$.data.summary.missingWorkOrderCount").value(3))
+                // EW-008 是草稿且无工单:排除后缺失数随之 3 → 2。
+                .andExpect(jsonPath("$.data.summary.missingWorkOrderCount").value(2))
                 // 票 74:**工单口径**对预警族不成立 → 显式 null(不是 0,也不是别的族的数)。
                 // 票 74:**工单口径**对预警族不成立 → 显式 null(不是 0,也不是别的族的数)。
                 .andExpect(jsonPath("$.data.summary.handledCount").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.handledCount").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.inProgressCount").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.inProgressCount").value(nullValue()))
@@ -100,11 +101,12 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(jsonPath("$.data.summary.handlingEfficiency").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.handlingEfficiency").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.averageDuration").value(nullValue()))
                 .andExpect(jsonPath("$.data.summary.averageDuration").value(nullValue()))
                 .andExpect(jsonPath("$.data.workOrderStateCounts").value(nullValue()))
                 .andExpect(jsonPath("$.data.workOrderStateCounts").value(nullValue()))
-                // 六个已知态全铺;EW-LEGACY 状态为空,另计 UNKNOWN,桶和仍为 9。
+                // 六个已知态全铺;EW-008 是草稿(票 126),DRAFT 桶保留但计 0;
+                // EW-LEGACY 状态为空,另计 UNKNOWN,桶和仍为 8。
                 .andExpect(jsonPath("$.data.warningStateCounts", hasSize(7)))
                 .andExpect(jsonPath("$.data.warningStateCounts", hasSize(7)))
                 .andExpect(jsonPath("$.data.warningStateCounts[0].stateCode").value("DRAFT"))
                 .andExpect(jsonPath("$.data.warningStateCounts[0].stateCode").value("DRAFT"))
                 .andExpect(jsonPath("$.data.warningStateCounts[0].stateName").value("草稿"))
                 .andExpect(jsonPath("$.data.warningStateCounts[0].stateName").value("草稿"))
-                .andExpect(jsonPath("$.data.warningStateCounts[0].count").value(1))
+                .andExpect(jsonPath("$.data.warningStateCounts[0].count").value(0))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].stateCode").value("PENDING"))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].stateCode").value("PENDING"))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].stateName").value("待接收"))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].stateName").value("待接收"))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].count").value(1))
                 .andExpect(jsonPath("$.data.warningStateCounts[1].count").value(1))
@@ -120,10 +122,10 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(jsonPath("$.data.warningStateCounts[6].stateCode").value("UNKNOWN"))
                 .andExpect(jsonPath("$.data.warningStateCounts[6].stateCode").value("UNKNOWN"))
                 .andExpect(jsonPath("$.data.warningStateCounts[6].stateName").value("未知"))
                 .andExpect(jsonPath("$.data.warningStateCounts[6].stateName").value("未知"))
                 .andExpect(jsonPath("$.data.warningStateCounts[6].count").value(1))
                 .andExpect(jsonPath("$.data.warningStateCounts[6].count").value(1))
-                // 已解除率=已解除 ÷ 窗口内全部预警数(含未知类型,3/9)。
+                // 已解除率=已解除 ÷ 窗口内全部预警数(含未知类型,3/8;草稿不进分母)。
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.numerator").value(3))
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.numerator").value(3))
-                .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.denominator").value(9))
-                .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.value").value("0.3333"))
+                .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.denominator").value(8))
+                .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.value").value("0.3750"))
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.state").value("AVAILABLE"))
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.state").value("AVAILABLE"))
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.basis")
                 .andExpect(jsonPath("$.data.summary.warningHandlingEfficiency.basis")
                         .value("CLOSED_WARNINGS_OVER_WINDOW_WARNINGS"))
                         .value("CLOSED_WARNINGS_OVER_WINDOW_WARNINGS"))
@@ -132,18 +134,18 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(jsonPath("$.data.summary.warningDuration.unit").value("HOURS"))
                 .andExpect(jsonPath("$.data.summary.warningDuration.unit").value("HOURS"))
                 .andExpect(jsonPath("$.data.summary.warningDuration.sampleCount").value(3))
                 .andExpect(jsonPath("$.data.summary.warningDuration.sampleCount").value(3))
                 .andExpect(jsonPath("$.data.summary.warningDuration.state").value("AVAILABLE"))
                 .andExpect(jsonPath("$.data.summary.warningDuration.state").value("AVAILABLE"))
-                .andExpect(jsonPath("$.data.events", hasSize(9)))
+                .andExpect(jsonPath("$.data.events", hasSize(8)))
                 .andExpect(jsonPath("$.data.events[0].eventNo").value("EW-007"))
                 .andExpect(jsonPath("$.data.events[0].eventNo").value("EW-007"))
                 .andExpect(jsonPath("$.data.events[0].hasWorkOrder").value(true))
                 .andExpect(jsonPath("$.data.events[0].hasWorkOrder").value(true))
                 .andExpect(jsonPath("$.data.events[*].eventNo").value(contains(
                 .andExpect(jsonPath("$.data.events[*].eventNo").value(contains(
-                        "EW-007", "EW-006", "EW-005", "EW-004", "EW-008", "EW-003", "EW-LEGACY", "EW-002", "EW-001")))
+                        "EW-007", "EW-006", "EW-005", "EW-004", "EW-003", "EW-LEGACY", "EW-002", "EW-001")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].deviceCode").value(contains("D-LEGACY")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].deviceCode").value(contains("D-LEGACY")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].hasWorkOrder").value(contains(false)))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].hasWorkOrder").value(contains(false)))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].workOrderStateCode").value(contains(nullValue())))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].workOrderStateCode").value(contains(nullValue())))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].levelColor").value(contains("RED")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].levelColor").value(contains("RED")))
-                .andExpect(jsonPath("$.data.pagination.total").value(9))
+                .andExpect(jsonPath("$.data.pagination.total").value(8))
                 .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains(
                 .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains(
-                        "D-DR-1", "D-DR-2", "D-DR-3", "D-GAS-1", "D-GAS-2", "D-GAS-3", "D-LEGACY", "D-WS-1", "D-WS-2")))
+                        "D-DR-1", "D-DR-2", "D-GAS-1", "D-GAS-2", "D-GAS-3", "D-LEGACY", "D-WS-1", "D-WS-2")))
                 // 趋势桶:事件发布量照实给,工单结案量与结案时长两族口径 → null。
                 // 趋势桶:事件发布量照实给,工单结案量与结案时长两族口径 → null。
                 .andExpect(jsonPath("$.data.durationTrend", hasSize(5)))
                 .andExpect(jsonPath("$.data.durationTrend", hasSize(5)))
                 .andExpect(jsonPath("$.data.durationTrend[0].timeBucket").value("2026-09-02T08:00:00+08:00"))
                 .andExpect(jsonPath("$.data.durationTrend[0].timeBucket").value("2026-09-02T08:00:00+08:00"))
@@ -151,7 +153,7 @@ class CockpitHandlingEfficiencyControllerTest {
                 .andExpect(jsonPath("$.data.durationTrend[0].handledCount").value(nullValue()))
                 .andExpect(jsonPath("$.data.durationTrend[0].handledCount").value(nullValue()))
                 .andExpect(jsonPath("$.data.durationTrend[0].averageDuration").value(nullValue()))
                 .andExpect(jsonPath("$.data.durationTrend[0].averageDuration").value(nullValue()))
                 .andExpect(jsonPath("$.data.durationTrend[1].timeBucket").value("2026-09-02T09:00:00+08:00"))
                 .andExpect(jsonPath("$.data.durationTrend[1].timeBucket").value("2026-09-02T09:00:00+08:00"))
-                .andExpect(jsonPath("$.data.durationTrend[1].eventCount").value(3))
+                .andExpect(jsonPath("$.data.durationTrend[1].eventCount").value(2))
                 .andExpect(jsonPath("$.data.durationTrend[2].eventCount").value(2))
                 .andExpect(jsonPath("$.data.durationTrend[2].eventCount").value(2))
                 .andExpect(jsonPath("$.data.durationTrend[3].eventCount").value(2))
                 .andExpect(jsonPath("$.data.durationTrend[3].eventCount").value(2))
                 .andExpect(jsonPath("$.data.durationTrend[4].timeBucket").value("2026-09-02T12:00:00+08:00"))
                 .andExpect(jsonPath("$.data.durationTrend[4].timeBucket").value("2026-09-02T12:00:00+08:00"))
@@ -341,12 +343,12 @@ class CockpitHandlingEfficiencyControllerTest {
                         .param("startTime", START)
                         .param("startTime", START)
                         .param("endTime", END))
                         .param("endTime", END))
                 .andExpect(status().isOk())
                 .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.summary.missingWorkOrderCount").value(3))
-                .andExpect(jsonPath("$.data.events", hasSize(9)))
-                .andExpect(jsonPath("$.data.summary.totalEvents").value(9))
-                .andExpect(jsonPath("$.data.events[?(@.hasWorkOrder == false)].eventNo").value(contains("EW-005", "EW-008", "EW-LEGACY")))
+                .andExpect(jsonPath("$.data.summary.missingWorkOrderCount").value(2))
+                .andExpect(jsonPath("$.data.events", hasSize(8)))
+                .andExpect(jsonPath("$.data.summary.totalEvents").value(8))
+                .andExpect(jsonPath("$.data.events[?(@.hasWorkOrder == false)].eventNo").value(contains("EW-005", "EW-LEGACY")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].deviceCode").value(contains("D-LEGACY")))
                 .andExpect(jsonPath("$.data.events[?(@.eventNo == 'EW-LEGACY')].deviceCode").value(contains("D-LEGACY")))
-                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(9)));
+                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(8)));
 
 
         // EventItem 不公开 industry;以真实筛选结果证明未知类型未被归入燃气。
         // EventItem 不公开 industry;以真实筛选结果证明未知类型未被归入燃气。
         mockMvc.perform(get(ENDPOINT)
         mockMvc.perform(get(ENDPOINT)
@@ -600,8 +602,9 @@ class CockpitHandlingEfficiencyControllerTest {
     }
     }
 
 
     /**
     /**
-     * 主样本:9 条在范围内预警;`EW-LEGACY` 类型未登记但全域保留,状态为空计 UNKNOWN。
-     * 已知状态覆盖六态 —— DRAFT 1 / PENDING 1 / RECEIVED 1 / PROCESSING 1 / HANDLED 1 / CLOSED 3,
+     * 主样本:9 条预警,其中 `EW-008` 是草稿(DRAFT)—— 服务层必须排除(票 126),故响应按 8 条计;
+     * `EW-LEGACY` 类型未登记但全域保留,状态为空计 UNKNOWN。
+     * 已知状态覆盖六态 —— DRAFT 0(草稿已排除)/ PENDING 1 / RECEIVED 1 / PROCESSING 1 / HANDLED 1 / CLOSED 3,
      * 其中三条 CLOSED 的 `update_time` 分别距发布 0.50h / 2.00h / 1.00h。
      * 其中三条 CLOSED 的 `update_time` 分别距发布 0.50h / 2.00h / 1.00h。
      */
      */
     private static CockpitHandlingEfficiencySnapshot fixture() {
     private static CockpitHandlingEfficiencySnapshot fixture() {

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

@@ -128,6 +128,38 @@ class CockpitHistoryAnalysisControllerTest {
                 .andExpect(jsonPath("$.data.rows[3].handlingEfficiency.value").value("0.0000"));
                 .andExpect(jsonPath("$.data.rows[3].handlingEfficiency.value").value("0.0000"));
     }
     }
 
 
+    /**
+     * 票 126:草稿(DRAFT)预警只是未发布的编辑稿,不属于历史事件 —— 不进逐事件行、不进小时桶、
+     * 不计 pagination.total;状态为空/缺失的行仍保留(词表缺口不得把行藏掉,与总览既有判据一致)。
+     */
+    @Test
+    void draftWarningsAreExcludedFromRowsBucketsAndPaginationTotal() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitHistoryAnalysisSnapshot(
+                "2026-09-02T02:00:00+08:00",
+                Arrays.asList(type("GAS_SENSOR", "GAS")),
+                Arrays.asList(
+                        warningWithStatus("HW-PENDING", 2, "2026-09-02T00:10:00+08:00", "GAS_SENSOR", "D-1", "PENDING"),
+                        warningWithStatus("HW-DRAFT", 2, "2026-09-02T00:20:00+08:00", "GAS_SENSOR", "D-2", "DRAFT"),
+                        warningWithStatus("HW-NOSTATUS", 2, "2026-09-02T00:30:00+08:00", "GAS_SENSOR", "D-3", null)),
+                Collections.emptyList(),
+                Collections.emptyList(),
+                Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT)
+                        .param("eventFamily", "WARNING")
+                        .param("startTime", START)
+                        .param("endTime", END))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.summary.eventCount").value(2))
+                .andExpect(jsonPath("$.data.events", hasSize(2)))
+                .andExpect(jsonPath("$.data.events[*].eventNo").value(contains("HW-NOSTATUS", "HW-PENDING")))
+                .andExpect(jsonPath("$.data.events[?(@.eventNo == 'HW-DRAFT')]", hasSize(0)))
+                .andExpect(jsonPath("$.data.pagination.total").value(2))
+                // 小时桶同口径:00:00 桶只数到保留的两条,草稿不进桶。
+                .andExpect(jsonPath("$.data.rows[?(@.timeBucket == '2026-09-02T00:00:00+08:00')].eventCount")
+                        .value(contains(2)));
+    }
+
     /**
     /**
      * 票 77:片区在历史分析上真的生效 —— 事件行与汇总处置率的工单范围**同一片区口径**。
      * 票 77:片区在历史分析上真的生效 —— 事件行与汇总处置率的工单范围**同一片区口径**。
      *
      *
@@ -568,6 +600,14 @@ class CockpitHistoryAnalysisControllerTest {
                 no, level, eventTime, typeCode, deviceCode, null, null, null, null, district);
                 no, level, eventTime, typeCode, deviceCode, null, null, null, null, district);
     }
     }
 
 
+    /** 票 126:带业务状态的预警样本(DRAFT 用于验证草稿排除)。 */
+    private static CockpitHistoryAnalysisSnapshot.SourceWarning warningWithStatus(
+            String no, Integer level, String eventTime, String typeCode, String deviceCode,
+            String status) {
+        return new CockpitHistoryAnalysisSnapshot.SourceWarning(
+                no, level, eventTime, typeCode, deviceCode, status, null, null, null, null);
+    }
+
     private static CockpitHistoryAnalysisSnapshot.SourceAlarm alarm(
     private static CockpitHistoryAnalysisSnapshot.SourceAlarm alarm(
             String id, Integer level, String eventTime, String typeCode, String deviceCode) {
             String id, Integer level, String eventTime, String typeCode, String deviceCode) {
         return alarm(id, level, eventTime, typeCode, deviceCode, null);
         return alarm(id, level, eventTime, typeCode, deviceCode, null);

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

@@ -92,6 +92,33 @@ class CockpitMultidimensionalAnalysisControllerTest {
                 .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(8)));
                 .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(8)));
     }
     }
 
 
+    /**
+     * 票 126:草稿(DRAFT)不是对外读数 —— 不进任何维度桶、不进 totalCount、不进 mapFilter;
+     * 状态缺失的行仍保留(词表缺口不得把行藏掉)。
+     */
+    @Test
+    void warningFamilyExcludesDraftWarningsFromEveryDimension() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMultidimensionalAnalysisSnapshot(
+                "2026-09-02T15:59:50+08:00",
+                Arrays.asList(type("GAS_SENSOR", "燃气浓度计", "GAS")),
+                Arrays.asList(
+                        warning("MD-PENDING", "GAS_CONCENTRATION", "浓度超限", 2,
+                                "2026-09-02T09:00:00+08:00", 0, "GAS_SENSOR", "D-1", "PENDING"),
+                        warning("MD-DRAFT", "GAS_CONCENTRATION", "浓度超限", 2,
+                                "2026-09-02T09:10:00+08:00", 0, "GAS_SENSOR", "D-2", "DRAFT"),
+                        warning("MD-NOSTATUS", "GAS_CONCENTRATION", "浓度超限", 2,
+                                "2026-09-02T09:20:00+08:00", 0, "GAS_SENSOR", "D-3", null)),
+                Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT)
+                        .param("eventFamily", "WARNING")
+                        .param("startTime", START)
+                        .param("endTime", END))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.totalCount").value(2))
+                .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(2)));
+    }
+
     @Test
     @Test
     void alarmFamilyIsIsolatedFromWarnings() throws Exception {
     void alarmFamilyIsIsolatedFromWarnings() throws Exception {
         mockMvc.perform(get(ENDPOINT)
         mockMvc.perform(get(ENDPOINT)
@@ -499,8 +526,15 @@ class CockpitMultidimensionalAnalysisControllerTest {
     private static CockpitMultidimensionalAnalysisSnapshot.SourceWarning warning(
     private static CockpitMultidimensionalAnalysisSnapshot.SourceWarning warning(
             String no, String eventType, String cause, Integer level, String eventTime,
             String no, String eventType, String cause, Integer level, String eventTime,
             Integer district, String typeCode, String deviceCode) {
             Integer district, String typeCode, String deviceCode) {
+        return warning(no, eventType, cause, level, eventTime, district, typeCode, deviceCode, null);
+    }
+
+    /** 票 126:带业务状态的样本(DRAFT 用于验证草稿排除)。 */
+    private static CockpitMultidimensionalAnalysisSnapshot.SourceWarning warning(
+            String no, String eventType, String cause, Integer level, String eventTime,
+            Integer district, String typeCode, String deviceCode, String status) {
         return new CockpitMultidimensionalAnalysisSnapshot.SourceWarning(
         return new CockpitMultidimensionalAnalysisSnapshot.SourceWarning(
-                no, eventType, cause, level, eventTime, district, typeCode, deviceCode);
+                no, eventType, cause, level, eventTime, district, typeCode, deviceCode, status);
     }
     }
 
 
     private static CockpitMultidimensionalAnalysisSnapshot.SourceAlarm alarm(
     private static CockpitMultidimensionalAnalysisSnapshot.SourceAlarm alarm(

+ 11 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/domain/WarningWorkflow.java

@@ -4,6 +4,7 @@ import com.zksy.common.exception.ServiceException;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
+import java.util.Locale;
 
 
 /** 预警业务状态的唯一主线;已处置仍需核查,只有已解除才是终态。 */
 /** 预警业务状态的唯一主线;已处置仍需核查,只有已解除才是终态。 */
 public final class WarningWorkflow {
 public final class WarningWorkflow {
@@ -20,6 +21,16 @@ public final class WarningWorkflow {
         return EarlyWarningStatusEnum.labelOf(state);
         return EarlyWarningStatusEnum.labelOf(state);
     }
     }
 
 
+    /**
+     * 草稿:保存了但还没发布的编辑稿,不属于任何对外读数(历史/效率/分析的计数一律排除)。
+     *
+     * <p>空或缺失状态**不是**草稿 —— 认不出的状态按「不能证明是草稿」保留,
+     * 与总览计数判据({@code status IS NULL OR UPPER(TRIM(status)) <> 'DRAFT'})同一语义。
+     */
+    public static boolean isDraft(String state) {
+        return state != null && DRAFT.equals(state.trim().toUpperCase(Locale.ROOT));
+    }
+
     public static void requireState(EarlyWarning warning, String operation, String... allowed) {
     public static void requireState(EarlyWarning warning, String operation, String... allowed) {
         if (warning == null) throw new ServiceException("预警不存在");
         if (warning == null) throw new ServiceException("预警不存在");
         if (!Arrays.asList(allowed).contains(warning.getStatus())) {
         if (!Arrays.asList(allowed).contains(warning.getStatus())) {

+ 3 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/BusinessCockpitEventAdapter.java

@@ -589,7 +589,9 @@ public class BusinessCockpitEventAdapter {
                         offsetTime(item.warning.getPublishTime()),
                         offsetTime(item.warning.getPublishTime()),
                         districtCode(item.warning.getDeviceCode(), facts),
                         districtCode(item.warning.getDeviceCode(), facts),
                         typeCode(item.warning.getDeviceCode(), facts),
                         typeCode(item.warning.getDeviceCode(), facts),
-                        trimToNull(item.warning.getDeviceCode())))
+                        trimToNull(item.warning.getDeviceCode()),
+                        // 票 126:状态随快照下传,供服务层排除草稿(与历史/效率同一判据)。
+                        trimToNull(item.warning.getStatus())))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
     }
     }
 
 

+ 3 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/CockpitHandlingEfficiencyService.java

@@ -530,7 +530,10 @@ public class CockpitHandlingEfficiencyService {
             return facts;
             return facts;
         }
         }
         for (CockpitHandlingEfficiencySnapshot.SourceWarning warning : snapshot.getWarnings()) {
         for (CockpitHandlingEfficiencySnapshot.SourceWarning warning : snapshot.getWarnings()) {
+            // 票 126:草稿(DRAFT)未发布,不进逐事件行,也不进六态分布与处置率分母
+            // (同一份 facts 派生全部读数,故只在这一处排除即全口径一致)。
             if (warning == null
             if (warning == null
+                    || WarningWorkflow.isDraft(warning.getStatus())
                     || !inScope(types, warning.getTypeCode(), industry)
                     || !inScope(types, warning.getTypeCode(), industry)
                     || (level != null && !level.equals(warning.getLevel()))
                     || (level != null && !level.equals(warning.getLevel()))
                     || !CockpitDistrict.matches(district, warning.getDistrict())) {
                     || !CockpitDistrict.matches(district, warning.getDistrict())) {

+ 4 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/CockpitHistoryAnalysisService.java

@@ -1,5 +1,6 @@
 package com.zksy.cockpit.event;
 package com.zksy.cockpit.event;
 
 
+import com.zksy.base.warning.domain.WarningWorkflow;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
@@ -234,7 +235,10 @@ public class CockpitHistoryAnalysisService {
             return rows;
             return rows;
         }
         }
         for (CockpitHistoryAnalysisSnapshot.SourceWarning warning : snapshot.getWarnings()) {
         for (CockpitHistoryAnalysisSnapshot.SourceWarning warning : snapshot.getWarnings()) {
+            // 票 126:草稿(DRAFT)只是未发布的编辑稿,不属于历史事件 —— 不进 events[]、
+            // 不进小时桶、不计 pagination.total。状态为空/缺失不算草稿(词表缺口不得把行藏掉)。
             if (warning == null
             if (warning == null
+                    || WarningWorkflow.isDraft(warning.getStatus())
                     || !inScope(types, warning.getTypeCode(), industry)
                     || !inScope(types, warning.getTypeCode(), industry)
                     || (level != null && !level.equals(warning.getLevel()))
                     || (level != null && !level.equals(warning.getLevel()))
                     || !CockpitDistrict.matches(district, warning.getDistrict())) {
                     || !CockpitDistrict.matches(district, warning.getDistrict())) {

+ 3 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/CockpitMultidimensionalAnalysisService.java

@@ -1,5 +1,6 @@
 package com.zksy.cockpit.event;
 package com.zksy.cockpit.event;
 
 
+import com.zksy.base.warning.domain.WarningWorkflow;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
@@ -355,7 +356,8 @@ public class CockpitMultidimensionalAnalysisService {
             return facts;
             return facts;
         }
         }
         for (CockpitMultidimensionalAnalysisSnapshot.SourceWarning warning : snapshot.getWarnings()) {
         for (CockpitMultidimensionalAnalysisSnapshot.SourceWarning warning : snapshot.getWarnings()) {
-            if (warning == null) {
+            // 票 126:草稿不进任何维度计数(与历史/效率同一判据);状态缺失不算草稿。
+            if (warning == null || WarningWorkflow.isDraft(warning.getStatus())) {
                 continue;
                 continue;
             }
             }
             CockpitMultidimensionalAnalysisSnapshot.SourceType type = resolveType(types, warning.getTypeCode());
             CockpitMultidimensionalAnalysisSnapshot.SourceType type = resolveType(types, warning.getTypeCode());

+ 6 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/CockpitMultidimensionalAnalysisSnapshot.java

@@ -69,6 +69,8 @@ public class CockpitMultidimensionalAnalysisSnapshot {
         private final Integer district;
         private final Integer district;
         private final String typeCode;
         private final String typeCode;
         private final String deviceCode;
         private final String deviceCode;
+        /** 预警业务状态(原值);用于排除草稿(票 126),未知/缺失如实保留。 */
+        private final String status;
 
 
         public SourceWarning(
         public SourceWarning(
                 String warningNo,
                 String warningNo,
@@ -78,7 +80,8 @@ public class CockpitMultidimensionalAnalysisSnapshot {
                 String eventTime,
                 String eventTime,
                 Integer district,
                 Integer district,
                 String typeCode,
                 String typeCode,
-                String deviceCode) {
+                String deviceCode,
+                String status) {
             this.warningNo = warningNo;
             this.warningNo = warningNo;
             this.warningType = warningType;
             this.warningType = warningType;
             this.cause = cause;
             this.cause = cause;
@@ -87,6 +90,7 @@ public class CockpitMultidimensionalAnalysisSnapshot {
             this.district = district;
             this.district = district;
             this.typeCode = typeCode;
             this.typeCode = typeCode;
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
+            this.status = status;
         }
         }
 
 
         public String getWarningNo() { return warningNo; }
         public String getWarningNo() { return warningNo; }
@@ -98,6 +102,7 @@ public class CockpitMultidimensionalAnalysisSnapshot {
         public Integer getDistrict() { return district; }
         public Integer getDistrict() { return district; }
         public String getTypeCode() { return typeCode; }
         public String getTypeCode() { return typeCode; }
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
+        public String getStatus() { return status; }
     }
     }
 
 
     public static class SourceAlarm {
     public static class SourceAlarm {