|
@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
import com.fjhx.flow.core.FlowBean;
|
|
import com.fjhx.flow.core.FlowBean;
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
@@ -39,6 +41,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
|
+import java.sql.Wrapper;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
@@ -249,6 +252,20 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
case CANCELLATION:
|
|
case CANCELLATION:
|
|
flowResult = cancellation(context);
|
|
flowResult = cancellation(context);
|
|
break;
|
|
break;
|
|
|
|
+ //加签
|
|
|
|
+ case ADD_APPROVAL:
|
|
|
|
+ //修改状态为审批通过
|
|
|
|
+ dto.setHandleType(HandleTypeEnum.SKIP_TO_NEXT.getKey());
|
|
|
|
+ flowResult = transfer(context, dto);
|
|
|
|
+ break;
|
|
|
|
+ //移交
|
|
|
|
+ case TRANSFER:
|
|
|
|
+ flowResult = transfer(context, dto);
|
|
|
|
+ break;
|
|
|
|
+ // 退回到指定节点
|
|
|
|
+ case RETURN_TO_NODE:
|
|
|
|
+ flowResult = returnToNode(context, dto);
|
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
default:
|
|
throw new ServiceException("未知流程跳转类型");
|
|
throw new ServiceException("未知流程跳转类型");
|
|
@@ -401,6 +418,81 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
throw new ServiceException("流程定义错误:未找到结束节点");
|
|
throw new ServiceException("流程定义错误:未找到结束节点");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private FlowResult transfer(FlowJumpContext context, JumpDto dto) {
|
|
|
|
+ Long handleUserId = dto.getHandleUserId();
|
|
|
|
+ if (ObjectUtil.isEmpty(handleUserId)){
|
|
|
|
+ List<SysUser> userList = sysUserService.list(Wrappers.<SysUser>query().eq("company_id", SecurityUtils.getCompanyId()));
|
|
|
|
+
|
|
|
|
+ FlowResult flowResult = new FlowResult();
|
|
|
|
+ flowResult.setSuccess(false);
|
|
|
|
+ flowResult.setUserList(userList);
|
|
|
|
+ return flowResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //生成下一节点信息(复制当前节点)
|
|
|
|
+ FlowResult flowResult = getHandleUser(context.getCurrentNode(), context.getJumpHandleUserId());
|
|
|
|
+ // 流程进行中
|
|
|
|
+ context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
+ // 赋值流程节点审批人为加签用户
|
|
|
|
+ context.setJumpHandleUserId(handleUserId);
|
|
|
|
+ context.setJumpNode(context.getCurrentNode());
|
|
|
|
+ return flowResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 跳转到指定节点
|
|
|
|
+ */
|
|
|
|
+ private FlowResult returnToNode(FlowJumpContext context, JumpDto dto) {
|
|
|
|
+ if (ObjectUtil.isEmpty(dto.getHandleNodeId())) {
|
|
|
|
+
|
|
|
|
+ FlowExample flowExample = context.getFlowExample();
|
|
|
|
+
|
|
|
|
+ // 获取已完成节点
|
|
|
|
+ List<Long> flowNodeIds = flowExampleDetailService.listObject(FlowExampleDetail::getFlowDefinitionNodeId,
|
|
|
|
+ q -> q.eq(FlowExampleDetail::getFlowExampleId, dto.getFlowId()));
|
|
|
|
+
|
|
|
|
+ // 获取流程全部节点
|
|
|
|
+ List<FlowDefinitionNode> flowDefinitionNodeList = flowDefinitionNodeService.list(
|
|
|
|
+ q -> q.eq(FlowDefinitionNode::getFlowDefinitionId, flowExample.getDefinitionId())
|
|
|
|
+ .in(FlowDefinitionNode::getId, flowNodeIds)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ FlowResult flowResult = new FlowResult();
|
|
|
|
+ flowResult.setSuccess(false);
|
|
|
|
+ flowResult.setFlowDefinitionNodeList(flowDefinitionNodeList);
|
|
|
|
+
|
|
|
|
+ return flowResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long handleNodeId = dto.getHandleNodeId();
|
|
|
|
+ List<FlowDefinitionNode> flowDefinitionNodeList = context.getFlowDefinitionNodeList();
|
|
|
|
+ // 节点map
|
|
|
|
+ Map<Long, FlowDefinitionNode> nodeMap = flowDefinitionNodeList.stream()
|
|
|
|
+ .collect(Collectors.toMap(FlowDefinitionNode::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 查找指定节点信息
|
|
|
|
+ FlowDefinitionNode jumpNode = nodeMap.get(handleNodeId);
|
|
|
|
+
|
|
|
|
+ context.setJumpNode(jumpNode);
|
|
|
|
+
|
|
|
|
+ // 如果流程回退到开始节点
|
|
|
|
+ if (NodeTypeEnum.START.getKey().equals(jumpNode.getNodeType())) {
|
|
|
|
+ // 流程未发起
|
|
|
|
+ context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
|
+ // 流程节点处理人为流程发起人
|
|
|
|
+ context.setJumpHandleUserId(context.getFlowExample().getCreateUser());
|
|
|
|
+ return new FlowResult(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
|
+ // 流程进行中
|
|
|
|
+ context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
+ // 赋值流程节点审批人
|
|
|
|
+ context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
|
+
|
|
|
|
+ return flowResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 执行节点方法
|
|
* 执行节点方法
|
|
*/
|
|
*/
|
|
@@ -787,6 +879,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
switch (handleTypeEnum) {
|
|
switch (handleTypeEnum) {
|
|
// 跳转下一节点
|
|
// 跳转下一节点
|
|
|
|
+ case ADD_APPROVAL:
|
|
|
|
+ case TRANSFER:
|
|
case SKIP_TO_NEXT:
|
|
case SKIP_TO_NEXT:
|
|
// 如果流程结束
|
|
// 如果流程结束
|
|
if (FlowStatusEnum.PASS.equals(flowStatusEnum)) {
|
|
if (FlowStatusEnum.PASS.equals(flowStatusEnum)) {
|
|
@@ -812,6 +906,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
break;
|
|
break;
|
|
|
|
|
|
// 退回上一节点
|
|
// 退回上一节点
|
|
|
|
+ case RETURN_TO_NODE:
|
|
case RETURN_TO_PREVIOUS:
|
|
case RETURN_TO_PREVIOUS:
|
|
|
|
|
|
// 查找上次审批节点
|
|
// 查找上次审批节点
|