张洋洋
2025-02-20 5ec04f09b1569a3cc566657684a647f467b1e608
Merge remote-tracking branch 'origin/master'
已修改3个文件
137 ■■■■■ 文件已修改
src/main/java/com/se/simu/controller/SwwFilesDealController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/Impl/SwwFilesDealServiceImpl.java 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/UwService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/SwwFilesDealController.java
@@ -19,7 +19,7 @@
 * @author xingjinshuang@smartearth.cn
 * @date 2025/02/20
 */
@Api(tags = "SEM相关接口")
@Api(tags = " Sww 相关接口")
@CrossOrigin(origins = "*")
@RequiredArgsConstructor
@RestController
src/main/java/com/se/simu/service/Impl/SwwFilesDealServiceImpl.java
@@ -1,16 +1,142 @@
package com.se.simu.service.Impl;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.se.simu.config.PropertiesConfig;
import com.se.simu.domain.po.DataPo;
import com.se.simu.domain.po.SimuPo;
import com.se.simu.helper.StringHelper;
import com.se.simu.service.ResultService;
import com.se.simu.service.SwwFilesDealService;
import com.se.simu.service.UwService;
import io.swagger.annotations.ApiModelProperty;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
@Service
public class SwwFilesDealServiceImpl implements SwwFilesDealService {
    @Resource
    private PropertiesConfig config;
    @Resource
    private UwService uwService;
    @Resource
    private ResultService resultService;
    @Override
    public Object readSwwFile(String filePath) {
        DataPo dataPo = new DataPo();
        dataPo.setPid(0);
        dataPo.setName("处理sww文件");
        dataPo.setInPath("H:\\simu\\semout\\testsem\\.out\\testsem.sww");
        dataPo.setOutPath("H:\\simu\\semout\\testsem\\.out");
        String json_data = "{\"pid\":0,\"name\":\"20241213135203\",\"inPath\":\"20241213135203\",\"outPath\":\"20241213135203\",\"startTime\":1727661600000,\"minx\":116.64388473935195,\"miny\":39.884315914604464,\"maxx\":116.64754729082588,\"maxy\":39.887069143903496,\"total\":50,\"duration\":60,\"floodStart\":60,\"floodEnd\":180,\"floodHeight\":1,\"floodType\":\"沙袋\",\"floodMinx\":116.64388473935195,\"floodMiny\":39.884315914604464,\"floodMaxx\":116.64754729082588,\"floodMaxy\":39.887069143903496,\"epsg\":4548}";
        JSONObject jsonObject = JSON.parseObject(json_data);
        System.out.println("jsonObject = " + jsonObject);
//
//        @ApiModelProperty("开始时间")
//        @JSONField(format = "yyyy-MM-dd HH:mm:ss")
//        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//        private Date startTime;
//
//        @ApiModelProperty("最小X")
//        private Double minx;
//
//        @ApiModelProperty("最小Y")
//        private Double miny;
//
//        @ApiModelProperty("最大X")
//        private Double maxx;
//
//        @ApiModelProperty("最大Y")
//        private Double maxy;
//
//        @ApiModelProperty("降雨量(mm)")
//        private Double total;
//
//        @ApiModelProperty("时长(min)")
//        private Integer duration;
//
//        @ApiModelProperty("是否为防汛(0-否,1-是)")
//        private Integer isFlood;
//
//        @ApiModelProperty("防汛开始时间(秒)")
//        private Integer floodStart;
//
//        @ApiModelProperty("防汛结束时间(秒)")
//        private Integer floodEnd;
//
//        @ApiModelProperty("防汛高度(mm)")
//        private Double floodHeight;
//
//        @ApiModelProperty("防汛类型(沙袋,防水板)")
//        private String floodType;
//
//        @ApiModelProperty("防汛最小X")
//        private Double floodMinx;
//
//        @ApiModelProperty("防汛最小Y")
//        private Double floodMiny;
//
//        @ApiModelProperty("防汛最大X")
//        private Double floodMaxx;
//
//        @ApiModelProperty("防汛最大Y")
//        private Double floodMaxy;
//
//        @ApiModelProperty("坐标系ID")
//        private Integer epsg;
        // 读取sww文件
        asyncCall(dataPo);
        return null;
    }
    private void asyncCall(DataPo dataPo) {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(new Runnable() {
            @Override
            @SneakyThrows
            public void run() {
                copeDeal(dataPo);
            }
        });
        executor.shutdown();
    }
    private void copeDeal(DataPo data) {
        try {
            uwService.callExe(data);
//            uwService.copeWaterFiles();
//            uwService.copeDrainFiles(data);
            uwService.copeSwwDrainFiles(data);
//            resultService.process(data);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
}
src/main/java/com/se/simu/service/UwService.java
@@ -195,4 +195,13 @@
        return exec(cmd);
    }
    public String copeSwwDrainFiles(DataPo data) throws Exception {
        String time = StringHelper.YMDHMS_FORMAT.format(data.getStartTime());
        String inPath = "H:\\simu\\semout";
        String sww = "H:\\simu\\semout\\testsem\\.out\\" + "testsem.sww";
        String cmd = config.getSww2tifBat() + " " + sww + " \"" + time + "\" " + data.getEpsg() + " " + inPath;
        return exec(cmd);
    }
}