| | |
| | | } |
| | | Optional<WaylineJobDTO> waylineJobOpt = this.createWaylineJob(param, loginUser.getUsername(), |
| | | param.getExecuteTime(), param.getExecuteTime()); |
| | | if (waylineJobOpt.isEmpty()) { |
| | | return ResponseResult.error("创建机场任务失败!"); |
| | | } |
| | | // 循环任务 |
| | | if (param.getTaskType() == WaylineTaskTypeEnum.LOOP.getVal()) { |
| | | // 循环任务,不立即执行,由定时任务发布 |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | if (waylineJobOpt.isEmpty()) { |
| | | return ResponseResult.error("创建机场任务失败!"); |
| | | } |
| | | |
| | | WaylineJobDTO waylineJob = waylineJobOpt.get(); |
| | |
| | | .build(); |
| | | |
| | | ServiceReply serviceReply = messageSender.publishWithReply(topic, response); |
| | | log.info("下发任务结果: {}", serviceReply.getResult()); |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Prepare task ====> Error code: {}", serviceReply.getResult()); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | |
| | | |
| | | // 飞行命令先注释掉 |
| | | // Issue an immediate task execution command. |
| | | // if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | // if (!executeFlightTask(waylineJob.getJobId())) { |
| | | // return ResponseResult.error("Failed to execute job."); |
| | | // } |
| | | // } |
| | | // |
| | | // if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | // boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | // waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | // waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | // if (!isAdd) { |
| | | // return ResponseResult.error("Failed to create scheduled job."); |
| | | // } |
| | | // } |
| | | if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | if (!executeFlightTask(waylineJob.getJobId())) { |
| | | return ResponseResult.error("Failed to execute job."); |
| | | } |
| | | } |
| | | |
| | | if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | if (!isAdd) { |
| | | return ResponseResult.error("Failed to create scheduled job."); |
| | | } |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | .build(); |
| | | |
| | | ServiceReply serviceReply = messageSender.publishWithReply(topic, response); |
| | | log.info("下发任务结果: {}", serviceReply.getResult()); |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | log.info("Prepare task ====> Error code: {}", serviceReply.getResult()); |
| | | this.updateJob(WaylineJobDTO.builder() |
| | |
| | | |
| | | // 飞行命令先注释掉 |
| | | // Issue an immediate task execution command. |
| | | // if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | // if (!executeFlightTask(waylineJob.getJobId())) { |
| | | // return ResponseResult.error("Failed to execute job."); |
| | | // } |
| | | // } |
| | | // |
| | | // if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | // boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | // waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | // waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | // if (!isAdd) { |
| | | // return ResponseResult.error("Failed to create scheduled job."); |
| | | // } |
| | | // } |
| | | if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) { |
| | | if (!executeFlightTask(waylineJob.getJobId())) { |
| | | return ResponseResult.error("Failed to execute job."); |
| | | } |
| | | } |
| | | |
| | | if (WaylineTaskTypeEnum.TIMED.getVal() == waylineJob.getTaskType()) { |
| | | boolean isAdd = RedisOpsUtils.zAdd(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, |
| | | waylineJob.getDockSn() + RedisConst.DELIMITER + waylineJob.getJobId(), |
| | | waylineJob.getBeginTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | if (!isAdd) { |
| | | return ResponseResult.error("Failed to create scheduled job."); |
| | | } |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | // Check if the task status is correct. |
| | | boolean isErr = !jobIds.removeAll(waylineJobIds) || !jobIds.isEmpty(); |
| | | if (isErr) { |
| | | throw new IllegalArgumentException("These tasks have an incorrect status and cannot be canceled. " |
| | | + Arrays.toString(jobIds.toArray())); |
| | | throw new IllegalArgumentException("任务开始后,无法取消。" + Arrays.toString(jobIds.toArray())); |
| | | // throw new IllegalArgumentException("These tasks have an incorrect status and cannot be canceled. " |
| | | // + Arrays.toString(jobIds.toArray())); |
| | | } |
| | | |
| | | // Group job id by dock sn. |
| | |
| | | new Page<WaylineJobEntity>(page, pageSize), |
| | | new LambdaQueryWrapper<WaylineJobEntity>() |
| | | // 实际开始时间筛选,允许为空,为空则不进行筛选 |
| | | .ge(startTime != null, WaylineJobEntity::getExecuteTime, startTime) |
| | | .le(endTime != null, WaylineJobEntity::getExecuteTime, endTime) |
| | | .ge(startTime != null, WaylineJobEntity::getBeginTime, startTime) |
| | | .le(endTime != null, WaylineJobEntity::getBeginTime, endTime) |
| | | // 任务类型筛选,允许为空,为空则不进行筛选 |
| | | .eq(taskType != null, WaylineJobEntity::getTaskType, taskType) |
| | | // 任务名称筛选,允许为空,为空则不进行筛选;....模糊查询 |
| | |
| | | return null; |
| | | } |
| | | // 修改航线文件名称,从ard_route_info航线表中取; |
| | | String fileId = entity.getFileId(); |
| | | String fileName = ""; |
| | | try { |
| | | if (fileId != null) { |
| | | ArdRouteInfo ardRouteInfo = _ardRouteInfoService.selectArdRouteInfoById(fileId); |
| | | if (ardRouteInfo != null) { |
| | | fileName = Optional.ofNullable(ardRouteInfo.getName()).orElse(""); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) { |
| | | log.info("获取航线名称失败,fileId:{},异常原因:{}", fileId,e.getMessage()); |
| | | fileName = ""; |
| | | } |
| | | WaylineJobDTO.WaylineJobDTOBuilder builder = WaylineJobDTO.builder() |
| | | .jobId(entity.getJobId()) |
| | | .jobName(entity.getName()) |
| | | .fileId(entity.getFileId()) |
| | | // .fileName(waylineFileService.getWaylineByWaylineId(entity.getFileId()) |
| | | // .orElse(WaylineFileDTO.builder().build()).getName()) |
| | | .fileName(_ardRouteInfoService.selectArdRouteInfoById(entity.getFileId()) |
| | | .getName()) |
| | | .fileName(fileName) |
| | | .dockSn(entity.getDockSn()) |
| | | .dockName(deviceService.getDeviceBySn(entity.getDockSn()) |
| | | .orElse(DeviceDTO.builder().build()).getNickname()) |