InverterInfoController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.jiayue.ipp.idp.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.jiayue.ipp.common.data.entity.InverterInfo;
  6. import com.jiayue.ipp.common.data.entity.WindTurbineInfo;
  7. import com.jiayue.ipp.idp.service.InverterInfoService;
  8. import com.jiayue.ipp.idp.util.R;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import lombok.RequiredArgsConstructor;
  12. import org.springframework.security.access.prepost.PreAuthorize;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.ArrayList;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * idp_inverter_info
  20. *
  21. * @author whc
  22. * @date 2022-03-18 15:49:11
  23. */
  24. @RestController
  25. @RequiredArgsConstructor
  26. @RequestMapping("/inverterinfo")
  27. @Api(value = "inverterinfo", tags = "idp_inverter_info管理")
  28. public class InverterInfoController {
  29. private final InverterInfoService inverterInfoService;
  30. /**
  31. * 分页查询
  32. *
  33. * @param page 分页对象
  34. * @param inverterInfo idp_inverter_info
  35. * @return
  36. */
  37. @ApiOperation(value = "分页查询", notes = "分页查询")
  38. @GetMapping("/page")
  39. public R getInverterInfoPage(Page page, InverterInfo inverterInfo) {
  40. return R.ok(inverterInfoService.page(page, Wrappers.query(inverterInfo)));
  41. }
  42. /**
  43. * 根据场站编号分页查询
  44. *
  45. * @param currentPage
  46. * @param pageSize
  47. * @param stationCode
  48. * @return
  49. */
  50. @ApiOperation(value = "根据场站编号分页查询", notes = "分页查询")
  51. @PostMapping("/getByStationCode")
  52. public R getByStationCode(Long currentPage, Long pageSize, String stationCode) {
  53. Page page = new Page(currentPage, pageSize);
  54. page.setMaxLimit((long) -1);
  55. return R.ok(inverterInfoService.page(page, inverterInfoService.getByStationCode(stationCode)));
  56. }
  57. /**
  58. * 通过id查询idp_inverter_info
  59. *
  60. * @param id id
  61. * @return R
  62. */
  63. @ApiOperation(value = "通过id查询", notes = "通过id查询")
  64. @GetMapping("/{id}")
  65. public R getById(@PathVariable("id") String id) {
  66. return R.ok(inverterInfoService.getById(id));
  67. }
  68. /**
  69. * 新增idp_inverter_info
  70. *
  71. * @param inverterInfo idp_inverter_info
  72. * @return R
  73. */
  74. @ApiOperation(value = "新增idp_inverter_info", notes = "新增idp_inverter_info")
  75. @PostMapping
  76. public R save(@RequestBody InverterInfo inverterInfo) {
  77. return R.ok(inverterInfoService.save(inverterInfo));
  78. }
  79. /**
  80. * 修改idp_inverter_info
  81. *
  82. * @param inverterInfo idp_inverter_info
  83. * @return R
  84. */
  85. @ApiOperation(value = "修改idp_inverter_info", notes = "修改idp_inverter_info")
  86. @PutMapping
  87. public R updateById(@RequestBody InverterInfo inverterInfo) {
  88. return R.ok(inverterInfoService.updateById(inverterInfo));
  89. }
  90. /**
  91. * 通过id删除idp_inverter_info
  92. *
  93. * @param id id
  94. * @return R
  95. */
  96. @ApiOperation(value = "通过id删除idp_inverter_info", notes = "通过id删除idp_inverter_info")
  97. @DeleteMapping("/{id}")
  98. public R removeById(@PathVariable String id) {
  99. return R.ok(inverterInfoService.removeById(id));
  100. }
  101. /**
  102. * 根据场站编号查询 返回map格式
  103. *
  104. * @param stationCode
  105. * @return
  106. */
  107. @ApiOperation(value = "根据场站编号查询", notes = "分页查询")
  108. @PostMapping("/findByStationCode")
  109. public R findByStationCode(String stationCode) {
  110. List<InverterInfo> inverterInfoList = inverterInfoService.findByStationCode(stationCode);
  111. List<Map<String, String>> list = new ArrayList<>();
  112. for (InverterInfo e : inverterInfoList) {
  113. Map<String, String> map = new HashMap<>();
  114. map.put("label", e.getName());
  115. map.put("value", e.getEquipmentNo());
  116. list.add(map);
  117. }
  118. return R.ok(list);
  119. }
  120. @GetMapping("/all")
  121. public R findAll() {
  122. List<InverterInfo> inverterInfoList = inverterInfoService.list();
  123. List<Map<String, String>> list = new ArrayList<>();
  124. for (InverterInfo e : inverterInfoList) {
  125. Map<String, String> map = new HashMap<>();
  126. map.put("label", e.getName());
  127. map.put("value", e.getId());
  128. list.add(map);
  129. }
  130. return R.ok(list);
  131. }
  132. /**
  133. * 查找设备编号是否存在
  134. *
  135. * @param stationCode
  136. * @return
  137. */
  138. @GetMapping("/findExistEquipmentNo")
  139. public R findExistEquipmentNo(String stationCode,String equipmentNo) {
  140. QueryWrapper<InverterInfo> wrapper = new QueryWrapper<>();
  141. wrapper.eq("station_code", stationCode);
  142. wrapper.eq("equipment_no", equipmentNo);
  143. List<InverterInfo> inverterInfoList = inverterInfoService.list(wrapper);
  144. return R.ok(inverterInfoList);
  145. }
  146. }