1
13693261870
2024-10-17 26a04387f9aa299c6e6af5476b195b307f068743
src/main/java/com/se/simu/service/UwService.java
@@ -26,6 +26,16 @@
    @Resource
    PropertiesConfig config;
    static Rainfall _rainfall = null;
    public static Rainfall getTainfall() throws Exception {
        if (null == _rainfall) {
            _rainfall = new Rainfall();
        }
        return _rainfall;
    }
    /**
     * 创建降雨文件
     * <p>
@@ -40,7 +50,7 @@
        //MWCharArray station = new MWCharArray(config.getRainStation());
        //MWCharArray time = new MWCharArray(startTime);
        Rainfall rainfall = new Rainfall();
        Rainfall rainfall = getTainfall();
        //rainfall('D:\simu\in\RainGage.dat','Tongzhou','2024-09-29 00:00:00',60,0.5,10)
        Object[] rs = rainfall.rainfall(filePath, config.getRainStation(), startTime,
                Double.valueOf(data.getDuration()), 0.5, config.getRainPeriod());
@@ -80,15 +90,15 @@
            nr = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
            er = new BufferedReader(new InputStreamReader(process.getErrorStream(), "GBK"));
            String errorLine;
            while ((errorLine = er.readLine()) != null) {
                log.warn(errorLine);
            }
            String line;
            StringBuilder sb = new StringBuilder();
            while ((line = nr.readLine()) != null) {
                sb.append(line);
            }
            String errorLine;
            while ((errorLine = er.readLine()) != null) {
                log.warn(errorLine);
            }
            // 等待程序执行结束并输出状态
@@ -124,27 +134,17 @@
        }
    }
    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() {
        //
    }
    public void copeDrainFiles() {
        //
    public String copeDrainFiles(DataPo data) throws Exception {
        String time = StringHelper.YMDHMS_FORMAT.format(data.getStartTime());
        String inPath = config.getInPath() + File.separator + data.getInPath();
        String sww = inPath + File.separator + ".save" + File.separator + data.getInPath() + ".sww";
        String cmd = config.getSww2tifBat() + " " + sww + " \"" + time + "\" " + data.getEpsg() + " " + inPath;
        return exec(cmd);
    }
}