|
|
@@ -231,6 +231,17 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<DeviceDTO> getDevicesStatus(List<String> snList) {
|
|
|
+ List<DeviceDTO> deviceDTOList = new ArrayList<DeviceDTO>();
|
|
|
+ for (String sn : snList) {
|
|
|
+ DeviceDTO deviceDTO = DeviceDTO.builder().deviceSn(sn).build();
|
|
|
+ getDeviceStatus(deviceDTO);
|
|
|
+ deviceDTOList.add(deviceDTO);
|
|
|
+ }
|
|
|
+ return deviceDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<DeviceDTO> getDevicesTopoForWeb(String workspaceId) {
|
|
|
List<DeviceDTO> devicesList = this.getDevicesByParams(
|
|
|
@@ -249,7 +260,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
|
|
|
@Override
|
|
|
public void spliceDeviceTopo(DeviceDTO gateway) {
|
|
|
-
|
|
|
+ getDeviceStatus(gateway);
|
|
|
gateway.setStatus(deviceRedisService.checkDeviceOnline(gateway.getDeviceSn()));
|
|
|
|
|
|
// sub device
|
|
|
@@ -258,6 +269,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
}
|
|
|
|
|
|
DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0);
|
|
|
+ getDeviceStatus(subDevice);
|
|
|
subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn()));
|
|
|
gateway.setChildren(subDevice);
|
|
|
|
|
|
@@ -265,6 +277,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
subDevice.setPayloadsList(payloadService.getDevicePayloadEntitiesByDeviceSn(gateway.getChildDeviceSn()));
|
|
|
}
|
|
|
|
|
|
+ private void getDeviceStatus(DeviceDTO deviceDTO) {
|
|
|
+ Optional<DeviceStatusEnum> deviceStatusOpt = deviceRedisService.getDeviceStatus(deviceDTO.getDeviceSn());
|
|
|
+ if(deviceStatusOpt.isPresent()) {
|
|
|
+ deviceDTO.setStatusText(deviceStatusOpt.get().getText());
|
|
|
+ } else {
|
|
|
+ deviceDTO.setStatusText("设备已离线");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Optional<TopologyDeviceDTO> getDeviceTopoForPilot(String sn) {
|
|
|
if (!StringUtils.hasText(sn)) {
|