From 1e4cafb7b48c3aac7b6111ff496cac0a40807435 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 26 九月 2024 12:38:10 +0800
Subject: [PATCH] 修改配置文件

---
 src/main/java/com/se/simu/config/PropertiesConfig.java |  159 +++++++++++
 src/main/java/com/se/simu/service/GedbService.java     |   90 ++----
 src/main/java/com/se/simu/domain/dto/ConfigDto.java    |  469 +++++++++++++++++++++++++++++++++
 src/main/java/com/se/simu/service/SimuService.java     |   18 
 src/main/java/com/se/simu/service/WaterService.java    |   20 
 src/main/java/com/se/simu/config/InitConfig.java       |    2 
 src/main/resources/application.yml                     |   25 +
 7 files changed, 690 insertions(+), 93 deletions(-)

diff --git a/src/main/java/com/se/simu/config/InitConfig.java b/src/main/java/com/se/simu/config/InitConfig.java
index 9553d32..ac399bc 100644
--- a/src/main/java/com/se/simu/config/InitConfig.java
+++ b/src/main/java/com/se/simu/config/InitConfig.java
@@ -34,7 +34,7 @@
         // noinspection AlibabaRemoveCommentedCode
         try {
             log.info("***************** 鍒濆鍖� GDAL *****************" + "\n");
-            GdalHelper.init(env.getProperty("sys.path.gdalPath"));
+            GdalHelper.init(env.getProperty("config.gdalPath"));
 
             String path = null != contextPath && contextPath.length() > 1 ? contextPath : "";
             log.info("API鏂囨。:http://localhost:" + serverPort + path + "/doc.html");
diff --git a/src/main/java/com/se/simu/config/PropertiesConfig.java b/src/main/java/com/se/simu/config/PropertiesConfig.java
new file mode 100644
index 0000000..e107405
--- /dev/null
+++ b/src/main/java/com/se/simu/config/PropertiesConfig.java
@@ -0,0 +1,159 @@
+package com.se.simu.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+
+/**
+ * 灞炴�ч厤缃被
+ *
+ * @author WWW
+ * @date 2024-09-26
+ */
+@Configuration
+@SuppressWarnings("ALL")
+@ConfigurationProperties(prefix = "config")
+public class PropertiesConfig {
+    private String ver;
+
+    private String inPath;
+
+    private String outPath;
+
+    private String host;
+
+    private String user;
+
+    private String pwd;
+
+    private String dbName;
+
+    private Integer pageSize;
+
+    private List<String> layerNames;
+
+    private List<String > shpNames;
+
+    private String demName;
+
+    private String demType;
+
+    private String demFile;
+
+    //@Value("#{'${config.sysFields}'}")
+    private List<String> sysFields;
+
+    public String getVer() {
+        return ver;
+    }
+
+    public void setVer(String ver) {
+        this.ver = ver;
+    }
+
+    public String getInPath() {
+        return inPath;
+    }
+
+    public void setInPath(String inPath) {
+        this.inPath = inPath;
+    }
+
+    public String getOutPath() {
+        return outPath;
+    }
+
+    public void setOutPath(String outPath) {
+        this.outPath = outPath;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getPwd() {
+        return pwd;
+    }
+
+    public void setPwd(String pwd) {
+        this.pwd = pwd;
+    }
+
+    public String getDbName() {
+        return dbName;
+    }
+
+    public void setDbName(String dbName) {
+        this.dbName = dbName;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public List<String> getLayerNames() {
+        return layerNames;
+    }
+
+    public void setLayerNames(List<String> layerNames) {
+        this.layerNames = layerNames;
+    }
+
+    public List<String> getShpNames() {
+        return shpNames;
+    }
+
+    public void setShpNames(List<String> shpNames) {
+        this.shpNames = shpNames;
+    }
+
+    public String getDemName() {
+        return demName;
+    }
+
+    public void setDemName(String demName) {
+        this.demName = demName;
+    }
+
+    public String getDemType() {
+        return demType;
+    }
+
+    public void setDemType(String demType) {
+        this.demType = demType;
+    }
+
+    public String getDemFile() {
+        return demFile;
+    }
+
+    public void setDemFile(String demFile) {
+        this.demFile = demFile;
+    }
+
+    public List<String> getSysFields() {
+        return sysFields;
+    }
+
+    public void setSysFields(List<String> sysFields) {
+        this.sysFields = sysFields;
+    }
+}
diff --git a/src/main/java/com/se/simu/domain/dto/ConfigDto.java b/src/main/java/com/se/simu/domain/dto/ConfigDto.java
new file mode 100644
index 0000000..9796cc3
--- /dev/null
+++ b/src/main/java/com/se/simu/domain/dto/ConfigDto.java
@@ -0,0 +1,469 @@
+package com.se.simu.domain.dto;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * uwsolver閰嶇疆绫�
+ *
+ * @author WWW
+ * @date 2024-09-26
+ */
+@SuppressWarnings("ALL")
+public class ConfigDto {
+    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
+
+    // 妗堜緥鏂囦欢澶癸紝蹇呴』鎸囧畾锛屽彲浠ユ槸鐩稿璺緞锛岄粯璁ゅ湪姹傝В鍣ㄥ綋鍓嶇洰褰曚笅
+    private String casedir = "case";
+    // 鍦板舰鏂囦欢锛屼粎闇�鎸囧畾鏂囦欢鍚嶏紙鍚屼笅锛夛紝鏃犻渶鎸囧畾璺緞锛岄粯璁よ矾寰勫湪妗堜緥鏂囦欢澶逛笅
+    private String terrain_file = "DEM4548.tif";
+    // 缃戞牸鏂囦欢锛屽湪涓嶆彁渚涚殑鎯呭喌涓嬮粯璁ら�氳繃studyzone_file杩涜鐢熸垚
+    private String mesh_file = "tongzhou-mini.msh";
+    // 婕旂畻鍖哄煙鏂囦欢锛屽湪涓嶆彁渚涚綉鏍兼枃浠剁殑鍓嶆彁涓嬪繀椤绘寚瀹�
+    private String studyzone_file = "studyzone_difference.shp";
+    // 缁嗗寲鍖哄煙鏂囦欢锛岄�氳繃studyzone_file鐢熸垚缃戞牸鏂囦欢鏃朵娇鐢紝鍙笉鎻愪緵锛屽垯榛樿鍧囧寑缃戞牸灏哄
+    private String refinezones_file = "refinezones.shp";
+    // 寤虹瓚鍖哄煙鏂囦欢锛岄�氳繃studyzone_file鐢熸垚缃戞牸鏂囦欢鏃朵娇鐢紝鍙笉鎻愪緵
+    private String buildings_file = "buildings_inside.shp";
+    // 绠$綉鑺傜偣鏂囦欢锛屽繀椤绘寚瀹氾紝鐢ㄤ簬鐢熸垚姹傝В鏂囦欢
+    private String nodes_file = "pipeline-demo-point.shp";
+    // 绠$綉绠℃鏂囦欢锛屽繀椤绘寚瀹氾紝鐢ㄤ簬鐢熸垚姹傝В鏂囦欢
+    private String links_file = "pipeline-demo-conduit.shp";
+    // 绠$綉闆嗘按鐐规枃浠讹紝鍗冲叿鏈夋眹闆嗕竴瀹氳寖鍥村唴闄嶆按鐨勯洦姘寸畢銆侀洦姘翠簳绛夛紝蹇呴』鎸囧畾锛岀敤浜庣敓鎴愭眰瑙f枃浠�
+    private String junctions_file = "pipeline-demo-point-junctions.shp";
+    // 闄嶉洦鏂囦欢锛屽繀椤绘寚瀹氾紝鐢ㄤ簬鐢熸垚姹傝В鏂囦欢
+    private String raingage_file = "RainGage.dat";
+    // 闃叉椽闅滅鐗╂枃浠讹紝鍙笉鎻愪緵
+    private String barrier_file = "barrier.shp";
+    // 鎺掓按绯荤粺缁撴灉鏂囦欢锛岀敤浜庝繚瀛樼娈�/绠$偣鐨勬按浣嶃�佹祦閲忕瓑淇℃伅
+    private String drainage_outfile = "tongzhou-mini-drainage.h5";
+    // 鍦伴潰姘翠綅缁撴灉鏂囦欢锛岀敤浜庝繚瀛樺湴闈㈡按浣嶄俊鎭�
+    private String sww_outfile = "tongzhou-mini.sww";
+    // 娴侀噺鍗曚綅锛屼粎鎻愪緵LPS锛堝崌/绉掞級銆丆MS锛堢珛鏂圭背/绉�)銆丆FS(绔嬫柟鑻卞昂/绉�)涓夌鍗曚綅
+    private String flow_units = "LPS";
+    private String infiltration = "HORTON";
+    private String link_offsets = "DEPTH";
+    private Double min_slope = 0.01;
+    private String allow_ponding = "NO";
+    private String skip_steady_state = "NO";
+    private String flow_routing = "DYNWAVE";
+    // 婕旂畻寮�濮嬫椂鍒�
+    private String start_datetime = "06/12/2024 12:00:00";
+    // 婕旂畻缁撴潫鏃跺埢
+    private String end_datetime = "06/12/2024 13:00:00";
+    // 缁撴灉淇濆瓨鐨勮捣濮嬫椂鍒�
+    private String report_start_datetime = "06/12/2024 00:00:00";
+    // 缁撴灉淇濆瓨鏃堕棿闂撮殧
+    private String report_step = "00:01:00";
+    // 鎺掓按绠$綉婕旂畻鏃堕棿姝ラ暱锛岄粯璁ゅ崟浣嶄负s
+    private String routing_step = "00:00:10";
+    private String inertial_damping = "PARTIAL";
+    private String normal_flow_limited = "BOTH";
+    private String force_main_equation = "H-W";
+    private Integer max_trials = 20;
+    private Double minimum_step = 0.1;
+    private Double min_surfarea = 0.5;
+    private Integer threads = 8;
+    private Double Manning = 0.014;
+    private Integer areas_slope = 1;
+    private Integer areas_imperv = 80;
+    private Double areas_n_imperv = 0.015;
+    private Double areas_n_perv = 0.24;
+    private Double areas_storage_imperv = 0.06;
+    private Integer areas_storage_perv = 3;
+    private Integer areas_pct_zero = 25;
+    private Integer init_depth = 0;
+    private Double friction = 0.01;
+    private Double terrain_smoothing = 0.1;
+    private String flow_algorithm = "DE1";
+    // 缃戞牸鍗曞厓鏈�澶ч潰绉紝榛樿鍗曚綅涓簃
+    private Integer mesh_size = 5;
+    // 缁撴灉淇濆瓨棰戠巼锛岀浉瀵箁eport_step鏉ヨ锛屾瘮濡俿ave_step=3灏辫〃绀烘瘡闂撮殧2涓猺eport_step淇濆瓨涓�娆$粨鏋�
+    private Integer save_step = 1;
+
+    public void setCalcTime(Integer minutes) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.set(Calendar.HOUR, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+
+        String start = DATE_FORMAT.format(calendar.getTime());
+        calendar.add(Calendar.MINUTE, minutes);
+        String end = DATE_FORMAT.format(calendar.getTime());
+
+        this.start_datetime = start;
+        this.report_start_datetime = start;
+        this.end_datetime = end;
+    }
+
+    public String getCasedir() {
+        return casedir;
+    }
+
+    public void setCasedir(String casedir) {
+        this.casedir = casedir;
+    }
+
+    public String getTerrain_file() {
+        return terrain_file;
+    }
+
+    public void setTerrain_file(String terrain_file) {
+        this.terrain_file = terrain_file;
+    }
+
+    public String getMesh_file() {
+        return mesh_file;
+    }
+
+    public void setMesh_file(String mesh_file) {
+        this.mesh_file = mesh_file;
+    }
+
+    public String getStudyzone_file() {
+        return studyzone_file;
+    }
+
+    public void setStudyzone_file(String studyzone_file) {
+        this.studyzone_file = studyzone_file;
+    }
+
+    public String getRefinezones_file() {
+        return refinezones_file;
+    }
+
+    public void setRefinezones_file(String refinezones_file) {
+        this.refinezones_file = refinezones_file;
+    }
+
+    public String getBuildings_file() {
+        return buildings_file;
+    }
+
+    public void setBuildings_file(String buildings_file) {
+        this.buildings_file = buildings_file;
+    }
+
+    public String getNodes_file() {
+        return nodes_file;
+    }
+
+    public void setNodes_file(String nodes_file) {
+        this.nodes_file = nodes_file;
+    }
+
+    public String getLinks_file() {
+        return links_file;
+    }
+
+    public void setLinks_file(String links_file) {
+        this.links_file = links_file;
+    }
+
+    public String getJunctions_file() {
+        return junctions_file;
+    }
+
+    public void setJunctions_file(String junctions_file) {
+        this.junctions_file = junctions_file;
+    }
+
+    public String getRaingage_file() {
+        return raingage_file;
+    }
+
+    public void setRaingage_file(String raingage_file) {
+        this.raingage_file = raingage_file;
+    }
+
+    public String getBarrier_file() {
+        return barrier_file;
+    }
+
+    public void setBarrier_file(String barrier_file) {
+        this.barrier_file = barrier_file;
+    }
+
+    public String getDrainage_outfile() {
+        return drainage_outfile;
+    }
+
+    public void setDrainage_outfile(String drainage_outfile) {
+        this.drainage_outfile = drainage_outfile;
+    }
+
+    public String getSww_outfile() {
+        return sww_outfile;
+    }
+
+    public void setSww_outfile(String sww_outfile) {
+        this.sww_outfile = sww_outfile;
+    }
+
+    public String getFlow_units() {
+        return flow_units;
+    }
+
+    public void setFlow_units(String flow_units) {
+        this.flow_units = flow_units;
+    }
+
+    public String getInfiltration() {
+        return infiltration;
+    }
+
+    public void setInfiltration(String infiltration) {
+        this.infiltration = infiltration;
+    }
+
+    public String getLink_offsets() {
+        return link_offsets;
+    }
+
+    public void setLink_offsets(String link_offsets) {
+        this.link_offsets = link_offsets;
+    }
+
+    public Double getMin_slope() {
+        return min_slope;
+    }
+
+    public void setMin_slope(Double min_slope) {
+        this.min_slope = min_slope;
+    }
+
+    public String getAllow_ponding() {
+        return allow_ponding;
+    }
+
+    public void setAllow_ponding(String allow_ponding) {
+        this.allow_ponding = allow_ponding;
+    }
+
+    public String getSkip_steady_state() {
+        return skip_steady_state;
+    }
+
+    public void setSkip_steady_state(String skip_steady_state) {
+        this.skip_steady_state = skip_steady_state;
+    }
+
+    public String getFlow_routing() {
+        return flow_routing;
+    }
+
+    public void setFlow_routing(String flow_routing) {
+        this.flow_routing = flow_routing;
+    }
+
+    public String getStart_datetime() {
+        return start_datetime;
+    }
+
+    public void setStart_datetime(String start_datetime) {
+        this.start_datetime = start_datetime;
+    }
+
+    public String getEnd_datetime() {
+        return end_datetime;
+    }
+
+    public void setEnd_datetime(String end_datetime) {
+        this.end_datetime = end_datetime;
+    }
+
+    public String getReport_start_datetime() {
+        return report_start_datetime;
+    }
+
+    public void setReport_start_datetime(String report_start_datetime) {
+        this.report_start_datetime = report_start_datetime;
+    }
+
+    public String getReport_step() {
+        return report_step;
+    }
+
+    public void setReport_step(String report_step) {
+        this.report_step = report_step;
+    }
+
+    public String getRouting_step() {
+        return routing_step;
+    }
+
+    public void setRouting_step(String routing_step) {
+        this.routing_step = routing_step;
+    }
+
+    public String getInertial_damping() {
+        return inertial_damping;
+    }
+
+    public void setInertial_damping(String inertial_damping) {
+        this.inertial_damping = inertial_damping;
+    }
+
+    public String getNormal_flow_limited() {
+        return normal_flow_limited;
+    }
+
+    public void setNormal_flow_limited(String normal_flow_limited) {
+        this.normal_flow_limited = normal_flow_limited;
+    }
+
+    public String getForce_main_equation() {
+        return force_main_equation;
+    }
+
+    public void setForce_main_equation(String force_main_equation) {
+        this.force_main_equation = force_main_equation;
+    }
+
+    public Integer getMax_trials() {
+        return max_trials;
+    }
+
+    public void setMax_trials(Integer max_trials) {
+        this.max_trials = max_trials;
+    }
+
+    public Double getMinimum_step() {
+        return minimum_step;
+    }
+
+    public void setMinimum_step(Double minimum_step) {
+        this.minimum_step = minimum_step;
+    }
+
+    public Double getMin_surfarea() {
+        return min_surfarea;
+    }
+
+    public void setMin_surfarea(Double min_surfarea) {
+        this.min_surfarea = min_surfarea;
+    }
+
+    public Integer getThreads() {
+        return threads;
+    }
+
+    public void setThreads(Integer threads) {
+        this.threads = threads;
+    }
+
+    public Double getManning() {
+        return Manning;
+    }
+
+    public void setManning(Double manning) {
+        Manning = manning;
+    }
+
+    public Integer getAreas_slope() {
+        return areas_slope;
+    }
+
+    public void setAreas_slope(Integer areas_slope) {
+        this.areas_slope = areas_slope;
+    }
+
+    public Integer getAreas_imperv() {
+        return areas_imperv;
+    }
+
+    public void setAreas_imperv(Integer areas_imperv) {
+        this.areas_imperv = areas_imperv;
+    }
+
+    public Double getAreas_n_imperv() {
+        return areas_n_imperv;
+    }
+
+    public void setAreas_n_imperv(Double areas_n_imperv) {
+        this.areas_n_imperv = areas_n_imperv;
+    }
+
+    public Double getAreas_n_perv() {
+        return areas_n_perv;
+    }
+
+    public void setAreas_n_perv(Double areas_n_perv) {
+        this.areas_n_perv = areas_n_perv;
+    }
+
+    public Double getAreas_storage_imperv() {
+        return areas_storage_imperv;
+    }
+
+    public void setAreas_storage_imperv(Double areas_storage_imperv) {
+        this.areas_storage_imperv = areas_storage_imperv;
+    }
+
+    public Integer getAreas_storage_perv() {
+        return areas_storage_perv;
+    }
+
+    public void setAreas_storage_perv(Integer areas_storage_perv) {
+        this.areas_storage_perv = areas_storage_perv;
+    }
+
+    public Integer getAreas_pct_zero() {
+        return areas_pct_zero;
+    }
+
+    public void setAreas_pct_zero(Integer areas_pct_zero) {
+        this.areas_pct_zero = areas_pct_zero;
+    }
+
+    public Integer getInit_depth() {
+        return init_depth;
+    }
+
+    public void setInit_depth(Integer init_depth) {
+        this.init_depth = init_depth;
+    }
+
+    public Double getFriction() {
+        return friction;
+    }
+
+    public void setFriction(Double friction) {
+        this.friction = friction;
+    }
+
+    public Double getTerrain_smoothing() {
+        return terrain_smoothing;
+    }
+
+    public void setTerrain_smoothing(Double terrain_smoothing) {
+        this.terrain_smoothing = terrain_smoothing;
+    }
+
+    public String getFlow_algorithm() {
+        return flow_algorithm;
+    }
+
+    public void setFlow_algorithm(String flow_algorithm) {
+        this.flow_algorithm = flow_algorithm;
+    }
+
+    public Integer getMesh_size() {
+        return mesh_size;
+    }
+
+    public void setMesh_size(Integer mesh_size) {
+        this.mesh_size = mesh_size;
+    }
+
+    public Integer getSave_step() {
+        return save_step;
+    }
+
+    public void setSave_step(Integer save_step) {
+        this.save_step = save_step;
+    }
+}
diff --git a/src/main/java/com/se/simu/service/GedbService.java b/src/main/java/com/se/simu/service/GedbService.java
index f1b2110..a286a96 100644
--- a/src/main/java/com/se/simu/service/GedbService.java
+++ b/src/main/java/com/se/simu/service/GedbService.java
@@ -4,6 +4,7 @@
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.se.simu.config.PropertiesConfig;
 import com.se.simu.domain.dto.GeDb;
 import com.se.simu.domain.dto.GeField;
 import com.se.simu.domain.dto.GeFile;
@@ -42,49 +43,16 @@
 @Service
 @SuppressWarnings("ALL")
 public class GedbService {
-    @Value("${sys.path.in}")
-    String inPath;
-
-    @Value("${gedb.host}")
-    String host;
-
-    @Value("${gedb.user}")
-    String user;
-
-    @Value("${gedb.pwd}")
-    String pwd;
-
-    @Value("${gedb.dbName}")
-    String dbName;
-
-    @Value("${gedb.pageSize}")
-    Integer pageSize;
-
-    @Value("#{'${gedb.layerNames}'}")
-    List<String> layerNames;
-
-    @Value("#{'${gedb.shpNames}'}")
-    List<String> shpNames;
-
-    @Value("#{'${gedb.sysFields}'}")
-    List<String> sysFields;
-
-    @Value("${gedb.demFile}")
-    String demFile;
-
-    @Value("${gedb.demType}")
-    String demType;
-
-    @Value("${gedb.demName}")
-    String demName;
-
     String password;
+
+    @Resource
+    PropertiesConfig config;
 
     @Resource
     RestTemplate restTemplate;
 
     public boolean test(DataPo data) throws Exception {
-        createPath(inPath + File.separator + data.getInPath());
+        createPath(config.getInPath() + File.separator + data.getInPath());
 
         String token = getToken();
         GeDb db = connectGedb(token, data);
@@ -106,10 +74,10 @@
 
     public String getToken() throws Exception {
         Map<String, Object> map = new HashMap<>(2);
-        map.put("userid", user);
+        map.put("userid", config.getUser());
         map.put("password", getPassword());
 
-        JSONObject obj = restTemplate.postForObject(host + "account-service/security/login", map, JSONObject.class);
+        JSONObject obj = restTemplate.postForObject(config.getHost() + "account-service/security/login", map, JSONObject.class);
 
         JSONObject data = obj.getJSONObject("data");
 
@@ -120,7 +88,7 @@
         if (StringHelper.isEmpty(password)) {
             String key = getPublicKey();
             RsaHelper.setPublicKey(key);
-            password = RsaHelper.encrypt(pwd);
+            password = RsaHelper.encrypt(config.getPwd());
         }
 
         return password;
@@ -128,7 +96,7 @@
 
     private String getPublicKey() {
         //{"datetime":"2024-09-12 17:24:38","code":200,"data":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtFwJCh2taVTEi05C8qT2oG7Y+rDmJhlO4zicpSeRtiro9LsytePeWI7BXM6sfDU0WeKun1izawcfgGkZgnoJuMBluAOKI1tL0uCrR+DreNLqMVtnXHwoWEIk/hGJedDWaf3q22aGDyEB5h9qCq0JklSShP1Ih4ppap4LmgxdTPQIDAQAB"}
-        JSONObject obj = restTemplate.getForObject(host + "account-service/security/publickey", JSONObject.class);
+        JSONObject obj = restTemplate.getForObject(config.getHost() + "account-service/security/publickey", JSONObject.class);
 
         return obj.getStr("data");
     }
@@ -145,17 +113,17 @@
         Map<String, Object> map = new HashMap<>(1);
         map.put("token", token);
 
-        JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydb/list/canview", map, JSONObject.class);
+        JSONObject obj = restTemplate.postForObject(config.getHost() + "geo-service/entitydb/list/canview", map, JSONObject.class);
         JSONArray data = obj.getJSONArray("data");
 
         List<GeDb> list = JSONUtil.toList(data, GeDb.class);
         if (CollectionUtils.isEmpty(list)) return null;
 
-        return list.stream().filter(db -> null != db.getName() && db.getName().contains(dbName)).findFirst().orElse(null);
+        return list.stream().filter(db -> null != db.getName() && db.getName().contains(config.getDbName())).findFirst().orElse(null);
     }
 
     public List<GeLayer> getLayers(String token, GeDb db) {
-        String uri = String.format("%sgeo-service/entitydb/map/config?dbid=%s&token=%s", host, db.getDbid(), token);
+        String uri = String.format("%sgeo-service/entitydb/map/config?dbid=%s&token=%s", config.getHost(), db.getDbid(), token);
         JSONObject obj = restTemplate.getForObject(uri, JSONObject.class);
 
         JSONObject data = obj.getJSONObject("data");
@@ -166,12 +134,12 @@
         for (int i = 0, c = arr.size(); i < c; i++) {
             JSONObject jb = arr.getJSONObject(i);
             String name = jb.getStr("name");
-            if (layerNames.contains(name)) {
+            if (config.getLayerNames().contains(name)) {
                 String id = jb.getStr("id");
                 String queryType = getQueryType(jb);
                 List<GeField> fields = JSONUtil.toList(jb.getJSONArray("fields"), GeField.class);
-                fields = fields.stream().filter(f -> !sysFields.contains(f.getName())).collect(Collectors.toList());
-                String shpName = shpNames.get(layerNames.indexOf(name));
+                fields = fields.stream().filter(f -> !config.getSysFields().contains(f.getName())).collect(Collectors.toList());
+                String shpName = config.getShpNames().get(config.getLayerNames().indexOf(name));
 
                 layers.add(new GeLayer(id, name, queryType, fields, shpName, db));
             }
@@ -199,9 +167,9 @@
             int count = getCount(token, db, layer);
             if (0 == count) throw new Exception(layer.getName() + "锛屽浘灞傛暟鎹负绌�");
 
-            int pageCount = (count - 1) / pageSize + 1;
+            int pageCount = (count - 1) / config.getPageSize() + 1;
             for (int i = 0; i < pageCount; i++) {
-                JSONArray data = query(token, db, layer, i + 1, pageSize);
+                JSONArray data = query(token, db, layer, i + 1, config.getPageSize());
                 if (null != data && data.size() > 0) {
                     layer.addData(data);
                 }
@@ -218,7 +186,7 @@
         map.put("returnCountOnly", true);
         map.put("inSR", 4326);
 
-        JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class);
+        JSONObject obj = restTemplate.postForObject(config.getHost() + "geo-service/entitydbdata/layer/query", map, JSONObject.class);
         if (null == obj || 200 != obj.getInt("code")) return 0;
 
         return obj.getInt("data");
@@ -236,7 +204,7 @@
         map.put("querytype", layer.getQueryType());
         map.put("inSR", 4326);
 
-        JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class);
+        JSONObject obj = restTemplate.postForObject(config.getHost() + "geo-service/entitydbdata/layer/query", map, JSONObject.class);
         if (null == obj || 200 != obj.getInt("code")) return null;
 
         JSONObject data = obj.getJSONObject("data");
@@ -245,7 +213,7 @@
     }
 
     public void copeVectors(String token, DataPo data, GeDb db) throws Exception {
-        String basePath = inPath + File.separator + data.getInPath();
+        String basePath = config.getInPath() + File.separator + data.getInPath();
 
         List<GeLayer> layers = getLayers(token, db);
         queryData(token, db, layers);
@@ -266,32 +234,32 @@
         String fileId = getFileId(token, fileDb.getDbid());
         List<GeFile> files = getFileNames(token, fileDb.getDbid(), fileId);
 
-        String filePath = inPath + File.separator + fileDb.getDbid();
+        String filePath = config.getInPath() + File.separator + fileDb.getDbid();
         downloadFiles(token, filePath, files, fileDb.getDbid(), fileId);
         clipDemFile(filePath, files, data);
     }
 
     private GeDb getFileDb(String token) {
-        String uri = String.format("%sfile-service/docdb/query/canview?token=%s", host, token);
+        String uri = String.format("%sfile-service/docdb/query/canview?token=%s", config.getHost(), token);
         JSONObject obj = restTemplate.getForObject(uri, JSONObject.class);
         JSONArray data = obj.getJSONArray("data");
 
         List<GeDb> list = JSONUtil.toList(data, GeDb.class);
         if (CollectionUtils.isEmpty(list)) return null;
 
-        return list.stream().filter(db -> null != db.getName() && db.getName().contains(dbName)).findFirst().orElse(null);
+        return list.stream().filter(db -> null != db.getName() && db.getName().contains(config.getDbName())).findFirst().orElse(null);
     }
 
     private String getFileId(String token, String dbid) {
         String uri = String.format("%sfile-service/doc/catagory/file/query?token=%s&dbid=%s&catagory=%s&count=%d&start=%d&like=",
-                host, token, dbid, "image", 9999, 1);
+                config.getHost(), token, dbid, "image", 9999, 1);
 
         JSONObject obj = restTemplate.getForObject(uri, JSONObject.class);
         JSONArray items = obj.getJSONObject("data").getJSONArray("items");
 
         for (int i = 0, c = items.size(); i < c; i++) {
             JSONObject jb = items.getJSONObject(i);
-            if (demName.equals(jb.getStr("filename"))) {
+            if (config.getDemName().equals(jb.getStr("filename"))) {
                 return jb.getStr("fileid");
             }
         }
@@ -301,7 +269,7 @@
 
     private List<GeFile> getFileNames(String token, String dbid, String fileId) {
         String uri = String.format("%sfile-service/doc/cluster/struct/list?token=%s&dbid=%s&cluster_fileid=%s&onlychild=true&folder_stairs=",
-                host, token, dbid, fileId);
+                config.getHost(), token, dbid, fileId);
 
         JSONObject obj = restTemplate.getForObject(uri, JSONObject.class);
         JSONArray data = obj.getJSONArray("data");
@@ -326,7 +294,7 @@
             }
 
             String uri = String.format("%sfile-service/fileparser/cluster/download/%s?token=%s&dbid=%s&cluster_fileid=%s",
-                    host, geFile.getName(), token, dbid, fileId);
+                    config.getHost(), geFile.getName(), token, dbid, fileId);
             downloadFile(uri, filePath);
         }
     }
@@ -351,9 +319,9 @@
     }
 
     private void clipDemFile(String filePath, List<GeFile> files, DataPo data) throws Exception {
-        String target = inPath + File.separator + data.getInPath() + File.separator + demFile;
+        String target = config.getInPath() + File.separator + data.getInPath() + File.separator + config.getDemFile();
         for (GeFile file : files) {
-            if (file.getName().toLowerCase().endsWith(demType)) {
+            if (file.getName().toLowerCase().endsWith(config.getDemType())) {
                 String source = filePath + File.separator + file.getName();
                 clipDem(source, target, data);
                 break;
diff --git a/src/main/java/com/se/simu/service/SimuService.java b/src/main/java/com/se/simu/service/SimuService.java
index 346c044..0da0db9 100644
--- a/src/main/java/com/se/simu/service/SimuService.java
+++ b/src/main/java/com/se/simu/service/SimuService.java
@@ -8,6 +8,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.se.simu.config.PropertiesConfig;
 import com.se.simu.domain.dto.GeDb;
 import com.se.simu.domain.dto.GeLayer;
 import com.se.simu.domain.po.DataPo;
@@ -39,14 +40,11 @@
 @Service
 @SuppressWarnings("ALL")
 public class SimuService {
-    @Value("${sys.path.in}")
-    String inPath;
-
-    @Value("${sys.path.out}")
-    String outPath;
-
     @Resource
     SimuMapper simuMapper;
+
+    @Resource
+    PropertiesConfig config;
 
     @Resource
     GedbService gedbService;
@@ -99,8 +97,8 @@
                     DataPo dp = JSONUtil.toBean(po.getData(), DataPo.class);
                     if (null == dp) continue;
 
-                    delDir(inPath + File.separator + dp.getInPath());
-                    delDir(outPath + File.separator + dp.getOutPath());
+                    delDir(config.getInPath() + File.separator + dp.getInPath());
+                    delDir(config.getOutPath() + File.separator + dp.getOutPath());
                 } catch (Exception ex) {
                     log.error(ex.getMessage(), ex);
                 }
@@ -146,8 +144,8 @@
     }
 
     private void initPath(DataPo data) {
-        createDir(inPath + File.separator + data.getInPath());
-        createDir(outPath + File.separator + data.getOutPath());
+        createDir(config.getInPath() + File.separator + data.getInPath());
+        createDir(config.getOutPath() + File.separator + data.getOutPath());
     }
 
     private void createDir(String path) {
diff --git a/src/main/java/com/se/simu/service/WaterService.java b/src/main/java/com/se/simu/service/WaterService.java
index 4cb4571..e2ea59d 100644
--- a/src/main/java/com/se/simu/service/WaterService.java
+++ b/src/main/java/com/se/simu/service/WaterService.java
@@ -1,10 +1,11 @@
 package com.se.simu.service;
 
+import com.se.simu.config.PropertiesConfig;
 import com.se.simu.domain.vo.*;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.ArrayList;
@@ -20,18 +21,15 @@
 @Slf4j
 @Service
 public class WaterService {
-    @Value("${sys.ver}")
-    String ver;
-
-    @Value("${sys.path.out}")
-    String outPath;
+    @Resource
+    PropertiesConfig config;
 
     /**
      * 鑾峰彇鍏冩暟鎹俊鎭�
      */
     public byte[] getLayerJson(String serviceName) {
         try {
-            String filePath = outPath + File.separator + serviceName + File.separator + "layer.json";
+            String filePath = config.getOutPath() + File.separator + serviceName + File.separator + "layer.json";
 
             File dat = new File(filePath);
             if (!dat.exists()) {
@@ -54,21 +52,21 @@
      * 鑾峰彇鍦板舰楂樺害鍥�
      */
     public String getTerraMap(String serviceName, Integer width, Integer height) {
-        return outPath + File.separator + serviceName + File.separator + "terrain" + File.separator + width + "_" + height + ".png";
+        return config.getOutPath() + File.separator + serviceName + File.separator + "terrain" + File.separator + width + "_" + height + ".png";
     }
 
     /**
      * 鑾峰彇姘撮潰楂樺害鍥�
      */
     public String getWaterMap(String serviceName, Integer width, Integer height, Long timestamp) {
-        return outPath + File.separator + serviceName + File.separator + "waters" + File.separator + timestamp + File.separator + width + "_" + height + ".png";
+        return config.getOutPath() + File.separator + serviceName + File.separator + "waters" + File.separator + timestamp + File.separator + width + "_" + height + ".png";
     }
 
     /**
      * 鑾峰彇姘存祦鍚戞祦閫熷浘
      */
     public String getFlowMap(String serviceName, Integer width, Integer height, Long timestamp) {
-        return outPath + File.separator + serviceName + File.separator + "flows" + File.separator + timestamp + File.separator + width + "_" + height + ".png";
+        return config.getOutPath() + File.separator + serviceName + File.separator + "flows" + File.separator + timestamp + File.separator + width + "_" + height + ".png";
     }
 
     /**
@@ -76,7 +74,7 @@
      */
     public Layer getLayer(String serviceName) {
         Layer layer = new Layer();
-        layer.setVersion(ver);
+        layer.setVersion(config.getVer());
         layer.setDuration(new Duration(1719812810225L, 1719812810225L));
         layer.setExtension(new Extension(2.11062743358, 0.53812160220, 2.11070827834, 0.53819799453, 1.151, 38.83));
 
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 411d23f..00c1eb1 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -91,21 +91,26 @@
   connectTimeout: -1
   readTimeout: -1
 
-sys:
+config:
   ver: 0.2
-  path:
-    in: D:\simu\in
-    out: D:\simu\out
-
-gedb:
+  # Gdal椹卞姩鐩綍
+  gdalPath: E:/terrait/TianJin/Zip/release-1928-x64-dev/release-1928-x64/bin
+  inPath: D:\simu\in
+  outPath: D:\simu\out
   host: http://106.120.22.26:8013/
   user: WUWEIWEI
   pwd: WUWEIWEI
   dbName: 閫氬窞姘村埄浠跨湡
   pageSize: 2000
-  layerNames: 绠$偣,绠$嚎,寤虹瓚鐗�
-  shpNames: pipePoint,pipeLine,building
-  sysFields: _ext_attr,_meta_id,_attach_files,_x,_y,_z,operatetime,operator,_is_latest,_data_type,groupid,id,shape_length,shape_area
+  layerNames:
+    - 绠$偣
+    - 绠$嚎
+    - 寤虹瓚鐗�
+  shpNames:
+    - pipePoint
+    - pipeLine
+    - building
   demName: DEM
   demType: .tif
-  demFile: dem.tif
\ No newline at end of file
+  demFile: dem.tif
+  sysFields: _ext_attr,_meta_id,_attach_files,_x,_y,_z,operatetime,operator,_is_latest,_data_type,groupid,id,shape_length,shape_area

--
Gitblit v1.9.3