xingjinshuang
2025-02-20 4ffb61934bd556bb681b96bcc5c690105000ed5e
Merge remote-tracking branch 'origin/master'
已修改2个文件
67 ■■■■■ 文件已修改
pom.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/SimuController.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -383,6 +383,15 @@
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <jvmArguments>
                        -Xms2048m -Xmx4096m -XX:+PrintGCDetails
                    </jvmArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
src/main/java/com/se/simu/controller/SimuController.java
@@ -15,6 +15,7 @@
import com.se.simu.service.*;
import com.se.simu.utils.*;
import io.swagger.annotations.*;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
@@ -33,6 +34,8 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@Api(tags = "仿真管理")
@@ -313,11 +316,11 @@
                    return fail("模拟计算计算坐标!", false);
                }
                double aveTotal = BigDecimal.valueOf(vo.getTotal()).divide(BigDecimal.valueOf(vo.getDuration()), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
                JSONArray jsonArray=new JSONArray();
                LocalDateTime now=LocalDateTime.now();
                JSONArray jsonArray = new JSONArray();
                LocalDateTime now = LocalDateTime.now();
                DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
                for (int i=0;i<vo.getDuration();i++){
                    JSONObject jsonObject=new JSONObject();
                for (int i = 0; i < vo.getDuration(); i++) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("stationName", vo.getStation());
                    jsonObject.put("rainfall", aveTotal);
                    jsonObject.put("longitude", vo.getStationLongitude());
@@ -377,7 +380,22 @@
            dtos.add(new GridDto(vo.getMaxy(), vo.getMinx()));
            dtos.add(new GridDto(vo.getMaxy(), vo.getMaxx()));
            dtos.add(new GridDto(vo.getMiny(), vo.getMaxx()));
            createSem(tableName, dtos, vo);
            String bbox = "";
            //生成点和线的实体库模型并保存路径
            String name = vo.getSemUrl();
            String token = EntityLibraryUtils.login();
            vo.setPointName(name + "-point");
            vo.setLinkName(name + "-line");
            JSONArray min = ProjectionToGeographicUtil.get4548Point(dtos.get(0).getLon(), dtos.get(0).getLat());
            JSONArray max = ProjectionToGeographicUtil.get4548Point(dtos.get(2).getLon(), dtos.get(2).getLat());
            bbox = bbox + min.getDouble(0) + "," + min.getDouble(1) + "," + max.getDouble(0) + "," + max.getDouble(1);
            JSONObject point = getModule("layerQueryPointParams.json");
            String pointUrl = assemble(vo.getPointName(), point.getString("layerid"), bbox, token);
            vo.setPointName(pointUrl);
            JSONObject link = getModule("layerQueryParams.json");
            String linkUrl = assemble(vo.getLinkName(), link.getString("layerid"), bbox, token);
            vo.setLinkName(linkUrl);
            asyncCall(tableName, dtos, vo, token);
            // 开始模拟计算
            boolean flag = simuFilesService.createByfiles(vo);
            return success(flag, flag ? "成功" : "失败");
@@ -408,8 +426,19 @@
        return success(null);
    }
    public R<Boolean> createSem(String tableName, List<GridDto> dtos, CreateFilesSimuVo vo) throws Exception {
        String name = vo.getSemUrl();
    private void asyncCall(String tableName, List<GridDto> dtos, CreateFilesSimuVo vo, String token) {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(new Runnable() {
            @Override
            @SneakyThrows
            public void run() {
                createSem(tableName, dtos, vo, token);
            }
        });
        executor.shutdown();
    }
    public void createSem(String tableName, List<GridDto> dtos, CreateFilesSimuVo vo, String token) throws Exception {
        vo.setSemUrl(inPath + "\\" + vo.getSemUrl());
        boolean ends = vo.getSemUrl().endsWith("\\");
        if (!ends) {
@@ -419,7 +448,6 @@
        if (!file.exists()) {
            file.mkdirs();
        }
        String token = EntityLibraryUtils.login();
        //降雨文件生成
        saveZarr(tableName, vo.getSemUrl());
        //管点生成
@@ -434,20 +462,6 @@
        landuseToSem(vo.getSemUrl());
        //地形生成
        terrainToSem(dtos, vo.getSemUrl());
        String bbox = "";
        //生成点和线的实体库模型并保存路径
        vo.setPointName(name + "-point");
        vo.setLinkName(name + "-line");
        JSONArray min = ProjectionToGeographicUtil.get4548Point(dtos.get(0).getLon(), dtos.get(0).getLat());
        JSONArray max = ProjectionToGeographicUtil.get4548Point(dtos.get(2).getLon(), dtos.get(2).getLat());
        bbox = bbox + min.getDouble(0) + "," + min.getDouble(1) + "," + max.getDouble(0) + "," + max.getDouble(1);
        JSONObject point = getModule("layerQueryPointParams.json");
        String pointUrl = assemble(vo.getPointName(), point.getString("layerid"), bbox, token);
        vo.setPointName(pointUrl);
        JSONObject link = getModule("layerQueryParams.json");
        String linkUrl = assemble(vo.getLinkName(), link.getString("layerid"), bbox, token);
        vo.setLinkName(linkUrl);
        return success(true);
    }