FlowMainController.java 44 KB

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