|
@@ -13,6 +13,7 @@ import com.zksy.base.domain.EquipmentStatus;
|
|
|
import com.zksy.base.domain.EquipmentType;
|
|
import com.zksy.base.domain.EquipmentType;
|
|
|
import com.zksy.ops.domain.WorkOrder;
|
|
import com.zksy.ops.domain.WorkOrder;
|
|
|
import com.zksy.base.domain.vo.AbnormalDeviceVO;
|
|
import com.zksy.base.domain.vo.AbnormalDeviceVO;
|
|
|
|
|
+import com.zksy.base.domain.vo.DeviceAbnormalStatsVO;
|
|
|
import com.zksy.base.domain.vo.DeviceGisVO;
|
|
import com.zksy.base.domain.vo.DeviceGisVO;
|
|
|
import com.zksy.base.domain.vo.DeviceLedgerStatisticsVO;
|
|
import com.zksy.base.domain.vo.DeviceLedgerStatisticsVO;
|
|
|
import com.zksy.base.domain.vo.DeviceTypeStatisticsVO;
|
|
import com.zksy.base.domain.vo.DeviceTypeStatisticsVO;
|
|
@@ -75,6 +76,7 @@ class WaterSupplyDeviceServiceImplTest {
|
|
|
|
|
|
|
|
private EquipmentBase pressureDevice;
|
|
private EquipmentBase pressureDevice;
|
|
|
private EquipmentBase repairDevice;
|
|
private EquipmentBase repairDevice;
|
|
|
|
|
+ private EquipmentBase offlineDevice;
|
|
|
private EquipmentBase gasDevice;
|
|
private EquipmentBase gasDevice;
|
|
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
@@ -98,6 +100,7 @@ class WaterSupplyDeviceServiceImplTest {
|
|
|
|
|
|
|
|
pressureDevice = device("water-pressure-1", "WS-PRESSURE-001", "供水压力监测点", "water-pressure");
|
|
pressureDevice = device("water-pressure-1", "WS-PRESSURE-001", "供水压力监测点", "water-pressure");
|
|
|
repairDevice = device("water-flow-1", "WS-FLOW-001", "供水流量监测点", "water-flow");
|
|
repairDevice = device("water-flow-1", "WS-FLOW-001", "供水流量监测点", "water-flow");
|
|
|
|
|
+ offlineDevice = device("water-offline-1", "WS-OFFLINE-001", "供水离线监测点", "water-flow");
|
|
|
gasDevice = device("gas-1", "GAS-001", "燃气监测点", "gas-root");
|
|
gasDevice = device("gas-1", "GAS-001", "燃气监测点", "gas-root");
|
|
|
|
|
|
|
|
when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
@@ -465,6 +468,111 @@ class WaterSupplyDeviceServiceImplTest {
|
|
|
.collect(Collectors.toList()));
|
|
.collect(Collectors.toList()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void abnormalStatsCountsAlarmRepairAndOfflineWaterDevices() {
|
|
|
|
|
+ when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
|
|
|
+ pressureDevice, repairDevice, offlineDevice));
|
|
|
|
|
+ when(equipmentStatusMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ status(pressureDevice.getEquipmentId(), 1, 1, 1),
|
|
|
|
|
+ status(repairDevice.getEquipmentId(), 3, 0, 1),
|
|
|
|
|
+ status(offlineDevice.getEquipmentId(), 1, 0, 0),
|
|
|
|
|
+ status(gasDevice.getEquipmentId(), 1, 1, 1)));
|
|
|
|
|
+ when(alarmDataMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ alarm(pressureDevice.getEquipmentCode(), "供水压力超限", 1),
|
|
|
|
|
+ alarm(gasDevice.getEquipmentCode(), "燃气浓度超限", 2)));
|
|
|
|
|
+
|
|
|
|
|
+ DeviceAbnormalStatsVO stats = service.getAbnormalDeviceStats();
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(3, stats.getTotal());
|
|
|
|
|
+ assertEquals(1, stats.getAlarm());
|
|
|
|
|
+ assertEquals(1, stats.getRepair());
|
|
|
|
|
+ assertEquals(1, stats.getOffline());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void abnormalStatsExcludeNormalAndNonWaterDevicesAndMissingStatusAlarmFallback() {
|
|
|
|
|
+ EquipmentBase normalDevice = device("water-normal-1", "WS-NORMAL-001", "供水正常设备", "water-pressure");
|
|
|
|
|
+ when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
|
|
|
+ pressureDevice, repairDevice, offlineDevice, normalDevice));
|
|
|
|
|
+ when(equipmentStatusMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ status(repairDevice.getEquipmentId(), 3, 0, 1),
|
|
|
|
|
+ status(offlineDevice.getEquipmentId(), 1, 0, 0),
|
|
|
|
|
+ status(normalDevice.getEquipmentId(), 1, 0, 1),
|
|
|
|
|
+ status(gasDevice.getEquipmentId(), 1, 1, 1)));
|
|
|
|
|
+ when(alarmDataMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ alarm(pressureDevice.getEquipmentCode(), "供水压力超限", 1),
|
|
|
|
|
+ alarm(gasDevice.getEquipmentCode(), "燃气浓度超限", 2)));
|
|
|
|
|
+
|
|
|
|
|
+ DeviceAbnormalStatsVO stats = service.getAbnormalDeviceStats();
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(3, stats.getTotal());
|
|
|
|
|
+ assertEquals(1, stats.getAlarm());
|
|
|
|
|
+ assertEquals(1, stats.getRepair());
|
|
|
|
|
+ assertEquals(1, stats.getOffline());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void abnormalPageIncludesOfflineReasonAndFiltersByAbnormalTypeAndRegion() {
|
|
|
|
|
+ when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
|
|
|
+ pressureDevice, repairDevice, offlineDevice));
|
|
|
|
|
+ pressureDevice.setDistrict("城南");
|
|
|
|
|
+ repairDevice.setDistrict("城北");
|
|
|
|
|
+ offlineDevice.setDistrict("太常");
|
|
|
|
|
+ when(equipmentStatusMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ status(pressureDevice.getEquipmentId(), 1, 1, 1),
|
|
|
|
|
+ status(repairDevice.getEquipmentId(), 3, 0, 1),
|
|
|
|
|
+ status(offlineDevice.getEquipmentId(), 1, 0, 0),
|
|
|
|
|
+ status(gasDevice.getEquipmentId(), 1, 1, 1)));
|
|
|
|
|
+ when(alarmDataMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ alarm(pressureDevice.getEquipmentCode(), "供水压力超限", 1),
|
|
|
|
|
+ alarm(gasDevice.getEquipmentCode(), "燃气浓度超限", 2)));
|
|
|
|
|
+ when(workOrderMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
|
|
+
|
|
|
|
|
+ Page<AbnormalDeviceVO> offlinePage = service.getAbnormalDevicePage(
|
|
|
|
|
+ 1, 10, null, null, null, null, "offline", "太常");
|
|
|
|
|
+ assertEquals(Collections.singletonList("water-offline-1"), offlinePage.getRecords().stream()
|
|
|
|
|
+ .map(AbnormalDeviceVO::getEquipmentId)
|
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
+ assertEquals("设备离线", ReflectionTestUtils.getField(offlinePage.getRecords().get(0), "abnormalReason"));
|
|
|
|
|
+
|
|
|
|
|
+ Page<AbnormalDeviceVO> repairPage = service.getAbnormalDevicePage(
|
|
|
|
|
+ 1, 10, null, null, null, null, "repair", "城北");
|
|
|
|
|
+ assertEquals(Collections.singletonList("water-flow-1"), repairPage.getRecords().stream()
|
|
|
|
|
+ .map(AbnormalDeviceVO::getEquipmentId)
|
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
+
|
|
|
|
|
+ Page<AbnormalDeviceVO> regionPage = service.getAbnormalDevicePage(
|
|
|
|
|
+ 1, 10, null, null, null, null, null, "城南");
|
|
|
|
|
+ assertEquals(Collections.singletonList("water-pressure-1"), regionPage.getRecords().stream()
|
|
|
|
|
+ .map(AbnormalDeviceVO::getEquipmentId)
|
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void abnormalExportAppliesAbnormalTypeAndRegionFilters() {
|
|
|
|
|
+ when(equipmentBaseService.findByTopLevelType("供水")).thenReturn(Arrays.asList(
|
|
|
|
|
+ pressureDevice, repairDevice, offlineDevice));
|
|
|
|
|
+ pressureDevice.setDistrict("城南");
|
|
|
|
|
+ repairDevice.setDistrict("城北");
|
|
|
|
|
+ offlineDevice.setDistrict("太常");
|
|
|
|
|
+ when(equipmentStatusMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ status(pressureDevice.getEquipmentId(), 1, 1, 1),
|
|
|
|
|
+ status(repairDevice.getEquipmentId(), 3, 0, 1),
|
|
|
|
|
+ status(offlineDevice.getEquipmentId(), 1, 0, 0),
|
|
|
|
|
+ status(gasDevice.getEquipmentId(), 1, 1, 1)));
|
|
|
|
|
+ when(alarmDataMapper.selectList(any())).thenReturn(Arrays.asList(
|
|
|
|
|
+ alarm(pressureDevice.getEquipmentCode(), "供水压力超限", 1),
|
|
|
|
|
+ alarm(gasDevice.getEquipmentCode(), "燃气浓度超限", 2)));
|
|
|
|
|
+ when(workOrderMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
|
|
+
|
|
|
|
|
+ List<AbnormalDeviceVO> result = service.getAbnormalDeviceExport(
|
|
|
|
|
+ null, null, null, null, "alarm", "城南");
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(Collections.singletonList("water-pressure-1"), result.stream()
|
|
|
|
|
+ .map(AbnormalDeviceVO::getEquipmentId)
|
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
void deviceGisPointsIncludeWaterOnlyWithCoordinatesAndStatuses() {
|
|
void deviceGisPointsIncludeWaterOnlyWithCoordinatesAndStatuses() {
|
|
|
pressureDevice.setLongitude(new BigDecimal("113.28000000"));
|
|
pressureDevice.setLongitude(new BigDecimal("113.28000000"));
|