张洋洋
2025-02-18 eaf2eddc15c08bc073c953630b727f6497dfee3a
[add]tif裁剪
已修改5个文件
133 ■■■■ 文件已修改
src/main/java/com/se/simu/controller/SimuController.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/domain/po/SimuPo.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/domain/vo/CreateFilesSimuVo.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/SimuFilesService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/SimuController.java
@@ -336,12 +336,15 @@
                    return fail("防汛范围不能为空", false);
                }
            }
            if (StringUtils.isEmpty(vo.getSemUrl())){
                return fail("sem文件生成路径不能为空!", false);
            }
            List<GridDto> dtos = new ArrayList<>();
            dtos.add(new GridDto( vo.getMiny(),vo.getMinx()));
            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);
            dtos.add(new GridDto(vo.getMiny(), vo.getMinx()));
            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.getSemUrl());
            // 开始模拟计算
            boolean flag = simuFilesService.createByfiles(vo);
            return success(flag, flag ? "成功" : "失败");
@@ -350,28 +353,36 @@
        }
    }
    public R<Boolean> createSem(String tableName, List<GridDto> dtos) throws Exception {
    public R<Boolean> createSem(String tableName, List<GridDto> dtos, String semUrl) throws Exception {
        boolean ends = semUrl.endsWith("\\");
        if (!ends) {
            semUrl = semUrl + "\\";
        }
        File file = new File(semUrl);
        if (!file.exists()) {
            file.mkdirs();
        }
        //降雨文件生成
        saveZarr(tableName);
        saveZarr(tableName,semUrl);
        String token = EntityLibraryUtils.login();
        //管点生成
        pointTosem(dtos,token);
        pointTosem(dtos, token,semUrl);
        //管线生成
        lineToSem(dtos,token);
        lineToSem(dtos, token,semUrl);
        //地形生成
        terrainToSem(dtos);
        terrainToSem(dtos,semUrl);
        //范围生成
        gridToCityJson(dtos);
        gridToCityJson(dtos,semUrl);
        //河流生成
        riverToSem();
        riverToSem(semUrl);
        //土地利用生成
        landuseToSem();
        landuseToSem(semUrl);
        return success(true);
    }
    @ApiOperation(value = "tarr文件组装")
    @GetMapping(value = "/saveZarr", produces = "application/json; charset=UTF-8")
    public R<String> saveZarr(@RequestParam("name") String tableName) throws Exception {
    public R<String> saveZarr(@RequestParam("name") String tableName,String semUrl) throws Exception {
        List<String> list = CsvToSQLiteUtils.getNameList(tableName);
        String path = outPath + "\\";
        String rainfall = "rainfall\\";
@@ -428,16 +439,11 @@
        FileWriter fileWriter = new FileWriter(path + tableName + "\\降雨量.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(path + tableName + "\\降雨量.json", filePatn + "raingage.sem");
        return success(filePatn + "raingage.sem");
        SemUtils.cityJsonToSem(path + tableName + "\\降雨量.json", semUrl + "raingage.sem");
        return success(semUrl + "raingage.sem");
    }
    public R<String> pointTosem(List<GridDto> dtos,String token) throws Exception {
    public R<String> pointTosem(List<GridDto> dtos, String token,String semUrl) throws Exception {
        String path = outPath + "\\point\\";
        String publicKey = EntityLibraryUtils.getPublicKey();
        JSONArray jsonArrayList = EntityLibraryUtils.getPointInfo(dtos, token);
@@ -502,13 +508,8 @@
        FileWriter fileWriter = new FileWriter(pointPath);
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(pointPath, filePatn + "node.sem");
        return success(filePatn + "node.sem");
        SemUtils.cityJsonToSem(pointPath, semUrl + "node.sem");
        return success(semUrl + "node.sem");
    }
    @ApiOperation(value = "管点转cityjson")
@@ -560,7 +561,7 @@
        return success(filePatn + "node.sem");
    }
    public R<String> lineToSem(List<GridDto> dtos,String token) throws Exception {
    public R<String> lineToSem(List<GridDto> dtos, String token,String semUrl) throws Exception {
        String path = outPath + "\\line\\";
        String publicKey = EntityLibraryUtils.getPublicKey();
        JSONArray jsonArrayList = EntityLibraryUtils.getLineInfo(dtos, token);
@@ -651,13 +652,8 @@
        FileWriter fileWriter = new FileWriter(pointPath);
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(pointPath, filePatn + "link.sem");
        return success(filePatn + "link.sem");
        SemUtils.cityJsonToSem(pointPath, semUrl + "link.sem");
        return success(semUrl + "link.sem");
    }
    @ApiOperation(value = "管线转cityjson")
@@ -715,7 +711,7 @@
    @ApiOperation(value = "地形转sem")
    @PostMapping(value = "/terrainToSem", produces = "application/json; charset=UTF-8")
    public R<String> terrainToSem(@RequestBody List<GridDto> dtos) throws Exception {
    public R<String> terrainToSem(@RequestBody List<GridDto> dtos,String semUrl) throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\terrain\\" + times + "\\";
        File dirFile = new File(path + "appearance");
@@ -752,13 +748,8 @@
        FileWriter fileWriter = new FileWriter(path + "terrain.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(path + "terrain.json", filePatn + "terrain.sem");
        return success(filePatn + "terrain.sem");
        SemUtils.cityJsonToSem(path + "terrain.json", semUrl + "terrain.sem");
        return success(semUrl + "terrain.sem");
    }
    @ApiOperation(value = "地形转cityjson")
@@ -788,7 +779,7 @@
    @ApiOperation(value = "grid转cityjson")
    @PostMapping(value = "/gridToCityJson", produces = "application/json; charset=UTF-8")
    public R<String> gridToCityJson(@RequestBody List<GridDto> dtos) throws Exception {
    public R<String> gridToCityJson(@RequestBody List<GridDto> dtos,String semUrl) throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\grid\\" + times + "\\";
        File dirFile = new File(path);
@@ -809,18 +800,13 @@
        FileWriter fileWriter = new FileWriter(path + "grid.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(path + "grid.json", filePatn + "grid.sem");
        return success(filePatn + "grid.sem");
        SemUtils.cityJsonToSem(path + "grid.json", semUrl + "grid.sem");
        return success(semUrl + "grid.sem");
    }
    @ApiOperation(value = "river转sem")
    @GetMapping(value = "/riverToSem", produces = "application/json; charset=UTF-8")
    public R<String> riverToSem() throws Exception {
    public R<String> riverToSem(String semUrl) throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\river\\" + times + "\\";
        File dirFile = new File(path);
@@ -831,18 +817,13 @@
        FileWriter fileWriter = new FileWriter(path + "river.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(path + "river.json", filePatn + "river.sem");
        return success(filePatn + "river.sem");
        SemUtils.cityJsonToSem(path + "river.json", semUrl + "river.sem");
        return success(semUrl + "river.sem");
    }
    @ApiOperation(value = "landuse转sem")
    @GetMapping(value = "/landuseToSem", produces = "application/json; charset=UTF-8")
    public R<String> landuseToSem() throws Exception {
    public R<String> landuseToSem(String semUrl) throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\landuse\\" + times + "\\";
        File dirFile = new File(path);
@@ -853,13 +834,8 @@
        FileWriter fileWriter = new FileWriter(path + "landuse.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        String filePatn = inPath + "\\tongzhou\\";
        File file = new File(filePatn);
        if (!file.exists()) {
            file.mkdirs();
        }
        SemUtils.cityJsonToSem(path + "landuse.json", filePatn + "landuse.sem");
        return success(filePatn + "landuse.sem");
        SemUtils.cityJsonToSem(path + "landuse.json", semUrl + "landuse.sem");
        return success(semUrl + "landuse.sem");
    }
    public JSONObject getModule(String moduleName) {
src/main/java/com/se/simu/domain/po/SimuPo.java
@@ -44,6 +44,9 @@
    @ApiModelProperty("备注")
    private String bak;
    @ApiModelProperty("sem路径")
    private String semUrl;
    public SimuPo() {
    }
@@ -143,4 +146,12 @@
    public void setBak(String bak) {
        this.bak = bak;
    }
    public String getSemUrl() {
        return semUrl;
    }
    public void setSemUrl(String semUrl) {
        this.semUrl = semUrl;
    }
}
src/main/java/com/se/simu/domain/vo/CreateFilesSimuVo.java
@@ -85,4 +85,7 @@
    @ApiModelProperty("计算模型类型")
    private String modelType;
    @ApiModelProperty("sem路径")
    private String semUrl;
}
src/main/java/com/se/simu/service/SimuFilesService.java
@@ -120,15 +120,13 @@
        if (StringHelper.isEmpty(vo.getName())) {
            vo.setName(date);
        }
        DataPo data = BeanUtil.copyProperties(vo, DataPo.class);
        data.setPath(date, date);
        initPath(data);
        SimuPo simu = new SimuPo(vo.getNum(), vo.getPid(), vo.getName(), JSONUtil.toJsonStr(data), 0, vo.getBak());
        simu.setServiceName(date);
        simu.setCreateTime(new Timestamp(now.getTime()));
        simu.setSemUrl(vo.getSemUrl());
        int rows = simuMapper.insert(simu);
        if (rows > 0) {
            asyncCall(simu);
src/main/resources/application-prod.yml
@@ -156,3 +156,4 @@
  waterPath: depth
  flowPath: velocity
  copyTif: false
  tifPath: H:\城市内涝\sem\tongzhou_1m_tif\tongzhou_raster_4548_1m_clip_river_fill.tif