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.domain.po.DataPo;
|
import com.se.simu.domain.po.SimuPo;
|
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.util.Date;
|
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.Executors;
|
|
@Slf4j
|
@Service
|
public class SwwFilesDealServiceImpl implements SwwFilesDealService {
|
|
@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);
|
resultService.process(data);
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
|
|
}
|