From 9bce48a9f30f7d80c43f43f46d40df20fcb00e15 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 03 二月 2023 09:39:59 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/controller/data/upload/CheckController.java |  339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 333 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/data/upload/CheckController.java b/src/main/java/com/lf/server/controller/data/upload/CheckController.java
index 78063c0..a08764f 100644
--- a/src/main/java/com/lf/server/controller/data/upload/CheckController.java
+++ b/src/main/java/com/lf/server/controller/data/upload/CheckController.java
@@ -3,14 +3,27 @@
 import com.lf.server.annotation.SysLog;
 import com.lf.server.controller.all.BaseController;
 import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.all.StaticData;
 import com.lf.server.entity.ctrl.FmeReqEntity;
+import com.lf.server.helper.HttpHelper;
+import com.lf.server.helper.PathHelper;
 import com.lf.server.helper.StringHelper;
 import com.lf.server.service.data.FmeService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 妫�鏌ユ帶鍒跺櫒
@@ -18,7 +31,321 @@
  */
 public class CheckController extends BaseController {
     @Autowired
+    protected PathHelper pathHelper;
+
+    @Autowired
     protected FmeService fmeService;
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ浠诲姟鐘舵��")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "浠诲姟ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4")
+    })
+    @GetMapping(value = "/selectTaskStatus")
+    public Object selectTaskStatus(String id, HttpServletRequest req) {
+        try {
+            if (StringHelper.isEmpty(id)) {
+                return fail("id涓嶈兘涓虹┖");
+            }
+
+            return fmeService.getTaskStatus(id, req);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "涓嬭浇璐ㄦ閿欒缁撴灉")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "浠诲姟ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4")
+    })
+    @GetMapping(value = "/downloadResult")
+    public void downloadResult(String id, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            if (!StringHelper.isEmpty(id)) {
+                String url = fmeService.getDownloadUrl(id, req);
+
+                HttpHelper httpHelper = new HttpHelper();
+                // res.sendRedirect(url)
+                httpHelper.service(req, res, url, null);
+            }
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鎻愪氦鏁版嵁璐ㄦ")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "entity", value = "FME璇锋眰瀹炰綋绫�", dataType = "FmeReqEntity", paramType = "body")
+    })
+    @ResponseBody
+    @PostMapping(value = "/uploadChecks")
+    public ResponseMsg<Object> uploadChecks(@RequestBody FmeReqEntity entity, HttpServletRequest req) {
+        try {
+            if (StringHelper.isEmpty(entity.names)) {
+                return fail("浠诲姟鍚嶇О涓嶈兘涓虹┖");
+            }
+            if (StringHelper.isEmpty(entity.zipPath)) {
+                return fail("璇烽�夋嫨寰呰川妫�鐨剒ip鏂囦欢");
+            }
+
+            entity.zipPath = getFullPath(entity.zipPath);
+            if (!isZipFile(entity.zipPath)) {
+                return fail("寰呰川妫�鐨剒ip鏂囦欢涓嶅瓨鍦�");
+            }
+            if (entity.names.contains(StaticData.CHECK_MAIN)) {
+                entity.wbsPath = getFullPath(entity.wbsPath);
+                if (!isXlsFile(entity.wbsPath)) {
+                    return fail("寰呰川妫�鐨刉BS鏂囦欢涓嶅瓨鍦�");
+                }
+            }
+
+            List<String> list = new ArrayList<>();
+            for (String name : entity.names.split(StaticData.COMMA)) {
+                String guid = invoke(name, entity, req);
+                list.add(guid);
+            }
+
+            return success(list);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    /**
+     * 鑾峰彇鏂囦欢璺緞
+     */
+    private String getFullPath(String filePath) {
+        return null == filePath ? null : pathHelper.getConfig().getTempPath() + File.separator + filePath;
+    }
+
+    /**
+     * 鏄�/鍚︿负Zip鏂囦欢
+     */
+    private boolean isZipFile(String filePath) {
+        if (null == filePath || !filePath.toLowerCase().endsWith(StaticData.ZIP)) {
+            return false;
+        }
+
+        File zipFile = new File(filePath);
+
+        return zipFile.exists() && !zipFile.isDirectory();
+    }
+
+    /**
+     * 鏄�/鍚︿负Excel鏂囦欢
+     */
+    private boolean isXlsFile(String filePath) {
+        if (null == filePath) {
+            return false;
+        }
+        if (!(filePath.toLowerCase().endsWith(StaticData.XLS) || filePath.toLowerCase().endsWith(StaticData.XLSX))) {
+            return false;
+        }
+
+        File zipFile = new File(filePath);
+
+        return zipFile.exists() && !zipFile.isDirectory();
+    }
+
+    /**
+     * 鏂规硶璋冪敤
+     */
+    private String invoke(String name, FmeReqEntity entity, HttpServletRequest req) throws Exception {
+        Method method;
+        try {
+            method = FmeService.class.getDeclaredMethod(name, FmeReqEntity.class, HttpServletRequest.class);
+        } catch (Exception ex) {
+            throw new Exception(name + "锛岃妫�鏌ユ柟娉曚笉瀛樺湪");
+        }
+
+        Object obj = method.invoke(fmeService, entity, req);
+
+        return null == obj ? null : obj.toString();
+    }
+
+    /*@SysLog()
+    @ApiOperation(value = "鏌ヨOSGB妫�鏌�")
+    @GetMapping(value = "/selectCheckOsgb")
+    public ResponseMsg<Object> selectCheckOsgb(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\OSGB妫�鏌�.zip";
+            fme.imgResolution = 0.2;
+
+            String rs = fmeService.checkOsgb(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ琛ㄦ牸鏁版嵁妫�鏌�")
+    @GetMapping(value = "/selectCheckXls")
+    public ResponseMsg<Object> selectCheckXls(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.sjzy = "娴嬮噺涓撲笟";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\琛ㄦ牸鏁版嵁妫�鏌�.zip";
+
+            String rs = fmeService.checkXls(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ鐐逛簯妫�鏌�")
+    @GetMapping(value = "/selectCheckLaz")
+    public ResponseMsg<Object> selectCheckLaz(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鐐逛簯妫�鏌�.zip";
+            fme.lazDensity = 1;
+
+            String rs = fmeService.checkLaz(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ楂樼▼妫�鏌�")
+    @GetMapping(value = "/selectCheckDem")
+    public ResponseMsg<Object> selectCheckDem(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\楂樼▼妫�鏌�.zip";
+            fme.demTolerance = 5;
+            fme.demChangeRate = 200;
+
+            String rs = fmeService.checkDem(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ灞炴�ф鏌�")
+    @GetMapping(value = "/selectCheckAttrs")
+    public ResponseMsg<Object> selectCheckAttrs(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.sjzy = "娴嬮噺涓撲笟";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\灞炴�ф鏌�.zip";
+
+            String rs = fmeService.checkAttrs(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ鎷撴墤妫�鏌�")
+    @GetMapping(value = "/selectCheckTopology")
+    public ResponseMsg<Object> selectCheckTopology(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鎷撴墤妫�鏌�.zip";
+            fme.polyTolerance = 0.001;
+            fme.lineTolerance = 0.001;
+            fme.pointTolerance = 0.001;
+            fme.gcdOffset = 20;
+            fme.kzdOffset = 100;
+            fme.rangeOffset = 200;
+            fme.xgMax = 0.005;
+
+            String rs = fmeService.checkTopology(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ鍥鹃潰鏁撮グ妫�鏌�")
+    @GetMapping(value = "/selectCheckDecorate")
+    public ResponseMsg<Object> selectCheckDecorate(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鍥鹃潰鏁撮グ妫�鏌�.zip";
+            fme.xlsList = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鏂囦欢娓呭崟.xlsx";
+
+            String rs = fmeService.checkDecorate(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "鏌ヨ鍘熺偣妫�鏌�")
+    @GetMapping(value = "/selectCheckOrigin")
+    public ResponseMsg<Object> selectCheckOrigin(HttpServletRequest req) {
+        try {
+            FmeReqEntity fme = new FmeReqEntity();
+            fme.name = StringHelper.getGuid();
+            fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鍘熺偣妫�鏌�.zip";
+
+            String rs = fmeService.checkOrigin(fme, req);
+            if (StringHelper.isEmpty(rs)) {
+                return fail("妫�鏌ュけ璐�");
+            }
+
+            return success(rs);
+        } catch (Exception ex) {
+            return fail(ex.getMessage(), null);
+        }
+    }
 
     @SysLog()
     @ApiOperation(value = "鏌ヨ鏍呮牸妫�鏌�")
@@ -29,7 +356,7 @@
             fme.name = StringHelper.getGuid();
             fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
             fme.sjzy = "娴嬮噺涓撲笟";
-            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230106135746\\鏍呮牸妫�鏌�.zip";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鏍呮牸妫�鏌�.zip";
             fme.coordinateSystem = "CGCS2000/GK3d-93E_FME";
             fme.imgResolution = 0.2;
 
@@ -53,7 +380,7 @@
             fme.name = StringHelper.getGuid();
             fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
             fme.sjzy = "娴嬮噺涓撲笟";
-            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230106135746\\鏁板鍩虹妫�鏌�.zip";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鏁板鍩虹妫�鏌�.zip";
 
             String rs = fmeService.checkMath(fme, req);
             if (StringHelper.isEmpty(rs)) {
@@ -75,7 +402,7 @@
             fme.name = StringHelper.getGuid();
             fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
             fme.sjzy = "娴嬮噺涓撲笟";
-            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230106135746\\鍏冩暟鎹鏌�.zip";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\鍏冩暟鎹鏌�.zip";
 
             String rs = fmeService.checkMeta(fme, req);
             if (StringHelper.isEmpty(rs)) {
@@ -97,8 +424,8 @@
             fme.name = StringHelper.getGuid();
             fme.xmmc = "瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�";
             fme.sjzy = "娴嬮噺涓撲笟";
-            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230106135746\\瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�.7z";
-            fme.wbsPath = "D:\\Project\\Data\\LF\\temp\\20230106135746\\椤圭洰WBS瀵煎嚭.xlsx";
+            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\瑗挎皵涓滆緭鍥涚嚎澶╃劧姘旂閬撳伐绋嬶紙鍚愰瞾鐣�-涓崼锛夛紙00116BT02锛�.7z";
+            fme.wbsPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\椤圭洰WBS瀵煎嚭.xlsx";
             fme.isDiZai = "NO";
             fme.diZaiType = "NO";
 
@@ -111,5 +438,5 @@
         } catch (Exception ex) {
             return fail(ex.getMessage(), null);
         }
-    }
+    }*/
 }

--
Gitblit v1.9.3