13693261870
2024-11-02 dc0601492c12ea8009ab0e47ff25ec0e78f60903
src/main/java/com/se/simu/controller/WaterController.java
@@ -2,6 +2,7 @@
import com.se.simu.domain.po.SimuPo;
import com.se.simu.domain.vo.R;
import com.se.simu.helper.StringHelper;
import com.se.simu.helper.WebHelper;
import com.se.simu.service.SimuService;
import com.se.simu.service.WaterService;
@@ -145,13 +146,13 @@
    }
    @ApiOperation(value = "根据坐标查询积水深度")
    @GetMapping("/{serviceName}/getWaterHeight")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serviceName", value = "服务名", dataType = "String", paramType = "path", example = "20241010095328"),
            @ApiImplicitParam(name = "x", value = "X", dataType = "double", paramType = "query", example = "116.6447998"),
            @ApiImplicitParam(name = "y", value = "Y", dataType = "double", paramType = "query", example = "39.8868915"),
            @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) {
        try {
            SimuPo simu = simuService.getSimuByServiceName(serviceName);
@@ -167,6 +168,47 @@
        }
    }
    @ApiOperation(value = "根据seid查询建筑物涉水深度")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serviceName", value = "服务名", dataType = "String", paramType = "path", example = "20241010095328"),
            @ApiImplicitParam(name = "seid", value = "X", dataType = "String", paramType = "query", example = "5_f128d8b1aba6455c88d2f42334ca62bb")
    })
    @GetMapping("/{serviceName}/getBuildingDepthBySeid")
    public R<Object> getBuildingDepthBySeid(@PathVariable String serviceName, String seid) {
        try {
            if (StringHelper.isEmpty(serviceName) || StringHelper.isEmpty(seid)) {
                return null;
            }
            // 根据服务名+时间戳+坐标,查询对应的积水深度
            return success(waterService.getBuildingDepthBySeid(serviceName, seid));
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return fail(ex);
        }
    }
    @ApiOperation(value = "根据timestamp查询建筑物涉水深度")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serviceName", value = "服务名", dataType = "String", paramType = "path", example = "20241010095328"),
            @ApiImplicitParam(name = "timestamp", value = "时间戳", dataType = "Long", paramType = "query", example = "1730217660000")
    })
    @GetMapping("/{serviceName}/getBuildingDepthByTime")
    public R<Object> getBuildingDepthByTime(@PathVariable String serviceName, Long timestamp) {
        try {
            if (StringHelper.isEmpty(serviceName) || null == timestamp) {
                return null;
            }
            // 根据服务名+时间戳+坐标,查询对应的积水深度
            return success(waterService.getBuildingDepthByTime(serviceName, timestamp));
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return fail(ex);
        }
    }
    private boolean validate(String serviceName, HttpServletResponse res) {
        if (WebHelper.isEmpty(serviceName)) {
            return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空");