1
13693261870
2024-11-01 a6415c0c5116172db31fd353032fdfd11ac91544
1
已修改3个文件
89 ■■■■ 文件已修改
src/main/java/com/se/simu/controller/WaterController.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/ResultService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/WaterService.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/WaterController.java
@@ -42,15 +42,49 @@
    private final static long Y2000 = 949334400000L;
    @ApiOperation(value = "获取元数据信息")
    @ApiOperation(value = "获取元数据JSON")
    @GetMapping("/{serviceName}/layer.json")
    public void getLayer(@PathVariable String serviceName, HttpServletResponse res) {
    public void getLayerJson(@PathVariable String serviceName, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getLayerJson(serviceName);
            byte[] bytes = waterService.getson(serviceName, "layer.json");
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
        }
    }
    @ApiOperation(value = "获取降水曲线JSON")
    @GetMapping("/{serviceName}/rainfall.json")
    public void getRainfallJson(@PathVariable String serviceName, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getson(serviceName, "rainfall.json");
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
        }
    }
    @ApiOperation(value = "获取建筑物涉水JSON")
    @GetMapping("/{serviceName}/building.json")
    public void getBuildingJson(@PathVariable String serviceName, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getson(serviceName, "building.json");
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
@@ -104,23 +138,6 @@
            String file = waterService.getFlowMap(serviceName, width, height, timestamp);
            WebHelper.writePng(file, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
        }
    }
    @ApiOperation(value = "获取降水曲线文件曲线图")
    @GetMapping("/{serviceName}/rainfall.json")
    public void getRainfall(@PathVariable String serviceName, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getRainfall(serviceName);
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
src/main/java/com/se/simu/service/ResultService.java
@@ -18,6 +18,7 @@
import org.gdal.gdalconst.gdalconst;
import org.gdal.ogr.*;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
@@ -565,6 +566,8 @@
    }
    private void copeBuildingDepthJson(ResultDto dto, List<BuildingDepthVo> list) throws IOException {
        if (CollectionUtils.isEmpty(list)) return;
        String json = JSON.toJSONString(list);
        String filePath = dto.getOutPath() + File.separator + "building.json";
src/main/java/com/se/simu/service/WaterService.java
@@ -37,9 +37,9 @@
    /**
     * 获取元数据信息
     */
    public byte[] getLayerJson(String serviceName) {
    public byte[] getson(String serviceName, String json) {
        try {
            String filePath = config.getOutPath() + File.separator + serviceName + File.separator + "layer.json";
            String filePath = config.getOutPath() + File.separator + serviceName + File.separator + json;
            File dat = new File(filePath);
            if (!dat.exists()) {
@@ -54,6 +54,7 @@
            return bytes;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
        }
    }
@@ -101,30 +102,6 @@
        layer.setWaters(new Water(data));
        return layer;
    }
    /**
     * 获取降水曲线文件曲线图
     */
    public byte[] getRainfall(String serviceName) {
        try {
            String filePath = config.getOutPath() + File.separator + serviceName + File.separator + "rainfall.json";
            File rainfall = new File(filePath);
            if (!rainfall.exists()) {
                return null;
            }
            byte[] bytes = new byte[(int) rainfall.length()];
            FileInputStream fs = new FileInputStream(filePath);
            fs.read(bytes);
            fs.close();
            return bytes;
        } catch (Exception ex) {
            return null;
        }
    }
    /**