From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 02 七月 2025 16:43:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service

---
 src/main/java/com/lf/server/controller/data/upload/UploadController.java |  181 +++++++++++++++++++++++++++------------------
 1 files changed, 109 insertions(+), 72 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/data/upload/UploadController.java b/src/main/java/com/lf/server/controller/data/upload/UploadController.java
index 7c56727..b9ab916 100644
--- a/src/main/java/com/lf/server/controller/data/upload/UploadController.java
+++ b/src/main/java/com/lf/server/controller/data/upload/UploadController.java
@@ -2,11 +2,14 @@
 
 import com.lf.server.annotation.SysLog;
 import com.lf.server.entity.all.ResponseMsg;
-import com.lf.server.entity.all.StaticData;
+import com.lf.server.entity.ctrl.KeyValueEntity;
 import com.lf.server.entity.data.DirEntity;
+import com.lf.server.entity.data.MetaEntity;
 import com.lf.server.entity.data.MetaFileEntity;
+import com.lf.server.entity.data.VerEntity;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.StringHelper;
+import com.lf.server.service.all.UploadAttachService;
 import com.lf.server.service.data.UploadService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -30,6 +33,9 @@
     @Autowired
     UploadService uploadService;
 
+    @Autowired
+    UploadAttachService uploadAttachService;
+
     @SysLog()
     @ApiOperation(value = "鏌ヨ璺緞")
     @GetMapping(value = "/selectPath")
@@ -39,7 +45,8 @@
 
             return success(pathName);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            log.error(ex.getMessage(), ex);
+            return fail(ex, null);
         }
     }
 
@@ -52,14 +59,61 @@
     @PostMapping(value = "/uploadFiles")
     public ResponseMsg<Object> uploadFiles(String path, HttpServletRequest req, HttpServletResponse res) {
         try {
-            List<MetaFileEntity> list = uploadService.uploadData(null, path, req, res);
+            List<MetaFileEntity> list = uploadService.uploadData(null, path, false, req, res);
             if (null == list || list.isEmpty()) {
                 return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null);
             }
 
+            uploadService.copePath(list);
+
             return success(list);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
+        }
+    }
+
+    /**
+     * 鎺ユ敹鏁扮粍1锛欯RequestParam(value = "ids")List<Integer> ids
+     *          &ids=1209&ids=1180&ids=1387
+     * 鎺ユ敹鏁版嵁2锛欼nteger[] ids
+     *          formData.append("ids", 1209); formData.append("ids", 1180); formData.append("ids", 1387);
+     */
+    @SysLog()
+    @ApiOperation(value = "涓婁紶Excel闄勪欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹泦鍚�", dataType = "Integer", allowMultiple = true, paramType = "query")
+    })
+    @ResponseBody
+    @PostMapping(value = "/uploadXlsAnnex")
+    public ResponseMsg<Object> uploadXlsAnnex(String path, Integer[] ids, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue == null) {
+                return fail("鐢ㄦ埛鏈櫥褰�", null);
+            }
+            if (null == ids || ids.length == 0) {
+                return fail("鎵句笉鍒板厓鏁版嵁鐨処D闆嗗悎");
+            }
+
+            List<MetaEntity> ms = metaService.selectXlsAnnex(ids, UploadAttachService.getTabs());
+            if (null == ms || ms.isEmpty()) {
+                return fail("鎵句笉鍒拌涓婁紶闄勪欢鐨勫厓鏁版嵁");
+            }
+
+            List<MetaFileEntity> list = uploadService.uploadData(null, path, false, req, res);
+            if (null == list || list.isEmpty()) {
+                return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null);
+            }
+
+            List<KeyValueEntity> rs = uploadAttachService.uploadXlsAnnex(ue, ms, list, path);
+            if (null == rs || rs.size() == 0) {
+                return fail("娌℃湁瑕佹洿鏂扮殑鍏冩暟鎹�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex, null);
         }
     }
 
@@ -71,11 +125,11 @@
     @GetMapping(value = "/selectFiles")
     public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) {
         try {
-            List<MetaFileEntity> list = uploadService.selectFiles(path, StaticData.ALL_EXTENSION);
+            List<MetaFileEntity> list = uploadService.selectFiles(path, false);
 
             return success(list);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
@@ -100,22 +154,23 @@
 
             return success("鎴愬姛", rows);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
     @SysLog()
     @ApiOperation(value = "鏌ヨ鏄犲皠")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query", example = "20230109010101"),
+            @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query", example = "20230722"),
             @ApiImplicitParam(name = "dirid", value = "鐩綍ID", dataType = "Integer", paramType = "query", example = "1"),
+            @ApiImplicitParam(name = "verid", value = "鐗堟湰ID", dataType = "Integer", paramType = "query", example = "0"),
             @ApiImplicitParam(name = "epsgCode", value = "鍧愭爣缂栫爜", dataType = "String", paramType = "query", example = "EPSG:4490")
     })
     @GetMapping(value = "/selectMappers")
