|
|
@ -5,9 +5,11 @@ 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 org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.*; |
|
|
|
import org.dromara.common.sdk.cloudapi.firmware.*; |
|
|
|
import org.dromara.common.sdk.cloudapi.firmware.api.AbstractFirmwareService; |
|
|
|
import org.dromara.common.sdk.cloudapi.livestream.VideoTypeEnum; |
|
|
|
import org.dromara.common.sdk.cloudapi.property.api.AbstractPropertyService; |
|
|
|
import org.dromara.common.sdk.cloudapi.tsa.DeviceIconUrl; |
|
|
|
import org.dromara.common.sdk.cloudapi.tsa.TopologyDeviceModel; |
|
|
@ -45,6 +47,7 @@ import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.dromara.sample.websocket.service.IWebSocketMessageService; |
|
|
|
import org.dromara.system.api.model.LoginUser; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -58,6 +61,9 @@ import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static org.dromara.common.core.utils.StringUtils.DASH; |
|
|
|
import static org.dromara.common.core.utils.StringUtils.SLASH; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @author sean.zhou |
|
|
@ -132,6 +138,9 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
@Autowired |
|
|
|
private IDeviceProMapper deviceProMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDeviceProService deviceProService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void subDeviceOffline(String deviceSn) { |
|
|
|
// If no information about this device exists in the cache, the drone is considered to be offline.
|
|
|
@ -221,21 +230,28 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
} |
|
|
|
}) |
|
|
|
.eq(StringUtils.hasText(param.getWorkspaceId()), |
|
|
|
DeviceEntity::getWorkspaceId, param.getWorkspaceId()) |
|
|
|
DeviceEntity::getWorkspaceId, param.getWorkspaceId()) |
|
|
|
.eq(param.getBoundStatus() != null, DeviceEntity::getBoundStatus, param.getBoundStatus()) |
|
|
|
.in(ObjectUtil.isAllNotEmpty(param.getProIds()), |
|
|
|
DeviceEntity::getProId, param.getProIds()) |
|
|
|
.orderBy(param.isOrderBy(), |
|
|
|
param.isAsc(), DeviceEntity::getId)) |
|
|
|
param.isAsc(), DeviceEntity::getId)) |
|
|
|
.stream() |
|
|
|
.map(this::deviceEntityConvertToDTO) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname) { |
|
|
|
public List<DeviceDTO> getDevicesTopoForWeb(String workspaceId,String nickname,List<Integer> proIds) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
if(proIds == null){ |
|
|
|
proIds = deviceProService.listDeviceGroup(loginUser.getUserId()); |
|
|
|
} |
|
|
|
List<DeviceDTO> devicesList = this.getDevicesByParams( |
|
|
|
DeviceQueryParam.builder() |
|
|
|
.workspaceId(workspaceId) |
|
|
|
.domains(List.of(DeviceDomainEnum.REMOTER_CONTROL.getDomain(), DeviceDomainEnum.DOCK.getDomain())) |
|
|
|
.proIds(proIds) |
|
|
|
.build()); |
|
|
|
|
|
|
|
devicesList.stream() |
|
|
@ -258,14 +274,15 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
|
|
|
|
DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0); |
|
|
|
subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn())); |
|
|
|
List<CapacityCameraDTO> capacityCameraByDeviceSn = capacityCameraService.getCapacityCameraByDeviceSn(gateway.getChildDeviceSn()); |
|
|
|
/*List<CapacityCameraDTO> capacityCameraByDeviceSn = capacityCameraService.getCapacityCameraByDeviceSn(gateway.getChildDeviceSn()); |
|
|
|
String videoId = ""; |
|
|
|
if(capacityCameraByDeviceSn != null && capacityCameraByDeviceSn.size() > 0 ){ |
|
|
|
if(capacityCameraByDeviceSn.get(0).getVideosList().size() > 0){ |
|
|
|
videoId = gateway.getChildDeviceSn() + "/" + capacityCameraByDeviceSn.get(0).getIndex() + "/" + capacityCameraByDeviceSn.get(0).getVideosList().get(0).getIndex(); |
|
|
|
} |
|
|
|
} |
|
|
|
subDevice.setVideoId(videoId); |
|
|
|
}*/ |
|
|
|
String deviceVideoEnum = DeviceVideoEnum.find(subDevice.getDeviceName()).getDevice(); |
|
|
|
subDevice.setVideoId(new VideoId(subDevice.getDeviceSn()+SLASH+deviceVideoEnum+SLASH + VideoTypeEnum.NORMAL.getType() + DASH+DeviceTypeVideoEnum.ZERO.getVideoType()).toString()); |
|
|
|
gateway.setChildren(subDevice); |
|
|
|
// gateway.setVideoId(DeviceEnum.videoId);
|
|
|
|
// payloads
|
|
|
@ -405,7 +422,8 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
.map(WorkspaceDTO::getWorkspaceName).orElse("") : "") |
|
|
|
.firmwareStatus(DeviceFirmwareStatusEnum.NOT_UPGRADE) |
|
|
|
.videoId(dockVideoId) |
|
|
|
.thingVersion(entity.getVersion()).proId(ObjectUtil.isNotEmpty(entity.getProId())?String.valueOf(entity.getProId()):"").build(); |
|
|
|
.proId(ObjectUtil.isNotEmpty(entity.getProId())?entity.getProId():null) |
|
|
|
.thingVersion(entity.getVersion()).build(); |
|
|
|
} catch (CloudSDKException e) { |
|
|
|
log.error(e.getLocalizedMessage() + "Entity: {}", entity); |
|
|
|
} |
|
|
@ -495,13 +513,14 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public PaginationData<DeviceDTO> getBoundDevicesWithDomain(String workspaceId, Long page, |
|
|
|
Long pageSize, Integer domain,String nickname) { |
|
|
|
Long pageSize, Integer domain,String nickname,List<Integer> proIds) { |
|
|
|
|
|
|
|
Page<DeviceEntity> pagination = mapper.selectPage(new Page<>(page, pageSize), |
|
|
|
new LambdaQueryWrapper<DeviceEntity>() |
|
|
|
.eq(DeviceEntity::getDomain, domain) |
|
|
|
.eq(DeviceEntity::getWorkspaceId, workspaceId) |
|
|
|
.eq(DeviceEntity::getBoundStatus, true) |
|
|
|
.in(ObjectUtil.isAllNotEmpty(proIds),DeviceEntity::getProId, proIds) |
|
|
|
.eq(org.dromara.common.core.utils.StringUtils.isNotEmpty(nickname),DeviceEntity::getNickname,nickname)); |
|
|
|
List<DeviceDTO> devicesList = pagination.getRecords().stream().map(this::deviceEntityConvertToDTO) |
|
|
|
.peek(device -> { |
|
|
@ -728,7 +747,8 @@ public class DeviceServiceImpl implements IDeviceService { |
|
|
|
.firmwareVersion(dto.getFirmwareVersion()) |
|
|
|
.compatibleStatus(dto.getFirmwareStatus() == null ? null : |
|
|
|
DeviceFirmwareStatusEnum.CONSISTENT_UPGRADE != dto.getFirmwareStatus()) |
|
|
|
.deviceDesc(dto.getDeviceDesc()).proId(ObjectUtil.isNotEmpty(dto.getProId())?Integer.valueOf(dto.getProId()):null) |
|
|
|
.deviceDesc(dto.getDeviceDesc()) |
|
|
|
.proId(dto.getProId() == null ? null : dto.getProId()) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
} |
|
|
|