张洋洋
2025-02-24 9804628abf554c3658345fc8fc9472cfb179fd5f
src/main/java/com/se/simu/controller/WaterController.java
@@ -1,6 +1,7 @@
package com.se.simu.controller;
import com.se.simu.domain.po.SimuPo;
import com.se.simu.domain.vo.PondingVo;
import com.se.simu.domain.vo.R;
import com.se.simu.helper.StringHelper;
import com.se.simu.helper.WebHelper;
@@ -19,16 +20,12 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
/**
 * 内涝管理
 *
 * @author WWW
 * @date   2024-07-16
 */
@Api(tags = "内涝管理")
@Slf4j
@RestController
@SuppressWarnings("ALL")
@RequestMapping("/waterlogging")
public class WaterController extends BaseController {
    @Resource
@@ -86,6 +83,23 @@
            }
            byte[] bytes = waterService.getson(serviceName, "building.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}/{timestamp}/water.json")
    public void getWaterJson(@PathVariable String serviceName, @PathVariable String timestamp, HttpServletResponse res) {
        try {
            if (!validate(serviceName, res)) {
                return;
            }
            byte[] bytes = waterService.getson(serviceName, "waters" + File.separator + timestamp + File.separator + "water.json");
            WebHelper.writeBytes(bytes, res);
        } catch (Exception ex) {
@@ -153,15 +167,17 @@
            @ApiImplicitParam(name = "timestamp", value = "时间戳", dataType = "long", paramType = "query", example = "1730217660000")
    })
    @GetMapping("/{serviceName}/getWaterHeight")
    public R<Double> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
    public R<Object> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) {
        try {
            SimuPo simu = simuService.getSimuByServiceName(serviceName);
            if (null == simu) {
                return null;
            }
            // 根据服务名+时间戳+坐标,查询对应的积水深度
            return success(waterService.getWaterHeight(simu, x, y, timestamp));
            Double depth = waterService.getWaterHeight(simu, x, y, timestamp);
            Double area = waterService.getWaterArea(simu, x, y, timestamp);
            return success(new PondingVo(depth, area));
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return fail(ex);