| | |
| | | package com.ard.sample.wayline.service.impl; |
| | | |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.ossdock.service.impl.OssDockServiceContext; |
| | | import com.ard.route.domain.route.ArdRouteInfo; |
| | | import com.ard.route.service.IArdRouteInfoService; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | |
| | | private IArdRouteInfoService _ardRouteInfoService; |
| | | |
| | | @Resource |
| | | private OssServiceContext _ossService; |
| | | private OssDockServiceContext _ossService; |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | |
| | | if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == param.getTaskType()) { |
| | | param.setExecuteTime(System.currentTimeMillis()); |
| | | } |
| | | param.setRth_mode(1); |
| | | Optional<WaylineJobDTO> waylineJobOpt = this.createWaylineJob(param, loginUser.getUsername(), |
| | | param.getExecuteTime(), param.getExecuteTime()); |
| | | // 循环任务 |
| | |
| | | // get file url |
| | | // URL url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId()); |
| | | URL url = null; |
| | | String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath()); |
| | | String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath1()); |
| | | String md5 = ""; |
| | | try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) { |
| | | md5 = DigestUtils.md5Hex(inputStream); |
| | | url = new URL(ardRouteOpt.getPath()); |
| | | url = new URL(ardRouteOpt.getPath1()); |
| | | log.info("机场任务航线文件url地址:{}", url); |
| | | log.info("机场任务航线文件md5值:{}", md5); |
| | | } catch (Exception e) { |
| | |
| | | .outOfControlAction(waylineJob.getOutOfControlAction()) |
| | | .rthMode(waylineJob.getRthMode()) |
| | | .file(WaylineTaskFileDTO.builder() |
| | | .url(url.toString()) |
| | | // .url(url.toString().replace("https://192.168.10.103:9001", "http://192.168.10.103:9011")) |
| | | // .fingerprint(waylineFile.get().getSign()) |
| | | // .replace("https://", "http://") |
| | | // .replace("9001", "9011") |
| | | .url(url.toString()) |
| | | .fingerprint(md5) |
| | | .build()) |
| | | // .simulateMission(WaylineSimulateMissionDTO.builder() |
| | | // .isEnable(1) |
| | | // .latitude(46.558831038) |
| | | // .longitude(125.148072319) |
| | | // .latitude(46.55819013988211) |
| | | // .longitude(125.14652370145113) |
| | | // .build()) |
| | | .build(); |
| | | |
| | |
| | | return Optional.ofNullable(entity2Dto(jobEntity)); |
| | | } |
| | | |
| | | public List<WaylineJobDTO> getJobByJobParentId(String parentId) { |
| | | List<WaylineJobEntity> jobEntities = mapper.selectList( |
| | | new LambdaQueryWrapper<WaylineJobEntity>() |
| | | .eq(WaylineJobEntity::getParentId, parentId)); |
| | | if (CollectionUtils.isEmpty(jobEntities)) { |
| | | return Collections.emptyList(); // 返回不可变空列表,更安全 |
| | | } |
| | | return jobEntities.stream() |
| | | .map(this::entity2Dto) // 调用原有的单个转换方法 |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 更新作业信息 |
| | | * |
| | |
| | | Page<WaylineJobEntity> pageData = mapper.selectPage( |
| | | new Page<WaylineJobEntity>(page, pageSize), |
| | | new LambdaQueryWrapper<WaylineJobEntity>() |
| | | .isNull(WaylineJobEntity::getParentId) |
| | | // 实际开始时间筛选,允许为空,为空则不进行筛选 |
| | | .ge(startTime != null, WaylineJobEntity::getBeginTime, startTime) |
| | | .le(endTime != null, WaylineJobEntity::getBeginTime, endTime) |
| | |
| | | .ne(isComplete != null && !isComplete, WaylineJobEntity::getStatus, 3) |
| | | // 任务状态筛选,允许为空,为空则不进行筛选 |
| | | .eq(status != null, WaylineJobEntity::getStatus, status) |
| | | .orderByDesc(WaylineJobEntity::getId)); |
| | | .orderByDesc(WaylineJobEntity::getBeginTime)); |
| | | List<WaylineJobDTO> records = pageData.getRecords() |
| | | .stream() |
| | | .map(this::entity2Dto) |
| | | .peek(job -> { |
| | | List<WaylineJobDTO> parentOpt = this.getJobByJobParentId(job.getJobId()); |
| | | job.setParentJobs(parentOpt); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return new PaginationData<WaylineJobDTO>(records, new Pagination(pageData)); |
| | |
| | | |
| | | // get file url |
| | | URL url = null; |
| | | String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath()); |
| | | String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath1()); |
| | | String md5 = ""; |
| | | try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) { |
| | | md5 = DigestUtils.md5Hex(inputStream); |
| | | url = new URL(ardRouteOpt.getPath()); |
| | | url = new URL(ardRouteOpt.getPath1()); |
| | | log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId + " 返回信息为url:" + url.toString() + " md5:" + md5); |
| | | // } |
| | | // try { |
| | | // url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId()); |
| | | // url = new URL(ardRouteOpt.getUpPath()); |
| | | |
| | | Map<String, Object> jsonResourceGet = new HashMap<>(); |
| | | jsonResourceGet.put("url", url.toString()); |
| | | jsonResourceGet.put("fingerprint", md5); |
| | | // Map<String, Object> jsonResourceGet = new HashMap<>(); |
| | | // jsonResourceGet.put("url", url.toString().replace("https//192.168.10.103:9001", "http//192.168.10.103:9002")); |
| | | // jsonResourceGet.put("fingerprint", md5); |
| | | // .replace("https://", "http://") |
| | | // .replace("9001", "9011") |
| | | |
| | | builder.data(RequestsReply.success(WaylineTaskCreateDTO.builder() |
| | | .file(WaylineTaskFileDTO.builder() |
| | |
| | | .fingerprint(md5) |
| | | .build()) |
| | | .build())); |
| | | |
| | | // WaylineTaskFileDTO.builder() |
| | | // .url(url.toString()) |
| | | //// .fingerprint(waylineFile.get().getSign()) |
| | | // .fingerprint(md5) |
| | | // .build() |
| | | |
| | | } catch (NullPointerException | IOException e) { |
| | | e.printStackTrace(); |