From 5b7a703cc14ecf2dfffc071b558371e3adf4278e Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Wed, 26 Nov 2025 14:12:06 +0800
Subject: [PATCH] 2025-11-26 zwy 替换http路径

---
 ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java |  177 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 125 insertions(+), 52 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..07f3ba4 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
@@ -133,6 +133,7 @@
                 .waylineType(param.getWaylineType())
                 .outOfControlAction(param.getOutOfControlAction())
                 .rthAltitude(param.getRthAltitude())
+                .rthMode(param.getRth_mode())
                 .mediaCount(0)
                 .parentId(param.getParentId())
                 .loopSum(param.getLoopSum())
@@ -177,6 +178,7 @@
         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());
         // 循环任务
@@ -215,9 +217,14 @@
         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());
         }
+
+        log.info("机场任务-rth_mode的值:{}", waylineJob.getRthMode());
 
         WaylineTaskCreateDTO flightTask = WaylineTaskCreateDTO.builder()
                 .flightId(waylineJob.getJobId())
@@ -226,16 +233,19 @@
                 .waylineType(waylineJob.getWaylineType())
                 .rthAltitude(waylineJob.getRthAltitude())
                 .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())
+                        .url(url.toString().replace("https://", "http://")
+                                .replace("9001", "9011"))
                         .fingerprint(md5)
                         .build())
-                .simulateMission(WaylineSimulateMissionDTO.builder()
-                        .isEnable(1)
-                        .latitude(46.558831038)
-                        .longitude(125.148072319)
-                        .build())
+//                .simulateMission(WaylineSimulateMissionDTO.builder()
+//                        .isEnable(1)
+//                        .latitude(46.55819013988211)
+//                        .longitude(125.14652370145113)
+//                        .build())
                 .build();
 
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT +
@@ -248,8 +258,19 @@
                 .method(WaylineMethodEnum.FLIGHT_TASK_PREPARE.getMethod())
                 .build();
 
+        // 下发参数打印
+        try{
+            String json = objectMapper.writeValueAsString(response);
+            log.info("机场下发航线任务的参数response:{}", json);
+        }
+        catch (Exception e){
+            log.error("机场下发航线任务的参数response异常:{}", e.getMessage());
+        }
+
         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()
@@ -263,20 +284,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 +324,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,12 +343,21 @@
 //                        .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();
+
+        // 下发参数打印
+        try{
+            String json = objectMapper.writeValueAsString(flightTask);
+            log.info("机场下发航线任务的参数flightTask:{}", json);
+        }
+        catch (Exception e){
+            log.error("机场下发航线任务的参数flightTask异常:{}", e.getMessage());
+        }
 
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT +
                 waylineJob.getDockSn() + TopicConst.SERVICES_SUF;
@@ -337,7 +370,11 @@
                 .build();
 
         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 +388,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();
     }
@@ -392,7 +429,7 @@
 
         WaylineJobDTO job = waylineJob.get();
         WaylineTaskCreateDTO flightTask = WaylineTaskCreateDTO.builder().flightId(jobId).build();
-
+        // flightTask中,只有任务id是有值的,其他字段不返回
         String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT +
                 job.getDockSn() + TopicConst.SERVICES_SUF;
         CommonTopicResponse<Object> response = CommonTopicResponse.builder()
@@ -403,7 +440,19 @@
                 .method(WaylineMethodEnum.FLIGHT_TASK_EXECUTE.getMethod())
                 .build();
 
+        // 下发参数打印
+        try{
+            String json = objectMapper.writeValueAsString(response);
+            log.info("机场下发-执行飞行任务-的参数response:{}", json);
+        }
+        catch (Exception e){
+            log.error("机场下发-执行飞行任务-的参数response异常:{}", e.getMessage());
+        }
+
         ServiceReply serviceReply = messageSender.publishWithReply(topic, response);
+
+        log.info("下发-执行飞行任务-结果: {}", serviceReply.getResult());
+
         if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) {
             log.info("Execute job ====> Error code: {}", serviceReply.getResult());
             this.updateJob(WaylineJobDTO.builder()
@@ -436,14 +485,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 +681,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,23 +724,44 @@
         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());
 //            url = new URL(ardRouteOpt.getUpPath());
+
+//            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);
+
             builder.data(RequestsReply.success(WaylineTaskCreateDTO.builder()
                     .file(WaylineTaskFileDTO.builder()
-                            .url(url.toString())
-//                            .fingerprint(waylineFile.get().getSign())
-                            .fingerprint(md5)
-                            .build())
+                    .url(url.toString().replace("https://", "http://")
+                            .replace("9001", "9011"))
+                    .fingerprint(md5)
+                    .build())
                     .build()));
+
+//            WaylineTaskFileDTO.builder()
+//                    .url(url.toString())
+////                            .fingerprint(waylineFile.get().getSign())
+//                    .fingerprint(md5)
+//                    .build()
 
         } catch (NullPointerException | IOException e) {
             e.printStackTrace();
             builder.data(RequestsReply.error(CommonErrorEnum.ILLEGAL_ARGUMENT));
             messageSender.publish(topic, builder.build());
             return;
+        }
+
+        // 下发参数打印
+        try{
+            String json = objectMapper.writeValueAsString(builder.build());
+            log.info("机场通过flighttask_resource_get获取航线文件的参数flightTask:{}", json);
+        }
+        catch (Exception e){
+            log.error("机场通过flighttask_resource_get获取航线文件的参数flightTask异常:{}", e.getMessage());
         }
 
         messageSender.publish(topic, builder.build());
@@ -819,6 +891,7 @@
                 .taskType(entity.getTaskType())
                 .waylineType(entity.getWaylineType())
                 .rthAltitude(entity.getRthAltitude())
+                .rthMode(entity.getRthMode())
                 .outOfControlAction(entity.getOutOfControlAction())
                 .mediaCount(entity.getMediaCount())
                 .loopSum(entity.getLoopSum());

--
Gitblit v1.9.3