wuww
2025-05-04 73ca802381bd76cc1a5bd608e4a1e5ef12de88a2
完成求解器对接~
已修改4个文件
80 ■■■■ 文件已修改
src/main/java/com/se/nsl/controller/SimuController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/service/ResolveService.java 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/service/TestService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/controller/SimuController.java
@@ -107,7 +107,7 @@
            SimuData data = JSON.parseObject(simu.getData(), SimuData.class);
            if (null == data) return fail("方案数据格式(JSON)不正确");
            if (simu.getStatus() != 0) return fail("方案正在运行或已完成");
            //if (simu.getStatus() != 0) return fail("方案正在运行或已完成");
            if (StringUtils.isEmpty(simu.getGeom())) return fail("方案的图形为空");
            int rows = resolveService.start(simu);
src/main/java/com/se/nsl/service/ResolveService.java
@@ -13,6 +13,7 @@
import com.se.nsl.helper.WebHelper;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.axis.utils.StringUtils;
import org.gdal.ogr.Geometry;
import org.gdal.ogr.ogr;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +28,8 @@
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -40,8 +43,12 @@
    @Resource
    PropertiesConfig config;
    @Autowired
    private UwService uwService;
    @Resource
    UwService uwService;
    @Resource
    TestService testService;
    public int start(Simu simu) {
        Date now = new Date();
@@ -90,17 +97,17 @@
        try {
            DataPo data = JSONUtil.toBean(simu.getData(), DataPo.class);
            update(simu, 1, "开始");
            update(simu, 1, "初始化参数");
            initArgs(data);
            String rs = callUwSolver(data);
            //gedbService.copeVectors(token, data, db);
            //update(simu, 3, null);
            //gedbService.copeDem(token, data);
            update(simu, 2, "调用求解器");
            callUwSolver(data);
            //update(simu, 4, null);
            //uwService.createRainFile(data);
            update(simu, 3, "调用Zarr转Tif");
            callZarr2tif(data);
            update(simu, 4, "解析数据");
            createNsl(data);
            update(simu, 10, "完成");
        } catch (Exception ex) {
@@ -158,8 +165,17 @@
        return callBat(cmd);
    }
    /**
     * 调用zarr2tif
     */
    private String callZarr2tif(DataPo data) throws Exception {
        String cmd = "";
        File uwBat = new File(config.getUwSolverBat());
        String zarrFile = uwBat.getParent() + File.separator + "result.zarr";
        String inPath = config.getInPath() + File.separator + data.getInPath();
        String terrainFile = inPath + File.separator + config.getDemFile();
        String waterPath = inPath + File.separator + "depth";
        String cmd = String.format("%s \"%s\" \"%s\" \"%s\" \"%s\"", config.getZarr2tifBat(), "depth", zarrFile, terrainFile, waterPath);
        return callBat(cmd);
    }
@@ -189,4 +205,32 @@
            return null;
        }
    }
    private void createNsl(DataPo data) throws Exception {
        String inPath = config.getInPath() + File.separator + data.getInPath() + File.separator + "depth";
        procTifs(inPath, inPath, data.getStartTime());
        testService.test(data);
    }
    private void procTifs(String tifPath, String outPath, Date startTime) {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startTime);
        for (File file : new File(tifPath).listFiles()) {
            if (!file.exists() || !file.isDirectory()) continue;
            File tif = new File(tifPath + "\\" + file.getName() + File.separator + "depth.tif");
            if (!tif.exists() || tif.isDirectory()) continue;
            calendar.add(Calendar.SECOND, 1);
            String newName = df.format(calendar.getTime());
            String newFile = outPath + File.separator + newName + ".tif";
            System.out.println(newFile);
            tif.renameTo(new File(newFile));
            file.delete();
        }
    }
}
src/main/java/com/se/nsl/service/TestService.java
@@ -240,8 +240,8 @@
            }
        });*/
        int c = files.size();
        int step = c <= 1 ? 1 : c / 10;
        int c = files.size(), step = files.size() / 10;
        if (step < 1) step = 1;
        for (int i = 0; i < c; i += step) {
            Dataset ds = null;
            try {
@@ -625,8 +625,10 @@
        layer.getWaters().setFiles(null);
        layer.getTerrain().setEpsg(null);
        layer.getExtension().setDiffer(null);
        layer.setWaterUrl("/hls/w" + dto.getOutPath() + ".m3u8");
        layer.setFlowUrl("/hls/f" + dto.getOutPath() + ".m3u8");
        String path = dto.getOutPath().replace(config.getOutPath() + File.separator, "");
        layer.setWaterUrl("/hls/w" + path + ".m3u8");
        layer.setFlowUrl("/hls/f" + path + ".m3u8");
        String json = JSON.toJSONString(layer);
        // String json = JSONUtil.toJsonPrettyStr(layer);
src/main/resources/application-dev.yml
@@ -142,7 +142,7 @@
  solverBat: D:\other\simu\uwsolver\run_solver.bat
  sww2tifBat: D:\other\simu\uwsolver\sww2tif.bat
  uwSolverBat: D:\other\simu\uwsolver\CudaUWSolver.Demo.NoVis.20250430\start.bat
  zarr2tifBat: D:\other\simu\uwsolver\zarr2tif 1.0\CudaUWSolver.Demo.NoVis.20250430\start.bat
  zarr2tifBat: D:\other\simu\uwsolver\zarr2tif1.0\start.bat
  saveFrames: 10
  #sizes: 64,128,256,512,1024,2048,4096
  sizes: 1024