PolicyShareController.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package com.qdport.controller;
  2. import com.qdport.annotation.WebLog;
  3. import com.qdport.entity.PolicyShare;
  4. import com.qdport.enums.QDPortEnum;
  5. import com.qdport.modules.system.entity.SysDept;
  6. import com.qdport.modules.system.service.SysDeptService;
  7. import com.qdport.query.PolicyShareQuery;
  8. import com.qdport.service.PolicyFileService;
  9. import com.qdport.service.PolicyLogService;
  10. import com.qdport.service.PolicyShareService;
  11. import com.qdport.service.PolicyTodoService;
  12. import com.qdport.vo.PolicyFileVO;
  13. import com.qdport.vo.PolicyLogVO;
  14. import com.qdport.vo.PolicyShareVO;
  15. import com.qdport.wrapper.PolicyShareWrapper;
  16. import org.springframework.web.bind.annotation.*;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import io.swagger.annotations.ApiParam;
  20. import com.qdport.core.tool.api.R;
  21. import com.qdport.core.tool.utils.Func;
  22. import com.qdport.core.boot.ctrl.QdportController;
  23. import com.baomidou.mybatisplus.core.metadata.IPage;
  24. import javax.annotation.Resource;
  25. import javax.servlet.http.HttpServletRequest;
  26. import javax.validation.Valid;
  27. import java.util.*;
  28. import java.util.concurrent.ExecutionException;
  29. /**
  30. * 政策共享
  31. *
  32. * @author yuheng
  33. * @since 1.0.0 2024-09-30
  34. */
  35. @RestController
  36. @RequestMapping("qdport-zcgx/share")
  37. @Api(value = "政策共享", tags = "政策共享")
  38. public class PolicyShareController extends QdportController {
  39. @Resource
  40. private PolicyShareService policyShareService;
  41. @Resource
  42. private PolicyFileService policyFileService;
  43. @Resource
  44. private PolicyTodoService policyTodoService;
  45. @Resource
  46. private SysDeptService sysDeptService;
  47. /**
  48. * 分页
  49. */
  50. @GetMapping("page")
  51. @ApiOperation(value = "分页", notes = "分页")
  52. public R<IPage<PolicyShareVO>> page(@Valid PolicyShareQuery query) {
  53. IPage<PolicyShareVO> page = policyShareService.page(query);
  54. List<PolicyShareVO> records = page.getRecords();
  55. for (PolicyShareVO model : records) {
  56. SysDept dept = sysDeptService.getById(model.getDeptId());
  57. model.setDeptName(dept.getName());
  58. SysDept company = sysDeptService.getById(model.getCompanyId());
  59. model.setCompanyName(company.getName());
  60. List<PolicyFileVO> fileList = policyFileService.getFileList(model.getId(), QDPortEnum.POLICY_FILE_REFTYPE_POLICY_SHARE.getValue());
  61. model.setFileList(fileList);
  62. }
  63. return R.data(page);
  64. }
  65. /**
  66. * 详情
  67. */
  68. @GetMapping("{id}")
  69. @ApiOperation(value = "详情", notes = "id")
  70. public R<PolicyShareVO> get(@PathVariable("id") String id) {
  71. PolicyShare entity = policyShareService.getById(id);
  72. PolicyShareVO vo = PolicyShareWrapper.build().entityVO(entity);
  73. SysDept dept = sysDeptService.getById(vo.getDeptId());
  74. vo.setDeptName(dept.getName());
  75. SysDept company = sysDeptService.getById(vo.getCompanyId());
  76. vo.setCompanyName(company.getName());
  77. List<PolicyFileVO> fileList = policyFileService.getFileList(entity.getId().toString(), QDPortEnum.POLICY_FILE_REFTYPE_POLICY_SHARE.getValue());
  78. vo.setFileList(fileList);
  79. return R.data(vo);
  80. }
  81. /**
  82. * 新增
  83. */
  84. @PostMapping("/save")
  85. @ApiOperation(value = "新增", notes = "传入PolicyShare")
  86. @WebLog(operateName = "新增", operateType = "policy_share")
  87. public R save(@RequestBody PolicyShareVO vo) {
  88. vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
  89. policyShareService.save(vo);
  90. return R.success("保存成功");
  91. }
  92. @PostMapping("/saveDone")
  93. @ApiOperation(value = "新增", notes = "传入PolicyShare")
  94. @WebLog(operateName = "管理员新增", operateType = "policy_share")
  95. public R saveDone(@RequestBody PolicyShareVO vo) {
  96. vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_DONE.getValue());
  97. policyShareService.save(vo);
  98. return R.success("保存成功");
  99. }
  100. @PostMapping("/saveApprove")
  101. @ApiOperation(value = "新增并且提交", notes = "传入PolicyShare")
  102. @WebLog(operateName = "新增并且上报", operateType = "policy_share")
  103. public R saveApprove(@RequestBody PolicyShareVO vo) throws ExecutionException, InterruptedException {
  104. policyShareService.saveApprove(vo);
  105. policyTodoService.save(vo);
  106. return R.success("新增并且提交成功");
  107. }
  108. /**
  109. * 修改
  110. */
  111. @PostMapping("/update")
  112. @ApiOperation(value = "编辑", notes = "传入PolicyShare")
  113. @WebLog(operateName = "修改", operateType = "policy_share")
  114. public R update(@RequestBody @Valid PolicyShareVO vo) {
  115. policyShareService.update(vo);
  116. return R.success("更新成功");
  117. }
  118. @PostMapping("/withdraw")
  119. @ApiOperation(value = "撤回", notes = "传入PolicyShare")
  120. @WebLog(operateName = "撤回", operateType = "policy_share")
  121. public R withdraw(@RequestBody @Valid PolicyShareVO vo) {
  122. policyShareService.withdraw(vo);
  123. return R.success("撤回成功");
  124. }
  125. @PostMapping("/approve")
  126. @ApiOperation(value = "审核通过", notes = "传入PolicyShare")
  127. @WebLog(operateName = "审核通过", operateType = "policy_share")
  128. public R approve(@RequestBody @Valid PolicyShareVO vo) throws ExecutionException, InterruptedException {
  129. vo.setIsWithdraw(0);
  130. policyShareService.approve(vo);
  131. policyTodoService.save(vo);
  132. return R.success("更新成功");
  133. }
  134. @PostMapping("/refuse")
  135. @ApiOperation(value = "审核拒绝", notes = "传入PolicyShare")
  136. @WebLog(operateName = "审核拒绝", operateType = "policy_share")
  137. public R refuse(@RequestBody @Valid PolicyShareVO vo) {
  138. vo.setIsWithdraw(1);
  139. policyShareService.refuse(vo);
  140. return R.success("更新成功");
  141. }
  142. @PostMapping("/resubmit")
  143. @ApiOperation(value = "重新提交", notes = "传入PolicyShare")
  144. @WebLog(operateName = "重新上报", operateType = "policy_share")
  145. public R resubmit(@RequestBody @Valid PolicyShareVO vo) throws ExecutionException, InterruptedException {
  146. vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_APPROVE.getValue());
  147. policyShareService.approve(vo);
  148. policyTodoService.save(vo);
  149. return R.success("重新发起成功");
  150. }
  151. /**
  152. * 删除
  153. */
  154. @PostMapping("/remove")
  155. @ApiOperation(value = "逻辑删除", notes = "传入ids")
  156. @WebLog(operateName = "删除", operateType = "policy_share")
  157. public R delete(@ApiParam(value = "主键集合", required = true) @RequestParam(name = "ids") String ids) {
  158. List<String> idList = Func.toStrList(ids);
  159. policyShareService.delete(idList);
  160. return R.success("删除成功");
  161. }
  162. }