1
13693261870
2024-10-14 a6fe405947004d6571806edabd8f14357e144cfa
1
已修改5个文件
73 ■■■■ 文件已修改
src/main/java/com/se/simu/config/PropertiesConfig.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/SimuController.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/ResultService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/UwService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
    }
}
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);
        }
    }
}
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);
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() {
        //
    }
src/main/resources/application.yml
@@ -122,6 +122,7 @@
  # 流量单位,LPS(升/秒)、CMS(立方米/秒)、CFS(立方英尺/秒)
  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