|
|
@ -359,8 +359,6 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
log.info("b:{}", b); |
|
|
|
UpdateFlowFieldVo vo = new UpdateFlowFieldVo(); |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
// Map<String, Object> formVariables = dto.getFormVariables();
|
|
|
|
|
|
|
|
String taskId = dto.getTaskId(); |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return rb.setMsg("taskId 不能为空!"); |
|
|
@ -368,27 +366,195 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
if (StringUtils.isBlank(dto.getBusinessSid())) { |
|
|
|
return rb.setMsg("businessSid 不能为空!"); |
|
|
|
} |
|
|
|
/*if(formVariables==null){ |
|
|
|
return rb.setMsg("业务参数集合 不能为空!"); |
|
|
|
}*/ |
|
|
|
if (dto.getFormVariables() == null) |
|
|
|
dto.setFormVariables(new HashMap<String, Object>()); |
|
|
|
Map<String, Object> formVariables = dto.getFormVariables(); |
|
|
|
formVariables.put("businessSid", dto.getBusinessSid()); |
|
|
|
String nextUserSid = dto.getNextNodeUserSids(); |
|
|
|
boolean adminContains = false; |
|
|
|
if (StringUtils.isBlank(nextUserSid)) { |
|
|
|
ResultBean<UserAndOrgPath> nextNodeUserSidsOfSubmit = getNextNodeUserSidsOfSubmit(dto); |
|
|
|
if (!nextNodeUserSidsOfSubmit.getSuccess()) { |
|
|
|
// return rb.setMsg("nextUserSid 不能为空!");
|
|
|
|
//=================================添加系统个管理员自动审批
|
|
|
|
nextUserSid = "427a2fb0-60c5-409f-bea4-4eb441041ae6"; |
|
|
|
adminContains = true; |
|
|
|
}else{ |
|
|
|
nextUserSid = nextNodeUserSidsOfSubmit.getData().getUserSid(); |
|
|
|
formVariables.put(BusinessVariables.ORGPATH, nextNodeUserSidsOfSubmit.getData().getOrgPath()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
String comment = dto.getComment(); |
|
|
|
if (StringUtils.isBlank(comment)) { |
|
|
|
comment = ""; |
|
|
|
} |
|
|
|
String instanceId = dto.getInstanceId(); |
|
|
|
if (StringUtils.isBlank(instanceId)) { |
|
|
|
return rb.setMsg("instanceId 不能为空!"); |
|
|
|
} |
|
|
|
String userSid = dto.getUserSid(); |
|
|
|
if (StringUtils.isBlank(userSid)) { |
|
|
|
return rb.setMsg("userSid 不能为空!"); |
|
|
|
} |
|
|
|
String businessSid = dto.getBusinessSid(); |
|
|
|
if (StringUtils.isBlank(businessSid)) { |
|
|
|
return rb.setMsg("业务sid 不能为空!"); |
|
|
|
} |
|
|
|
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("当前用户不是环节的待办人,不能进行办理操作!"); |
|
|
|
} |
|
|
|
String nodeState = ""; |
|
|
|
String taskDefKey = ""; |
|
|
|
vo.setSid(businessSid); |
|
|
|
|
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
|
taskService.addComment(taskId, instanceId, |
|
|
|
FlowComment.DELEGATE.getType(), comment); |
|
|
|
taskService.resolveTask(taskId, formVariables); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
//根据流程实例的id取最新的待办环节,给环节设置上用户sid
|
|
|
|
ResultBean<List<LatestTaskVo>> ll = flowtaskService.getLatestTasksNew(instanceId); |
|
|
|
if (ll.getData().size() > 0) { |
|
|
|
LatestTaskVo latestTaskVo = ll.getData().get(0); |
|
|
|
String id_ = latestTaskVo.getId_(); |
|
|
|
taskService.setAssignee(id_, nextUserSid); |
|
|
|
vo.setTaskId(id_); |
|
|
|
//在act_ru_variable表中增加环节上的业务参数的变量
|
|
|
|
taskService.setVariablesLocal(id_, formVariables); |
|
|
|
nodeState = latestTaskVo.getName_(); |
|
|
|
taskDefKey = latestTaskVo.getTask_def_key_(); |
|
|
|
} else { |
|
|
|
nodeState = FlowComment.SETTLE.getRemark(); |
|
|
|
taskDefKey = "Event_end"; |
|
|
|
vo.setNodeState(FlowComment.SETTLE.getRemark()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (adminContains) { |
|
|
|
dto.setUserSid(nextUserSid); |
|
|
|
dto.setTaskId(vo.getTaskId()); |
|
|
|
dto.setTaskDefKey(taskDefKey); |
|
|
|
dto.setComment("系统管理员已自动审批"); |
|
|
|
return handleProsess(dto, false); |
|
|
|
} |
|
|
|
List<FlowElement> flowElements = processService.calApprovePath(dto.getModelId(), dto.getModelId(), |
|
|
|
dto.getFormVariables()); |
|
|
|
boolean contains = false; |
|
|
|
boolean adminSecondsContains = false; |
|
|
|
for (int i = 0; i < flowElements.size(); i++) { |
|
|
|
FlowElement flowElement = flowElements.get(i); |
|
|
|
String id = flowElement.getId(); |
|
|
|
if (taskDefKey.equals(id) && i + 1 < flowElements.size()) { |
|
|
|
FlowElement flowElement1 = flowElements.get(i + 1); |
|
|
|
if (flowElement1 instanceof UserTask) { |
|
|
|
UserTask userTask = (UserTask) flowElement1; |
|
|
|
List<String> candidateGroups = userTask.getCandidateGroups(); |
|
|
|
List<SysUserVo> sysUserVoLists = new ArrayList<>(); |
|
|
|
//根据角色查询用户
|
|
|
|
for (String roleSid : candidateGroups) { |
|
|
|
UserQuery userQuery = new UserQuery(); |
|
|
|
userQuery.setRoleSid(roleSid); |
|
|
|
userQuery.setOrgSidPath(dto.getOrgSidPath()); |
|
|
|
ResultBean<List<SysUserVo>> userByRole = sysUserFeign.getUserByRole(userQuery); |
|
|
|
boolean success = userByRole.getSuccess(); |
|
|
|
if (!success) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
sysUserVoLists.addAll(userByRole.getData()); |
|
|
|
} |
|
|
|
//当前环节运营部总经理 刘丽艳 点击同意 下一环节 事业部副总经理 (nextUserSid) 和事业部总经理(sysUserVoLists.get(0).getSid())
|
|
|
|
//判断查询回来的用户的集合size是1 并且用户的sid和下一环节的用户的sid相同。
|
|
|
|
if (sysUserVoLists.size() == 1 && sysUserVoLists.get(0).getSid().equals(nextUserSid)) { |
|
|
|
contains = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
//如果下一环节无用户,则默认系统管理员自动审批
|
|
|
|
if(sysUserVoLists.size() == 0 && StringUtils.isNotBlank(nextUserSid)){ |
|
|
|
contains = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
if(sysUserVoLists.size() == 0){ |
|
|
|
adminSecondsContains = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (contains) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (adminSecondsContains) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (contains) { |
|
|
|
dto.setUserSid(nextUserSid); |
|
|
|
dto.setTaskId(vo.getTaskId()); |
|
|
|
dto.setTaskDefKey(taskDefKey); |
|
|
|
dto.setComment("因与下一级审批人相同,系统自动处理,需以下一级审批人审批意见为准!"); |
|
|
|
return handleProsess(dto, false); |
|
|
|
} |
|
|
|
if (adminSecondsContains) { |
|
|
|
dto.setUserSid(nextUserSid); |
|
|
|
dto.setTaskId(vo.getTaskId()); |
|
|
|
dto.setTaskDefKey(taskDefKey); |
|
|
|
dto.setComment("系统管理员已自动审批"); |
|
|
|
return handleProsess(dto, false); |
|
|
|
} |
|
|
|
|
|
|
|
vo.setProcInsId(instanceId); |
|
|
|
vo.setProcDefId(task.getProcessDefinitionId()); |
|
|
|
vo.setNodeState(nodeState); |
|
|
|
vo.setTaskDefKey(taskDefKey); |
|
|
|
vo.setNextNodeUserSids(nextUserSid); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 未添加系统管理员自动审批功能 |
|
|
|
* @param dto |
|
|
|
* @param b 是否连续跳转环节 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess111(BusinessVariables dto, boolean b) { |
|
|
|
log.info("BusinessVariables:{}", JSONObject.toJSONString(dto)); |
|
|
|
log.info("b:{}", b); |
|
|
|
UpdateFlowFieldVo vo = new UpdateFlowFieldVo(); |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String taskId = dto.getTaskId(); |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return rb.setMsg("taskId 不能为空!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(dto.getBusinessSid())) { |
|
|
|
return rb.setMsg("businessSid 不能为空!"); |
|
|
|
} |
|
|
|
if (dto.getFormVariables() == null) |
|
|
|
dto.setFormVariables(new HashMap<String, Object>()); |
|
|
|
Map<String, Object> formVariables = dto.getFormVariables(); |
|
|
|
formVariables.put("businessSid", dto.getBusinessSid()); |
|
|
|
String nextUserSid = dto.getNextNodeUserSids(); |
|
|
|
if (StringUtils.isBlank(nextUserSid)) { |
|
|
|
ResultBean<UserAndOrgPath> nextNodeUserSidsOfSubmit = getNextNodeUserSidsOfSubmit(dto); |
|
|
|
if (!nextNodeUserSidsOfSubmit.getSuccess()) { |
|
|
|
return rb.setMsg("nextUserSid 不能为空!"); |
|
|
|
}else{ |
|
|
|
nextUserSid = nextNodeUserSidsOfSubmit.getData().getUserSid(); |
|
|
|
formVariables.put(BusinessVariables.ORGPATH, nextNodeUserSidsOfSubmit.getData().getOrgPath()); |
|
|
|
|
|
|
|
} |
|
|
|
nextUserSid = nextNodeUserSidsOfSubmit.getData().getUserSid(); |
|
|
|
formVariables.put(BusinessVariables.ORGPATH, nextNodeUserSidsOfSubmit.getData().getOrgPath()); |
|
|
|
} |
|
|
|
String comment = dto.getComment(); |
|
|
|
if (StringUtils.isBlank(comment)) { |
|
|
|
comment = ""; |
|
|
|
//return rb.setMsg("comment 不能为空!");
|
|
|
|
} |
|
|
|
String instanceId = dto.getInstanceId(); |
|
|
|
if (StringUtils.isBlank(instanceId)) { |
|
|
@ -397,7 +563,6 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
String userSid = dto.getUserSid(); |
|
|
|
if (StringUtils.isBlank(userSid)) { |
|
|
|
return rb.setMsg("userSid 不能为空!"); |
|
|
|
|
|
|
|
} |
|
|
|
String businessSid = dto.getBusinessSid(); |
|
|
|
if (StringUtils.isBlank(businessSid)) { |
|
|
@ -418,18 +583,12 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
if (DelegationState.PENDING.equals(task.getDelegationState())) { |
|
|
|
taskService.addComment(taskId, instanceId, |
|
|
|
FlowComment.DELEGATE.getType(), comment); |
|
|
|
// Map<String,Object> values =(Map<String,Object>) formVariables.get("values");
|
|
|
|
taskService.resolveTask(taskId, formVariables); |
|
|
|
} else { |
|
|
|
taskService.addComment(taskId, instanceId, FlowComment.NORMAL.getType(), comment); |
|
|
|
log.error("taskid:{},userSid:{}", taskId, userSid); |
|
|
|
log.error("formVariables:{}", JSON.toJSONString(formVariables)); |
|
|
|
taskService.setAssignee(taskId, userSid); |
|
|
|
//formVariables.remove("userSid");
|
|
|
|
/*for(Map.Entry<String, Object> entry:formVariables.entrySet()){ |
|
|
|
taskService.setVariable(taskId,entry.getKey(),entry.getValue()); |
|
|
|
System.out.println(entry.getKey()+"--->"+entry.getValue()); |
|
|
|
}*/ |
|
|
|
taskService.complete(taskId, formVariables); |
|
|
|
//根据流程实例的id取最新的待办环节,给环节设置上用户sid
|
|
|
|
ResultBean<List<LatestTaskVo>> ll = flowtaskService.getLatestTasksNew(instanceId); |
|
|
@ -438,13 +597,6 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
String id_ = latestTaskVo.getId_(); |
|
|
|
taskService.setAssignee(id_, nextUserSid); |
|
|
|
vo.setTaskId(id_); |
|
|
|
/* for(Map.Entry<String, Object> entry:formVariables.entrySet()){ |
|
|
|
taskService.setVariable(id_,entry.getKey(),entry.getValue()); |
|
|
|
taskService.setVariableLocal(id_,entry.getKey(),entry.getValue()); |
|
|
|
|
|
|
|
System.out.println(entry.getKey()+"--->"+entry.getValue()); |
|
|
|
}*/ |
|
|
|
// taskService.setVariables(id_,formVariables);
|
|
|
|
//在act_ru_variable表中增加环节上的业务参数的变量
|
|
|
|
taskService.setVariablesLocal(id_, formVariables); |
|
|
|
nodeState = latestTaskVo.getName_(); |
|
|
@ -455,7 +607,6 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
vo.setNodeState(FlowComment.SETTLE.getRemark()); |
|
|
|
} |
|
|
|
} |
|
|
|
//ResultBean<FlowRecordVo> flowRecordVoResultBean = flowableService.flowRecord(dto.getInstanceId(), dto.getModelId());
|
|
|
|
List<FlowElement> flowElements = processService.calApprovePath(dto.getModelId(), dto.getModelId(), |
|
|
|
dto.getFormVariables()); |
|
|
|
boolean contains = false; |
|
|
|