AgcDeviateController.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.gyee.runeconomy.controller.agc;
  2. import com.gyee.runeconomy.config.GyeeConfig;
  3. import com.gyee.runeconomy.service.agc.AgcDeviateService;
  4. import org.springframework.web.bind.annotation.GetMapping;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestParam;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import javax.annotation.Resource;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.Map;
  12. import java.util.stream.Collectors;
  13. /**
  14. * 获取各个场站AGC偏差分析数据
  15. */
  16. @RestController
  17. @RequestMapping("/agc")
  18. public class AgcDeviateController {
  19. @Resource
  20. private AgcDeviateService agcDeviateService;
  21. @Resource
  22. private GyeeConfig gyeeConfig;
  23. /**
  24. * 获取偏差信息
  25. *
  26. * @param startTs 开始时间
  27. * @param endTs 结束时间
  28. * @param id 场站id
  29. * @param interval 时间间隔
  30. * @return
  31. */
  32. @GetMapping("/deviate")
  33. public Map<String, AgcDeviateTag> getData(@RequestParam(value = "startTs") long startTs,
  34. @RequestParam(value = "endTs") long endTs,
  35. @RequestParam(value = "id") String id,
  36. @RequestParam(value = "interval", defaultValue = "60", required = false) int interval) {
  37. List<AgcDeviateTag> ls = new ArrayList<>();
  38. if (gyeeConfig.isOffLine()) {
  39. ls = agcDeviateService.getAgcDeviateTags(id, startTs, endTs, interval);
  40. } else {
  41. ls = agcDeviateService.getAgcDeviateTags(id, startTs, endTs, interval);
  42. }
  43. return ls.stream().collect(Collectors.toMap(AgcDeviateTag::getName, f -> f));
  44. }
  45. /**
  46. * 获取配置
  47. *
  48. * @return
  49. */
  50. @GetMapping("/config")
  51. public Object getAgcConifg() {
  52. return agcDeviateService.getConfig();
  53. }
  54. }