NwpController.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.jiayue.ipfcst.console.controller;
  2. import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
  3. import com.jiayue.ipfcst.console.service.NwpService;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.PathVariable;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import java.util.Map;
  10. /**
  11. * NWP信息restful接口
  12. *
  13. * @author yh
  14. * @version 1.0
  15. * @since 2019/8/7 10:12
  16. */
  17. @RestController
  18. @Slf4j
  19. public class NwpController {
  20. private final NwpService nwpService;
  21. @Autowired
  22. public NwpController(NwpService nwpService) {
  23. this.nwpService = nwpService;
  24. }
  25. /**
  26. * 按时间查询实时nwp yh
  27. *
  28. * @param startTime 开始时间
  29. * @param endTime 结束时间
  30. * @return 结果集
  31. */
  32. @GetMapping(value = "/nwp/{startTime}/{endTime}/{stationCode}")
  33. public ResponseVO findByForecastTimeBetween(@PathVariable("startTime") Long startTime,
  34. @PathVariable("endTime") Long endTime,
  35. @PathVariable("stationCode") String stationCode) {
  36. Map<String, Object> map;
  37. try {
  38. map = nwpService.findByForecastTimeBetween(startTime, endTime, stationCode);
  39. return ResponseVO.success(map);
  40. } catch (Exception e) {
  41. e.printStackTrace();
  42. log.error("nwp实时查询错误");
  43. return ResponseVO.fail(e.toString());
  44. }
  45. }
  46. /**
  47. * 分页查询 实时nwp
  48. *
  49. * @param startTime 开始时间
  50. * @param endTime 结束时间
  51. * @param page 页码
  52. * @param size 条数
  53. * @param sortOrder 排序
  54. * @return
  55. */
  56. @GetMapping(value = "/nwp/{startTime}/{endTime}/{stationCode}/{page}/{size}")
  57. public ResponseVO findByTimeBetweenForPaging(@PathVariable("startTime") Long startTime,
  58. @PathVariable("endTime") Long endTime,
  59. @PathVariable("stationCode") String stationCode,
  60. @PathVariable("page") Integer page,
  61. @PathVariable("size") Integer size,
  62. String sortOrder) {
  63. Map<String, Object> map;
  64. try {
  65. map = nwpService.findByTimeBetweenAndNoForPaging(startTime, endTime, stationCode, page, size, sortOrder);
  66. return ResponseVO.success(map);
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. log.error("nwp实时分页查询错误");
  70. return ResponseVO.fail(e.toString());
  71. }
  72. }
  73. }