|
|
@@ -2,6 +2,7 @@ package com.usky.ems.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.ems.domain.*;
|
|
|
import com.usky.ems.mapper.*;
|
|
|
@@ -59,6 +60,10 @@ public class EmsModelServiceImpl implements EmsModelService {
|
|
|
@Autowired
|
|
|
private DmpProductMapper dmpProductMapper;
|
|
|
@Autowired
|
|
|
+ private DmpDeviceMapper dmpDeviceMapper;
|
|
|
+ @Autowired
|
|
|
+ private DmpDeviceStatusMapper dmpDeviceStatusMapper;
|
|
|
+ @Autowired
|
|
|
private BaseSpaceServiceImpl baseSpaceService;
|
|
|
|
|
|
private static final int SPACE_TYPE_PROJECT = 1;
|
|
|
@@ -759,10 +764,10 @@ public class EmsModelServiceImpl implements EmsModelService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<DmpGateway> gateways = dmpGatewayMapper.selectList(
|
|
|
- new LambdaQueryWrapper<DmpGateway>().in(DmpGateway::getDeviceUuid, normalizedUuids));
|
|
|
+ List<DmpDevice> gateways = dmpDeviceMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<DmpDevice>().in(DmpDevice::getDeviceUuid, normalizedUuids));
|
|
|
Set<String> existsGatewayUuids = gateways.stream()
|
|
|
- .map(DmpGateway::getDeviceUuid)
|
|
|
+ .map(DmpDevice::getDeviceUuid)
|
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toSet());
|
|
|
if (existsGatewayUuids.isEmpty()) {
|
|
|
@@ -826,31 +831,33 @@ public class EmsModelServiceImpl implements EmsModelService {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
- List<DmpGateway> gateways = dmpGatewayMapper.selectList(
|
|
|
- new LambdaQueryWrapper<DmpGateway>().in(DmpGateway::getDeviceUuid, gatewayUuids));
|
|
|
+ List<DmpDevice> gateways = dmpDeviceMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<DmpDevice>()
|
|
|
+ .in(DmpDevice::getDeviceUuid, gatewayUuids)
|
|
|
+ .eq(DmpDevice::getDeleteFlag, 0));
|
|
|
if (gateways == null || gateways.isEmpty()) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
+ List<DmpDeviceStatus> statusList = dmpDeviceStatusMapper.selectList(
|
|
|
+ Wrappers.<DmpDeviceStatus>lambdaQuery().in(DmpDeviceStatus::getDeviceUuid, gatewayUuids));
|
|
|
+ Map<String, DmpDeviceStatus> statusByUuid = statusList == null ? Collections.emptyMap()
|
|
|
+ : statusList.stream()
|
|
|
+ .filter(s -> s.getDeviceUuid() != null)
|
|
|
+ .collect(Collectors.toMap(DmpDeviceStatus::getDeviceUuid, s -> s, (a, b) -> a));
|
|
|
+
|
|
|
return gateways.stream().map(item -> {
|
|
|
DmpGatewayDetailResponse resp = new DmpGatewayDetailResponse();
|
|
|
resp.setId(item.getId());
|
|
|
resp.setDeviceUuid(item.getDeviceUuid());
|
|
|
- resp.setName(item.getName());
|
|
|
- resp.setIp(item.getIp());
|
|
|
- resp.setPort(item.getPort());
|
|
|
- resp.setCommunicationStatus(item.getCommStatus());
|
|
|
- resp.setOnlineTime(item.getOnlineTime());
|
|
|
- resp.setOfflineTime(item.getOfflineTime());
|
|
|
- resp.setUpdateConfigTime(item.getUpdateConfigTime());
|
|
|
- resp.setUpdateProtocolTime(item.getUpdateProtocolTime());
|
|
|
- resp.setUpgradeTime(item.getUpgradeTime());
|
|
|
- resp.setVirtualDevice(item.getVirtualDevice());
|
|
|
- resp.setRemark(item.getRemark());
|
|
|
- resp.setUpdatedBy(item.getUpdatedBy());
|
|
|
- resp.setUpdateTime(item.getUpdateTime());
|
|
|
- resp.setCreatedBy(item.getCreatedBy());
|
|
|
- resp.setCreateTime(item.getCreateTime());
|
|
|
+ resp.setName(item.getDeviceName());
|
|
|
+ resp.setInstallAddress(item.getInstallAddress());
|
|
|
+ DmpDeviceStatus status = statusByUuid.get(item.getDeviceUuid());
|
|
|
+ if (status != null) {
|
|
|
+ resp.setCommunicationStatus(status.getDeviceStatus());
|
|
|
+ resp.setOnlineTime(status.getLastOnlineTime());
|
|
|
+ resp.setOfflineTime(status.getLastOfflineTime());
|
|
|
+ }
|
|
|
return resp;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|