|
|
@ -17,6 +17,7 @@ import org.dom4j.io.SAXReader; |
|
|
|
import org.dromara.common.oss.core.OssClient; |
|
|
|
import org.dromara.common.oss.entity.UploadResult; |
|
|
|
import org.dromara.common.oss.factory.OssFactory; |
|
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceDomainEnum; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceEnum; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceSubTypeEnum; |
|
|
@ -28,6 +29,8 @@ import org.dromara.common.sdk.common.Pagination; |
|
|
|
import org.dromara.common.sdk.common.PaginationData; |
|
|
|
import org.dromara.resource.api.RemoteFileService; |
|
|
|
import org.dromara.resource.api.domain.RemoteFile; |
|
|
|
import org.dromara.sample.manage.service.IDeviceProService; |
|
|
|
import org.dromara.sample.manage.service.IDeviceRedisService; |
|
|
|
import org.dromara.sample.wayline.mapper.IAudioFileMapper; |
|
|
|
import org.dromara.sample.wayline.mapper.IWaylineFileMapper; |
|
|
|
import org.dromara.sample.wayline.model.dto.KmzFileProperties; |
|
|
@ -35,6 +38,7 @@ import org.dromara.sample.wayline.model.dto.WaylineFileDTO; |
|
|
|
import org.dromara.sample.wayline.model.entity.AudioFileEntity; |
|
|
|
import org.dromara.sample.wayline.model.entity.WaylineFileEntity; |
|
|
|
import org.dromara.sample.wayline.service.IWaylineFileService; |
|
|
|
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; |
|
|
@ -77,9 +81,21 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
|
@DubboReference |
|
|
|
private RemoteFileService remoteFileService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDeviceProService deviceProService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDeviceRedisService deviceRedisService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PaginationData<GetWaylineListResponse> getWaylinesByParam(String workspaceId, GetWaylineListRequest param,List<Integer> proIds) { |
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser(); |
|
|
|
if(proIds == null){ |
|
|
|
proIds = deviceProService.listDeviceGroup(loginUser.getUserId()); |
|
|
|
} |
|
|
|
// Paging Query
|
|
|
|
List<Integer> finalProIds = proIds; |
|
|
|
Page<WaylineFileEntity> page = mapper.selectPage( |
|
|
|
new Page<WaylineFileEntity>(param.getPage(), param.getPageSize()), |
|
|
|
new LambdaQueryWrapper<WaylineFileEntity>() |
|
|
@ -104,7 +120,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
|
wrapper.eq(WaylineFileEntity::getDeviceSn, param.getDeviceSn()).or(); |
|
|
|
}) |
|
|
|
.and(ObjectUtil.isAllNotEmpty(proIds), wrapper -> { |
|
|
|
wrapper.in(WaylineFileEntity::getProId, proIds).or(); |
|
|
|
wrapper.in(WaylineFileEntity::getProId, finalProIds); |
|
|
|
}) |
|
|
|
.like(Objects.nonNull(param.getKey()), WaylineFileEntity::getName, param.getKey()) |
|
|
|
// There is a risk of SQL injection
|
|
|
@ -118,6 +134,24 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
|
return new PaginationData<>(records, new Pagination(page.getCurrent(), page.getSize(), page.getTotal())); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GetWaylineListResponse> getWaylinesByParamList(String workspaceId,Integer proId) { |
|
|
|
|
|
|
|
List<WaylineFileEntity> waylineFileEntities = mapper.selectList( |
|
|
|
new LambdaQueryWrapper<WaylineFileEntity>() |
|
|
|
.eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
|
|
|
.eq(WaylineFileEntity::getProId, proId) |
|
|
|
// There is a risk of SQL injection
|
|
|
|
.orderByDesc(WaylineFileEntity::getCreateTime)); |
|
|
|
|
|
|
|
// Wrap the results of a paging query into a custom paging object.
|
|
|
|
List<GetWaylineListResponse> records = waylineFileEntities |
|
|
|
.stream() |
|
|
|
.map(this::entityConvertToDTO) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
return records; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Optional<GetWaylineListResponse> getWaylineByWaylineId(String workspaceId, String waylineId) { |
|
|
|
return Optional.ofNullable( |
|
|
@ -207,6 +241,9 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void importKmzFile(MultipartFile file, String workspaceId, String creator,String deviceSn,Integer proId) { |
|
|
|
if(ObjectUtil.isNull(proId)){ |
|
|
|
proId = deviceRedisService.getDeviceOnline(deviceSn).get().getProId(); |
|
|
|
} |
|
|
|
Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file); |
|
|
|
if (waylineFileOpt.isEmpty()) { |
|
|
|
throw new RuntimeException("文件格式不正确。"); |
|
|
|