ProEconAlarmRealController.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.gyee.alarm.controller;
  2. import com.gyee.alarm.model.auto.ProBasicPowerstation;
  3. import com.gyee.alarm.model.auto.ProBasicSubStation;
  4. import com.gyee.alarm.model.vo.AjaxResult;
  5. import com.gyee.alarm.model.vo.AjaxStatus;
  6. import com.gyee.alarm.model.vo.AlarmTypeValue;
  7. import com.gyee.alarm.service.TokenService;
  8. import com.gyee.alarm.util.StringUtils;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import org.springframework.web.context.request.RequestContextHolder;
  14. import org.springframework.web.context.request.ServletRequestAttributes;
  15. import javax.annotation.Resource;
  16. import javax.servlet.http.HttpServletRequest;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. /**
  20. * <p>
  21. * 前端控制器
  22. * </p>
  23. *
  24. * @author shilin
  25. * @since 2024-10-28
  26. */
  27. @RestController
  28. @RequestMapping("///electricity")
  29. public class ProEconAlarmRealController {
  30. @Resource
  31. private TokenService tokenService;
  32. @GetMapping(value = "/czlist")
  33. @ApiOperation(value = "查询场站列表", notes = "查询场站列表")
  34. public AjaxResult queryWplList(String types) {
  35. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  36. List<ProBasicPowerstation> wpls = tokenService.getWpls(request);
  37. List<ProBasicPowerstation> vos = new ArrayList<>();
  38. if(!wpls.isEmpty())
  39. {
  40. for(ProBasicPowerstation wp:wpls)
  41. {
  42. if(StringUtils.notEmp(types))
  43. {
  44. if(types.equals(AlarmTypeValue.WT.getCode()) && wp.getId().contains("FDC"))
  45. {
  46. vos.add(wp);
  47. }else if(types.equals(AlarmTypeValue.IN.getCode()) && wp.getId().contains("GDC"))
  48. {
  49. vos.add(wp);
  50. }else if(types.equals(AlarmTypeValue.BT.getCode()))
  51. {
  52. List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
  53. return AjaxResult.successData(AjaxStatus.success.code, subwpls);
  54. }
  55. }else
  56. {
  57. vos =wpls;
  58. }
  59. }
  60. }
  61. if (StringUtils.notEmp(vos)) {
  62. return AjaxResult.successData(AjaxStatus.success.code, vos);
  63. } else {
  64. return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
  65. }
  66. }
  67. }