From 3db92a6fff18c1591b298fa0bf8085dfcbdb6747 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Sat, 06 Jul 2024 15:08:11 +0800
Subject: [PATCH] 修改智能航线规划,修改南昌机场和西安机场人工接管时图片绑定图斑问题

---
 src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java |    2 
 src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java         |   74 ++++++++++++++----------
 src/main/java/com/dji/sample/patches/controller/PatchesController.java       |   68 ++++++++--------------
 3 files changed, 69 insertions(+), 75 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 00b0753..7429d24 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
@@ -457,9 +457,7 @@
     public void updateMediaFileNames(String jobId) {
         // 查询符合条件的数据
         List<MediaFileEntity> mediaFiles = mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>()
-                        .eq(MediaFileEntity::getJobId, jobId)
-//                .eq(MediaFileMarkEntity::getIsadd, 0)
-        );
+                .eq(MediaFileEntity::getJobId, jobId));
         boolean allContainTilde = mediaFiles.stream().allMatch(file -> file.getFileName().contains("~"));
         boolean noneContainTilde = mediaFiles.stream().noneMatch(file -> file.getFileName().contains("~"));
 
@@ -512,22 +510,28 @@
             closestFileOpt.ifPresent(closestFile -> {
                 String closestName = closestFile.getFileName();
                 int startIndex = closestName.indexOf("V");
-                if (closestName.contains("W")) {
-                    startIndex = closestName.indexOf("W");
-                }
-                if (closestName.contains("Z")) {
-                    startIndex = closestName.indexOf("Z");
+                if (startIndex == -1) startIndex = closestName.indexOf("W");
+                if (startIndex == -1) startIndex = closestName.indexOf("Z");
+                if (startIndex == -1) startIndex = closestName.indexOf("T");
+                if (startIndex == -1) {
+                    return;
                 }
                 int endIndex = closestName.indexOf(".", startIndex);
+                if (endIndex == -1) {
+                    return;
+                }
                 String replacement = closestName.substring(startIndex, endIndex);
                 int currentStartIndex = currentName.indexOf("V");
-                if (currentName.contains("W")) {
-                    currentStartIndex = closestName.indexOf("W");
-                }
-                if (currentName.contains("Z")) {
-                    currentStartIndex = closestName.indexOf("Z");
+                if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("W");
+                if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("Z");
+                if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("T");
+                if (currentStartIndex == -1) {
+                    return;
                 }
                 int currentEndIndex = currentName.indexOf(".", currentStartIndex);
+                if (currentEndIndex == -1) {
+                    return;
+                }
                 String newName = currentName.substring(0, currentStartIndex)
                         + replacement
                         + currentName.substring(currentEndIndex);
@@ -540,13 +544,10 @@
     @Override
     public void updateMarkMediaFileNames(String jobId) {
         try {
-
-
             // 查询符合条件的数据
             List<MediaFileMarkEntity> mediaFiles = markMapper.selectList(new LambdaQueryWrapper<MediaFileMarkEntity>()
-                            .eq(MediaFileMarkEntity::getJobId, jobId)
-//                .eq(MediaFileMarkEntity::getIsadd, 0)
-            );
+                    .eq(MediaFileMarkEntity::getJobId, jobId));
+
             // 判断所有 fileName 是否都包含 '~' 或者都不包含 '~'
             boolean allContainTilde = mediaFiles.stream().allMatch(file -> file.getFileName().contains("~"));
             boolean noneContainTilde = mediaFiles.stream().noneMatch(file -> file.getFileName().contains("~"));
@@ -557,9 +558,9 @@
                     file.setIsadd(1);
                     updateById(file.getId(), file);
                 });
-                    return;
-
+                return;
             }
+
             // 筛选出name字段不包含'~'的数据
             List<MediaFileMarkEntity> filteredFiles = mediaFiles.stream()
                     .filter(file -> !file.getFileName().contains("~"))
@@ -569,6 +570,7 @@
                 String currentName = currentFile.getFileName();
                 Map<String, Object> currentMetadata = JSON.parseObject(JSON.toJSONString(currentFile.getMetadata()), Map.class);
                 Long currentCreatedTime = (Long) currentMetadata.get("createdTime");
+
                 // 找到metadata中的createdTime小于当前数据的createdTime且最接近的那条数据
                 Optional<MediaFileMarkEntity> closestFileOpt = mediaFiles.stream()
                         .filter(file -> {
@@ -584,6 +586,7 @@
                             Long time2 = (Long) metadata2.get("createdTime");
                             return Long.compare(currentCreatedTime - time1, currentCreatedTime - time2);
                         });
+
                 if (closestFileOpt.isEmpty()) {
                     // 找不到小于的文件,尝试找大于且最接近的文件
                     closestFileOpt = mediaFiles.stream()
@@ -601,26 +604,34 @@
                                 return Long.compare(time1 - currentCreatedTime, time2 - currentCreatedTime);
                             });
                 }
