From d23b2ce1ae45c192aed067041da8de748b97d405 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 22 十一月 2024 14:19:31 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/data/FmeService.java |  341 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 314 insertions(+), 27 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 7057092..6cefe9f 100644
--- a/src/main/java/com/lf/server/service/data/FmeService.java
+++ b/src/main/java/com/lf/server/service/data/FmeService.java
@@ -1,8 +1,21 @@
 package com.lf.server.service.data;
 
-import com.lf.server.config.PropertiesConfig;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.lf.server.entity.ctrl.FmeReqEntity;
+import com.lf.server.entity.ctrl.NameValueEntity;
+import com.lf.server.entity.ctrl.RegisterEntity;
+import com.lf.server.entity.data.MetaFileEntity;
+import com.lf.server.helper.RestHelper;
+import com.lf.server.helper.StringHelper;
+import com.lf.server.helper.WebHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 /**
  * FME鏈嶅姟绫�
@@ -10,83 +23,357 @@
  */
 @Service
 public class FmeService {
-    @Autowired
-    PropertiesConfig propertiesConfig;
+    @Value("${sys.fmeUrl}")
+    private String fmeUrl;
+
+    @Value("${sys.fmeToken}")
+    private String fmeToken;
+
+    private final static Log log = LogFactory.getLog(FmeService.class);
 
     /**
-     * OSGB妫�鏌ワ細.osgb + .xls/.xlsx
+     * 鑾峰彇浠诲姟鐘舵��
      */
-    public void checkOsgb(){
+    public Object getTaskStatus(String id, HttpServletRequest req) {
+        String url = getUrl("datax/task/get", req) + "&id=" + id;
 
+        return RestHelper.getForRest(url, Object.class);
     }
 
     /**
-     * 琛ㄦ牸鏁版嵁妫�鏌ワ細.xls/.xlsx
+     * 涓嬭浇璐ㄦ閿欒缁撴灉
      */
-    public void checkXls(){
-
+    public String getDownloadUrl(String id, HttpServletRequest req) {
+        return getUrl("datax/task/downloadResult", req) + "&id=" + id;
     }
 
     /**
-     * 鐐逛簯妫�鏌ワ細.laz + .xls/.xlsx
+     * 1.OSGB妫�鏌ワ細.osgb + *鍊炬枩鎽勫奖*.xls/.xlsx
      */
-    public void checkLaz(){
+    public String checkOsgb(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A8鎴愭灉璐ㄦ_OSGB妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("OSGB妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("DMYX_FBL", fme.imgResolution));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 楂樼▼妫�鏌ワ細.tif/.tfw/.tif.ovr + .dwg
+     * 2.琛ㄦ牸鏁版嵁妫�鏌ワ細.xls/.xlsx锛堟帓闄ゅ厓鏁版嵁锛�
      */
-    public void checkDem(){
+    public String checkXls(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A3鎴愭灉璐ㄦ_琛ㄦ牸鏁版嵁妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("琛ㄦ牸鏁版嵁妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 灞炴�ф鏌ワ細.dwg, *dlg.gdb
+     * 3.鐐逛簯妫�鏌ワ細.laz + *婵�鍏夌偣浜�*.xls/.xlsx
      */
-    public void checkAttrs(){
+    public String checkLaz(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A9鎴愭灉璐ㄦ_鐐逛簯妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("鐐逛簯妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("LAZ_MD", fme.lazDensity));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鎷撴墤妫�鏌ワ細*鍦板舰鍥�.dwg
+     * 4.楂樼▼妫�鏌ワ細.tif/.prj/.tfw/.tif.ovr + *鍦板舰鍥�*.dwg
      */
-    public void checkTopology(){
+    public String checkDem(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A6鎴愭灉璐ㄦ_楂樼▼妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("楂樼▼妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("GCZWC", fme.demTolerance));
+        list.add(new NameValueEntity("ChangeRate", fme.demChangeRate));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鍥鹃潰鏁撮グ妫�鏌ワ細.dwg
+     * 5.灞炴�ф鏌ワ細*dlg*.gdb + *鍦板舰鍥�*.dwg
      */
-    public void checkDecorate(){
+    public String checkAttrs(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A5鎴愭灉璐ㄦ_灞炴�ф鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("灞炴�ф鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鍘熺偣妫�鏌ワ細鍓栭潰鍥�.dwg
+     * 6.鎷撴墤妫�鏌ワ細*鍦板舰鍥�*.dwg
      */
-    public void checkOrigin(){
+    public String checkTopology(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A4鎴愭灉璐ㄦ_鎷撴墤妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("鎷撴墤妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("S_MCDRC", fme.tolerance));
+        list.add(new NameValueEntity("S_XCDRC", fme.tolerance));
+        list.add(new NameValueEntity("S_DCDRC", fme.tolerance));
+        list.add(new NameValueEntity("OFFSET_GCD", fme.gcdOffset));
+        list.add(new NameValueEntity("OFFSET_KZD", fme.kzdOffset));
+        list.add(new NameValueEntity("Range_OFFSET", fme.rangeOffset));
+        list.add(new NameValueEntity("XG_MAX", fme.xgMax));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鏍呮牸妫�鏌ワ細.tif/.tfw/.tif.ovr + .xls/.xlsx
+     * 7.鍥鹃潰鏁撮グ妫�鏌ワ細.dwg
      */
-    public void checkDom(){
+    public String checkDecorate(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A10鎴愭灉璐ㄦ_鍥鹃潰鏁撮グ妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("鍥鹃潰鏁撮グ妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("S_XLS", "$(ZJPZWJ)\\璐ㄦ閰嶇疆琛ㄦ��.xlsx"));
+        list.add(new NameValueEntity("S_XLS2", "D:\\Project\\Data\\LF\\temp\\20230107010101\\鏂囦欢娓呭崟.xlsx"));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鏁板鍩虹妫�鏌ワ細.shp, .gdb, .xls/.xlsx
+     * 8.鍘熺偣妫�鏌ワ細*鍓栭潰鍥�*.dwg
      */
-    public void checkMath(){
+    public String checkOrigin(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A11鎴愭灉璐ㄦ_鍘熺偣妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("鍘熺偣妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
     }
 
     /**
-     * 鍏冩暟鎹鏌ワ細.xls/.xlsx
+     * 9.鏍呮牸妫�鏌ワ細.tif/.prj/.tfw/.tif.ovr + .xls/.xlsx
      */
-    public void checkMeta(){
+    public String checkDom(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/A7鎴愭灉璐ㄦ_鏍呮牸妫�鏌�", req);
 
+        List<NameValueEntity> list = getKeyValues("鏍呮牸妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("S_CoordinateSystem", fme.coordinateSystem));
+        list.add(new NameValueEntity("DMYX_FBL", fme.imgResolution));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 10.鏁板鍩虹妫�鏌ワ細.shp, .gdb, *鍏冩暟鎹�*.xls/.xlsx
+     */
+    public String checkMath(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/B1鍏ュ簱璐ㄦ_鏁板鍩虹妫�鏌�", req);
+
+        List<NameValueEntity> list = getKeyValues("鏁板鍩虹妫�鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 11.鍏冩暟鎹鏌ワ細*鍏冩暟鎹�*.xls/.xlsx
+     */
+    public String checkMeta(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/B5鍏ュ簱璐ㄦ_鍏冩暟鎹鏌�", req);
+
+        List<NameValueEntity> list = getKeyValues("鍏冩暟鎹鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 12.鎬昏川妫�锛�.zip/.7z + .xls/.xlsx
+     */
+    public String checkMain(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/B0鍏ュ簱璐ㄦ__鎬�", req);
+
+        List<NameValueEntity> list = getKeyValues("鎬昏川妫�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("S_WBSBG", fme.wbsPath));
+        list.add(new NameValueEntity("S_DZDK", fme.isDiZai));
+        list.add(new NameValueEntity("DZ_ZLLX", fme.diZaiType));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 13.閫昏緫涓�鑷存�ф鏌ワ細.dwg/.xls/.xlsx
+     */
+    public String checkLogical(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/B3鍏ュ簱璐ㄦ_閫昏緫涓�鑷存�ф鏌�", req);
+
+        List<NameValueEntity> list = getKeyValues("閫昏緫涓�鑷存�ф鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 14.鍗曢」鎴愭灉瀹屾暣鎬ф鏌ワ細.*
+     */
+    public String checkSingleIntegrity(FmeReqEntity fme, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/B6鍏ュ簱璐ㄦ_鍗曢」鎴愭灉瀹屾暣鎬ф鏌�", req);
+
+        List<NameValueEntity> list = getKeyValues("鍗曢」鎴愭灉瀹屾暣鎬ф鏌�");
+        list.add(new NameValueEntity("XMMC", fme.xmmc));
+        list.add(new NameValueEntity("SJZY", fme.sjzy));
+        list.add(new NameValueEntity("GCXMYSB", fme.zipPath));
+        list.add(new NameValueEntity("SJFL", fme.sjfl));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * a.琛ㄦ牸鍏ュ簱锛歋_RKBG銆乨irid銆乸arentid锛屽涓互鑻辨枃閫楀彿闅斿紑
+     */
+    public String excelLoader(MetaFileEntity meta, HttpServletRequest req) {
+        String url = getUrl("datax/task/run/琛ㄦ牸鍏ュ簱", req);
+
+        List<NameValueEntity> list = getKeyValues("琛ㄦ牸鍏ュ簱");
+        list.add(new NameValueEntity("S_RKBG", meta.getPath()));
+        list.add(new NameValueEntity("COORDSYS", meta.getEpsgCode()));
+        list.add(new NameValueEntity("dirid", meta.getName()));
+        list.add(new NameValueEntity("depid", meta.getDepcode()));
+        list.add(new NameValueEntity("verid", meta.getVerid()));
+        list.add(new NameValueEntity("createuser", meta.getCreateUser()));
+        list.add(new NameValueEntity("parentid", meta.getEventid()));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * b.CRDS骞冲彴浜や粯
+     */
+    public String crdsPackaging(String dirCode, String major, String isCut, HttpServletRequest req) {
+        // datax/task/run/CRDS骞冲彴浜や粯_娴嬭瘯
+        String url = getUrl("datax/task/run/CRDS骞冲彴浜や粯_code娴嬭瘯", req);
+
+        List<NameValueEntity> list = getKeyValues("CRDS骞冲彴浜や粯");
+        list.add(new NameValueEntity("S_FFXMMC", dirCode));
+        list.add(new NameValueEntity("MBZY", major));
+        list.add(new NameValueEntity("P_WBFW", isCut));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * c.鏈嶅姟娉ㄥ唽
+     */
+    public RegisterEntity serverRegister(String name, String serverUri, String type, HttpServletRequest req) {
+        String url = getUrl("resource/res/item", req);
+
+        RegisterEntity entity = new RegisterEntity(name, serverUri, type);
+
+        String resid = RestHelper.postForRest(url, entity);
+        entity.setSerialnum(resid);
+
+        return entity;
+    }
+
+    /**
+     * d.鏈嶅姟鐢宠
+     */
+    public void serverApply(String id, Integer pubid, HttpServletRequest req) {
+        try {
+            String url = getUrl("resource/res/request", req) + "&resourceid=" + id;
+
+            RegisterEntity entity = new RegisterEntity(pubid);
+
+            RestHelper.postForRest(url, entity);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+    }
+
+    /**
+     * e.鍒犻櫎璧勬簮
+     */
+    public void deleteRes(String id, HttpServletRequest req) {
+        String url = getUrl("resource/res/hashid", req) + "&hashid=" + id;
+
+        RestHelper.deleteForRest(url);
+    }
+
+    /**
+     * f.璁$畻闈㈢Н
+     */
+    public String calcArea(String sjfl, String id, String wjlj) {
+        String url = getUrl("datax/task/run/鏁版嵁鍗犲湴闈㈢Н璁$畻");
+
+        List<NameValueEntity> list = new ArrayList<>();
+        list.add(new NameValueEntity("_name", String.format("%s_%s", "鏁版嵁鍗犲湴闈㈢Н璁$畻", StringHelper.YMDHMS2_FORMAT.format(new Date()))));
+        list.add(new NameValueEntity("_terminate_on_error", false));
+        list.add(new NameValueEntity("_priority", 100));
+        list.add(new NameValueEntity("SJFL", sjfl));
+        list.add(new NameValueEntity("ID", id));
+        list.add(new NameValueEntity("WJLJ", wjlj));
+
+        return RestHelper.postForRest(url, list);
+    }
+
+    /**
+     * 鑾峰彇Url
+     */
+    public String getUrl(String subUrl, HttpServletRequest req) {
+        String token = WebHelper.getToken(req);
+
+        return fmeUrl + subUrl + "?token=" + token;
+    }
+
+    /**
+     * 鑾峰彇Url
+     */
+    public String getUrl(String subUrl) {
+        return fmeUrl + subUrl + "?token=" + fmeToken;
+    }
+
+    /**
+     * 鑾峰彇鍚嶇О鍊煎闆嗗悎
+     */
+    public List<NameValueEntity> getKeyValues(String name) {
+        List<NameValueEntity> list = new ArrayList<>();
+        list.add(new NameValueEntity("_name", String.format("%s_%s", name, StringHelper.YMDHMS2_FORMAT.format(new Date()))));
+        list.add(new NameValueEntity("_priority", 100));
+        list.add(new NameValueEntity("_terminate_on_error", false));
+        list.add(new NameValueEntity("IID", ""));
+        list.add(new NameValueEntity("FANOUT_DIR", "$(OrgResultStorage)"));
+        list.add(new NameValueEntity("IID_JL", "$(ZJPZWJ)\\IID璁板綍琛�.xlsx"));
+        list.add(new NameValueEntity("S_ZJXZ", "$(ZJPZWJ)\\璐ㄦ缁嗗垯鎬�.xlsx"));
+        list.add(new NameValueEntity("S_BZPZB", "$(ZJPZWJ)\\璐ㄦ閰嶇疆琛ㄦ��.xlsx"));
+
+        return list;
     }
 }

--
Gitblit v1.9.3