DeptResponsibilityController.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package com.ims.eval.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.ims.eval.config.CustomException;
  4. import com.ims.eval.entity.DeptResponsibility;
  5. import com.ims.eval.entity.Indicator;
  6. import com.ims.eval.entity.dto.response.DeptResponsibilityResDTO;
  7. import com.ims.eval.entity.dto.result.R;
  8. import com.ims.eval.service.IDeptResponsibilityService;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import javax.servlet.http.HttpServletRequest;
  13. import java.util.Arrays;
  14. import java.util.List;
  15. import java.util.Map;
  16. /**
  17. * <p>
  18. * 部门目标责任表 前端控制器
  19. * </p>
  20. *
  21. * @author wang
  22. * @since 2023-02-27
  23. */
  24. @RestController
  25. @RequestMapping("//dept-responsibility")
  26. public class DeptResponsibilityController {
  27. @Autowired
  28. private IDeptResponsibilityService deptResponsibilityService;
  29. @Autowired
  30. private HttpServletRequest request;
  31. /**
  32. * 分页查询
  33. *
  34. * @param pageNum 当前页数
  35. * @param pageSize 当前页大小
  36. * @param id 主键
  37. * @param responsibilityCode 业务编码
  38. * @param cycleUnit 周期单位
  39. * @param checkCycle 周期
  40. * @param beginDate 考核开始时间
  41. * @param endDate 考核截止时间
  42. * @param stage 审批状态
  43. * @param createBy 创建者
  44. * @param year 年
  45. * @param month 月
  46. * @param des 描述
  47. * @return
  48. */
  49. //@ImsPreAuth("eval:deptResponsibility:view")
  50. @GetMapping(value = "list")
  51. public R list(@RequestParam(value = "pageNum") Integer pageNum,
  52. @RequestParam(value = "pageSize") Integer pageSize,
  53. @RequestParam(value = "id", required = false) String id,
  54. @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode,
  55. @RequestParam(value = "cycleUnit", required = false) String cycleUnit,
  56. @RequestParam(value = "checkCycle", required = false) List<String> checkCycle,
  57. @RequestParam(value = "beginDate", required = false) String beginDate,
  58. @RequestParam(value = "endDate", required = false) String endDate,
  59. @RequestParam(value = "stage", required = false) String stage,
  60. @RequestParam(value = "createBy", required = false) String createBy,
  61. @RequestParam(value = "year", required = false) String year,
  62. @RequestParam(value = "month", required = false) String month,
  63. @RequestParam(value = "des", required = false) String des) {
  64. IPage<DeptResponsibility> list = deptResponsibilityService.list(pageNum, pageSize, id, responsibilityCode, cycleUnit, checkCycle, beginDate, endDate, stage, createBy, year, month, des);
  65. return R.ok().data(list);
  66. }
  67. /**
  68. * 添加
  69. *
  70. * @param deptResponsibility
  71. * @return
  72. */
  73. //@ImsPreAuth("eval:deptResponsibility:edit")
  74. @PostMapping(value = "/save")
  75. @ApiOperation(value = "新增(修改)", notes = "新增(修改)")
  76. public R add(@RequestBody DeptResponsibility deptResponsibility) {
  77. try {
  78. boolean b = deptResponsibilityService.saveOrUpdate(deptResponsibility);
  79. if (b) {
  80. return R.ok().data(b);
  81. } else {
  82. return R.error().data("保存失败!");
  83. }
  84. } catch (CustomException e) {
  85. return R.customError(e.getMessage()).data("失败!");
  86. }
  87. }
  88. /**
  89. * 生成目标责任书
  90. *
  91. * @param responsibilityIds 目标责任书ids
  92. * @return
  93. */
  94. //@ImsPreAuth("eval:deptResponsibility:edit")
  95. @PostMapping(value = "/generate")
  96. @ApiOperation(value = "生成部门责任书", notes = "生成部门责任书")
  97. public R generateResponsibility(@RequestParam(value = "responsibilityIds", required = true) String responsibilityIds) {
  98. try {
  99. List<String> orgEvalRuleIdList = Arrays.asList(responsibilityIds.split(","));
  100. boolean b = false;
  101. for (String id : orgEvalRuleIdList) {
  102. b = deptResponsibilityService.generateResponsibility(id);
  103. if (!b) {
  104. return R.error().data("保存失败!");
  105. }
  106. }
  107. return R.ok().data(b);
  108. } catch (CustomException e) {
  109. return R.customError(e.getMessage()).data("失败!");
  110. }
  111. }
  112. /**
  113. *
  114. * @param id 目标责任书id
  115. * @return
  116. */
  117. //@ImsPreAuth("eval:responsibilityIndicatorInfo:view")
  118. @GetMapping(value = "getByidAndInfo")
  119. public R planValueList(
  120. @RequestParam(value = "id", required = false) String id,
  121. @RequestParam(value = "dept", required = false) String dept) {
  122. DeptResponsibilityResDTO resDTO = deptResponsibilityService.getByidAndInfo(id, dept);
  123. return R.ok().data(resDTO);
  124. }
  125. /**
  126. * 批量删除
  127. *
  128. * @param ids
  129. * @return
  130. */
  131. //@ImsPreAuth("eval:deptResponsibility:remove")
  132. @PostMapping(value = "/remove/{ids}")
  133. @ApiOperation(value = "删除", notes = "删除")
  134. public R deleteAll(@PathVariable("ids") String ids) {
  135. try {
  136. String[] strings = ids.split(",");
  137. boolean b = deptResponsibilityService.removeByIds(Arrays.asList(strings));
  138. if (b) {
  139. return R.ok().data(b);
  140. } else {
  141. return R.error().data("删除失败!");
  142. }
  143. } catch (CustomException e) {
  144. return R.customError(e.getMessage()).data("失败!");
  145. }
  146. }
  147. @GetMapping(value = "targetValueeport")
  148. public R targetValueeport(
  149. @RequestParam(value = "id", required = false) String id,
  150. @RequestParam(value = "dept", required = false) String dept) {
  151. List<Map> list = deptResponsibilityService.targetValueeport(id, dept,request);
  152. return R.ok().data(list);
  153. }
  154. }