From 4d8dd71b7d13fa41132c46831090c6282af502cb Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 12 十一月 2022 09:03:08 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/show/MarkService.java         |    2 
 src/main/java/com/lf/server/service/show/ExportService.java       |   64 ++++++++++++++++++++++++++++----
 data/db_tab.sql                                                   |    2 
 说明.txt                                                            |    8 +--
 src/main/java/com/lf/server/controller/show/ExportController.java |   10 +----
 5 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/data/db_tab.sql b/data/db_tab.sql
index 546c7b7..c75b534 100644
--- a/data/db_tab.sql
+++ b/data/db_tab.sql
@@ -788,7 +788,7 @@
 comment on table lf.sys_download is '涓嬭浇璁板綍琛�';
 comment on column lf.sys_download.id is '涓婚敭ID';
 comment on column lf.sys_download.name is '鍚嶇О';
-comment on column lf.sys_download.type is '绫诲瀷锛�1-涓嬭浇鏁版嵁,2-涓嬭浇涓撻鍥�';
+comment on column lf.sys_download.type is '绫诲瀷锛�1-ShapeFile锛�2-涓撻鍥�';
 comment on column lf.sys_download.depid is '鍗曚綅ID';
 comment on column lf.sys_download.dcount is '涓嬭浇娆℃暟';
 comment on column lf.sys_download.pwd is 'MD5';
diff --git a/src/main/java/com/lf/server/controller/show/ExportController.java b/src/main/java/com/lf/server/controller/show/ExportController.java
index 210abe8..25a8365 100644
--- a/src/main/java/com/lf/server/controller/show/ExportController.java
+++ b/src/main/java/com/lf/server/controller/show/ExportController.java
@@ -7,7 +7,6 @@
 import com.lf.server.entity.show.ExportEntity;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.StringHelper;
-import com.lf.server.service.data.DownloadService;
 import com.lf.server.service.show.ExportService;
 import com.lf.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
@@ -33,9 +32,6 @@
 
     @Autowired
     TokenService tokenService;
-
-    @Autowired
-    DownloadService downloadService;
 
     @SysLog()
     @ApiOperation(value = "鍒嗛〉鏌ヨ")
@@ -81,14 +77,12 @@
                 return fail("鐢ㄦ埛鏈櫥褰�");
             }
 
-            String str = exportService.post(entity);
+            String str = exportService.post(ue, entity);
             if (StringHelper.isNull(str)) {
                 return fail("鍑哄浘澶辫触");
             }
 
-            //
-
-            return success(str);
+            return success("鍑哄浘鎴愬姛", str);
         } catch (Exception ex) {
             return fail(ex.getMessage());
         }
diff --git a/src/main/java/com/lf/server/service/show/ExportService.java b/src/main/java/com/lf/server/service/show/ExportService.java
index 2132174..400573f 100644
--- a/src/main/java/com/lf/server/service/show/ExportService.java
+++ b/src/main/java/com/lf/server/service/show/ExportService.java
@@ -2,18 +2,21 @@
 
 import com.alibaba.fastjson.JSON;
 import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.data.DownloadEntity;
 import com.lf.server.entity.show.ExportEntity;
+import com.lf.server.entity.sys.UserEntity;
+import com.lf.server.helper.FileHelper;
+import com.lf.server.helper.PathHelper;
 import com.lf.server.helper.RestHelper;
 import com.lf.server.helper.StringHelper;
-import org.apache.http.NameValuePair;
-import org.apache.http.message.BasicNameValuePair;
+import com.lf.server.service.data.DownloadService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.lang.reflect.Field;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,8 +28,22 @@
     @Value("${sys.path.exportServer}")
     private String exportServer;
 
-    public String post(ExportEntity entity) {
-        Map<String, Object> map = getPostEntity(entity);
+    @Autowired
+    PathHelper pathHelper;
+
+    @Autowired
+    DownloadService downloadService;
+
+    /**
+     * POST璇锋眰鍑哄浘鏈嶅姟
+     *
+     * @param ue     鐢ㄦ埛绫�
+     * @param entity 鍦ㄧ嚎鍒跺浘绫�
+     * @return 鎴愬姛
+     * @throws Exception
+     */
+    public String post(UserEntity ue, ExportEntity entity) throws Exception {
+        Map<String, Object> map = getMapData(entity);
         String url = exportServer + "/Export/Start";
 
         String str = RestHelper.postForRest(url, map);
@@ -39,10 +56,22 @@
             return null;
         }
 
-        return msg.getResult();
+        String file = pathHelper.getConfig().getDownloadPath() + File.separator + msg.getResult();
+        File f = new File(file);
+        if (!f.exists() && !f.isDirectory()) {
+            return null;
+        }
+
+        DownloadEntity de = getDownloadEntity(ue, file);
+        int rows = downloadService.insert(de);
+
+        return rows > 0 ? de.getGuid() : null;
     }
 
