Просмотр исходного кода

feat(cockpit): expose real createdAt on the three monitoring endpoints (#35)

数据时间契约补齐:/monitoring/{overview,distribution,situation} 此前
data 中完全没有 createdAt 字段(不是显式 null),前端消费侧已交付但 real 下
恒显示占位符,是阶段收口票 18 唯一残留的审计失败项。

按规格 08 / 决策票 03 的字段落点显式返回 createdAt(记录创建时间 = create_time):
- overview:信封级,聚合源真实 create_time 跨类型 max
- distribution:信封级 + 点位 marker(monitor_point.create_time)
  + 未关联设备 marker(equipment_base.create_time)
- situation:信封级取异常设备来源表 create_time 的 max(维护者 2026-10-14 裁定)
  + 异常设备逐对象 createdAt;事件时间仍由趋势桶 bucketStart 承载

口径纪律:新增 CockpitCreatedAt 单一口径来源,只做 create_time -> createdAt
的格式化与跨来源 max,不读时钟,故结构上无法用 updatedAt/serverUpdatedAt/
sampledAt/status_update_time 冒充数据时间。空态显式 null;取值域跟随筛选、
分布/概况取分页前全量(不随翻页跳动);map-snapshot 与 archive 不新增该字段。

验证:Cockpit*Test 507/507 通过(含新增契约测试 18 项)。
真实只读复验待部署后执行——当前运行实例(PID 17972,08:48 启动)早于本次改动。
Kazerin 1 месяц назад
Родитель
Сommit
05c237749e
20 измененных файлов с 691 добавлено и 18 удалено
  1. 24 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringDistributionAdapterTest.java
  2. 48 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringOverviewAdapterTest.java
  3. 33 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/BusinessCockpitMonitoringSituationAdapterTest.java
  4. 62 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitCreatedAtTest.java
  5. 93 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringDistributionControllerTest.java
  6. 82 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringOverviewControllerTest.java
  7. 59 0
      pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitMonitoringSituationControllerTest.java
  8. 77 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitCreatedAt.java
  9. 7 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringDistributionAdapter.java
  10. 6 2
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringOverviewAdapter.java
  11. 4 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringSituationAdapter.java
  12. 21 4
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionResponse.java
  13. 22 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionService.java
  14. 37 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionSnapshot.java
  15. 8 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewResponse.java
  16. 30 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewService.java
  17. 22 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewSnapshot.java
  18. 14 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringSituationResponse.java
  19. 19 3
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringSituationService.java
  20. 23 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringSituationSnapshot.java

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

@@ -181,6 +181,30 @@ class BusinessCockpitMonitoringDistributionAdapterTest {
 
 
     // ---- fixtures ----
     // ---- fixtures ----
 
 
+    /**
+     * 规格 08:点位 `createdAt` 来自 `monitor_point.create_time`、设备来自 `equipment_base.create_time`;
+     * 两者与 `statusTime`(状态更新时间)分离。
+     */
+    @Test
+    void createdAtComesFromCreateTimeColumnsAndStaysSeparateFromStatusTime() {
+        MonitorPoint point = point("P-1", "P-1", "点位", new BigDecimal("110.4"), new BigDecimal("28.4"));
+        point.setCreateTime(java.time.LocalDateTime.parse("2026-01-05T08:00:00"));
+        stubPoints(Collections.singletonList(point));
+        stubTypes(Collections.singletonList(type(22, "22", "可燃气体检测仪", "3")));
+        EquipmentBase device = device("D-1", "D-1", "设备", "22",
+                new BigDecimal("110.4"), new BigDecimal("28.4"), 0);
+        device.setCreateTime(java.time.LocalDateTime.parse("2026-03-11T09:30:00"));
+        stubDevices(Collections.singletonList(device), Collections.emptyList());
+        when(deviceFactResolver.resolve(any(), anyString())).thenReturn(fact("D-1", true, false, false, false));
+
+        CockpitMonitoringDistributionSnapshot snapshot = adapter.load(null);
+
+        assertEquals("2026-01-05T08:00:00+08:00", snapshot.getMonitoringPoints().get(0).getCreatedAt());
+        assertEquals("2026-03-11T09:30:00+08:00", snapshot.getSmartDevices().get(0).getCreatedAt());
+        assertNull(snapshot.getSmartDevices().get(0).getStatusTime(),
+                "statusTime 仍取设备状态更新时间,不被 createdAt 顶替");
+    }
+
     private static CockpitMonitoringPointDeviceSnapshot fact(
     private static CockpitMonitoringPointDeviceSnapshot fact(
             String code, boolean online, boolean alarm, boolean warning, boolean workOrder) {
             String code, boolean online, boolean alarm, boolean warning, boolean workOrder) {
         return new CockpitMonitoringPointDeviceSnapshot(
         return new CockpitMonitoringPointDeviceSnapshot(

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

@@ -162,6 +162,54 @@ class BusinessCockpitMonitoringOverviewAdapterTest {
 
 
     // ---- helpers ----
     // ---- helpers ----
 
 
+    /**
+     * 规格 08:设备 `createdAt` 来自 `equipment_base.create_time`、点位来自 `monitor_point.create_time`,
+     * 且与 `sampledAt`(状态更新时间)分离 —— 两者取自不同列,不得互相冒充。
+     */
+    @Test
+    void createdAtComesFromCreateTimeColumnsAndStaysSeparateFromSampledAt() {
+        MonitorPoint point = point("P-1", "Z-RQXLJC01");
+        point.setCreateTime(LocalDateTime.parse("2026-01-05T08:00:00"));
+        stubPoints(Collections.singletonList(point));
+        stubTypes(Collections.singletonList(type(22, "combustible_gas_detector", "可燃气体检测仪", "3")));
+        EquipmentBase device = device("D-1", "ONLINE-1", "22");
+        device.setCreateTime(LocalDateTime.parse("2026-03-11T09:30:00"));
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(device));
+        when(equipmentBaseService.getEquipmentByPoint("P-1")).thenReturn(Collections.singletonList(device));
+        when(equipmentStatusService.getByDeviceCode("ONLINE-1")).thenReturn(status(1));
+
+        CockpitMonitoringOverviewSnapshot snapshot = adapter.load();
+
+        CockpitMonitoringOverviewSnapshot.SourceDevice source = snapshot.getDevices().get(0);
+        assertEquals("2026-03-11T09:30:00+08:00", source.getCreatedAt());
+        assertEquals("2026-09-02T09:59:50+08:00", source.getSampledAt(),
+                "sampledAt 仍取状态更新时间,语义不变");
+        assertEquals("2026-01-05T08:00:00+08:00", snapshot.getMonitoringPoints().get(0).getCreatedAt());
+
+        CockpitMonitoringOverviewService service = new CockpitMonitoringOverviewService(
+                () -> snapshot, Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+        assertEquals("2026-03-11T09:30:00+08:00", service.load("req", null, null).getCreatedAt());
+    }
+
+    /** 源表无 `create_time` → 快照带 null,服务层出口也是 null(不拿快照时间顶替)。 */
+    @Test
+    void missingCreateTimeStaysNullThroughTheWholeChain() {
+        stubPoints(Collections.singletonList(point("P-1", "P-1")));
+        stubTypes(Collections.singletonList(type(22, "combustible_gas_detector", "可燃气体检测仪", "3")));
+        EquipmentBase device = device("D-1", "NS-1", "22");
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(device));
+        when(equipmentBaseService.getEquipmentByPoint(any())).thenReturn(Collections.emptyList());
+        when(equipmentStatusService.getByDeviceCode("NS-1")).thenReturn(status(1));
+
+        CockpitMonitoringOverviewSnapshot snapshot = adapter.load();
+        assertNull(snapshot.getDevices().get(0).getCreatedAt());
+        assertNull(snapshot.getMonitoringPoints().get(0).getCreatedAt());
+
+        CockpitMonitoringOverviewService service = new CockpitMonitoringOverviewService(
+                () -> snapshot, Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+        assertNull(service.load("req", null, null).getCreatedAt());
+    }
+
     private static String stateOf(CockpitMonitoringOverviewSnapshot snapshot, String deviceCode) {
     private static String stateOf(CockpitMonitoringOverviewSnapshot snapshot, String deviceCode) {
         return snapshot.getDevices().stream()
         return snapshot.getDevices().stream()
                 .filter(d -> deviceCode.equals(d.getDeviceCode()))
                 .filter(d -> deviceCode.equals(d.getDeviceCode()))

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

@@ -11,6 +11,7 @@ import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.service.EarlyWarningService;
 import com.zksy.base.warning.service.EarlyWarningService;
 import com.zksy.cockpit.monitoring.BusinessCockpitMonitoringSituationAdapter;
 import com.zksy.cockpit.monitoring.BusinessCockpitMonitoringSituationAdapter;
+import com.zksy.cockpit.monitoring.CockpitMonitoringSituationService;
 import com.zksy.cockpit.monitoring.CockpitMonitoringSituationSnapshot;
 import com.zksy.cockpit.monitoring.CockpitMonitoringSituationSnapshot;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
 import com.zksy.cockpit.point.CockpitMonitoringPointDeviceSnapshot;
@@ -184,6 +185,38 @@ class BusinessCockpitMonitoringSituationAdapterTest {
 
 
     // ---- helpers ----
     // ---- helpers ----
 
 
+    /**
+     * 规格 08:异常设备 `createdAt` 来自 `equipment_base.create_time`,
+     * 与 `sampledAt`(状态更新时间)取自不同列,不得互相冒充。
+     */
+    @Test
+    void createdAtComesFromCreateTimeAndStaysSeparateFromSampledAt() {
+        stubTypes(Collections.singletonList(type(22, "combustible_gas_detector", "可燃气体检测仪", "3")));
+        EquipmentBase device = device("D-1", "ALARM-1", "22");
+        device.setCreateTime(LocalDateTime.parse("2026-03-11T09:30:00"));
+        when(equipmentBaseService.list()).thenReturn(Collections.singletonList(device));
+        when(equipmentStatusService.getByDeviceCode("ALARM-1")).thenReturn(status(1));
+        // 状态更新时间与 create_time 明确取不同值,才能证明两者没有互相冒充
+        when(deviceFactResolver.resolve(any(), anyString())).thenReturn(
+                new CockpitMonitoringPointDeviceSnapshot(
+                        "ALARM-1", "ALARM-1", "类型名", true, true, false, false,
+                        Collections.emptyList(), "2026-07-07T07:07:00+08:00"));
+        stubEvents(Collections.emptyList(), Collections.emptyList());
+
+        CockpitMonitoringSituationSnapshot snapshot = adapter.load();
+
+        CockpitMonitoringSituationSnapshot.SourceMetricDevice source = snapshot.getDevices().get(0);
+        assertEquals("2026-03-11T09:30:00+08:00", source.getCreatedAt(),
+                "createdAt 取 equipment_base.create_time");
+        assertEquals("2026-07-07T07:07:00+08:00", source.getSampledAt(),
+                "sampledAt 仍取状态更新时间,语义不变");
+
+        CockpitMonitoringSituationService service = new CockpitMonitoringSituationService(
+                () -> snapshot, Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC));
+        assertEquals("2026-03-11T09:30:00+08:00",
+                service.load("req", null, null, null, null, null, null).getCreatedAt());
+    }
+
     private void stubTypes(List<EquipmentType> types) {
     private void stubTypes(List<EquipmentType> types) {
         when(equipmentTypeService.list()).thenReturn(types);
         when(equipmentTypeService.list()).thenReturn(types);
     }
     }

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

@@ -0,0 +1,62 @@
+package com.zksy.web.controller.cockpit;
+
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
+import org.junit.jupiter.api.Test;
+
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * 数据时间单一口径来源的契约测试(规格 08 / 决策票 03)。
+ *
+ * <p>本类不注入时钟 —— 结构上就**没有**「拿响应时间冒充数据时间」的入口。
+ */
+class CockpitCreatedAtTest {
+
+    @Test
+    void formatsLocalCreateTimeInBusinessZone() {
+        assertEquals("2026-03-11T09:30:00+08:00",
+                CockpitCreatedAt.format(LocalDateTime.parse("2026-03-11T09:30:00")));
+    }
+
+    @Test
+    void missingSourceCreateTimeIsNullNotAFabricatedTime() {
+        assertNull(CockpitCreatedAt.format(null));
+        assertNull(CockpitCreatedAt.max(Collections.emptyList()));
+        assertNull(CockpitCreatedAt.max(Arrays.asList(null, null)));
+        assertNull(CockpitCreatedAt.max((String) null, null));
+    }
+
+    @Test
+    void maxPicksTheLatestRealCreateTimeAcrossHeterogeneousSources() {
+        assertEquals("2026-05-06T11:22:00+08:00", CockpitCreatedAt.max(Arrays.asList(
+                "2026-01-05T08:00:00+08:00",
+                null,
+                "2026-05-06T11:22:00+08:00",
+                "2026-03-11T09:30:00+08:00")));
+    }
+
+    /** 只有一边可用时取那一边:不因为另一来源缺失就把已拿到的真实时间丢掉。 */
+    @Test
+    void maxKeepsTheOnlyAvailableSide() {
+        assertEquals("2026-01-05T08:00:00+08:00",
+                CockpitCreatedAt.max("2026-01-05T08:00:00+08:00", null));
+        assertEquals("2026-01-05T08:00:00+08:00",
+                CockpitCreatedAt.max(null, "2026-01-05T08:00:00+08:00"));
+    }
+
+    /** 时区不同但时刻相同时,按真实先后比较而不是按字符串比较。 */
+    @Test
+    void maxComparesInstantsNotStrings() {
+        // 同一时刻的两种写法:UTC 01:00 == +08:00 09:00
+        assertEquals("2026-01-05T01:00:00Z",
+                CockpitCreatedAt.max("2026-01-05T01:00:00Z", "2026-01-05T09:00:00+08:00"));
+        // 字符串序会把 "2026-01-05T09:00:00+08:00" 判大,真实时刻是 UTC 02:00 更晚
+        assertEquals("2026-01-05T02:00:00Z",
+                CockpitCreatedAt.max("2026-01-05T02:00:00Z", "2026-01-05T09:00:00+08:00"));
+    }
+}

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

@@ -587,6 +587,99 @@ class CockpitMonitoringDistributionControllerTest {
                 Arrays.asList(devices));
                 Arrays.asList(devices));
     }
     }
 
 
+    private static CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint pointAt(
+            String code, String name, Integer district, String typeCode,
+            String longitude, String latitude, String createdAt,
+            CockpitMonitoringPointDeviceSnapshot... devices) {
+        return new CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint(
+                code, name, district, typeCode,
+                new BigDecimal(longitude), new BigDecimal(latitude), true,
+                Arrays.asList(devices), createdAt);
+    }
+
+    // ---- 数据时间(createdAt)契约 ----
+
+    /**
+     * 规格 08:`distribution` 的信封级 `createdAt` 取台账逐对象真实 `create_time` 的 max,
+     * 点位用 `monitor_point.create_time`、设备用 `equipment_base.create_time`;
+     * 必须与 `updatedAt`(快照加载时刻)取值不同,证明没拿响应时间冒充。
+     */
+    @Test
+    void distributionCreatedAtIsTheMaxLedgerCreateTimeAndNeverTheSnapshotTime() throws Exception {
+        CockpitMonitoringDistributionSnapshot snapshot = new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT,
+                "2026-09-02T09:59:50+08:00",
+                fixture().getTypes(),
+                Collections.singletonList(pointAt("P-1", "点位", 0, "GAS_SENSOR",
+                        "110.130", "28.440", "2026-02-20T10:00:00+08:00")),
+                Collections.singletonList(new CockpitMonitoringDistributionSnapshot.SourceSmartDevice(
+                        "D-1", "设备", 0, "GAS_SENSOR", new BigDecimal("110.131"), new BigDecimal("28.441"),
+                        true, true, false, false, false, Collections.emptyList(), null, true,
+                        "2026-04-01T07:15:00+08:00")));
+        when(adapter.load(null)).thenReturn(snapshot);
+
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-04-01T07:15:00+08:00"))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"))
+                // 逐对象字段齐备(台账卡读它)
+                .andExpect(jsonPath("$.data.monitoringPoints[0].createdAt").value("2026-02-20T10:00:00+08:00"))
+                .andExpect(jsonPath("$.data.unassociatedEquipment[0].createdAt").value("2026-04-01T07:15:00+08:00"));
+    }
+
+    /** 空态:无台账对象 → 信封 `createdAt` 显式 null,不用快照时间顶上。 */
+    @Test
+    void distributionCreatedAtIsNullForEmptyLedger() throws Exception {
+        when(adapter.load(null)).thenReturn(new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, "2026-09-02T09:59:50+08:00", Collections.emptyList(),
+                Collections.emptyList(), Collections.emptyList()));
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"));
+    }
+
+    /** 有台账对象但来源表无 `create_time` → 信封与逐对象都显式 null。 */
+    @Test
+    void distributionCreatedAtIsNullWhenLedgerHasNoCreateTime() throws Exception {
+        when(adapter.load(null)).thenReturn(new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, "2026-09-02T09:59:50+08:00", fixture().getTypes(),
+                Collections.singletonList(point("P-1", "点位", 0, "GAS_SENSOR", "110.130", "28.440")),
+                Collections.emptyList()));
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.monitoringPoints", hasSize(1)))
+                .andExpect(jsonPath("$.data.monitoringPoints[0].createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"));
+    }
+
+    /**
+     * 取值域是分页前的全量台账(与三份分布同口径),故翻页不改变数据时间读数 ——
+     * 否则「数据时间」会随翻页跳动,读者无法据它判断这批数据写到什么时候。
+     */
+    @Test
+    void distributionCreatedAtDoesNotMoveAcrossPages() throws Exception {
+        java.util.List<CockpitMonitoringDistributionSnapshot.SourceMonitoringPoint> points =
+                new java.util.ArrayList<>();
+        for (int index = 0; index < 4; index++) {
+            points.add(pointAt("P-" + index, "点位" + index, 0, "GAS_SENSOR",
+                    "110.13" + index, "28.44" + index,
+                    "2026-0" + (index + 1) + "-01T08:00:00+08:00"));
+        }
+        when(adapter.load(null)).thenReturn(new CockpitMonitoringDistributionSnapshot(
+                SNAPSHOT_AT, SNAPSHOT_AT, fixture().getTypes(), points, Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT).param("page", "1").param("pageSize", "2"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.pagination.total").value(4))
+                .andExpect(jsonPath("$.data.createdAt").value("2026-04-01T08:00:00+08:00"));
+        mockMvc.perform(get(ENDPOINT).param("page", "2").param("pageSize", "2")
+                        .param("snapshotAt", SNAPSHOT_AT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-04-01T08:00:00+08:00"));
+    }
+
     private static CockpitMonitoringPointDeviceSnapshot device(
     private static CockpitMonitoringPointDeviceSnapshot device(
             String code, String name, boolean online, boolean alarm, boolean warning,
             String code, String name, boolean online, boolean alarm, boolean warning,
             boolean workOrderInProgress, List<String> statusReasons) {
             boolean workOrderInProgress, List<String> statusReasons) {

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

@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.nullValue;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -330,7 +331,88 @@ class CockpitMonitoringOverviewControllerTest {
                 code, typeCode, state, "2026-09-02T09:59:00+08:00", pointCode);
                 code, typeCode, state, "2026-09-02T09:59:00+08:00", pointCode);
     }
     }
 
 
+    private static CockpitMonitoringOverviewSnapshot.SourceDevice deviceAt(
+            String code, String typeCode, String state, String pointCode, String createdAt) {
+        return new CockpitMonitoringOverviewSnapshot.SourceDevice(
+                code, typeCode, state, "2026-09-02T09:59:00+08:00", pointCode, createdAt);
+    }
+
     private static CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint point(String code, String typeCode) {
     private static CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint point(String code, String typeCode) {
         return new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(code, typeCode);
         return new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(code, typeCode);
     }
     }
+
+    // ---- 数据时间(createdAt)契约 ----
+
+    /**
+     * 规格 08:`overview` 的分区级 `createdAt` 取聚合源真实 `create_time` 的跨类型 max;
+     * 且必须与 `updatedAt`(快照加载时刻)取值不同,证明确实没拿响应时间冒充。
+     */
+    @Test
+    void overviewCreatedAtIsTheMaxCreateTimeAcrossSourcesAndNeverTheSnapshotTime() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMonitoringOverviewSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Collections.singletonList(type("GAS_SENSOR", "燃气浓度计", "GAS")),
+                Arrays.asList(
+                        deviceAt("GAS-001", "GAS_SENSOR", "ONLINE", "P-GAS-1", "2026-01-05T08:00:00+08:00"),
+                        deviceAt("GAS-002", "GAS_SENSOR", "OFFLINE", "P-GAS-2", "2026-03-11T09:30:00+08:00")),
+                Arrays.asList(
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
+                                "P-GAS-1", "GAS_SENSOR", 1, "2026-02-20T10:00:00+08:00"),
+                        new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
+                                "P-GAS-2", "GAS_SENSOR", 1, null))));
+
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-03-11T09:30:00+08:00"))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"));
+    }
+
+    /** 空态:没有对象时 `createdAt` 必须显式 null,不得回退到响应时间。 */
+    @Test
+    void overviewCreatedAtIsNullForEmptySnapshot() throws Exception {
+        when(adapter.load()).thenReturn(emptyFixture());
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"));
+    }
+
+    /** 有对象但来源表无 `create_time` → 同样显式 null(不拿快照时间顶替)。 */
+    @Test
+    void overviewCreatedAtIsNullWhenSourcesHaveNoCreateTime() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMonitoringOverviewSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Collections.singletonList(type("GAS_SENSOR", "燃气浓度计", "GAS")),
+                Collections.singletonList(device("GAS-001", "GAS_SENSOR", "ONLINE", "P-GAS-1")),
+                Collections.emptyList()));
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.counts.equipmentCount").value(1))
+                .andExpect(jsonPath("$.data.createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"));
+    }
+
+    /**
+     * 取值域跟随筛选:被筛掉的设备/点位不得把时间带进读数,
+     * 否则「数据时间」会指向本响应根本不包含的对象。
+     */
+    @Test
+    void overviewCreatedAtFollowsTheActiveFilter() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMonitoringOverviewSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Arrays.asList(
+                        type("GAS_SENSOR", "燃气浓度计", "GAS"),
+                        type("WATER_SUPPLY_SENSOR", "供水压力计", "WATER_SUPPLY")),
+                Arrays.asList(
+                        deviceAt("GAS-001", "GAS_SENSOR", "ONLINE", "P-GAS-1", "2026-01-05T08:00:00+08:00"),
+                        deviceAt("WS-001", "WATER_SUPPLY_SENSOR", "ONLINE", "P-WS-1", "2026-05-05T08:00:00+08:00")),
+                Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-05-05T08:00:00+08:00"));
+        mockMvc.perform(get(ENDPOINT).queryParam("industry", "GAS"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-01-05T08:00:00+08:00"));
+    }
 }
 }

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

