xingjinshuang
2025-02-20 8aa5b21c6a990e15ae5a5b19e4faa9cebb19001a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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);
        }
    }
 
 
}