|
|
@@ -82,7 +82,8 @@ class MonitoringServiceImplTest {
|
|
|
type(1, "供水", 0),
|
|
|
type(11, "供水流量计", 1),
|
|
|
type(12, "供水压力计", 1),
|
|
|
- type(13, "供水漏失监测器", 1)
|
|
|
+ type(13, "供水漏失监测器", 1),
|
|
|
+ type(14, "消火栓压力监测终端", 1)
|
|
|
));
|
|
|
when(radarDataMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
when(telemetryDataMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
@@ -161,7 +162,7 @@ class MonitoringServiceImplTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void leakagePaginationExcludesDevicesWithoutQualifyingMeasurements() {
|
|
|
+ void leakagePaginationKeepsUnmeasuredDevicesWhenNoMeasurementFilterIsApplied() {
|
|
|
when(equipmentBaseMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
device("leakage-1", "WS-LK-1", "漏失监测点1", "13", BASE_TIME),
|
|
|
device("leakage-2", "WS-LK-2", "漏失监测点2", "13", BASE_TIME.minusMinutes(1))
|
|
|
@@ -173,36 +174,52 @@ class MonitoringServiceImplTest {
|
|
|
Page<LeakageMonitoringVO> page = service.getLeakageMonitorPage(
|
|
|
1, 10, null, null, null, null, null, null, null);
|
|
|
|
|
|
- assertEquals(1, page.getTotal());
|
|
|
- assertEquals(1, page.getRecords().size());
|
|
|
+ assertEquals(2, page.getTotal());
|
|
|
+ assertEquals(2, page.getRecords().size());
|
|
|
assertEquals("leakage-1", page.getRecords().get(0).getEquipmentId());
|
|
|
assertEquals(12D, page.getRecords().get(0).getPower());
|
|
|
assertEquals(BASE_TIME, page.getRecords().get(0).getMonitorTime());
|
|
|
+ assertEquals("leakage-2", page.getRecords().get(1).getEquipmentId());
|
|
|
+ assertEquals(null, page.getRecords().get(1).getPower());
|
|
|
+ assertEquals(null, page.getRecords().get(1).getMonitorTime());
|
|
|
+
|
|
|
+ Page<LeakageMonitoringVO> filtered = service.getLeakageMonitorPage(
|
|
|
+ 1, 10, null, null, null, null, null, 10D, null);
|
|
|
+ assertEquals(1, filtered.getTotal());
|
|
|
+ assertEquals("leakage-1", filtered.getRecords().get(0).getEquipmentId());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void monitoringPagesReturnAnEmptyPageWhenThereIsNoMeasurementData() {
|
|
|
- when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
|
|
|
- device("flow-empty", "WS-FLOW-EMPTY", "无数据监测点", "11", BASE_TIME)
|
|
|
- ));
|
|
|
-
|
|
|
+ void monitoringPagesKeepFourWaterDevicesInTheirTypesWithoutMeasurements() {
|
|
|
+ when(equipmentBaseMapper.selectList(any())).thenAnswer(invocation -> {
|
|
|
+ LambdaQueryWrapper<EquipmentBase> wrapper = invocation.getArgument(0);
|
|
|
+ Set<Object> allowedTypeIds = flattenWrapperValues(wrapper);
|
|
|
+ return Arrays.asList(
|
|
|
+ device("flow", "TEST-FLOW", "测试流量计", "11", BASE_TIME),
|
|
|
+ device("pressure", "TEST-PRESSURE", "测试压力计", "12", BASE_TIME),
|
|
|
+ device("leakage", "TEST-LEAK", "测试漏失监测01", "13", BASE_TIME),
|
|
|
+ device("hydrant", "TEST-HYDRANT", "测试消火栓", "14", BASE_TIME),
|
|
|
+ device("drainage", "DRAIN-FLOW", "排水流量计", "17", BASE_TIME)
|
|
|
+ ).stream().filter(device -> allowedTypeIds.contains(device.getEquipmentTypeId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ });
|
|
|
Page<FlowMonitoringVO> flow = service.getFlowMonitorPage(1, 10, null, null, null, null, null, null, null);
|
|
|
- assertEquals(0, flow.getTotal());
|
|
|
- assertTrue(flow.getRecords().isEmpty());
|
|
|
+ assertEquals(1, flow.getTotal());
|
|
|
+ assertEquals("测试流量计", flow.getRecords().get(0).getEquipmentName());
|
|
|
+ assertEquals(null, flow.getRecords().get(0).getInstantFlow());
|
|
|
+ assertEquals(null, flow.getRecords().get(0).getMonitorTime());
|
|
|
|
|
|
- when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
|
|
|
- device("pressure-empty", "WS-PR-EMPTY", "无数据监测点", "12", BASE_TIME)
|
|
|
- ));
|
|
|
Page<PressureMonitoringVO> pressure = service.getPressureMonitorPage(1, 10, null, null, null, null, null, null, null);
|
|
|
- assertEquals(0, pressure.getTotal());
|
|
|
- assertTrue(pressure.getRecords().isEmpty());
|
|
|
+ assertEquals(2, pressure.getTotal());
|
|
|
+ assertEquals(Set.of("测试压力计", "测试消火栓"), pressure.getRecords().stream()
|
|
|
+ .map(PressureMonitoringVO::getEquipmentName).collect(Collectors.toSet()));
|
|
|
+ assertTrue(pressure.getRecords().stream().allMatch(row -> row.getPressureValue() == null && row.getMonitorTime() == null));
|
|
|
|
|
|
- when(equipmentBaseMapper.selectList(any())).thenReturn(Collections.singletonList(
|
|
|
- device("leakage-empty", "WS-LK-EMPTY", "无数据监测点", "13", BASE_TIME)
|
|
|
- ));
|
|
|
Page<LeakageMonitoringVO> leakage = service.getLeakageMonitorPage(1, 10, null, null, null, null, null, null, null);
|
|
|
- assertEquals(0, leakage.getTotal());
|
|
|
- assertTrue(leakage.getRecords().isEmpty());
|
|
|
+ assertEquals(1, leakage.getTotal());
|
|
|
+ assertEquals("测试漏失监测01", leakage.getRecords().get(0).getEquipmentName());
|
|
|
+ assertEquals(null, leakage.getRecords().get(0).getPower());
|
|
|
+ assertEquals(null, leakage.getRecords().get(0).getMonitorTime());
|
|
|
}
|
|
|
|
|
|
@Test
|