+
                 // 提取并替换name字段
                 closestFileOpt.ifPresent(closestFile -> {
                     String closestName = closestFile.getFileName();
                     int startIndex = closestName.indexOf("V");
-                    if (closestName.contains("W")) {
-                        startIndex = closestName.indexOf("W");
-                    }
-                    if (closestName.contains("Z")) {
-                        startIndex = closestName.indexOf("Z");
+                    if (startIndex == -1) startIndex = closestName.indexOf("W");
+                    if (startIndex == -1) startIndex = closestName.indexOf("Z");
+                    if (startIndex == -1) startIndex = closestName.indexOf("T");
+                    if (startIndex == -1) {
+                        return;
                     }
                     int endIndex = closestName.indexOf(".", startIndex);
-                    String replacement = closestName.substring(startIndex, endIndex);
-                    int currentStartIndex = currentName.indexOf("V");
-                    if (currentName.contains("W")) {
-                        currentStartIndex = closestName.indexOf("W");
+                    if (endIndex == -1) {
+                        return;
                     }
-                    if (currentName.contains("Z")) {
-                        currentStartIndex = closestName.indexOf("Z");
+                    String replacement = closestName.substring(startIndex, endIndex);
+
+                    int currentStartIndex = currentName.indexOf("V");
+                    if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("W");
+                    if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("Z");
+                    if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("T");
+                    if (currentStartIndex == -1) {
+                        return;
                     }
                     int currentEndIndex = currentName.indexOf(".", currentStartIndex);
+                    if (currentEndIndex == -1) {
+                        return;
+                    }
                     String newName = currentName.substring(0, currentStartIndex)
                             + replacement
                             + currentName.substring(currentEndIndex);
@@ -633,6 +644,7 @@
         }
     }
 
+
     public void updateById(Integer id, MediaFileMarkEntity entity) {
         entity.setIsadd(1);
         UpdateWrapper<MediaFileMarkEntity> updateWrapper = new UpdateWrapper<>();
diff --git a/src/main/java/com/dji/sample/patches/controller/PatchesController.java b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
index 4cab5ae..fba9968 100644
--- a/src/main/java/com/dji/sample/patches/controller/PatchesController.java
+++ b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -4,14 +4,12 @@
 import com.dji.sample.common.model.PaginationData;
 import com.dji.sample.common.model.ResponseResult;
 import com.dji.sample.common.util.MinioUrlUtils;
-import com.dji.sample.log.aspect.SysLogAnnotation;
 import com.dji.sample.media.model.MediaFileEntity;
 import com.dji.sample.media.service.impl.FileServiceImpl;
 import com.dji.sample.patches.model.Param.PatchesParam;
 import com.dji.sample.patches.model.entity.LotInfo;
 import com.dji.sample.patches.service.GetPatchesService;
 import com.dji.sample.patches.service.ShpToDataSourceService;
-import com.dji.sample.patches.service.impl.ShpToDataSourceServiceImpl;
 import com.dji.sample.patches.utils.DistrictCodeUtils;
 import com.dji.sample.patches.utils.TimerUtil;
 import com.dji.sample.territory.service.impl.TbDkjbxxServiceImpl;
@@ -127,50 +125,36 @@
         }
     }
 
-    @PostMapping("/patchesToWayline")
-    public ResponseResult patchesToWayline(@RequestBody List<LotInfo> list,
-                                           @RequestParam String waylineName,
-                                           @RequestParam String workspaceId,
-                                           @RequestParam String PatchesId,
-                                           @RequestParam String spotInFreckle,
-                                           @RequestParam double lat,
-                                           @RequestParam double lon,
-                                           HttpServletRequest request) throws IOException {
-        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
-        String creator = customClaim.getUsername();
-        MultipartFile file = timerUtil.getFile(waylineName, list,lat,lon);
-        waylineFileService.importKmzFile(file, workspaceId, creator,PatchesId,spotInFreckle);
-        WaylineFileEntity entity = waylineFileService.selectByName(waylineName);
-        Map<String, String> infoMap = new HashMap<>();
-        URL url = null;
-        try {
-            url = waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId());
-            infoMap.put("url", String.valueOf(MinioUrlUtils.getUrl(url)));
-            infoMap.put("waylineId", entity.getWaylineId());
-        } catch (SQLException e) {
-            throw new RuntimeException(e);
+
+        @PostMapping("/patchesToWayline")
+        public ResponseResult patchesToWayline(@RequestBody List<LotInfo> lotInfos,
+                                               @RequestParam String waylineName,
+                                               @RequestParam String spotInFreckle,
+                                               @RequestParam String workspaceId,
+                                               @RequestParam String patchesId,
+                                               @RequestParam double lat,
+                                               @RequestParam double lon,
+                                               HttpServletRequest request) throws IOException {
+            CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
+            String creator = customClaim.getUsername();
+            MultipartFile file = timerUtil.getFile(waylineName, lotInfos, lat, lon);
+            waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, spotInFreckle);
+            WaylineFileEntity entity = waylineFileService.selectByName(waylineName);
+            Map<String, String> infoMap = new HashMap<>();
+            URL url = null;
+            try {
+                url = waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId());
+                infoMap.put("url", String.valueOf(MinioUrlUtils.getUrl(url)));
+                infoMap.put("waylineId", entity.getWaylineId());
+            } catch (SQLException e) {
+                throw new RuntimeException(e);
+            }
+            return ResponseResult.success(infoMap);
         }
-        return ResponseResult.success(infoMap);
-    }
 
-    @GetMapping("/useMyTask")
-    public ResponseResult useMyTask() throws Exception {
-        try {
-//            timerUtil.myTask();
-//            timerUtil.myTask2();
-//            timerUtil.myTask3();
-            timerUtil.mytask4();
-            timerUtil.mytask5();
-            timerUtil.mytask6();
-            timerUtil.mytask7();
 
-        } catch (Exception e) {
-            throw new RuntimeException("db存储发送出现异常" + e);
-        }
-        return ResponseResult.success();
-    }
 
-        @GetMapping ("/tests")
+    @GetMapping ("/tests")
     public ResponseResult use()  {
             ExecutorService executor = Executors.newSingleThreadExecutor();
             executor.execute(() -> {
diff --git a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
index 5294366..432a432 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -1,7 +1,6 @@
 package com.dji.sample.patches.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dji.sample.common.model.Pagination;
@@ -20,7 +19,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 @Service

--
Gitblit v1.9.3