@@ -460,10 +460,69 @@ class CockpitMonitoringSituationControllerTest {
                 new BigDecimal(longitude), new BigDecimal(latitude), verified);
                 new BigDecimal(longitude), new BigDecimal(latitude), verified);
     }
     }
 
 
+    private static CockpitMonitoringSituationSnapshot.SourceMetricDevice deviceAt(
+            String code, String name, Integer district, String typeCode, String metricStatus,
+            List<String> reasons, String longitude, String latitude, boolean verified,
+            String createdAt) {
+        return new CockpitMonitoringSituationSnapshot.SourceMetricDevice(
+                code, name, district, typeCode, metricStatus, reasons,
+                "2026-09-02T09:59:00+08:00",
+                new BigDecimal(longitude), new BigDecimal(latitude), verified, createdAt);
+    }
+
     private static CockpitMonitoringSituationSnapshot.SourceEvent event(
     private static CockpitMonitoringSituationSnapshot.SourceEvent event(
             String eventNo, String level, String eventTime, String industry,
             String eventNo, String level, String eventTime, String industry,
             String typeCode, String deviceCode, String deviceName) {
             String typeCode, String deviceCode, String deviceName) {
         return new CockpitMonitoringSituationSnapshot.SourceEvent(
         return new CockpitMonitoringSituationSnapshot.SourceEvent(
                 eventNo, level, eventTime, industry, typeCode, deviceCode, deviceName);
                 eventNo, level, eventTime, industry, typeCode, deviceCode, deviceName);
     }
     }
