| | |
| | | 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; |
| | | 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; |
| | |
| | | |
| | | 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 { |
| | | public class WaterController extends BaseController { |
| | | @Resource |
| | | SimuService simuService; |
| | | |
| | | @Resource |
| | | WaterService waterService; |
| | | |
| | |
| | | |
| | | 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) { |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "获取降水曲线文件曲线图") |
| | | @GetMapping("/{serviceName}/rainfall.json") |
| | | public void getRainfall(@PathVariable String serviceName, HttpServletResponse res) { |
| | | @ApiOperation(value = "根据坐标查询积水深度") |
| | | @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<Object> getWaterHeight(@PathVariable String serviceName, double x, double y, long timestamp, HttpServletResponse res) { |
| | | try { |
| | | if (!validate(serviceName, res)) { |
| | | return; |
| | | SimuPo simu = simuService.getSimuByServiceName(serviceName); |
| | | if (null == simu) { |
| | | return null; |
| | | } |
| | | |
| | | byte[] bytes = waterService.getRainfall(serviceName); |
| | | Double depth = waterService.getWaterHeight(simu, x, y, timestamp); |
| | | Double area = waterService.getWaterArea(simu, x, y, timestamp); |
| | | |
| | | WebHelper.writeBytes(bytes, res); |
| | | return success(new PondingVo(depth, area)); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | | return fail(ex); |
| | | } |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | } |
| | | |