FlowMainService.java 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  1. package com.idea.oa.flow2.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.idea.oa.activiti.service.ProActiService;
  5. import com.idea.oa.apply.model.*;
  6. import com.idea.oa.apply.model.inout.AddConfirmResult;
  7. import com.idea.oa.apply.model.inout.OperaterManage;
  8. import com.idea.oa.apply.service.ApplyLxWorkService;
  9. import com.idea.oa.apply.service.ApplyOffWorkTimeService;
  10. import com.idea.oa.apply.service.ApplyUseMoneyDetailService;
  11. import com.idea.oa.apply.util.constant.ConstantFlowType;
  12. import com.idea.oa.flow2.mapper.FlowMainExtendMapper;
  13. import com.idea.oa.flow2.mapper.FlowMainMapper;
  14. import com.idea.oa.flow2.model.*;
  15. import com.idea.oa.flow2.model.in.FlowMainIn;
  16. import com.idea.oa.flow2.model.out.FlowHistoryInfo;
  17. import com.idea.oa.flow2.model.out.IMGFlowHistoryInfo;
  18. import com.idea.oa.project.model.ProMain;
  19. import com.idea.oa.project.service.ProMainService;
  20. import com.rockstar.common.base.BaseService;
  21. import com.rockstar.common.domain.AjaxResult;
  22. import com.rockstar.common.support.Convert;
  23. import com.rockstar.flow.service.FlowService;
  24. import com.rockstar.frame.model.FrameRoleData;
  25. import com.rockstar.frame.model.FrameUser;
  26. import com.rockstar.frame.model.extend.DateTrans;
  27. import com.rockstar.frame.model.extend.Tablepar;
  28. import com.rockstar.frame.service.FrameUserService;
  29. import com.rockstar.shiro.util.ShiroUtils;
  30. import com.rockstar.util.UUIDUtils;
  31. import org.activiti.bpmn.model.UserTask;
  32. import org.activiti.engine.TaskService;
  33. import org.activiti.engine.task.Task;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.stereotype.Service;
  36. import org.springframework.util.StringUtils;
  37. import java.math.BigDecimal;
  38. import java.math.MathContext;
  39. import java.util.*;
  40. @Service
  41. public class FlowMainService implements BaseService<FlowMain, FlowMainExample> {
  42. @Autowired
  43. private ApplyOffWorkTimeService applyOffWorkTimeService;
  44. @Autowired
  45. private ApplyUseMoneyDetailService applyUseMoneyDetailService;
  46. @Autowired
  47. public FrameUserService frameUserService;
  48. @Autowired
  49. private TaskService taskService;
  50. @Autowired
  51. private FlowService flowService;
  52. @Autowired
  53. private FlowMainPushService flowMainPushService;
  54. //文件mapper
  55. @Autowired
  56. private FlowMainMapper flowMainMapper;
  57. @Autowired
  58. private FlowMainExtendMapper flowMainExtendMapper;
  59. @Autowired
  60. private ProActiService proActiService;
  61. @Autowired
  62. private FlowMainLogService flowMainLogService;
  63. @Autowired
  64. private FlowMainCcService flowMainCcService;
  65. @Autowired
  66. private ProMainService proMainService;
  67. @Autowired
  68. private ApplyLxWorkService applyLxWorkService;
  69. /**
  70. * 添加审核结果
  71. * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程(不同意,并且结束流程);
  72. *
  73. * @return string 如果为ok就是成功,不然就是失败message
  74. */
  75. public String doConfirmResult(AddConfirmResult addConfirmResult, String deploymentid, String constantFlowType, FlowMainPush flowMainPush, HashMap<String, Object> conditionMap) throws com.rockstar.flow.exception.FlowException {
  76. if (addConfirmResult.getConfirmResult() == null) {
  77. return "没有获取到confirmResult值";
  78. }
  79. // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID;
  80. // String constantFlowType = ConstantFlowType.USE_MONEY;
  81. OperaterManage operaterManage = new OperaterManage();
  82. FrameUser frameUser = new FrameUser();
  83. try {
  84. frameUser.setId(ShiroUtils.getUser().getId());
  85. } catch (Exception e) {
  86. frameUser.setId(addConfirmResult.getOperaterId());
  87. }
  88. operaterManage.setUser(frameUser);
  89. // FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId());
  90. if (!flowMainPush.getStatus().equals(0)) {
  91. if (flowMainPush.getStatus().equals(1)) {
  92. return "已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认";
  93. } else if (flowMainPush.getStatus().equals(2)) {
  94. return "已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认";
  95. }
  96. }
  97. {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突
  98. FlowMainPush updateFlowMainPush = new FlowMainPush();
  99. updateFlowMainPush.setId(flowMainPush.getId());
  100. updateFlowMainPush.setStatus(1);
  101. updateFlowMainPush.setUpdatedAt(new Date());
  102. updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  103. flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  104. }
  105. FlowMain flowMain = this.selectByPrimaryKey(flowMainPush.getFlowMainId());
  106. //当前任务流程 目的是获取节点名称,存起来nodeName
  107. String nodeName = flowMainPush.getNodeName() == null ? proActiService.getNodeName(flowMainPush) : flowMainPush.getNodeName();
  108. if (nodeName == null) {
  109. return "异常:没有找到对应的任务...请通知管理员";
  110. }
  111. String mypushUserKey = flowMainPush.getPushUserKey();
  112. // flowMain.
  113. // Map<String, Object> conditionMap
  114. //审核通过,转下一步
  115. boolean isEnd = false;//是否审核到最后一步了
  116. if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
  117. {// 发起流程引擎操作 并查看下一节点的操作要求
  118. //1.如果当前角色是自己,就进行正常的审核流程
  119. //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程
  120. Map<String, String> stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap);
  121. if (stringStringMap == null) {
  122. return "流程引擎开启失败,请查看原因!";
  123. }
  124. isEnd = stringStringMap.get("isEnd") == null ? false : true;
  125. }
  126. {
  127. //存入流程日志表的id
  128. String flowMainLogUuid = UUIDUtils.middleUUID();
  129. //1修改主表状态 ok
  130. {
  131. FlowMain flowMain1 = new FlowMain();
  132. flowMain1.setId(flowMainPush.getFlowMainId());
  133. if (isEnd) {
  134. flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  135. flowMain1.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
  136. } else {
  137. flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  138. flowMain1.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
  139. }
  140. flowMain1.setLastMainLogId(flowMainLogUuid);
  141. flowMain1.setUpdatedAt(new Date());
  142. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  143. this.updateByPrimaryKeySelective(flowMain1);
  144. }
  145. //2添加日志 ok
  146. FlowMainLog flowMainLog = new FlowMainLog();
  147. {
  148. flowMainLog.setId(flowMainLogUuid);
  149. flowMainLog.setFlowMainId(flowMain.getId());
  150. flowMainLog.setFormId(flowMain.getFormId());
  151. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  152. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  153. flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  154. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  155. if (isEnd) {
  156. flowMainLog.setAuditType("2");
  157. } else {
  158. flowMainLog.setAuditType("1");
  159. }
  160. flowMainLog.setFlowType(constantFlowType);
  161. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  162. {// 需要工作流引擎的支持
  163. flowMainLog.setFlowId(flowMain.getFlowId());
  164. flowMainLog.setTaskId(flowMainPush.getTaskId());
  165. flowMainLog.setNodeName(nodeName);
  166. flowMainLog.setPushUserKey(mypushUserKey);
  167. }
  168. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  169. // 因为感觉用不到,暂时不放进去
  170. // flowMainLog.setNextPersons();
  171. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  172. flowMainLog.setCcList(null);
  173. flowMainLog.setCreatedAt(new Date());
  174. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  175. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  176. flowMainLog.setStatus(0);
  177. flowMainLogService.insertWithoutId(flowMainLog);
  178. }
  179. // 3存入抄送人信息 ok
  180. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  181. String[] split = addConfirmResult.getCcList().split(",");
  182. for (String ccId : split) {
  183. if (!StringUtils.isEmpty(ccId)) {
  184. FlowMainCc flowMainCc = new FlowMainCc();
  185. flowMainCc.setFlowMainId(flowMain.getId());
  186. flowMainCc.setCcUser(ccId);
  187. //选择抄送人时的记录表id(flow_main_log):例如:112122
  188. flowMainCc.setMainLogIds(flowMainLog.getId());
  189. flowMainCc.setUpdatedAt(new Date());
  190. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  191. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  192. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  193. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  194. flowMainCc.setStatus(0);
  195. flowMainCcService.insert(flowMainCc);
  196. }
  197. }
  198. }
  199. //4.0判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  200. {
  201. //todo推送类型1单流程推送,2串联推送,3并联推送
  202. Integer pushType = flowMainPush.getPushType();
  203. //逻辑删除本推送
  204. {
  205. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  206. // updateFlowMainPush.setId(flowMainPush.getId());
  207. // updateFlowMainPush.setStatus(1);
  208. // updateFlowMainPush.setUpdatedAt(new Date());
  209. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  210. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  211. }
  212. if (pushType.equals(1) || pushType.equals(2)) {
  213. //只要逻辑删除本推送
  214. } else if (pushType.equals(3)) {
  215. //要逻辑删除自己和其他推送
  216. //将其他并联推送的人员推送状态status改成2状态值
  217. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  218. }
  219. }
  220. //4添加新的推送人员
  221. if (!isEnd) {//查看各个任务
  222. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  223. // taskService.createTaskQuery().processInstanceId();
  224. //查看总的数据流程
  225. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  226. for (Task task : listTask) {
  227. {
  228. //获取推送类型1单流程推送,2串联推送,3并联推送',
  229. Integer pushType = null;
  230. //'推送时彭总给的key值',
  231. String pushUserKey = null;
  232. UserTask myUserTask = null;
  233. {
  234. String taskDefinitionKey = task.getTaskDefinitionKey();
  235. for (int i = 0; i < TaskList.size(); i++) {
  236. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  237. myUserTask = TaskList.get(i);
  238. break;
  239. }
  240. }
  241. //判断是否存在串并联并修改推送状态
  242. if (myUserTask != null) {
  243. pushUserKey = myUserTask.getCandidateGroups().get(0);
  244. if (listTask.size() > 1) {
  245. String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  246. if (s1.length >= 5) {
  247. String pushTypeNum = s1[4];
  248. if ("0".equals(pushTypeNum)) {
  249. pushType = 2;
  250. } else if ("1".equals(pushTypeNum)) {
  251. pushType = 3;
  252. }
  253. }
  254. } else {
  255. pushType = 1;
  256. }
  257. }
  258. }
  259. FlowMainPush newflowMainPush = new FlowMainPush();
  260. newflowMainPush.setFlowMainId(flowMain.getId());
  261. newflowMainPush.setFormId(flowMain.getFormId());
  262. {// 需要工作流引擎的支持
  263. newflowMainPush.setPushUser(task.getAssignee());//推送人id'
  264. newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  265. newflowMainPush.setNodeName(myUserTask.getName());
  266. newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  267. newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  268. newflowMainPush.setFlowType(constantFlowType);
  269. newflowMainPush.setFlowPost(task.getAssignee());
  270. ////2023年5月10日 修改成上面的了 张洮
  271. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  272. newflowMainPush.setFlowId(flowMain.getFlowId());
  273. newflowMainPush.setTaskId(task.getId());
  274. }
  275. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  276. newflowMainPush.setUpdatedAt(new Date());
  277. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  278. newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  279. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  280. newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  281. newflowMainPush.setStatus(0);
  282. flowMainPushService.insert(newflowMainPush);
  283. }
  284. }
  285. }
  286. }
  287. } else if (addConfirmResult.getConfirmResult().equals("2")) {//退回发起人 ok
  288. {// 退回发起人
  289. isEnd = true;
  290. // flowService.deleteInstance(flowMain.getFlowId(), "退回发起人");
  291. //当前审核人/委托人代表的用户id
  292. String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
  293. if (myFrameUserId == null) {
  294. return null;
  295. }
  296. //当前审核人/委托人代表的用户
  297. FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  298. FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser());
  299. // FrameUser currUser = operaterManage.getUser();
  300. boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "no", "退回发起人", targetUser, myFrameUser, null);
  301. }
  302. {
  303. //存入流程日志表的id
  304. String flowMainLogUuid = UUIDUtils.middleUUID();
  305. //1修改主表状态
  306. {
  307. FlowMain flowMain1 = new FlowMain();
  308. flowMain1.setId(flowMainPush.getFlowMainId());
  309. flowMain1.setFlowStatus(2);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  310. flowMain1.setLastMainLogId(flowMainLogUuid);
  311. flowMain1.setUpdatedAt(new Date());
  312. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  313. this.updateByPrimaryKeySelective(flowMain1);
  314. }
  315. //2添加日志 ok
  316. FlowMainLog flowMainLog = new FlowMainLog();
  317. {
  318. flowMainLog.setId(flowMainLogUuid);
  319. flowMainLog.setFlowMainId(flowMain.getId());
  320. flowMainLog.setFormId(flowMain.getFormId());
  321. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  322. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  323. flowMainLog.setAuditResult("2");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  324. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  325. flowMainLog.setAuditType("1");
  326. flowMainLog.setFlowType(constantFlowType);
  327. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  328. {// 需要工作流引擎的支持
  329. flowMainLog.setFlowId(flowMain.getFlowId());
  330. flowMainLog.setTaskId(flowMainPush.getTaskId());
  331. flowMainLog.setNodeName(nodeName);
  332. flowMainLog.setPushUserKey(mypushUserKey);
  333. }
  334. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  335. // 因为感觉用不到,暂时不放进去
  336. // flowMainLog.setNextPersons();
  337. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  338. flowMainLog.setCcList(null);
  339. flowMainLog.setCreatedAt(new Date());
  340. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  341. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  342. flowMainLog.setStatus(0);
  343. flowMainLogService.insertWithoutId(flowMainLog);
  344. }
  345. //2.1添加抄送
  346. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  347. String[] split = addConfirmResult.getCcList().split(",");
  348. for (String ccId : split) {
  349. if (!StringUtils.isEmpty(ccId)) {
  350. FlowMainCc flowMainCc = new FlowMainCc();
  351. flowMainCc.setFlowMainId(flowMain.getId());
  352. flowMainCc.setCcUser(ccId);
  353. //选择抄送人时的记录表id(flow_main_log):例如:112122
  354. flowMainCc.setMainLogIds(flowMainLog.getId());
  355. flowMainCc.setUpdatedAt(new Date());
  356. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  357. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  358. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  359. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  360. flowMainCc.setStatus(0);
  361. flowMainCcService.insert(flowMainCc);
  362. }
  363. }
  364. }
  365. //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  366. {
  367. //todo推送类型1单流程推送,2串联推送,3并联推送
  368. Integer pushType = flowMainPush.getPushType();
  369. //逻辑删除本推送
  370. {
  371. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  372. // updateFlowMainPush.setId(flowMainPush.getId());
  373. // updateFlowMainPush.setStatus(1);
  374. // updateFlowMainPush.setUpdatedAt(new Date());
  375. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  376. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  377. }
  378. if (pushType.equals(1) || pushType.equals(2)) {
  379. //只要逻辑删除本推送
  380. } else if (pushType.equals(3)) {
  381. //要逻辑删除自己和其他推送
  382. //将其他并联推送的人员推送状态status改成2状态值
  383. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  384. }
  385. }
  386. //4添加推送人(因为退回发起人之后 发起人不需要再审核,所以改成推送人就不要了,下面的注释掉了)
  387. {//查看各个任务
  388. // List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  389. //// taskService.createTaskQuery().processInstanceId();
  390. // //查看总的数据流程
  391. // List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  392. // for (Task task : listTask) {
  393. // UserTask myUserTask = null;
  394. // {
  395. // String taskDefinitionKey = task.getTaskDefinitionKey();
  396. // for (int i = 0; i < TaskList.size(); i++) {
  397. // if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  398. // myUserTask = TaskList.get(i);
  399. // break;
  400. // }
  401. // }
  402. // //判断是否存在串并联并修改推送状态
  403. // //'推送时彭总给的key值',
  404. // String pushUserKey = null;
  405. // if (myUserTask != null) {
  406. // pushUserKey = myUserTask.getCandidateGroups().get(0);
  407. // }
  408. // //'推送类型1单流程推送,2串联推送,3并联推送',
  409. // Integer pushType = 1;
  410. //// if (myUserTask != null) {
  411. //// pushUserKey = myUserTask.getCandidateGroups().get(0);
  412. //// if (listTask.size() > 1) {
  413. //// String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  414. //// if (s1.length >= 5) {
  415. //// String pushTypeNum = s1[4];
  416. //// if ("0".equals(pushTypeNum)) {
  417. //// pushType = 2;
  418. //// } else if ("1".equals(pushTypeNum)) {
  419. //// pushType = 3;
  420. //// }
  421. ////
  422. //// }
  423. //// } else {
  424. //// pushType = 1;
  425. //// }
  426. //// }
  427. // FlowMainPush newflowMainPush = new FlowMainPush();
  428. // newflowMainPush.setFlowMainId(flowMain.getId());
  429. // newflowMainPush.setFormId(flowMain.getFormId());
  430. // {// 需要工作流引擎的支持
  431. // newflowMainPush.setPushUser(task.getAssignee());//推送人id'
  432. // newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  433. // newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  434. // newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  435. // newflowMainPush.setFlowType(constantFlowType);
  436. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  437. // newflowMainPush.setFlowId(flowMain.getFlowId());
  438. // newflowMainPush.setTaskId(task.getId());
  439. // }
  440. // newflowMainPush.setUpMainLogId(flowMainLog.getId());
  441. // newflowMainPush.setUpdatedAt(new Date());
  442. // newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  443. // newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  444. // newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  445. // newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  446. // newflowMainPush.setStatus(0);
  447. // flowMainPushService.insert(newflowMainPush);
  448. // }
  449. // }
  450. }
  451. }
  452. } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点
  453. FrameUser targetUser = null;
  454. {// 发起流程引擎操作
  455. //当前审核人/委托人代表的用户id
  456. String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
  457. if (myFrameUserId == null) {
  458. return null;
  459. }
  460. //当前审核人/委托人代表的用户
  461. FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  462. FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId());
  463. while ("4".equals(flowMainLog.getAuditResult())) {
  464. flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainLog.getUpMainLogId());
  465. }
  466. targetUser = frameUserService.selectByPrimaryKey(flowMainLog.getAuditUser());
  467. // FrameUser currUser = operaterManage.getUser();
  468. boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "back", "退回上节点", targetUser, myFrameUser, null);
  469. }
  470. {
  471. //存入流程日志表的id
  472. String flowMainLogUuid = UUIDUtils.middleUUID();
  473. //1修改主表状态
  474. {
  475. FlowMain flowMain1 = new FlowMain();
  476. flowMain1.setId(flowMainPush.getFlowMainId());
  477. flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  478. flowMain1.setLastMainLogId(flowMainLogUuid);
  479. flowMain1.setUpdatedAt(new Date());
  480. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  481. this.updateByPrimaryKeySelective(flowMain1);
  482. }
  483. //2添加日志 ok
  484. FlowMainLog flowMainLog = new FlowMainLog();
  485. {
  486. flowMainLog.setId(flowMainLogUuid);
  487. flowMainLog.setFlowMainId(flowMain.getId());
  488. flowMainLog.setFormId(flowMain.getFormId());
  489. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  490. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  491. flowMainLog.setAuditResult("3");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  492. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  493. flowMainLog.setAuditType("1");
  494. flowMainLog.setFlowType(constantFlowType);
  495. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  496. {// 需要工作流引擎的支持
  497. flowMainLog.setFlowId(flowMain.getFlowId());
  498. flowMainLog.setTaskId(flowMainPush.getTaskId());
  499. flowMainLog.setNodeName(nodeName);
  500. flowMainLog.setPushUserKey(mypushUserKey);
  501. }
  502. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  503. // 因为感觉用不到,暂时不放进去
  504. // flowMainLog.setNextPersons();
  505. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  506. flowMainLog.setCcList(null);
  507. flowMainLog.setCreatedAt(new Date());
  508. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  509. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  510. flowMainLog.setStatus(0);
  511. flowMainLogService.insertWithoutId(flowMainLog);
  512. }
  513. //2.1添加抄送
  514. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  515. String[] split = addConfirmResult.getCcList().split(",");
  516. for (String ccId : split) {
  517. if (!StringUtils.isEmpty(ccId)) {
  518. FlowMainCc flowMainCc = new FlowMainCc();
  519. flowMainCc.setFlowMainId(flowMain.getId());
  520. flowMainCc.setCcUser(ccId);
  521. //选择抄送人时的记录表id(flow_main_log):例如:112122
  522. flowMainCc.setMainLogIds(flowMainLog.getId());
  523. flowMainCc.setUpdatedAt(new Date());
  524. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  525. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  526. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  527. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  528. flowMainCc.setStatus(0);
  529. flowMainCcService.insert(flowMainCc);
  530. }
  531. }
  532. }
  533. //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  534. {
  535. //todo推送类型1单流程推送,2串联推送,3并联推送
  536. Integer pushType = flowMainPush.getPushType();
  537. //逻辑删除本推送
  538. {
  539. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  540. // updateFlowMainPush.setId(flowMainPush.getId());
  541. // updateFlowMainPush.setStatus(1);
  542. // updateFlowMainPush.setUpdatedAt(new Date());
  543. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  544. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  545. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  546. }
  547. }
  548. //4添加新的推送人员
  549. {//查看各个任务
  550. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  551. // taskService.createTaskQuery().processInstanceId();
  552. //查看总的数据流程
  553. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  554. for (Task task : listTask) {
  555. UserTask myUserTask = null;
  556. {
  557. String taskDefinitionKey = task.getTaskDefinitionKey();
  558. for (int i = 0; i < TaskList.size(); i++) {
  559. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  560. myUserTask = TaskList.get(i);
  561. break;
  562. }
  563. }
  564. //判断是否存在串并联并修改推送状态
  565. //'推送时彭总给的key值',
  566. String pushUserKey = null;
  567. if (myUserTask != null) {
  568. pushUserKey = myUserTask.getCandidateGroups().get(0);
  569. }
  570. //'推送类型1单流程推送,2串联推送,3并联推送',
  571. Integer pushType = 1;
  572. // if (myUserTask != null) {
  573. // pushUserKey = myUserTask.getCandidateGroups().get(0);
  574. // if (listTask.size() > 1) {
  575. // String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  576. // if (s1.length >= 5) {
  577. // String pushTypeNum = s1[4];
  578. // if ("0".equals(pushTypeNum)) {
  579. // pushType = 2;
  580. // } else if ("1".equals(pushTypeNum)) {
  581. // pushType = 3;
  582. // }
  583. //
  584. // }
  585. // } else {
  586. // pushType = 1;
  587. // }
  588. // }
  589. FlowMainPush newflowMainPush = new FlowMainPush();
  590. newflowMainPush.setFlowMainId(flowMain.getId());
  591. newflowMainPush.setFormId(flowMain.getFormId());
  592. {// 需要工作流引擎的支持
  593. if (!task.getAssignee().equals(targetUser.getId())) {
  594. continue;
  595. }
  596. newflowMainPush.setPushUser(task.getAssignee());//推送人id'
  597. newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  598. newflowMainPush.setNodeName(myUserTask.getName());
  599. newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  600. newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  601. newflowMainPush.setFlowType(constantFlowType);
  602. newflowMainPush.setFlowPost(task.getAssignee());
  603. ////2023年5月10日 修改成上面的了 张洮
  604. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  605. newflowMainPush.setFlowId(flowMain.getFlowId());
  606. newflowMainPush.setTaskId(task.getId());
  607. }
  608. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  609. newflowMainPush.setUpdatedAt(new Date());
  610. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  611. newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  612. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  613. newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  614. newflowMainPush.setStatus(0);
  615. flowMainPushService.insert(newflowMainPush);
  616. }
  617. }
  618. }
  619. }
  620. } else if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 ok
  621. isEnd = true;
  622. {// 发起流程引擎操作 并结束该流程
  623. flowService.deleteInstance(flowMain.getFlowId(), "结束流程");
  624. }
  625. {
  626. //存入流程日志表的id
  627. String flowMainLogUuid = UUIDUtils.middleUUID();
  628. //1修改主表状态
  629. {
  630. FlowMain flowMain1 = new FlowMain();
  631. flowMain1.setId(flowMainPush.getFlowMainId());
  632. flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  633. flowMain1.setFlowResult(2); //审核结果0无状态,1审核通过结束,2审核不通过结束
  634. flowMain1.setLastMainLogId(flowMainLogUuid);
  635. flowMain1.setUpdatedAt(new Date());
  636. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  637. this.updateByPrimaryKeySelective(flowMain1);
  638. }
  639. //2添加日志 ok
  640. FlowMainLog flowMainLog = new FlowMainLog();
  641. {
  642. flowMainLog.setId(flowMainLogUuid);
  643. flowMainLog.setFlowMainId(flowMain.getId());
  644. flowMainLog.setFormId(flowMain.getFormId());
  645. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  646. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  647. flowMainLog.setAuditResult("5");// `audit_result` varchar(4) DEFAULT NULL COMMENT 审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,5,不同意且结束流程,null没有审核)',
  648. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  649. flowMainLog.setAuditType("2");
  650. flowMainLog.setFlowType(constantFlowType);
  651. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  652. {// 需要工作流引擎的支持
  653. flowMainLog.setFlowId(flowMain.getFlowId());
  654. flowMainLog.setTaskId(flowMainPush.getTaskId());
  655. flowMainLog.setNodeName(nodeName);
  656. flowMainLog.setPushUserKey(mypushUserKey);
  657. }
  658. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  659. // 因为感觉用不到,暂时不放进去
  660. // flowMainLog.setNextPersons();
  661. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  662. flowMainLog.setCcList(null);
  663. flowMainLog.setCreatedAt(new Date());
  664. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  665. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  666. flowMainLog.setStatus(0);
  667. flowMainLogService.insertWithoutId(flowMainLog);
  668. }
  669. //3 存入抄送人信息
  670. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  671. String[] split = addConfirmResult.getCcList().split(",");
  672. for (String ccId : split) {
  673. if (!StringUtils.isEmpty(ccId)) {
  674. FlowMainCc flowMainCc = new FlowMainCc();
  675. flowMainCc.setFlowMainId(flowMain.getId());
  676. flowMainCc.setCcUser(ccId);
  677. //选择抄送人时的记录表id(flow_main_log):例如:112122
  678. flowMainCc.setMainLogIds(flowMainLog.getId());
  679. flowMainCc.setUpdatedAt(new Date());
  680. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  681. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  682. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  683. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  684. flowMainCc.setStatus(0);
  685. flowMainCcService.insert(flowMainCc);
  686. }
  687. }
  688. }
  689. //4.0逻辑删除旧的推送人
  690. {
  691. //todo推送类型1单流程推送,2串联推送,3并联推送
  692. Integer pushType = flowMainPush.getPushType();
  693. //逻辑删除本推送
  694. {
  695. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  696. // updateFlowMainPush.setId(flowMainPush.getId());
  697. // updateFlowMainPush.setStatus(1);
  698. // updateFlowMainPush.setUpdatedAt(new Date());
  699. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  700. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  701. }
  702. if (pushType.equals(1) || pushType.equals(2)) {
  703. //只要逻辑删除本推送
  704. } else if (pushType.equals(3)) {
  705. //要逻辑删除自己和其他推送
  706. //将其他并联推送的人员推送状态status改成2状态值
  707. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  708. }
  709. }
  710. }
  711. }
  712. if (isEnd) {
  713. return "ok_end";
  714. } else {
  715. return "ok_noEnd";
  716. }
  717. }
  718. /**
  719. * 通用方法,加载到流程业务模块
  720. *
  721. * @return
  722. */
  723. public AjaxResult doFlowMain(String ApplyTheme, String recordId, String recordRemark, String recordCcList, String processdefine, String deploymentid, Map<String, Object> conditionMap, String constantFlowTypeNAME, String constantFlowType,FrameUser currUser) throws com.rockstar.flow.exception.FlowException {
  724. // 存入流程主表 ok
  725. FlowMain flowMain = new FlowMain();
  726. flowMain.setId(UUIDUtils.middleUUID());
  727. // 进入流程引擎,开始启动流程
  728. String processInstanceId = null;
  729. // 判断启动申请后是否结束
  730. boolean isEnd = false;
  731. {
  732. //启动流程引擎
  733. Map<String, String> stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain.getId(),currUser, conditionMap);
  734. if (stringStringMap == null) {
  735. return AjaxResult.error("流程引擎开启失败,请查看原因!");
  736. }
  737. processInstanceId = stringStringMap.get("processInstanceId");
  738. if (stringStringMap.get("isEnd") != null) {
  739. isEnd = true;
  740. }
  741. }
  742. //存入流程日志表的id
  743. String flowMainLogUuid = UUIDUtils.middleUUID();
  744. {
  745. // conditionMap
  746. // if (conditionMap!=null) {
  747. // Object conditionMapString = JSONObject.toJSON(conditionMap);
  748. // flowMain.setConditionMap(conditionMapString.toString());
  749. // }
  750. // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单
  751. flowMain.setApplyTheme(ApplyTheme);
  752. flowMain.setFormId(recordId);
  753. flowMain.setApplyUser(currUser.getId());
  754. flowMain.setDeptId(currUser.getDepartment());
  755. //todo 判断是否结束
  756. if (isEnd) {
  757. flowMain.setFlowStatus(3);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  758. flowMain.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
  759. } else {
  760. flowMain.setFlowStatus(1);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  761. flowMain.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
  762. }
  763. flowMain.setReturnStatus(0);//'0/null无状态,1已撤回并且已重新发起',
  764. flowMain.setCcList(null);
  765. flowMain.setFlowName(constantFlowTypeNAME);
  766. flowMain.setFlowType(constantFlowType);
  767. //当前流程邮递操作人(frame_user)id 去除岗位的设定
  768. flowMain.setFlowPost(currUser.getId());
  769. {// 需要工作流引擎的支持
  770. flowMain.setFlowId(processInstanceId);
  771. flowMain.setTaskId(null);
  772. }
  773. flowMain.setLastMainLogId(flowMainLogUuid);
  774. flowMain.setUpdatedAt(new Date());
  775. flowMain.setCreatedAt(flowMain.getUpdatedAt());
  776. flowMain.setCreatedBy(currUser.getId());
  777. flowMain.setUpdatedBy(flowMain.getCreatedBy());
  778. flowMain.setGroupId(currUser.getGroupId());
  779. flowMain.setStatus(0);
  780. if (!StringUtils.isEmpty(recordRemark)) {
  781. flowMain.setRemark(recordRemark);
  782. }
  783. this.insertWithoutId(flowMain);
  784. }
  785. // 存入流程日志表 ok
  786. FlowMainLog flowMainLog = new FlowMainLog();
  787. {
  788. flowMainLog.setId(flowMainLogUuid);
  789. flowMainLog.setFlowMainId(flowMain.getId());
  790. flowMainLog.setFormId(recordId);
  791. flowMainLog.setAuditUser(currUser.getId());
  792. //todo 判断是否结束
  793. if (isEnd) {
  794. flowMainLog.setAuditType("2"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  795. flowMainLog.setAuditContent("自审通过");
  796. flowMainLog.setAuditResult("1");
  797. } else {
  798. flowMainLog.setAuditType("0"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  799. flowMainLog.setAuditContent(null);
  800. flowMainLog.setAuditResult(null);
  801. }
  802. flowMainLog.setFlowType(constantFlowType);
  803. flowMainLog.setFlowPost(currUser.getId());
  804. {// 需要工作流引擎的支持
  805. flowMainLog.setFlowId(processInstanceId);
  806. flowMainLog.setTaskId(null);
  807. flowMainLog.setNodeName(ConstantFlowType.nodeKeysName.get(1));
  808. flowMainLog.setPushUserKey(ConstantFlowType.nodeKeysName.get(11));
  809. }
  810. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  811. // 因为感觉用不到,暂时不放进去
  812. // flowMainLog.setNextPersons();
  813. flowMainLog.setUpMainLogId(null);
  814. flowMainLog.setCcList(null);
  815. flowMainLog.setCreatedAt(new Date());
  816. flowMainLog.setCreatedBy(currUser.getId());
  817. flowMainLog.setGroupId(currUser.getGroupId());
  818. flowMainLog.setStatus(0);
  819. flowMainLogService.insertWithoutId(flowMainLog);
  820. }
  821. // 存入抄送人信息 ok
  822. if (!StringUtils.isEmpty(recordCcList)) {
  823. String[] split = recordCcList.split(",");
  824. for (String ccId : split) {
  825. if (!StringUtils.isEmpty(ccId)) {
  826. FlowMainCc flowMainCc = new FlowMainCc();
  827. flowMainCc.setFlowMainId(flowMain.getId());
  828. flowMainCc.setCcUser(ccId);
  829. //选择抄送人时的记录表id(flow_main_log):例如:112122
  830. flowMainCc.setMainLogIds(flowMainLog.getId());
  831. flowMainCc.setUpdatedAt(new Date());
  832. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  833. flowMainCc.setCreatedBy(currUser.getId());
  834. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  835. flowMainCc.setGroupId(currUser.getGroupId());
  836. flowMainCc.setStatus(0);
  837. flowMainCcService.insert(flowMainCc);
  838. }
  839. }
  840. }
  841. // 存入推送人
  842. //查看各个任务
  843. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  844. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  845. for (Task task : listTask) {
  846. UserTask myUserTask = null;
  847. {
  848. String taskDefinitionKey = task.getTaskDefinitionKey();
  849. for (int i = 0; i < TaskList.size(); i++) {
  850. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  851. myUserTask = TaskList.get(i);
  852. break;
  853. }
  854. }
  855. //'推送时彭总给的key值',
  856. String pushUserKey = null;
  857. //'推送类型1单流程推送,2串联推送,3并联推送',
  858. Integer pushType = null;
  859. if (myUserTask != null) {
  860. pushUserKey = myUserTask.getCandidateGroups().get(0);
  861. if (listTask.size() > 1) {
  862. String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  863. if (s1.length >= 5) {
  864. String pushTypeNum = s1[4];
  865. if ("0".equals(pushTypeNum)) {
  866. pushType = 2;
  867. } else if ("1".equals(pushTypeNum)) {
  868. pushType = 3;
  869. }
  870. }
  871. } else {
  872. pushType = 1;
  873. }
  874. }
  875. FlowMainPush flowMainPush = new FlowMainPush();
  876. flowMainPush.setFlowMainId(flowMain.getId());
  877. flowMainPush.setFormId(recordId);
  878. {// 需要工作流引擎的支持
  879. flowMainPush.setPushUser(task.getAssignee());//推送人id'
  880. flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  881. flowMainPush.setNodeName(myUserTask.getName());
  882. flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  883. flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  884. flowMainPush.setFlowType(constantFlowType);
  885. flowMainPush.setFlowPost(task.getAssignee());
  886. //2023年5月10日 修改成上面的了 张洮
  887. // flowMainPush.setFlowPost(currUser.getId());
  888. flowMainPush.setFlowId(processInstanceId);
  889. flowMainPush.setTaskId(task.getId());
  890. }
  891. flowMainPush.setUpMainLogId(flowMainLog.getId());
  892. flowMainPush.setUpdatedAt(new Date());
  893. flowMainPush.setCreatedAt(flowMainPush.getUpdatedAt());
  894. flowMainPush.setCreatedBy(currUser.getId());
  895. flowMainPush.setUpdatedBy(flowMainPush.getCreatedBy());
  896. flowMainPush.setGroupId(currUser.getGroupId());
  897. flowMainPush.setStatus(0);
  898. flowMainPushService.insert(flowMainPush);
  899. }
  900. }
  901. if (isEnd) {
  902. return AjaxResult.successData(1688, null);
  903. } else {
  904. return AjaxResult.success();
  905. }
  906. }
  907. /**
  908. * 申请人撤回申请
  909. *
  910. * @param flowMainid
  911. */
  912. public AjaxResult recallApply(String flowMainid) {
  913. if (com.rockstar.util.StringUtils.isEmpty(flowMainid)) {
  914. return AjaxResult.error("数据不能为空");
  915. }
  916. FlowMain flowMain = this.selectByPrimaryKey(flowMainid);
  917. //流转状态为审核中时,可以由发起人撤回。ok
  918. if (!flowMain.getFlowStatus().equals(1)) {
  919. return AjaxResult.error("流程状态不在审核中,请重新确认");
  920. }
  921. String mypushUserKey = null;
  922. {//开始申请人撤回申请
  923. //先搜索目前有哪些人在审核中 ,获取key
  924. // select * from flow_main_push WHERE flow_main_push.flow_main_id=#{flowMainId} and STATUS=0
  925. FlowMainPushExample example = new FlowMainPushExample();
  926. example.createCriteria().andFlowMainIdEqualTo(flowMain.getId()).andStatusEqualTo(0);
  927. List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(example);
  928. mypushUserKey = flowMainPushes.get(0).getPushUserKey();
  929. //1.关闭所有推送人数据信息表 ok
  930. {
  931. flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(), flowMain.getId());
  932. }
  933. //2.关闭主流程 ok
  934. {// 发起流程引擎操作 并结束该流程
  935. try {
  936. flowService.deleteInstance(flowMain.getFlowId(), "申请人撤回申请_结束流程");
  937. } catch (Exception e) {
  938. System.err.println("流程引擎异常");
  939. e.printStackTrace();
  940. // throw new RuntimeException(e);
  941. }
  942. }
  943. //3.关闭主流程表 ok
  944. //存入流程日志表的id
  945. String flowMainLogUuid = UUIDUtils.middleUUID();
  946. {
  947. FlowMain flowMain1 = new FlowMain();
  948. flowMain1.setId(flowMain.getId());
  949. flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  950. flowMain1.setLastMainLogId(flowMainLogUuid);
  951. flowMain1.setUpdatedAt(new Date());
  952. flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
  953. this.updateByPrimaryKeySelective(flowMain1);
  954. }
  955. //4 添加日志表
  956. FlowMainLog flowMainLog = new FlowMainLog();
  957. {//其表单对应的流转历史该节点审核结果显示为”发起人撤回”
  958. // flowMainLogUuid
  959. flowMainLog.setId(flowMainLogUuid);
  960. flowMainLog.setFlowMainId(flowMain.getId());
  961. flowMainLog.setFormId(flowMain.getFormId());
  962. flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
  963. flowMainLog.setAuditContent(null);
  964. flowMainLog.setAuditResult(null);
  965. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  966. flowMainLog.setAuditType("4");
  967. flowMainLog.setFlowType(flowMain.getFlowType());
  968. flowMainLog.setFlowPost(ShiroUtils.getUser().getId());
  969. {// 需要工作流引擎的支持
  970. flowMainLog.setFlowId(flowMain.getFlowId());
  971. flowMainLog.setTaskId(null);
  972. flowMainLog.setNodeName("发起人撤回");
  973. flowMainLog.setPushUserKey(mypushUserKey);//发起人撤回时 当时的审核人所对应的角色
  974. }
  975. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  976. // 因为感觉用不到,暂时不放进去
  977. // flowMainLog.setNextPersons();
  978. flowMainLog.setUpMainLogId(flowMain.getLastMainLogId());
  979. flowMainLog.setCcList(null);
  980. flowMainLog.setCreatedAt(new Date());
  981. flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  982. flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  983. flowMainLog.setStatus(0);
  984. flowMainLogService.insertWithoutId(flowMainLog);
  985. }
  986. }
  987. if(ConstantFlowType.LX_WORK.equals(flowMain.getFlowType())||ConstantFlowType.LX_SJ_WORK.equals(flowMain.getFlowType())){
  988. ApplyLxWork applyLxWork = applyLxWorkService.selectByPrimaryKey(flowMain.getFormId());
  989. ProMain proMain = proMainService.selectVoByPrimaryKey(applyLxWork.getProId());
  990. proMain.setRealValidStatus("0");
  991. proMainService.updateByPrimaryKey(proMain);
  992. }
  993. return AjaxResult.success();
  994. }
  995. /**
  996. * 分页查询
  997. *
  998. * @return
  999. */
  1000. public PageInfo<FlowMain> list(Tablepar tablepar, FlowMain model, DateTrans dt) {
  1001. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1002. List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  1003. PageInfo<FlowMain> pageInfo = new PageInfo<>(list);
  1004. return pageInfo;
  1005. }
  1006. public Object listAll(FlowMain model, DateTrans dt) {
  1007. List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  1008. return list;
  1009. }
  1010. @Override
  1011. public int deleteByPrimaryKey(String ids) {
  1012. List<String> lista = Convert.toListStrArray(ids);
  1013. FlowMainExample example = new FlowMainExample();
  1014. example.createCriteria().andIdIn(lista);
  1015. return flowMainMapper.deleteByExample(example);
  1016. }
  1017. @Override
  1018. public FlowMain selectByPrimaryKey(String id) {
  1019. return flowMainMapper.selectByPrimaryKey(id);
  1020. }
  1021. @Override
  1022. public int updateByPrimaryKeySelective(FlowMain record) {
  1023. return flowMainMapper.updateByPrimaryKeySelective(record);
  1024. }
  1025. @Override
  1026. public int updateByExampleSelective(FlowMain record, FlowMainExample example) {
  1027. return flowMainMapper.updateByExampleSelective(record, example);
  1028. }
  1029. @Override
  1030. public int updateByExample(FlowMain record, FlowMainExample example) {
  1031. return flowMainMapper.updateByExample(record, example);
  1032. }
  1033. @Override
  1034. public List<FlowMain> selectByExample(FlowMainExample example) {
  1035. return flowMainMapper.selectByExample(example);
  1036. }
  1037. @Override
  1038. public long countByExample(FlowMainExample example) {
  1039. return flowMainMapper.countByExample(example);
  1040. }
  1041. @Override
  1042. public int deleteByExample(FlowMainExample example) {
  1043. return flowMainMapper.deleteByExample(example);
  1044. }
  1045. public int insert(FlowMain record) {
  1046. record.setId(UUIDUtils.middleUUID());
  1047. return insertWithoutId(record);
  1048. }
  1049. public int insertWithoutId(FlowMain record) {
  1050. return flowMainMapper.insert(record);
  1051. }
  1052. @Override
  1053. public int insertSelective(FlowMain record) {
  1054. record.setId(UUIDUtils.middleUUID());
  1055. record.setCreatedAt(new Date());
  1056. return flowMainMapper.insertSelective(record);
  1057. }
  1058. public PageInfo<FlowMainIn> hasDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1059. model.setAuditResult(new String[]{"1", "2", "3", "5"});
  1060. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1061. List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
  1062. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1063. return pageInfo;
  1064. }
  1065. public List<FrameRoleData> findFrameRoleDatasByUserId(String userId, String roleType) {
  1066. return flowMainExtendMapper.findFrameRoleDatasByUserId(userId, roleType);
  1067. }
  1068. public List<FrameUser> findFrameUsersByRoleKey(String roleKey, String roleType,String groupId) {
  1069. List<FrameUser> frameUsersByRoleKey = null;
  1070. try {
  1071. // System.out.println("SELECT frame_user.* FROM frame_role_data_user LEFT JOIN frame_role_data ON frame_role_data.id=frame_role_data_user.role_data_id LEFT JOIN frame_user ON frame_user.id=frame_role_data_user.user_id WHERE frame_role_data.role_key='"+roleKey+"' AND frame_role_data.role_type='"+roleType+"'");
  1072. frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKey(roleKey, roleType,groupId);
  1073. } catch (Exception e) {
  1074. e.printStackTrace();
  1075. frameUsersByRoleKey = new ArrayList<>();
  1076. }
  1077. return frameUsersByRoleKey;
  1078. }
  1079. public PageInfo<FlowMainIn> myApplylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1080. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1081. List<FlowMainIn> list = flowMainExtendMapper.myApplylistByInfo(model, dt);
  1082. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1083. return pageInfo;
  1084. }
  1085. public List<FlowMainIn> myApplylistByProId(FlowMainIn model) {
  1086. return flowMainExtendMapper.myApplylistByProId(model);
  1087. }
  1088. /**
  1089. * 抄送事项 ok
  1090. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  1091. */
  1092. public PageInfo<FlowMainIn> cclistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1093. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1094. List<FlowMainIn> list = flowMainExtendMapper.cclistByInfo(model, dt);
  1095. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1096. return pageInfo;
  1097. }
  1098. public PageInfo<FlowMainIn> myEntrustlistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1099. model.setAuditResult(new String[]{"4"});
  1100. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1101. List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
  1102. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1103. return pageInfo;
  1104. }
  1105. /**
  1106. * 待办事项
  1107. *
  1108. * @param tablepar
  1109. * @param model
  1110. * @param dt
  1111. * @return
  1112. */
  1113. public PageInfo<FlowMainIn> toDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1114. model.setAuditResult(new String[]{"1"});
  1115. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1116. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1117. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1118. return pageInfo;
  1119. }
  1120. /**
  1121. * 委托代办事项
  1122. *
  1123. * @param tablepar
  1124. * @param model
  1125. * @param dt
  1126. * @return
  1127. */
  1128. public PageInfo<FlowMainIn> entrustToDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1129. model.setAuditResult(new String[]{"2"});
  1130. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1131. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1132. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1133. return pageInfo;
  1134. }
  1135. public List<FlowHistoryInfo> getFlowHistroyByFlowMainId(String flowMainId) {
  1136. return flowMainExtendMapper.getFlowHistroyByFlowMainId(flowMainId);
  1137. }
  1138. public Integer numtoDolistByInfo(FlowMainIn model, DateTrans dt) {
  1139. model.setAuditResult(new String[]{"1"});
  1140. return flowMainExtendMapper.numtoDolistByInfo(model, dt);
  1141. }
  1142. public PageInfo<FlowMainIn> toDolisAndEntrusttByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1143. model.setAuditResult(new String[]{"1", "2"});
  1144. // model.setAuditResult(new String[]{"2"});
  1145. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1146. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1147. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1148. return pageInfo;
  1149. }
  1150. public Integer numtoDolisAndEntrusttByInfo(FlowMainIn model, DateTrans dt) {
  1151. model.setAuditResult(new String[]{"1", "2"});
  1152. return flowMainExtendMapper.numtoDolistByInfo(model, dt);
  1153. }
  1154. public List<IMGFlowHistoryInfo> getIMGFlowHistroyByFlowMainId(String flowMainId) {
  1155. FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId);
  1156. // 判断流程是哪种流程
  1157. String[] flowStep = null;
  1158. {
  1159. if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
  1160. flowStep = ConstantFlowType.ADD_WORK_FLOWSTEPS;
  1161. } else if (flowMain.getFlowType().equals(ConstantFlowType.OFF_WORK)) {
  1162. ApplyOffWorkTimeExample example = new ApplyOffWorkTimeExample();
  1163. example.createCriteria().andOffWorkIdEqualTo(flowMain.getFormId());
  1164. List<ApplyOffWorkTime> applyOffWorkTimes = applyOffWorkTimeService.selectByExample(example);
  1165. BigDecimal hour_totalTiaoXiu = new BigDecimal(0);//所有调休假小时
  1166. BigDecimal day_totalNianJia = new BigDecimal(0);//所有年假天数
  1167. BigDecimal hour_totalShiJia = new BigDecimal(0);//所有事假天数
  1168. BigDecimal day_total_BingJia_hunjia_chanjia_peichanjia_sangjia = new BigDecimal(0);//所有,4病假,5婚假,6产假,7陪产假,8丧假 ,最小为0.5天
  1169. {
  1170. // ApplyOffWork applyOffWork = modelService.selectByPrimaryKey(flowMainPush.getFormId());
  1171. for (ApplyOffWorkTime applyOffWorkTime : applyOffWorkTimes) {
  1172. {//修改请假表,将请假表的对应数据添加冻结时间,并减去可用时间
  1173. if (applyOffWorkTime.getOffWorkType().equals("1")) {//1年假
  1174. day_totalNianJia = day_totalNianJia.add(new BigDecimal(applyOffWorkTime.getUseTime().toString()), MathContext.DECIMAL32);
  1175. } else if (applyOffWorkTime.getOffWorkType().equals("3")) {//3调休
  1176. hour_totalTiaoXiu = hour_totalTiaoXiu.add(new BigDecimal(applyOffWorkTime.getUseTime().toString()), MathContext.DECIMAL32);
  1177. } else if (applyOffWorkTime.getOffWorkType().equals("2")) {//2事假
  1178. hour_totalShiJia = hour_totalShiJia.add(new BigDecimal(applyOffWorkTime.getUseTime().toString()), MathContext.DECIMAL32);
  1179. } else if (applyOffWorkTime.getOffWorkType().equals("4") || applyOffWorkTime.getOffWorkType().equals("4")||applyOffWorkTime.getOffWorkType().equals("5") || applyOffWorkTime.getOffWorkType().equals("5")
  1180. ||applyOffWorkTime.getOffWorkType().equals("6") || applyOffWorkTime.getOffWorkType().equals("6")||applyOffWorkTime.getOffWorkType().equals("7") || applyOffWorkTime.getOffWorkType().equals("7")
  1181. ||applyOffWorkTime.getOffWorkType().equals("8") || applyOffWorkTime.getOffWorkType().equals("8")) {//4病假,5婚假,6产假,7陪产假,8丧假 ,最小为0.5天
  1182. day_total_BingJia_hunjia_chanjia_peichanjia_sangjia = day_total_BingJia_hunjia_chanjia_peichanjia_sangjia.add(new BigDecimal(applyOffWorkTime.getUseTime().toString()), MathContext.DECIMAL32);
  1183. }
  1184. }
  1185. }
  1186. }
  1187. //添加判断条件
  1188. HashMap<String, Object> feeMoneyTotalMap = new HashMap<>();
  1189. if (hour_totalTiaoXiu.doubleValue() > 0 && day_totalNianJia.doubleValue() <= 0 && hour_totalShiJia.doubleValue() <= 0 && day_total_BingJia_hunjia_chanjia_peichanjia_sangjia.doubleValue() <= 0) {
  1190. //假别仅有调休假
  1191. // String isExchangeOnly = conditionMap.get("isExchangeOnly").toString();
  1192. // Integer applyDay = Integer.valueOf(conditionMap.get("applyDay").toString());
  1193. feeMoneyTotalMap.put("isExchangeOnly", "yes");
  1194. feeMoneyTotalMap.put("applyDay", 0);
  1195. flowStep = ConstantFlowType.OFF_WORK_FLOWSTEPS_noenough;
  1196. } else {
  1197. BigDecimal addDay = hour_totalTiaoXiu.add(hour_totalShiJia).divide(new BigDecimal(ConstantFlowType.ONE_DAY_TIME), 2, BigDecimal.ROUND_HALF_UP);
  1198. if (addDay.add(day_totalNianJia).add(day_total_BingJia_hunjia_chanjia_peichanjia_sangjia).doubleValue() > 3) {
  1199. // 假期天数合计>3天
  1200. feeMoneyTotalMap.put("isExchangeOnly", "no");
  1201. feeMoneyTotalMap.put("applyDay", 4);
  1202. flowStep = ConstantFlowType.OFF_WORK_FLOWSTEPS_enough;
  1203. } else {
  1204. feeMoneyTotalMap.put("isExchangeOnly", "no");
  1205. feeMoneyTotalMap.put("applyDay", 0);
  1206. flowStep = ConstantFlowType.OFF_WORK_FLOWSTEPS_noenough2;
  1207. }
  1208. }
  1209. } else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMEN)) {
  1210. flowStep = ConstantFlowType.PAYMEN_FLOWSTEPS;
  1211. } else if (flowMain.getFlowType().equals(ConstantFlowType.USE_MONEY)) {
  1212. ApplyUseMoneyDetailExample example = new ApplyUseMoneyDetailExample();
  1213. example.createCriteria().andUseMoneyIdEqualTo(flowMain.getFormId());
  1214. List<ApplyUseMoneyDetail> applyUseMoneyDetails = applyUseMoneyDetailService.selectByExample(example);
  1215. // 付款总金额
  1216. BigDecimal feeMoneyTotal = new BigDecimal(0);
  1217. for (ApplyUseMoneyDetail applyUseMoneyDetail : applyUseMoneyDetails) {
  1218. BigDecimal feeMoney = applyUseMoneyDetail.getFeeMoney() == null ? new BigDecimal(0) : applyUseMoneyDetail.getFeeMoney();
  1219. feeMoneyTotal = feeMoneyTotal.add(feeMoney, MathContext.DECIMAL32);
  1220. }
  1221. double feeMoneyTotalDouble = feeMoneyTotal.doubleValue();
  1222. //添加判断条件
  1223. // HashMap<String, Object> conditionMap = new HashMap<>();
  1224. // conditionMap.put("billMoney", feeMoneyTotalDouble);
  1225. if (feeMoneyTotalDouble < 3000) {
  1226. flowStep = ConstantFlowType.USE_MONEY_FLOWSTEPS_noenough;
  1227. } else {
  1228. flowStep = ConstantFlowType.USE_MONEY_FLOWSTEPS_enough;
  1229. }
  1230. }else if(flowMain.getFlowType().equals(ConstantFlowType.LX_WORK)){
  1231. flowStep = ConstantFlowType.LX_WORK_FLOWSTEPS;
  1232. }else if(flowMain.getFlowType().equals(ConstantFlowType.LX_SJ_WORK)){
  1233. ApplyLxWork applyLxWork = applyLxWorkService.selectByPrimaryKey(flowMain.getFormId());
  1234. if (applyLxWork.getPresales() < 2000000) {
  1235. flowStep = ConstantFlowType.LX_SJ_WORK_FLOWSTEPS_LESS;
  1236. } else {
  1237. flowStep = ConstantFlowType.LX_SJ_WORK_FLOWSTEPS;
  1238. }
  1239. }
  1240. }
  1241. //获取返回值
  1242. ArrayList<IMGFlowHistoryInfo> imgFlowHistoryInfos = new ArrayList<>();
  1243. {//`flow_status` int(4) DEFAULT NULL COMMENT //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1244. if (flowMain.getFlowStatus().equals(1)) { //ok //需要找到最新推送人 //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1245. List<FlowMainPush> pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainId);
  1246. String pushUserKey = pushByFlowMainId.get(0).getPushUserKey();
  1247. for (int i = 0; i < flowStep.length; i++) {
  1248. if (flowStep[i].startsWith(pushUserKey)) {
  1249. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1250. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1251. imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1252. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1253. break;
  1254. } else {
  1255. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1256. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1257. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1258. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1259. }
  1260. }
  1261. return imgFlowHistoryInfos;
  1262. } else if (flowMain.getFlowStatus().equals(2)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1263. //需要找到最新操作日志
  1264. FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1265. if (flowMainLog==null){
  1266. return null;
  1267. }
  1268. String pushUserKey = flowMainLog.getPushUserKey();
  1269. for (int i = 0; i < flowStep.length; i++) {
  1270. if (flowStep[i].startsWith(pushUserKey)) {
  1271. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1272. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1273. imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1274. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1275. break;
  1276. } else {
  1277. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1278. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1279. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1280. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1281. }
  1282. }
  1283. return imgFlowHistoryInfos;
  1284. } else if (flowMain.getFlowStatus().equals(3)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1285. //需要找到最新操作日志
  1286. FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1287. if (flowMainLog==null){
  1288. return null;
  1289. }
  1290. String pushUserKey = flowMainLog.getPushUserKey();
  1291. for (int i = 0; i < flowStep.length; i++) {
  1292. if (flowStep[i].startsWith(pushUserKey)) {
  1293. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1294. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1295. if ("1".equals(flowMainLog.getAuditResult())){//1,同意
  1296. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1297. imgFlowHistoryInfo.setIsPass("1");
  1298. }else{
  1299. imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1300. }
  1301. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1302. } else {
  1303. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1304. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1305. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1306. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1307. }
  1308. }
  1309. return imgFlowHistoryInfos;
  1310. } else if (flowMain.getFlowStatus().equals(4)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1311. //判断是监控室撤回还是自己撤回
  1312. //需要找到最新操作日志
  1313. FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1314. if (flowMainLog==null){
  1315. return null;
  1316. }
  1317. String pushUserKey = flowMainLog.getPushUserKey();
  1318. for (int i = 0; i < flowStep.length; i++) {
  1319. if (flowStep[i].startsWith(pushUserKey)) {
  1320. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1321. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1322. if (flowMainLog.getAuditType().equals(5)){
  1323. //监控室撤回
  1324. imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1325. }else{
  1326. imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1327. }
  1328. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1329. break;
  1330. } else {
  1331. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1332. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1333. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1334. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1335. }
  1336. }
  1337. return imgFlowHistoryInfos;
  1338. }
  1339. }
  1340. return null;
  1341. }
  1342. }