瀏覽代碼

fix(cockpit): 当前预警除草稿与已解除外均计入

- 预警状态词表改为排除制:仅 DRAFT/CLOSED 不算当前预警,HANDLED 等仍需核查的照旧计入
- 预警条目不再因设备/类型解析失败被丢弃;无法归入行业时行业如实为空,仅显式行业筛选才排除
- 处置效率与历史分析在缺发布时间时回退更新时间,避免整条被跳过
Kazerin 3 周之前
父節點
當前提交
42bdb3db00

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

@@ -54,8 +54,13 @@ public class BusinessCockpitEventAdapter {
 
     private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
     private static final DateTimeFormatter TIMESTAMP = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
-    private static final List<String> CURRENT_WARNING_STATUSES = java.util.Arrays.asList(
-            "PENDING", "RECEIVED", "PROCESSING", "HANDLING");
+    /**
+     * 「当前预警」的排除口径(维护者 2026-11-05):预警状态为
+     * DRAFT/PENDING/RECEIVED/PROCESSING/HANDLED/CLOSED,**除草稿与已解除外都算预警状态**
+     * —— 已处置(HANDLED)仍需核查,照旧进入当前列表;认不出/缺失的状态按「不能证明已排除」
+     * 保留,不因词表缺口把进行中的预警藏掉。
+     */
+    private static final Set<String> EXCLUDED_WARNING_STATUSES = new HashSet<>(Arrays.asList("DRAFT", "CLOSED"));
 
     private final EquipmentBaseService equipmentBaseService;
     private final EquipmentTypeService equipmentTypeService;
@@ -820,11 +825,11 @@ public class BusinessCockpitEventAdapter {
     }
 
     private static boolean isCurrentWarning(EarlyWarning warning) {
-        return warning != null && isCurrentStatus(warning.getStatus());
+        return warning != null && !isExcludedWarningStatus(warning.getStatus());
     }
 
-    private static boolean isCurrentStatus(String status) {
-        return status != null && CURRENT_WARNING_STATUSES.contains(status.trim().toUpperCase());
+    private static boolean isExcludedWarningStatus(String status) {
+        return status != null && EXCLUDED_WARNING_STATUSES.contains(status.trim().toUpperCase());
     }
 
     private static boolean isOpenWorkOrder(Integer status) {

+ 7 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/CockpitCurrentEventsService.java

@@ -193,7 +193,12 @@ public class CockpitCurrentEventsService {
                 continue;
             }
             CockpitCurrentEventsSnapshot.SourceType type = resolveType(types, warning.getTypeCode());
-            if (!inScope(type, industry)) {
+            // 维护者 2026-11-05:预警条目不得因设备/类型解析不出而被丢——无法归入行业时
+            // 行业按 null 如实带出(未分区/未知),只有显式行业筛选才排除它。
+            if (type != null && !inScope(type, industry)) {
+                continue;
+            }
+            if (type == null && industry != null) {
                 continue;
             }
             if (level != null && !level.equals(warning.getLevel())) {
@@ -221,7 +226,7 @@ public class CockpitCurrentEventsService {
                     warning.getMonitoringPointCode(),
                     warning.getMonitoringPointName(),
                     warning.getLocation(),
-                    type.getIndustry(),
+                    type == null ? null : type.getIndustry(),
                     warning.getLongitude(),
                     warning.getLatitude(),
                     warning.isCoordinateVerified(),

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

@@ -481,7 +481,11 @@ public class CockpitHandlingEfficiencyService {
                 ? warningFacts(snapshot, types, industry, level, district)
                 : alarmFacts(snapshot, types, industry, level, district);
         for (EventFact fact : facts) {
+            // 发布时刻缺失时退回更新时间(不把已存在的预警从窗口里抹掉)。
             OffsetDateTime eventTime = parseEventTime(fact.eventTime);
+            if (eventTime == null) {
+                eventTime = parseEventTime(fact.updateTime);
+            }
             if (eventTime == null) {
                 continue;
             }
@@ -579,11 +583,15 @@ public class CockpitHandlingEfficiencyService {
             String industry) {
         CockpitHandlingEfficiencySnapshot.SourceType type =
                 isBlank(typeCode) ? null : types.get(typeCode.trim());
-        if (type == null
-                || !SMART_DEVICE.equals(type.getObjectKind())
+        // 维护者 2026-11-05:预警条目不得因类型解析不出而被丢;行业如实为 null,
+        // 只有显式行业筛选才排除。
+        if (type == null) {
+            return industry == null;
+        }
+        if (!SMART_DEVICE.equals(type.getObjectKind())
                 || type.getIndustry() == null
                 || !INDUSTRIES.contains(type.getIndustry())) {
-            return false;
+            return industry == null;
         }
         return industry == null || industry.equals(type.getIndustry());
     }

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

@@ -240,7 +240,11 @@ public class CockpitHistoryAnalysisService {
                     || !CockpitDistrict.matches(district, warning.getDistrict())) {
                 continue;
             }
+            // 发布时刻缺失时退回更新时间(不把已存在的预警从历史里抹掉)。
             OffsetDateTime eventTime = parseEventTime(warning.getEventTime());
+            if (eventTime == null) {
+                eventTime = parseEventTime(warning.getUpdatedTime());
+            }
             if (eventTime == null) {
                 continue;
             }
@@ -313,11 +317,15 @@ public class CockpitHistoryAnalysisService {
             String industry) {
         CockpitHistoryAnalysisSnapshot.SourceType type =
                 isBlank(typeCode) ? null : types.get(typeCode.trim());
-        if (type == null
-                || !SMART_DEVICE.equals(type.getObjectKind())
+        // 维护者 2026-11-05:历史预警/报警条目不得因类型解析不出而被丢;
+        // 行业如实为 null(未知),只有显式行业筛选才排除。
+        if (type == null) {
+            return industry == null;
+        }
+        if (!SMART_DEVICE.equals(type.getObjectKind())
                 || type.getIndustry() == null
                 || !INDUSTRIES.contains(type.getIndustry())) {
-            return false;
+            return industry == null;
         }
         return industry == null || industry.equals(type.getIndustry());
     }