-    private Map<String, Object> getPostEntity(ExportEntity entity) {
+    /**
+     * 鑾峰彇Map鏁版嵁
+     */
+    private Map<String, Object> getMapData(ExportEntity entity) {
         Map<String, Object> map = new HashMap<String, Object>();
 
         Field[] fields = entity.getClass().getDeclaredFields();
@@ -63,4 +92,23 @@
 
         return map;
     }
+
+    /**
+     * 鑾峰彇涓嬭浇瀹炰綋绫�
+     */
+    private DownloadEntity getDownloadEntity(UserEntity ue, String file) throws Exception {
+        DownloadEntity de = new DownloadEntity();
+        de.setName(FileHelper.getFileName(file));
+        de.setType(2);
+        de.setDepid(ue.getDepid());
+        de.setDcount(0);
+        // de.setPwd(null)
+        de.setUrl(FileHelper.getRelativePath(file));
+        de.setDescr("涓撻鍥炬枃浠�");
+        de.setGuid(FileHelper.getFileMd5(file));
+        de.setCreateUser(ue.getId());
+        // de.setGeom(null)
+
+        return de;
+    }
 }
diff --git a/src/main/java/com/lf/server/service/show/MarkService.java b/src/main/java/com/lf/server/service/show/MarkService.java
index 77907a3..7c806a4 100644
--- a/src/main/java/com/lf/server/service/show/MarkService.java
+++ b/src/main/java/com/lf/server/service/show/MarkService.java
@@ -181,7 +181,7 @@
         de.setDcount(0);
         // de.setPwd(null)
         de.setUrl(FileHelper.getRelativePath(file));
-        de.setDescr("涓嬭浇ShapeFile鏂囦欢");
+        de.setDescr("ShapeFile鏂囦欢");
         de.setGuid(FileHelper.getFileMd5(file));
         de.setCreateUser(ue.getId());
         // de.setGeom(null)
diff --git "a/\350\257\264\346\230\216.txt" "b/\350\257\264\346\230\216.txt"
index 1186366..d71c9ff 100644
--- "a/\350\257\264\346\230\216.txt"
+++ "b/\350\257\264\346\230\216.txt"
@@ -39,9 +39,9 @@
 38.寮�鍙戞牴鎹疄浣撳悕绉拌繘琛屽姩鎬佸垎椤垫煡璇�
 39.寮�鍙戞牴鎹疄浣撳悕绉�+瀛楁+鍊兼ā绯婃悳绱㈠墠10鏉¤褰�
 40.寮�鍙戞牴鎹疄浣撳悕绉版煡璇㈢┖闂磋〃鐨刉KT璁板綍
-41.鎼缓QGIS+Python寮�鍙戠幆澧� <
-42.
-43.
+41.鎼缓QGIS+Python寮�鍙戠幆澧�
+42.寮�鍙戞牴鎹悕绉版ā绯婃悳绱㈢敤鎴枫�佸崟浣嶇殑鍓�10鏉¤褰�
+43.鏋勫缓QGIS宸ョ▼锛屼娇鐢≒ython杩愯宸ョ▼ <
 44.
 45.
 46.
@@ -50,10 +50,8 @@
 49.
 50.
 -----------------------------------------------
-.寮�鍙戞牴鎹悕绉版ā绯婃悳绱㈢敤鎴枫�佸崟浣嶇殑鍓�10鏉¤褰�
 .寮�鍙戞牴鎹爣缁楯SON鏁版嵁鐢熸垚shp鏂囦欢骞朵笅杞�
 .寮�鍙戜笂浼爏hp鏂囦欢杞崲涓篔SON鏁版嵁鎺ュ彛
-.鏋勫缓QGIS宸ョ▼锛屼娇鐢≒ython杩愯宸ョ▼
 .鍒涘缓QGIS鍑哄浘妯℃澘
 .寮�鍙慞ython鍑哄浘鍔熻兘
 .寮�鍙慟GIS鍑哄浘鐨凜#鏈嶅姟

--
Gitblit v1.9.3