1
13693261870
2024-10-17 26a04387f9aa299c6e6af5476b195b307f068743
src/main/java/com/se/simu/service/UwService.java
@@ -1,7 +1,6 @@
package com.se.simu.service;
import cn.hutool.json.JSONUtil;
import com.mathworks.toolbox.javabuilder.MWCharArray;
import com.se.simu.config.PropertiesConfig;
import com.se.simu.domain.dto.ConfigDto;
import com.se.simu.domain.po.DataPo;
@@ -13,8 +12,6 @@
import javax.annotation.Resource;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
 * 内涝求解器服务类
@@ -28,6 +25,16 @@
public class UwService {
    @Resource
    PropertiesConfig config;
    static Rainfall _rainfall = null;
    public static Rainfall getTainfall() throws Exception {
        if (null == _rainfall) {
            _rainfall = new Rainfall();
        }
        return _rainfall;
    }
    /**
     * 创建降雨文件
@@ -43,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,18 +87,18 @@
        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()));
            String errorLine;
            while ((errorLine = er.readLine()) != null) {
                log.warn(errorLine);
            }
            nr = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
            er = new BufferedReader(new InputStreamReader(process.getErrorStream(), "GBK"));
            String line;
            StringBuilder sb = new StringBuilder();
            while ((line = nr.readLine()) != null) {
                sb.append(line);
            }
            String errorLine;
            while ((errorLine = er.readLine()) != null) {
                log.warn(errorLine);
            }
            // 等待程序执行结束并输出状态
@@ -131,7 +138,13 @@
        //
    }
    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);
    }
}