Ver Fonte

fix(cockpit): 运行指标下发设施主键与状态、工单摘要下发 orderId(票65)

Kazerin há 5 dias atrás
pai
commit
eae1cbe664

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

@@ -272,6 +272,7 @@ class CockpitWorkOrderReadControllerTest {
     private CockpitWorkOrderSummary unassociated(String workOrderCode, int state) {
         CockpitWorkOrderState stateEntry = CockpitWorkOrderStateDictionary.byLegacyCode(state);
         return new CockpitWorkOrderSummary(
+                279L,
                 workOrderCode,
                 DEVICE_CODE,
                 2,
@@ -288,6 +289,7 @@ class CockpitWorkOrderReadControllerTest {
 
     private CockpitWorkOrderSummary summary(String workOrderCode, int state, String eventSource, String eventCode) {        CockpitWorkOrderState stateEntry = CockpitWorkOrderStateDictionary.byLegacyCode(state);
         return new CockpitWorkOrderSummary(
+                280L,
                 workOrderCode,
                 DEVICE_CODE,
                 2,

+ 11 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/BusinessCockpitInfrastructureOperatingInformationAdapter.java

@@ -76,7 +76,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     plant.getDesignCapacity(),
                     sampledAt,
                     abnormalStatus(plant.getStatus()),
-                    plant.getPlantCode()));
+                    plant.getPlantCode(), String.valueOf(plant.getId()), "WATER_PLANT", plant.getStatus()));
         }
 
         for (WaterPumpStation station : safeList(pumpStationService.list(
@@ -102,7 +102,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     null,
                     sampledAt,
                     abnormalStatus(station.getStatus()),
-                    station.getStationCode()));
+                    station.getStationCode(), String.valueOf(station.getId()), "PUMP_STATION", station.getStatus()));
         }
 
         for (PipeNetworkBase pipe : safeList(pipeNetworkBaseService.list())) {
@@ -124,7 +124,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     null,
                     sampledAt,
                     abnormalStatus(pipe.getStatus()),
-                    pipe.getNetworkCode()));
+                    pipe.getNetworkCode(), pipe.getNetworkId(), "PIPE_NETWORK", pipe.getStatus()));
         }
 
         for (EngineeringFacility facility : safeList(engineeringFacilityService.list())) {
@@ -148,7 +148,7 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                     null,
                     sampledAt,
                     false,
-                    facility.getFacilityId()));
+                    facility.getFacilityId(), facility.getFacilityId(), "ENGINEERING_FACILITY", facility.getStatus()));
         }
 
         return new CockpitInfrastructureOperatingInformationSnapshot(latestUpdatedAt, metrics);
@@ -164,7 +164,10 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
             BigDecimal capacityValue,
             String sampledAt,
             boolean abnormal,
-            String pointCode) {
+            String pointCode,
+            String facilityId,
+            String facilityKind,
+            String facilityStatus) {
         return new CockpitInfrastructureOperatingInformationSnapshot.SourceMetric(
                 code,
                 name,
@@ -176,6 +179,9 @@ public class BusinessCockpitInfrastructureOperatingInformationAdapter
                 sampledAt,
                 abnormal,
                 pointCode == null ? Collections.emptyList() : Collections.singletonList(pointCode.trim()),
+                facilityId,
+                facilityKind,
+                facilityStatus,
                 Collections.emptyList());
     }
 

+ 18 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/CockpitInfrastructureOperatingInformationResponse.java

