Explorar o código

Merge remote-tracking branch 'origin/master'

zengy hai 17 horas
pai
achega
eb77bb2802

+ 17 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/HazardHiddenAccountServiceImpl.java

@@ -434,6 +434,9 @@ public class HazardHiddenAccountServiceImpl extends ServiceImpl<HazardHiddenAcco
 
     /**
      * 各区域隐患统计(饼图):按片区分组,片区编码经字典 drainage_district 转中文标签
+     *
+     * 固定输出 城南/城北/太常 三个片区维度(无数据补 0),未填写片区或片区编码
+     * 不在字典内的数据归入「未知」兜底,避免隐患数据缺失片区时饼图只剩一块
      */
     @Override
     public List<Map<String, Object>> statisticsDistrictPie(String startDate, String endDate) {
@@ -443,9 +446,22 @@ public class HazardHiddenAccountServiceImpl extends ServiceImpl<HazardHiddenAcco
                         h -> StringUtils.hasText(h.getDistrict()) ? h.getDistrict() : "未知",
                         Collectors.counting()));
         List<Map<String, Object>> result = new ArrayList<>();
+        // 固定三个片区维度:0城南 / 1城北 / 2太常
+        for (String code : new String[]{"0", "1", "2"}) {
+            String label = dictDataService.selectDictLabel("drainage_district", code);
+            Map<String, Object> item = new HashMap<>();
+            item.put("name", StringUtils.hasText(label) ? label : code);
+            item.put("value", grouped.getOrDefault(code, 0L));
+            result.add(item);
+        }
+        // 其余片区编码(脏数据)与未填片区的「未知」兜底追加
         for (Map.Entry<String, Long> entry : grouped.entrySet()) {
+            if ("0".equals(entry.getKey()) || "1".equals(entry.getKey()) || "2".equals(entry.getKey())) {
+                continue;
+            }
+            String label = "未知".equals(entry.getKey()) ? "未知"
+                    : dictDataService.selectDictLabel("drainage_district", entry.getKey());
             Map<String, Object> item = new HashMap<>();
-            String label = dictDataService.selectDictLabel("drainage_district", entry.getKey());
             item.put("name", StringUtils.hasText(label) ? label : entry.getKey());
             item.put("value", entry.getValue());
             result.add(item);

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

@@ -2,6 +2,7 @@ package com.zksy.cockpit.event;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.zksy.base.alarm.domain.AlarmData;
+import com.zksy.base.alarm.enums.AlarmAuditStatusEnum;
 import com.zksy.base.alarm.service.AlarmDataService;
 import com.zksy.base.domain.EquipmentBase;
 import com.zksy.base.domain.EquipmentType;
@@ -269,7 +270,7 @@ public class BusinessCockpitEventAdapter {
         AlarmData alarm = item.alarm;
         PointFact point = facts.pointsByDevice.get(normalize(alarm.getDeviceCode()));
         EquipmentWarningType metadata = warningType(alarm, facts);
-        return new CockpitEventAlarm(
+        CockpitEventAlarm result = new CockpitEventAlarm(
                 trimToNull(alarm.getId()),
                 // 报警业务单号来自同一条已加载的 alarm_data 行,原样透传,缺失为 null。
                 trimToNull(alarm.getAlarmNo()),
@@ -290,6 +291,9 @@ public class BusinessCockpitEventAdapter {
                 trimToNull(alarm.getDeviceCode()),
                 firstNonBlank(alarm.getDeviceName(), deviceName(alarm.getDeviceCode(), facts)),
                 point == null ? null : point.location);
+        result.setAuditStatus(alarm.getAuditStatus());
+        result.setAuditStatusName(auditStatusName(alarm.getAuditStatus()));
+        return result;
     }
 
     private List<CockpitAlarmWarningRelation> eventRelations(
@@ -377,7 +381,7 @@ public class BusinessCockpitEventAdapter {
         PointFact point = facts.pointsByDevice.get(normalize(alarm.getDeviceCode()));
         EquipmentWarningType metadata = warningType(alarm, facts);
         EquipmentBase device = facts.devicesByCode.get(normalize(alarm.getDeviceCode()));
-        return new CockpitCurrentEventsSnapshot.SourceAlarm(
+        CockpitCurrentEventsSnapshot.SourceAlarm source = new CockpitCurrentEventsSnapshot.SourceAlarm(
                 trimToNull(alarm.getId()),
                 trimToNull(alarm.getAlarmNo()),
                 firstNonBlank(warningTypeName(metadata), alarm.getWarningCode()),
@@ -400,6 +404,14 @@ public class BusinessCockpitEventAdapter {
                 alarm.getMinValue(),
                 alarm.getMaxValue(),
                 districtCode(alarm.getDeviceCode(), facts));
+        source.setAuditStatus(alarm.getAuditStatus());
+        source.setAuditStatusName(auditStatusName(alarm.getAuditStatus()));
+        return source;
+    }
+
+    private static String auditStatusName(Integer status) {
+        AlarmAuditStatusEnum value = AlarmAuditStatusEnum.fromCode(status);
+        return value == null ? null : value.getLabel();
     }
 
     private List<CockpitCurrentEventsSnapshot.SourceWorkOrderLink> currentWorkOrders(Facts facts) {
@@ -448,7 +460,8 @@ public class BusinessCockpitEventAdapter {
                     trimToNull(warning.getWarningNo()),
                     level(warning.getWarningLevel()),
                     offsetTime(warning.getPublishTime()),
-                    typeCode(warning.getDeviceCode(), facts),
+                    // 历史行的 EVENT_TYPE 与当前事件同口径:预警类型码(不是设备类型码)。
+                    trimToNull(warning.getWarningType()),
                     trimToNull(warning.getDeviceCode()),
                     trimToNull(warning.getStatus()),
                     firstNonBlank(warning.getDeviceName(), deviceName(warning.getDeviceCode(), facts)),

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

@@ -168,6 +168,9 @@ public class CockpitCurrentEventsResponse {
         private final String levelColor;
         private final String status;
         private final String eventTime;
+        /** 审核结果(0 未审核/1 确认报警/2 误报警/3 自动恢复免核实);与 status 分开。 */
+        private Integer auditStatus;
+        private String auditStatusName;
         private final String updatedTime;
         private final BigDecimal value;
         private final String unit;
@@ -241,6 +244,10 @@ public class CockpitCurrentEventsResponse {
         public Integer getLevel() { return level; }
         public String getLevelColor() { return levelColor; }
         public String getStatus() { return status; }
+        public Integer getAuditStatus() { return auditStatus; }
+        public void setAuditStatus(Integer auditStatus) { this.auditStatus = auditStatus; }
+        public String getAuditStatusName() { return auditStatusName; }
+        public void setAuditStatusName(String auditStatusName) { this.auditStatusName = auditStatusName; }
         public String getEventTime() { return eventTime; }
         public String getUpdatedTime() { return updatedTime; }
         public BigDecimal getValue() { return value; }

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

@@ -216,6 +216,8 @@ public class CockpitCurrentEventsService {
                     warning.getWarningType(),
                     warning.getLevel(),
                     warning.getStatus(),
+                    null,
+                    null,
                     warning.getEventTime(),
                     warning.getUpdatedTime(),
                     warning.getValue(),
@@ -270,6 +272,8 @@ public class CockpitCurrentEventsService {
                     alarm.getWarningType(),
                     alarm.getLevel(),
                     alarm.getStatus(),
+                    alarm.getAuditStatus(),
+                    alarm.getAuditStatusName(),
                     alarm.getEventTime(),
                     alarm.getUpdatedTime(),
                     alarm.getValue(),
@@ -466,6 +470,8 @@ public class CockpitCurrentEventsService {
         private final String eventType;
         private final Integer level;
         private final String status;
+        private final Integer auditStatus;
+        private final String auditStatusName;
         private final String eventTime;
         private final String updatedTime;
         private final BigDecimal value;
@@ -489,6 +495,8 @@ public class CockpitCurrentEventsService {
                 String eventType,
                 Integer level,
                 String status,
+                Integer auditStatus,
+                String auditStatusName,
                 String eventTime,
                 String updatedTime,
                 BigDecimal value,
@@ -510,6 +518,8 @@ public class CockpitCurrentEventsService {
             this.eventType = eventType;
             this.level = level;
             this.status = status;
+            this.auditStatus = auditStatus;
+            this.auditStatusName = auditStatusName;
             this.eventTime = eventTime;
             this.updatedTime = updatedTime;
             this.value = value;
@@ -534,7 +544,7 @@ public class CockpitCurrentEventsService {
         private CockpitCurrentEventsResponse.EventItem toItem(
                 Map<String, CockpitCurrentEventsResponse.WorkOrderSummary> summaries) {
             String key = eventNo == null ? null : eventNo.trim();
-            return new CockpitCurrentEventsResponse.EventItem(
+            CockpitCurrentEventsResponse.EventItem item = new CockpitCurrentEventsResponse.EventItem(
                     eventNo,
                     firstNonBlank(eventCode, eventNo),
                     eventName,
@@ -558,6 +568,9 @@ public class CockpitCurrentEventsService {
                     thresholdMinValue,
                     thresholdMaxValue,
                     key == null ? null : summaries.get(key));
+            item.setAuditStatus(auditStatus);
+            item.setAuditStatusName(auditStatusName);
+            return item;
         }
     }
 }

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

@@ -254,6 +254,9 @@ public class CockpitCurrentEventsSnapshot {
         private final boolean coordinateVerified;
         private final BigDecimal thresholdMinValue;
         private final BigDecimal thresholdMaxValue;
+        /** 审核结果,与 alarm_status(是否已处理)分开;当前列表徽标读它。 */
+        private Integer auditStatus;
+        private String auditStatusName;
         /** 报警片区(原始编码,未归一见 {@code CockpitDistrict});无设备/未识别时为 null=未分区。 */
         private final Integer district;
 
@@ -417,6 +420,22 @@ public class CockpitCurrentEventsSnapshot {
             return thresholdMaxValue;
         }
 
+        public Integer getAuditStatus() {
+            return auditStatus;
+        }
+
+        public void setAuditStatus(Integer auditStatus) {
+            this.auditStatus = auditStatus;
+        }
+
+        public String getAuditStatusName() {
+            return auditStatusName;
+        }
+
+        public void setAuditStatusName(String auditStatusName) {
+            this.auditStatusName = auditStatusName;
+        }
+
         /** 片区原始编码;未经筛时也照实给出(调用方按 {@code CockpitDistrict} 归一)。 */
         public Integer getDistrict() {
             return district;

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

@@ -22,6 +22,9 @@ public class CockpitEventAlarm {
     private final String deviceCode;
     private final String deviceName;
     private final String location;
+    /** 审核结果(0 未审核/1 确认报警/2 误报警/3 自动恢复免核实)。 */
+    private Integer auditStatus;
+    private String auditStatusName;
 
     public CockpitEventAlarm(
             String alarmId,
@@ -107,4 +110,8 @@ public class CockpitEventAlarm {
     public String getDeviceCode() { return deviceCode; }
     public String getDeviceName() { return deviceName; }
     public String getLocation() { return location; }
+    public Integer getAuditStatus() { return auditStatus; }
+    public void setAuditStatus(Integer auditStatus) { this.auditStatus = auditStatus; }
+    public String getAuditStatusName() { return auditStatusName; }
+    public void setAuditStatusName(String auditStatusName) { this.auditStatusName = auditStatusName; }
 }

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

@@ -140,6 +140,9 @@ public class CockpitEventReadService {
                     item.getContent(), item.getStatus(), item.getEventTime(), item.getValue(),
                     item.getThresholdMinValue(), item.getThresholdMaxValue(), item.getUnit(),
                     item.getDeviceCode(), item.getDeviceName(), item.getLocation()));
+            CockpitEventAlarm added = result.get(result.size() - 1);
+            added.setAuditStatus(item.getAuditStatus());
+            added.setAuditStatusName(item.getAuditStatusName());
         }
         return result;
     }