FlowMainController.java 36 KB

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