Commit 85ec5535 by gdj

增加机场和无人机查询接口。

parent 49328e57
......@@ -253,4 +253,21 @@ public class DeviceController {
return HttpResultResponse.success();
}
/**
* Get the binding devices list in one workspace.
* @param workspaceId
* @param page
* @param pageSize
* @return
*/
@GetMapping("/{workspace_id}/devices/DockAndDroneList")
public HttpResultResponse<PaginationData<DeviceDTO>> getDockAndDrone(
@PathVariable("workspace_id") String workspaceId,
@RequestParam(defaultValue = "1") Long page,
@RequestParam(name = "page_size", defaultValue = "50") Long pageSize) {
PaginationData<DeviceDTO> devices = deviceService.getDockAndDrone(workspaceId, page, pageSize);
return HttpResultResponse.success(devices);
}
}
\ No newline at end of file
......@@ -244,4 +244,13 @@ public interface IDeviceService {
boolean editAirport(DeviceDTO airport);
/**
* Get the devices list in one workspace.
* @param workspaceId
* @param page
* @param pageSize
* @return
*/
PaginationData<DeviceDTO> getDockAndDrone(String workspaceId ,Long page, Long pageSize);
}
\ No newline at end of file
......@@ -962,4 +962,43 @@ public class DeviceServiceImpl implements IDeviceService {
return update > 0;
}
/**
* Get the devices list in one workspace.
* @param workspaceId
* @param page
* @param pageSize
* @return
*/
@Override
public PaginationData<DeviceDTO> getDockAndDrone(String workspaceId ,Long page, Long pageSize) {
LambdaQueryWrapper<DeviceEntity> wrapper = new LambdaQueryWrapper<DeviceEntity>()
.eq(DeviceEntity::getWorkspaceId, workspaceId);
// if (StringUtils.hasText(deviceName)) {
// wrapper.like(DeviceEntity::getDeviceName, deviceName);
// }
wrapper.in(DeviceEntity::getDomain, DeviceDomainEnum.DOCK.getDomain(), DeviceDomainEnum.DRONE.getDomain());
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize), wrapper );
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
.peek(device -> {
if (StringUtils.hasText(device.getDeviceSn())) {
device.setStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn()));
}
if (StringUtils.hasText(device.getChildDeviceSn())) {
Optional<DeviceDTO> childOpt = this.getDeviceBySn(device.getChildDeviceSn());
childOpt.ifPresent(child -> {
child.setStatus(deviceRedisService.checkDeviceOnline(child.getDeviceSn()));
child.setWorkspaceName(device.getWorkspaceName());
device.setChildren(child);
});
}
})
.collect(Collectors.toList());
return new PaginationData<DeviceDTO>(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment