| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.se.simu.domain.po.SimuPo; |
| | | import com.se.simu.helper.WebHelper; |
| | | import com.se.simu.service.SimuService; |
| | | import com.se.simu.service.WaterService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | @RestController |
| | | @RequestMapping("/waterlogging") |
| | | public class WaterController { |
| | | @Resource |
| | | SimuService simuService; |
| | | |
| | | @Resource |
| | | WaterService waterService; |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "根据坐标查询积水深度") |
| | | @GetMapping("/{serviceName}/getWaterHeight") |
| | | public Double getWaterHeight(@PathVariable String serviceName, Double x, Double y, Long timestamp, HttpServletResponse res) { |
| | | @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") |
| | | }) |
| | | public Double getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) { |
| | | try { |
| | | if (!validate(serviceName, res)) { |
| | | SimuPo simu = simuService.getSimuByServiceName(serviceName); |
| | | if (null == simu) { |
| | | return null; |
| | | } |
| | | |
| | | // 根据服务名+时间戳+坐标,查询对应的积水深度 |
| | | return waterService.getWaterHeight(serviceName, x, y, timestamp); |
| | | return waterService.getWaterHeight(simu, x, y, timestamp); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |