AlarmController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.huimv.env.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.huimv.common.utils.Result;
  6. import com.huimv.env.service.IAlarm;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import java.text.ParseException;
  11. /**
  12. * @Project : huimv.shiwan
  13. * @Package : com.huimv.biosafety.uface.controller
  14. * @Description : TODO
  15. * @Version : 1.0
  16. * @Author : ZhuoNing
  17. * @Create : 2020-12-25
  18. **/
  19. @RestController
  20. @RequestMapping("/alarm")
  21. @Slf4j
  22. public class AlarmController {
  23. @Autowired
  24. private IAlarm iAlarm;
  25. @RequestMapping(value = "/getAlarm",method = RequestMethod.GET)
  26. public Result getAlarmByFarmIdAndDate(@RequestParam(value = "farmId",required = true) Integer farmId,
  27. @RequestParam(value="alarmType",required=false) Integer alarmType,
  28. @RequestParam(value = "alarmDate",required=false) String alarmDate,
  29. @RequestParam(value = "pageSize",required=true) Integer pageSize,
  30. @RequestParam(value = "pageNo",required=true) Integer pageNo) throws ParseException {
  31. log.info("farmId>>"+farmId);
  32. log.info("alarmType>>"+alarmType);
  33. log.info("alarmDate>>"+alarmDate);
  34. log.info("pageNo>>"+pageNo);
  35. log.info("pageSize>>"+pageSize);
  36. //
  37. return iAlarm.getAlarm(farmId,alarmType,alarmDate,pageNo,pageSize);
  38. }
  39. @RequestMapping(value = "/getManyAlarm",method = RequestMethod.GET)
  40. public Result getManyAlarmByFarmIdAndDate(@RequestParam(value = "farmId",required = true) Integer farmId,
  41. @RequestParam(value="alarmType",required=false) Integer alarmType,
  42. @RequestParam(value = "alarmDate",required=false) String alarmDate,
  43. @RequestParam(value = "quantity",required=true) Integer quantity ) throws ParseException {
  44. log.info("farmId>>"+farmId);
  45. log.info("alarmType>>"+alarmType);
  46. log.info("alarmDate>>"+alarmDate);
  47. log.info("quantity>>"+quantity);
  48. //
  49. // return iAlarm.getAlarm(farmId,alarmType,alarmDate,pageNo,pageSize);
  50. return iAlarm.getAlarm(farmId,alarmType,alarmDate,quantity);
  51. }
  52. //查询今天的警报列表
  53. @RequestMapping(value = "/getTodayAlarm",method = RequestMethod.GET)
  54. public Result getTodayAlarmByFarmId(@RequestParam(value = "farmId",required = true) Integer farmId,
  55. @RequestParam(value = "quantity",required=true) Integer quantity ) throws ParseException {
  56. log.info("farmId>>"+farmId);
  57. log.info("quantity>>"+quantity);
  58. //
  59. return iAlarm.getAlarm(farmId,quantity);
  60. }
  61. //查询今日各类警报占比
  62. @RequestMapping(value = "/getTodayAlarmRate",method = RequestMethod.GET)
  63. public Result getTodayAlarmRate(@RequestParam(value = "farmId",required = true) Integer farmId) throws ParseException {
  64. log.info("farmId>>"+farmId);
  65. //
  66. return iAlarm.getAlarmRate(farmId);
  67. }
  68. //查询报警分布(一周数据)
  69. @RequestMapping(value = "/getOneWeekAlarm",method = RequestMethod.GET)
  70. public Result getOneWeekAlarm(@RequestParam(value = "farmId",required = true) Integer farmId) throws ParseException {
  71. log.info("farmId>>"+farmId);
  72. //
  73. return iAlarm.getOneWeekAlarm(farmId);
  74. }
  75. }