From 36b2f13fff583e0dbc94ee40e9fe4ae6e75af4e0 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 29 二月 2024 14:44:27 +0800
Subject: [PATCH] 修改JSHelper类

---
 src/main/java/com/lf/server/service/sys/ReportService.java |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/lf/server/service/sys/ReportService.java b/src/main/java/com/lf/server/service/sys/ReportService.java
index 353c1f6..cf96ef6 100644
--- a/src/main/java/com/lf/server/service/sys/ReportService.java
+++ b/src/main/java/com/lf/server/service/sys/ReportService.java
@@ -13,6 +13,7 @@
 import com.lf.server.mapper.sys.ReportMapper;
 import com.lf.server.service.all.RedisService;
 import com.lf.server.service.data.DownloadService;
+import org.locationtech.jts.geom.Coordinate;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -124,10 +125,10 @@
     @Override
     public List<CountEntity> countExplorationPoints() {
         String key = RedisCacheKey.dataCountKey("countExplorationPoints");
-        Object obj = redisService.get(key);
-        if (obj instanceof List<?>) {
-            return (List<CountEntity>) obj;
-        }
+//        Object obj = redisService.get(key);
+//        if (obj instanceof List<?>) {
+//            return (List<CountEntity>) obj;
+//        }
 
         List<CountEntity> list = reportMapper.countExplorationPoints();
         if (null != list && list.size() > 0) {
@@ -157,12 +158,33 @@
                 continue;
             }
 
-            double area = JtsHelper.calcAreaByPoints(ces);
+            StringBuilder sb = new StringBuilder();
+            sb.append("[");
+            for (CoordinateEntity e : ces) {
+                sb.append(e.getX() + "," + e.getY() + ",");
+            }
+            sb.replace(sb.length() - 1, sb.length(), "]");
+
+            // double area = JtsHelper.calcAreaByPoints(ces)
+            double area = callJsFn(sb.toString());
             ce.setArea(area);
         }
     }
 
     /**
+     * 璋冪敤JS鏂规硶
+     */
+    private double callJsFn(String str) {
+        String staticPath = PathHelper.getStaticPath();
+        Object obj = JsHelper.callJsFn(staticPath + "js/turf.min.6.5.js", "pointsToPolygon", str);
+        if (null == obj) {
+            return 0d;
+        }
+
+        return (double) obj;
+    }
+
+    /**
      * 鍒涘缓鎶ュ憡
      */
     public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception {

--
Gitblit v1.9.3