c5d060e115ffc3f36daaef342087e864f1304138.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. package cn.com.goldenwater.dcproj.controller.tac;
  2. import cn.com.goldenwater.dcproj.constValue.*;
  3. import cn.com.goldenwater.dcproj.dao.GwSubProcessDao;
  4. import cn.com.goldenwater.dcproj.model.*;
  5. import cn.com.goldenwater.dcproj.param.GwSubProcessParam;
  6. import cn.com.goldenwater.dcproj.param.TacPawpRgstrParam;
  7. import cn.com.goldenwater.dcproj.param.TacWordBaseParam;
  8. import cn.com.goldenwater.dcproj.service.*;
  9. import cn.com.goldenwater.core.web.BaseController;
  10. import cn.com.goldenwater.core.web.BaseResponse;
  11. import cn.com.goldenwater.dcproj.utils.InspUtils;
  12. import cn.com.goldenwater.id.util.UuidUtil;
  13. import com.github.pagehelper.PageInfo;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import io.swagger.annotations.ApiParam;
  17. import org.apache.commons.lang3.StringUtils;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.web.bind.annotation.PathVariable;
  22. import org.springframework.web.bind.annotation.RequestBody;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestMethod;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import java.util.Date;
  27. import java.util.List;
  28. import java.util.Map;
  29. /**
  30. * @author lune
  31. * @date 2019-6-19
  32. */
  33. @Api(value = "TAC 专业稽察登记表管理", tags = "TAC 专业稽察登记表管理")
  34. @RestController
  35. @RequestMapping("/tac/pawp/rgstr")
  36. public class TacPawpRgstrController extends BaseController {
  37. private Logger logger = LoggerFactory.getLogger(getClass());
  38. @Autowired
  39. private TacPawpRgstrService tacPawpRgstrService;
  40. @Autowired
  41. private TacActiveLogService activeLogService;
  42. @Autowired
  43. private GwSubProcessDao gwSubProcessDao;
  44. @Autowired
  45. private TacWordBaseService tacWordBaseService;
  46. @ApiOperation(value = "添加/修改专业稽察登记表")
  47. @RequestMapping(value = "", method = RequestMethod.POST)
  48. public BaseResponse<TacPawpRgstr> insert(@ApiParam(name = "tacPawpRgstr", value = "TacPawpRgstr", required = true) @RequestBody TacPawpRgstr tacPawpRgstr) {
  49. if (StringUtils.isNotBlank(tacPawpRgstr.getId())) {
  50. tacPawpRgstr.setUptm(new Date());
  51. tacPawpRgstrService.update(tacPawpRgstr);
  52. } else {
  53. String uuid = UuidUtil.uuid();
  54. tacPawpRgstr.setId(uuid);
  55. tacPawpRgstr.setIntm(new Date());
  56. tacPawpRgstr.setState(StateEnum.NOWASTSTATE.getKey());
  57. tacPawpRgstrService.insert(tacPawpRgstr);
  58. activeLogService.addTacLog(tacPawpRgstr.getName(), StateEnum.EXWASTSTATE.getDesc(), uuid, "", StateEnum.EXWASTSTATE.getKey(),"", "", getCurrentPersId());
  59. }
  60. return buildSuccessResponse(tacPawpRgstr);
  61. }
  62. @ApiOperation(value = "根据ID删除专业稽察登记表")
  63. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  64. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  65. int ret = tacPawpRgstrService.delete(id);
  66. return buildSuccessResponse();
  67. }
  68. @ApiOperation(value = "退回底稿给专家")
  69. @RequestMapping(value = "/zhuli/rollback/{regstrId}/{type}", method = RequestMethod.GET)
  70. public BaseResponse rollback(
  71. @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId
  72. , @ApiParam(name = "type", value = "type", required = true) @PathVariable String type) {
  73. String key = regstrId + "_" + type + "_roll";
  74. synchronized (this) {
  75. if (!tacPawpRgstrService.suoding(key)) {
  76. return buildFailResponse("操作太频繁,请等会儿再操作");
  77. }
  78. }
  79. TacPawpRgstr pawpRgstr = tacPawpRgstrService.get(regstrId);
  80. String state = InspUtils.getTypeState(type, pawpRgstr);
  81. if (StringUtils.isBlank(state)) {
  82. return buildFailResponse("该状态数据不能回退");
  83. } else {
  84. int stateType = Integer.parseInt(state);
  85. if (stateType != 4) {
  86. return buildFailResponse("该状态数据不能回退");
  87. }
  88. }
  89. String regstrId_zhuli = pawpRgstr.getId() + "_" + state;
  90. if (!StateEnum.SUBMIT_ZHULI.getKey().equals(state)) {
  91. return buildFailResponse("退回底稿失败,该底稿不具备退回条件!");
  92. }
  93. String persId = "";
  94. pawpRgstr = tacPawpRgstrService.rollbackControl(regstrId_zhuli, persId, type, pawpRgstr, StateEnum.SUBMIT_ZHUANJIA.getKey());
  95. tacPawpRgstrService.update(pawpRgstr);
  96. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_ZHUANJIA.getDesc(), pawpRgstr.getId(), type, StateEnum.SUBMIT_ZHUANJIA.getKey(), "","退稿给专家", getCurrentPersId());
  97. return buildSuccessResponse("退回底稿完成!!");
  98. }
  99. @ApiOperation(value = "提交底稿给助理")
  100. @RequestMapping(value = "/zhuli/submit/{regstrId}/{type}", method = RequestMethod.GET)
  101. public BaseResponse zhuliSubmit(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId,
  102. @ApiParam(name = "type", value = "type", required = true) @PathVariable String type) {
  103. String persId = getCurrentPersId();
  104. String key = regstrId + "_" + type + "_submit";
  105. synchronized (this) {
  106. if (!tacPawpRgstrService.suoding(key)) {
  107. return buildFailResponse("操作太频繁,请等会儿再操作");
  108. }
  109. }
  110. TacPawpRgstr pawpRgstr = tacPawpRgstrService.get(regstrId);
  111. if (pawpRgstr == null) {
  112. return buildFailResponse("稽察督查表不存在!");
  113. }
  114. String state = InspUtils.getTypeState(type, pawpRgstr);
  115. if (StateEnum.SUBMIT_ZHULI.getKey().equals(state)) {
  116. return buildFailResponse("底稿信息已经提交,请不要重复提交!");
  117. }
  118. String regstrId_zhuli = "";
  119. if (regstrId.contains("_")) {
  120. regstrId_zhuli = regstrId.substring(0, regstrId.indexOf("_")) + "_4";
  121. } else {
  122. regstrId_zhuli = regstrId + "_4";
  123. }
  124. TacWordBaseParam wordBaseParam = new TacWordBaseParam();
  125. wordBaseParam.setType("10" + type);
  126. wordBaseParam.setBizId(regstrId_zhuli);
  127. List<TacWordBase> wordBaseList = tacWordBaseService.findList(wordBaseParam);
  128. if (wordBaseList != null && wordBaseList.size() > 0) {
  129. return buildFailResponse("底稿信息已经提交,请不要重复提交!");
  130. }
  131. pawpRgstr = tacPawpRgstrService.createZhuliData(persId, regstrId, type, pawpRgstr, regstrId_zhuli, StateEnum.SUBMIT_ZHULI.getKey());
  132. tacPawpRgstrService.update(pawpRgstr);
  133. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_ZHULI.getDesc(), pawpRgstr.getId(), type, StateEnum.SUBMIT_ZHULI.getKey(),"", "提交给助理", getCurrentPersId());
  134. return buildSuccessResponse("提交完成");
  135. }
  136. @ApiOperation(value = "专家提交底稿、助理提交报告;专家提交到助理(交换意见稿)-->成果讨论阶段(助理通过)-->中心修改阶段-->司局修改阶段:flag分别为:4,5,6,7")
  137. @RequestMapping(value = "/chengguo/submit/{regstrId}/{flag}", method = RequestMethod.GET)
  138. public BaseResponse chengguoSubmit(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId,
  139. @ApiParam(name = "flag", value = "flag", required = true) @PathVariable String flag) {
  140. String persId = getCurrentPersId();
  141. TacPawpRgstr pawpRgstr = tacPawpRgstrService.get(regstrId);
  142. if (pawpRgstr == null) {
  143. return buildFailResponse("稽察督查表不存在!");
  144. }
  145. if (StringUtils.isBlank(flag)) {
  146. return buildFailResponse("接口标识不能为空");
  147. }
  148. if (flag.equals(pawpRgstr.getState())) {
  149. return buildFailResponse("报告信息已经提交,请不要重复提交!");
  150. }
  151. GwSubProcessParam processParam=new GwSubProcessParam();
  152. processParam.setApp("tac");
  153. processParam.setLocalState(flag);
  154. GwSubProcess gwSubProcess=gwSubProcessDao.getBy(processParam);
  155. if(gwSubProcess==null ){
  156. return buildFailResponse("报告已经处于最终阶段不能继续提交!");
  157. }
  158. if(StringUtils.isNotBlank(pawpRgstr.getState())){
  159. if(!gwSubProcess.getPrvState().equals(pawpRgstr.getState()) && !"3".equals(pawpRgstr.getState())){
  160. return buildFailResponse("上一阶段数据未提交,请确认后再执行当前操作!");
  161. }
  162. }else{
  163. //未空默认刚提交
  164. if(!"4".equals(gwSubProcess.getPrvState())){
  165. return buildFailResponse("上一阶段数据未提交,请确认后再执行当前操作!");
  166. }
  167. }
  168. //上一阶段得标识
  169. String startRegstrId =regstrId+"_"+gwSubProcess.getPrvState();
  170. if (StringUtils.isBlank(flag)) {
  171. startRegstrId = regstrId;
  172. } else {
  173. int stateType = Integer.parseInt(flag);
  174. if (stateType < 3) {
  175. startRegstrId = regstrId;
  176. }
  177. }
  178. String regstrId_flag = "";
  179. if (regstrId.contains("_")) {
  180. regstrId_flag = regstrId.substring(0, regstrId.indexOf("_")) + "_" + flag;
  181. } else {
  182. regstrId_flag = regstrId + "_" + flag;
  183. }
  184. pawpRgstr = tacPawpRgstrService.createZhuliData(persId, startRegstrId, "", pawpRgstr, regstrId_flag, flag);
  185. // pawpRgstr=typeState(pawpRgstr,type,flag);
  186. tacPawpRgstrService.update(pawpRgstr);
  187. if (StateEnum.SUBMIT_ZHULI.getKey().equals(flag)) {
  188. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_ZHULI.getDesc(), pawpRgstr.getId(), "0", StateEnum.SUBMIT_ZHULI.getKey(),"", "专家到助理", getCurrentPersId());
  189. }
  190. if (StateEnum.SUBMIT_CHENGGUO.getKey().equals(flag)) {
  191. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_CHENGGUO.getDesc(), pawpRgstr.getId(), "0", StateEnum.SUBMIT_CHENGGUO.getKey(), "","成果到中心", getCurrentPersId());
  192. }
  193. if (StateEnum.SUBMIT_ZHONGXIN.getKey().equals(flag)) {
  194. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_ZHONGXIN.getDesc(), pawpRgstr.getId(), "0", StateEnum.SUBMIT_ZHONGXIN.getKey(),"", "中心到司局", getCurrentPersId());
  195. }
  196. if (StateEnum.SUBMIT_SIJU.getKey().equals(flag)) {
  197. activeLogService.addTacLog(pawpRgstr.getName(), StateEnum.SUBMIT_SIJU.getDesc(), pawpRgstr.getId(), "0", StateEnum.SUBMIT_SIJU.getKey(), "","司局通过", getCurrentPersId());
  198. }
  199. return buildSuccessResponse("提交完成");
  200. }
  201. @ApiOperation(value = "助理通过--助理提交到成果讨论阶段")
  202. @RequestMapping(value = "/excute/{regstrId}/{type}", method = RequestMethod.GET)
  203. public BaseResponse<TacPawpRgstr> excute(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId,
  204. @ApiParam(name = "type", value = "type", required = true) @PathVariable String type) {
  205. if (regstrId.contains(PersTypeEnum.ZHULI.getEnflag())) {
  206. regstrId = regstrId.substring(0, regstrId.indexOf("_") - 1);
  207. }
  208. TacPawpRgstr tacPawpRgstr = tacPawpRgstrService.get(regstrId);
  209. if (JinChaEnum.TACPAWPPDBST.getKey().equals(type)) {
  210. tacPawpRgstr.setPdbstStat(StateEnum.SUBMIT_ZHULI.getKey());
  211. }
  212. if (JinChaEnum.TacPawpBstocmTsopbfp.getKey().equals(type)) {
  213. tacPawpRgstr.setBstocmTsopbfpStat(StateEnum.SUBMIT_ZHULI.getKey());
  214. }
  215. if (JinChaEnum.TacPawpRaiobis.getKey().equals(type)) {
  216. tacPawpRgstr.setRaiobisStat(StateEnum.SUBMIT_ZHULI.getKey());
  217. }
  218. if (JinChaEnum.TacPawpBstocmCms.getKey().equals(type)) {
  219. tacPawpRgstr.setBstocmCmsStat(StateEnum.SUBMIT_ZHULI.getKey());
  220. }
  221. if (JinChaEnum.TacPawpBitopqPeqaa.getKey().equals(type)) {
  222. tacPawpRgstr.setBitopqPeqaaStat(StateEnum.SUBMIT_ZHULI.getKey());
  223. }
  224. if (JinChaEnum.TacPawpBioesRwunit.getKey().equals(type)) {
  225. tacPawpRgstr.setBioesRwunitStat(StateEnum.SUBMIT_ZHULI.getKey());
  226. }
  227. tacPawpRgstrService.update(tacPawpRgstr);
  228. return buildSuccessResponse(tacPawpRgstr);
  229. }
  230. private TacPawpRgstr typeState(TacPawpRgstr tacPawpRgstr, String type, String flag) {
  231. if (JinChaEnum.TACPAWPPDBST.getKey().equals(type)) {
  232. tacPawpRgstr.setPdbstStat(flag);
  233. }
  234. if (JinChaEnum.TacPawpBstocmTsopbfp.getKey().equals(type)) {
  235. tacPawpRgstr.setBstocmTsopbfpStat(flag);
  236. }
  237. if (JinChaEnum.TacPawpRaiobis.getKey().equals(type)) {
  238. tacPawpRgstr.setRaiobisStat(flag);
  239. }
  240. if (JinChaEnum.TacPawpBstocmCms.getKey().equals(type)) {
  241. tacPawpRgstr.setBstocmCmsStat(flag);
  242. }
  243. if (JinChaEnum.TacPawpBitopqPeqaa.getKey().equals(type)) {
  244. tacPawpRgstr.setBitopqPeqaaStat(flag);
  245. }
  246. if (JinChaEnum.TacPawpBioesRwunit.getKey().equals(type)) {
  247. tacPawpRgstr.setBioesRwunitStat(flag);
  248. }
  249. return tacPawpRgstr;
  250. }
  251. @ApiOperation(value = "根据ID获取专业稽察登记表(单表)")
  252. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  253. public BaseResponse<TacPawpRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  254. TacPawpRgstr tacPawpRgstr = tacPawpRgstrService.get(id);
  255. return buildSuccessResponse(tacPawpRgstr);
  256. }
  257. @ApiOperation(value = "根据登记表id和专业类型获取操作状态")
  258. @RequestMapping(value = "/getState/{regstrId}/{type}", method = RequestMethod.GET)
  259. public BaseResponse<Map<String, String>> getBy(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId,
  260. @ApiParam(name = "type", value = "type", required = true) @PathVariable String type) {
  261. // TacPawpRgstr tacPawpRgstr = tacPawpRgstrService.get(regstrId);
  262. // Map<String, String> retMap = new HashMap<>();
  263. // if (StringUtils.isNotBlank(tacPawpRgstr.getState())) {
  264. // int stateType = Integer.parseInt(tacPawpRgstr.getState());
  265. // if (stateType > 3) {
  266. // retMap.put("state", stateType + "");
  267. // return buildSuccessResponse(201, "助理提交状态", retMap);
  268. // }
  269. // }
  270. //
  271. // String state = InspUtils.getTypeState(type, tacPawpRgstr);
  272. // retMap.put("state", state);
  273. Map<String, String> statemap = tacPawpRgstrService.getState(regstrId, type);
  274. String state = statemap.get("state");
  275. if(StringUtils.isNotBlank(state)&&Integer.parseInt(state)>3) {
  276. return buildSuccessResponse(201, "助理提交状态", statemap);
  277. }
  278. return buildSuccessResponse(202, "专家提交状态",statemap);
  279. }
  280. @ApiOperation(value = "司局提交")
  281. @RequestMapping(value = "/siju/{regstrId}/{type}/{flag}", method = RequestMethod.GET)
  282. public BaseResponse siju(@ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId,
  283. @ApiParam(name = "type", value = "type", required = true) @PathVariable String type,
  284. @ApiParam(name = "flag", value = "flag", required = true) @PathVariable String flag) {
  285. TacPawpRgstr tacPawpRgstr = tacPawpRgstrService.get(regstrId);
  286. if (tacPawpRgstr == null) {
  287. return buildFailResponse("无登记信息记录");
  288. }
  289. String state = InspUtils.getTypeState(type, tacPawpRgstr);
  290. if (StringUtils.isBlank(state)) {
  291. return buildFailResponse("提交失败");
  292. }
  293. if (!StateEnum.SUBMIT_ZHONGXIN.getKey().equals(state)) {
  294. return buildFailResponse("当前阶段数据不能提交!!");
  295. }
  296. tacPawpRgstr = typeState(tacPawpRgstr, type, flag);
  297. tacPawpRgstrService.update(tacPawpRgstr);
  298. return buildSuccessResponse("司局提交完成");
  299. }
  300. @Autowired
  301. private BisInspAllRlationService allRlationService;
  302. @ApiOperation(value = "根据objId获取专业稽察登记表(单表)")
  303. @RequestMapping(value = "/getBy/{objId}", method = RequestMethod.GET)
  304. public BaseResponse<TacPawpRgstr> getByNew(@ApiParam(name = "objId", value = "objId", required = true) @PathVariable String objId) {
  305. TacPawpRgstrParam pawpRgstrParam = new TacPawpRgstrParam();
  306. pawpRgstrParam.setObjId(objId);
  307. TacPawpRgstr tacPawpRgstr = tacPawpRgstrService.getBy(pawpRgstrParam);
  308. String persId = getCurrentPersId();
  309. return buildSuccessResponse(tacPawpRgstr);
  310. }
  311. @ApiOperation(value = "分页查询稽察督查表")
  312. @RequestMapping(value = "/page", method = RequestMethod.POST)
  313. public BaseResponse<PageInfo<TacPawpRgstr>> page(@RequestBody TacPawpRgstrParam rgstrParam) {
  314. PageInfo<TacPawpRgstr> tacPawpRgstr = tacPawpRgstrService.findPageInfo(rgstrParam);
  315. return buildSuccessResponse(tacPawpRgstr);
  316. }
  317. }