WindTurbineStatusDataController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.jiayue.ipfcst.console.controller;
  2. import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
  3. import com.jiayue.ipfcst.console.service.WindTurbineStatusDataService;
  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.Date;
  10. import java.util.Map;
  11. @RestController
  12. @Slf4j
  13. public class WindTurbineStatusDataController {
  14. private final WindTurbineStatusDataService windTurbineStatusDataService;
  15. @Autowired
  16. public WindTurbineStatusDataController(WindTurbineStatusDataService windTurbineStatusDataService) {
  17. this.windTurbineStatusDataService = windTurbineStatusDataService;
  18. }
  19. /**
  20. * 分页查询 所有风机功率状态
  21. *
  22. * @param startTime 开始时间
  23. * @param endTime 结束时间
  24. * @param page 页码
  25. * @param size 条数
  26. * @param no 风机编号
  27. * @return
  28. */
  29. @GetMapping(value = "/windTurbineStatusData/{stationCode}/{startTime}/{endTime}/{page}/{size}/{no}")
  30. public ResponseVO findByTimeBetweenForPaging(@PathVariable("stationCode") String stationCode,
  31. @PathVariable("startTime") Long startTime,
  32. @PathVariable("endTime") Long endTime,
  33. @PathVariable("page") Integer page,
  34. @PathVariable("size") Integer size,
  35. @PathVariable("no") String no) {
  36. Map<String, Object> map;
  37. try {
  38. map = windTurbineStatusDataService.findByTimeBetweenForPaging(stationCode, new Date(startTime), new Date(endTime), page, size, no);
  39. return ResponseVO.success(map);
  40. } catch (Exception e) {
  41. e.printStackTrace();
  42. log.error("风机分页查询错误");
  43. return ResponseVO.fail(e.toString());
  44. }
  45. }
  46. /**
  47. * 分页查询 按设备编号查询风机状态
  48. *
  49. * @param startTime 开始时间
  50. * @param endTime 结束时间
  51. * @param page 页码
  52. * @param size 条数
  53. * @return
  54. */
  55. @GetMapping(value = "/windTurbineStatusData/{startTime}/{endTime}/{page}/{size}/{no}")
  56. public ResponseVO findByTimeBetweenForPaging(@PathVariable("startTime") Long startTime,
  57. @PathVariable("endTime") Long endTime,
  58. @PathVariable("page") Integer page,
  59. @PathVariable("size") Integer size,
  60. @PathVariable("no") Integer[] no,
  61. String timeSortOrder, String noSortOrder) {
  62. Map<String, Object> map;
  63. try {
  64. map = windTurbineStatusDataService.findByTimeBetweenAndNoForPaging(new Date(startTime), new Date(endTime), page, size, no, timeSortOrder, noSortOrder);
  65. return ResponseVO.success(map);
  66. } catch (Exception e) {
  67. e.printStackTrace();
  68. log.error("按设备号风机分页查询错误");
  69. return ResponseVO.fail(e.toString());
  70. }
  71. }
  72. }