张洋洋
2025-02-10 c3137476e71b28cb77f52d24b2714cee336fc2f4
src/main/java/com/se/simu/controller/SimuController.java
@@ -54,6 +54,9 @@
    @Value("${config.outPath}")
    private String outPath;
    @Value("${config.inPath}")
    private String inPath;
    @Resource
    ResultService resultService;
@@ -401,8 +404,13 @@
        FileWriter fileWriter = new FileWriter(path + tableName + "\\降雨量.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        SemUtils.cityJsonToSem(path + tableName + "\\降雨量.json", path + tableName + "\\station_rain.sem");
        return success(path + tableName + "\\station_rain.sem");
        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");
    }
    @ApiOperation(value = "管点转cityjson")
@@ -445,8 +453,13 @@
        FileWriter fileWriter = new FileWriter(pointPath);
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        SemUtils.cityJsonToSem(pointPath, path + times + "\\point.sem");
        return success(path + times + "\\point.sem");
        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");
    }
    @ApiOperation(value = "管线转cityjson")
@@ -493,8 +506,13 @@
        FileWriter fileWriter = new FileWriter(pointPath);
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        SemUtils.cityJsonToSem(pointPath, path + times + "\\line.sem");
        return success(path + times + "\\line.sem");
        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");
    }
    @ApiOperation(value = "地形转cityjson")
@@ -513,8 +531,13 @@
        FileWriter fileWriter = new FileWriter(path + "terrain.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        SemUtils.cityJsonToSem(path + "terrain.json", path + "terrain.sem");
        return success(path + "terrain.sem");
        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");
    }
    @ApiOperation(value = "grid转cityjson")
@@ -522,26 +545,75 @@
    public R<String> gridToCityJson(@RequestBody List<GridDto> dtos) throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\grid\\" + times + "\\";
        File dirFile = new File(path );
        File dirFile = new File(path);
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        JSONObject jsonObject = getModule("grid.json");
        JSONArray array = jsonObject.getJSONArray("vertices");
        for (GridDto dto:dtos
             ) {
            JSONArray jsonArray=new JSONArray();
        for (GridDto dto : dtos
        ) {
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(dto.getLon());
            jsonArray.add(dto.getLat());
            jsonArray.add(0);
            array.add(jsonArray);
        }
        jsonObject.put("vertices",array);
        jsonObject.put("vertices", array);
        FileWriter fileWriter = new FileWriter(path + "grid.json");
        fileWriter.write(jsonObject.toJSONString());
        fileWriter.close();
        SemUtils.cityJsonToSem(path + "grid.json", path + "grid.sem");
        return success(path + "grid.sem");
        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");
    }
    @ApiOperation(value = "river转sem")
    @GetMapping(value = "/riverToSem", produces = "application/json; charset=UTF-8")
    public R<String> riverToSem() throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\river\\" + times + "\\";
        File dirFile = new File(path);
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        JSONObject jsonObject = getModule("river.json");
        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");
    }
    @ApiOperation(value = "landuse转sem")
    @GetMapping(value = "/landuseToSem", produces = "application/json; charset=UTF-8")
    public R<String> landuseToSem() throws Exception {
        long times = System.currentTimeMillis();
        String path = outPath + "\\landuse\\" + times + "\\";
        File dirFile = new File(path);
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        JSONObject jsonObject = getModule("landuse.json");
        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");
    }
    public JSONObject getModule(String moduleName) {