-    public ResponseMsg<Object> selectMappers(String path, Integer dirid, String epsgCode) {
+    public ResponseMsg<Object> selectMappers(String path, Integer dirid, Integer verid, String epsgCode, HttpServletRequest req) {
         try {
-            if (StringHelper.isEmpty(path) || StringHelper.isEmpty(epsgCode) || null == dirid) {
-                return fail("璺緞銆佺洰褰旾D鍜屽潗鏍囩紪鐮佷笉鑳戒负绌�");
+            if (StringHelper.isEmpty(path) || StringHelper.isEmpty(epsgCode) || null == dirid || null == verid) {
+                return fail("璺緞銆佺洰褰旾D銆佺増鏈琁D鍜屽潗鏍囩紪鐮佷笉鑳戒负绌�");
             }
             if (1 > uploadService.selectCount4Coord(epsgCode)) {
                 return fail("鍧愭爣缂栫爜" + epsgCode + "涓嶅瓨鍦�");
@@ -124,92 +179,74 @@
             if (null == dir) {
                 return fail("鐩綍ID=" + dirid + "涓嶅瓨鍦�");
             }
-
-            List<MetaFileEntity> metas = uploadService.selectFiles(path, StaticData.ALL_EXTENSION);
-            if (null == metas || metas.isEmpty()) {
-                return fail("鐩綍" + path + "涓嬫煡鏃犳枃浠�");
+            VerEntity ver = verService.selectVersion(verid);
+            if (null == ver) {
+                return fail("鐗堟湰ID=" + verid + "涓嶅瓨鍦�");
             }
 
-            List<MetaFileEntity> list = uploadService.selectMappers(metas, dir, epsgCode);
+            UserEntity ue = tokenService.getCurrentUser(req);
+            List<MetaFileEntity> list = uploadService.selectMappers(ue, path, dir, ver, epsgCode);
 
             return success(list);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
-        }
-    }
-
-    /*@SysLog()
-    @ApiOperation(value = "鎻掑叆鏂囦欢")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "entity", value = "涓婁紶瀹炰綋绫�", dataType = "UploadEntity", paramType = "body")
-    })
-    @ResponseBody
-    @PostMapping(value = "/insertFiles")
-    public ResponseMsg<Object> insertFiles(@RequestBody UploadEntity entity, HttpServletRequest req) {
-        try {
-            UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue == null) {
-                return fail("鐢ㄦ埛鏈櫥褰�", null);
-            }
-            if (null == entity || null == entity.getMetaEntity()) {
-                return fail("鍏冩暟鎹俊鎭负绌�", null);
-            }
-
-            if (null == entity.getFileEntities() || entity.getFileEntities().isEmpty()) {
-                return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null);
-            }
-
-            MetaEntity me = entity.getMetaEntity();
-            me.setCreateTime(WebHelper.getCurrentTimestamp());
-            // me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime())))
-            me.setCreateUser(ue.getId());
-
-            // int rows = uploadService.insertFiles(me, entity.getFileEntities())
-
-            return success("鎴愬姛", 0);
-        } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
     @SysLog()
     @ApiOperation(value = "鎻掑叆鏂囦欢")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "entity", value = "涓婁紶瀹炰綋绫�", dataType = "UploadEntity", paramType = "body")
+            @ApiImplicitParam(name = "list", value = "鍏冩暟鎹枃浠堕泦鍚�", dataType = "MetaFileEntity", paramType = "body")
     })
     @ResponseBody
-    @PostMapping(value = "/insertFiles2")
-    public ResponseMsg<Object> insertFiles2(@RequestBody UploadEntity entity, HttpServletRequest req) {
+    @PostMapping(value = "/insertFiles")
+    public ResponseMsg<Object> insertFiles(@RequestBody List<MetaFileEntity> list, HttpServletRequest req) {
         try {
             UserEntity ue = tokenService.getCurrentUser(req);
-            if (ue == null) {
+            if (null == ue) {
                 return fail("鐢ㄦ埛鏈櫥褰�", null);
             }
-            if (null == entity || null == entity.getMetaEntity()) {
-                return fail("鍏冩暟鎹俊鎭负绌�", null);
+            if (null == list || list.isEmpty()) {
+                return fail("鍏冩暟鎹枃浠堕泦鍚堜负绌�", null);
             }
 
-            if (null == entity.getFileEntities() || entity.getFileEntities().isEmpty()) {
-                return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null);
-            }
+            uploadService.insertFiles(ue, list, req);
 
-            MetaEntity me = entity.getMetaEntity();
-            me.setCreateTime(WebHelper.getCurrentTimestamp());
-            // me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime())))
-            me.setCreateUser(ue.getId());
-
-            // uploadService.insertFiles(me, entity.getFileEntities(), entity.getTabEntities())
-
-            return success("鎴愬姛", entity.getTabEntities());
+            return success("鎴愬姛", list);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
-    }*/
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鎻掑叆KML鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "list", value = "鍏冩暟鎹枃浠堕泦鍚�", dataType = "MetaFileEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/insertKml")
+    public ResponseMsg<Object> insertKml(@RequestBody List<MetaFileEntity> list, HttpServletRequest req){
+        try {
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (null == ue) {
+                return fail("鐢ㄦ埛鏈櫥褰�", null);
+            }
+            if (null == list || list.isEmpty()) {
+                return fail("鍏冩暟鎹枃浠堕泦鍚堜负绌�", null);
+            }
+
+            uploadService.insertKml(ue, list);
+
+            return success("鎴愬姛", list);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
 
     @SysLog()
     @ApiOperation(value = "鍒犻櫎鍏冩暟鎹�")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", example = "1,2")
+            @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
     })
     @GetMapping(value = "/deleteMetas")
     public ResponseMsg<Integer> deleteMetas(@RequestParam List<Integer> ids) {
@@ -222,7 +259,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 }

--
Gitblit v1.9.3