|
|
@ -99,25 +99,284 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
private ProcessEngine processEngine; |
|
|
|
|
|
|
|
public ResultBean<UpdateFlowFieldVo> businessStartProcessInstanceById(BusinessVariables bv) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
// 获取流程定义ID和发起人ID
|
|
|
|
String procDefId = bv.getModelId(); |
|
|
|
String userSid = bv.getUserSid(); |
|
|
|
// 获取传入的变量
|
|
|
|
Map<String, Object> variables = bv.getFormVariables(); |
|
|
|
Map<String, Object> variablesSeconds = bv.getFormVariables(); |
|
|
|
String nextNodeUserSids = ""; |
|
|
|
List<String> userSidForNextNode = new ArrayList<>(); |
|
|
|
if (StringUtils.isBlank(nextNodeUserSids)) { |
|
|
|
userSidForNextNode = getNextNodeUser(bv).getData(); |
|
|
|
variables.put("approvers", userSidForNextNode); |
|
|
|
} else { |
|
|
|
nextNodeUserSids = bv.getNextNodeUserSids(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据流程定义ID查询最新的流程定义
|
|
|
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
|
|
|
.processDefinitionId(procDefId) |
|
|
|
.latestVersion() |
|
|
|
.singleResult(); |
|
|
|
|
|
|
|
// 如果流程被挂起,返回错误信息
|
|
|
|
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { |
|
|
|
return rb.setMsg("流程已被挂起,请先激活流程"); |
|
|
|
} |
|
|
|
|
|
|
|
// 设置发起人信息
|
|
|
|
ResultBean<SysUserVo> sysUserVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
SysUserVo sysUser = sysUserVoResultBean.getData(); |
|
|
|
identityService.setAuthenticatedUserId(sysUser.getSid()); |
|
|
|
variables.put(ProcessConstants.PROCESS_INITIATOR, userSid); |
|
|
|
variables.put(ProcessConstants.USER_TYPE_ASSIGNEE, userSid); |
|
|
|
|
|
|
|
// 启动流程实例
|
|
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); |
|
|
|
|
|
|
|
// 获取第一步任务并设置任务执行人和意见
|
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); |
|
|
|
if (Objects.nonNull(task)) { |
|
|
|
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.START.getType(), |
|
|
|
sysUser.getName() + "发起流程申请"); |
|
|
|
taskService.setAssignee(task.getId(), userSid); |
|
|
|
taskService.complete(task.getId(), variables); |
|
|
|
} |
|
|
|
String id_ = ""; |
|
|
|
String name_ = ""; |
|
|
|
String task_def_key_ = ""; |
|
|
|
//查询当前实例的最新待办任务
|
|
|
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); |
|
|
|
if (StringUtils.isBlank(nextNodeUserSids)) { |
|
|
|
//遍历待办任务
|
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
String isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
if ("会签任务".equals(isMultiInstanceTask) || "或签任务".equals(isMultiInstanceTask)) { |
|
|
|
String approver = getApproverForTask(userSidForNextNode, i); |
|
|
|
taskService.claim(task2.getId(), approver); |
|
|
|
} else { |
|
|
|
nextNodeUserSids = userSidForNextNode.get(0); |
|
|
|
} |
|
|
|
id_ = task2.getId(); |
|
|
|
task_def_key_ = task2.getTaskDefinitionKey(); |
|
|
|
name_ = task2.getName(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
Task task2 = tasks.get(0); |
|
|
|
id_ = task2.getId(); |
|
|
|
task_def_key_ = task2.getTaskDefinitionKey(); |
|
|
|
name_ = task2.getName(); |
|
|
|
|
|
|
|
} |
|
|
|
//提交前传入下一环节待办人
|
|
|
|
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextNodeUserSids)) { |
|
|
|
return handleAutomaticApproval(bv, task, id_, task_def_key_, variables, variablesSeconds, processDefinition); |
|
|
|
} |
|
|
|
// 如果申请人与下一环节审批人相同,则自动审批
|
|
|
|
if (bv.getUserSid().equals(nextNodeUserSids)) { |
|
|
|
return handleSelfApproval(bv, task, id_, task_def_key_, variables, variablesSeconds, processDefinition); |
|
|
|
} |
|
|
|
// 实例化 UpdateFlowFieldVo
|
|
|
|
UpdateFlowFieldVo updateFlowFieldVo = new UpdateFlowFieldVo(); |
|
|
|
updateFlowFieldVo.setProcInsId(task.getProcessInstanceId()); |
|
|
|
updateFlowFieldVo.setNodeState(name_); |
|
|
|
updateFlowFieldVo.setTaskId(id_); |
|
|
|
updateFlowFieldVo.setTaskDefKey(task_def_key_); |
|
|
|
updateFlowFieldVo.setProcDefId(bv.getModelId()); |
|
|
|
updateFlowFieldVo.setSid(bv.getBusinessSid()); |
|
|
|
updateFlowFieldVo.setName(processDefinition.getName()); |
|
|
|
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables bv, boolean b) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
UpdateFlowFieldVo vo = new UpdateFlowFieldVo(); |
|
|
|
//获取表单中的参数
|
|
|
|
Map<String, Object> formVariables = bv.getFormVariables(); |
|
|
|
formVariables = formVariables == null ? new HashMap<>() : formVariables; |
|
|
|
formVariables.put("businessSid", bv.getBusinessSid()); |
|
|
|
String nextUserSid = bv.getNextNodeUserSids(); |
|
|
|
String taskId = bv.getTaskId(); |
|
|
|
String userSid = bv.getUserSid(); |
|
|
|
String instanceId = bv.getInstanceId(); |
|
|
|
String comment = bv.getComment(); |
|
|
|
String nodeState = ""; |
|
|
|
String taskDefKey = ""; |
|
|
|
String orgPath = bv.getOrgSidPath(); |
|
|
|
String service = (String) formVariables.get("service"); |
|
|
|
String ydfOrgPath = (String) formVariables.get("ydfOrgPath"); |
|
|
|
List<String> userSidForNextNode = new ArrayList<>(); |
|
|
|
|
|
|
|
//设置下一环节审批人是否自动审批通过,默认否
|
|
|
|
boolean contains = false; |
|
|
|
//设置是否是管理员自动审批,默认否
|
|
|
|
boolean adminContains = false; |
|
|
|
//查询任务id为taskId的任务是否存在
|
|
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|
|
|
if (Objects.isNull(task)) { |
|
|
|
return rb.setMsg("任务不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
String assignee = task.getAssignee(); |
|
|
|
if (b && (StringUtils.isNotBlank(assignee) && assignee.indexOf(userSid) < 0)) { |
|
|
|
return rb.setMsg("当前用户不是环节的待办人,不能进行办理操作!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(nextUserSid)) { |
|
|
|
if ("公司间调车".equals(service) && "Activity_0695qh4".equals(bv.getTaskDefKey())) { |
|
|
|
bv.setOrgSidPath(ydfOrgPath); |
|
|
|
} |
|
|
|
ResultBean<List<String>> listResultBean = getNextNodeUserSidsOfSubmit(bv); |
|
|
|
if (!listResultBean.getSuccess()) { |
|
|
|
nextUserSid = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId(); |
|
|
|
adminContains = true; |
|
|
|
} else { |
|
|
|
userSidForNextNode = listResultBean.getData(); |
|
|
|
formVariables.put("approvers", listResultBean.getData()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//若下一环节用户与系统管理员一致,则自动审批
|
|
|
|
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextUserSid)) { |
|
|
|
adminContains = true; |
|
|
|
} |
|
|
|
} |
|
|
|
//是否是多实例任务
|
|
|
|
String isMultiInstanceTask = isMultiInstanceTask(task); |
|
|
|
boolean isMultiInstanceTaskNext = false; |
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
|
adminContains = false; |
|
|
|
//加签
|
|
|
|
Authentication.setAuthenticatedUserId(userSid); |
|
|
|
taskService.addComment(taskId, instanceId, |
|
|
|
FlowComment.DELEGATE.getType(), comment); |
|
|
|
taskService.resolveTask(taskId, formVariables); |
|
|
|
nodeState = task.getName(); |
|
|
|
taskDefKey = task.getTaskDefinitionKey(); |
|
|
|
} else { |
|
|
|
boolean checkTask = false;//是否要查询当前任务是否是会签环节
|
|
|
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(instanceId).list(); |
|
|
|
if (tasks.size() == 1 || "或签任务".equals(isMultiInstanceTask)) { |
|
|
|
checkTask = true; |
|
|
|
} |
|
|
|
//当前任务办理完成
|
|
|
|
taskService.addComment(taskId, instanceId, FlowComment.NORMAL.getType(), comment); |
|
|
|
log.error("taskid:{},userSid:{}", taskId, userSid); |
|
|
|
log.error("formVariables:{}", JSON.toJSONString(formVariables)); |
|
|
|
taskService.setAssignee(taskId, userSid); |
|
|
|
taskService.complete(taskId, formVariables); |
|
|
|
//查询办理完后的最新待办任务
|
|
|
|
tasks = taskService.createTaskQuery().processInstanceId(instanceId).list(); |
|
|
|
if (checkTask) {//单一审批任务或者或签任务时或者会签的最后一个待办任务
|
|
|
|
if (tasks.size() > 0) { |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
if ("会签任务".equals(isMultiInstanceTask) || "或签任务".equals(isMultiInstanceTask)) { |
|
|
|
taskService.claim(task2.getId(), userSidForNextNode.get(i)); // 由候选人认领任务
|
|
|
|
isMultiInstanceTaskNext = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
//查询下一环节用户是否有转办人
|
|
|
|
nextUserSid = change(nextUserSid, bv.getInstanceId()); |
|
|
|
taskService.setAssignee(task2.getId(), nextUserSid);//将下一环节用户放入流程中
|
|
|
|
} |
|
|
|
vo.setTaskId(task2.getId()); |
|
|
|
//在act_ru_variable表中增加环节上的业务参数的变量
|
|
|
|
taskService.setVariablesLocal(task2.getId(), formVariables); |
|
|
|
nodeState = task2.getName(); |
|
|
|
taskDefKey = task2.getTaskDefinitionKey(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
nodeState = FlowComment.SETTLE.getRemark(); |
|
|
|
taskDefKey = "Event_end"; |
|
|
|
vo.setNodeState(FlowComment.SETTLE.getRemark()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if (!isMultiInstanceTaskNext) { |
|
|
|
//获取该流程所有要走的环节节点
|
|
|
|
List<FlowElement> flowElements = calApprovePath(bv.getModelId(), |
|
|
|
bv.getFormVariables()); |
|
|
|
for (int i = 0; i < flowElements.size(); i++) { |
|
|
|
FlowElement flowElement = flowElements.get(i); |
|
|
|
String id = flowElement.getId(); |
|
|
|
// 如果当前环节匹配taskDefKey,并且后续环节存在
|
|
|
|
if (taskDefKey.equals(id) && i + 1 < flowElements.size()) { |
|
|
|
FlowElement nextFlowElement = flowElements.get(i + 1); // 获取下一个环节
|
|
|
|
List<SysUserVo> nextUserList = getUserListFromFlowElement(nextFlowElement, orgPath); // 获取下一个环节的用户列表
|
|
|
|
|
|
|
|
// 获取下下一个环节的用户列表(如果存在)
|
|
|
|
List<SysUserVo> nextNextUserList = new ArrayList<>(); |
|
|
|
if (i + 2 < flowElements.size()) { |
|
|
|
FlowElement nextNextFlowElement = flowElements.get(i + 2); // 获取下下一个环节
|
|
|
|
nextNextUserList = getUserListFromFlowElement(nextNextFlowElement, orgPath); // 获取下下一个环节的用户列表
|
|
|
|
} |
|
|
|
|
|
|
|
// 如果下一个环节只有一个用户,并且其sid与下一级相同,则设置contains为true
|
|
|
|
if (nextUserList.size() == 1 && nextUserList.get(0).getSid().equals(nextUserSid)) { |
|
|
|
contains = true; // 确定自动审批
|
|
|
|
break; // 跳出循环,不再检查后续环节
|
|
|
|
} |
|
|
|
|
|
|
|
// 如果下下一个环节没有用户,且下下下一个环节与下一级相同,设置contains为true
|
|
|
|
if (nextUserList.isEmpty() && nextNextUserList.size() == 1 && nextNextUserList.get(0).getSid().equals(nextUserSid)) { |
|
|
|
contains = true; // 确定自动审批
|
|
|
|
break; // 跳出循环
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//设置管理员是否自动审批的字段是否是是。//若下一环节用户与系统管理员一致,则自动审批
|
|
|
|
if (adminContains) { |
|
|
|
bv.setUserSid(nextUserSid); |
|
|
|
bv.setTaskId(vo.getTaskId()); |
|
|
|
bv.setTaskDefKey(taskDefKey); |
|
|
|
bv.setComment("系统自动跳过"); |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
return handleProsess(bv, false); |
|
|
|
} |
|
|
|
|
|
|
|
if (contains) { |
|
|
|
bv.setUserSid(nextUserSid); |
|
|
|
bv.setTaskId(vo.getTaskId()); |
|
|
|
bv.setTaskDefKey(taskDefKey); |
|
|
|
bv.setComment("因与下一级审批人相同,系统自动处理,需以下一级审批人审批意见为准!"); |
|
|
|
return handleProsess(bv, false); |
|
|
|
} |
|
|
|
vo.setProcInsId(instanceId); |
|
|
|
vo.setProcDefId(bv.getModelId()); |
|
|
|
vo.setNodeState(nodeState); |
|
|
|
vo.setTaskDefKey(taskDefKey); |
|
|
|
vo.setSid(bv.getBusinessSid()); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<UpdateFlowFieldVo> businessStartProcessInstanceById222(BusinessVariables bv) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
// 或签任务候选人
|
|
|
|
List<String> userIds = Arrays.asList( |
|
|
|
/* List<String> userIds = Arrays.asList( |
|
|
|
"dc6b9e36-1b31-4b94-908b-d2d7f78a0977", |
|
|
|
"657bf5a5-7665-440e-9cbd-ab87eccfbdcc", |
|
|
|
"2737e5ee-5ffd-4127-919b-e6694dfc8361"); |
|
|
|
// 会签任务候选人
|
|
|
|
List<String> approvers = Arrays.asList( |
|
|
|
List<String> approvers = Arrays.asList( |
|
|
|
"1d85d1fe-e527-4ec5-a5e4-c37a76a36518", |
|
|
|
"64e289bc-80cd-487a-9498-5ae61e260f71", |
|
|
|
"7ffcd76a-4fa0-4c9c-87ca-a0c2116bb2ed"); |
|
|
|
"7ffcd76a-4fa0-4c9c-87ca-a0c2116bb2ed");*/ |
|
|
|
// 获取流程定义ID和发起人ID
|
|
|
|
String procDefId = bv.getModelId(); |
|
|
|
String userSid = bv.getUserSid(); |
|
|
|
|
|
|
|
// 获取传入的变量
|
|
|
|
Map<String, Object> variables = bv.getFormVariables(); |
|
|
|
variables.put("userSids", userIds); |
|
|
|
variables.put("approvers", approvers); |
|
|
|
List<String> userSidForNextNode = getNextNodeUser(bv).getData(); |
|
|
|
variables.put("approvers", userSidForNextNode); |
|
|
|
Map<String, Object> variablesSeconds = bv.getFormVariables(); |
|
|
|
|
|
|
|
// 根据流程定义ID查询最新的流程定义
|
|
|
@ -152,38 +411,34 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
|
|
|
|
boolean isMultiInstanceTaskNext = false; |
|
|
|
|
|
|
|
// 查询当前流程实例的待办任务
|
|
|
|
ResultBean<List<LatestTaskVo>> latestTasksNew = flowTaskService.getLatestTasksNew(processInstance.getId()); |
|
|
|
List<LatestTaskVo> data = latestTasksNew.getData(); |
|
|
|
LatestTaskVo latestTaskVo = data.get(0); |
|
|
|
String id_ = latestTaskVo.getId_(); |
|
|
|
String task_def_key_ = latestTaskVo.getTask_def_key_(); |
|
|
|
|
|
|
|
// 获取下一个环节的待办人
|
|
|
|
if (StringUtils.isBlank(bv.getNextNodeUserSids())) { |
|
|
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
String isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
|
|
|
|
// 会签任务认领
|
|
|
|
if ("会签任务".equals(isMultiInstanceTask)) { |
|
|
|
String approver = getApproverForTask(approvers, i); // 动态获取会签候选人
|
|
|
|
taskService.claim(task2.getId(), approver); // 由会签候选人认领任务
|
|
|
|
if ("会签任务".equals(isMultiInstanceTask) || "或签任务".equals(isMultiInstanceTask)) { |
|
|
|
String approver = getApproverForTask(userSidForNextNode, i); |
|
|
|
taskService.claim(task2.getId(), approver); |
|
|
|
isMultiInstanceTaskNext = true; |
|
|
|
} |
|
|
|
// 单一审批任务
|
|
|
|
else if ("单一审批任务".equals(isMultiInstanceTask)) { |
|
|
|
String userSidForNextNode = getNextNodeUser(bv).getData(); |
|
|
|
taskService.claim(task2.getId(), userSidForNextNode); |
|
|
|
bv.setNextNodeUserSids(userSidForNextNode); |
|
|
|
} else if ("单一审批任务".equals(isMultiInstanceTask)) { |
|
|
|
bv.setNextNodeUserSids(userSidForNextNode.get(0)); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String id_ = ""; |
|
|
|
String name_ = ""; |
|
|
|
String task_def_key_ = ""; |
|
|
|
// 如果没有会签任务,继续处理其他节点
|
|
|
|
if (!isMultiInstanceTaskNext) { |
|
|
|
ResultBean<List<LatestTaskVo>> latestTasksNew = flowTaskService.getLatestTasksNew(processInstance.getId()); |
|
|
|
List<LatestTaskVo> data = latestTasksNew.getData(); |
|
|
|
LatestTaskVo latestTaskVo = data.get(0); |
|
|
|
id_ = latestTaskVo.getId_(); |
|
|
|
task_def_key_ = latestTaskVo.getTask_def_key_(); |
|
|
|
name_ = latestTaskVo.getName_(); |
|
|
|
String nextNodeUserSids = bv.getNextNodeUserSids(); |
|
|
|
// 查询下一环节是否有转办并添加评论
|
|
|
|
nextNodeUserSids = change(nextNodeUserSids, processInstance.getProcessInstanceId()); |
|
|
@ -198,12 +453,26 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
if (bv.getUserSid().equals(nextNodeUserSids)) { |
|
|
|
return handleSelfApproval(bv, task, id_, task_def_key_, variables, variablesSeconds, processDefinition); |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
id_ = task2.getId(); |
|
|
|
task_def_key_ = task2.getTaskDefinitionKey(); |
|
|
|
name_ = task2.getName(); |
|
|
|
if (!ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(task2.getAssignee())) { |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
return handleAutomaticApproval(bv, task, id_, task_def_key_, variables, variablesSeconds, processDefinition); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 实例化 UpdateFlowFieldVo
|
|
|
|
UpdateFlowFieldVo updateFlowFieldVo = new UpdateFlowFieldVo(); |
|
|
|
updateFlowFieldVo.setProcInsId(task.getProcessInstanceId()); |
|
|
|
updateFlowFieldVo.setNodeState(latestTaskVo.getName_()); |
|
|
|
updateFlowFieldVo.setNodeState(name_); |
|
|
|
updateFlowFieldVo.setTaskId(id_); |
|
|
|
updateFlowFieldVo.setTaskDefKey(task_def_key_); |
|
|
|
updateFlowFieldVo.setProcDefId(bv.getModelId()); |
|
|
@ -262,148 +531,6 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
return handleProsess(bv, false); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 启动流程 |
|
|
|
* |
|
|
|
* @param bv |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<UpdateFlowFieldVo> businessStartProcessInstanceById2(BusinessVariables bv) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
// 或签任务候选人
|
|
|
|
List<String> userIds = Arrays.asList( |
|
|
|
"dc6b9e36-1b31-4b94-908b-d2d7f78a0977", |
|
|
|
"657bf5a5-7665-440e-9cbd-ab87eccfbdcc", |
|
|
|
"2737e5ee-5ffd-4127-919b-e6694dfc8361"); |
|
|
|
|
|
|
|
// 会签任务候选人
|
|
|
|
List<String> approvers = Arrays.asList( |
|
|
|
"1d85d1fe-e527-4ec5-a5e4-c37a76a36518", |
|
|
|
"64e289bc-80cd-487a-9498-5ae61e260f71", |
|
|
|
"7ffcd76a-4fa0-4c9c-87ca-a0c2116bb2ed"); |
|
|
|
|
|
|
|
|
|
|
|
UpdateFlowFieldVo updateFlowFieldVo = new UpdateFlowFieldVo(); |
|
|
|
String procDefId = bv.getModelId(); |
|
|
|
String userSid = bv.getUserSid(); |
|
|
|
|
|
|
|
Map<String, Object> variables = bv.getFormVariables(); |
|
|
|
variables.put("userSids", userIds); |
|
|
|
variables.put("approvers", approvers); |
|
|
|
Map<String, Object> variablesSeconds = bv.getFormVariables(); |
|
|
|
//根据流程定义id查询
|
|
|
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) |
|
|
|
.latestVersion().singleResult(); |
|
|
|
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { |
|
|
|
return rb.setMsg("流程已被挂起,请先激活流程"); |
|
|
|
} |
|
|
|
// 设置流程发起人Id到流程中
|
|
|
|
ResultBean<SysUserVo> sysUserVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
SysUserVo sysUser = sysUserVoResultBean.getData(); |
|
|
|
identityService.setAuthenticatedUserId(sysUser.getSid()); |
|
|
|
variables.put(ProcessConstants.PROCESS_INITIATOR, userSid); |
|
|
|
variables.put(ProcessConstants.USER_TYPE_ASSIGNEE, userSid); |
|
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); |
|
|
|
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
|
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult(); |
|
|
|
if (Objects.nonNull(task)) { |
|
|
|
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.START.getType(), |
|
|
|
sysUser.getName() + "发起流程申请"); |
|
|
|
taskService.setAssignee(task.getId(), userSid); |
|
|
|
taskService.complete(task.getId(), variables); |
|
|
|
} |
|
|
|
|
|
|
|
boolean isMultiInstanceTaskNext = false; |
|
|
|
|
|
|
|
//根据流程实例的id查询最新的待办环节
|
|
|
|
ResultBean<List<LatestTaskVo>> latestTasksNew = flowTaskService.getLatestTasksNew(processInstance.getId()); |
|
|
|
List<LatestTaskVo> data = latestTasksNew.getData(); |
|
|
|
LatestTaskVo latestTaskVo = data.get(0); |
|
|
|
String id_ = latestTaskVo.getId_(); |
|
|
|
String task_def_key_ = latestTaskVo.getTask_def_key_(); |
|
|
|
//获取下一环节待办人
|
|
|
|
if (StringUtils.isBlank(bv.getNextNodeUserSids())) { |
|
|
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
String isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
if ("会签任务".equals(isMultiInstanceTask)) { |
|
|
|
taskService.claim(task2.getId(), approvers.get(i)); // 由候选人认领任务
|
|
|
|
isMultiInstanceTaskNext = true; |
|
|
|
} else { |
|
|
|
ResultBean<String> userResultBean = getNextNodeUser(bv); |
|
|
|
bv.setNextNodeUserSids(userResultBean.getData()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isMultiInstanceTaskNext) { |
|
|
|
String nextNodeUserSids = bv.getNextNodeUserSids(); |
|
|
|
//查询下一环节是否有转办并添加评论
|
|
|
|
nextNodeUserSids = change(nextNodeUserSids, processInstance.getProcessInstanceId()); |
|
|
|
taskService.setAssignee(id_, nextNodeUserSids); |
|
|
|
taskService.setVariablesLocal(id_, variables); |
|
|
|
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextNodeUserSids)) { |
|
|
|
bv.setModelId(procDefId); |
|
|
|
bv.setInstanceId(task.getProcessInstanceId()); |
|
|
|
bv.setTaskId(id_); |
|
|
|
bv.setUserSid(nextNodeUserSids); |
|
|
|
bv.setBusinessSid(bv.getBusinessSid()); |
|
|
|
bv.setTaskDefKey(task_def_key_); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setOrgSidPath(bv.getOrgSidPath()); |
|
|
|
bv.setComment("系统自动跳过!"); |
|
|
|
bv.setFormVariables(variablesSeconds); |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(bv, false); |
|
|
|
if (updateFlowFieldVoResultBean.getSuccess() && updateFlowFieldVoResultBean.getData() != null) { |
|
|
|
UpdateFlowFieldVo vo = updateFlowFieldVoResultBean.getData(); |
|
|
|
updateFlowFieldVo.setProcInsId(vo.getProcInsId()); |
|
|
|
updateFlowFieldVo.setNodeState(vo.getNodeState()); |
|
|
|
updateFlowFieldVo.setTaskId(vo.getTaskId()); |
|
|
|
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey()); |
|
|
|
updateFlowFieldVo.setProcDefId(bv.getModelId()); |
|
|
|
updateFlowFieldVo.setSid(bv.getBusinessSid()); |
|
|
|
updateFlowFieldVo.setName(processDefinition.getName()); |
|
|
|
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (bv.getUserSid().equals(nextNodeUserSids)) { |
|
|
|
//如果申请人与下一环节审批人相同,则自动审批
|
|
|
|
bv.setModelId(procDefId); |
|
|
|
bv.setInstanceId(task.getProcessInstanceId()); |
|
|
|
bv.setTaskId(id_); |
|
|
|
bv.setUserSid(nextNodeUserSids); |
|
|
|
bv.setBusinessSid(bv.getBusinessSid()); |
|
|
|
bv.setTaskDefKey(task_def_key_); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setOrgSidPath(bv.getOrgSidPath()); |
|
|
|
bv.setFormVariables(variablesSeconds); |
|
|
|
bv.setComment("因与申请人相同,系统自动处理,需以下一级审批人审批意见为准!"); |
|
|
|
bv.setNextNodeUserSids(""); |
|
|
|
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(bv, false); |
|
|
|
if (updateFlowFieldVoResultBean.getSuccess() && updateFlowFieldVoResultBean.getData() != null) { |
|
|
|
UpdateFlowFieldVo vo = updateFlowFieldVoResultBean.getData(); |
|
|
|
updateFlowFieldVo.setProcInsId(vo.getProcInsId()); |
|
|
|
updateFlowFieldVo.setNodeState(vo.getNodeState()); |
|
|
|
updateFlowFieldVo.setTaskId(vo.getTaskId()); |
|
|
|
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey()); |
|
|
|
updateFlowFieldVo.setProcDefId(bv.getModelId()); |
|
|
|
updateFlowFieldVo.setSid(bv.getBusinessSid()); |
|
|
|
updateFlowFieldVo.setName(processDefinition.getName()); |
|
|
|
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
updateFlowFieldVo.setProcInsId(task.getProcessInstanceId()); |
|
|
|
updateFlowFieldVo.setNodeState(latestTaskVo.getName_()); |
|
|
|
updateFlowFieldVo.setTaskId(id_); |
|
|
|
updateFlowFieldVo.setTaskDefKey(task_def_key_); |
|
|
|
updateFlowFieldVo.setProcDefId(bv.getModelId()); |
|
|
|
updateFlowFieldVo.setSid(bv.getBusinessSid()); |
|
|
|
updateFlowFieldVo.setName(processDefinition.getName()); |
|
|
|
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询下一环节用户是否有转办用户,若有转办用户则添加转办评论 |
|
|
@ -454,14 +581,28 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
return nextNodeUserSids; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 办理 |
|
|
|
* 提取获取用户角色列表的公共方法,避免重复代码 |
|
|
|
* |
|
|
|
* @param bv |
|
|
|
* @param b |
|
|
|
* @return |
|
|
|
* @param flowElement 当前流程环节 |
|
|
|
* @param orgPath 当前用户的组织路径 |
|
|
|
* @return 用户列表 |
|
|
|
*/ |
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables bv, boolean b) { |
|
|
|
private List<SysUserVo> getUserListFromFlowElement(FlowElement flowElement, String orgPath) { |
|
|
|
List<SysUserVo> userList = new ArrayList<>(); // 初始化用户列表
|
|
|
|
if (flowElement instanceof UserTask) { // 判断当前环节是否为用户任务
|
|
|
|
UserTask userTask = (UserTask) flowElement; // 转换为用户任务类型
|
|
|
|
List<String> candidateGroups = userTask.getCandidateGroups(); // 获取候选组
|
|
|
|
UserssQuery userssQuery = new UserssQuery(); // 创建查询对象
|
|
|
|
userssQuery.setCandidateGroups(candidateGroups); // 设置候选组
|
|
|
|
userssQuery.setOrgSidPath(orgPath); // 设置组织路径
|
|
|
|
userList = sysUserFeign.getUsersByRoles(userssQuery).getData(); // 根据角色查询用户
|
|
|
|
} |
|
|
|
return userList == null ? new ArrayList<>() : userList; // 如果返回为null,则返回空列表
|
|
|
|
} |
|
|
|
|
|
|
|
/* public ResultBean<UpdateFlowFieldVo> handleProsess222(BusinessVariables bv, boolean b) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
UpdateFlowFieldVo vo = new UpdateFlowFieldVo(); |
|
|
|
// 或签任务候选人
|
|
|
@ -562,7 +703,7 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
tasks = taskService.createTaskQuery().processInstanceId(instanceId).list(); |
|
|
|
for (int i = 0; i < tasks.size(); i++) { |
|
|
|
Task task2 = tasks.get(i); |
|
|
|
isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
isMultiInstanceTask = isMultiInstanceTask(task2); |
|
|
|
if ("会签任务".equals(isMultiInstanceTask)) { |
|
|
|
taskService.claim(task2.getId(), approvers.get(i)); // 由候选人认领任务
|
|
|
|
isMultiInstanceTaskNext = true; |
|
|
@ -570,9 +711,15 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
taskService.claim(task2.getId(), userIds.get(i)); // 由候选人认领任务
|
|
|
|
isMultiInstanceTaskNext = true; |
|
|
|
} else { |
|
|
|
ResultBean<String> userResultBean = getNextNodeUser(bv); |
|
|
|
bv.setNextNodeUserSids(userResultBean.getData()); |
|
|
|
nextUserSid = bv.getNextNodeUserSids(); |
|
|
|
//获取下一环节用户
|
|
|
|
ResultBean<String> stringResultBean = getNextNodeUserSidsOfSubmit(bv); |
|
|
|
if (!stringResultBean.getSuccess()) { |
|
|
|
//下一环节用户为空的情况
|
|
|
|
nextUserSid = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId(); |
|
|
|
adminContains = true; |
|
|
|
} else { |
|
|
|
nextUserSid = stringResultBean.getData(); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -681,7 +828,7 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
vo.setTaskDefKey(taskDefKey); |
|
|
|
vo.setSid(bv.getBusinessSid()); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取下一环节用户 |
|
|
@ -689,8 +836,9 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
* @param bv |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<String> getNextNodeUserSidsOfSubmit(BusinessVariables bv) { |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
|
public ResultBean<List<String>> getNextNodeUserSidsOfSubmit(BusinessVariables bv) { |
|
|
|
ResultBean<List<String>> rb = ResultBean.fireFail(); |
|
|
|
List<String> nextUserList = new ArrayList<>(); |
|
|
|
String orgPath = bv.getOrgSidPath(); |
|
|
|
String taskDefKey = bv.getTaskDefKey(); |
|
|
|
//根据业务参数取流程流转的环节 信息
|
|
|
@ -710,28 +858,45 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
} else { |
|
|
|
Object o = task_map.get("candidateGroups"); |
|
|
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o)); |
|
|
|
String roleSid = jsonArray.get(0).toString(); |
|
|
|
//根据组织架构、角色两个参数取相关符合条件的用户信息
|
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(roleSid); |
|
|
|
userQuery.setOrgSidPath(orgPath); |
|
|
|
String nextNodeUserSids_ = ""; |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData(); |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
return rb; |
|
|
|
} else { |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
for (SysUserVo su : sysUserVos) { |
|
|
|
nextNodeUserSids.append(su.getSid()).append(","); |
|
|
|
// 将JSONArray转换为List<String>
|
|
|
|
List<String> stringList = jsonArray.toJavaList(String.class); |
|
|
|
stringList.removeAll(Collections.singleton(null)); |
|
|
|
if (!stringList.isEmpty()) { |
|
|
|
for (int i = 0; i < stringList.size(); i++) { |
|
|
|
String roleSid = stringList.get(i); |
|
|
|
//根据组织架构、角色两个参数取相关符合条件的用户信息
|
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(roleSid); |
|
|
|
userQuery.setOrgSidPath(orgPath); |
|
|
|
String nextNodeUserSids_ = ""; |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData(); |
|
|
|
if (nextUserList.isEmpty() && i == stringList.size() - 1) { |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
log.error("下一环节无用户填充管理员用户"); |
|
|
|
return rb; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
for (SysUserVo su : sysUserVos) { |
|
|
|
nextNodeUserSids.append(su.getSid()).append(","); |
|
|
|
} |
|
|
|
//符合条件的用户的sid,拼接的字符串
|
|
|
|
nextNodeUserSids_ = nextNodeUserSids.toString(); |
|
|
|
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
nextUserList.add(nextNodeUserSids_); |
|
|
|
} |
|
|
|
//符合条件的用户的sid,拼接的字符串
|
|
|
|
nextNodeUserSids_ = nextNodeUserSids.toString(); |
|
|
|
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1); |
|
|
|
} |
|
|
|
return rb.success().setData(nextNodeUserSids_); |
|
|
|
return rb.success().setData(nextUserList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 流程抄送的功能 |
|
|
|
* |
|
|
@ -960,157 +1125,10 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean assignTask(FlowDelegateQuery flowDelegateQuery) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
DelegateQuery delegateQuery = new DelegateQuery(); |
|
|
|
BeanUtil.copyProperties(flowDelegateQuery, delegateQuery); |
|
|
|
ResultBean assignTask = flowTaskService.assignTask(delegateQuery); |
|
|
|
String userSid = flowDelegateQuery.getUserSid(); |
|
|
|
String assigneeSid = flowDelegateQuery.getAssignee(); |
|
|
|
String instanceId = flowDelegateQuery.getInstanceId(); |
|
|
|
String views = ""; |
|
|
|
if (StringUtils.isNotBlank(flowDelegateQuery.getViews())) { |
|
|
|
views = flowDelegateQuery.getViews(); |
|
|
|
} |
|
|
|
ResultBean<SysUserVo> userVoResultBean1 = sysUserFeign.fetchBySid(userSid); |
|
|
|
String userName = ""; |
|
|
|
if (userVoResultBean1.getData() != null) { |
|
|
|
userName = userVoResultBean1.getData().getName(); |
|
|
|
} |
|
|
|
ResultBean<SysUserVo> userVoResultBean2 = sysUserFeign.fetchBySid(assigneeSid); |
|
|
|
ProcessCommentDto processCommentDto = new ProcessCommentDto(); |
|
|
|
processCommentDto.setReviewerSid(userSid); |
|
|
|
if (userVoResultBean2.getData() != null) { |
|
|
|
String changeName = userVoResultBean2.getData().getName(); |
|
|
|
processCommentDto.setReviewer(userName); |
|
|
|
processCommentDto.setContent(userName + "转办给" + changeName + ":" + views); |
|
|
|
} |
|
|
|
processCommentDto.setTime(new Date()); |
|
|
|
processCommentDto.setProcessId(instanceId); |
|
|
|
processCommentService.saveOrUpdateDto(processCommentDto); |
|
|
|
//转办内容推送至待阅
|
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery() |
|
|
|
.includeProcessVariables().taskId(delegateQuery.getTaskId()).singleResult(); |
|
|
|
if (historicTaskInstance == null) { |
|
|
|
return rb.setMsg("分享失败!"); |
|
|
|
} |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
String procDefId = historicTaskInstance.getProcessDefinitionId(); |
|
|
|
String procInsId = historicTaskInstance.getProcessInstanceId(); |
|
|
|
String nodeState = historicTaskInstance.getName(); |
|
|
|
String taskDefKey = historicTaskInstance.getTaskDefinitionKey(); |
|
|
|
messageFlowVo.setProcDefId(procDefId); |
|
|
|
messageFlowVo.setTaskId(delegateQuery.getTaskId()); |
|
|
|
messageFlowVo.setNodeState(nodeState); |
|
|
|
messageFlowVo.setProcInsId(procInsId); |
|
|
|
messageFlowVo.setTaskDefKey(taskDefKey); |
|
|
|
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables(); |
|
|
|
MessageFlowableQuery mfq = new MessageFlowableQuery(); |
|
|
|
mfq.setUfVo(messageFlowVo); |
|
|
|
String createrOrgPath = (String) processVariables.get("createrOrgPath"); |
|
|
|
if (historicTaskInstance == null) { |
|
|
|
return rb.setMsg("分享失败!"); |
|
|
|
} |
|
|
|
//
|
|
|
|
String assignee = (String) processVariables.get("assignee"); |
|
|
|
ResultBean<SysUserVo> stringResultBean = sysUserFeign.fetchBySid(assignee); |
|
|
|
String assigneeName = ""; |
|
|
|
if (stringResultBean.getData() != null) { |
|
|
|
assigneeName = stringResultBean.getData().getName(); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> app = new HashMap<>(); |
|
|
|
if (processVariables.get("app") != null) { |
|
|
|
app = (Map<String, Object>) processVariables.get("app"); |
|
|
|
} |
|
|
|
mfq.setAppMap(app); |
|
|
|
String businessSid = (String) processVariables.get("businessSid"); |
|
|
|
mfq.setBusinessSid(businessSid); |
|
|
|
mfq.setMsgContent(userName + "分享的流程审批,请查看"); |
|
|
|
// act_re_procdef
|
|
|
|
Map<String, String> process = processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId()); |
|
|
|
|
|
|
|
mfq.setModuleName(process.get("NAME_")); |
|
|
|
if (processVariables.containsKey("orderNames")) { |
|
|
|
mfq.setMsgTitle(processVariables.get("orderNames").toString()); |
|
|
|
} else { |
|
|
|
mfq.setMsgTitle(process.get("NAME_")); |
|
|
|
} |
|
|
|
mfq.setUserSids(userSid); |
|
|
|
mfq.setOrgPath(createrOrgPath); |
|
|
|
mfq.setUserSid(assignee); |
|
|
|
mfq.setApplicationName(assigneeName); |
|
|
|
ResultBean<String> resultBean = messageFeign.pushMessageShare(mfq); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<FlowableMessageVo> getApplicantInfoForUrgeCount(String taskId, String procInstId) { |
|
|
|
ResultBean<FlowableMessageVo> rb = ResultBean.fireFail(); |
|
|
|
FlowableMessageVo flowableMessageVo = baseMapper.getApplicantInfoForUrgeCount(taskId, procInstId); |
|
|
|
String procDefId = ""; |
|
|
|
if (null != flowableMessageVo) { |
|
|
|
procDefId = flowableMessageVo.getProDefId(); |
|
|
|
} |
|
|
|
List<FlowableMessageVo> messageVos = baseMapper.getApplicantInfos(procDefId, procInstId); |
|
|
|
messageVos.removeAll(Collections.singleton(null)); |
|
|
|
FlowableMessageVo messageVo = new FlowableMessageVo(); |
|
|
|
if (!messageVos.isEmpty()) { |
|
|
|
messageVo = messageVos.get(2); |
|
|
|
} |
|
|
|
return rb.success().setData(messageVo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<FlowableMessageVo> getTask(String taskId, String procInstId) { |
|
|
|
ResultBean<FlowableMessageVo> rb = ResultBean.fireFail(); |
|
|
|
FlowableMessageVo flowableMessageVo = baseMapper.getTask(taskId, procInstId); |
|
|
|
return rb.success().setData(flowableMessageVo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<FlowTaskDto> getTaskNameForUrgeCount(String taskId, String procInstId) { |
|
|
|
ResultBean<FlowTaskDto> rb = ResultBean.fireFail(); |
|
|
|
FlowTaskDto flowTask = new FlowTaskDto(); |
|
|
|
flowTask.setTaskId(taskId); |
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskId(flowTask.getTaskId()).singleResult(); |
|
|
|
flowTask.setProcessVariables(historicTaskInstance.getProcessVariables()); |
|
|
|
if (flowTask.getProcessVariables().containsKey("orderNames")) { |
|
|
|
flowTask.setProcDefName(flowTask.getProcessVariables().get("orderNames").toString()); |
|
|
|
} else { |
|
|
|
FlowableMessageVo task = baseMapper.getTask(taskId, procInstId); |
|
|
|
if (null != task) { |
|
|
|
String proDefId = task.getProDefId(); |
|
|
|
FlowableMessageVo flowableMessageVo = baseMapper.selTaskNameForUrgeCount(proDefId); |
|
|
|
if (null != flowableMessageVo) { |
|
|
|
if (StringUtils.isNotBlank(flowableMessageVo.getNodeName())) { |
|
|
|
flowTask.setProcDefName(flowableMessageVo.getNodeName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(flowTask); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<FlowableMessageVo> getApprovalResult(String proDefId, String procInstId) { |
|
|
|
ResultBean<FlowableMessageVo> rb = ResultBean.fireFail(); |
|
|
|
FlowableMessageVo vo = baseMapper.getApprovalResult(proDefId, procInstId); |
|
|
|
if (vo != null) { |
|
|
|
String taskId = vo.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(vo.getEndTime())) { |
|
|
|
String type = baseMapper.getComment(taskId, procInstId); |
|
|
|
if (type.equals("6")) { |
|
|
|
vo.setResult("终止"); |
|
|
|
} else if (type.equals("1")) { |
|
|
|
vo.setResult("通过"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
vo.setResult("审批中"); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> getNextNodeUser(BusinessVariables bv) { |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
|
public ResultBean<List<String>> getNextNodeUser(BusinessVariables bv) { |
|
|
|
ResultBean<List<String>> rb = ResultBean.fireFail(); |
|
|
|
List<String> nextUserList = new ArrayList<>(); |
|
|
|
//根据业务参数取流程流转的环节 信息
|
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>) getProcessCirculationNodesByMap(bv).getData(); |
|
|
|
if (list == null || list.size() < 2) { |
|
|
@ -1122,25 +1140,34 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
return rb.setMsg("流程设计问题"); |
|
|
|
} |
|
|
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o)); |
|
|
|
String roleSid = jsonArray.get(0).toString(); |
|
|
|
//根据组织架构、角色两个参数取相关符合条件的用户信息
|
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(roleSid); |
|
|
|
userQuery.setOrgSidPath(bv.getOrgSidPath()); |
|
|
|
String nextNodeUserSids_ = ""; |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData(); |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
nextNodeUserSids_ = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId(); |
|
|
|
} else { |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
for (SysUserVo su : sysUserVos) { |
|
|
|
nextNodeUserSids.append(su.getSid()).append(","); |
|
|
|
|
|
|
|
// 将JSONArray转换为List<String>
|
|
|
|
List<String> stringList = jsonArray.toJavaList(String.class); |
|
|
|
stringList.removeAll(Collections.singleton(null)); |
|
|
|
if (!stringList.isEmpty()) { |
|
|
|
for (int i = 0; i < stringList.size(); i++) { |
|
|
|
String roleSid = stringList.get(i); |
|
|
|
//根据组织架构、角色两个参数取相关符合条件的用户信息
|
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(roleSid); |
|
|
|
userQuery.setOrgSidPath(bv.getOrgSidPath()); |
|
|
|
String nextNodeUserSids_ = ""; |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData(); |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
nextNodeUserSids_ = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId(); |
|
|
|
} else { |
|
|
|
StringBuilder nextNodeUserSids = new StringBuilder(); |
|
|
|
for (SysUserVo su : sysUserVos) { |
|
|
|
nextNodeUserSids.append(su.getSid()).append(","); |
|
|
|
} |
|
|
|
//符合条件的用户的sid,拼接的字符串
|
|
|
|
nextNodeUserSids_ = nextNodeUserSids.toString(); |
|
|
|
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1); |
|
|
|
} |
|
|
|
nextUserList.add(nextNodeUserSids_); |
|
|
|
} |
|
|
|
//符合条件的用户的sid,拼接的字符串
|
|
|
|
nextNodeUserSids_ = nextNodeUserSids.toString(); |
|
|
|
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1); |
|
|
|
} |
|
|
|
return rb.success().setData(nextNodeUserSids_); |
|
|
|
return rb.success().setData(nextUserList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -1285,7 +1312,7 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean submit222() { |
|
|
|
/* public ResultBean submit222() { |
|
|
|
String userSid = "7f56f6ec-4a5f-47b0-aaab-158d64cb97b1"; |
|
|
|
// 或签任务候选人
|
|
|
|
List<String> userIds = new ArrayList<>(); |
|
|
@ -1400,33 +1427,6 @@ public class Flow3Service extends MybatisBaseService<FlowMapper, Flowable> { |
|
|
|
assertTrue(isEnded2); |
|
|
|
|
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* private boolean isMultiInstanceTask(Task task, boolean isSequential) { |
|
|
|
// 获取任务节点的ID
|
|
|
|
String taskDefinitionKey = task.getTaskDefinitionKey(); |
|
|
|
|
|
|
|
// 获取流程定义对象
|
|
|
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
|
|
|
.processDefinitionId(task.getProcessDefinitionId()) |
|
|
|
.singleResult(); |
|
|
|
|
|
|
|
// 获取BPMN模型,解析任务定义
|
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); |
|
|
|
FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey); |
|
|
|
|
|
|
|
// 判断flowElement是否是UserTask,并且获取其multiInstanceLoopCharacteristics
|
|
|
|
if (flowElement instanceof UserTask) { |
|
|
|
UserTask userTask = (UserTask) flowElement; |
|
|
|
// 获取multiInstanceLoopCharacteristics
|
|
|
|
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics(); |
|
|
|
if (multiInstance != null) { |
|
|
|
boolean sequential = multiInstance.isSequential(); |
|
|
|
return sequential == isSequential; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|