+
+    // ---- 数据时间(createdAt)契约 ----
+
+    /**
+     * 维护者 2026-10-14 裁定(票 35 Q3):信封级 `createdAt` 取**异常设备来源表** `create_time` 的 max,
+     * 与逐对象字段同源可复算;事件时间仍由 `warningTrend`/`alarmTrend` 的 `bucketStart` 承载,不并入读数。
+     */
+    @Test
+    void situationCreatedAtIsTheMaxAbnormalDeviceCreateTimeNotTheEventWindow() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMonitoringSituationSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Collections.singletonList(type("GAS_SENSOR", "燃气浓度计", "GAS")),
+                Arrays.asList(
+                        // 异常(ALARM)→ 进异常清单,携带 create_time
+                        deviceAt("D-ABNORMAL", "异常设备", 0, "GAS_SENSOR", "ALARM",
+                                Collections.singletonList("浓度超限"), "110.360", "28.440", true,
+                                "2026-05-06T11:22:00+08:00"),
+                        // 正常设备不进异常清单,其 create_time 更晚也不得影响读数
+                        deviceAt("D-NORMAL", "正常设备", 0, "GAS_SENSOR", "NORMAL",
+                                Collections.emptyList(), "110.361", "28.441", true,
+                                "2026-08-08T08:08:00+08:00")),
+                Collections.emptyList(),
+                Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value("2026-05-06T11:22:00+08:00"))
+                // 事件窗口时间不得冒充数据时间
+                .andExpect(jsonPath("$.data.range.startTime").value("2026-09-01T10:00:00+08:00"))
+                .andExpect(jsonPath("$.data.updatedAt").value("2026-09-02T09:59:50+08:00"))
+                .andExpect(jsonPath("$.data.abnormalEquipment[0].createdAt").value("2026-05-06T11:22:00+08:00"));
+    }
+
+    /** 无异常设备 → 信封 `createdAt` 显式 null,不用窗口时间或响应时间顶上。 */
+    @Test
+    void situationCreatedAtIsExplicitlyNullWhenNoAbnormalDeviceExists() throws Exception {
+        when(adapter.load()).thenReturn(new CockpitMonitoringSituationSnapshot(
+                "2026-09-02T09:59:50+08:00",
+                Collections.singletonList(type("GAS_SENSOR", "燃气浓度计", "GAS")),
+                Collections.singletonList(deviceAt("D-NORMAL", "正常设备", 0, "GAS_SENSOR", "NORMAL",
+                        Collections.emptyList(), "110.360", "28.440", true, "2026-08-08T08:08:00+08:00")),
+                Collections.emptyList(),
+                Collections.emptyList()));
+
+        mockMvc.perform(get(ENDPOINT))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.data.createdAt").value(nullValue()))
+                .andExpect(jsonPath("$.data.abnormalEquipment", hasSize(0)));
+    }
 }
 }

