|
|
@ -904,14 +904,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
|
|
|
|
ResultBean<FlowTask> rb = ResultBean.fireFail(); |
|
|
|
|
|
|
|
/* if(dto.getFormVariables()==null){ |
|
|
|
return rb.setMsg("业务参数集合 不能为空!"); |
|
|
|
}*/ |
|
|
|
|
|
|
|
if(dto.getFormVariables()==null) |
|
|
|
dto.setFormVariables(new HashMap<String, Object>()); |
|
|
|
Map<String, Object> formVariables = dto.getFormVariables(); |
|
|
|
// formVariables.put("handleUrl", dto.getHandleUrl());
|
|
|
|
// formVariables.put("detailUrl", dto.getDetailUrl());
|
|
|
|
String taskId = (String) formVariables.get("taskId"); |
|
|
|
String procInsId = (String) formVariables.get("instanceId"); |
|
|
|
String nextUserSid = (String) formVariables.get("nextUserSid"); |
|
|
@ -985,7 +981,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
flowTask.setTaskId(task.getId()); |
|
|
|
flowTask.setTaskName(task.getName()); |
|
|
|
flowTask.setProcInsId(task.getProcessInstanceId()); |
|
|
|
// flowTask.setProcVars();
|
|
|
|
rb.success().setData(flowTask); |
|
|
|
return rb; |
|
|
|
} |
|
|
@ -1073,8 +1068,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
if (!isSequential) { |
|
|
|
throw new CustomException("当前节点相对于目标节点,不属于串行关系,无法回退"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
|
|
|
|
List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list(); |
|
|
|
List<String> runTaskKeyList = new ArrayList<>(); |
|
|
@ -1096,7 +1089,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
for (String currentTaskId : currentTaskIds) { |
|
|
|
taskService.addComment(currentTaskId, task.getProcessInstanceId(), FlowComment.REBACK.getType(), comment); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
// 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
|
|
|
|
runtimeService.createChangeActivityStateBuilder() |
|
|
@ -1247,32 +1239,22 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
if(map.get("ASSIGNEE_")!=null){ |
|
|
|
assignee_ = map.get("ASSIGNEE_").toString(); |
|
|
|
} |
|
|
|
// String assignee_ = map.get("ASSIGNEE_").toString();
|
|
|
|
String id_ = map2.get("id_").toString(); |
|
|
|
/* List<FlowElement> flowElements = processService.calApprovePath(flowTaskVo.getInstanceId(), flowTaskVo.getInstanceId(), |
|
|
|
flowTaskVo.getValues()); |
|
|
|
for(int i=0;i<flowElements.size();i++){ |
|
|
|
FlowElement flowElement = flowElements.get(i); |
|
|
|
System.out.println(flowElement.getId()); |
|
|
|
}*/ |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean_2=null; |
|
|
|
if(flowTaskVo.getUserSid().equals(assignee_)){ |
|
|
|
flowTaskVo.setTaskId(id_); |
|
|
|
flowTaskVo.setUserSid(assignee_); |
|
|
|
flowTaskVo.setTargetKey(item.getId()); |
|
|
|
listResultBean_2= taskReject_(flowTaskVo, true); |
|
|
|
}else{taskService.setAssignee(id_, assignee_);} |
|
|
|
}else{ |
|
|
|
taskService.setAssignee(id_, assignee_); |
|
|
|
} |
|
|
|
LatestTaskVo latestTaskVo = new LatestTaskVo(); |
|
|
|
latestTaskVo.setASSIGNEE_(item.getAssignee()); |
|
|
|
// latestTaskVo.setId_(item.getId());
|
|
|
|
latestTaskVo.setId_(listResultBean_2!=null?listResultBean_2.getData().get(0).getId_():id_); |
|
|
|
//if(b){
|
|
|
|
// taskService.setAssignee(id_, assignee_);
|
|
|
|
// }
|
|
|
|
latestTaskVo.setName_(listResultBean_2!=null?listResultBean_2.getData().get(0).getName_():item.getName()); |
|
|
|
latestTaskVo.setTask_def_key_(listResultBean_2!=null?listResultBean_2.getData().get(0).getTask_def_key_():item.getId()); |
|
|
|
latestTaskVo.setIncomingSourceRef(listResultBean_2!=null?listResultBean_2.getData().get(0).getIncomingSourceRef():item.getIncomingFlows().get(0).getSourceRef()); |
|
|
|
|
|
|
|
latestTaskList.add(latestTaskVo); |
|
|
|
}); |
|
|
|
} catch (FlowableObjectNotFoundException e) { |
|
|
@ -1364,8 +1346,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取上一个节点的activityId
|
|
|
|
|
|
|
|
|
|
|
|
HistoricActivityInstance historicActivityInstance = list1.get(0);//singleResult()
|
|
|
|
String activityType = historicActivityInstance.getActivityType(); |
|
|
|
String historicActivityInstanceActivityId = historicActivityInstance.getActivityId(); |
|
|
@ -1383,9 +1363,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
// 获取当前节点的activityId,即xml中每个标签的ID
|
|
|
|
String currentActivityId = delegateExecution.getCurrentActivityId(); |
|
|
|
// List<Task> list1 = taskService.createTaskQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).list();
|
|
|
|
// taskService.addComment(currentTask.getId(), execution.getProcessInstanceId(), body.get("msg").toString());
|
|
|
|
// FlowNode flowNode2 = (FlowNode)bpmnModel.getFlowElement(sourceRef);
|
|
|
|
String taskId = getTaskId(currentActivityId, historicTaskInstance.getProcessInstanceId(), historicTaskInstance.getProcessDefinitionId()); |
|
|
|
if (StringUtils.isBlank(taskId)) { |
|
|
|
return new ResultBean<List<LatestTaskVo>>().fail().setMsg("流程找不到上一环节,撤回操作失败!").setData(new ArrayList<>()); |
|
|
@ -1407,13 +1384,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
TaskUserInfo taskUserInfo_0 = taskUserInfos_0.get(0); |
|
|
|
String assigneeSid1 = taskUserInfo_1.getAssigneeSid(); |
|
|
|
String assigneeSid0 = taskUserInfo_0.getAssigneeSid(); |
|
|
|
/* if(assigneeSid1.equals(assigneeSid0)){ |
|
|
|
ii=1; |
|
|
|
ybrsid=userSid; |
|
|
|
}else{ |
|
|
|
ybrsid=assigneeSid1; |
|
|
|
}*/ |
|
|
|
|
|
|
|
if(!assigneeSid1.equals(assigneeSid0)){ |
|
|
|
ybrsid=assignee; |
|
|
|
}else{ |
|
|
@ -1445,27 +1415,10 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
return revokeProcess(flowTaskVo,0); |
|
|
|
} |
|
|
|
|
|
|
|
/* private ResultBean<List<LatestTaskVo>> getListResultBean(FlowTaskVo flowTaskVo, String assignee, ResultBean<List<LatestTaskVo>> listResultBean) { |
|
|
|
List<LatestTaskVo> data = listResultBean.getData(); |
|
|
|
LatestTaskVo latestTaskVo = data.get(0); |
|
|
|
flowTaskVo.setTaskId(latestTaskVo.getId_()); |
|
|
|
flowTaskVo.setUserSid(assignee); |
|
|
|
// ResultBean<List<LatestTaskVo>> listResultBean1 = revokeProcess(flowTaskVo);
|
|
|
|
LatestTaskVo latestTaskVo2 = data.get(0); |
|
|
|
String assignee_ = latestTaskVo2.getASSIGNEE_(); |
|
|
|
if(!assignee_.equals(assignee)){ |
|
|
|
return getListResultBean(flowTaskVo, assignee, listResultBean); |
|
|
|
} |
|
|
|
return listResultBean1; |
|
|
|
}*/ |
|
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
private ResultBean<List<LatestTaskVo>> revokeProcess_( String processInstanceId, |
|
|
|
String assignee ) { |
|
|
|
// 流程回退到上一个节点,审批人继续审批
|
|
|
|
/* runtimeService.createChangeActivityStateBuilder().processInstanceId(historicTaskInstance.getProcessInstanceId()) |
|
|
|
.moveActivityIdTo(currentActivityId,sourceRef).changeState(); |
|
|
|
*/ |
|
|
|
// 获取流程定义信息
|
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); |
|
|
|
ProcessDefinition processDefinition = repositoryService |
|
|
@ -1561,14 +1514,9 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
})); |
|
|
|
// 设置撤回意见
|
|
|
|
currentTaskIds.forEach(item -> { |
|
|
|
taskService.addComment(item, processInstanceId, |
|
|
|
FlowComment.RECALL.getType(), "撤回办理"); |
|
|
|
taskService.addComment(item, processInstanceId,FlowComment.RECALL.getType(), "撤回办理"); |
|
|
|
// 设置实际办理人
|
|
|
|
/* if(assignee.equals("0d8d8119-d476-47ce-89c2-075cd809dda6")){ |
|
|
|
taskService.setAssignee(item, assignee); |
|
|
|
}else{*/ |
|
|
|
taskService.setAssignee(item, assignee); |
|
|
|
/* }*/ |
|
|
|
}); |
|
|
|
|
|
|
|
// 最近环节
|
|
|
@ -1592,24 +1540,16 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
parentUserTaskList.forEach(item -> { |
|
|
|
LatestTaskVo latestTaskVo = new LatestTaskVo(); |
|
|
|
latestTaskVo.setASSIGNEE_(item.getAssignee()); |
|
|
|
|
|
|
|
latestTaskVo.setName_(item.getName()); |
|
|
|
latestTaskVo.setTask_def_key_(item.getId()); |
|
|
|
latestTaskVo.setIncomingSourceRef(item.getIncomingFlows().get(0).getSourceRef()); |
|
|
|
|
|
|
|
Map<String, Object> task_map = flowTaskMapper.getTaskByDefKey(processInstanceId, item.getId()); |
|
|
|
/* if(assignee.equals("0d8d8119-d476-47ce-89c2-075cd809dda6")){ |
|
|
|
taskService.setAssignee(task_map.get("id_").toString(), assignee); |
|
|
|
}else{*/ |
|
|
|
if(task_map!=null){ |
|
|
|
taskService.setAssignee(task_map.get("id_").toString(), assignee); |
|
|
|
latestTaskVo.setId_(task_map.get("id_").toString()); |
|
|
|
latestTaskList.add(latestTaskVo); |
|
|
|
} |
|
|
|
|
|
|
|
/* }*/ |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
} catch (FlowableObjectNotFoundException e) { |
|
|
|
throw new CustomException("未找到流程实例,流程可能已发生变化"); |
|
|
@ -1633,9 +1573,7 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
} |
|
|
|
String comment = flowTaskVo.getComment(); |
|
|
|
if (StringUtils.isBlank(comment)) { |
|
|
|
// comment="";
|
|
|
|
throw new CustomException("comment 不能为空!"); |
|
|
|
// return rb.setMsg("comment 不能为空!");
|
|
|
|
} |
|
|
|
String processInstanceId = flowTaskVo.getInstanceId(); |
|
|
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
|
|
@ -1647,9 +1585,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
List<Execution> executions = runtimeService.createExecutionQuery().parentId(processInstanceId).list(); |
|
|
|
List<String> executionIds = new ArrayList<>(); |
|
|
|
executions.forEach(execution -> executionIds.add(execution.getId())); |
|
|
|
/*if (StringUtils.isBlank(comment)) { |
|
|
|
comment = "终止"; |
|
|
|
}*/ |
|
|
|
taskService.setAssignee(flowTaskVo.getTaskId(), flowTaskVo.getUserSid()); |
|
|
|
taskService.addComment(flowTaskVo.getTaskId(), processInstanceId, FlowComment.STOP.getType(), comment); |
|
|
|
runtimeService.createChangeActivityStateBuilder().moveExecutionsToSingleActivityId(executionIds, endId).changeState(); |
|
|
@ -1683,8 +1618,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
List<EndEvent> endNodes = process.findFlowElementsOfType(EndEvent.class, false); |
|
|
|
if (CollectionUtils.isNotEmpty(endNodes)) { |
|
|
|
Authentication.setAuthenticatedUserId(sysUser.getSid().toString()); |
|
|
|
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
|
|
|
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
|
|
|
String endId = endNodes.get(0).getId(); |
|
|
|
List<Execution> executions = |
|
|
|
runtimeService.createExecutionQuery().parentId(processInstance.getProcessInstanceId()).list(); |
|
|
@ -1833,9 +1766,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
if (bv.getModelId() != null) { |
|
|
|
procId = bv.getModelId(); |
|
|
|
} |
|
|
|
/* if(bv.getFormVariables()==null){ |
|
|
|
return ResultBean.fireFail().setMsg("业务参数集合 不能为空!"); |
|
|
|
}*/ |
|
|
|
if(bv.getFormVariables()==null) |
|
|
|
bv.setFormVariables(new HashMap<String, Object>()); |
|
|
|
List<FlowElement> flowElements = processService.calApprovePath(procId, modelId, bv.getFormVariables()); |
|
|
@ -1874,9 +1804,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
if (bv.getModelId() != null) { |
|
|
|
procId = bv.getModelId(); |
|
|
|
} |
|
|
|
/*if(bv.getFormVariables()==null){ |
|
|
|
return ResultBean.fireFail().setMsg("业务参数集合 不能为空!"); |
|
|
|
}*/ |
|
|
|
if(bv.getFormVariables()==null) |
|
|
|
bv.setFormVariables(new HashMap<String, Object>()); |
|
|
|
List<FlowElement> flowElements = processService.calApprovePath(procId, modelId, bv.getFormVariables()); |
|
|
@ -1888,9 +1815,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
FlowElement f =flowElements.get(i); |
|
|
|
if(i>0&&bv.getTaskDefKey().equals(f.getId())){ |
|
|
|
f =flowElements.get(i-1); |
|
|
|
//this.nextNode=arr[i-1];
|
|
|
|
//不是最后一个环节
|
|
|
|
//this.startTask=false;
|
|
|
|
map.put("name", f.getName()); |
|
|
|
map.put("id", f.getId()); |
|
|
|
String s = JSON.toJSONString(f); |
|
|
@ -1936,7 +1860,6 @@ public class FlowTaskService extends MybatisBaseService<FlowTaskMapper, FlowTask |
|
|
|
taskQuery.active() |
|
|
|
.includeProcessVariables() |
|
|
|
.or() |
|
|
|
//.taskCandidateGroupIn(roleSidList)
|
|
|
|
.taskAssigneeLike("%" + userSid + "%") |
|
|
|
.endOr() |
|
|
|
.orderByTaskCreateTime().desc(); |
|
|
|