From a6fe405947004d6571806edabd8f14357e144cfa Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 14 十月 2024 17:31:31 +0800 Subject: [PATCH] 1 --- src/main/java/com/se/simu/config/PropertiesConfig.java | 10 +++++ src/main/java/com/se/simu/service/ResultService.java | 3 - src/main/java/com/se/simu/service/UwService.java | 20 +++++++++- src/main/resources/application.yml | 1 src/main/java/com/se/simu/controller/SimuController.java | 39 ++++++++++++++----- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/se/simu/config/PropertiesConfig.java b/src/main/java/com/se/simu/config/PropertiesConfig.java index 3697b86..a584e83 100644 --- a/src/main/java/com/se/simu/config/PropertiesConfig.java +++ b/src/main/java/com/se/simu/config/PropertiesConfig.java @@ -62,6 +62,8 @@ private String solverBat; + private String keyFrameBat; + private List<Integer> sizes; private String terrainFile; @@ -295,4 +297,12 @@ public void setFlowPath(String flowPath) { this.flowPath = flowPath; } + + public String getKeyFrameBat() { + return keyFrameBat; + } + + public void setKeyFrameBat(String keyFrameBat) { + this.keyFrameBat = keyFrameBat; + } } diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java index 8ee0441..cff90ca 100644 --- a/src/main/java/com/se/simu/controller/SimuController.java +++ b/src/main/java/com/se/simu/controller/SimuController.java @@ -10,6 +10,7 @@ import com.se.simu.service.GedbService; import com.se.simu.service.ResultService; import com.se.simu.service.SimuService; +import com.se.simu.service.UwService; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @@ -33,13 +34,16 @@ @SuppressWarnings("ALL") public class SimuController extends BaseController { @Resource + UwService uwService; + + @Resource GedbService gedbService; @Resource - ResultService resultService; + SimuService simuService; @Resource - SimuService simuService; + ResultService resultService; private final List<String> FLOOD_TYPE = new ArrayList<>(Arrays.asList("娌欒", "闃叉按鏉�")); @@ -145,14 +149,20 @@ } } - @ApiOperation(value = "Test *") - @GetMapping("/test") - public R<Object> test() { + @ApiOperation(value = "褰撳墠鏃堕棿 *") + @GetMapping("/getTime") + public Object getTime() { + return System.currentTimeMillis(); + } + + @ApiOperation(value = "testResuslt *") + @GetMapping("/testResuslt") + public R<Object> testResuslt() { try { //DataPo data = new DataPo("20240913", "20240913", "20240913", 116.64388473935195, 39.884315914604464, 116.64754729082588, 39.887069143903496, 50.0, 25); //Object rs = gedbService.test(data); - Object rs = resultService.test(); + Object rs = resultService.testResuslt(); return success(rs); } catch (Exception ex) { @@ -160,9 +170,18 @@ } } - @ApiOperation(value = "褰撳墠鏃堕棿 *") - @GetMapping("/getTime") - public Object getTime() { - return System.currentTimeMillis(); + @ApiOperation(value = "testKeyFrame *") + @GetMapping("/testKeyFrame") + public R<Object> testKeyFrame() { + try { + DataPo data = new DataPo(); + data.setInPath("20241010095328"); + + Object rs = uwService.getKeyFrame(data); + + return success(rs); + } catch (Exception ex) { + return fail(ex, null); + } } } diff --git a/src/main/java/com/se/simu/service/ResultService.java b/src/main/java/com/se/simu/service/ResultService.java index 8e4da70..772ec93 100644 --- a/src/main/java/com/se/simu/service/ResultService.java +++ b/src/main/java/com/se/simu/service/ResultService.java @@ -40,7 +40,7 @@ public final static double MAX_X_OFFSET = 0.002; - public String test() throws Exception { + public String testResuslt() throws Exception { ResultDto dto = new ResultDto( "202409", "D:\\simu\\input\\tongzhou-local-mesh2-terrain.tif", @@ -71,7 +71,6 @@ private void process(ResultDto dto, LayerDto layer) throws Exception { try { - copeTerrain(dto, layer); copeBuilding(dto, layer); copeWater(dto, layer); diff --git a/src/main/java/com/se/simu/service/UwService.java b/src/main/java/com/se/simu/service/UwService.java index 38756a7..634489b 100644 --- a/src/main/java/com/se/simu/service/UwService.java +++ b/src/main/java/com/se/simu/service/UwService.java @@ -77,8 +77,8 @@ try { // new String[] { "/bin/sh", "-c", cmd } process = Runtime.getRuntime().exec(cmd); - nr = new BufferedReader(new InputStreamReader(process.getInputStream())); - er = new BufferedReader(new InputStreamReader(process.getErrorStream())); + nr = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK")); + er = new BufferedReader(new InputStreamReader(process.getErrorStream(), "GBK")); String errorLine; while ((errorLine = er.readLine()) != null) { @@ -124,6 +124,22 @@ } } + public String getKeyFrame(DataPo data) throws Exception { + String cmd = config.getKeyFrameBat() + " " + config.getInPath() + File.separator + data.getInPath() + File.separator + ".save" + File.separator + data.getInPath() + ".sww"; + + String str = exec(cmd); + if (StringHelper.isEmpty(str) || !str.contains("[")) { + throw new Exception("鐢熸垚鍏抽敭甯у嚭閿�"); + } + + String rs = str.split("\\[", 2)[1].replace("]", "").replace(" ", ""); + if (StringHelper.isEmpty(rs)) { + throw new Exception("鍏抽敭甯т负绌�"); + } + + return rs; + } + public void copeWaterFiles() { // } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2742b94..65b9f4f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -122,6 +122,7 @@ # 娴侀噺鍗曚綅锛孡PS锛堝崌/绉掞級銆丆MS锛堢珛鏂圭背/绉�)銆丆FS(绔嬫柟鑻卞昂/绉�) flowUnits: CMS solverBat: D:\simu\uwsolver\run_solver.bat + keyFrameBat: D:\simu\uwsolver\keyFrame.bat sizes: 64,128,256,512,1024,2048 # 杈撳嚭鏂囦欢 terrainFile: terrain.tif -- Gitblit v1.9.3