@@ -211,6 +211,9 @@ public class CockpitInfrastructureOperatingInformationResponse {
         private final List<TrendPoint> trend;
         private final boolean abnormal;
         private final List<String> pointCodes;
+        private final String facilityId;
+        private final String facilityKind;
+        private final String facilityStatus;
         /**
          * 指标所属设施的片区(票 81):设施没有片区列,按**设施编码前缀**由
          * {@code CockpitDistrictPrefix} 做后端唯一映射;推不出时为 {@code null}=未分区。
@@ -253,6 +256,15 @@ public class CockpitInfrastructureOperatingInformationResponse {
                 List<String> pointCodes,
                 Integer district,
                 String districtName) {
+            this(metricCode, metricName, category, unit, value, capacityValue, loadRatio, loadState, sampledAt, freshness,
+                    trend, abnormal, pointCodes, district, districtName, null, null, null);
+        }
+
+        public OperatingMetric(
+                String metricCode, String metricName, String category, String unit, BigDecimal value,
+                BigDecimal capacityValue, BigDecimal loadRatio, String loadState, String sampledAt,
+                MetricFreshness freshness, List<TrendPoint> trend, boolean abnormal, List<String> pointCodes,
+                Integer district, String districtName, String facilityId, String facilityKind, String facilityStatus) {
             this.metricCode = metricCode;
             this.metricName = metricName;
             this.category = category;
@@ -266,6 +278,9 @@ public class CockpitInfrastructureOperatingInformationResponse {
             this.trend = trend;
             this.abnormal = abnormal;
             this.pointCodes = pointCodes;
+            this.facilityId = facilityId;
+            this.facilityKind = facilityKind;
+            this.facilityStatus = facilityStatus;
             this.district = district;
             this.districtName = districtName;
         }
@@ -286,6 +301,9 @@ public class CockpitInfrastructureOperatingInformationResponse {
         public List<TrendPoint> getTrend() { return trend; }
         public boolean isAbnormal() { return abnormal; }
         public List<String> getPointCodes() { return pointCodes; }
+        public String getFacilityId() { return facilityId; }
+        public String getFacilityKind() { return facilityKind; }
+        public String getFacilityStatus() { return facilityStatus; }
         public Integer getDistrict() { return district; }
         public String getDistrictName() { return districtName; }
     }

+ 4 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/CockpitInfrastructureOperatingInformationService.java

@@ -210,7 +210,10 @@ public class CockpitInfrastructureOperatingInformationService {
                 abnormal,
                 pointCodes(source),
                 districtOf(source),
-                CockpitDistrict.nameOf(districtOf(source)));
+                CockpitDistrict.nameOf(districtOf(source)),
+                source.getFacilityId(),
+                source.getFacilityKind(),
+                source.getFacilityStatus());
     }
 
     private static List<CockpitInfrastructureOperatingInformationResponse.TrendPoint> trend(

+ 18 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/infrastructure/CockpitInfrastructureOperatingInformationSnapshot.java

@@ -26,6 +26,9 @@ public class CockpitInfrastructureOperatingInformationSnapshot {
         private final String sampledAt;
         private final boolean abnormal;
         private final List<String> pointCodes;
+        private final String facilityId;
+        private final String facilityKind;
+        private final String facilityStatus;
         private final List<SourcePoint> trend;
 
         public SourceMetric(
@@ -40,6 +43,15 @@ public class CockpitInfrastructureOperatingInformationSnapshot {
                 boolean abnormal,
                 List<String> pointCodes,
                 List<SourcePoint> trend) {
+            this(metricCode, metricName, category, unit, industry, value, capacityValue, sampledAt, abnormal,
+                    pointCodes, null, null, null, trend);
+        }
+
+        public SourceMetric(
+                String metricCode, String metricName, String category, String unit, String industry,
+                BigDecimal value, BigDecimal capacityValue, String sampledAt, boolean abnormal,
+                List<String> pointCodes, String facilityId, String facilityKind, String facilityStatus,
+                List<SourcePoint> trend) {
             this.metricCode = metricCode;
             this.metricName = metricName;
             this.category = category;
@@ -50,6 +62,9 @@ public class CockpitInfrastructureOperatingInformationSnapshot {
             this.sampledAt = sampledAt;
             this.abnormal = abnormal;
             this.pointCodes = pointCodes;
+            this.facilityId = facilityId;
+            this.facilityKind = facilityKind;
+            this.facilityStatus = facilityStatus;
             this.trend = trend;
         }
 
@@ -63,6 +78,9 @@ public class CockpitInfrastructureOperatingInformationSnapshot {
         public String getSampledAt() { return sampledAt; }
         public boolean isAbnormal() { return abnormal; }
         public List<String> getPointCodes() { return pointCodes; }
+        public String getFacilityId() { return facilityId; }
+        public String getFacilityKind() { return facilityKind; }
+        public String getFacilityStatus() { return facilityStatus; }
         public List<SourcePoint> getTrend() { return trend; }
     }
 

+ 1 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/BusinessCockpitWorkOrderReadAdapter.java

@@ -326,6 +326,7 @@ public class BusinessCockpitWorkOrderReadAdapter implements CockpitWorkOrderRead
             WorkOrder order, String eventSource, String eventCode, boolean associatedWithCurrentEvent) {
         CockpitWorkOrderState state = CockpitWorkOrderStateDictionary.byCode(order.getOrderStatus());
         return new CockpitWorkOrderSummary(
+                order.getOrderId(),
                 order.getOrderNo(),
                 resolveDeviceCode(order.getDeviceId()),
                 order.getOrderLevel(),

+ 13 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/workorder/CockpitWorkOrderSummary.java

@@ -1,6 +1,9 @@
 package com.zksy.cockpit.workorder;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
 public class CockpitWorkOrderSummary {
+    private final Long orderId;
     private final String workOrderCode;
     private final String deviceCode;
     private final Integer orderLevel;
@@ -16,6 +19,7 @@ public class CockpitWorkOrderSummary {
     private final boolean associatedWithCurrentEvent;
 
     public CockpitWorkOrderSummary(
+            Long orderId,
             String workOrderCode,
             String deviceCode,
             Integer orderLevel,
@@ -28,6 +32,7 @@ public class CockpitWorkOrderSummary {
             String realFinishTime,
             CockpitWorkOrderEventAssociation eventAssociation,
             boolean associatedWithCurrentEvent) {
+        this.orderId = orderId;
         this.workOrderCode = workOrderCode;
         this.deviceCode = deviceCode;
         this.orderLevel = orderLevel;
@@ -42,6 +47,14 @@ public class CockpitWorkOrderSummary {
         this.associatedWithCurrentEvent = associatedWithCurrentEvent;
     }
 
+    /**
+     * 数据库主键,仅供服务端内部关联使用,**不进 JSON**。
+     *
+     * <p>驾驶舱 REST 读模型与 WS 增量帧同一口径:不泄漏数据库主键
+     * (见 {@code CockpitWorkOrderDeltaPushTaskTest} 的「增量帧不泄漏数据库主键(REST 读模型同口径)」)。
+     */
+    @JsonIgnore
+    public Long getOrderId() { return orderId; }
     public String getWorkOrderCode() { return workOrderCode; }
     public String getDeviceCode() { return deviceCode; }
     public Integer getOrderLevel() { return orderLevel; }