yeg
2026-09-03 54f683c3fd09dd88fd4520e014b14825f7479c2f
修正暂停停止后的设备异常展示

暂停接收和检测完成时不再把不可观测设备状态列为实时告警,保留设备事实状态并补充回归测试。
2个文件已修改
32 ■■■■■ 已修改文件
ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestLiveServiceImplTest.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestLiveServiceImplTest.java
@@ -59,6 +59,18 @@
        assertEquals(new BigDecimal("2.500"), snapshot.get("capacityAh"));
    }
    @Test
    void pausedShouldNotExposeUnavailableSourceAsAlarm()
    {
        Instant now = Instant.parse("2026-09-02T06:00:00Z");
        TTest test = test("PAUSED");
        TTestLiveServiceImpl service = liveService(test, now, false);
        LiveState state = service.current(10L);
        assertTrue(state.exceptions().isEmpty());
    }
    private static TTest test(String receptionStatus)
    {
        TTest test = new TTest();
@@ -81,6 +93,11 @@
    private static TTestLiveServiceImpl liveService(TTest test, Instant now)
    {
        return liveService(test, now, true);
    }
    private static TTestLiveServiceImpl liveService(TTest test, Instant now, boolean online)
    {
        DeviceDiscoveryCandidateStore candidates = mock(DeviceDiscoveryCandidateStore.class);
        BtsDevelopmentSimulator simulator = mock(BtsDevelopmentSimulator.class);
        ITTestService tests = mock(ITTestService.class);
@@ -91,7 +108,7 @@
                new BigDecimal("9.250"), 12L, 12L, "0", now,
                java.util.Map.of());
        DeviceDiscoveryCandidateStore.ChannelCandidate channel = new DeviceDiscoveryCandidateStore.ChannelCandidate(
                identity, true, DeviceWorkStatus.WORKING, now, snapshot);
                identity, online, DeviceWorkStatus.WORKING, now, snapshot);
        DeviceDiscoveryCandidateStore.CabinetCandidate cabinet = new DeviceDiscoveryCandidateStore.CabinetCandidate(
                "dev-sim", 1L, "dev-sim", 1, 1, "127.0.0.2", "mac", "cabinet", "vendor", "model",
                List.of(channel), now, now.plusSeconds(60));
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java
@@ -62,12 +62,13 @@
                sources.add(snapshotFor(collectorSource(battery), receiving));
        }
        List<Map<String, Object>> exceptions = new ArrayList<>();
        exceptions.addAll(sources.stream().filter(source -> !"COLLECTOR".equals(source.sourceType())
                && !"ONLINE".equals(source.deviceStatus())
                && !"WORKING".equals(source.deviceStatus()) && !"PAUSED".equals(source.deviceStatus()))
                .map(source -> Map.<String, Object>of("sourceType", source.sourceType(), "sourceId", source.sourceId(),
                        "batteryNo", source.batteryNo(), "status", source.deviceStatus(), "message", "数据来源当前不可观测"))
                .toList());
        if (receiving)
            exceptions.addAll(sources.stream().filter(source -> !"COLLECTOR".equals(source.sourceType())
                    && !"ONLINE".equals(source.deviceStatus())
                    && !"WORKING".equals(source.deviceStatus()) && !"PAUSED".equals(source.deviceStatus()))
                    .map(source -> Map.<String, Object>of("sourceType", source.sourceType(), "sourceId", source.sourceId(),
                            "batteryNo", source.batteryNo(), "status", source.deviceStatus(), "message", "数据来源当前不可观测"))
                    .toList());
        if (mapper != null) {
            mapper.selectWarningExceptions(testId, "OPEN").forEach(item -> exceptions.add(Map.of(
                    "exceptionId", item.getExceptionId(), "sourceType", item.getSourceType(),