|
|
@@ -1,6 +1,7 @@
|
|
|
package com.dji.sample.manage.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.dji.sample.common.error.CommonErrorEnum;
|
|
|
@@ -10,6 +11,8 @@ import com.dji.sample.component.websocket.model.BizCodeEnum;
|
|
|
import com.dji.sample.component.websocket.service.IWebSocketMessageService;
|
|
|
import com.dji.sample.control.model.enums.DroneAuthorityEnum;
|
|
|
import com.dji.sample.manage.dao.IDeviceMapper;
|
|
|
+import com.dji.sample.manage.model.param.DeviceBoundQueryParam;
|
|
|
+import com.dji.sample.media.model.MediaDirEntity;
|
|
|
import com.dji.sample.manage.model.enums.*;
|
|
|
import com.dji.sdk.common.AMap;
|
|
|
import com.dji.sample.manage.model.dto.*;
|
|
|
@@ -228,17 +231,6 @@ 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(
|
|
|
@@ -257,7 +249,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
|
|
|
@Override
|
|
|
public void spliceDeviceTopo(DeviceDTO gateway) {
|
|
|
- getDeviceStatus(gateway);
|
|
|
+
|
|
|
gateway.setStatus(deviceRedisService.checkDeviceOnline(gateway.getDeviceSn()));
|
|
|
|
|
|
// sub device
|
|
|
@@ -266,7 +258,6 @@ 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);
|
|
|
|
|
|
@@ -274,15 +265,6 @@ 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)) {
|
|
|
@@ -505,13 +487,29 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
|
|
|
@Override
|
|
|
public PaginationData<DeviceDTO> getBoundDevicesWithDomain(String workspaceId, Long page,
|
|
|
- Long pageSize, Integer domain) {
|
|
|
+ Long pageSize, Integer domain, DeviceBoundQueryParam param) {
|
|
|
+
|
|
|
+ QueryWrapper<DeviceEntity> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().in(DeviceEntity::getDomain, DeviceDomainEnum.DRONE.getDomain(),DeviceDomainEnum.DOCK.getDomain())
|
|
|
+ .eq(DeviceEntity::getWorkspaceId, workspaceId)
|
|
|
+ .eq(DeviceEntity::getBoundStatus, true)
|
|
|
+ .ge(param != null && param.getBeginTime() != null, DeviceEntity::getCreateTime,param.getBeginTime())
|
|
|
+ .le(param != null && param.getEndTime() != null, DeviceEntity::getCreateTime,param.getEndTime())
|
|
|
+ .and(StringUtils.hasText(param.getSearchInfo()),
|
|
|
+ wrapper2 -> wrapper2.like( DeviceEntity::getDeviceSn, param.getSearchInfo())
|
|
|
+ .or().like( DeviceEntity::getNickname, param.getSearchInfo()));
|
|
|
+ if (param != null && StringUtils.hasText(param.getDeviceType())) {
|
|
|
+ String[] deviceType = param.getDeviceType().split("-");
|
|
|
+ String dom = deviceType[0];
|
|
|
+ String sub = deviceType[1];
|
|
|
+ String type = deviceType[2];
|
|
|
+ wrapper.lambda().eq(DeviceEntity::getDomain,dom )
|
|
|
+ .eq(DeviceEntity::getSubType,sub )
|
|
|
+ .eq(DeviceEntity::getDeviceType,type );
|
|
|
+ }
|
|
|
|
|
|
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize),
|
|
|
- new LambdaQueryWrapper<DeviceEntity>()
|
|
|
- .in(DeviceEntity::getDomain, DeviceDomainEnum.DRONE.getDomain(),DeviceDomainEnum.DOCK.getDomain())
|
|
|
- .eq(DeviceEntity::getWorkspaceId, workspaceId)
|
|
|
- .eq(DeviceEntity::getBoundStatus, true));
|
|
|
+ wrapper);
|
|
|
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO)
|
|
|
.peek(device -> {
|
|
|
device.setStatus(deviceRedisService.checkDeviceOnline(device.getDeviceSn()));
|