ProEconTestingPointController.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package com.gyee.backconfig.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.gyee.backconfig.config.CacheContext;
  4. import com.gyee.backconfig.config.R;
  5. import com.gyee.backconfig.model.auto.ProEconTestingPoint;
  6. import com.gyee.backconfig.service.auto.AsysncGeneratePointService;
  7. import com.gyee.backconfig.service.auto.IProEconTestingPointService;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.ArrayList;
  13. import java.util.Arrays;
  14. import java.util.List;
  15. /**
  16. * <p>
  17. * 逻辑测点 前端控制器
  18. * </p>
  19. *
  20. * @author wang
  21. * @since 2022-11-10
  22. */
  23. @Api(value = "逻辑测点配置" ,tags = "逻辑测点配置")
  24. @RestController
  25. @RequestMapping("//pro-econ-testing-point")
  26. public class ProEconTestingPointController {
  27. @Autowired
  28. private IProEconTestingPointService proEconTestingPointService;
  29. @Autowired
  30. private CacheContext cacheContext;
  31. @Autowired
  32. private AsysncGeneratePointService asysncTestService;
  33. /**
  34. * 逻辑测点list
  35. * @param id
  36. * @param nemCode
  37. * @param name
  38. * @param model
  39. * @param uniformCode
  40. * @param isDisplay
  41. * @param pageNum
  42. * @param pageSize
  43. * @return
  44. */
  45. @GetMapping(value = "/list")
  46. @ApiOperation(value = "逻辑测点配置-列表", notes = "逻辑测点配置-列表")
  47. public R findList(@RequestParam(value = "id", required = false) String id,
  48. @RequestParam(value = "nemCode", required = false) String nemCode,
  49. @RequestParam(value = "name", required = false) String name,
  50. @RequestParam(value = "model", required = false) String model,
  51. @RequestParam(value = "uniformCode", required = false) String uniformCode,
  52. @RequestParam(value = "isDisplay", required = false) String isDisplay,
  53. @RequestParam(value = "pageNum", required = true) String pageNum,
  54. @RequestParam(value = "pageSize", required = true) String pageSize) {
  55. IPage<ProEconTestingPoint> list = proEconTestingPointService.list( id, nemCode, name, model, uniformCode, isDisplay, pageNum, pageSize);
  56. if (null != list) {
  57. return R.ok().data(list);
  58. } else {
  59. return R.error().data("查询失败!");
  60. }
  61. }
  62. /**
  63. * 添加
  64. * @param proEconTestingPoint
  65. * @return
  66. */
  67. @PostMapping(value = "/add")
  68. @ApiOperation(value = "逻辑测点配置-新增or修改", notes = "逻辑测点配置-新增or修改")
  69. public R addAll(@RequestBody ProEconTestingPoint proEconTestingPoint) {
  70. boolean b = proEconTestingPointService.saveOrUpdate(proEconTestingPoint);
  71. if (b) {
  72. cacheContext.initProEconTestingPointList();
  73. return R.ok().data(b);
  74. } else {
  75. return R.error().data("保存失败!");
  76. }
  77. }
  78. /**
  79. * 删除
  80. * @param ids
  81. * @return
  82. */
  83. @DeleteMapping(value = "/{ids}")
  84. @ApiOperation(value = "逻辑测点配置-删除", notes = "逻辑测点配置-删除")
  85. public R deleteAll(@PathVariable("ids") String ids) {
  86. String[] strings = ids.split(",");
  87. boolean b = proEconTestingPointService.removeByIds(Arrays.asList(strings));
  88. if (b) {
  89. cacheContext.initProEconTestingPointList();
  90. return R.ok().data(b);
  91. } else {
  92. return R.error().data("删除失败!");
  93. }
  94. }
  95. /**
  96. * 测点生成器
  97. * @param points 测点,数组 默认空:全部
  98. * @param station 场站 默认空(全场)
  99. * @param type fj:风机测点;fc:风场测点;sbs:变电所测点;ws:气象站测点;sq:方正测点 默认空:全部
  100. * @return
  101. */
  102. @PostMapping(value = "/generatePoint")
  103. @ApiOperation(value = "设备or场站测点生成", notes = "设备or场站测点生成")
  104. public R generatePoint(@RequestParam(value = "points", required = false) String[] points,
  105. @RequestParam(value = "station", required = false) String station,
  106. @RequestParam(value = "type", required = false) String type) {
  107. try {
  108. asysncTestService.generatePoint(station, points, type);
  109. } catch (Exception e) {
  110. e.printStackTrace();
  111. return R.error();
  112. }
  113. return R.ok().data(true);
  114. }
  115. /**
  116. * 测点分类列表
  117. * @param type fj:风机测点;fc:风场测点;sbs:变电所测点;ws:气象站测点;sq:方正测点 默认空:全部
  118. * @return
  119. */
  120. @PostMapping(value = "/type-point-list")
  121. @ApiOperation(value = "测点分类列表", notes = "测点分类列表")
  122. public R generateTypePointList( @RequestParam(value = "type", required = false) String type) {
  123. List<ProEconTestingPoint> list = new ArrayList<>();
  124. try {
  125. list = proEconTestingPointService.generateTypePointList(type);
  126. } catch (Exception e) {
  127. e.printStackTrace();
  128. return R.error();
  129. }
  130. return R.ok().data(list);
  131. }
  132. @PostMapping(value = "/generateSubStationPoint")
  133. @ApiOperation(value = "变电所测点生成", notes = "变电所测点生成")
  134. public R generateSubStationPoint(@RequestParam(value = "points", required = false) String[] points,
  135. @RequestParam(value = "station", required = false) String station) {
  136. try {
  137. proEconTestingPointService.generateSubStationPoint(station,points);
  138. } catch (Exception e) {
  139. e.printStackTrace();
  140. return R.error();
  141. }
  142. return R.ok().data(true);
  143. }
  144. @PostMapping(value = "/generateWsStationPoint")
  145. @ApiOperation(value = "气象站测点生成", notes = "气象站测点生成")
  146. public R generateWsStationPoint(@RequestParam(value = "points", required = false) String[] points,
  147. @RequestParam(value = "station", required = false) String station) {
  148. try {
  149. proEconTestingPointService.generateWsStationPoint(station,points);
  150. } catch (Exception e) {
  151. e.printStackTrace();
  152. return R.error();
  153. }
  154. return R.ok().data(true);
  155. }
  156. @PostMapping(value = "/generateSquareStationPoint")
  157. @ApiOperation(value = "光伏阵区测点生成", notes = "光伏阵区测点生成")
  158. public R generateSquareStationPoint(@RequestParam(value = "points", required = false) String[] points,
  159. @RequestParam(value = "station", required = false) String station) {
  160. try {
  161. proEconTestingPointService.generateSquareStationPoint(station,points);
  162. } catch (Exception e) {
  163. e.printStackTrace();
  164. return R.error();
  165. }
  166. return R.ok().data(true);
  167. }
  168. }