|
|
@@ -176,24 +176,37 @@ public class DeviceStatisticsService {
|
|
|
gateWayUserInfos = gateWayUserInfos.stream().filter(it -> {
|
|
|
return !it.getUserName().equals("admin");
|
|
|
}).collect(Collectors.toList());
|
|
|
- List<DeviceInfo> deviceInfos = deviceInfoDao.findByIsDelete(Boolean.FALSE);
|
|
|
+
|
|
|
+ List<DeviceInfo> deviceInfos = deviceInfoDao.findByDeviceCategoryInAndIsDelete(
|
|
|
+ List.of(DeviceCategory.GW, DeviceCategory.DC), Boolean.FALSE);
|
|
|
Map<String, List<DeviceInfo>> mqttUser2GateWayInfo = new HashMap<>();
|
|
|
- for (DeviceInfo deviceInfo : deviceInfos) {
|
|
|
- if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
|
|
|
- // 网关
|
|
|
- List<DeviceInfo> list = new ArrayList<>();
|
|
|
- if (mqttUser2GateWayInfo.containsKey(deviceInfo.getMqttUserName())) {
|
|
|
- list = mqttUser2GateWayInfo.get(deviceInfo.getMqttUserName());
|
|
|
- }
|
|
|
- list.add(deviceInfo);
|
|
|
- mqttUser2GateWayInfo.put(deviceInfo.getMqttUserName(), list);
|
|
|
- } else {
|
|
|
+ Map<String, List<DeviceInfo>> dcMap = new HashMap<>();
|
|
|
|
|
|
- }
|
|
|
+ if (ObjectUtils.isNotEmpty(deviceInfos)) {
|
|
|
+ deviceInfos.parallelStream().forEach(deviceInfo -> {
|
|
|
+ if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
|
|
|
+ // 网关
|
|
|
+ List<DeviceInfo> list = new ArrayList<>();
|
|
|
+ if (mqttUser2GateWayInfo.containsKey(deviceInfo.getMqttUserName())) {
|
|
|
+ list = mqttUser2GateWayInfo.get(deviceInfo.getMqttUserName());
|
|
|
+ }
|
|
|
+ list.add(deviceInfo);
|
|
|
+ mqttUser2GateWayInfo.put(deviceInfo.getMqttUserName(), list);
|
|
|
+ } else if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
|
|
|
+ List<DeviceInfo> list = new ArrayList<>();
|
|
|
+ if (dcMap.containsKey(deviceInfo.getMqttUserName())) {
|
|
|
+ list = dcMap.get(deviceInfo.getMqttUserName());
|
|
|
+ }
|
|
|
+ list.add(deviceInfo);
|
|
|
+ dcMap.put(deviceInfo.getMqttUserName(), list);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- gateWayUserInfos.stream().forEach(it -> {
|
|
|
+
|
|
|
+ gateWayUserInfos.parallelStream().forEach(it -> {
|
|
|
TopologyTreeModel mqttModel = mqttUserTopologyTreeModel(it);
|
|
|
+
|
|
|
// 查询网关信息
|
|
|
if (mqttUser2GateWayInfo.containsKey(it.getUserName())) {
|
|
|
List<DeviceInfo> gateWays = mqttUser2GateWayInfo.get(it.getUserName());
|
|
|
@@ -209,7 +222,13 @@ public class DeviceStatisticsService {
|
|
|
}
|
|
|
children.add(gateWayModel);
|
|
|
}
|
|
|
- mqttModel.setChildren(children);
|
|
|
+ mqttModel.addAll(children);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加直连设备
|
|
|
+ if (dcMap.containsKey(it.getUserName())) {
|
|
|
+ List<DeviceInfo> gateWays = dcMap.get(it.getUserName());
|
|
|
+ mqttModel.addAll(gateWays.stream().map(this::deviceTopologyTreeModel).collect(Collectors.toList()));
|
|
|
}
|
|
|
models.add(mqttModel);
|
|
|
});
|