+ 77 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/foundation/CockpitCreatedAt.java

@@ -0,0 +1,77 @@
+package com.zksy.cockpit.foundation;
+
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.Collection;
+
+/**
+ * 数据时间({@code createdAt})的单一口径来源:库列 {@code create_time} → API {@code createdAt}。
+ *
+ * <p>语义由决策票 03 与规格 08 固化:{@code createdAt}=<b>记录创建时间</b>,
+ * 既不是采样/上报时刻({@code sampledAt}),也不是状态更新时刻
+ * ({@code status_update_time})或响应生成时刻({@code serverUpdatedAt})。
+ *
+ * <p>空值一律显式 {@code null}:本类不读时钟,因此**结构上无法**用响应时间冒充数据时间。
+ */
+public final class CockpitCreatedAt {
+
+    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
+
+    private CockpitCreatedAt() {
+    }
+
+    /** 来源表 {@code create_time} → 响应 {@code createdAt};缺值为 {@code null}。 */
+    public static String format(LocalDateTime value) {
+        return value == null
+                ? null
+                : FORMATTER.format(value.atZone(BUSINESS_ZONE).toOffsetDateTime());
+    }
+
+    /**
+     * 跨来源取 max:异构来源(多张表、多种设备类型)统一成一个读数。
+     * 两边都缺为 {@code null};只有一边可解析时取那一边,不丢已拿到的真实时间。
+     */
+    public static String max(String left, String right) {
+        if (left == null) {
+            return right;
+        }
+        if (right == null) {
+            return left;
+        }
+        OffsetDateTime leftTime = parse(left);
+        OffsetDateTime rightTime = parse(right);
+        if (leftTime == null && rightTime == null) {
+            return left;
+        }
+        if (leftTime == null) {
+            return right;
+        }
+        if (rightTime == null) {
+            return left;
+        }
+        return rightTime.isAfter(leftTime) ? right : left;
+    }
+
+    /** 集合上的 {@link #max(String, String)};空集合为 {@code null}。 */
+    public static String max(Collection<String> values) {
+        String result = null;
+        if (values != null) {
+            for (String value : values) {
+                result = max(result, value);
+            }
+        }
+        return result;
+    }
+
+    private static OffsetDateTime parse(String value) {
+        try {
+            return OffsetDateTime.parse(value);
+        } catch (DateTimeParseException exception) {
+            return null;
+        }
+    }
+}

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

@@ -6,6 +6,7 @@ import com.zksy.base.domain.MonitorPoint;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.MonitorPointService;
 import com.zksy.base.service.MonitorPointService;
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
@@ -113,7 +114,9 @@ public class BusinessCockpitMonitoringDistributionAdapter implements CockpitMoni
                     point.getLongitude(),
                     point.getLongitude(),
                     point.getLatitude(),
                     point.getLatitude(),
                     false,
                     false,
-                    devices));
+                    devices,
+                    // 数据时间=点位自身记录创建时间(monitor_point.create_time)
+                    CockpitCreatedAt.format(point.getCreateTime())));
         }
         }
 
 
         List<CockpitMonitoringDistributionSnapshot.SourceSmartDevice> smartDevices = new ArrayList<>();
         List<CockpitMonitoringDistributionSnapshot.SourceSmartDevice> smartDevices = new ArrayList<>();
@@ -139,7 +142,9 @@ public class BusinessCockpitMonitoringDistributionAdapter implements CockpitMoni
                     fact.isWorkOrderInProgress(),
                     fact.isWorkOrderInProgress(),
                     fact.getStatusReasons(),
                     fact.getStatusReasons(),
                     fact.getStatusTime(),
                     fact.getStatusTime(),
-                    fact.isStatusPublished()));
+                    fact.isStatusPublished(),
+                    // 数据时间=设备自身记录创建时间(equipment_base.create_time)
+                    CockpitCreatedAt.format(device.getCreateTime())));
         }
         }
 
 
         List<CockpitMonitoringDistributionSnapshot.SourceType> sourceTypes = types.values().stream()
         List<CockpitMonitoringDistributionSnapshot.SourceType> sourceTypes = types.values().stream()

+ 6 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/BusinessCockpitMonitoringOverviewAdapter.java

@@ -8,6 +8,7 @@ import com.zksy.base.service.EquipmentBaseService;
 import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.MonitorPointService;
 import com.zksy.base.service.MonitorPointService;
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -100,7 +101,8 @@ public class BusinessCockpitMonitoringOverviewAdapter implements CockpitMonitori
             sourcePoints.add(new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
             sourcePoints.add(new CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint(
                     pointCode,
                     pointCode,
                     deviceTypes.size() == 1 ? deviceTypes.iterator().next() : null,
                     deviceTypes.size() == 1 ? deviceTypes.iterator().next() : null,
-                    boundDeviceCodes.size()));
+                    boundDeviceCodes.size(),
+                    CockpitCreatedAt.format(point.getCreateTime())));
         }
         }
 
 
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> devices = new ArrayList<>();
         List<CockpitMonitoringOverviewSnapshot.SourceDevice> devices = new ArrayList<>();
@@ -127,7 +129,9 @@ public class BusinessCockpitMonitoringOverviewAdapter implements CockpitMonitori
                             ? null
                             ? null
                             : TIME_FORMATTER.format(status.getStatusUpdateTime()
                             : TIME_FORMATTER.format(status.getStatusUpdateTime()
                                     .atZone(BUSINESS_ZONE).toOffsetDateTime()),
                                     .atZone(BUSINESS_ZONE).toOffsetDateTime()),
-                    pointCodeByDevice.get(deviceCode)));
+                    pointCodeByDevice.get(deviceCode),
+                    // 数据时间=记录创建时间(equipment_base.create_time),与 sampledAt 分离
+                    CockpitCreatedAt.format(device.getCreateTime())));
         }
         }
 
 
         List<CockpitMonitoringOverviewSnapshot.SourceType> sourceTypes = types.values().stream()
         List<CockpitMonitoringOverviewSnapshot.SourceType> sourceTypes = types.values().stream()

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

@@ -10,6 +10,7 @@ import com.zksy.base.service.EquipmentStatusService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.service.EquipmentTypeService;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.domain.EarlyWarning;
 import com.zksy.base.warning.service.EarlyWarningService;
 import com.zksy.base.warning.service.EarlyWarningService;
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitDistrict;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.foundation.CockpitTypeIndustry;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
 import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
@@ -117,7 +118,9 @@ public class BusinessCockpitMonitoringSituationAdapter implements CockpitMonitor
                     fact.getStatusTime(),
                     fact.getStatusTime(),
                     device.getLongitude(),
                     device.getLongitude(),
                     device.getLatitude(),
                     device.getLatitude(),
-                    false));
+                    false,
+                    // 数据时间=记录创建时间(equipment_base.create_time),与 sampledAt 分离
+                    CockpitCreatedAt.format(device.getCreateTime())));
         }
         }
 
 
         List<CockpitMonitoringSituationSnapshot.SourceEvent> warnings = new ArrayList<>();
         List<CockpitMonitoringSituationSnapshot.SourceEvent> warnings = new ArrayList<>();

+ 21 - 4
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionResponse.java

