|
|
@ -641,21 +641,39 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
.collect(Collectors.groupingBy(HwDevice::getDeviceType));
|
|
|
|
.collect(Collectors.groupingBy(HwDevice::getDeviceType));
|
|
|
|
List<HwDevice> gatewayDevices = hwDevicesMap.get(HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE);
|
|
|
|
List<HwDevice> gatewayDevices = hwDevicesMap.get(HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE);
|
|
|
|
List<HwDevice> subDevices = hwDevicesMap.get(HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT);
|
|
|
|
List<HwDevice> subDevices = hwDevicesMap.get(HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT);
|
|
|
|
//根据关联网关设备ID进行分组
|
|
|
|
List<HwDevice> directConnectDevices = hwDevicesMap.get(HwDictConstants.DEVICE_TYPE_DIRECT_CONNECT_DEVICE);
|
|
|
|
Map<Long, List<HwDevice>> releatedDeviceIdDevicesMap = subDevices.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(HwDevice::getReleatedDeviceId));
|
|
|
|
|
|
|
|
int onlineDevicesCount = 0;
|
|
|
|
int onlineDevicesCount = 0;
|
|
|
|
int offlineDevicesCount = 0;
|
|
|
|
int offlineDevicesCount = 0;
|
|
|
|
for (HwDevice gatewayDevice : gatewayDevices) {
|
|
|
|
//网关设备和网关子设备,根据网关设备状态来判断网关子设备的状态
|
|
|
|
String onlineStatus = gatewayDevice.getOnlineStatus();
|
|
|
|
if (gatewayDevices != null && !gatewayDevices.isEmpty() && subDevices != null && !subDevices.isEmpty()) {
|
|
|
|
//获取关联子设备的数量
|
|
|
|
//根据关联网关设备ID进行分组
|
|
|
|
int gatewaySubPublishedDevicesCount =
|
|
|
|
Map<Long, List<HwDevice>> releatedDeviceIdDevicesMap = subDevices.stream()
|
|
|
|
releatedDeviceIdDevicesMap.get(gatewayDevice.getDeviceId()) == null ?
|
|
|
|
.collect(Collectors.groupingBy(HwDevice::getReleatedDeviceId));
|
|
|
|
0 : releatedDeviceIdDevicesMap.get(gatewayDevice.getDeviceId()).size();
|
|
|
|
|
|
|
|
if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_ONLINE)) {
|
|
|
|
for (HwDevice gatewayDevice : gatewayDevices) {
|
|
|
|
onlineDevicesCount += gatewaySubPublishedDevicesCount;
|
|
|
|
String onlineStatus = gatewayDevice.getOnlineStatus();
|
|
|
|
} else if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_OFFLINE)) {
|
|
|
|
//获取关联子设备的数量
|
|
|
|
offlineDevicesCount += gatewaySubPublishedDevicesCount;
|
|
|
|
int gatewaySubPublishedDevicesCount =
|
|
|
|
|
|
|
|
releatedDeviceIdDevicesMap.get(gatewayDevice.getDeviceId()) == null ?
|
|
|
|
|
|
|
|
0 : releatedDeviceIdDevicesMap.get(gatewayDevice.getDeviceId()).size();
|
|
|
|
|
|
|
|
if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_ONLINE)) {
|
|
|
|
|
|
|
|
onlineDevicesCount += gatewaySubPublishedDevicesCount;
|
|
|
|
|
|
|
|
} else if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_OFFLINE)) {
|
|
|
|
|
|
|
|
offlineDevicesCount += gatewaySubPublishedDevicesCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//直连设备直接获取设备状态
|
|
|
|
|
|
|
|
if (directConnectDevices != null && !directConnectDevices.isEmpty()) {
|
|
|
|
|
|
|
|
for (HwDevice directConnectDevice : directConnectDevices) {
|
|
|
|
|
|
|
|
String onlineStatus = directConnectDevice.getOnlineStatus();
|
|
|
|
|
|
|
|
if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_ONLINE)) {
|
|
|
|
|
|
|
|
onlineDevicesCount += 1;
|
|
|
|
|
|
|
|
} else if (onlineStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_OFFLINE)) {
|
|
|
|
|
|
|
|
offlineDevicesCount += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -778,7 +796,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@DataScope(tenantAlias = "hd")
|
|
|
|
@DataScope(tenantAlias = "hd")
|
|
|
|
public List<HwDevice> selectHwDeviceListWithDeviceMode(HwDevice hwDevice) {
|
|
|
|
public List<HwDevice> selectHwDeviceListWithDeviceMode(HwDevice hwDevice) {
|
|
|
|
return hwDeviceMapper.selectHwDeviceListByMonitor(hwDevice);
|
|
|
|
return hwDeviceMapper.selectHwDeviceListByMonitor(hwDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Map<Long, Integer> computeDeviceCountPerDay(Long startTime, Long endTime) {
|
|
|
|
private Map<Long, Integer> computeDeviceCountPerDay(Long startTime, Long endTime) {
|
|
|
|