|
@@ -50,6 +50,7 @@ import org.springframework.util.StringUtils;
|
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -125,6 +126,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AbstractFirmwareService abstractFirmwareService;
|
|
private AbstractFirmwareService abstractFirmwareService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IUserService userService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void subDeviceOffline(String deviceSn) {
|
|
public void subDeviceOffline(String deviceSn) {
|
|
|
// If no information about this device exists in the cache, the drone is considered to be offline.
|
|
// If no information about this device exists in the cache, the drone is considered to be offline.
|
|
@@ -384,7 +388,8 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId())
|
|
workspaceService.getWorkspaceByWorkspaceId(entity.getWorkspaceId())
|
|
|
.map(WorkspaceDTO::getWorkspaceName).orElse("") : "")
|
|
.map(WorkspaceDTO::getWorkspaceName).orElse("") : "")
|
|
|
.firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE)
|
|
.firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE)
|
|
|
- .thingVersion(entity.getVersion()).build();
|
|
|
|
|
|
|
+ .thingVersion(entity.getVersion())
|
|
|
|
|
+ .compatibleStatus(entity.getCompatibleStatus()).build();
|
|
|
} catch (CloudSDKException e) {
|
|
} catch (CloudSDKException e) {
|
|
|
log.error(e.getLocalizedMessage() + "Entity: {}", entity);
|
|
log.error(e.getLocalizedMessage() + "Entity: {}", entity);
|
|
|
}
|
|
}
|
|
@@ -446,6 +451,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //更新登录用户绑定项目工作空间
|
|
|
|
|
+ if(StringUtils.hasText(device.getUserId())) {
|
|
|
|
|
+ userService.updateUserWorkspace(device.getWorkspaceId(), device.getUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
DeviceDTO redisDevice = deviceOpt.get();
|
|
DeviceDTO redisDevice = deviceOpt.get();
|
|
|
redisDevice.setWorkspaceId(device.getWorkspaceId());
|
|
redisDevice.setWorkspaceId(device.getWorkspaceId());
|
|
|
deviceRedisService.setDeviceOnline(redisDevice);
|
|
deviceRedisService.setDeviceOnline(redisDevice);
|
|
@@ -470,7 +480,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
|
|
|
|
|
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize),
|
|
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize),
|
|
|
new LambdaQueryWrapper<DeviceEntity>()
|
|
new LambdaQueryWrapper<DeviceEntity>()
|
|
|
- .eq(DeviceEntity::getDomain, domain)
|
|
|
|
|
|
|
+ .in(DeviceEntity::getDomain, DeviceDomainEnum.DRONE.getDomain(),DeviceDomainEnum.DOCK.getDomain())
|
|
|
.eq(DeviceEntity::getWorkspaceId, workspaceId)
|
|
.eq(DeviceEntity::getWorkspaceId, workspaceId)
|
|
|
.eq(DeviceEntity::getBoundStatus, true));
|
|
.eq(DeviceEntity::getBoundStatus, true));
|
|
|
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
|
|
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
|
|
@@ -484,6 +494,14 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
device.setChildren(child);
|
|
device.setChildren(child);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ //遥控器作为child
|
|
|
|
|
+ if(DeviceDomainEnum.DRONE == device.getDomain()) {
|
|
|
|
|
+ Optional<DeviceDTO> childOpt = getDevice(device.getWorkspaceId(), DeviceDomainEnum.REMOTER_CONTROL.getDomain(), device.getDeviceSn());
|
|
|
|
|
+ childOpt.ifPresent(child -> {
|
|
|
|
|
+ child.setWorkspaceName(device.getWorkspaceName());
|
|
|
|
|
+ device.setChildren(child);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
return new PaginationData<DeviceDTO>(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
|
|
return new PaginationData<DeviceDTO>(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
|
|
@@ -521,6 +539,18 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
return Optional.of(device);
|
|
return Optional.of(device);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private Optional<DeviceDTO> getDevice(String workspaceId, Integer domain, String childSn) {
|
|
|
|
|
+ List<Integer> domainList = new ArrayList<>();
|
|
|
|
|
+ domainList.add(domain);
|
|
|
|
|
+ List<DeviceDTO> devicesList = this.getDevicesByParams(DeviceQueryParam.builder().workspaceId(workspaceId).childSn(childSn).domains(domainList).build());
|
|
|
|
|
+ if (devicesList.isEmpty()) {
|
|
|
|
|
+ return Optional.empty();
|
|
|
|
|
+ }
|
|
|
|
|
+ DeviceDTO device = devicesList.get(0);
|
|
|
|
|
+ device.setStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn()));
|
|
|
|
|
+ return Optional.of(device);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public HttpResultResponse createDeviceOtaJob(String workspaceId, List<DeviceFirmwareUpgradeDTO> upgradeDTOS) {
|
|
public HttpResultResponse createDeviceOtaJob(String workspaceId, List<DeviceFirmwareUpgradeDTO> upgradeDTOS) {
|
|
|
List<OtaCreateDevice> deviceOtaFirmwares = deviceFirmwareService.getDeviceOtaFirmware(workspaceId, upgradeDTOS);
|
|
List<OtaCreateDevice> deviceOtaFirmwares = deviceFirmwareService.getDeviceOtaFirmware(workspaceId, upgradeDTOS);
|