AlarmController.java 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. @CrossOrigin
  20. @RestController
  21. @RequestMapping("/alarm")
  22. @Slf4j
  23. public class AlarmController {
  24. @Autowired
  25. private IAlarm iAlarm;
  26. @RequestMapping(value = "/getAlarm",method = RequestMethod.GET)
  27. public Result getAlarmByFarmIdAndDate(@RequestParam(value = "farmId",required = true) Integer farmId,
  28. @RequestParam(value="alarmType",required=false) Integer alarmType,
  29. @RequestParam(value = "alarmDate",required=false) String alarmDate,
  30. @RequestParam(value = "pageSize",required=true) Integer pageSize,
  31. @RequestParam(value = "pageNo",required=true) Integer pageNo) throws ParseException {
  32. log.info("farmId>>"+farmId);
  33. log.info("alarmType>>"+alarmType);
  34. log.info("alarmDate>>"+alarmDate);
  35. log.info("pageNo>>"+pageNo);
  36. log.info("pageSize>>"+pageSize);
  37. //
  38. return iAlarm.getAlarm(farmId,alarmType,alarmDate,pageNo,pageSize);
  39. }
  40. @RequestMapping(value = "/getManyAlarm",method = RequestMethod.GET)
  41. public Result getManyAlarmByFarmIdAndDate(@RequestParam(value = "farmId",required = true) Integer farmId,
  42. @RequestParam(value="alarmType",required=false) Integer alarmType,
  43. @RequestParam(value = "alarmDate",required=false) String alarmDate,
  44. @RequestParam(value = "quantity",required=true) Integer quantity ) throws ParseException {
  45. log.info("farmId>>"+farmId);
  46. log.info("alarmType>>"+alarmType);
  47. log.info("alarmDate>>"+alarmDate);
  48. log.info("quantity>>"+quantity);
  49. //
  50. // return iAlarm.getAlarm(farmId,alarmType,alarmDate,pageNo,pageSize);
  51. return iAlarm.getAlarm(farmId,alarmType,alarmDate,quantity);
  52. }
  53. //查询今天的警报列表
  54. @RequestMapping(value = "/getTodayAlarm",method = RequestMethod.GET)
  55. public Result getTodayAlarmByFarmId(@RequestParam(value = "farmId",required = true) Integer farmId,
  56. @RequestParam(value = "quantity",required=true) Integer quantity ) throws ParseException {
  57. log.info("farmId>>"+farmId);
  58. log.info("quantity>>"+quantity);
  59. //
  60. return iAlarm.getAlarm(farmId,quantity);
  61. }
  62. //查询今日各类警报占比
  63. @RequestMapping(value = "/getTodayAlarmRate",method = RequestMethod.GET)
  64. public Result getTodayAlarmRate(@RequestParam(value = "farmId",required = true) Integer farmId){
  65. log.info("farmId>>"+farmId);
  66. //
  67. return iAlarm.getAlarmRate(farmId);
  68. }
  69. //查询报警分布(一周数据)
  70. @RequestMapping(value = "/getOneWeekAlarm",method = RequestMethod.GET)
  71. public Result getOneWeekAlarm(@RequestParam(value = "farmId",required = true) Integer farmId) throws ParseException {
  72. log.info("farmId>>"+farmId);
  73. //
  74. return iAlarm.getOneWeekAlarm(farmId);
  75. }
  76. }