|
@@ -44,7 +44,6 @@ import org.dromara.warm.flow.orm.mapper.FlowInstanceMapper;
|
|
|
import org.dromara.warm.flow.orm.mapper.FlowNodeMapper;
|
|
import org.dromara.warm.flow.orm.mapper.FlowNodeMapper;
|
|
|
import org.dromara.warm.flow.orm.mapper.FlowTaskMapper;
|
|
import org.dromara.warm.flow.orm.mapper.FlowTaskMapper;
|
|
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
|
|
-import org.dromara.workflow.common.constant.FlowConstant;
|
|
|
|
|
import org.dromara.workflow.common.enums.TaskAssigneeType;
|
|
import org.dromara.workflow.common.enums.TaskAssigneeType;
|
|
|
import org.dromara.workflow.common.enums.TaskOperationEnum;
|
|
import org.dromara.workflow.common.enums.TaskOperationEnum;
|
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
|
@@ -128,6 +127,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
// 已存在流程
|
|
// 已存在流程
|
|
|
BusinessStatusEnum.checkStartStatus(flowInstance.getFlowStatus());
|
|
BusinessStatusEnum.checkStartStatus(flowInstance.getFlowStatus());
|
|
|
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(flowInstance.getId()));
|
|
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(flowInstance.getId()));
|
|
|
|
|
+ if (CollUtil.isEmpty(taskList)) {
|
|
|
|
|
+ throw new ServiceException("流程实例缺少任务,请检查流程定义配置");
|
|
|
|
|
+ }
|
|
|
taskService.mergeVariable(flowInstance, variables);
|
|
taskService.mergeVariable(flowInstance, variables);
|
|
|
insService.updateById(flowInstance);
|
|
insService.updateById(flowInstance);
|
|
|
StartProcessReturnDTO dto = new StartProcessReturnDTO();
|
|
StartProcessReturnDTO dto = new StartProcessReturnDTO();
|
|
@@ -157,6 +159,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
this.buildFlowInstanceBizExt(instance, bizExt);
|
|
this.buildFlowInstanceBizExt(instance, bizExt);
|
|
|
// 申请人执行流程
|
|
// 申请人执行流程
|
|
|
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(instance.getId()));
|
|
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(instance.getId()));
|
|
|
|
|
+ if (CollUtil.isEmpty(taskList)) {
|
|
|
|
|
+ throw new ServiceException("流程启动失败,未生成任务");
|
|
|
|
|
+ }
|
|
|
if (taskList.size() > 1) {
|
|
if (taskList.size() > 1) {
|
|
|
throw new ServiceException("请检查流程第一个环节是否为申请人!");
|
|
throw new ServiceException("请检查流程第一个环节是否为申请人!");
|
|
|
}
|
|
}
|
|
@@ -220,6 +225,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
throw new ServiceException("流程任务不存在或任务已审批!");
|
|
throw new ServiceException("流程任务不存在或任务已审批!");
|
|
|
}
|
|
}
|
|
|
Instance ins = insService.getById(flowTask.getInstanceId());
|
|
Instance ins = insService.getById(flowTask.getInstanceId());
|
|
|
|
|
+ if (ObjectUtil.isNull(ins)) {
|
|
|
|
|
+ throw new ServiceException("流程实例不存在");
|
|
|
|
|
+ }
|
|
|
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
|
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
|
|
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
|
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
|
|
variables.put(SUBMIT, true);
|
|
variables.put(SUBMIT, true);
|
|
@@ -483,6 +491,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
throw new ServiceException("任务不存在!");
|
|
throw new ServiceException("任务不存在!");
|
|
|
}
|
|
}
|
|
|
Instance inst = insService.getById(task.getInstanceId());
|
|
Instance inst = insService.getById(task.getInstanceId());
|
|
|
|
|
+ if (ObjectUtil.isNull(inst)) {
|
|
|
|
|
+ throw new ServiceException("流程实例不存在");
|
|
|
|
|
+ }
|
|
|
BusinessStatusEnum.checkBackStatus(inst.getFlowStatus());
|
|
BusinessStatusEnum.checkBackStatus(inst.getFlowStatus());
|
|
|
Long definitionId = task.getDefinitionId();
|
|
Long definitionId = task.getDefinitionId();
|
|
|
String applyNodeCode = flwCommonService.applyNodeCode(definitionId);
|
|
String applyNodeCode = flwCommonService.applyNodeCode(definitionId);
|
|
@@ -514,6 +525,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
@Override
|
|
@Override
|
|
|
public List<Node> getBackTaskNode(Long taskId, String nowNodeCode) {
|
|
public List<Node> getBackTaskNode(Long taskId, String nowNodeCode) {
|
|
|
FlowTask task = flowTaskMapper.selectById(taskId);
|
|
FlowTask task = flowTaskMapper.selectById(taskId);
|
|
|
|
|
+ if (ObjectUtil.isNull(task)) {
|
|
|
|
|
+ throw new ServiceException("任务不存在!");
|
|
|
|
|
+ }
|
|
|
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), task.getDefinitionId());
|
|
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), task.getDefinitionId());
|
|
|
if (!CollUtil.isNotEmpty(nodeCodes)) {
|
|
if (!CollUtil.isNotEmpty(nodeCodes)) {
|
|
|
return nodeCodes;
|
|
return nodeCodes;
|
|
@@ -598,7 +612,13 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
}
|
|
}
|
|
|
FlowTaskVo flowTaskVo = BeanUtil.toBean(task, FlowTaskVo.class);
|
|
FlowTaskVo flowTaskVo = BeanUtil.toBean(task, FlowTaskVo.class);
|
|
|
Instance instance = insService.getById(task.getInstanceId());
|
|
Instance instance = insService.getById(task.getInstanceId());
|
|
|
|
|
+ if (ObjectUtil.isNull(instance)) {
|
|
|
|
|
+ throw new ServiceException("流程实例不存在");
|
|
|
|
|
+ }
|
|
|
Definition definition = defService.getById(task.getDefinitionId());
|
|
Definition definition = defService.getById(task.getDefinitionId());
|
|
|
|
|
+ if (ObjectUtil.isNull(definition)) {
|
|
|
|
|
+ throw new ServiceException("流程定义不存在");
|
|
|
|
|
+ }
|
|
|
flowTaskVo.setFlowStatus(instance.getFlowStatus());
|
|
flowTaskVo.setFlowStatus(instance.getFlowStatus());
|
|
|
flowTaskVo.setVersion(definition.getVersion());
|
|
flowTaskVo.setVersion(definition.getVersion());
|
|
|
flowTaskVo.setFlowCode(definition.getFlowCode());
|
|
flowTaskVo.setFlowCode(definition.getFlowCode());
|
|
@@ -641,11 +661,23 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
Long taskId = bo.getTaskId();
|
|
Long taskId = bo.getTaskId();
|
|
|
Map<String, Object> variables = bo.getVariables();
|
|
Map<String, Object> variables = bo.getVariables();
|
|
|
Task task = taskService.getById(taskId);
|
|
Task task = taskService.getById(taskId);
|
|
|
|
|
+ if (ObjectUtil.isNull(task)) {
|
|
|
|
|
+ throw new ServiceException("任务不存在!");
|
|
|
|
|
+ }
|
|
|
Instance instance = insService.getById(task.getInstanceId());
|
|
Instance instance = insService.getById(task.getInstanceId());
|
|
|
|
|
+ if (ObjectUtil.isNull(instance)) {
|
|
|
|
|
+ throw new ServiceException("流程实例不存在");
|
|
|
|
|
+ }
|
|
|
Definition definition = defService.getById(task.getDefinitionId());
|
|
Definition definition = defService.getById(task.getDefinitionId());
|
|
|
|
|
+ if (ObjectUtil.isNull(definition)) {
|
|
|
|
|
+ throw new ServiceException("流程定义不存在");
|
|
|
|
|
+ }
|
|
|
Map<String, Object> mergeVariable = MapUtil.mergeAll(instance.getVariableMap(), variables);
|
|
Map<String, Object> mergeVariable = MapUtil.mergeAll(instance.getVariableMap(), variables);
|
|
|
// 获取下一节点列表
|
|
// 获取下一节点列表
|
|
|
List<Node> nextNodeList = nodeService.getNextNodeList(task.getDefinitionId(), task.getNodeCode(), null, SkipType.PASS.getKey(), mergeVariable);
|
|
List<Node> nextNodeList = nodeService.getNextNodeList(task.getDefinitionId(), task.getNodeCode(), null, SkipType.PASS.getKey(), mergeVariable);
|
|
|
|
|
+ if (CollUtil.isEmpty(nextNodeList)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
List<FlowNode> nextFlowNodes = BeanUtil.copyToList(nextNodeList, FlowNode.class);
|
|
List<FlowNode> nextFlowNodes = BeanUtil.copyToList(nextNodeList, FlowNode.class);
|
|
|
// 只获取中间节点
|
|
// 只获取中间节点
|
|
|
nextFlowNodes = StreamUtils.filter(nextFlowNodes, node -> NodeType.BETWEEN.getKey().equals(node.getNodeType()));
|
|
nextFlowNodes = StreamUtils.filter(nextFlowNodes, node -> NodeType.BETWEEN.getKey().equals(node.getNodeType()));
|
|
@@ -749,7 +781,13 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
|
|
|
|
|
|
Long taskId = bo.getTaskId();
|
|
Long taskId = bo.getTaskId();
|
|
|
Task task = taskService.getById(taskId);
|
|
Task task = taskService.getById(taskId);
|
|
|
|
|
+ if (ObjectUtil.isNull(task)) {
|
|
|
|
|
+ throw new ServiceException("任务不存在!");
|
|
|
|
|
+ }
|
|
|
FlowNode flowNode = getByNodeCode(task.getNodeCode(), task.getDefinitionId());
|
|
FlowNode flowNode = getByNodeCode(task.getNodeCode(), task.getDefinitionId());
|
|
|
|
|
+ if (ObjectUtil.isNull(flowNode)) {
|
|
|
|
|
+ throw new ServiceException("流程节点不存在");
|
|
|
|
|
+ }
|
|
|
if (op == TaskOperationEnum.ADD_SIGNATURE || op == TaskOperationEnum.REDUCTION_SIGNATURE) {
|
|
if (op == TaskOperationEnum.ADD_SIGNATURE || op == TaskOperationEnum.REDUCTION_SIGNATURE) {
|
|
|
if (CooperateType.isOrSign(flowNode.getNodeRatio())) {
|
|
if (CooperateType.isOrSign(flowNode.getNodeRatio())) {
|
|
|
throw new ServiceException(task.getNodeName() + "不是会签或票签节点!");
|
|
throw new ServiceException(task.getNodeName() + "不是会签或票签节点!");
|