From 1fd6775420288be4dce934fe845328e9501bf023 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 11 九月 2025 10:28:54 +0800
Subject: [PATCH] bug修改,增加坐标系转换

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java
index be5c135..009aa55 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java
@@ -27,6 +27,7 @@
 import com.ruoyi.system.service.*;
 import com.ruoyi.system.utils.CustomerImportFailedData;
 import com.ruoyi.system.vo.system.*;
+import com.ruoyi.web.controller.tool.HighPrecisionCoordinateTransformUtil;
 import com.sun.org.apache.bcel.internal.generic.NEW;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -45,6 +46,8 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -141,6 +144,9 @@
         List<String> collect = list.stream().map(TTask::getId).collect(Collectors.toList());
 
         List<LocationListTaskVO> res = new ArrayList<>();
+        if (collect.isEmpty()){
+            return R.ok(pageInfo);
+        }
         List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                         .in(TTaskDetail::getTaskId,collect)
                 .eq(TTaskDetail::getClearStatus, 2)
@@ -388,6 +394,9 @@
 
         for (TLocationImportExcel locationExcel : locationExcelList) {
             System.err.println(locationExcel);
+            if (locationExcel.getLocationName()==null){
+                continue;
+            }
             TLocation location = new TLocation();
             location.setLocationCode(locationExcel.getLocationCode());
             location.setLocationName(locationExcel.getLocationName());
@@ -396,13 +405,16 @@
                 location.setLocationType(tLocationType.getId());
             }
             location.setLocationAddress(locationExcel.getLocationAddress());
-            String[] addressLonLat = locationExcel.getLocationAddressLonLat().split(",");
-            location.setLocationLon(addressLonLat[0]);
-            location.setLocationLat(addressLonLat[1]);
+            String[] addressLonLat = locationExcel.getLocationAddressLonLat().split("/");
+            double[] start = HighPrecisionCoordinateTransformUtil.wgs84ToGcj02ViaGaode(Double.parseDouble(addressLonLat[1]), Double.parseDouble(addressLonLat[0]));
+            location.setLocationLon(String.valueOf(start[1]));
+            location.setLocationLat(String.valueOf(start[0]));
             location.setLocationAddressEnd(locationExcel.getLocationAddressEnd());
-            String[] addressEndLonLat = locationExcel.getLocationAddressEndLonLat().split(",");
-            location.setLocationLonEnd(addressEndLonLat[0]);
-            location.setLocationLatEnd(addressEndLonLat[1]);
+            String[] addressEndLonLat = locationExcel.getLocationAddressEndLonLat().split("/");
+            double[] end = HighPrecisionCoordinateTransformUtil.wgs84ToGcj02ViaGaode(Double.parseDouble(addressEndLonLat[1]), Double.parseDouble(addressEndLonLat[0]));
+
+            location.setLocationLonEnd(String.valueOf(end[1]));
+            location.setLocationLatEnd(String.valueOf(end[0]));
             TProjectDept projectDept = deptList.stream().filter(dept -> dept.getCode().equals(locationExcel.getDeptCode())).findFirst().orElse(null);
             if(Objects.nonNull(projectDept)){
                 location.setProjectId(projectDept.getId());
@@ -417,7 +429,8 @@
                 result.append("路段名:[", locationExcel.getLocationName()+"]未查询到点位负责人");
                 continue;
             }
-            TCleaner tCleaner = cleaners.stream().filter(cleaner -> cleaner.getCleanerCode().equals(locationExcel.getCleanerCodeClear())
+            TCleaner tCleaner = cleaners.stream().filter(cleaner -> cleaner.getCleanerCode().equals(
+                    locationExcel.getCleanerCodeClear())
                     && cleaner.getDeptCode().equals(locationExcel.getDeptCodeClear())
                     && cleaner.getProjectCode().equals(locationExcel.getProjectCodeClear())
                     && cleaner.getCleanerName().equals(locationExcel.getCleanerName())).findFirst().orElse(null);
@@ -436,5 +449,10 @@
         return R.ok();
     }
 
+    public static void main(String[] args) {
+        BigDecimal divide = new BigDecimal("-23").divide(new BigDecimal("40"),2, RoundingMode.HALF_UP);
+        System.err.println(divide);
+    }
+
 }
 

--
Gitblit v1.7.1