From 966b8ec80833c3281a41370a29960156a73360c7 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 13 三月 2024 10:20:13 +0800
Subject: [PATCH] 添加 数据自动计算 接口

---
 src/main/java/com/lf/server/service/data/FmeService.java    |   10 +++++
 src/main/java/com/lf/server/service/show/OneMapService.java |   69 +++++++++++++++++++++++++++++++---
 src/main/resources/mapper/show/OneMapMapper.xml             |   16 ++++----
 src/main/resources/application.yml                          |    4 +
 4 files changed, 84 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/lf/server/service/data/FmeService.java b/src/main/java/com/lf/server/service/data/FmeService.java
index 7fb782d..4af356a 100644
--- a/src/main/java/com/lf/server/service/data/FmeService.java
+++ b/src/main/java/com/lf/server/service/data/FmeService.java
@@ -24,6 +24,9 @@
     @Value("${sys.fmeUrl}")
     private String fmeUrl;
 
+    @Value("${sys.fmeToken}")
+    private String fmeToken;
+
     /**
      * 鑾峰彇浠诲姟鐘舵��
      */
@@ -343,6 +346,13 @@
     }
 
     /**
+     * 鑾峰彇Url
+     */
+    public String getUrl(String subUrl) {
+        return fmeUrl + subUrl + "?token=" + fmeToken;
+    }
+
+    /**
      * 鑾峰彇鍚嶇О鍊煎闆嗗悎
      */
     public List<NameValueEntity> getKeyValues(String name) {
diff --git a/src/main/java/com/lf/server/service/show/OneMapService.java b/src/main/java/com/lf/server/service/show/OneMapService.java
index 1b2e1be..f1e7a6e 100644
--- a/src/main/java/com/lf/server/service/show/OneMapService.java
+++ b/src/main/java/com/lf/server/service/show/OneMapService.java
@@ -2,12 +2,18 @@
 
 import com.lf.server.entity.bs.MpipelineEntity;
 import com.lf.server.entity.ctrl.CountEntity;
-import com.lf.server.entity.ctrl.IdNameEntity;
 import com.lf.server.entity.show.OneMapEntity;
+import com.lf.server.helper.PathHelper;
+import com.lf.server.helper.WebHelper;
 import com.lf.server.mapper.show.OneMapMapper;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.lf.server.service.data.FmeService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -19,25 +25,36 @@
  */
 @Service
 public class OneMapService implements OneMapMapper {
-    @Autowired
+    @Resource
     OneMapMapper oneMapMapper;
+
+    @Resource
+    FmeService fmeService;
+
+    @Resource
+    PathHelper pathHelper;
 
     /**
      * 娴嬬粯
      */
     private static final String MEASUREMENT = "娴嬬粯锛圗SV锛�";
+
     /**
      * 璋冩煡
      */
     private static final String TOINVESTIGATE = "鍕樺療锛圗GE锛�";
+
     /**
      * 鍦扮伨
      */
     private static final String DISASTER = "鍦扮伨锛圗GD锛�";
+
     /**
      * 鍦颁笅缁撴瀯娲炲簱
      */
     private static final String UNDERGROUNDSTRUCTURE = "娲炲簱锛圗GD锛�";
+
+    private final static Log log = LogFactory.getLog(OneMapService.class);
 
     /**
      * 椤圭洰绫诲埆conut
@@ -256,7 +273,6 @@
         return null;
     }
 
-
     /**
      * 鏌ヨ琛ㄤ俊鎭�
      *
@@ -379,11 +395,52 @@
 
     @Override
     public Integer selectLineBuffer() {
-        return oneMapMapper.selectLineBuffer();
+        try {
+            return oneMapMapper.selectLineBuffer();
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return 0;
+        }
     }
 
     @Override
     public List<Map<String, Object>> selectMetaByType() {
-        return oneMapMapper.selectMetaByType();
+        try {
+            return oneMapMapper.selectMetaByType();
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            return null;
+        }
+    }
+
+    /**
+     * 璁$畻鏁版嵁
+     */
+    public String calcData() {
+        Integer rows = selectLineBuffer();
+
+        List<Map<String, Object>> list = selectMetaByType();
+        if (null != list && list.size() > 0) {
+            HttpServletRequest req = WebHelper.getRequest();
+            String rootPath = pathHelper.getUploadFullPath();
+            for (Map<String, Object> map : list) {
+                String sjfl = map.get("type").toString();
+                String id = map.get("id").toString();
+                String wjlj = rootPath + File.separator + map.get("path").toString();
+
+                File file = new File(wjlj);
+                if (!file.exists() || file.isDirectory()) {
+                    continue;
+                }
+
+                String str = fmeService.calcArea(sjfl, id, wjlj, req);
+                if (null != str) {
+                    System.out.println(str);
+                }
+                rows++;
+            }
+        }
+
+        return String.format("鍏卞鐞嗕簡 %d 鏉¤褰�", rows);
     }
 }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index e8e3faf..006c072 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -135,6 +135,8 @@
   # FME鏈嶅姟鍦板潃
   #fmeUrl: http://106.120.22.35:8051/
   fmeUrl: http://192.168.11.205:88/
+  # FME浠ょ墝
+  fmeToken: c36e4f94-dfde-401e-9967-2c4a449f1300
   # 鍑哄浘鏈嶅姟
   exportServer: http://127.0.0.1/ExportMap
   #exportServer: http://103.85.165.99:8050/ExportMap
@@ -148,7 +150,7 @@
     # 涓嬭浇鐩綍
     download: D:\LF\download
     # 涓婁紶鐩綍
-    upload: D:\LF\upload
+    upload: E:\TaiRui\LF\upload
     # 涓存椂鐩綍
     temp: D:\LF\temp
   # 涓婁紶闄勪欢琛�
diff --git a/src/main/resources/mapper/show/OneMapMapper.xml b/src/main/resources/mapper/show/OneMapMapper.xml
index c19e372..1c57857 100644
--- a/src/main/resources/mapper/show/OneMapMapper.xml
+++ b/src/main/resources/mapper/show/OneMapMapper.xml
@@ -317,20 +317,20 @@
 
     <!-- 鏍规嵁绫诲瀷鏌ヨ鍏冩暟鎹紙鐢ㄤ簬璁$畻闈㈢Н锛� -->
     <select id="selectMetaByType" resultType="java.util.Map">
-        (select a.id, a.path, 'DOM' name from lf.sys_meta a
+        (select a.id, a.path, 'DOM' type from lf.sys_meta a
             inner join lf.sys_dir b on a.dircode = b.code
-            where a.area is null and a.type in ('img', 'tif', 'tiff') and b.name = '鏁板瓧姝e皠褰卞儚鍥�')
+            where a.area is null and a.type in ('img', 'tif', 'tiff') and b.name = '鏁板瓧姝e皠褰卞儚鍥�' limit 1)
         union all
-        (select a.id, a.path, 'DEM' name from lf.sys_meta a
+        (select a.id, a.path, 'DEM' type from lf.sys_meta a
             inner join lf.sys_dir b on a.dircode = b.code
-            where a.area is null and a.type in ('dem', 'tif', 'tiff') and b.name = '鏁板瓧楂樼▼妯″瀷')
+            where a.area is null and a.type in ('dem', 'tif', 'tiff') and b.name = '鏁板瓧楂樼▼妯″瀷' limit 1)
         union all
-        (select id, path, 'OSGB' name from lf.sys_meta where area is null and type = 'osgb')
+        (select id, path, 'OSGB' type from lf.sys_meta where area is null and type = 'osgb' limit 1)
         union all
-        (select id, path, 'LAS' name from lf.sys_meta where area is null and type = 'las' or type = 'laz')
+        (select id, path, 'LAS' type from lf.sys_meta where area is null and type = 'las' or type = 'laz' limit 1)
         union all
-        (select id, path, 'IFC' name from lf.sys_meta where area is null and type = 'ifc')
+        (select id, path, 'IFC' type from lf.sys_meta where area is null and type = 'ifc' limit 1)
         union all
-        (select id, path, 'FBX' name from lf.sys_meta where area is null and type = 'fbx')
+        (select id, path, 'FBX' type from lf.sys_meta where area is null and type = 'fbx' limit 1)
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3