5ca9967d1c0df44bfef7f846ce30367bab211291.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. package cn.com.goldenwater.dcproj.controller.zhejiang;
  2. import cn.com.goldenwater.dcproj.constValue.PlanEnum;
  3. import cn.com.goldenwater.dcproj.constValue.SendState;
  4. import cn.com.goldenwater.dcproj.dto.DepartDto;
  5. import cn.com.goldenwater.dcproj.dto.GroupInfoDto;
  6. import cn.com.goldenwater.dcproj.model.*;
  7. import cn.com.goldenwater.dcproj.param.BisZhejiangCheckPlanParam;
  8. import cn.com.goldenwater.dcproj.param.BisZhejiangCheckProcessParam;
  9. import cn.com.goldenwater.dcproj.param.GwComFileParam;
  10. import cn.com.goldenwater.dcproj.service.*;
  11. import cn.com.goldenwater.core.web.BaseController;
  12. import cn.com.goldenwater.core.web.BaseResponse;
  13. import cn.com.goldenwater.dcproj.utils.InspPblmUtils;
  14. import cn.com.goldenwater.id.util.UuidUtil;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiOperation;
  17. import io.swagger.annotations.ApiParam;
  18. import org.apache.commons.lang3.StringUtils;
  19. import com.github.pagehelper.PageInfo;
  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.web.bind.annotation.PathVariable;
  24. import org.springframework.web.bind.annotation.RequestBody;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RequestMethod;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.util.ArrayList;
  30. import java.util.Date;
  31. import java.util.List;
  32. /**
  33. * @author lune
  34. * @date 2020-5-12
  35. */
  36. @Api(value = "BIS 浙江监督检查工作计划表管理", tags = "BIS 浙江监督检查工作计划表管理")
  37. @RestController
  38. @RequestMapping("/bis/zhejiang/check/plan")
  39. public class BisZhejiangCheckPlanController extends BaseController {
  40. private Logger logger = LoggerFactory.getLogger(getClass());
  41. @Autowired
  42. private BisZhejiangCheckPlanService bisZhejiangCheckPlanService;
  43. @Autowired
  44. private BisZhejiangCheckProcessService bisZhejiangCheckProcessService;
  45. @Autowired
  46. private BisInspAllRlationPersService bisInspAllRlationPersService;
  47. @Autowired
  48. private GwComFileService gwComFileService;
  49. @Autowired
  50. private BisInspAllService bisInspAllService;
  51. @Autowired
  52. private OlBisInspOrgService olBisInspOrgService;
  53. @Autowired
  54. private SupervisionPlanService supervisionPlanService;
  55. @ApiOperation(value = "添加/修改浙江监督检查工作计划表")
  56. @RequestMapping(value = "", method = RequestMethod.POST)
  57. public BaseResponse<BisZhejiangCheckPlan> insert(@ApiParam(name = "bisZhejiangCheckPlan", value = "BisZhejiangCheckPlan", required = true) @RequestBody BisZhejiangCheckPlan bisZhejiangCheckPlan) {
  58. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  59. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  60. bisZhejiangCheckPlan.setPersName(bisInspAllRlationPers.getPersName());
  61. bisZhejiangCheckPlan.setOrgId(getCurrentOrgId());
  62. bisZhejiangCheckPlan.setOrgName(olBisInspOrg.getOrgNm());
  63. bisZhejiangCheckPlan.setFileState("0");
  64. bisZhejiangCheckPlan.setUptm(new Date());
  65. if (StringUtils.isBlank(bisZhejiangCheckPlan.getId())) {
  66. String uuid = UuidUtil.uuid(); // 生成uuid
  67. bisZhejiangCheckPlan.setId(uuid);
  68. bisZhejiangCheckPlan.setIntm(new Date());
  69. bisZhejiangCheckPlan.setState(PlanEnum.PLAN_CHECK.getKey());
  70. bisZhejiangCheckPlan.setIsSend(SendState.SEND_NO.getKey());
  71. bisZhejiangCheckPlan.setPersId(getCurrentPersId());
  72. bisZhejiangCheckPlanService.insert(bisZhejiangCheckPlan);
  73. } else {
  74. if (PlanEnum.PLAN_SEND.getKey().equals(bisZhejiangCheckPlan.getState())) {
  75. bisZhejiangCheckPlan.setIsSend(SendState.SEND.getKey());
  76. }
  77. if (SendState.SEND.getKey().equals(bisZhejiangCheckPlan.getIsSend())) {
  78. bisZhejiangCheckPlan.setState(PlanEnum.PLAN_SEND.getKey());
  79. }
  80. if ("2".equals(bisZhejiangCheckPlan.getState())) {
  81. bisZhejiangCheckPlan.setState("1");
  82. }
  83. bisZhejiangCheckPlanService.update(bisZhejiangCheckPlan);
  84. }
  85. return buildSuccessResponse(bisZhejiangCheckPlan);
  86. }
  87. @ApiOperation(value = "工作方案上传状态维护")
  88. @RequestMapping(value = "/modify", method = RequestMethod.POST)
  89. public BaseResponse<BisZhejiangCheckPlan> modify(@ApiParam(name = "bisZhejiangCheckPlan", value = "BisZhejiangCheckPlan", required = true) @RequestBody BisZhejiangCheckPlan bisZhejiangCheckPlan) throws Exception {
  90. bisZhejiangCheckPlan.setFileState("0");
  91. if (bisZhejiangCheckPlan.getGwComFileList() != null && !bisZhejiangCheckPlan.getGwComFileList().isEmpty()) {
  92. for (GwComFile gwComFile : bisZhejiangCheckPlan.getGwComFileList()) {
  93. gwComFile.setBizId(bisZhejiangCheckPlan.getId());
  94. gwComFileService.update(gwComFile);
  95. }
  96. bisZhejiangCheckPlan = bisZhejiangCheckPlanService.get(bisZhejiangCheckPlan.getId());
  97. bisZhejiangCheckPlan.setFileState("1");
  98. GroupInfoDto groupInfoDto = new GroupInfoDto();
  99. groupInfoDto.setOrgId(getCurrentOrgId());
  100. groupInfoDto.setPtype(bisZhejiangCheckPlan.getInspType());
  101. groupInfoDto.setInspMnth(bisZhejiangCheckPlan.getMonth());
  102. groupInfoDto.setInspYear(bisZhejiangCheckPlan.getYear());
  103. groupInfoDto.setEntm(bisZhejiangCheckPlan.getCheckEndDate());
  104. groupInfoDto.setSttm(bisZhejiangCheckPlan.getCheckSttdDate());
  105. groupInfoDto.setName(bisZhejiangCheckPlan.getWokerNm());
  106. supervisionPlanService.insertGroupInfo(groupInfoDto);
  107. }
  108. bisZhejiangCheckPlanService.update(bisZhejiangCheckPlan);
  109. return buildSuccessResponse(bisZhejiangCheckPlan);
  110. }
  111. @ApiOperation(value = "根据ID删除浙江监督检查工作计划表")
  112. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  113. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  114. int ret = bisZhejiangCheckPlanService.delete(id);
  115. BisZhejiangCheckProcessParam bisZhejiangCheckProcess = new BisZhejiangCheckProcessParam();
  116. bisZhejiangCheckProcess.setPlanId(id);
  117. bisZhejiangCheckProcessService.deleteBy(bisZhejiangCheckProcess);
  118. return buildSuccessResponse();
  119. }
  120. @ApiOperation(value = "根据ID获取浙江监督检查工作方案表(单表,工作方案维护)")
  121. @RequestMapping(value = "/weihu/{id}", method = RequestMethod.GET)
  122. public BaseResponse<BisZhejiangCheckPlan> weihu(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  123. BisZhejiangCheckPlan bisZhejiangCheckPlan = bisZhejiangCheckPlanService.get(id);
  124. if (bisZhejiangCheckPlan != null && "1".equals(bisZhejiangCheckPlan.getFileState())) {
  125. GwComFileParam checkProcessParam = new GwComFileParam();
  126. checkProcessParam.setBizId(id);
  127. List<GwComFile> checkProcessList = gwComFileService.findList(checkProcessParam);
  128. if (checkProcessList == null) {
  129. checkProcessList = new ArrayList<>();
  130. }
  131. bisZhejiangCheckPlan.setGwComFileList(checkProcessList);
  132. }
  133. return buildSuccessResponse(bisZhejiangCheckPlan);
  134. }
  135. @ApiOperation(value = "根据ID获取浙江监督检查工作计划表(单表,包括审核流程)")
  136. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  137. public BaseResponse<BisZhejiangCheckPlan> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  138. BisZhejiangCheckPlan bisZhejiangCheckPlan = bisZhejiangCheckPlanService.get(id);
  139. if (bisZhejiangCheckPlan != null) {
  140. BisZhejiangCheckProcessParam checkProcessParam = new BisZhejiangCheckProcessParam();
  141. checkProcessParam.setPlanId(id);
  142. List<BisZhejiangCheckProcess> checkProcessList = bisZhejiangCheckProcessService.findList(checkProcessParam);
  143. if (checkProcessList == null) {
  144. checkProcessList = new ArrayList<>();
  145. }
  146. bisZhejiangCheckPlan.setCheckProcessList(checkProcessList);
  147. }
  148. return buildSuccessResponse(bisZhejiangCheckPlan);
  149. }
  150. @ApiOperation(value = "获取浙江监督检查工作计划表(列表所有)")
  151. @RequestMapping(value = "/list", method = RequestMethod.POST)
  152. public BaseResponse<List<BisZhejiangCheckPlan>> list(@ApiParam(name = "bisZhejiangCheckPlanParam", value = "bisZhejiangCheckPlanParam", required = true) @RequestBody BisZhejiangCheckPlanParam bisZhejiangCheckPlanParam) {
  153. List<BisZhejiangCheckPlan> bisZhejiangCheckPlanList = bisZhejiangCheckPlanService.findList(bisZhejiangCheckPlanParam);
  154. return buildSuccessResponse(bisZhejiangCheckPlanList);
  155. }
  156. @Autowired
  157. BisZhejiangCheckDepartService bisZhejiangCheckDepartService;
  158. @ApiOperation(value = "获取浙江监督检查工作计划表(列表--分页--检查计划)")
  159. @RequestMapping(value = "/pagePlan", method = RequestMethod.POST)
  160. public BaseResponse<PageInfo<BisZhejiangCheckPlan>> page(@ApiParam(name = "bisZhejiangCheckPlanParam", value = "bisZhejiangCheckPlanParam", required = true) @RequestBody BisZhejiangCheckPlanParam bisZhejiangCheckPlanParam) {
  161. DepartDto departDto = bisZhejiangCheckDepartService.getState(getCurrentPersId());
  162. PageInfo<BisZhejiangCheckPlan> bisZhejiangCheckPlanList = bisZhejiangCheckPlanService.findPageInfo(bisZhejiangCheckPlanParam);
  163. if (departDto != null) {
  164. for (BisZhejiangCheckPlan checkPlan : bisZhejiangCheckPlanList.getList()) {
  165. if (!"3".equals(checkPlan.getState())) {
  166. checkPlan.setIsCheck("0");
  167. checkPlan.setIsRect("0");
  168. if (departDto.getId().equals(checkPlan.getDepartId()) && "2".equals(checkPlan.getState())) {
  169. checkPlan.setIsRect("1");
  170. }
  171. if ("1".equals(departDto.getIsCheck()) && "1".equals(checkPlan.getState())) {
  172. checkPlan.setIsCheck("1");
  173. }
  174. }
  175. }
  176. }
  177. return buildSuccessResponse(bisZhejiangCheckPlanList);
  178. }
  179. @ApiOperation(value = "获取浙江监督检查工作计划表(列表--分页--工作方案)")
  180. @RequestMapping(value = "/pageFangan", method = RequestMethod.POST)
  181. public BaseResponse<PageInfo<BisZhejiangCheckPlan>> pageFangan(@ApiParam(name = "bisZhejiangCheckPlanParam", value = "bisZhejiangCheckPlanParam", required = true) @RequestBody BisZhejiangCheckPlanParam bisZhejiangCheckPlanParam) {
  182. bisZhejiangCheckPlanParam.setIsSend(PlanEnum.PLAN_SEND.getKey());
  183. bisZhejiangCheckPlanParam.setState(PlanEnum.PLAN_SEND.getKey());
  184. DepartDto departDto = bisZhejiangCheckDepartService.getState(getCurrentPersId());
  185. PageInfo<BisZhejiangCheckPlan> bisZhejiangCheckPlanList = bisZhejiangCheckPlanService.findPageInfo(bisZhejiangCheckPlanParam);
  186. for (BisZhejiangCheckPlan checkPlan : bisZhejiangCheckPlanList.getList()) {
  187. if (departDto == null) {
  188. checkPlan.setIsControl("0");
  189. } else {
  190. if (checkPlan.getDepartId().equals(departDto.getId())) {
  191. checkPlan.setIsControl("1");
  192. } else {
  193. checkPlan.setIsControl("0");
  194. }
  195. }
  196. }
  197. return buildSuccessResponse(bisZhejiangCheckPlanList);
  198. }
  199. @ApiOperation(value = "获取浙江监督检查工作计划表-导出excel")
  200. @RequestMapping(value = "/export", method = RequestMethod.POST)
  201. public void export(@ApiParam(name = "bisZhejiangCheckPlanParam", value = "bisZhejiangCheckPlanParam", required = true) @RequestBody BisZhejiangCheckPlanParam bisZhejiangCheckPlanParam,
  202. HttpServletResponse response) throws Exception {
  203. response.setContentType("application/binary;charset=UTF-8");
  204. String fileName = "监督检查工作计划";
  205. List<BisZhejiangCheckPlan> bisZhejiangCheckPlanList = bisZhejiangCheckPlanService.findList(bisZhejiangCheckPlanParam);
  206. InspPblmUtils.ExportWorkNew(response, bisZhejiangCheckPlanList, fileName);
  207. // ExcelUtil.sendExcel(bisZhejiangCheckPlanList,response,fileName);
  208. }
  209. }