@@ -16,6 +16,11 @@ public class CockpitMonitoringDistributionResponse {
     private final String timezone;
     private final String timezone;
     private final Range range;
     private final Range range;
     private final String updatedAt;
     private final String updatedAt;
+    /**
+     * 数据时间=记录创建时间({@code create_time})跨台账对象取 max;
+     * 空态显式 {@code null}。与 {@code updatedAt}(快照加载时刻)语义不同,不互相冒充。
+     */
+    private final String createdAt;
     private final Freshness freshness;
     private final Freshness freshness;
     private final List<DistrictDistribution> districtDistribution;
     private final List<DistrictDistribution> districtDistribution;
     private final List<IndustryDistribution> industryDistribution;
     private final List<IndustryDistribution> industryDistribution;
@@ -35,6 +40,7 @@ public class CockpitMonitoringDistributionResponse {
             String timezone,
             String timezone,
             Range range,
             Range range,
             String updatedAt,
             String updatedAt,
+            String createdAt,
             Freshness freshness,
             Freshness freshness,
             List<DistrictDistribution> districtDistribution,
             List<DistrictDistribution> districtDistribution,
             List<IndustryDistribution> industryDistribution,
             List<IndustryDistribution> industryDistribution,
@@ -52,6 +58,7 @@ public class CockpitMonitoringDistributionResponse {
         this.timezone = timezone;
         this.timezone = timezone;
         this.range = range;
         this.range = range;
         this.updatedAt = updatedAt;
         this.updatedAt = updatedAt;
+        this.createdAt = createdAt;
         this.freshness = freshness;
         this.freshness = freshness;
         this.districtDistribution = districtDistribution;
         this.districtDistribution = districtDistribution;
         this.industryDistribution = industryDistribution;
         this.industryDistribution = industryDistribution;
@@ -71,6 +78,7 @@ public class CockpitMonitoringDistributionResponse {
     public String getTimezone() { return timezone; }
     public String getTimezone() { return timezone; }
     public Range getRange() { return range; }
     public Range getRange() { return range; }
     public String getUpdatedAt() { return updatedAt; }
     public String getUpdatedAt() { return updatedAt; }
+    public String getCreatedAt() { return createdAt; }
     public Freshness getFreshness() { return freshness; }
     public Freshness getFreshness() { return freshness; }
     public List<DistrictDistribution> getDistrictDistribution() { return districtDistribution; }
     public List<DistrictDistribution> getDistrictDistribution() { return districtDistribution; }
     public List<IndustryDistribution> getIndustryDistribution() { return industryDistribution; }
     public List<IndustryDistribution> getIndustryDistribution() { return industryDistribution; }
@@ -296,10 +304,13 @@ public class CockpitMonitoringDistributionResponse {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final CockpitCoordinateValidation coordinateValidation;
         private final CockpitCoordinateValidation coordinateValidation;
+        /** 记录创建时间(点位={@code monitor_point.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public MonitoringPointMarker(String pointCode, String pointName, Integer district, String industry,
         public MonitoringPointMarker(String pointCode, String pointName, Integer district, String industry,
                 DeviceType deviceType, CockpitMonitoringPointStatus pointStatus, List<String> statusReasons,
                 DeviceType deviceType, CockpitMonitoringPointStatus pointStatus, List<String> statusReasons,
-                BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation) {
+                BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
+                String createdAt) {
             this.pointCode = pointCode;
             this.pointCode = pointCode;
             this.pointName = pointName;
             this.pointName = pointName;
             this.district = CockpitDistrict.codeOf(district);
             this.district = CockpitDistrict.codeOf(district);
@@ -311,6 +322,7 @@ public class CockpitMonitoringDistributionResponse {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateValidation = coordinateValidation;
             this.coordinateValidation = coordinateValidation;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getPointCode() { return pointCode; }
         public String getPointCode() { return pointCode; }
@@ -324,6 +336,7 @@ public class CockpitMonitoringDistributionResponse {
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLatitude() { return latitude; }
         public BigDecimal getLatitude() { return latitude; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
+        public String getCreatedAt() { return createdAt; }
     }
     }
 
 
     public static class UnassociatedEquipmentMarker {
     public static class UnassociatedEquipmentMarker {
@@ -338,10 +351,13 @@ public class CockpitMonitoringDistributionResponse {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final CockpitCoordinateValidation coordinateValidation;
         private final CockpitCoordinateValidation coordinateValidation;
+        /** 记录创建时间({@code equipment_base.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public UnassociatedEquipmentMarker(String deviceCode, String deviceName, Integer district, String industry,
         public UnassociatedEquipmentMarker(String deviceCode, String deviceName, Integer district, String industry,
                 DeviceType deviceType, CockpitMonitoringPointStatus pointStatus, List<String> statusReasons,
                 DeviceType deviceType, CockpitMonitoringPointStatus pointStatus, List<String> statusReasons,
-                BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation) {
+                BigDecimal longitude, BigDecimal latitude, CockpitCoordinateValidation coordinateValidation,
+                String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.district = CockpitDistrict.codeOf(district);
             this.district = CockpitDistrict.codeOf(district);
@@ -353,13 +369,13 @@ public class CockpitMonitoringDistributionResponse {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateValidation = coordinateValidation;
             this.coordinateValidation = coordinateValidation;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceStatus() {
         public String getDeviceStatus() {
             return CockpitPointStatusQuery.deviceBucket(pointStatus == null ? null : pointStatus.name());
             return CockpitPointStatusQuery.deviceBucket(pointStatus == null ? null : pointStatus.name());
-        }
-        public String getDeviceName() { return deviceName; }
+        }        public String getDeviceName() { return deviceName; }
         public Integer getDistrict() { return district; }
         public Integer getDistrict() { return district; }
         public String getDistrictName() { return districtName; }
         public String getDistrictName() { return districtName; }
         public String getIndustry() { return industry; }
         public String getIndustry() { return industry; }
@@ -369,6 +385,7 @@ public class CockpitMonitoringDistributionResponse {
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLatitude() { return latitude; }
         public BigDecimal getLatitude() { return latitude; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
+        public String getCreatedAt() { return createdAt; }
     }
     }
 
 
     public static class Excluded {
     public static class Excluded {

+ 22 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionService.java

@@ -2,6 +2,7 @@ package com.zksy.cockpit.monitoring;
 
 
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 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;
@@ -295,7 +296,8 @@ public class CockpitMonitoringDistributionService {
                         point.getLatitude(),
                         point.getLatitude(),
                         validation,
                         validation,
                         true,
                         true,
-                        codes(effective)));
+                        codes(effective),
+                        point.getCreatedAt()));
             }
             }
         }
         }
 
 
@@ -355,7 +357,8 @@ public class CockpitMonitoringDistributionService {
                         device.getLatitude(),
                         device.getLatitude(),
                         validation,
                         validation,
                         false,
                         false,
-                        Collections.emptyList()));
+                        Collections.emptyList(),
+                        device.getCreatedAt()));
             }
             }
         }
         }
 
 
@@ -407,6 +410,16 @@ public class CockpitMonitoringDistributionService {
 
 
         boolean hasResolved = total > 0;
         boolean hasResolved = total > 0;
         String updatedAt = isBlank(snapshot.getUpdatedAt()) ? businessTime() : snapshot.getUpdatedAt();
         String updatedAt = isBlank(snapshot.getUpdatedAt()) ? businessTime() : snapshot.getUpdatedAt();
+        // 数据时间=筛选后台账对象(点位 + 未关联设备)真实 create_time 的 max。
+        // 取分页前的全量台账(与三份分布同口径),故不随翻页跳动;空态显式 null。
+        List<String> createdAtValues = new ArrayList<>();
+        for (Marker marker : pointMarkers) {
+            createdAtValues.add(marker.createdAt);
+        }
+        for (Marker marker : deviceMarkers) {
+            createdAtValues.add(marker.createdAt);
+        }
+        String createdAt = CockpitCreatedAt.max(createdAtValues);
 
 
         return new CockpitMonitoringDistributionResponse(
         return new CockpitMonitoringDistributionResponse(
                 requestId,
                 requestId,
@@ -416,6 +429,7 @@ public class CockpitMonitoringDistributionService {
                 "Asia/Shanghai",
                 "Asia/Shanghai",
                 new CockpitMonitoringDistributionResponse.Range("CURRENT_BASELINE"),
                 new CockpitMonitoringDistributionResponse.Range("CURRENT_BASELINE"),
                 updatedAt,
                 updatedAt,
+                createdAt,
                 new CockpitMonitoringDistributionResponse.Freshness(
                 new CockpitMonitoringDistributionResponse.Freshness(
                         hasResolved ? CockpitFreshnessStatus.CURRENT.name()
                         hasResolved ? CockpitFreshnessStatus.CURRENT.name()
                                 : CockpitFreshnessStatus.EMPTY.name(),
                                 : CockpitFreshnessStatus.EMPTY.name(),
@@ -735,11 +749,13 @@ public class CockpitMonitoringDistributionService {
         private final CockpitCoordinateValidation coordinateValidation;
         private final CockpitCoordinateValidation coordinateValidation;
         private final boolean point;
         private final boolean point;
         private final List<String> deviceCodes;
         private final List<String> deviceCodes;
+        /** 记录创建时间(点位=monitor_point.create_time,设备=equipment_base.create_time)。 */
+        private final String createdAt;
 
 
         private Marker(String code, String name, Integer district, String industry, String typeCode, String typeName,
         private Marker(String code, String name, Integer district, String industry, String typeCode, String typeName,
                 CockpitMonitoringPointStatus status, List<String> statusReasons, BigDecimal longitude,
                 CockpitMonitoringPointStatus status, List<String> statusReasons, BigDecimal longitude,
                 BigDecimal latitude, CockpitCoordinateValidation coordinateValidation, boolean point,
                 BigDecimal latitude, CockpitCoordinateValidation coordinateValidation, boolean point,
-                List<String> deviceCodes) {
+                List<String> deviceCodes, String createdAt) {
             this.code = code;
             this.code = code;
             this.name = name;
             this.name = name;
             this.district = district;
             this.district = district;
@@ -753,6 +769,7 @@ public class CockpitMonitoringDistributionService {
             this.coordinateValidation = coordinateValidation;
             this.coordinateValidation = coordinateValidation;
             this.point = point;
             this.point = point;
             this.deviceCodes = deviceCodes;
             this.deviceCodes = deviceCodes;
+            this.createdAt = createdAt;
         }
         }
 
 
         private String getCode() {
         private String getCode() {
@@ -763,14 +780,14 @@ public class CockpitMonitoringDistributionService {
             return new CockpitMonitoringDistributionResponse.MonitoringPointMarker(
             return new CockpitMonitoringDistributionResponse.MonitoringPointMarker(
                     code, name, district, industry,
                     code, name, district, industry,
                     new CockpitMonitoringDistributionResponse.DeviceType(typeCode, typeName),
                     new CockpitMonitoringDistributionResponse.DeviceType(typeCode, typeName),
-                    status, statusReasons, longitude, latitude, coordinateValidation);
+                    status, statusReasons, longitude, latitude, coordinateValidation, createdAt);
         }
         }
 
 
         private CockpitMonitoringDistributionResponse.UnassociatedEquipmentMarker toUnassociatedEquipmentMarker() {
         private CockpitMonitoringDistributionResponse.UnassociatedEquipmentMarker toUnassociatedEquipmentMarker() {
             return new CockpitMonitoringDistributionResponse.UnassociatedEquipmentMarker(
             return new CockpitMonitoringDistributionResponse.UnassociatedEquipmentMarker(
                     code, name, district, industry,
                     code, name, district, industry,
                     new CockpitMonitoringDistributionResponse.DeviceType(typeCode, typeName),
                     new CockpitMonitoringDistributionResponse.DeviceType(typeCode, typeName),
-                    status, statusReasons, longitude, latitude, coordinateValidation);
+                    status, statusReasons, longitude, latitude, coordinateValidation, createdAt);
         }
         }
     }
     }
 
 

+ 37 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringDistributionSnapshot.java

@@ -105,6 +105,8 @@ public class CockpitMonitoringDistributionSnapshot {
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final boolean coordinateVerified;
         private final boolean coordinateVerified;
         private final List<CockpitMonitoringPointDeviceSnapshot> devices;
         private final List<CockpitMonitoringPointDeviceSnapshot> devices;
+        /** 记录创建时间({@code monitor_point.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public SourceMonitoringPoint(
         public SourceMonitoringPoint(
                 String pointCode,
                 String pointCode,
@@ -115,6 +117,20 @@ public class CockpitMonitoringDistributionSnapshot {
                 BigDecimal latitude,
                 BigDecimal latitude,
                 boolean coordinateVerified,
                 boolean coordinateVerified,
                 List<CockpitMonitoringPointDeviceSnapshot> devices) {
                 List<CockpitMonitoringPointDeviceSnapshot> devices) {
+            this(pointCode, pointName, district, typeCode, longitude, latitude,
+                    coordinateVerified, devices, null);
+        }
+
+        public SourceMonitoringPoint(
+                String pointCode,
+                String pointName,
+                Integer district,
+                String typeCode,
+                BigDecimal longitude,
+                BigDecimal latitude,
+                boolean coordinateVerified,
+                List<CockpitMonitoringPointDeviceSnapshot> devices,
+                String createdAt) {
             this.pointCode = pointCode;
             this.pointCode = pointCode;
             this.pointName = pointName;
             this.pointName = pointName;
             this.district = district;
             this.district = district;
@@ -123,6 +139,7 @@ public class CockpitMonitoringDistributionSnapshot {
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateVerified = coordinateVerified;
             this.coordinateVerified = coordinateVerified;
             this.devices = devices;
             this.devices = devices;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getPointCode() {
         public String getPointCode() {
@@ -157,6 +174,10 @@ public class CockpitMonitoringDistributionSnapshot {
         public List<CockpitMonitoringPointDeviceSnapshot> getDevices() {
         public List<CockpitMonitoringPointDeviceSnapshot> getDevices() {
             return devices;
             return devices;
         }
         }
+
+        public String getCreatedAt() {
+            return createdAt;
+        }
     }
     }
 
 
     public static class SourceSmartDevice {
     public static class SourceSmartDevice {
@@ -174,6 +195,8 @@ public class CockpitMonitoringDistributionSnapshot {
         private final List<String> statusReasons;
         private final List<String> statusReasons;
         private final String statusTime;
         private final String statusTime;
         private final boolean statusPublished;
         private final boolean statusPublished;
+        /** 记录创建时间({@code equipment_base.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public SourceSmartDevice(
         public SourceSmartDevice(
                 String deviceCode,
                 String deviceCode,
@@ -197,6 +220,15 @@ public class CockpitMonitoringDistributionSnapshot {
                 BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified,
                 BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified,
                 boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
                 boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
                 List<String> statusReasons, String statusTime, boolean statusPublished) {
                 List<String> statusReasons, String statusTime, boolean statusPublished) {
+            this(deviceCode, deviceName, district, typeCode, longitude, latitude, coordinateVerified,
+                    online, alarm, warning, workOrderInProgress, statusReasons, statusTime,
+                    statusPublished, null);
+        }
+
+        public SourceSmartDevice(String deviceCode, String deviceName, Integer district, String typeCode,
+                BigDecimal longitude, BigDecimal latitude, boolean coordinateVerified,
+                boolean online, boolean alarm, boolean warning, boolean workOrderInProgress,
+                List<String> statusReasons, String statusTime, boolean statusPublished, String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.district = district;
             this.district = district;
@@ -211,6 +243,7 @@ public class CockpitMonitoringDistributionSnapshot {
             this.statusReasons = statusReasons;
             this.statusReasons = statusReasons;
             this.statusTime = statusTime;
             this.statusTime = statusTime;
             this.statusPublished = statusPublished;
             this.statusPublished = statusPublished;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getDeviceCode() {
         public String getDeviceCode() {
@@ -267,5 +300,9 @@ public class CockpitMonitoringDistributionSnapshot {
         public String getStatusTime() {
         public String getStatusTime() {
             return statusTime;
             return statusTime;
         }
         }
+
+        public String getCreatedAt() {
+            return createdAt;
+        }
     }
     }
 }
 }

+ 8 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewResponse.java

@@ -12,6 +12,11 @@ public class CockpitMonitoringOverviewResponse {
     private final String timezone;
     private final String timezone;
     private final Range range;
     private final Range range;
     private final String updatedAt;
     private final String updatedAt;
+    /**
+     * 数据时间=记录创建时间({@code create_time}),跨聚合源类型取 max;
+     * 空态显式 {@code null}。与 {@code updatedAt}(快照加载时刻)语义不同,不互相冒充。
+     */
+    private final String createdAt;
     private final Freshness freshness;
     private final Freshness freshness;
     private final Counts counts;
     private final Counts counts;
     private final Status status;
     private final Status status;
@@ -28,6 +33,7 @@ public class CockpitMonitoringOverviewResponse {
             String timezone,
             String timezone,
             Range range,
             Range range,
             String updatedAt,
             String updatedAt,
+            String createdAt,
             Freshness freshness,
             Freshness freshness,
             Counts counts,
             Counts counts,
             Status status,
             Status status,
@@ -42,6 +48,7 @@ public class CockpitMonitoringOverviewResponse {
         this.timezone = timezone;
         this.timezone = timezone;
         this.range = range;
         this.range = range;
         this.updatedAt = updatedAt;
         this.updatedAt = updatedAt;
+        this.createdAt = createdAt;
         this.freshness = freshness;
         this.freshness = freshness;
         this.counts = counts;
         this.counts = counts;
         this.status = status;
         this.status = status;
@@ -58,6 +65,7 @@ public class CockpitMonitoringOverviewResponse {
     public String getTimezone() { return timezone; }
     public String getTimezone() { return timezone; }
     public Range getRange() { return range; }
     public Range getRange() { return range; }
     public String getUpdatedAt() { return updatedAt; }
     public String getUpdatedAt() { return updatedAt; }
+    public String getCreatedAt() { return createdAt; }
     public Freshness getFreshness() { return freshness; }
     public Freshness getFreshness() { return freshness; }
     public Counts getCounts() { return counts; }
     public Counts getCounts() { return counts; }
     public Status getStatus() { return status; }
     public Status getStatus() { return status; }

+ 30 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewService.java

@@ -1,5 +1,6 @@
 package com.zksy.cockpit.monitoring;
 package com.zksy.cockpit.monitoring;
 
 
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorCategory;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitErrorPayload;
 import com.zksy.cockpit.foundation.CockpitFreshnessStatus;
 import com.zksy.cockpit.foundation.CockpitFreshnessStatus;
@@ -199,6 +200,9 @@ public class CockpitMonitoringOverviewService {
         String updatedAt = snapshot == null || isBlank(snapshot.getUpdatedAt())
         String updatedAt = snapshot == null || isBlank(snapshot.getUpdatedAt())
                 ? businessTime()
                 ? businessTime()
                 : snapshot.getUpdatedAt();
                 : snapshot.getUpdatedAt();
+        // 数据时间=范围内真实记录 create_time 跨类型 max(设备表 + 点位表);
+        // 与 updatedAt(快照加载时刻)、freshness.serverUpdatedAt(响应生成时刻)语义分离。
+        String createdAt = CockpitCreatedAt.max(selectedCreatedAtValues(snapshot, selectedDevices, selectedPointCodes));
 
 
         List<CockpitMonitoringOverviewResponse.TypeDistribution> typeDistribution = new ArrayList<>();
         List<CockpitMonitoringOverviewResponse.TypeDistribution> typeDistribution = new ArrayList<>();
         for (TypeAccumulator accumulator : typeAccumulators.values()) {
         for (TypeAccumulator accumulator : typeAccumulators.values()) {
@@ -220,6 +224,7 @@ public class CockpitMonitoringOverviewService {
                 "Asia/Shanghai",
                 "Asia/Shanghai",
                 new CockpitMonitoringOverviewResponse.Range("CURRENT_BASELINE"),
                 new CockpitMonitoringOverviewResponse.Range("CURRENT_BASELINE"),
                 updatedAt,
                 updatedAt,
+                createdAt,
                 new CockpitMonitoringOverviewResponse.Freshness(
                 new CockpitMonitoringOverviewResponse.Freshness(
                         freshnessStatus, freshnessReason, updatedAt, businessTime()),
                         freshnessStatus, freshnessReason, updatedAt, businessTime()),
                 new CockpitMonitoringOverviewResponse.Counts(
                 new CockpitMonitoringOverviewResponse.Counts(
@@ -261,6 +266,31 @@ public class CockpitMonitoringOverviewService {
         return null;
         return null;
     }
     }
 
 
+    /**
+     * 数据时间的取值域=**筛选后**参与本响应的对象(设备 + 点位)各自来源表的 {@code create_time}。
+     * 空态(无对象或均无 create_time)返回空集合 → {@code createdAt} 显式 {@code null}。
+     */
+    private static List<String> selectedCreatedAtValues(
+            CockpitMonitoringOverviewSnapshot snapshot,
+            List<CockpitMonitoringOverviewSnapshot.SourceDevice> selectedDevices,
+            Set<String> selectedPointCodes) {
+        List<String> values = new ArrayList<>();
+        for (CockpitMonitoringOverviewSnapshot.SourceDevice device : selectedDevices) {
+            if (device != null) {
+                values.add(device.getCreatedAt());
+            }
+        }
+        if (snapshot != null && snapshot.getMonitoringPoints() != null) {
+            for (CockpitMonitoringOverviewSnapshot.SourceMonitoringPoint point : snapshot.getMonitoringPoints()) {
+                if (point != null && !isBlank(point.getPointCode())
+                        && selectedPointCodes.contains(point.getPointCode().trim())) {
+                    values.add(point.getCreatedAt());
+                }
+            }
+        }
+        return values;
+    }
+
     private static Set<String> selectMonitoringPointCodes(
     private static Set<String> selectMonitoringPointCodes(
             CockpitMonitoringOverviewSnapshot snapshot,
             CockpitMonitoringOverviewSnapshot snapshot,
             String selectedIndustry,
             String selectedIndustry,

+ 22 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringOverviewSnapshot.java

@@ -49,6 +49,8 @@ public class CockpitMonitoringOverviewSnapshot {
         private final String monitoringState;
         private final String monitoringState;
         private final String sampledAt;
         private final String sampledAt;
         private final String pointCode;
         private final String pointCode;
+        /** 记录创建时间({@code equipment_base.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public SourceDevice(
         public SourceDevice(
                 String deviceCode,
                 String deviceCode,
@@ -56,11 +58,22 @@ public class CockpitMonitoringOverviewSnapshot {
                 String monitoringState,
                 String monitoringState,
                 String sampledAt,
                 String sampledAt,
                 String pointCode) {
                 String pointCode) {
+            this(deviceCode, typeCode, monitoringState, sampledAt, pointCode, null);
+        }
+
+        public SourceDevice(
+                String deviceCode,
+                String typeCode,
+                String monitoringState,
+                String sampledAt,
+                String pointCode,
+                String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.typeCode = typeCode;
             this.typeCode = typeCode;
             this.monitoringState = monitoringState;
             this.monitoringState = monitoringState;
             this.sampledAt = sampledAt;
             this.sampledAt = sampledAt;
             this.pointCode = pointCode;
             this.pointCode = pointCode;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
@@ -68,6 +81,7 @@ public class CockpitMonitoringOverviewSnapshot {
         public String getMonitoringState() { return monitoringState; }
         public String getMonitoringState() { return monitoringState; }
         public String getSampledAt() { return sampledAt; }
         public String getSampledAt() { return sampledAt; }
         public String getPointCode() { return pointCode; }
         public String getPointCode() { return pointCode; }
+        public String getCreatedAt() { return createdAt; }
     }
     }
 
 
     public static class SourceMonitoringPoint {
     public static class SourceMonitoringPoint {
@@ -75,19 +89,27 @@ public class CockpitMonitoringOverviewSnapshot {
         private final String typeCode;
         private final String typeCode;
         /** -1 means an older adapter did not publish the association fact. */
         /** -1 means an older adapter did not publish the association fact. */
         private final int associatedDeviceCount;
         private final int associatedDeviceCount;
+        /** 记录创建时间({@code monitor_point.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public SourceMonitoringPoint(String pointCode, String typeCode) {
         public SourceMonitoringPoint(String pointCode, String typeCode) {
             this(pointCode, typeCode, -1);
             this(pointCode, typeCode, -1);
         }
         }
 
 
         public SourceMonitoringPoint(String pointCode, String typeCode, int associatedDeviceCount) {
         public SourceMonitoringPoint(String pointCode, String typeCode, int associatedDeviceCount) {
+            this(pointCode, typeCode, associatedDeviceCount, null);
+        }
+
+        public SourceMonitoringPoint(String pointCode, String typeCode, int associatedDeviceCount, String createdAt) {
             this.pointCode = pointCode;
             this.pointCode = pointCode;
             this.typeCode = typeCode;
             this.typeCode = typeCode;
             this.associatedDeviceCount = associatedDeviceCount;
             this.associatedDeviceCount = associatedDeviceCount;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getPointCode() { return pointCode; }
         public String getPointCode() { return pointCode; }
         public String getTypeCode() { return typeCode; }
         public String getTypeCode() { return typeCode; }
         public int getAssociatedDeviceCount() { return associatedDeviceCount; }
         public int getAssociatedDeviceCount() { return associatedDeviceCount; }
+        public String getCreatedAt() { return createdAt; }
     }
     }
 }
 }

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

@@ -14,6 +14,11 @@ public class CockpitMonitoringSituationResponse {
     private final String timezone;
     private final String timezone;
     private final Range range;
     private final Range range;
     private final String updatedAt;
     private final String updatedAt;
+    /**
+     * 数据时间=异常设备来源表 {@code create_time} 的 max(与逐对象 {@code createdAt} 同源可复算);
+     * 空态显式 {@code null}。事件时间由趋势桶 {@code bucketStart} 承载,不并入本读数。
+     */
+    private final String createdAt;
     private final Freshness freshness;
     private final Freshness freshness;
     private final List<MetricStatusCount> metricStatusDistribution;
     private final List<MetricStatusCount> metricStatusDistribution;
     private final List<TrendPoint> warningTrend;
     private final List<TrendPoint> warningTrend;
@@ -32,6 +37,7 @@ public class CockpitMonitoringSituationResponse {
             String timezone,
             String timezone,
             Range range,
             Range range,
             String updatedAt,
             String updatedAt,
+            String createdAt,
             Freshness freshness,
             Freshness freshness,
             List<MetricStatusCount> metricStatusDistribution,
             List<MetricStatusCount> metricStatusDistribution,
             List<TrendPoint> warningTrend,
             List<TrendPoint> warningTrend,
@@ -48,6 +54,7 @@ public class CockpitMonitoringSituationResponse {
         this.timezone = timezone;
         this.timezone = timezone;
         this.range = range;
         this.range = range;
         this.updatedAt = updatedAt;
         this.updatedAt = updatedAt;
+        this.createdAt = createdAt;
         this.freshness = freshness;
         this.freshness = freshness;
         this.metricStatusDistribution = metricStatusDistribution;
         this.metricStatusDistribution = metricStatusDistribution;
         this.warningTrend = warningTrend;
         this.warningTrend = warningTrend;
@@ -66,6 +73,7 @@ public class CockpitMonitoringSituationResponse {
     public String getTimezone() { return timezone; }
     public String getTimezone() { return timezone; }
     public Range getRange() { return range; }
     public Range getRange() { return range; }
     public String getUpdatedAt() { return updatedAt; }
     public String getUpdatedAt() { return updatedAt; }
+    public String getCreatedAt() { return createdAt; }
     public Freshness getFreshness() { return freshness; }
     public Freshness getFreshness() { return freshness; }
     public List<MetricStatusCount> getMetricStatusDistribution() { return metricStatusDistribution; }
     public List<MetricStatusCount> getMetricStatusDistribution() { return metricStatusDistribution; }
     public List<TrendPoint> getWarningTrend() { return warningTrend; }
     public List<TrendPoint> getWarningTrend() { return warningTrend; }
@@ -194,6 +202,8 @@ public class CockpitMonitoringSituationResponse {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final CockpitCoordinateValidation coordinateValidation;
         private final CockpitCoordinateValidation coordinateValidation;
+        /** 记录创建时间(来源表 {@code create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public AbnormalEquipment(
         public AbnormalEquipment(
                 String deviceCode,
                 String deviceCode,
@@ -206,7 +216,8 @@ public class CockpitMonitoringSituationResponse {
                 List<String> statusReasons,
                 List<String> statusReasons,
                 BigDecimal longitude,
                 BigDecimal longitude,
                 BigDecimal latitude,
                 BigDecimal latitude,
-                CockpitCoordinateValidation coordinateValidation) {
+                CockpitCoordinateValidation coordinateValidation,
+                String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.deviceType = deviceType;
             this.deviceType = deviceType;
@@ -220,6 +231,7 @@ public class CockpitMonitoringSituationResponse {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateValidation = coordinateValidation;
             this.coordinateValidation = coordinateValidation;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getDeviceCode() { return deviceCode; }
         public String getDeviceCode() { return deviceCode; }
@@ -235,6 +247,7 @@ public class CockpitMonitoringSituationResponse {
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLongitude() { return longitude; }
         public BigDecimal getLatitude() { return latitude; }
         public BigDecimal getLatitude() { return latitude; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
         public CockpitCoordinateValidation getCoordinateValidation() { return coordinateValidation; }
+        public String getCreatedAt() { return createdAt; }
     }
     }
 
 
     public static class DeviceType {
     public static class DeviceType {

+ 19 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringSituationService.java

@@ -2,6 +2,7 @@ package com.zksy.cockpit.monitoring;
 
 
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidation;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
 import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
+import com.zksy.cockpit.foundation.CockpitCreatedAt;
 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;
@@ -228,7 +229,8 @@ public class CockpitMonitoringSituationService {
                             device.getStatusReasons(),
                             device.getStatusReasons(),
                             device.getLongitude(),
                             device.getLongitude(),
                             device.getLatitude(),
                             device.getLatitude(),
-                            validation));
+                            validation,
+                            device.getCreatedAt()));
                     if (validation.isRenderable()) {
                     if (validation.isRenderable()) {
                         mapDeviceCodes.add(device.getDeviceCode().trim());
                         mapDeviceCodes.add(device.getDeviceCode().trim());
                     } else {
                     } else {
@@ -286,6 +288,14 @@ public class CockpitMonitoringSituationService {
         String updatedAt = isBlank(snapshot.getUpdatedAt())
         String updatedAt = isBlank(snapshot.getUpdatedAt())
                 ? businessTime()
                 ? businessTime()
                 : snapshot.getUpdatedAt();
                 : snapshot.getUpdatedAt();
+        // 数据时间=异常设备来源表 create_time 的 max(与逐对象 createdAt 同源可复算)。
+        // 取分页前的异常全集,故不随翻页跳动;无异常设备时显式 null。
+        // 事件时间不并入本读数:预警/报警趋势仍由各自 bucketStart 承载。
+        List<String> createdAtValues = new ArrayList<>();
+        for (AbnormalRow row : abnormal) {
+            createdAtValues.add(row.createdAt);
+        }
+        String createdAt = CockpitCreatedAt.max(createdAtValues);
 
 
         return new CockpitMonitoringSituationResponse(
         return new CockpitMonitoringSituationResponse(
                 requestId,
                 requestId,
@@ -298,6 +308,7 @@ public class CockpitMonitoringSituationService {
                         timestamp(window.start),
                         timestamp(window.start),
                         timestamp(window.end)),
                         timestamp(window.end)),
                 updatedAt,
                 updatedAt,
+                createdAt,
                 new CockpitMonitoringSituationResponse.Freshness(
                 new CockpitMonitoringSituationResponse.Freshness(
                         freshnessStatus, freshnessReason, updatedAt, businessTime()),
                         freshnessStatus, freshnessReason, updatedAt, businessTime()),
                 metricStatusDistribution,
                 metricStatusDistribution,
@@ -542,6 +553,8 @@ public class CockpitMonitoringSituationService {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final CockpitCoordinateValidation coordinateValidation;
         private final CockpitCoordinateValidation coordinateValidation;
+        /** 记录创建时间(equipment_base.create_time);缺值为 null。 */
+        private final String createdAt;
 
 
         private AbnormalRow(
         private AbnormalRow(
                 String deviceCode,
                 String deviceCode,
@@ -552,7 +565,8 @@ public class CockpitMonitoringSituationService {
                 List<String> statusReasons,
                 List<String> statusReasons,
                 BigDecimal longitude,
                 BigDecimal longitude,
                 BigDecimal latitude,
                 BigDecimal latitude,
-                CockpitCoordinateValidation coordinateValidation) {
+                CockpitCoordinateValidation coordinateValidation,
+                String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.type = type;
             this.type = type;
@@ -562,6 +576,7 @@ public class CockpitMonitoringSituationService {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateValidation = coordinateValidation;
             this.coordinateValidation = coordinateValidation;
+            this.createdAt = createdAt;
         }
         }
 
 
         private String getDeviceCode() {
         private String getDeviceCode() {
@@ -581,7 +596,8 @@ public class CockpitMonitoringSituationService {
                     statusReasons == null ? Collections.emptyList() : statusReasons,
                     statusReasons == null ? Collections.emptyList() : statusReasons,
                     longitude,
                     longitude,
                     latitude,
                     latitude,
-                    coordinateValidation);
+                    coordinateValidation,
+                    createdAt);
         }
         }
     }
     }
 
 

+ 23 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/monitoring/CockpitMonitoringSituationSnapshot.java

@@ -101,6 +101,8 @@ public class CockpitMonitoringSituationSnapshot {
         private final BigDecimal longitude;
         private final BigDecimal longitude;
         private final BigDecimal latitude;
         private final BigDecimal latitude;
         private final boolean coordinateVerified;
         private final boolean coordinateVerified;
+        /** 记录创建时间({@code equipment_base.create_time});缺值为 {@code null}。 */
+        private final String createdAt;
 
 
         public SourceMetricDevice(
         public SourceMetricDevice(
                 String deviceCode,
                 String deviceCode,
@@ -113,6 +115,22 @@ public class CockpitMonitoringSituationSnapshot {
                 BigDecimal longitude,
                 BigDecimal longitude,
                 BigDecimal latitude,
                 BigDecimal latitude,
                 boolean coordinateVerified) {
                 boolean coordinateVerified) {
+            this(deviceCode, deviceName, district, typeCode, metricStatus, statusReasons, sampledAt,
+                    longitude, latitude, coordinateVerified, null);
+        }
+
+        public SourceMetricDevice(
+                String deviceCode,
+                String deviceName,
+                Integer district,
+                String typeCode,
+                String metricStatus,
+                List<String> statusReasons,
+                String sampledAt,
+                BigDecimal longitude,
+                BigDecimal latitude,
+                boolean coordinateVerified,
+                String createdAt) {
             this.deviceCode = deviceCode;
             this.deviceCode = deviceCode;
             this.deviceName = deviceName;
             this.deviceName = deviceName;
             this.district = district;
             this.district = district;
@@ -123,6 +141,7 @@ public class CockpitMonitoringSituationSnapshot {
             this.longitude = longitude;
             this.longitude = longitude;
             this.latitude = latitude;
             this.latitude = latitude;
             this.coordinateVerified = coordinateVerified;
             this.coordinateVerified = coordinateVerified;
+            this.createdAt = createdAt;
         }
         }
 
 
         public String getDeviceCode() {
         public String getDeviceCode() {
@@ -165,6 +184,10 @@ public class CockpitMonitoringSituationSnapshot {
         public boolean isCoordinateVerified() {
         public boolean isCoordinateVerified() {
             return coordinateVerified;
             return coordinateVerified;
         }
         }
+
+        public String getCreatedAt() {
+            return createdAt;
+        }
     }
     }
 
 
     public static class SourceEvent {
     public static class SourceEvent {