From dfa4234bc115918a753b67f5980828a0903c6004 Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Mon, 24 Nov 2025 12:26:58 +0800
Subject: [PATCH] 2025-11-24 zwy 加日志打印,测试用,注释掉取消航线对航线任务状态的限制。

---
 ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java |  101 +++++++++++++++++++++++++++-----------------------
 1 files changed, 54 insertions(+), 47 deletions(-)

diff --git a/ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java b/ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java
index dfb1352..4237b35 100644
--- a/ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java
+++ b/ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -231,11 +231,11 @@
 //                        .fingerprint(waylineFile.get().getSign())
                         .fingerprint(md5)
                         .build())
-                .simulateMission(WaylineSimulateMissionDTO.builder()
-                        .isEnable(1)
-                        .latitude(46.558831038)
-                        .longitude(125.148072319)
-                        .build())
+//                .simulateMission(WaylineSimulateMissionDTO.builder()
+//                        .isEnable(1)
+//                        .latitude(46.558831038)
+//                        .longitude(125.148072319)
+//                        .build())
                 .build();
 
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT +
@@ -263,20 +263,20 @@
 
         // 飞行命令先注释掉
         // 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();
     }
@@ -303,7 +303,10 @@
         try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) {
             md5 = DigestUtils.md5Hex(inputStream);
             url = new URL(ardRouteOpt.getPath());
+            log.info("机场任务航线文件url地址:{}", url);
+            log.info("机场任务航线文件md5值:{}", md5);
         } catch (Exception e) {
+            log.error("机场任务航线文件地址错误!{}", e.getMessage());
             return ResponseResult.error("机场任务航线文件地址错误!" + e.getMessage());
         }
 
@@ -319,11 +322,11 @@
 //                        .fingerprint(waylineFile.get().getSign())
                         .fingerprint(md5)
                         .build())
-                .simulateMission(WaylineSimulateMissionDTO.builder()
-                        .isEnable(1)
-                        .latitude(46.558831038)
-                        .longitude(125.148072319)
-                        .build())
+//                .simulateMission(WaylineSimulateMissionDTO.builder()
+//                        .isEnable(1)
+//                        .latitude(46.558831038)
+//                        .longitude(125.148072319)
+//                        .build())
                 .build();
 
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT +
@@ -338,6 +341,8 @@
 
         ServiceReply serviceReply = messageSender.publishWithReply(topic, response);
         log.info("下发任务结果: {}", serviceReply.getResult());
+        log.info("机场任务航线文件url地址:{}", url);
+        log.info("机场任务航线文件md5值:{}", md5);
         if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) {
             log.info("Prepare task ====> Error code: {}", serviceReply.getResult());
             this.updateJob(WaylineJobDTO.builder()
@@ -351,20 +356,20 @@
 
         // 飞行命令先注释掉
         // 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();
     }
@@ -436,14 +441,14 @@
     public void cancelFlightTask(Collection<String> jobIds) {
         List<WaylineJobDTO> waylineJobs = getJobsByConditions(jobIds, WaylineJobStatusEnum.PENDING);
 
-        Set<String> waylineJobIds = waylineJobs.stream().map(WaylineJobDTO::getJobId).collect(Collectors.toSet());
-        // Check if the task status is correct.
-        boolean isErr = !jobIds.removeAll(waylineJobIds) || !jobIds.isEmpty();
-        if (isErr) {
-            throw new IllegalArgumentException("任务开始后,无法取消。" + Arrays.toString(jobIds.toArray()));
-//            throw new IllegalArgumentException("These tasks have an incorrect status and cannot be canceled. "
-//                    + Arrays.toString(jobIds.toArray()));
-        }
+//        Set<String> waylineJobIds = waylineJobs.stream().map(WaylineJobDTO::getJobId).collect(Collectors.toSet());
+//        // Check if the task status is correct.
+//        boolean isErr = !jobIds.removeAll(waylineJobIds) || !jobIds.isEmpty();
+//        if (isErr) {
+//            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.
         Map<String, List<String>> dockJobs = waylineJobs.stream()
@@ -632,6 +637,8 @@
         });
         String jobId = jobIdMap.get(MapKeyConst.FLIGHT_ID);
 
+        log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId);
+
         CommonTopicResponse.CommonTopicResponseBuilder<RequestsReply> builder = CommonTopicResponse.<RequestsReply>builder()
                 .tid(receiver.getTid())
                 .bid(receiver.getBid())
@@ -673,6 +680,7 @@
         try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) {
             md5 = DigestUtils.md5Hex(inputStream);
             url = new URL(ardRouteOpt.getPath());
+            log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId + " 返回信息为url:" + url.toString() + " md5:" + md5);
 //        }
 //        try {
 //            url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId());
@@ -691,7 +699,6 @@
             messageSender.publish(topic, builder.build());
             return;
         }
-
         messageSender.publish(topic, builder.build());
 
     }

--
Gitblit v1.9.3