FlowMainController.java 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. package com.idea.oa.flow2.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.idea.oa.activiti.service.ProActiService;
  4. import com.idea.oa.apply.model.ApplyAddWorkTimeExample;
  5. import com.idea.oa.apply.util.constant.ConstantFlowType;
  6. import com.idea.oa.apply.util.service.RunerLoadOneService;
  7. import com.idea.oa.flow2.model.FlowMain;
  8. import com.idea.oa.flow2.model.FlowMainLog;
  9. import com.idea.oa.flow2.model.FlowMainPush;
  10. import com.idea.oa.flow2.model.FlowMainPushExample;
  11. import com.idea.oa.flow2.model.in.FlowMainIn;
  12. import com.idea.oa.flow2.model.in.PushEntrust;
  13. import com.idea.oa.flow2.model.out.FlowHistoryInfo;
  14. import com.idea.oa.flow2.model.out.FlowMainPushOut;
  15. import com.idea.oa.flow2.model.out.IMGFlowHistoryInfo;
  16. import com.idea.oa.flow2.service.FlowMainLogService;
  17. import com.idea.oa.flow2.service.FlowMainPushService;
  18. import com.idea.oa.flow2.service.FlowMainService;
  19. import com.idea.oa.holidayManagement.model.HolidayManagement;
  20. import com.idea.oa.holidayManagement.service.HolidayManagementService;
  21. import com.rockstar.common.base.BaseController;
  22. import com.rockstar.common.domain.AjaxResult;
  23. import com.rockstar.flow.exception.FlowException;
  24. import com.rockstar.flow.model.FlowDefinition;
  25. import com.rockstar.flow.service.FlowDefinitionService;
  26. import com.rockstar.flow.service.FlowService;
  27. import com.rockstar.frame.model.extend.DateTrans;
  28. import com.rockstar.frame.model.extend.TableSplitResult;
  29. import com.rockstar.frame.model.extend.Tablepar;
  30. import com.rockstar.shiro.util.ShiroUtils;
  31. import com.rockstar.util.StringUtils;
  32. import com.rockstar.util.UUIDUtils;
  33. import io.swagger.annotations.Api;
  34. import org.activiti.bpmn.model.SequenceFlow;
  35. import org.activiti.bpmn.model.UserTask;
  36. import org.springframework.beans.factory.annotation.Autowired;
  37. import org.springframework.stereotype.Controller;
  38. import org.springframework.web.bind.annotation.PathVariable;
  39. import org.springframework.web.bind.annotation.PostMapping;
  40. import org.springframework.web.bind.annotation.RequestMapping;
  41. import org.springframework.web.bind.annotation.ResponseBody;
  42. import java.math.BigDecimal;
  43. import java.math.MathContext;
  44. import java.util.Date;
  45. import java.util.List;
  46. /**
  47. * Created by zt
  48. */
  49. @Controller
  50. @RequestMapping(value = "FlowMainController")
  51. @Api(value = "申请流程/主表_主申请审核表")
  52. public class FlowMainController extends BaseController {
  53. @Autowired
  54. private HolidayManagementService holidayManagementService;
  55. // @Autowired
  56. // private ApplyAddWorkTimeService applyAddWorkTimeService;
  57. //上面是业务中的信息,嵌入的业务信息了,以后可以考虑搬离
  58. @Autowired
  59. private RunerLoadOneService runerLoadOneService;
  60. @Autowired
  61. private FlowDefinitionService flowDefinitionService;
  62. @Autowired
  63. private FlowMainLogService flowMainLogService;
  64. @Autowired
  65. private ProActiService proActiService;
  66. //主表
  67. @Autowired
  68. private FlowMainService modelService;
  69. @Autowired
  70. private FlowMainPushService flowMainPushService;
  71. @Autowired
  72. private FlowService flowService;
  73. // @Autowired
  74. // private OutOrderMainService outOrderMainService;
  75. // @Autowired
  76. // private OutOrderPayService outOrderPayService;
  77. /**
  78. * 通过flowMainId获取审核流程信息
  79. * 2023年5月5日
  80. * 先判断流程是否结束,如果没有计算就进行
  81. * <p>
  82. * 作废==>增加获取本次申请的全部流程信息
  83. * 改成:后续节点名称、处理人应该可以带出来,如果还没有审则审核结果显示为“处理中”,审核时间为空
  84. *
  85. * @param flowMainId
  86. * @return
  87. */
  88. @PostMapping(value = "getFlowHistroyByFlowMainId", produces = {"application/json;charset=UTF-8"})
  89. @ResponseBody
  90. public List<FlowHistoryInfo> getFlowHistroyByFlowMainId(String flowMainId) {
  91. return modelService.getFlowHistroyByFlowMainId(flowMainId);
  92. }
  93. /**
  94. * 通过流程id获取流程当前所在节点和其他节点对应的状态
  95. *
  96. * @param flowMainId
  97. * @return
  98. */
  99. @PostMapping(value = "getIMGFlowHistroyByFlowMainId", produces = {"application/json;charset=UTF-8"})
  100. @ResponseBody
  101. public List<IMGFlowHistoryInfo> getIMGFlowHistroyByFlowMainId(String flowMainId) {
  102. return modelService.getIMGFlowHistroyByFlowMainId(flowMainId);
  103. }
  104. /**
  105. * 根据推送表的FlowMainPushId获取下一条线路怎么走,是返回上个节点还是返回申请人还是执行下个节点
  106. *
  107. * @param flowMainPushId
  108. * @return
  109. */
  110. @PostMapping(value = "getOutgoingFlowsByFlowMainPushId", produces = {"application/json;charset=UTF-8"})
  111. @ResponseBody
  112. public List<SequenceFlow> getOutgoingFlowsByFlowMainPushId(String flowMainPushId) {
  113. FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(flowMainPushId);
  114. // List<Object> nextCandidateGroupByDeploy = flowService.getNextCandidateGroupByDeploy(ConstantFlowType.USE_MONEY_DEPLOYMENTID, flowMainPush.getTaskId(), false);
  115. UserTask userTaskByTaskId = proActiService.getUserTaskByTaskId(flowMainPush.getTaskId());
  116. List<SequenceFlow> outgoingFlows = userTaskByTaskId.getOutgoingFlows();
  117. // List<UserTask> userTasks = flowService.nextTasks(flowMainPush.getTaskId(), false);
  118. return outgoingFlows;
  119. }
  120. /**
  121. * 申请人撤回申请
  122. * 申请人撤回申请
  123. *
  124. * @param flowMainid
  125. * @return
  126. */
  127. @PostMapping(value = "recallApply", produces = {"application/json;charset=UTF-8"})
  128. @ResponseBody
  129. public AjaxResult recallApply(String flowMainid) {
  130. return modelService.recallApply(flowMainid);
  131. // if (StringUtils.isEmpty(flowMainid)) {
  132. // return AjaxResult.error("数据不能为空");
  133. // }
  134. // FlowMain flowMain = modelService.selectByPrimaryKey(flowMainid);
  135. // //流转状态为审核中时,可以由发起人撤回。ok
  136. // if (!flowMain.getFlowStatus().equals(1)){
  137. // return AjaxResult.error("流程状态不在审核中,请重新确认");
  138. // }
  139. // {//开始申请人撤回申请
  140. // //1.关闭所有推送人数据信息表 ok
  141. // {
  142. // flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(),flowMain.getId());
  143. // }
  144. // //2.关闭主流程 ok
  145. // {// 发起流程引擎操作 并结束该流程
  146. //
  147. // try {
  148. // flowService.deleteInstance(flowMain.getFlowId(), "申请人撤回申请_结束流程");
  149. // } catch (Exception e) {
  150. // System.err.println("流程引擎异常");
  151. // e.printStackTrace();
  152. //// throw new RuntimeException(e);
  153. // }
  154. // }
  155. // //3.关闭主流程表 ok
  156. // //存入流程日志表的id
  157. // String flowMainLogUuid = UUIDUtils.middleUUID();
  158. // {
  159. // FlowMain flowMain1 = new FlowMain();
  160. // flowMain1.setId(flowMain.getId());
  161. // flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  162. // flowMain1.setLastMainLogId(flowMainLogUuid);
  163. // flowMain1.setUpdatedAt(new Date());
  164. // flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
  165. // modelService.updateByPrimaryKeySelective(flowMain1);
  166. // }
  167. // //4 添加日志表
  168. // FlowMainLog flowMainLog = new FlowMainLog();
  169. // {//其表单对应的流转历史该节点审核结果显示为”发起人撤回”
  170. //// flowMainLogUuid
  171. // flowMainLog.setId(flowMainLogUuid);
  172. // flowMainLog.setFlowMainId(flowMain.getId());
  173. // flowMainLog.setFormId(flowMain.getFormId());
  174. // flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
  175. // flowMainLog.setAuditContent(null);
  176. // flowMainLog.setAuditResult(null);
  177. // //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  178. // flowMainLog.setAuditType("4");
  179. // flowMainLog.setFlowType(flowMain.getFlowType());
  180. // flowMainLog.setFlowPost(ShiroUtils.getUser().getId());
  181. // {// 需要工作流引擎的支持
  182. // flowMainLog.setFlowId(flowMain.getFlowId());
  183. // flowMainLog.setTaskId(null);
  184. // flowMainLog.setNodeName("发起人撤回");
  185. // }
  186. //// 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  187. //// 因为感觉用不到,暂时不放进去
  188. //// flowMainLog.setNextPersons();
  189. // flowMainLog.setUpMainLogId(flowMain.getLastMainLogId());
  190. // flowMainLog.setCcList(null);
  191. // flowMainLog.setCreatedAt(new Date());
  192. // flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  193. // flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  194. // flowMainLog.setStatus(0);
  195. // flowMainLogService.insertWithoutId(flowMainLog);
  196. // }
  197. // }
  198. // return result(1);
  199. }
  200. /**
  201. * 流程监控室 撤回申请
  202. * 申请人撤回申请
  203. *
  204. * @param flowMainid
  205. * @return
  206. */
  207. @PostMapping(value = "topRecallApply", produces = {"application/json;charset=UTF-8"})
  208. @ResponseBody
  209. public AjaxResult topRecallApply(String flowMainid) {
  210. {//用的就是 return modelService.recallApply(flowMainid);的方法,就是 flowMainLog.setFlowPost(null);改了和flowMainLog.setRemark 和flowMain1.setRemark
  211. {
  212. if (StringUtils.isEmpty(flowMainid)) {
  213. return AjaxResult.error("数据不能为空");
  214. }
  215. FlowMain flowMain = modelService.selectByPrimaryKey(flowMainid);
  216. //流转状态为审核中时,可以由发起人撤回。ok
  217. if (!flowMain.getFlowStatus().equals(1)) {
  218. return AjaxResult.error("流程状态不在审核中,请重新确认");
  219. }
  220. String mypushUserKey = null;
  221. {//开始申请人撤回申请
  222. //先搜索目前有哪些人在审核中 ,获取key
  223. // select * from flow_main_push WHERE flow_main_push.flow_main_id=#{flowMainId} and STATUS=0
  224. FlowMainPushExample example = new FlowMainPushExample();
  225. example.createCriteria().andFlowMainIdEqualTo(flowMain.getId()).andStatusEqualTo(0);
  226. List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(example);
  227. mypushUserKey = flowMainPushes.get(0).getPushUserKey();
  228. //1.关闭所有推送人数据信息表 ok
  229. {
  230. flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(), flowMain.getId());
  231. }
  232. //2.关闭主流程 ok
  233. {// 发起流程引擎操作 并结束该流程
  234. try {
  235. flowService.deleteInstance(flowMain.getFlowId(), "流程监控室撤回申请_结束流程");
  236. } catch (Exception e) {
  237. System.err.println("流程引擎异常");
  238. e.printStackTrace();
  239. // throw new RuntimeException(e);
  240. }
  241. }
  242. //3.关闭主流程表 ok
  243. //存入流程日志表的id
  244. String flowMainLogUuid = UUIDUtils.middleUUID();
  245. {
  246. FlowMain flowMain1 = new FlowMain();
  247. flowMain1.setId(flowMain.getId());
  248. flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  249. flowMain1.setLastMainLogId(flowMainLogUuid);
  250. flowMain1.setUpdatedAt(new Date());
  251. flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
  252. flowMain1.setRemark(flowMain.getRemark() == null ? "" : (flowMain.getRemark() + ",") + "流程监控室撤回申请");
  253. modelService.updateByPrimaryKeySelective(flowMain1);
  254. }
  255. //4 添加日志表
  256. FlowMainLog flowMainLog = new FlowMainLog();
  257. {//其表单对应的流转历史该节点审核结果显示为”发起人撤回”
  258. // flowMainLogUuid
  259. flowMainLog.setId(flowMainLogUuid);
  260. flowMainLog.setFlowMainId(flowMain.getId());
  261. flowMainLog.setFormId(flowMain.getFormId());
  262. flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
  263. flowMainLog.setAuditContent(null);
  264. flowMainLog.setAuditResult(null);
  265. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态,5监控室结束状态(撤回状态)
  266. flowMainLog.setAuditType("5");
  267. flowMainLog.setFlowType(flowMain.getFlowType());
  268. flowMainLog.setFlowPost(null);//当前流程邮递操作人(frame_user)id 去除岗位的设定 因为已经撤回了,所以不知道传什么
  269. {// 需要工作流引擎的支持
  270. flowMainLog.setFlowId(flowMain.getFlowId());
  271. flowMainLog.setTaskId(null);
  272. flowMainLog.setNodeName("流程监控室_撤回");
  273. flowMainLog.setPushUserKey(mypushUserKey);//发起人撤回时 当时的审核人所对应的角色
  274. }
  275. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  276. // 因为感觉用不到,暂时不放进去
  277. // flowMainLog.setNextPersons();
  278. flowMainLog.setUpMainLogId(flowMain.getLastMainLogId());
  279. flowMainLog.setCcList(null);
  280. flowMainLog.setCreatedAt(new Date());
  281. flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  282. flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  283. flowMainLog.setStatus(0);
  284. flowMainLog.setRemark("流程监控室撤回申请");
  285. flowMainLogService.insertWithoutId(flowMainLog);
  286. }
  287. }
  288. return AjaxResult.success();
  289. }
  290. }
  291. }
  292. /**
  293. * 流程监控室 委托办理
  294. *
  295. * @param entity
  296. * @return
  297. */
  298. @PostMapping(value = "topEntrustOperate", produces = {"application/json;charset=UTF-8"})
  299. @ResponseBody
  300. public AjaxResult topEntrustOperate(PushEntrust entity) {
  301. if (StringUtils.isEmpty(entity.getFlowMainPushId())) {
  302. return AjaxResult.error("flowMainPushId数据不能为空");
  303. }
  304. if (StringUtils.isEmpty(entity.getPushEntrustId())) {
  305. return AjaxResult.error("PushEntrustId数据不能为空");
  306. }
  307. {// 进行委托
  308. // 获取推送数据
  309. FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(entity.getFlowMainPushId());
  310. //1.0 判断推送人数据是否修改//1推送人数据修改成逻辑删除
  311. {
  312. if (!flowMainPush.getStatus().equals(0)) {
  313. if (flowMainPush.getStatus().equals(1)) {
  314. return AjaxResult.error("已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认");
  315. } else if (flowMainPush.getStatus().equals(2)) {
  316. return AjaxResult.error("已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认");
  317. }
  318. }
  319. {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突
  320. FlowMainPush updateFlowMainPush = new FlowMainPush();
  321. updateFlowMainPush.setId(flowMainPush.getId());
  322. updateFlowMainPush.setStatus(1);
  323. updateFlowMainPush.setUpdatedAt(new Date());
  324. updateFlowMainPush.setUpdatedBy(ShiroUtils.getUser().getId());
  325. flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  326. }
  327. }
  328. //2 添加日志
  329. FlowMainLog flowMainLog = new FlowMainLog();
  330. {
  331. //当前任务流程 目的是获取节点名称,存起来nodeName
  332. String nodeName = proActiService.getNodeName(flowMainPush);
  333. if (nodeName == null) {
  334. return AjaxResult.error("异常:没有找到对应的任务...请通知管理员");
  335. }
  336. {
  337. //存入流程日志表的id
  338. String flowMainLogUuid = UUIDUtils.middleUUID();
  339. flowMainLog.setId(flowMainLogUuid);
  340. flowMainLog.setFlowMainId(flowMainPush.getFlowMainId());
  341. flowMainLog.setFormId(flowMainPush.getFormId());
  342. flowMainLog.setAuditUser(
  343. ShiroUtils.getUser().getId()
  344. );//xxxx审批人id
  345. flowMainLog.setAuditContent("委托他人审核");
  346. flowMainLog.setAuditResult("4");
  347. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  348. flowMainLog.setAuditType("1");
  349. flowMainLog.setFlowType(flowMainPush.getFlowType());
  350. flowMainLog.setFlowPost(
  351. flowMainPush.getFlowPost()
  352. );//xxxx当前流程邮递操作人(frame_user)id 去除岗位的设定
  353. {// 需要工作流引擎的支持
  354. flowMainLog.setFlowId(flowMainPush.getFlowId());
  355. flowMainLog.setTaskId(flowMainPush.getTaskId());
  356. flowMainLog.setNodeName(nodeName + "_流程监控室委托他人审核");
  357. flowMainLog.setPushUserKey(flowMainPush.getPushUserKey());
  358. }
  359. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  360. // 因为感觉用不到,暂时不放进去
  361. // flowMainLog.setNextPersons();
  362. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  363. flowMainLog.setCcList(null);
  364. flowMainLog.setCreatedAt(new Date());
  365. flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  366. flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  367. flowMainLog.setStatus(0);
  368. flowMainLog.setRemark("流程监控委托操作");
  369. flowMainLogService.insertWithoutId(flowMainLog);
  370. }
  371. }
  372. //3 添加新的推送人数据
  373. {
  374. FlowMainPush newflowMainPush = new FlowMainPush();
  375. newflowMainPush.setFlowMainId(flowMainPush.getFlowMainId());
  376. newflowMainPush.setFormId(flowMainPush.getFormId());
  377. {// 需要工作流引擎的支持
  378. newflowMainPush.setPushUser(entity.getPushEntrustId());//推送人id'
  379. newflowMainPush.setPushUserKey(flowMainPush.getPushUserKey());//推送时彭总给的key值
  380. newflowMainPush.setNodeName(flowMainPush.getNodeName() + "_流程监控室委托审核");
  381. newflowMainPush.setPushType(flowMainPush.getPushType());//推送类型1单流程推送,2串联推送,3并联推送
  382. newflowMainPush.setPushRole(2);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  383. newflowMainPush.setFlowType(flowMainPush.getFlowType());
  384. newflowMainPush.setFlowPost(flowMainPush.getFlowPost());
  385. newflowMainPush.setFlowId(flowMainPush.getFlowId());
  386. newflowMainPush.setTaskId(flowMainPush.getTaskId());
  387. }
  388. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  389. newflowMainPush.setUpdatedAt(new Date());
  390. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  391. newflowMainPush.setCreatedBy(ShiroUtils.getUser().getId());
  392. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  393. newflowMainPush.setGroupId(ShiroUtils.getUser().getGroupId());
  394. newflowMainPush.setStatus(0);
  395. newflowMainPush.setRemark("流程监控委托操作");
  396. flowMainPushService.insert(newflowMainPush);
  397. }
  398. }
  399. return result(1);
  400. }
  401. /**
  402. * 委托办理
  403. *
  404. * @param entity
  405. * @return
  406. */
  407. @PostMapping(value = "entrustOperate", produces = {"application/json;charset=UTF-8"})
  408. @ResponseBody
  409. public AjaxResult entrustOperate(PushEntrust entity) {
  410. if (StringUtils.isEmpty(entity.getFlowMainPushId())) {
  411. return AjaxResult.error("FlowMainPushid数据不能为空");
  412. }
  413. if (StringUtils.isEmpty(entity.getPushEntrustId())) {
  414. return AjaxResult.error("PushEntrustId数据不能为空");
  415. }
  416. {// 进行委托
  417. // 获取推送数据
  418. FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(entity.getFlowMainPushId());
  419. //1.0 判断推送人数据是否修改//1推送人数据修改成逻辑删除
  420. {
  421. if (!flowMainPush.getStatus().equals(0)) {
  422. if (flowMainPush.getStatus().equals(1)) {
  423. return AjaxResult.error("已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认");
  424. } else if (flowMainPush.getStatus().equals(2)) {
  425. return AjaxResult.error("已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认");
  426. }
  427. }
  428. {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突
  429. FlowMainPush updateFlowMainPush = new FlowMainPush();
  430. updateFlowMainPush.setId(flowMainPush.getId());
  431. updateFlowMainPush.setStatus(1);
  432. updateFlowMainPush.setUpdatedAt(new Date());
  433. updateFlowMainPush.setUpdatedBy(ShiroUtils.getUser().getId());
  434. flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  435. }
  436. }
  437. //2 添加日志
  438. FlowMainLog flowMainLog = new FlowMainLog();
  439. {
  440. //当前任务流程 目的是获取节点名称,存起来nodeName
  441. String nodeName = proActiService.getNodeName(flowMainPush);
  442. if (nodeName == null) {
  443. return AjaxResult.error("异常:没有找到对应的任务...请通知管理员");
  444. }
  445. {
  446. //存入流程日志表的id
  447. String flowMainLogUuid = UUIDUtils.middleUUID();
  448. flowMainLog.setId(flowMainLogUuid);
  449. flowMainLog.setFlowMainId(flowMainPush.getFlowMainId());
  450. flowMainLog.setFormId(flowMainPush.getFormId());
  451. flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
  452. flowMainLog.setAuditContent("委托他人审核");
  453. flowMainLog.setAuditResult("4");
  454. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  455. flowMainLog.setAuditType("1");
  456. flowMainLog.setFlowType(flowMainPush.getFlowType());
  457. flowMainLog.setFlowPost(ShiroUtils.getUser().getId());
  458. {// 需要工作流引擎的支持
  459. flowMainLog.setFlowId(flowMainPush.getFlowId());
  460. flowMainLog.setTaskId(flowMainPush.getTaskId());
  461. flowMainLog.setNodeName(nodeName + "_委托他人审核");
  462. flowMainLog.setPushUserKey(flowMainPush.getPushUserKey());
  463. }
  464. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  465. // 因为感觉用不到,暂时不放进去
  466. // flowMainLog.setNextPersons();
  467. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  468. flowMainLog.setCcList(null);
  469. flowMainLog.setCreatedAt(new Date());
  470. flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  471. flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  472. flowMainLog.setStatus(0);
  473. flowMainLogService.insertWithoutId(flowMainLog);
  474. }
  475. }
  476. //3 添加新的推送人数据
  477. {
  478. FlowMainPush newflowMainPush = new FlowMainPush();
  479. newflowMainPush.setFlowMainId(flowMainPush.getFlowMainId());
  480. newflowMainPush.setFormId(flowMainPush.getFormId());
  481. {// 需要工作流引擎的支持
  482. newflowMainPush.setPushUser(entity.getPushEntrustId());//推送人id'
  483. newflowMainPush.setPushUserKey(flowMainPush.getPushUserKey());//推送时彭总给的key值
  484. newflowMainPush.setNodeName(flowMainPush.getNodeName() + "_委托审核");
  485. newflowMainPush.setPushType(flowMainPush.getPushType());//推送类型1单流程推送,2串联推送,3并联推送
  486. newflowMainPush.setPushRole(2);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  487. newflowMainPush.setFlowType(flowMainPush.getFlowType());
  488. newflowMainPush.setFlowPost(flowMainPush.getFlowPost());
  489. newflowMainPush.setFlowId(flowMainPush.getFlowId());
  490. newflowMainPush.setTaskId(flowMainPush.getTaskId());
  491. }
  492. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  493. newflowMainPush.setUpdatedAt(new Date());
  494. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  495. newflowMainPush.setCreatedBy(ShiroUtils.getUser().getId());
  496. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  497. newflowMainPush.setGroupId(ShiroUtils.getUser().getGroupId());
  498. newflowMainPush.setStatus(0);
  499. flowMainPushService.insert(newflowMainPush);
  500. }
  501. }
  502. return result(1);
  503. }
  504. //=====下面是查询=============================================================================================
  505. /**
  506. * 流程监控的查询 根据flowmainid获取当前审核人的信息
  507. */
  508. @PostMapping(value = "findPushInfoByFlowMainId", produces = {"application/json;charset=UTF-8"})
  509. @ResponseBody
  510. public List<FlowMainPushOut> findPushInfoByFlowMainId(String flowMainid) {
  511. List<FlowMainPushOut> flowMainPushOutlist = flowMainPushService.findPushInfoByFlowMainId(flowMainid);
  512. return flowMainPushOutlist;//AjaxResult.success(flowMainPushOutlist);
  513. }
  514. //======================================================================================================
  515. /**
  516. * 流程监控的查询
  517. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  518. *
  519. * @param tablepar
  520. * @param model
  521. * @param dt
  522. * @return
  523. */
  524. @PostMapping(value = "applylistByInfo", produces = {"application/json;charset=UTF-8"})
  525. @ResponseBody
  526. public Object applylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  527. PageInfo<FlowMainIn> page = modelService.myApplylistByInfo(tablepar, model, dt);
  528. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  529. return result;
  530. }
  531. /**
  532. * 已办事项 ok
  533. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  534. * <p>
  535. * applyUserName 申请人名称
  536. * applyTheme 主题名称
  537. * flowName 流程名称
  538. *
  539. * @param tablepar
  540. * @param model
  541. * @param dt
  542. * @return
  543. */
  544. @PostMapping(value = "hasDolistByInfo", produces = {"application/json;charset=UTF-8"})
  545. @ResponseBody
  546. public Object hasDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  547. PageInfo<FlowMainIn> page = modelService.hasDolistByInfo(tablepar, model, dt);
  548. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  549. return result;
  550. }
  551. /**
  552. * 待办事项和委托代办事项
  553. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  554. *
  555. * @param tablepar
  556. * @param model
  557. * @param dt
  558. * @return
  559. */
  560. @PostMapping(value = "toDolisAndEntrusttByInfo", produces = {"application/json;charset=UTF-8"})
  561. @ResponseBody
  562. public Object toDolisAndEntrusttByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  563. PageInfo<FlowMainIn> page = modelService.toDolisAndEntrusttByInfo(tablepar, model, dt);
  564. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  565. return result;
  566. }
  567. /**
  568. * 待办事项和委托代办事项(统计总数量)
  569. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  570. *
  571. * @param model
  572. * @param dt
  573. * @return
  574. */
  575. @PostMapping(value = "numtoDolisAndEntrusttByInfo", produces = {"application/json;charset=UTF-8"})
  576. @ResponseBody
  577. public AjaxResult numtoDolisAndEntrusttByInfo(FlowMainIn model, DateTrans dt) {
  578. Integer num = modelService.numtoDolisAndEntrusttByInfo(model, dt);
  579. return AjaxResult.success(num);
  580. }
  581. /**
  582. * 待办事项
  583. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  584. *
  585. * @param tablepar
  586. * @param model
  587. * @param dt
  588. * @return
  589. */
  590. @PostMapping(value = "toDolistByInfo", produces = {"application/json;charset=UTF-8"})
  591. @ResponseBody
  592. public Object toDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  593. PageInfo<FlowMainIn> page = modelService.toDolistByInfo(tablepar, model, dt);
  594. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  595. return result;
  596. }
  597. /**
  598. * 待办事项(统计总数量)
  599. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  600. *
  601. * @param model
  602. * @param dt
  603. * @return
  604. */
  605. @PostMapping(value = "numtoDolistByInfo", produces = {"application/json;charset=UTF-8"})
  606. @ResponseBody
  607. public AjaxResult numtoDolistByInfo(FlowMainIn model, DateTrans dt) {
  608. Integer num = modelService.numtoDolistByInfo(model, dt);
  609. return AjaxResult.success(num);
  610. }
  611. /**
  612. * 我的申请 ok
  613. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  614. *
  615. * @param tablepar
  616. * @param model
  617. * @param dt
  618. * @return
  619. */
  620. @PostMapping(value = "myApplylistByInfo", produces = {"application/json;charset=UTF-8"})
  621. @ResponseBody
  622. public Object myApplylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  623. PageInfo<FlowMainIn> page = modelService.myApplylistByInfo(tablepar, model, dt);
  624. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  625. return result;
  626. }
  627. /**
  628. * 抄送事项 ok
  629. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  630. *
  631. * @param tablepar
  632. * @param model
  633. * @param dt
  634. * @return
  635. */
  636. @PostMapping(value = "cclistByInfo", produces = {"application/json;charset=UTF-8"})
  637. @ResponseBody
  638. public Object cclistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  639. PageInfo<FlowMainIn> page = modelService.cclistByInfo(tablepar, model, dt);
  640. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  641. return result;
  642. }
  643. /**
  644. * 委托代办事项
  645. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  646. *
  647. * @param tablepar
  648. * @param model
  649. * @param dt
  650. * @return
  651. */
  652. @PostMapping(value = "entrustToDolistByInfo", produces = {"application/json;charset=UTF-8"})
  653. @ResponseBody
  654. public Object entrustToDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  655. PageInfo<FlowMainIn> page = modelService.entrustToDolistByInfo(tablepar, model, dt);
  656. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  657. return result;
  658. }
  659. /**
  660. * 我的委托 ok
  661. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  662. *
  663. * @param tablepar
  664. * @param model
  665. * @param dt
  666. * @return
  667. */
  668. @PostMapping(value = "myEntrustlistByInfo", produces = {"application/json;charset=UTF-8"})
  669. @ResponseBody
  670. public Object myEntrustlistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  671. PageInfo<FlowMainIn> page = modelService.myEntrustlistByInfo(tablepar, model, dt);
  672. TableSplitResult<FlowMainIn> result = new TableSplitResult<FlowMainIn>(page.getPageNum(), page.getTotal(), page.getList());
  673. return result;
  674. }
  675. //===============================================================================================================
  676. @PostMapping(value = "list", produces = {"application/json;charset=UTF-8"})
  677. @ResponseBody
  678. public Object list(Tablepar tablepar, FlowMain model, DateTrans dt) {
  679. PageInfo<FlowMain> page = modelService.list(tablepar, model, dt);
  680. TableSplitResult<FlowMain> result = new TableSplitResult<FlowMain>(page.getPageNum(), page.getTotal(), page.getList());
  681. return result;
  682. }
  683. @PostMapping(value = "listAll", produces = {"application/json;charset=UTF-8"})
  684. @ResponseBody
  685. public Object listAll(FlowMain model, DateTrans dt) {
  686. return modelService.listAll(model, dt);
  687. }
  688. // @PostMapping(value = "add", produces = {"application/json;charset=UTF-8"})
  689. // @ResponseBody
  690. // public AjaxResult add(FlowMain record) {
  691. // record.setCreatedAt(new Date());
  692. // int result = modelService.insert(record);
  693. // return result(result);
  694. // }
  695. /**
  696. * 流程监控_进行删除操作
  697. *
  698. * @param id
  699. * @return
  700. */
  701. @PostMapping(value = "remove/{id}", produces = {"application/json;charset=UTF-8"})
  702. @ResponseBody
  703. public AjaxResult remove(@PathVariable("id") String id) {
  704. // int result = modelService.deleteByPrimaryKey(id);
  705. FlowMain flowMain = modelService.selectByPrimaryKey(id);
  706. if (flowMain.getFlowStatus().equals(1)) {
  707. return AjaxResult.error("还在审批中不能进行删除");
  708. }
  709. if (flowMain.getFlowStatus().equals(3)) {//流程结束了进行操作
  710. //判断最后的操作是否同意,如果同意就进行回滚
  711. //如果是加班,还要看调休时间是否足够回滚,如果够回滚就返回不能删除
  712. FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMain.getLastMainLogId());
  713. if (flowMainLog.getAuditResult().equals("1")) {//最后的操作是同意操作
  714. if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
  715. //加班进行回滚
  716. ApplyAddWorkTimeExample example = new ApplyAddWorkTimeExample();
  717. example.createCriteria().andAddWorkIdEqualTo(flowMain.getFormId());
  718. // List<ApplyAddWorkTime> applyOffWorkTimeList = applyAddWorkTimeService.selectByExample(example);
  719. //获取所有的加班时间
  720. BigDecimal totaluseTime = new BigDecimal(0);
  721. //2========================================================
  722. { //获取总共加班时间
  723. // for (ApplyAddWorkTime applyAddWorkTime : applyOffWorkTimeList) {
  724. // totaluseTime = totaluseTime.add(applyAddWorkTime.getUseTime(), MathContext.DECIMAL32);
  725. // }
  726. }
  727. HolidayManagement hoidayManagement = holidayManagementService.selectOneByUserId(flowMain.getApplyUser());
  728. {//进行判断
  729. if (hoidayManagement == null) {
  730. return AjaxResult.error("没有找到用户:" + flowMain.getApplyUser() + "假期信息");
  731. }
  732. if (!hoidayManagement.getStatus().equals(0)) {
  733. return AjaxResult.error("用户:" + flowMain.getApplyUser() + "已经删除,请重新确认");
  734. }
  735. }
  736. // 剩余调休假小时(要减去冻结的小时)',
  737. Double restExchangeTime = hoidayManagement.getRestExchangeTime();
  738. if (totaluseTime.doubleValue() > restExchangeTime) {
  739. return AjaxResult.error("剩余调休假不够抵扣退回的加班时间,请退回调休时间后再操作");
  740. }
  741. BigDecimal restExchangeTimeDecimal = new BigDecimal(restExchangeTime).subtract(totaluseTime, MathContext.DECIMAL32);
  742. {//修改假期信息
  743. HolidayManagement updatehoidayManagement = new HolidayManagement();
  744. //restExchangeTimeDecimal放到
  745. updatehoidayManagement.setId(hoidayManagement.getId());
  746. updatehoidayManagement.setRestExchangeTime(restExchangeTimeDecimal.doubleValue());
  747. holidayManagementService.updateByPrimaryKeySelective(updatehoidayManagement);
  748. }
  749. // for (ApplyAddWorkTime applyAddWorkTime : applyOffWorkTimeList) {
  750. // //删除对应的考勤日志
  751. // workAttendanceLogService.deleteListByTableNameAndTableId("apply_add_work_time", applyAddWorkTime.getId());
  752. //
  753. // }
  754. }
  755. }
  756. }
  757. FlowMain record = new FlowMain();
  758. record.setId(id);
  759. record.setStatus(1);
  760. record.setUpdatedAt(new Date());
  761. record.setUpdatedBy(ShiroUtils.getUser().getId());
  762. int i = modelService.updateByPrimaryKeySelective(record);
  763. return result(i);
  764. }
  765. // @PostMapping(value = "edit", produces = {"application/json;charset=UTF-8"})
  766. // @ResponseBody
  767. // public AjaxResult editSave(FlowMain model) {
  768. // int result = modelService.updateByPrimaryKeySelective(model);
  769. // return result(result);
  770. // }
  771. @PostMapping(value = "getById", produces = {"application/json;charset=UTF-8"})
  772. @ResponseBody
  773. public FlowMain getById(String id) {
  774. return modelService.selectByPrimaryKey(id);
  775. }
  776. /**
  777. * 重新写了一个重新部署该流程的接口
  778. * @param record
  779. * @return
  780. */
  781. @PostMapping(
  782. value = {"deployProcess"},
  783. produces = {"application/json;charset=UTF-8"}
  784. )
  785. @ResponseBody
  786. public AjaxResult deployProcess(FlowDefinition record) {
  787. AjaxResult success = null;
  788. try {
  789. success = this.success(this.flowDefinitionService.deployProcess(record));
  790. } catch (FlowException var3) {
  791. return this.error(var3.getMessage());
  792. }
  793. runerLoadOneService.refreshFlowNumber();
  794. return success;
  795. }
  796. }