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.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.in.TagerUserAndFlowRole; 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 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.getNodeUserRole(); if (mypushUserKey == null) { mypushUserKey = flowMainPush.getPushUserKey(); } // flowMain. // Map conditionMap //审核通过,转下一步 boolean isEnd = false;//是否审核到最后一步了 String roleType = null; //节点key 例如dept_superior_1_0_1 { //todo 先要判断是否是会签,会签要过滤一下, (后面的部分下面完成了)不是会签的就把其他待审核数据逻辑删除 // 1:单流程推送 // 2:串联审核(会签) // 3:并联推送 // 步骤1,判断是否是会签 //2,如果是,判断是否是同意 //3,如果不是同意就跳出本判断,如果是同意就判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息 Integer pushType = flowMainPush.getPushType(); if (new Integer(2).equals(pushType)) { if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok // 判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息 { List pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainPush.getFlowMainId()); if (pushByFlowMainId != null && !pushByFlowMainId.isEmpty() && pushByFlowMainId.size() > 0) { //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); //发现不需要修改setLastMainLogId,因为这个字段是保存:最后一次上个节点审核时的表(flow_main_log)id // { // FlowMain flowMain1 = new FlowMain(); // flowMain1.setId(flowMainPush.getFlowMainId()); // flowMain1.setLastMainLogId(flowMainLogUuid); // this.updateLastMainLogId(flowMainPush.getFlowMainId(),flowMainLogUuid);//修改主表的日志最后记录 // } //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申请人结束状态 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); } } } return "ok_noEnd"; } } } } } if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok {// 发起流程引擎操作 并查看下一节点的操作要求 //1.如果当前角色是自己,就进行正常的审核流程 //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 Map stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap, flowMain); if (stringStringMap == null) { return "流程引擎开启失败,请查看原因!"; } isEnd = stringStringMap.get("isEnd") == null ? false : true; //可能会传roleType,但是如果没有传就在pushuser中进行查询 roleType = stringStringMap.get("roleType"); } { //存入流程日志表的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 (roleType == null) {//只有在首次申请,且直属上级还有更高级的身份才会没有,但是还是在直属上级这里进行并联审核 if (pushUserKey != null) { 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 = 2; } } } else { String[] roleTypeArray = roleType.split("_"); String pushTypeNum = roleTypeArray[roleTypeArray.length - 1]; if ("1".equals(pushTypeNum)) { pushType = 1; } else if ("2".equals(pushTypeNum)) { pushType = 2; } else if ("3".equals(pushTypeNum)) { pushType = 3; } else { pushType = 2; } } } FlowMainPush newflowMainPush = new FlowMainPush(); newflowMainPush.setFlowMainId(flowMain.getId()); newflowMainPush.setFormId(flowMain.getFormId()); {// 需要工作流引擎的支持 newflowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id' newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 newflowMainPush.setNodeName(myUserTask.getName()); { // flowMainPush.setNodeUserRole(pushUserKey); // flowMainPush.setNodeName(myUserTask.getName()); // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中 newflowMainPush = this.setPushUserKeyAndNodeName(newflowMainPush, task.getAssignee().split(",")[0], flowMain, roleType); } 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); {//插入推送人前进行判断 if (new Integer(1).equals(newflowMainPush.getPushType())) { flowMainPushService.insert(newflowMainPush); } else { String[] splitIds = task.getAssignee().split(","); for (int i = 0; i < splitIds.length; i++) { newflowMainPush.setPushUser(splitIds[i]); 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)) { //只要逻辑删除本推送 } else if (pushType.equals(3) || pushType.equals(2)) {//3是并签//2是会签 //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态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")) {//退回上节点(todo 退回上个节点有问题,如果是跳跃审核的还有进行编辑,目前只支持不能跳跃审核的节点) 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)) { //只要逻辑删除本推送 } else if (pushType.equals(3) || pushType.equals(2)) { //要逻辑删除自己和其他推送 //将其他并联推送的人员推送状态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, String deptId, String tagerUserId) throws com.rockstar.flow.exception.FlowException { // 存入流程主表 ok FlowMain flowMain = new FlowMain(); { flowMain.setId(UUIDUtils.middleUUID()); flowMain.setFormId(recordId); flowMain.setFlowType(constantFlowType); if (ConstantFlowType.isMoreDept) { if (deptId == null) { return AjaxResult.error("请选择部门信息"); } flowMain.setDeptId(deptId); } else { flowMain.setDeptId(currUser.getDepartment()); } flowMain.setApplyTheme(ApplyTheme); flowMain.setApplyUser(currUser.getId()); flowMain.setUpdatedAt(new Date()); flowMain.setCreatedAt(flowMain.getUpdatedAt()); flowMain.setCreatedBy(currUser.getId()); flowMain.setUpdatedBy(flowMain.getCreatedBy()); flowMain.setGroupId(currUser.getGroupId()); if (!StringUtils.isEmpty(recordRemark)) { flowMain.setRemark(recordRemark); } } // 进入流程引擎,开始启动流程 String processInstanceId = null; // 判断启动申请后是否结束 boolean isEnd = false; currUser = frameUserService.selectByPrimaryKey(currUser.getId()); String roleType = null; //节点key 例如dept_superior_1_0_1 { //启动流程引擎 Map stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain, currUser, conditionMap, tagerUserId); if (stringStringMap == null) { return AjaxResult.error("流程引擎开启失败,请查看原因!"); } processInstanceId = stringStringMap.get("processInstanceId"); if (stringStringMap.get("isEnd") != null) { isEnd = true; } //可能会传roleType,但是如果没有传就在pushuser中进行查询 roleType = stringStringMap.get("roleType"); } //存入流程日志表的id String flowMainLogUuid = UUIDUtils.middleUUID(); { // conditionMap // if (conditionMap!=null) { // Object conditionMapString = JSONObject.toJSON(conditionMap); // flowMain.setConditionMap(conditionMapString.toString()); // } // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单 // 判断是否结束 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); //当前流程邮递操作人(frame_user)id 去除岗位的设定 flowMain.setFlowPost(currUser.getId()); {// 需要工作流引擎的支持 flowMain.setFlowId(processInstanceId); flowMain.setTaskId(null); } flowMain.setLastMainLogId(flowMainLogUuid); flowMain.setStatus(0); 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 (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 (roleType == null) { if (pushUserKey != null) { if (listTask.size() > 1) { String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_"); if (s1.length >= 5) { // 现在发现这个有问题,因为当前审核人的下个节点审核可能会跳节点,所以要找到下个审核人对应的节点才能判断推送类型,现在存的推送类型只是流程引擎中下个节点的推送类型,没有意义 String pushTypeNum = s1[4]; if ("1".equals(pushTypeNum)) { pushType = 1; } else if ("2".equals(pushTypeNum)) { pushType = 2; } else if ("3".equals(pushTypeNum)) { pushType = 3; } } } else { pushType = 2; } } } else { String[] roleTypeArray = roleType.split("_"); String pushTypeNum = roleTypeArray[roleTypeArray.length - 1]; if ("1".equals(pushTypeNum)) { pushType = 1; } else if ("2".equals(pushTypeNum)) { pushType = 2; } else if ("3".equals(pushTypeNum)) { pushType = 3; } else { pushType = 2; } } FlowMainPush flowMainPush = new FlowMainPush(); flowMainPush.setFlowMainId(flowMain.getId()); flowMainPush.setFormId(recordId); {// 需要工作流引擎的支持 flowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id' flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值 flowMainPush.setNodeName(myUserTask.getName()); { // flowMainPush.setNodeUserRole(pushUserKey); // flowMainPush.setNodeName(myUserTask.getName()); // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中 flowMainPush = this.setPushUserKeyAndNodeName(flowMainPush, task.getAssignee().split(",")[0], flowMain, roleType); } 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); {//插入推送人前进行判断 if (new Integer(1).equals(flowMainPush.getPushType())) { flowMainPushService.insert(flowMainPush); } else { String[] splitIds = task.getAssignee().split(","); for (int i = 0; i < splitIds.length; i++) { flowMainPush.setPushUser(splitIds[i]); flowMainPushService.insert(flowMainPush); } } } } } if (isEnd) { return AjaxResult.successData(1688, null); } else { return AjaxResult.success(); } } //做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称 private FlowMainPush setPushUserKeyAndNodeName(FlowMainPush flowMainPush, String pushUserId, FlowMain flowMain, String roleType) { // flowMainPush.setNodeUserRole(pushUserKey); // flowMainPush.setNodeName(myUserTask.getName()); if (roleType == null) { FrameUser frameUser = frameUserService.selectByPrimaryKey(pushUserId); boolean isCheck = false;//判断是否是出纳类型,如果是出纳类型就再查一下 for (String s : ConstantFlowType.FLOW_ROLES_CHECK) { if (flowMainPush.getPushUserKey().startsWith(s)) { isCheck = true; break; } } if (isCheck) { flowMainPush.setNodeUserRole(flowMainPush.getPushUserKey()); // 使用原来的设置 flowMainPush.setNodeName(myUserTask.getName()); } else { String currRole = proActiService.getCurrRole(frameUser, flowMain); if (currRole == null || currRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[0])) {//如果判断只是普通员工就还是设置成原来的(流程设置的) currRole = ConstantFlowType.FLOW_ROLES_DEPT[1];//flowMainPush.getPushUserKey();//ConstantFlowType.FLOW_ROLES_DEPT[1]; } flowMainPush.setNodeUserRole(currRole); flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(currRole)); } } else { flowMainPush.setNodeUserRole(roleType); flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(proActiService.getSetRurrRole(roleType))); } return flowMainPush; } /** * 申请人撤回申请 * * @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); } /** * 获取流程步骤(前端用) todo 新增流程要在这里加_步骤3 * * @return */ public String[] getFlowStep(FlowMain flowMain) { String[] flowStep = null; { if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) { flowStep = ConstantFlowType.ADD_WORK_FLOWSTEPS; }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) { flowStep = ConstantFlowType.PAYMENT_FLOWSTEPS; } } return flowStep; } /** * 获取流程步骤(后端查询各个节点名称用),逻辑同上 todo 新增流程要在这里加_步骤2 * * @param flowMain(就用了其中的getFlowType和getFormId方法) * @return */ public String[] getOnlyFlowFlowStep(FlowMain flowMain) { String[] flowStep = null; { if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) { flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS; }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) { flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS; } } return flowStep; } /** * 获取全流程信息 todo 新增流程要在这里加_步骤1 * * @param flowType * @return */ public String[] getOnlylowStepAll(String flowType) { String[] flowStep = null; { if (flowType.equals(ConstantFlowType.ADD_WORK)) { flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS_ALL; }else if (flowType.equals(ConstantFlowType.PAYMENT)) { flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS_ALL; } } return flowStep; } /** * 前端流程图使用查看各个流程节点目前的情况 * * @param flowMainId * @return */ public List getIMGFlowHistroyByFlowMainId(String flowMainId) { FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId); // 判断流程是哪种流程 String[] flowStep = this.getFlowStep(flowMain); //获取返回值 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).getNodeUserRole(); if (pushUserKey == null) { pushUserKey = pushByFlowMainId.get(0).getPushUserKey(); } boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息 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); isLastLogFind = true; break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } if (!isLastLogFind) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(pushUserKey); imgFlowHistoryInfo.setType("3");// 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(); boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息 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); isLastLogFind = true; break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } if (!isLastLogFind) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(pushUserKey); imgFlowHistoryInfo.setType("2");// 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(); boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息 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); isLastLogFind = true; break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } if (!isLastLogFind) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(pushUserKey); 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); } // 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(); boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息 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); isLastLogFind = true; break; } else { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(flowStep[i]); imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程 imgFlowHistoryInfos.add(imgFlowHistoryInfo); } } if (!isLastLogFind) { IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo(); imgFlowHistoryInfo.setNodeKey(pushUserKey); 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); } // return imgFlowHistoryInfos; } } {//查询操作记录,将操作过的设置isjump为false,默认isjump为true List flowMainLogs = flowMainLogService.selectPassListByFlowMainId(flowMainId); for (int i = 0; i < imgFlowHistoryInfos.size(); i++) { IMGFlowHistoryInfo imgFlowHistoryInfo = imgFlowHistoryInfos.get(i); if (i == 0) { imgFlowHistoryInfo.setJump(false); } else if (i == (imgFlowHistoryInfos.size() - 1)) { imgFlowHistoryInfo.setJump(false); } else { for (FlowMainLog flowMainLog : flowMainLogs) { // FlowMainLog flowMainLog if (flowMainLog.getPushUserKey().startsWith(imgFlowHistoryInfo.getNodeKey())) { imgFlowHistoryInfo.setJump(false); break; } } } } } return imgFlowHistoryInfos; } /** * 进行串并联申请,将id合并起来,用逗号,隔开 * * @return */ public FrameUser getFrameUsersId(String roleType, List targetUserList, FrameUser targetUser) { String[] roleTypeArray = roleType.split("_"); String key_e = roleTypeArray[roleTypeArray.length - 1]; if ("1".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送 } else { String ids = ""; for (FrameUser frameUser : targetUserList) { ids += ("," + frameUser.getId()); } targetUser.setId(ids.substring(1)); } return targetUser; } /** * 查询领导的全流程查看对应的目标用户,如果未来有需求可以将出纳等财务的角色也放进去 * //要进行从本角色(部门已经查过了,就是从领导角色开始查)开始的本流程的全角色查询 * 还有查全流程如果是会签就要改成并签了,因为之前支线流程里面没有找到对应节点 * * @param flowMain * @param flowRole * @return */ public TagerUserAndFlowRole getAllUpRoleTargetUsers(FlowMain flowMain, String flowRole) { String[] flowStep = this.getOnlylowStepAll(flowMain.getFlowType()); return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, true); } /** * 合并两个方法 * isNeed3To2:是否需要并签改串签 * * @return */ public TagerUserAndFlowRole getAllUpRoleTargetUsers_getUpRoleTargetUsers(String[] flowStep, FlowMain flowMain, String flowRole, boolean isNeed3To2) { TagerUserAndFlowRole tagerUserAndFlowRole = new TagerUserAndFlowRole(); String targetRole = null;//找目标用户的角色 FrameUser targetUser = null;//目标人 int i = 0; boolean isFindStartRole = false; for (; i < flowStep.length; i++) { if (!isFindStartRole) { if (flowStep[i].startsWith(flowRole)) { isFindStartRole = true; targetRole = flowStep[i]; //例如 flow_fgld_1_0_1 String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld {//查看谁是对应角色并查找对应的人 for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) { if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导 //查看谁是对应角色并查找对应的人 String role = ConstantFlowType.ROLES[j]; //例如 fgld // 进行查询目标人 List targetUserList = this.findFrameUsersByRoleKeyAndGroup( role, ConstantFlowType.ROLETYPE, flowMain.getGroupId()); if (!targetUserList.isEmpty() && targetUserList.size() >= 1) { targetUser = targetUserList.get(0); //进行串并联申请 { targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser); } } break; } } if (targetUser == null) { //进行下个角色查询 } else { tagerUserAndFlowRole.setFrameUser(targetUser); if (isNeed3To2) {//是否需要并签改串签 String[] roleTypeArray = targetRole.split("_"); String key_e = roleTypeArray[roleTypeArray.length - 1]; if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送 targetRole = targetRole.substring(0, targetRole.length() - 1) + "2"; } } tagerUserAndFlowRole.setFlowRole(targetRole); tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep); return tagerUserAndFlowRole; } } } } else { targetRole = flowStep[i]; //例如 flow_fgld_1_0_1 String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld {//查看谁是对应角色并查找对应的人 for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) { if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导 //查看谁是对应角色并查找对应的人 String role = ConstantFlowType.ROLES[j]; //例如 fgld // 进行查询目标人 List targetUserList = this.findFrameUsersByRoleKeyAndGroup( role, ConstantFlowType.ROLETYPE, flowMain.getGroupId()); if (!targetUserList.isEmpty() && targetUserList.size() >= 1) { targetUser = targetUserList.get(0); //进行串并联申请 { targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser); } } break; } } if (targetUser == null) { //进行下个角色查询 } else { tagerUserAndFlowRole.setFrameUser(targetUser); if (isNeed3To2) {//是否需要并签改串签 String[] roleTypeArray = targetRole.split("_"); String key_e = roleTypeArray[roleTypeArray.length - 1]; if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送 targetRole = targetRole.substring(0, targetRole.length() - 1) + "2"; } } tagerUserAndFlowRole.setFlowRole(targetRole); tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep); return tagerUserAndFlowRole; } } } } if (targetRole == null) { return tagerUserAndFlowRole; } else { return tagerUserAndFlowRole; } } /** * 根据传入的步骤进行查询(注意,有可能有出纳等财务角色,目前会剔除,默认出纳等财务必须有) * //查询对应设置角色开始的角色 * * @param flowRole * @param onlyFlowFlowStep * @return */ public TagerUserAndFlowRole getUpRoleTargetUsers(FlowMain flowMain, String flowRole, String[] onlyFlowFlowStep) { String[] flowStep = onlyFlowFlowStep; return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, false); } }