1
13693261870
2024-10-14 a6fe405947004d6571806edabd8f14357e144cfa
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;
/**
 * 内涝求解器服务类
@@ -39,28 +36,18 @@
        String filePath = config.getInPath() + File.separator + data.getInPath() + File.separator + config.getRaingage();
        String startTime = StringHelper.YMDHMS_FORMAT.format(data.getStartTime());
        MWCharArray file = new MWCharArray(filePath);
        MWCharArray station = new MWCharArray(config.getRainStation());
        MWCharArray time = new MWCharArray(startTime);
        //MWCharArray file = new MWCharArray(filePath);
        //MWCharArray station = new MWCharArray(config.getRainStation());
        //MWCharArray time = new MWCharArray(startTime);
        try {
            Rainfall rainfall = new Rainfall();
            //rainfall('D:\simu\in\RainGage.dat','Tongzhou','2024-09-29 00:00:00',60,0.5,10)
            //Object[] rs = rainfall.rainfall(0, file, station, time, data.getDuration(), 0.5, config.getRainPeriod());
            List args = new ArrayList<Object>();
            args.add(filePath);
            args.add(config.getRainStation());
            args.add(startTime);
            args.add(data.getDuration());
            args.add(0.5);
            args.add(config.getRainPeriod());
        Rainfall rainfall = new Rainfall();
        //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());
            rainfall.rainfall(new ArrayList(), args);
        } finally {
            file.dispose();
            station.dispose();
            time.dispose();
        }
        // file.dispose();
        //station.dispose();
        //time.dispose();
    }
    public void createConfig(DataPo data) throws IOException {
@@ -90,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) {
@@ -137,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() {
        //
    }