From a5f04d4925f77fd741abecdc37cfc6674894cefe Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Sat, 13 Dec 2025 10:54:04 +0800
Subject: [PATCH] 2025-12-13 zwy 修改机场航线文件取path,转换http地址,配置文件oss去掉endpoint-spare字段,增加dock:endpoint,增加DockConfiguration.java配置文件,删除ossdock模块
---
ard-sample/src/main/java/com/ard/sample/wayline/service/impl/WaylineJobServiceImpl.java | 90 +++++++++++++++++++++++++++++++-------------
1 files changed, 63 insertions(+), 27 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 930ca2e..a4ac847 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
@@ -1,8 +1,10 @@
package com.ard.sample.wayline.service.impl;
-import com.ard.ossdock.service.impl.OssDockServiceContext;
+import com.ard.common.config.OssConfiguration;
+import com.ard.oss.service.impl.OssServiceContext;
import com.ard.route.domain.route.ArdRouteInfo;
import com.ard.route.service.IArdRouteInfoService;
+import com.ard.sample.config.DockConfiguration;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -78,7 +80,7 @@
private IArdRouteInfoService _ardRouteInfoService;
@Resource
- private OssDockServiceContext _ossService;
+ private OssServiceContext _ossService;
@Autowired
private IDeviceService deviceService;
@@ -189,7 +191,7 @@
}
if (waylineJobOpt.isEmpty()) {
- return ResponseResult.error("创建机场任务失败!");
+ return ResponseResult.error(314013000,"创建机场任务失败!");
}
WaylineJobDTO waylineJob = waylineJobOpt.get();
@@ -206,23 +208,26 @@
// }
// 换航线表
ArdRouteInfo ardRouteOpt = _ardRouteInfoService.selectArdRouteInfoById(waylineJob.getFileId());
- if (ardRouteOpt == null) {
- return ResponseResult.error("机场任务航线不存在!");
+ if (ardRouteOpt == null || ardRouteOpt.getPath() == null || ardRouteOpt.getPath().isEmpty()) {
+ return ResponseResult.error(314013001,"机场任务航线不存在!");
}
// get file url
// URL url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId());
URL url = null;
- String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath1());
+ String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath());
String md5 = "";
+ String httpUrl="";
try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) {
md5 = DigestUtils.md5Hex(inputStream);
- url = new URL(ardRouteOpt.getPath1());
- log.info("机场任务航线文件url地址:{}", url);
+ url = new URL(ardRouteOpt.getPath());
+ log.info("机场任务航线文件url地址转换前:{}", url);
+ httpUrl = url.toString().replace(OssConfiguration.endpoint, DockConfiguration.endpoint);
+ log.info("机场任务航线文件url地址转换后:{}", httpUrl);
log.info("机场任务航线文件md5值:{}", md5);
} catch (Exception e) {
log.error("机场任务航线文件地址错误!{}", e.getMessage());
- return ResponseResult.error("机场任务航线文件地址错误!" + e.getMessage());
+ return ResponseResult.error(314013002,"机场任务航线文件地址错误!" + e.getMessage());
}
log.info("机场任务-rth_mode的值:{}", waylineJob.getRthMode());
@@ -240,7 +245,7 @@
// .fingerprint(waylineFile.get().getSign())
// .replace("https://", "http://")
// .replace("9001", "9011")
- .url(url.toString())
+ .url(httpUrl)
.fingerprint(md5)
.build())
// .simulateMission(WaylineSimulateMissionDTO.builder()
@@ -290,7 +295,7 @@
// Issue an immediate task execution command.
if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) {
if (!executeFlightTask(waylineJob.getJobId())) {
- return ResponseResult.error("Failed to execute job.");
+ return ResponseResult.error("无法执行作业。");
}
}
@@ -299,7 +304,7 @@
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.error("无法创建计划作业。");
}
}
@@ -309,7 +314,7 @@
public ResponseResult publishFlightTaskPrepare(Optional<WaylineJobDTO> waylineJobOpt) throws SQLException{
if (waylineJobOpt.isEmpty()) {
- return ResponseResult.error("创建机场任务失败!");
+ return ResponseResult.error(314013000,"创建机场任务失败!");
}
WaylineJobDTO waylineJob = waylineJobOpt.get();
boolean isOnline = deviceService.checkDeviceOnline(waylineJob.getDockSn());
@@ -318,21 +323,24 @@
}
// 换航线表
ArdRouteInfo ardRouteOpt = _ardRouteInfoService.selectArdRouteInfoById(waylineJob.getFileId());
- if (ardRouteOpt == null) {
- return ResponseResult.error("机场任务航线不存在!");
+ if (ardRouteOpt == null || ardRouteOpt.getPath() == null || ardRouteOpt.getPath().isEmpty()) {
+ return ResponseResult.error(314013001,"机场任务航线不存在!");
}
// get file url
URL url = null;
String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath());
String md5 = "";
+ String httpUrl="";
try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) {
md5 = DigestUtils.md5Hex(inputStream);
url = new URL(ardRouteOpt.getPath());
- log.info("机场任务航线文件url地址:{}", url);
+ log.info("机场任务航线文件url地址转换前:{}", url);
+ httpUrl = url.toString().replace(OssConfiguration.endpoint, DockConfiguration.endpoint);
+ log.info("机场任务航线文件url地址转换后:{}", httpUrl);
log.info("机场任务航线文件md5值:{}", md5);
} catch (Exception e) {
log.error("机场任务航线文件地址错误!{}", e.getMessage());
- return ResponseResult.error("机场任务航线文件地址错误!" + e.getMessage());
+ return ResponseResult.error(314013002,"机场任务航线文件地址错误!" + e.getMessage());
}
WaylineTaskCreateDTO flightTask = WaylineTaskCreateDTO.builder()
@@ -342,8 +350,9 @@
.waylineType(waylineJob.getWaylineType())
.rthAltitude(waylineJob.getRthAltitude())
.outOfControlAction(waylineJob.getOutOfControlAction())
+ .rthMode(waylineJob.getRthMode())
.file(WaylineTaskFileDTO.builder()
- .url(url.toString())
+ .url(httpUrl)
// .fingerprint(waylineFile.get().getSign())
.fingerprint(md5)
.build())
@@ -376,7 +385,7 @@
ServiceReply serviceReply = messageSender.publishWithReply(topic, response);
log.info("下发任务结果: {}", serviceReply.getResult());
- log.info("机场任务航线文件url地址:{}", url);
+ log.info("机场任务航线文件url地址:{}", httpUrl);
log.info("机场任务航线文件md5值:{}", md5);
if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) {
@@ -396,7 +405,7 @@
// Issue an immediate task execution command.
if (WaylineTaskTypeEnum.IMMEDIATE.getVal() == waylineJob.getTaskType()) {
if (!executeFlightTask(waylineJob.getJobId())) {
- return ResponseResult.error("Failed to execute job.");
+ return ResponseResult.error("无法执行作业。");
}
}
@@ -405,7 +414,7 @@
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.error("无法创建计划作业。");
}
}
@@ -597,8 +606,17 @@
return ResponseResult.error("任务不存在,jobId: " + jobId);
}
if (waylineJobDTO.get().getTaskType() == 3) {
- // 已经执行完的子任务是否删除,或者清掉父任务ID,和正常任务一起显示在列表中。
+ // 已经执行完的子任务一起全部删除
this.deleteTask(jobId);
+ log.info("删除循环任务已经完成,主任务ID:{}。", waylineJobDTO.get().getJobId());
+ List<WaylineJobDTO> waylineParentIds = this.getJobByJobParentId(jobId);
+ if (!waylineParentIds.isEmpty()) {
+ for (WaylineJobDTO waylineJob : waylineParentIds) {
+ this.deleteTask(waylineJob.getJobId());
+ RedisOpsUtils.zRemove(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, dockSn + RedisConst.DELIMITER + waylineJob.getJobId());
+ log.info("删除循环子任务已经完成,子任务ID:{}。", waylineJob.getJobId());
+ }
+ }
return ResponseResult.success();
}
}
@@ -630,7 +648,7 @@
.status(WaylineJobStatusEnum.CANCEL.getVal())
.completedTime(LocalDateTime.now())
.build());
- RedisOpsUtils.zRemove(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, RedisConst.DELIMITER + dockSn + RedisConst.DELIMITER + jobId);
+ RedisOpsUtils.zRemove(RedisConst.WAYLINE_JOB_TIMED_EXECUTE, dockSn + RedisConst.DELIMITER + jobId);
// 原流程是修改表中数据的status状态值,现在的精力是直接删除
this.deleteTask(jobId);
}
@@ -772,6 +790,18 @@
.orderByDesc(WaylineJobEntity::getId));
}
+ /**
+ * 获取所有待定状态的定时任务,未执行即将要执行的。
+ * */
+ public List<WaylineJobEntity> selectScheduledTaskList(){
+ // "1":"定时任务"
+ return mapper.selectList(new LambdaQueryWrapper<WaylineJobEntity>()
+ .eq(WaylineJobEntity::getTaskType, 1)
+ .eq(WaylineJobEntity::getStatus, WaylineJobStatusEnum.PENDING.getVal())
+ .gt(WaylineJobEntity::getBeginTime, System.currentTimeMillis())
+ .orderByDesc(WaylineJobEntity::getBeginTime));
+ }
+
/**
* 根据航班任务ID获取航班任务资源
@@ -830,12 +860,18 @@
// get file url
URL url = null;
- String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath1());
+ String minioUrl = subStringMinioUrlName(ardRouteOpt.getPath());
String md5 = "";
+ String httpUrl = "";
try (InputStream inputStream = _ossService.getObject(kmzPath, minioUrl)) {
md5 = DigestUtils.md5Hex(inputStream);
- url = new URL(ardRouteOpt.getPath1());
- log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId + " 返回信息为url:" + url.toString() + " md5:" + md5);
+ url = new URL(ardRouteOpt.getPath());
+
+ log.info("机场通过flightTaskResourceGet获取航线文件地址转换前:{}", url);
+ httpUrl = url.toString().replace(OssConfiguration.endpoint, DockConfiguration.endpoint);
+ log.info("机场通过flightTaskResourceGet获取航线文件地址转换后:{}", httpUrl);
+
+ log.info("机场通过flightTaskResourceGet获取航线文件地址,jobId: " + jobId + " 返回信息为url:" + httpUrl + " md5:" + md5);
// }
// try {
// url = waylineFileService.getObjectUrl(waylineFile.get().getWaylineId());
@@ -849,7 +885,7 @@
builder.data(RequestsReply.success(WaylineTaskCreateDTO.builder()
.file(WaylineTaskFileDTO.builder()
- .url(url.toString())
+ .url(httpUrl)
.fingerprint(md5)
.build())
.build()));
--
Gitblit v1.9.3