From 7b8c8077af714c808ae7a51ed5d3abbd407cc620 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 26 Jun 2024 17:15:29 +0800
Subject: [PATCH] 修改成果展示查询接口名字为空时的错误bug,加上按拍照时间倒叙。修改定时器时间
---
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java | 13 ++++++++++---
src/main/java/com/dji/sample/wayline/util/ErrorCodeUtil.java | 2 +-
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java | 7 +++++++
src/main/java/com/dji/sample/patches/utils/TimerUtil.java | 20 ++++++++------------
4 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
index 76fe1b3..63522b2 100644
--- a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -182,7 +182,13 @@
if (jobName != null && !jobName.isEmpty()) {
List<String> jobIds = waylineJobService.getJobIds(jobName);
- queryWrapper.in(MediaFileEntity::getJobId, jobIds);
+ // 检查 jobIds 列表是否为空
+ if (jobIds.isEmpty()) {
+ // 如果为空,则直接返回空的分页数据
+ return new PaginationData<>(Collections.emptyList(), new Pagination(pageObj));
+ }
+
+ queryWrapper.in(MediaFileEntity::getJobId, jobIds);
}
if (type != null && !type.isEmpty()) {
if ("图片".equals(type)) {
@@ -191,7 +197,7 @@
queryWrapper.likeLeft(MediaFileEntity::getFileName, ".mp4");
}
}
- queryWrapper.orderByDesc(MediaFileEntity::getCreateTime);
+ queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC");
// 执行分页查询
Page<MediaFileEntity> resultPage = mapper.selectPage(pageObj, queryWrapper);
@@ -414,7 +420,7 @@
return builder.build();
}
- public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file) {
+ public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file ) {
try {
// 创建MinIO客户端实例
MinioClient minioClient = MinioClient.builder()
@@ -428,6 +434,7 @@
.bucket(bucketName)
.object(objectName)
.stream(fileInputStream, file.length(), -1)
+ .contentType("image/jpeg")
.build()
);
fileInputStream.close();
diff --git a/src/main/java/com/dji/sample/patches/utils/TimerUtil.java b/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
index 9509d05..b6ea71f 100644
--- a/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
+++ b/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -64,8 +64,7 @@
private PatchesConfigPojo patchesConfigPojo;
@Autowired
public IWaylineFileService waylineFileService;
- @Autowired
- private IFileMapper fileMapper;
+
@Autowired
private ITbFJService tbFJService;
@Autowired
@@ -115,12 +114,12 @@
String times = convertTimestampToFormattedString(time);
sendPostWithParameters(waylineName, waylineFile.getWaylineId(), times, lists1, listOfLists);
updatePatchesStatu(list);
- time = addOneHourToTimestamp(time, 1, 30);
+ time = addOneHourToTimestamp(time, 1, 0);
}
}
- @Scheduled(cron = "0 0 0 * * ?")
+ @Scheduled(cron = "0 1 0 * * ?")
public void myTask2() {
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
@@ -143,9 +142,9 @@
// waylineJobService.publishOneFlightTask(waylineJobDTO.get());
// }
// }
- @Scheduled(cron = "0 0 0 * * ?")
+ @Scheduled(cron = "0 0 1 * * ?")
public void mytask4() throws IOException {
- Long time = getCurrentTimestampPlus8Hours(9);
+ Long time = getCurrentTimestampPlus8Hours(8);
List<List<Long>> listOfLists = new ArrayList<>();
List<Long> sublist = new ArrayList<>();
sublist.add(time); // 添加整数值
@@ -156,10 +155,9 @@
sendPostWithParameters("别墅巡查一段", "a07229af-471a-4058-9da6-5a2b84308b9e", times, lists1, listOfLists);
}
- @Scheduled(cron = "0 0 0 * * ?")
+ @Scheduled(cron = "0 50 0 * * ?")
public void mytask5() throws IOException {
Long time = getCurrentTimestampPlus8Hours(9);
- time = addOneHourToTimestamp(time, 0, 50);
List<List<Long>> listOfLists = new ArrayList<>();
List<Long> sublist = new ArrayList<>();
sublist.add(time); // 添加整数值
@@ -170,10 +168,9 @@
sendPostWithParameters("别墅巡查二段", "561ecb37-d673-40f8-a859-05dbfc7d9976", times, lists1, listOfLists);
}
- @Scheduled(cron = "0 0 0 * * ?")
+ @Scheduled(cron = "0 40 1 * * ?")
public void mytask6() throws IOException {
Long time = getCurrentTimestampPlus8Hours(9);
- time = addOneHourToTimestamp(time, 1, 40);
List<List<Long>> listOfLists = new ArrayList<>();
List<Long> sublist = new ArrayList<>();
sublist.add(time); // 添加整数值
@@ -184,10 +181,9 @@
sendPostWithParameters("九洲巡河一段", "9f471686-a73a-4e90-8f37-92eed8ed5929", times, lists1, listOfLists);
}
- @Scheduled(cron = "0 0 0 * * ?")
+ @Scheduled(cron = "0 40 2 * * ?")
public void mytask7() throws IOException {
Long time = getCurrentTimestampPlus8Hours(9);
- time = addOneHourToTimestamp(time, 2, 50);
List<List<Long>> listOfLists = new ArrayList<>();
List<Long> sublist = new ArrayList<>();
sublist.add(time); // 添加整数值
diff --git a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java b/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
index 9213b00..91cf612 100644
--- a/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
+++ b/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -789,6 +789,12 @@
@Override
public List<String> getJobIds(String jobNames) {
List<String> names = getJobNamesByPartialName(jobNames);
+
+ // 如果 names 列表为空,直接返回空的 jobIdStringList
+ if (names.isEmpty()) {
+ return new ArrayList<>();
+ }
+
// 使用 LambdaQueryWrapper 进行查询
List<Object> jobIdList = mapper.selectObjs(
new LambdaQueryWrapper<WaylineJobEntity>()
@@ -804,6 +810,7 @@
return jobIdStringList;
}
+
@Override
public WaylineJobEntity getLatestJob(String workspaceId, WaylineJobQueryParam waylineJobQueryParam) {
WaylineJobEntity waylineJobEntity = mapper.getLatest(workspaceId, waylineJobQueryParam);
diff --git a/src/main/java/com/dji/sample/wayline/util/ErrorCodeUtil.java b/src/main/java/com/dji/sample/wayline/util/ErrorCodeUtil.java
index aec4fef..7e4a0b2 100644
--- a/src/main/java/com/dji/sample/wayline/util/ErrorCodeUtil.java
+++ b/src/main/java/com/dji/sample/wayline/util/ErrorCodeUtil.java
@@ -46,6 +46,6 @@
}
public static void main(String[] args) {
- System.out.println(codeToReason(315002));
+ System.out.println(codeToReason(321517));
}
}
--
Gitblit v1.9.3