ProjectController.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. package com.gyee.backconfig.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.gyee.backconfig.config.R;
  5. import com.gyee.backconfig.model.auto.Project;
  6. import com.gyee.backconfig.service.BackConfigService;
  7. import com.gyee.backconfig.service.auto.IProjectService;
  8. import com.gyee.backconfig.vo.Projectvo;
  9. import com.gyee.common.model.StringUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import javax.annotation.Resource;
  13. import java.util.Date;
  14. import java.util.List;
  15. /**
  16. * <p>
  17. * 前端控制器
  18. * </p>
  19. *
  20. * @author wang
  21. * @since 2022-09-22
  22. */
  23. @RestController
  24. @RequestMapping("//project")
  25. public class ProjectController {
  26. @Resource
  27. private BackConfigService backConfigService;
  28. @Autowired
  29. private IProjectService projectService;
  30. @GetMapping("/listByPage")
  31. @ResponseBody
  32. @CrossOrigin(origins = "*", maxAge = 3600)
  33. public R ListByPage(
  34. @RequestParam(value = "pagenum", required = true) Integer pageNum,
  35. @RequestParam(value = "pagesize", required = true) Integer pageSize,
  36. @RequestParam(value = "id", required = false) String id,
  37. @RequestParam(value = "code", required = false) String code,
  38. @RequestParam(value = "name", required = false) String name,
  39. @RequestParam(value = "aname", required = false) String aname,
  40. @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
  41. @RequestParam(value = "capacity", required = false) Integer capacity,
  42. @RequestParam(value = "capacityunit", required = false) String capacityunit,
  43. @RequestParam(value = "quantity", required = false) Integer quantity,
  44. @RequestParam(value = "model", required = false) String model,
  45. @RequestParam(value = "commissiondate", required = false) Date commissiondate,
  46. @RequestParam(value = "masterphone", required = false) String masterphone,
  47. @RequestParam(value = "shiftforeman", required = false) String shiftforeman,
  48. @RequestParam(value = "shiftforemanphone", required = false) String shiftforemanphone,
  49. @RequestParam(value = "ordernum", required = false) Integer ordernum,
  50. @RequestParam(value = "version", required = false) Integer version) {
  51. Projectvo vo = new Projectvo();
  52. setVOTemplate(pageNum, pageNum, id, code, name, aname, windpowerstationid, capacity, capacityunit, quantity, model, commissiondate, masterphone, shiftforeman, shiftforemanphone, ordernum, version, vo);
  53. Page<Project> ProjectPage = backConfigService.ProjectBypage(vo);
  54. if (StringUtils.isNotNull(ProjectPage)) {
  55. return R.ok().data(ProjectPage);
  56. } else {
  57. return R.error().message("访问失败");
  58. }
  59. }
  60. private void setVOTemplate(@RequestParam(value = "pagenum", required = true) Integer pageNum,
  61. @RequestParam(value = "pagesize", required = true) Integer pageSize,
  62. @RequestParam(value = "id", required = false) String id,
  63. @RequestParam(value = "code", required = false) String code,
  64. @RequestParam(value = "name", required = false) String name,
  65. @RequestParam(value = "aname", required = false) String aname,
  66. @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
  67. @RequestParam(value = "capacity", required = false) Integer capacity,
  68. @RequestParam(value = "capacityunit", required = false) String capacityunit,
  69. @RequestParam(value = "quantity", required = false) Integer quantity,
  70. @RequestParam(value = "model", required = false) String model,
  71. @RequestParam(value = "commissiondate", required = false) Date commissiondate,
  72. @RequestParam(value = "masterphone", required = false) String masterphone,
  73. @RequestParam(value = "shiftforeman", required = false) String shiftforeman,
  74. @RequestParam(value = "shiftforemanphone", required = false) String shiftforemanphone,
  75. @RequestParam(value = "ordernum", required = false) Integer ordernum,
  76. @RequestParam(value = "version", required = false) Integer version, Projectvo vo) {
  77. vo.setPageSize(pageSize);
  78. vo.setId(id);
  79. vo.setCurrent(pageNum);
  80. vo.setCode(code);
  81. vo.setName(name);
  82. vo.setAname(aname);
  83. vo.setWindpowerstationid(windpowerstationid);
  84. vo.setCapacity(capacity);
  85. vo.setCapacityunit(capacityunit);
  86. vo.setQuantity(quantity);
  87. vo.setMasterphone(masterphone);
  88. vo.setModel(model);
  89. vo.setCommissiondate(commissiondate);
  90. vo.setShiftforeman(shiftforeman);
  91. vo.setShiftforemanphone(shiftforemanphone);
  92. vo.setOrdernum(ordernum);
  93. vo.setVersion(version);
  94. }
  95. /**
  96. * 查询
  97. *
  98. * @param id
  99. * @param name
  100. * @param pageNum
  101. * @param pageSize
  102. * @return
  103. */
  104. @GetMapping(value = "/List")
  105. public R findList(@RequestParam(value = "id", required = false) String id,
  106. @RequestParam(value = "name", required = false) String name,
  107. @RequestParam(value = "code", required = false) String code,
  108. @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
  109. @RequestParam(value = "pageNum", required = true) String pageNum,
  110. @RequestParam(value = "pageSize", required = true) String pageSize) {
  111. IPage<Project> list = projectService.getList(id, name, code, windpowerstationid, pageNum, pageSize);
  112. if (null != list) {
  113. return R.ok().data(list);
  114. } else {
  115. return R.error().data("查询失败!");
  116. }
  117. }
  118. /**
  119. * 根据id查询
  120. *
  121. * @param id
  122. * @return
  123. */
  124. @GetMapping(value = "/{id}")
  125. public R findOne(@PathVariable("id") String id) {
  126. Project project = projectService.getOne(id);
  127. if (StringUtils.isNotNull(project)) {
  128. return R.ok().data(project);
  129. } else {
  130. return R.error().data("查询失败!");
  131. }
  132. }
  133. /**
  134. * 插入(批量)
  135. *
  136. * @param project
  137. * @return
  138. */
  139. @PostMapping(value = "/add")
  140. public R addAll(@RequestBody Project project) {
  141. boolean b = projectService.addOrUpdate(project);
  142. if (b) {
  143. return R.ok().data(b);
  144. } else {
  145. return R.error().data("保存失败!");
  146. }
  147. }
  148. /**
  149. * 批量删除
  150. *
  151. * @param ids
  152. * @return
  153. */
  154. @DeleteMapping(value = "/{ids}")
  155. public R deleteAll(@PathVariable("ids") String ids) {
  156. boolean b = projectService.removeByIds(ids);
  157. if (b) {
  158. return R.ok().data(b);
  159. } else {
  160. return R.error().data("删除失败!");
  161. }
  162. }
  163. /**
  164. * 批量修改
  165. *
  166. * @param list
  167. * @return
  168. */
  169. @PutMapping(value = "/editRegions")
  170. public R update(@RequestBody List<Project> list) {
  171. boolean b = projectService.updateBatchById(list);
  172. if (b) {
  173. return R.ok().data(b);
  174. } else {
  175. return R.error().data("更新失败!");
  176. }
  177. }
  178. }