package com.idea.oa.flow2.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.idea.oa.activiti.service.ProActiService; import com.idea.oa.apply.model.inout.AddConfirmResult; import com.idea.oa.apply.model.inout.OperaterManage; //import com.idea.oa.apply.service.ApplyOffWorkTimeService; //import com.idea.oa.apply.service.ApplyUseMoneyDetailService; import com.idea.oa.apply.util.constant.ConstantFlowType; import com.idea.oa.flow2.mapper.FlowMainExtendMapper; import com.idea.oa.flow2.mapper.FlowMainMapper; import com.idea.oa.flow2.model.*; import com.idea.oa.flow2.model.in.FlowMainIn; import com.idea.oa.flow2.model.out.FlowHistoryInfo; import com.idea.oa.flow2.model.out.IMGFlowHistoryInfo; import com.rockstar.common.base.BaseService; import com.rockstar.common.domain.AjaxResult; import com.rockstar.common.support.Convert; import com.rockstar.flow.service.FlowService; import com.rockstar.frame.model.FrameRoleData; import com.rockstar.frame.model.FrameUser; import com.rockstar.frame.model.extend.DateTrans; import com.rockstar.frame.model.extend.Tablepar; import com.rockstar.frame.service.FrameUserService; import com.rockstar.shiro.util.ShiroUtils; import com.rockstar.util.UUIDUtils; import org.activiti.bpmn.model.UserTask; import org.activiti.engine.TaskService; import org.activiti.engine.task.Task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.math.MathContext; import java.util.*; @Service public class FlowMainService implements BaseService { // @Autowired // private ApplyOffWorkTimeService applyOffWorkTimeService; // @Autowired // private ApplyUseMoneyDetailService applyUseMoneyDetailService; @Autowired public FrameUserService frameUserService; @Autowired private TaskService taskService; @Autowired private FlowService flowService; @Autowired private FlowMainPushService flowMainPushService; //文件mapper @Autowired private FlowMainMapper flowMainMapper; @Autowired private FlowMainExtendMapper flowMainExtendMapper; @Autowired private ProActiService proActiService; @Autowired private FlowMainLogService flowMainLogService; @Autowired private FlowMainCcService flowMainCcService; /** * 添加审核结果 * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程(不同意,并且结束流程); * * @return string 如果为ok就是成功,不然就是失败message */ public String doConfirmResult(AddConfirmResult addConfirmResult, String deploymentid, String constantFlowType, FlowMainPush flowMainPush, HashMap conditionMap) throws com.rockstar.flow.exception.FlowException { if (addConfirmResult.getConfirmResult() == null) { return "没有获取到confirmResult值"; } // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID; // String constantFlowType = ConstantFlowType.USE_MONEY; OperaterManage operaterManage = new OperaterManage(); FrameUser frameUser = new FrameUser(); try { frameUser.setId(ShiroUtils.getUser().getId()); } catch (Exception e) { frameUser.setId(addConfirmResult.getOperaterId()); } operaterManage.setUser(frameUser); // FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId()); if (!flowMainPush.getStatus().equals(0)) { if (flowMainPush.getStatus().equals(1)) { return "已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认"; } else if (flowMainPush.getStatus().equals(2)) { return "已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认"; } } {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突 FlowMainPush updateFlowMainPush = new FlowMainPush(); updateFlowMainPush.setId(flowMainPush.getId()); updateFlowMainPush.setStatus(1); updateFlowMainPush.setUpdatedAt(new Date()); updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); } FlowMain flowMain = this.selectByPrimaryKey(flowMainPush.getFlowMainId()); //当前任务流程 目的是获取节点名称,存起来nodeName String nodeName = flowMainPush.getNodeName() == null ? proActiService.getNodeName(flowMainPush) : flowMainPush.getNodeName(); if (nodeName == null) { return "异常:没有找到对应的任务...请通知管理员"; } String mypushUserKey = flowMainPush.getPushUserKey(); // flowMain. // Map conditionMap //审核通过,转下一步 boolean isEnd = false;//是否审核到最后一步了 if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok {// 发起流程引擎操作 并查看下一节点的操作要求 //1.如果当前角色是自己,就进行正常的审核流程 //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 Map stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap); if (stringStringMap == null) { return "流程引擎开启失败,请查看原因!"; } isEnd = stringStringMap.get("isEnd") == null ? false : true; } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 ok { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); if (isEnd) { flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束 } else { flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束 } flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 if (isEnd) { flowMainLog.setAuditType("2"); } else { flowMainLog.setAuditType("1"); } flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } // 3存入抄送人信息 ok if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //4.0判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); //逻辑删除本推送 { // FlowMainPush updateFlowMainPush = new FlowMainPush(); // updateFlowMainPush.setId(flowMainPush.getId()); // updateFlowMainPush.setStatus(1); // updateFlowMainPush.setUpdatedAt(new Date()); // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); } if (pushType.equals(1) || pushType.equals(2)) { //只要逻辑删除本推送 } else if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } //4添加新的推送人员 if (!isEnd) {//查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); // taskService.createTaskQuery().processInstanceId(); //查看总的数据流程 List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { { //获取推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = null; //'推送时彭总给的key值', String pushUserKey = null; UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (int i = 0; i < TaskList.size(); i++) { if (TaskList.get(i).getId().equals(taskDefinitionKey)) { myUserTask = TaskList.get(i); break; } } //判断是否存在串并联并修改推送状态 if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); if (listTask.size() > 1) { String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); if (s1.length >= 5) { String pushTypeNum = s1[4]; if ("0".equals(pushTypeNum)) { pushType = 2; } else if ("1".equals(pushTypeNum)) { pushType = 3; } } } else { pushType = 1; } } } FlowMainPush newflowMainPush = new FlowMainPush(); newflowMainPush.setFlowMainId(flowMain.getId()); newflowMainPush.setFormId(flowMain.getFormId()); {// 需要工作流引擎的支持 newflowMainPush.setPushUser(task.getAssignee());//推送人id' newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 newflowMainPush.setNodeName(myUserTask.getName()); newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', newflowMainPush.setFlowType(constantFlowType); newflowMainPush.setFlowPost(task.getAssignee()); ////2023年5月10日 修改成上面的了 张洮 // newflowMainPush.setFlowPost(operaterManage.getUser().getId()); newflowMainPush.setFlowId(flowMain.getFlowId()); newflowMainPush.setTaskId(task.getId()); } newflowMainPush.setUpMainLogId(flowMainLog.getId()); newflowMainPush.setUpdatedAt(new Date()); newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt()); newflowMainPush.setCreatedBy(operaterManage.getUser().getId()); newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy()); newflowMainPush.setGroupId(operaterManage.getUser().getGroupId()); newflowMainPush.setStatus(0); flowMainPushService.insert(newflowMainPush); } } } } } else if (addConfirmResult.getConfirmResult().equals("2")) {//退回发起人 ok {// 退回发起人 isEnd = true; // flowService.deleteInstance(flowMain.getFlowId(), "退回发起人"); //当前审核人/委托人代表的用户id String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush); if (myFrameUserId == null) { return null; } //当前审核人/委托人代表的用户 FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId); FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser()); // FrameUser currUser = operaterManage.getUser(); boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "no", "退回发起人", targetUser, myFrameUser, null); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(2);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("2");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("1"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //2.1添加抄送 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); //逻辑删除本推送 { // FlowMainPush updateFlowMainPush = new FlowMainPush(); // updateFlowMainPush.setId(flowMainPush.getId()); // updateFlowMainPush.setStatus(1); // updateFlowMainPush.setUpdatedAt(new Date()); // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); } if (pushType.equals(1) || pushType.equals(2)) { //只要逻辑删除本推送 } else if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } //4添加推送人(因为退回发起人之后 发起人不需要再审核,所以改成推送人就不要了,下面的注释掉了) {//查看各个任务 // List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); //// taskService.createTaskQuery().processInstanceId(); // //查看总的数据流程 // List TaskList = flowService.getTaskList(deploymentid); // for (Task task : listTask) { // UserTask myUserTask = null; // { // String taskDefinitionKey = task.getTaskDefinitionKey(); // for (int i = 0; i < TaskList.size(); i++) { // if (TaskList.get(i).getId().equals(taskDefinitionKey)) { // myUserTask = TaskList.get(i); // break; // } // } // //判断是否存在串并联并修改推送状态 // //'推送时彭总给的key值', // String pushUserKey = null; // if (myUserTask != null) { // pushUserKey = myUserTask.getCandidateGroups().get(0); // } // //'推送类型1单流程推送,2串联推送,3并联推送', // Integer pushType = 1; //// if (myUserTask != null) { //// pushUserKey = myUserTask.getCandidateGroups().get(0); //// if (listTask.size() > 1) { //// String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); //// if (s1.length >= 5) { //// String pushTypeNum = s1[4]; //// if ("0".equals(pushTypeNum)) { //// pushType = 2; //// } else if ("1".equals(pushTypeNum)) { //// pushType = 3; //// } //// //// } //// } else { //// pushType = 1; //// } //// } // FlowMainPush newflowMainPush = new FlowMainPush(); // newflowMainPush.setFlowMainId(flowMain.getId()); // newflowMainPush.setFormId(flowMain.getFormId()); // {// 需要工作流引擎的支持 // newflowMainPush.setPushUser(task.getAssignee());//推送人id' // newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 // newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 // newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', // newflowMainPush.setFlowType(constantFlowType); // newflowMainPush.setFlowPost(operaterManage.getUser().getId()); // newflowMainPush.setFlowId(flowMain.getFlowId()); // newflowMainPush.setTaskId(task.getId()); // } // newflowMainPush.setUpMainLogId(flowMainLog.getId()); // newflowMainPush.setUpdatedAt(new Date()); // newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt()); // newflowMainPush.setCreatedBy(operaterManage.getUser().getId()); // newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy()); // newflowMainPush.setGroupId(operaterManage.getUser().getGroupId()); // newflowMainPush.setStatus(0); // flowMainPushService.insert(newflowMainPush); // } // } } } } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点 FrameUser targetUser = null; {// 发起流程引擎操作 //当前审核人/委托人代表的用户id String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush); if (myFrameUserId == null) { return null; } //当前审核人/委托人代表的用户 FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId); FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId()); while ("4".equals(flowMainLog.getAuditResult())) { flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainLog.getUpMainLogId()); } targetUser = frameUserService.selectByPrimaryKey(flowMainLog.getAuditUser()); // FrameUser currUser = operaterManage.getUser(); boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "back", "退回上节点", targetUser, myFrameUser, null); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("3");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("1"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //2.1添加抄送 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); //逻辑删除本推送 { // FlowMainPush updateFlowMainPush = new FlowMainPush(); // updateFlowMainPush.setId(flowMainPush.getId()); // updateFlowMainPush.setStatus(1); // updateFlowMainPush.setUpdatedAt(new Date()); // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } //4添加新的推送人员 {//查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); // taskService.createTaskQuery().processInstanceId(); //查看总的数据流程 List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (int i = 0; i < TaskList.size(); i++) { if (TaskList.get(i).getId().equals(taskDefinitionKey)) { myUserTask = TaskList.get(i); break; } } //判断是否存在串并联并修改推送状态 //'推送时彭总给的key值', String pushUserKey = null; if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); } //'推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = 1; // if (myUserTask != null) { // pushUserKey = myUserTask.getCandidateGroups().get(0); // if (listTask.size() > 1) { // String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); // if (s1.length >= 5) { // String pushTypeNum = s1[4]; // if ("0".equals(pushTypeNum)) { // pushType = 2; // } else if ("1".equals(pushTypeNum)) { // pushType = 3; // } // // } // } else { // pushType = 1; // } // } FlowMainPush newflowMainPush = new FlowMainPush(); newflowMainPush.setFlowMainId(flowMain.getId()); newflowMainPush.setFormId(flowMain.getFormId()); {// 需要工作流引擎的支持 if (!task.getAssignee().equals(targetUser.getId())) { continue; } newflowMainPush.setPushUser(task.getAssignee());//推送人id' newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 newflowMainPush.setNodeName(myUserTask.getName()); newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', newflowMainPush.setFlowType(constantFlowType); newflowMainPush.setFlowPost(task.getAssignee()); ////2023年5月10日 修改成上面的了 张洮 // newflowMainPush.setFlowPost(operaterManage.getUser().getId()); newflowMainPush.setFlowId(flowMain.getFlowId()); newflowMainPush.setTaskId(task.getId()); } newflowMainPush.setUpMainLogId(flowMainLog.getId()); newflowMainPush.setUpdatedAt(new Date()); newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt()); newflowMainPush.setCreatedBy(operaterManage.getUser().getId()); newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy()); newflowMainPush.setGroupId(operaterManage.getUser().getGroupId()); newflowMainPush.setStatus(0); flowMainPushService.insert(newflowMainPush); } } } } } else if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 ok isEnd = true; {// 发起流程引擎操作 并结束该流程 flowService.deleteInstance(flowMain.getFlowId(), "结束流程"); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(2); //审核结果0无状态,1审核通过结束,2审核不通过结束 flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("5");// `audit_result` varchar(4) DEFAULT NULL COMMENT 审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,5,不同意且结束流程,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("2"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //3 存入抄送人信息 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //4.0逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); //逻辑删除本推送 { // FlowMainPush updateFlowMainPush = new FlowMainPush(); // updateFlowMainPush.setId(flowMainPush.getId()); // updateFlowMainPush.setStatus(1); // updateFlowMainPush.setUpdatedAt(new Date()); // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); } if (pushType.equals(1) || pushType.equals(2)) { //只要逻辑删除本推送 } else if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } } } if (isEnd) { return "ok_end"; } else { return "ok_noEnd"; } } /** * 通用方法,加载到流程业务模块 * * @return */ public AjaxResult doFlowMain(String ApplyTheme, String recordId, String recordRemark, String recordCcList, String processdefine, String deploymentid, Map conditionMap, String constantFlowTypeNAME, String constantFlowType,FrameUser currUser) throws com.rockstar.flow.exception.FlowException { // 存入流程主表 ok FlowMain flowMain = new FlowMain(); flowMain.setId(UUIDUtils.middleUUID()); // 进入流程引擎,开始启动流程 String processInstanceId = null; // 判断启动申请后是否结束 boolean isEnd = false; { //启动流程引擎 Map stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain.getId(),currUser, conditionMap); if (stringStringMap == null) { return AjaxResult.error("流程引擎开启失败,请查看原因!"); } processInstanceId = stringStringMap.get("processInstanceId"); if (stringStringMap.get("isEnd") != null) { isEnd = true; } } //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); { // conditionMap // if (conditionMap!=null) { // Object conditionMapString = JSONObject.toJSON(conditionMap); // flowMain.setConditionMap(conditionMapString.toString()); // } // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单 flowMain.setApplyTheme(ApplyTheme); flowMain.setFormId(recordId); flowMain.setApplyUser(currUser.getId()); flowMain.setDeptId(currUser.getDepartment()); //todo 判断是否结束 if (isEnd) { flowMain.setFlowStatus(3);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', flowMain.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束 } else { flowMain.setFlowStatus(1);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', flowMain.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束 } flowMain.setReturnStatus(0);//'0/null无状态,1已撤回并且已重新发起', flowMain.setCcList(null); flowMain.setFlowName(constantFlowTypeNAME); flowMain.setFlowType(constantFlowType); //当前流程邮递操作人(frame_user)id 去除岗位的设定 flowMain.setFlowPost(currUser.getId()); {// 需要工作流引擎的支持 flowMain.setFlowId(processInstanceId); flowMain.setTaskId(null); } flowMain.setLastMainLogId(flowMainLogUuid); flowMain.setUpdatedAt(new Date()); flowMain.setCreatedAt(flowMain.getUpdatedAt()); flowMain.setCreatedBy(currUser.getId()); flowMain.setUpdatedBy(flowMain.getCreatedBy()); flowMain.setGroupId(currUser.getGroupId()); flowMain.setStatus(0); if (!StringUtils.isEmpty(recordRemark)) { flowMain.setRemark(recordRemark); } this.insertWithoutId(flowMain); } // 存入流程日志表 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(recordId); flowMainLog.setAuditUser(currUser.getId()); //todo 判断是否结束 if (isEnd) { flowMainLog.setAuditType("2"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditContent("自审通过"); flowMainLog.setAuditResult("1"); } else { flowMainLog.setAuditType("0"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditContent(null); flowMainLog.setAuditResult(null); } flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(currUser.getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(processInstanceId); flowMainLog.setTaskId(null); flowMainLog.setNodeName(ConstantFlowType.nodeKeysName.get(1)); flowMainLog.setPushUserKey(ConstantFlowType.nodeKeysName.get(11)); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(null); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(currUser.getId()); flowMainLog.setGroupId(currUser.getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } // 存入抄送人信息 ok if (!StringUtils.isEmpty(recordCcList)) { String[] split = recordCcList.split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(currUser.getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(currUser.getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } // 存入推送人 //查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (int i = 0; i < TaskList.size(); i++) { if (TaskList.get(i).getId().equals(taskDefinitionKey)) { myUserTask = TaskList.get(i); break; } } //'推送时彭总给的key值', String pushUserKey = null; //'推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = null; if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); if (listTask.size() > 1) { String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); if (s1.length >= 5) { String pushTypeNum = s1[4]; if ("0".equals(pushTypeNum)) { pushType = 2; } else if ("1".equals(pushTypeNum)) { pushType = 3; } } } else { pushType = 1; } } FlowMainPush flowMainPush = new FlowMainPush(); flowMainPush.setFlowMainId(flowMain.getId()); flowMainPush.setFormId(recordId); {// 需要工作流引擎的支持 flowMainPush.setPushUser(task.getAssignee());//推送人id' flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 flowMainPush.setNodeName(myUserTask.getName()); flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', flowMainPush.setFlowType(constantFlowType); flowMainPush.setFlowPost(task.getAssignee()); //2023年5月10日 修改成上面的了 张洮 // flowMainPush.setFlowPost(currUser.getId()); flowMainPush.setFlowId(processInstanceId); flowMainPush.setTaskId(task.getId()); } flowMainPush.setUpMainLogId(flowMainLog.getId()); flowMainPush.setUpdatedAt(new Date()); flowMainPush.setCreatedAt(flowMainPush.getUpdatedAt()); flowMainPush.setCreatedBy(currUser.getId()); flowMainPush.setUpdatedBy(flowMainPush.getCreatedBy()); flowMainPush.setGroupId(currUser.getGroupId()); flowMainPush.setStatus(0); flowMainPushService.insert(flowMainPush); } } if (isEnd) { return AjaxResult.successData(1688, null); } else { return AjaxResult.success(); } } /** * 申请人撤回申请 * * @param flowMainid */ public AjaxResult recallApply(String flowMainid) { if (com.rockstar.util.StringUtils.isEmpty(flowMainid)) { return AjaxResult.error("数据不能为空"); } FlowMain flowMain = this.selectByPrimaryKey(flowMainid); //流转状态为审核中时,可以由发起人撤回。ok if (!flowMain.getFlowStatus().equals(1)) { return AjaxResult.error("流程状态不在审核中,请重新确认"); } String mypushUserKey = null; {//开始申请人撤回申请 //先搜索目前有哪些人在审核中 ,获取key // select * from flow_main_push WHERE flow_main_push.flow_main_id=#{flowMainId} and STATUS=0 FlowMainPushExample example = new FlowMainPushExample(); example.createCriteria().andFlowMainIdEqualTo(flowMain.getId()).andStatusEqualTo(0); List flowMainPushes = flowMainPushService.selectByExample(example); mypushUserKey = flowMainPushes.get(0).getPushUserKey(); //1.关闭所有推送人数据信息表 ok { flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(), flowMain.getId()); } //2.关闭主流程 ok {// 发起流程引擎操作 并结束该流程 try { flowService.deleteInstance(flowMain.getFlowId(), "申请人撤回申请_结束流程"); } catch (Exception e) { System.err.println("流程引擎异常"); e.printStackTrace(); // throw new RuntimeException(e); } } //3.关闭主流程表 ok //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMain.getId()); flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(ShiroUtils.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //4 添加日志表 FlowMainLog flowMainLog = new FlowMainLog(); {//其表单对应的流转历史该节点审核结果显示为”发起人撤回” // flowMainLogUuid flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(ShiroUtils.getUser().getId()); flowMainLog.setAuditContent(null); flowMainLog.setAuditResult(null); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("4"); flowMainLog.setFlowType(flowMain.getFlowType()); flowMainLog.setFlowPost(ShiroUtils.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(null); flowMainLog.setNodeName("发起人撤回"); flowMainLog.setPushUserKey(mypushUserKey);//发起人撤回时 当时的审核人所对应的角色 } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(flowMain.getLastMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(ShiroUtils.getUser().getId()); flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } } return AjaxResult.success(); } /** * 分页查询 * * @return */ public PageInfo list(Tablepar tablepar, FlowMain model, DateTrans dt) { PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = null;//modelMapper.selectByExample(getCondition(model,dt)); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public Object listAll(FlowMain model, DateTrans dt) { List list = null;//modelMapper.selectByExample(getCondition(model,dt)); return list; } @Override public int deleteByPrimaryKey(String ids) { List lista = Convert.toListStrArray(ids); FlowMainExample example = new FlowMainExample(); example.createCriteria().andIdIn(lista); return flowMainMapper.deleteByExample(example); } @Override public FlowMain selectByPrimaryKey(String id) { return flowMainMapper.selectByPrimaryKey(id); } @Override public int updateByPrimaryKeySelective(FlowMain record) { return flowMainMapper.updateByPrimaryKeySelective(record); } @Override public int updateByExampleSelective(FlowMain record, FlowMainExample example) { return flowMainMapper.updateByExampleSelective(record, example); } @Override public int updateByExample(FlowMain record, FlowMainExample example) { return flowMainMapper.updateByExample(record, example); } @Override public List selectByExample(FlowMainExample example) { return flowMainMapper.selectByExample(example); } @Override public long countByExample(FlowMainExample example) { return flowMainMapper.countByExample(example); } @Override public int deleteByExample(FlowMainExample example) { return flowMainMapper.deleteByExample(example); } public int insert(FlowMain record) { record.setId(UUIDUtils.middleUUID()); return insertWithoutId(record); } public int insertWithoutId(FlowMain record) { return flowMainMapper.insert(record); } @Override public int insertSelective(FlowMain record) { record.setId(UUIDUtils.middleUUID()); record.setCreatedAt(new Date()); return flowMainMapper.insertSelective(record); } public PageInfo hasDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"1", "2", "3", "5"}); PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.listByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public List findFrameRoleDatasByUserId(String userId, String roleType) { return flowMainExtendMapper.findFrameRoleDatasByUserId(userId, roleType); } public List findFrameUsersByRoleKey(String roleKey, String roleType) { List frameUsersByRoleKey = null; try { // 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+"'"); frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKey(roleKey, roleType); } catch (Exception e) { e.printStackTrace(); frameUsersByRoleKey = new ArrayList<>(); } return frameUsersByRoleKey; } public List findFrameUsersByRoleKeyAndGroup(String roleKey, String roleType, String groupId) { List frameUsersByRoleKey = null; try { frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKeyAndGroup(roleKey, roleType, groupId); } catch (Exception e) { e.printStackTrace(); frameUsersByRoleKey = new ArrayList<>(); } return frameUsersByRoleKey; } public PageInfo myApplylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.myApplylistByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } /** * 抄送事项 ok * web端开始页面查询,不同类型, 流程名称,主题,发起人查询 */ public PageInfo cclistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.cclistByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public PageInfo myEntrustlistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"4"}); PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.listByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } /** * 待办事项 * * @param tablepar * @param model * @param dt * @return */ public PageInfo toDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"1"}); PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.toDolistByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } /** * 委托代办事项 * * @param tablepar * @param model * @param dt * @return */ public PageInfo entrustToDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"2"}); PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.toDolistByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public List getFlowHistroyByFlowMainId(String flowMainId) { return flowMainExtendMapper.getFlowHistroyByFlowMainId(flowMainId); } public Integer numtoDolistByInfo(FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"1"}); return flowMainExtendMapper.numtoDolistByInfo(model, dt); } public PageInfo toDolisAndEntrusttByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"1", "2"}); // model.setAuditResult(new String[]{"2"}); PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize()); List list = flowMainExtendMapper.toDolistByInfo(model, dt); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } public Integer numtoDolisAndEntrusttByInfo(FlowMainIn model, DateTrans dt) { model.setAuditResult(new String[]{"1", "2"}); return flowMainExtendMapper.numtoDolistByInfo(model, dt); } public List getIMGFlowHistroyByFlowMainId(String flowMainId) { FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId); // 判断流程是哪种流程 String[] flowStep = null; { if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) { flowStep = ConstantFlowType.PAYMENT_FLOWSTEPS; } } //获取返回值 ArrayList imgFlowHistoryInfos = new ArrayList<>(); {//`flow_status` int(4) DEFAULT NULL COMMENT //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', if (flowMain.getFlowStatus().equals(1)) { //ok //需要找到最新推送人 //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', List pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainId); String pushUserKey = pushByFlowMainId.get(0).getPushUserKey(); for (int i = 0; i < flowStep.length; i++) { if (flowStep[i].startsWith(pushUserKey)) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } return imgFlowHistoryInfos; } else if (flowMain.getFlowStatus().equals(2)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', //需要找到最新操作日志 FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId); if (flowMainLog==null){ return null; } String pushUserKey = flowMainLog.getPushUserKey(); for (int i = 0; i < flowStep.length; i++) { if (flowStep[i].startsWith(pushUserKey)) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } return imgFlowHistoryInfos; } else if (flowMain.getFlowStatus().equals(3)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', //需要找到最新操作日志 FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId); if (flowMainLog==null){ return null; } String pushUserKey = flowMainLog.getPushUserKey(); for (int i = 0; i < flowStep.length; i++) { if (flowStep[i].startsWith(pushUserKey)) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); if ("1".equals(flowMainLog.getAuditResult())){//1,同意 imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfo.setIsPass("1"); }else{ imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 } imgFlowHistoryInfos.add(imgFlowHistoryInfo); } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } return imgFlowHistoryInfos; } else if (flowMain.getFlowStatus().equals(4)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', //判断是监控室撤回还是自己撤回 //需要找到最新操作日志 FlowMainLog flowMainLog= flowMainLogService.selectLastOneByFlowMainId(flowMainId); if (flowMainLog==null){ return null; } String pushUserKey = flowMainLog.getPushUserKey(); for (int i = 0; i < flowStep.length; i++) { if (flowStep[i].startsWith(pushUserKey)) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); if (flowMainLog.getAuditType().equals(5)){ //监控室撤回 imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 }else{ imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 } imgFlowHistoryInfos.add(imgFlowHistoryInfo); break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } return imgFlowHistoryInfos; } } return null; } public AjaxResult doFlowMainForPurchase(String ApplyTheme, String recordId, String recordRemark, String recordCcList, String processdefine, String deploymentid, Map conditionMap, String constantFlowTypeNAME, String constantFlowType,FrameUser currUser) throws com.rockstar.flow.exception.FlowException { // 存入流程主表 ok FlowMain flowMain = new FlowMain(); flowMain.setId(UUIDUtils.middleUUID()); String processInstanceId = null; // 判断申请人是否是主要领导,是的话直接通过,不启动流程,保存相关信息 boolean isEnd = false; List frameRoleDataList = findFrameRoleDatasByUserId(currUser.getId(), ConstantFlowType.ROLETYPE); for (FrameRoleData data : frameRoleDataList) { if(data.getRoleKey().equals("zyld")){ isEnd = true; } } // 进入流程引擎,开始启动流程 if(!isEnd) { //启动流程引擎 Map stringStringMap = proActiService.startPurchaseTask(processdefine, deploymentid, flowMain.getId(),currUser, conditionMap); if (stringStringMap == null) { return AjaxResult.error("流程引擎开启失败,请查看原因!"); } processInstanceId = stringStringMap.get("processInstanceId"); if (stringStringMap.get("isEnd") != null) { isEnd = true; } } //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); { flowMain.setApplyTheme(ApplyTheme); flowMain.setFormId(recordId); flowMain.setApplyUser(currUser.getId()); flowMain.setDeptId(currUser.getDepartment()); if (isEnd) { flowMain.setFlowStatus(3);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', flowMain.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束 } else { flowMain.setFlowStatus(1);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)', flowMain.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束 } flowMain.setReturnStatus(0);//'0/null无状态,1已撤回并且已重新发起', flowMain.setCcList(null); flowMain.setFlowName(constantFlowTypeNAME); flowMain.setFlowType(constantFlowType); //当前流程邮递操作人(frame_user)id 去除岗位的设定 flowMain.setFlowPost(currUser.getId()); {// 需要工作流引擎的支持 flowMain.setFlowId(processInstanceId); flowMain.setTaskId(null); } flowMain.setLastMainLogId(flowMainLogUuid); flowMain.setUpdatedAt(new Date()); flowMain.setCreatedAt(flowMain.getUpdatedAt()); flowMain.setCreatedBy(currUser.getId()); flowMain.setUpdatedBy(flowMain.getCreatedBy()); flowMain.setGroupId(currUser.getGroupId()); flowMain.setStatus(0); if (!StringUtils.isEmpty(recordRemark)) { flowMain.setRemark(recordRemark); } this.insertWithoutId(flowMain); } // 存入流程日志表 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(recordId); flowMainLog.setAuditUser(currUser.getId()); if (isEnd) { flowMainLog.setAuditType("2"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditContent("自审通过"); flowMainLog.setAuditResult("1"); } else { flowMainLog.setAuditType("0"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditContent(null); flowMainLog.setAuditResult(null); } flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(currUser.getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(processInstanceId); flowMainLog.setTaskId(null); flowMainLog.setNodeName(ConstantFlowType.nodeKeysName.get(1)); flowMainLog.setPushUserKey(ConstantFlowType.nodeKeysName.get(11)); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, // 因为感觉用不到,暂时不放进去 // flowMainLog.setNextPersons(); flowMainLog.setUpMainLogId(null); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(currUser.getId()); flowMainLog.setGroupId(currUser.getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } // 存入抄送人信息 ok if (!StringUtils.isEmpty(recordCcList)) { String[] split = recordCcList.split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(currUser.getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(currUser.getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } // 存入推送人 //查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (UserTask userTask : TaskList) { if (userTask.getId().equals(taskDefinitionKey)) { myUserTask = userTask; break; } } //'推送时彭总给的key值', String pushUserKey = null; //'推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = null; if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); if (listTask.size() > 1) { String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); if (s1.length >= 5) { String pushTypeNum = s1[4]; if ("0".equals(pushTypeNum)) { pushType = 2; } else if ("1".equals(pushTypeNum)) { pushType = 3; } } } else { pushType = 1; } } FlowMainPush flowMainPush = new FlowMainPush(); flowMainPush.setFlowMainId(flowMain.getId()); flowMainPush.setFormId(recordId); {// 需要工作流引擎的支持 flowMainPush.setPushUser(task.getAssignee());//推送人id' flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 flowMainPush.setNodeName(null!=myUserTask?myUserTask.getName():null); flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', flowMainPush.setFlowType(constantFlowType); flowMainPush.setFlowPost(task.getAssignee()); flowMainPush.setFlowId(processInstanceId); flowMainPush.setTaskId(task.getId()); } flowMainPush.setUpMainLogId(flowMainLog.getId()); flowMainPush.setUpdatedAt(new Date()); flowMainPush.setCreatedAt(flowMainPush.getUpdatedAt()); flowMainPush.setCreatedBy(currUser.getId()); flowMainPush.setUpdatedBy(flowMainPush.getCreatedBy()); flowMainPush.setGroupId(currUser.getGroupId()); flowMainPush.setStatus(0); flowMainPushService.insert(flowMainPush); } } if (isEnd) { return AjaxResult.successData(1688, null); } else { return AjaxResult.success(); } } public String doConfirmResultForPurchase(AddConfirmResult addConfirmResult, String deploymentid, String constantFlowType, FlowMainPush flowMainPush, HashMap conditionMap) throws com.rockstar.flow.exception.FlowException { if (addConfirmResult.getConfirmResult() == null) { return "没有获取到confirmResult值"; } OperaterManage operaterManage = new OperaterManage(); FrameUser frameUser = new FrameUser(); try { frameUser.setId(ShiroUtils.getUser().getId()); } catch (Exception e) { frameUser.setId(addConfirmResult.getOperaterId()); } operaterManage.setUser(frameUser); if (!flowMainPush.getStatus().equals(0)) { if (flowMainPush.getStatus().equals(1)) { return "已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认"; } else if (flowMainPush.getStatus().equals(2)) { return "已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认"; } } {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突 FlowMainPush updateFlowMainPush = new FlowMainPush(); updateFlowMainPush.setId(flowMainPush.getId()); updateFlowMainPush.setStatus(1); updateFlowMainPush.setUpdatedAt(new Date()); updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId()); flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush); } FlowMain flowMain = this.selectByPrimaryKey(flowMainPush.getFlowMainId()); //当前任务流程 目的是获取节点名称,存起来nodeName String nodeName = flowMainPush.getNodeName() == null ? proActiService.getNodeName(flowMainPush) : flowMainPush.getNodeName(); if (nodeName == null) { return "异常:没有找到对应的任务...请通知管理员"; } String mypushUserKey = flowMainPush.getPushUserKey(); //审核通过,转下一步 boolean isEnd = false;//是否审核到最后一步了 if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok {// 发起流程引擎操作 并查看下一节点的操作要求 Map stringStringMap = proActiService.passToRunPurchaseTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap); if (stringStringMap == null) { return "流程引擎开启失败,请查看原因!"; } isEnd = stringStringMap.get("isEnd") != null; } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 ok { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); if (isEnd) { flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束 } else { flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束 } flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 if (isEnd) { flowMainLog.setAuditType("2"); } else { flowMainLog.setAuditType("1"); } flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } // 3存入抄送人信息 ok if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //4.0判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } //4添加新的推送人员 if (!isEnd) {//查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); //查看总的数据流程 List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { { //获取推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = null; //'推送时彭总给的key值', String pushUserKey = null; UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (UserTask userTask : TaskList) { if (userTask.getId().equals(taskDefinitionKey)) { myUserTask = userTask; break; } } //判断是否存在串并联并修改推送状态 if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); if (listTask.size() > 1) { String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); if (s1.length >= 5) { String pushTypeNum = s1[4]; if ("0".equals(pushTypeNum)) { pushType = 2; } else if ("1".equals(pushTypeNum)) { pushType = 3; } } } else { pushType = 1; } } } FlowMainPush newflowMainPush = new FlowMainPush(); newflowMainPush.setFlowMainId(flowMain.getId()); newflowMainPush.setFormId(flowMain.getFormId()); {// 需要工作流引擎的支持 newflowMainPush.setPushUser(task.getAssignee());//推送人id' newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 newflowMainPush.setNodeName(myUserTask.getName()); newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', newflowMainPush.setFlowType(constantFlowType); newflowMainPush.setFlowPost(task.getAssignee()); newflowMainPush.setFlowId(flowMain.getFlowId()); newflowMainPush.setTaskId(task.getId()); } newflowMainPush.setUpMainLogId(flowMainLog.getId()); newflowMainPush.setUpdatedAt(new Date()); newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt()); newflowMainPush.setCreatedBy(operaterManage.getUser().getId()); newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy()); newflowMainPush.setGroupId(operaterManage.getUser().getGroupId()); newflowMainPush.setStatus(0); flowMainPushService.insert(newflowMainPush); } } } } } else if (addConfirmResult.getConfirmResult().equals("2")) {//退回发起人 ok {// 退回发起人 isEnd = true; //当前审核人/委托人代表的用户id String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush); if (myFrameUserId == null) { return null; } //当前审核人/委托人代表的用户 FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId); FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser()); flowService.runTask(flowMainPush.getTaskId(), null, "no", "退回发起人", targetUser, myFrameUser, null); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(2);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("2");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("1"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //2.1添加抄送 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } } } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点 FrameUser targetUser = null; {// 发起流程引擎操作 //当前审核人/委托人代表的用户id String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush); if (myFrameUserId == null) { return null; } //当前审核人/委托人代表的用户 FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId); FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId()); while ("4".equals(flowMainLog.getAuditResult())) { flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainLog.getUpMainLogId()); } targetUser = frameUserService.selectByPrimaryKey(flowMainLog.getAuditUser()); flowService.runTask(flowMainPush.getTaskId(), null, "back", "退回上节点", targetUser, myFrameUser, null); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("3");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("1"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //2.1添加抄送 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); //逻辑删除本推送 { flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } //4添加新的推送人员 {//查看各个任务 List listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list(); //查看总的数据流程 List TaskList = flowService.getTaskList(deploymentid); for (Task task : listTask) { UserTask myUserTask = null; { String taskDefinitionKey = task.getTaskDefinitionKey(); for (UserTask userTask : TaskList) { if (userTask.getId().equals(taskDefinitionKey)) { myUserTask = userTask; break; } } //判断是否存在串并联并修改推送状态 //'推送时彭总给的key值', String pushUserKey = null; if (myUserTask != null) { pushUserKey = myUserTask.getCandidateGroups().get(0); } //'推送类型1单流程推送,2串联推送,3并联推送', Integer pushType = 1; FlowMainPush newflowMainPush = new FlowMainPush(); newflowMainPush.setFlowMainId(flowMain.getId()); newflowMainPush.setFormId(flowMain.getFormId()); {// 需要工作流引擎的支持 if (!task.getAssignee().equals(targetUser.getId())) { continue; } newflowMainPush.setPushUser(task.getAssignee());//推送人id' newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 newflowMainPush.setNodeName(myUserTask.getName()); newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送 newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)', newflowMainPush.setFlowType(constantFlowType); newflowMainPush.setFlowPost(task.getAssignee()); newflowMainPush.setFlowId(flowMain.getFlowId()); newflowMainPush.setTaskId(task.getId()); } newflowMainPush.setUpMainLogId(flowMainLog.getId()); newflowMainPush.setUpdatedAt(new Date()); newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt()); newflowMainPush.setCreatedBy(operaterManage.getUser().getId()); newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy()); newflowMainPush.setGroupId(operaterManage.getUser().getGroupId()); newflowMainPush.setStatus(0); flowMainPushService.insert(newflowMainPush); } } } } } else if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 ok isEnd = true; {// 发起流程引擎操作 并结束该流程 flowService.deleteInstance(flowMain.getFlowId(), "结束流程"); } { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //1修改主表状态 { FlowMain flowMain1 = new FlowMain(); flowMain1.setId(flowMainPush.getFlowMainId()); flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回) flowMain1.setFlowResult(2); //审核结果0无状态,1审核通过结束,2审核不通过结束 flowMain1.setLastMainLogId(flowMainLogUuid); flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(operaterManage.getUser().getId()); this.updateByPrimaryKeySelective(flowMain1); } //2添加日志 ok FlowMainLog flowMainLog = new FlowMainLog(); { flowMainLog.setId(flowMainLogUuid); flowMainLog.setFlowMainId(flowMain.getId()); flowMainLog.setFormId(flowMain.getFormId()); flowMainLog.setAuditUser(operaterManage.getUser().getId()); flowMainLog.setAuditContent(addConfirmResult.getConfirmContent()); flowMainLog.setAuditResult("5");// `audit_result` varchar(4) DEFAULT NULL COMMENT 审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,5,不同意且结束流程,null没有审核)', //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态 flowMainLog.setAuditType("2"); flowMainLog.setFlowType(constantFlowType); flowMainLog.setFlowPost(operaterManage.getUser().getId()); {// 需要工作流引擎的支持 flowMainLog.setFlowId(flowMain.getFlowId()); flowMainLog.setTaskId(flowMainPush.getTaskId()); flowMainLog.setNodeName(nodeName); flowMainLog.setPushUserKey(mypushUserKey); } // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四, flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId()); flowMainLog.setCcList(null); flowMainLog.setCreatedAt(new Date()); flowMainLog.setCreatedBy(operaterManage.getUser().getId()); flowMainLog.setGroupId(operaterManage.getUser().getGroupId()); flowMainLog.setStatus(0); flowMainLogService.insertWithoutId(flowMainLog); } //3 存入抄送人信息 if (!StringUtils.isEmpty(addConfirmResult.getCcList())) { String[] split = addConfirmResult.getCcList().split(","); for (String ccId : split) { if (!StringUtils.isEmpty(ccId)) { FlowMainCc flowMainCc = new FlowMainCc(); flowMainCc.setFlowMainId(flowMain.getId()); flowMainCc.setCcUser(ccId); //选择抄送人时的记录表id(flow_main_log):例如:112122 flowMainCc.setMainLogIds(flowMainLog.getId()); flowMainCc.setUpdatedAt(new Date()); flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt()); flowMainCc.setCreatedBy(operaterManage.getUser().getId()); flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy()); flowMainCc.setGroupId(operaterManage.getUser().getGroupId()); flowMainCc.setStatus(0); flowMainCcService.insert(flowMainCc); } } } //4.0逻辑删除旧的推送人 { //todo推送类型1单流程推送,2串联推送,3并联推送 Integer pushType = flowMainPush.getPushType(); if (pushType.equals(3)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态status改成2状态值 flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId()); } } } } if (isEnd) { return "ok_end"; } else { return "ok_noEnd"; } } }