| | |
| | | new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(param.isFavorited(), WaylineFileEntity::getFavorited, param.isFavorited()) |
| | | .and(param.getTemplateType() != null, wrapper -> { |
| | | for (Integer type : param.getTemplateType()) { |
| | | wrapper.like(WaylineFileEntity::getTemplateTypes, type).or(); |
| | | } |
| | | .and(param.getTemplateType() != null, wrapper -> { |
| | | for (Integer type : param.getTemplateType()) { |
| | | wrapper.like(WaylineFileEntity::getTemplateTypes, type).or(); |
| | | } |
| | | }) |
| | | // There is a risk of SQL injection |
| | | .last(StringUtils.hasText(param.getOrderBy()), " order by " + param.getOrderBy())); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getPatchesId(String waylineId) { |
| | | WaylineFileEntity entity = mapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)); |
| | | return entity.getPatchesId(); |
| | | } |
| | | |
| | | @Override |
| | | public Optional<WaylineFileDTO> getWaylineByWaylineId(String workspaceId, String waylineId) { |
| | | return Optional.ofNullable( |
| | | this.entityConvertToDTO( |
| | | mapper.selectOne( |
| | | new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)))); |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)))); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public List<String> getDuplicateNames(String workspaceId, List<String> names) { |
| | | return mapper.selectList(new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .in(WaylineFileEntity::getName, names)) |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .in(WaylineFileEntity::getName, names)) |
| | | .stream() |
| | | .map(WaylineFileEntity::getName) |
| | | .collect(Collectors.toList()); |
| | |
| | | } |
| | | WaylineFileDTO wayline = waylineOpt.get(); |
| | | boolean isDel = mapper.delete(new LambdaUpdateWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)) |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)) |
| | | > 0; |
| | | if (!isDel) { |
| | | return false; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void importKmzFile(MultipartFile file, String workspaceId, String creator,String patchesId) { |
| | | public String importKmzFile(MultipartFile file, String workspaceId, String creator, String patchesId, String spotInFreckle) { |
| | | Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file); |
| | | if (waylineFileOpt.isEmpty()) { |
| | | throw new RuntimeException("文件格式错误"); |
| | | } |
| | | |
| | | String back = null; |
| | | try { |
| | | WaylineFileDTO waylineFile = waylineFileOpt.get(); |
| | | waylineFile.setWaylineId(workspaceId); |
| | | waylineFile.setUsername(creator); |
| | | |
| | | ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); |
| | | this.saveWaylineFiles(workspaceId, waylineFile,patchesId); |
| | | waylineFile.setSpotInFreckle(spotInFreckle); |
| | | back = ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); |
| | | if (back==null) { |
| | | this.saveWaylineFiles(workspaceId, waylineFile, patchesId); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return back; |
| | | } |
| | | |
| | | @Override |
| | | public WaylineFileDTO importKmzFileBack(MultipartFile file, String workspaceId, String creator) { |
| | | WaylineFileDTO waylineFile=null; |
| | | WaylineFileDTO waylineFile = null; |
| | | Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file); |
| | | if (waylineFileOpt.isEmpty()) { |
| | | throw new RuntimeException("文件格式错误"); |
| | |
| | | waylineFile = waylineFileOpt.get(); |
| | | waylineFile.setWaylineId(workspaceId); |
| | | waylineFile.setUsername(creator); |
| | | |
| | | ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); |
| | | this.saveWaylineFile(workspaceId, waylineFile); |
| | | |
| | |
| | | |
| | | @Override |
| | | public WaylineFileEntity selectByName(String name) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getName,name)); |
| | | return mapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getName, name)); |
| | | } |
| | | |
| | | @Override |
| | | public List<WaylineListDTO> waylineList(String workspaceId,String droneName) { |
| | | public List<WaylineListDTO> waylineList(String workspaceId, String droneName) { |
| | | LambdaQueryChainWrapper<WaylineFileEntity> wrapper = |
| | | new LambdaQueryChainWrapper<>(mapper).eq(WaylineFileEntity::getWorkspaceId, workspaceId); |
| | | if (StringUtils.hasText(droneName)){ |
| | | wrapper.like(WaylineFileEntity::getName,droneName); |
| | | if (StringUtils.hasText(droneName)) { |
| | | wrapper.like(WaylineFileEntity::getName, droneName); |
| | | } |
| | | |
| | | return wrapper.list().stream().map(r -> WaylineListDTO.builder().waylineFileId(r.getWaylineId()).name(r.getName()).build()) |
| | | return wrapper.list().stream().map(r -> WaylineListDTO.builder().waylineFileId(r.getWaylineId()).name(r.getName()).build()) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | |
| | | |
| | | return Optional.of(WaylineFileDTO.builder() |
| | | .droneModelKey(String.format("%s-%s-%s", DeviceDomainEnum.SUB_DEVICE.getVal(), type, subType)) |
| | | .payloadModelKeys(List.of(String.format("%s-%s-%s",DeviceDomainEnum.PAYLOAD.getVal(), payloadType, payloadSubType))) |
| | | .payloadModelKeys(List.of(String.format("%s-%s-%s", DeviceDomainEnum.PAYLOAD.getVal(), payloadType, payloadSubType))) |
| | | // .objectKey(OssConfiguration.objectDirPrefix + File.separator + filename) |
| | | .objectKey(OssConfiguration.objectDirPrefix + "/" + filename) |
| | | .name(filename.substring(0, filename.lastIndexOf(WAYLINE_FILE_SUFFIX))) |
| | |
| | | } |
| | | return Optional.empty(); |
| | | } |
| | | |
| | | /** |
| | | * Convert database entity objects into wayline data transfer object. |
| | | * |
| | | * @param entity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Convert the received wayline object into a database entity object. |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | |
| | | .favorited(file.getFavorited()) |
| | | .sign(file.getSign()) |
| | | .patchesId(file.getPatchesId()) |
| | | .spotInFreckle(file.getSpotInFreckle()) |
| | | .build(); |
| | | } |
| | | |
| | | return builder.build(); |
| | | } |
| | | |
| | | @Override |
| | | public int updateWayline(WaylineFileEntity entity) { |
| | | return mapper.update(entity,new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWaylineId,entity.getWaylineId())); |
| | | return mapper.update(entity, new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWaylineId, entity.getWaylineId())); |
| | | } |
| | | } |