|
@@ -17,11 +17,9 @@ import com.fjhx.flow.entity.flow.dto.FlowResult;
|
|
|
import com.fjhx.flow.entity.flow.dto.InitiateDto;
|
|
|
import com.fjhx.flow.entity.flow.dto.JumpDto;
|
|
|
import com.fjhx.flow.entity.flow.po.*;
|
|
|
-import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
-import com.fjhx.flow.enums.HandleObjectTypeEnum;
|
|
|
-import com.fjhx.flow.enums.HandleTypeEnum;
|
|
|
-import com.fjhx.flow.enums.NodeTypeEnum;
|
|
|
+import com.fjhx.flow.enums.*;
|
|
|
import com.fjhx.flow.service.flow.*;
|
|
|
+import com.fjhx.socket.core.PushParam;
|
|
|
import com.fjhx.socket.core.PushTypeEnum;
|
|
|
import com.fjhx.socket.core.WebSocketPush;
|
|
|
import com.googlecode.aviator.AviatorEvaluator;
|
|
@@ -36,6 +34,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.system.service.ISysUserIdentityService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -57,6 +56,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
@Autowired
|
|
|
private FlowDefinitionNodeService flowDefinitionNodeService;
|
|
|
+ @Autowired
|
|
|
+ private FlowDefinitionLineService flowDefinitionLineService;
|
|
|
|
|
|
@Autowired
|
|
|
private FlowExampleService flowExampleService;
|
|
@@ -74,10 +75,13 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowInfoService flowInfoService;
|
|
|
@Autowired
|
|
|
private ISysUserIdentityService sysUserIdentityService;
|
|
|
+ @Autowired
|
|
|
+ private FlowExampleCurrentService flowExampleCurrentService;
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public FlowResult initiate(InitiateDto dto) {
|
|
|
+ dto.getData().put("createUser",SecurityUtils.getUserId());
|
|
|
|
|
|
// 获取流程委托对象
|
|
|
FlowDelegate flowDelegate = FlowBean.getBean(dto.getFlowKey());
|
|
@@ -91,14 +95,15 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
throw new ServiceException("流程未配置,请联系管理员");
|
|
|
}
|
|
|
|
|
|
- // 流程节点列表
|
|
|
- List<FlowDefinitionNode> flowDefinitionNodeList = flowDefinitionNodeService.list(q -> q
|
|
|
- .eq(FlowDefinitionNode::getFlowDefinitionId, flowDefinition.getId()));
|
|
|
+// // 流程节点列表
|
|
|
+// List<FlowDefinitionNode> flowDefinitionNodeList1 = flowDefinitionNodeService.list(q -> q
|
|
|
+// .eq(FlowDefinitionNode::getFlowDefinitionId, flowDefinition.getId()));
|
|
|
|
|
|
// 寻找开始节点
|
|
|
- FlowDefinitionNode startNode = flowDefinitionNodeList.stream()
|
|
|
- .filter(item -> NodeTypeEnum.START.getKey().equals(item.getNodeType()))
|
|
|
- .findFirst().orElse(null);
|
|
|
+ FlowDefinitionNode startNode = flowDefinitionNodeService.getOne(q -> q
|
|
|
+ .eq(FlowDefinitionNode::getFlowDefinitionId, flowDefinition.getId())
|
|
|
+ .eq(FlowDefinitionNode::getNodeType, NodeTypeEnum.START.getKey())
|
|
|
+ );
|
|
|
|
|
|
if (startNode == null) {
|
|
|
throw new ServiceException("流程定义错误:没有找到开始节点");
|
|
@@ -116,27 +121,36 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowThreadLocal.setHandleTypeEnum(HandleTypeEnum.SKIP_TO_NEXT);
|
|
|
flowThreadLocal.setCurrentNodeTypeEnum(NodeTypeEnum.START);
|
|
|
flowThreadLocal.setDynamicUserIds(flowDelegate.getHandlingUserList(flowId, dto.getData()));
|
|
|
+ flowThreadLocal.setFlowCreateUser(SecurityUtils.getUserId());
|
|
|
|
|
|
// 寻找下一节点
|
|
|
- FlowDefinitionNode nextUserNode = getNextUserNode(startNode, flowDefinitionNodeList);
|
|
|
- NodeTypeEnum nextNodeType = NodeTypeEnum.getEnum(nextUserNode.getNodeType());
|
|
|
+ List<FlowDefinitionLine> flowLineList = flowDefinitionLineService.list(q -> q
|
|
|
+ .eq(FlowDefinitionLine::getFlowDefinitionId, flowDefinition.getId())
|
|
|
+ .eq(FlowDefinitionLine::getSourceId, startNode.getId())
|
|
|
+ );
|
|
|
+ List<FlowDefinitionNode> nextUserNodes = getNextUserNode(startNode, flowLineList);
|
|
|
+
|
|
|
+ FlowDefinitionNode endNode = nextUserNodes.stream()
|
|
|
+ .filter(item -> ObjectUtil.equals(NodeTypeEnum.getEnum(item.getNodeType()), NodeTypeEnum.END))
|
|
|
+ .findFirst().orElse(null);
|
|
|
|
|
|
// 流程实例
|
|
|
FlowExample flowExample = new FlowExample();
|
|
|
|
|
|
- // 如果下一节点不为结束节点,赋值下一个节点处理用户id
|
|
|
- if (!NodeTypeEnum.END.equals(nextNodeType)) {
|
|
|
-
|
|
|
- FlowResult handleUser = getHandleUser(nextUserNode, dto.getHandleUserId());
|
|
|
- // 如果下一节点处理用户只有1人,赋值用户id
|
|
|
- if (handleUser.getSuccess()) {
|
|
|
- flowExample.setHandleUserId(handleUser.getUserId());
|
|
|
- flowThreadLocal.setNextHandleUserId(handleUser.getUserId());
|
|
|
+ // 如果下一节点不包含结束节点,赋值下一个节点处理用户id
|
|
|
+ if (endNode == null) {
|
|
|
+ List<FlowResult.SelectUser> selectUserList = dto.getSelectUserList();
|
|
|
+ if (selectUserList == null) {
|
|
|
+ selectUserList = new ArrayList<>();
|
|
|
}
|
|
|
- // 如果下一节点处理用户有多人,则返回用户列表让用户选择下一节点处理人id
|
|
|
- else {
|
|
|
- return handleUser;
|
|
|
+ //检查并赋值下一节点处理人信息,以及待办
|
|
|
+ FlowResult flowResult = setNextHandleNodeHandleUser(nextUserNodes, selectUserList);
|
|
|
+ if (!flowResult.getSuccess()) {
|
|
|
+ return flowResult;
|
|
|
}
|
|
|
+ //创建待办信息
|
|
|
+ createPendingInfo(nextUserNodes, flowId);
|
|
|
+
|
|
|
// 流程进行中
|
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
flowThreadLocal.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
@@ -170,7 +184,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
startExampleDetail.setSubmitData(JSONObject.toJSONString(dto));
|
|
|
flowExampleDetailList.add(startExampleDetail);
|
|
|
|
|
|
- if (NodeTypeEnum.END.equals(nextNodeType)) {
|
|
|
+
|
|
|
+ // 如果下一节点包含结束节点
|
|
|
+ if (endNode != null) {
|
|
|
+ FlowDefinitionNode nextUserNode = endNode;
|
|
|
+
|
|
|
|
|
|
// 赋值业务id到租户线程
|
|
|
flowThreadLocal.setBusinessId(businessId);
|
|
@@ -187,11 +205,12 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowExampleDetailList.add(endExampleDetail);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
flowExample.setId(flowId);
|
|
|
flowExample.setTitle(templateParse(flowDefinition.getTitleTemplate(), templateMap));
|
|
|
flowExample.setFlowKey(dto.getFlowKey());
|
|
|
flowExample.setDefinitionId(flowDefinition.getId());
|
|
|
- flowExample.setDefinitionNodeId(nextUserNode.getId());
|
|
|
+// flowExample.setDefinitionNodeId(nextUserNode.getId());
|
|
|
flowExample.setBusinessId(businessId);
|
|
|
flowExample.setStartData(dto.getData().toJSONString());
|
|
|
flowExample.setDefinitionVersion(flowDefinition.getVersionNumber());
|
|
@@ -203,7 +222,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
ObsFileUtil.saveFile(dto.getFileList(), startExampleDetail.getId());
|
|
|
|
|
|
// 推送
|
|
|
- pushInitiateMessage(flowId, flowDefinition, nextNodeType, flowExample);
|
|
|
+ pushInitiateMessage(flowId, flowDefinition, nextUserNodes);
|
|
|
|
|
|
// 清空ThreadLocal
|
|
|
FlowThreadLocalUtil.remove();
|
|
@@ -229,6 +248,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowThreadLocal.setFlowId(dto.getFlowId());
|
|
|
flowThreadLocal.setBusinessId(context.getFlowExample().getBusinessId());
|
|
|
flowThreadLocal.setDynamicUserIds(flowDelegate.getHandlingUserList(dto.getFlowId(), startData));
|
|
|
+ flowThreadLocal.setFlowCreateUser(context.getFlowExample().getCreateUser());
|
|
|
|
|
|
FlowResult flowResult;
|
|
|
|
|
@@ -284,13 +304,22 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
return flowResult;
|
|
|
}
|
|
|
|
|
|
+ //删除当前用户待审批数据
|
|
|
+ flowExampleCurrentService.remove(q -> q
|
|
|
+ .eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId())
|
|
|
+ .eq(FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
flowThreadLocal.setFlowStatusEnum(context.getFlowStatus());
|
|
|
flowThreadLocal.setHandleTypeEnum(context.getHandleType());
|
|
|
- flowThreadLocal.setNextHandleUserId(context.getJumpHandleUserId());
|
|
|
+// flowThreadLocal.setNextHandleUserId(context.getJumpHandleUserId());
|
|
|
flowThreadLocal.setCurrentNodeTypeEnum(context.getCurrentNodeType());
|
|
|
|
|
|
- // 执行节点方法
|
|
|
- executiveNodeMethod(context);
|
|
|
+ //如果非 抄送节点
|
|
|
+ if (!NodeHandleTypeEnum.CARBON_COPY.getKey().equals(context.getCurrentNode().getNodeHandleType())) {
|
|
|
+ // 执行节点方法
|
|
|
+ executiveNodeMethod(context);
|
|
|
+ }
|
|
|
|
|
|
// 保存数据
|
|
|
editExample(context);
|
|
@@ -316,43 +345,103 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
return JSONObject.parseObject(flowExample.getStartData());
|
|
|
}
|
|
|
|
|
|
+ private FlowResult setNextHandleNodeHandleUser(List<FlowDefinitionNode> nextUserNodes, List<FlowResult.SelectUser> selectUserList) {
|
|
|
+ List<FlowResult.SelectUser> reSelectUserList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (FlowDefinitionNode nextUserNode : nextUserNodes) {
|
|
|
+ FlowResult handleUser = getHandleUser(nextUserNode, selectUserList);
|
|
|
+ // 如果下一节点处理用户只有1人,赋值用户id
|
|
|
+ if (handleUser.getSuccess()) {
|
|
|
+ nextUserNode.setJumpHandleUserId(handleUser.getUserId());
|
|
|
+ }
|
|
|
+ // 如果下一节点处理用户有多人,则返回用户列表让用户选择下一节点处理人id
|
|
|
+ else {
|
|
|
+ FlowResult.SelectUser selectUser = new FlowResult.SelectUser();
|
|
|
+ selectUser.setNodeId(nextUserNode.getId());
|
|
|
+ selectUser.setNodeName(nextUserNode.getNodeName());
|
|
|
+ selectUser.setUserList(handleUser.getUserList());
|
|
|
+
|
|
|
+ reSelectUserList.add(selectUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回选择用户列表
|
|
|
+ if (reSelectUserList.size() > 0) {
|
|
|
+ FlowResult flowResult = new FlowResult();
|
|
|
+ flowResult.setSuccess(false);
|
|
|
+ flowResult.setSelectUserList(reSelectUserList);
|
|
|
+ return flowResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ FlowResult flowResult = new FlowResult();
|
|
|
+ flowResult.setSuccess(true);
|
|
|
+ return flowResult;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 流程跳转到下一个节点
|
|
|
*/
|
|
|
private FlowResult skipToNext(FlowJumpContext context) {
|
|
|
|
|
|
+ FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
// 寻找跳转节点
|
|
|
- FlowDefinitionNode jumpNode = getNextUserNode(context.getCurrentNode(), context.getFlowDefinitionNodeList());
|
|
|
-
|
|
|
- //如果当前节点是动态并行节点
|
|
|
- if (HandleObjectTypeEnum.PARALLEL.getKey().equals(context.getCurrentNode().getHandleObjectType())) {
|
|
|
- String jumpHandleUserId = context.getFlowExample().getHandleUserId();
|
|
|
- List<Long> collect = Arrays.stream(jumpHandleUserId.split(",")).map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
- collect.remove(SecurityUtils.getUserId());
|
|
|
- if (ObjectUtil.isNotEmpty(collect)) {
|
|
|
- jumpHandleUserId = collect.stream().map(item -> String.valueOf(item)).collect(Collectors.joining(","));
|
|
|
- jumpNode = context.getCurrentNode();
|
|
|
- }
|
|
|
- context.setJumpHandleUserId(jumpHandleUserId);
|
|
|
+ List<FlowDefinitionNode> jumpNodes = getNextUserNode(currentNode, context.getFlowDefinitionLineList());
|
|
|
+
|
|
|
+ //检查当前节点是否全部审批完成
|
|
|
+ long count = flowExampleCurrentService.count(q -> q
|
|
|
+ .eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId())
|
|
|
+ .eq(FlowExampleCurrent::getNodeId, currentNode.getId())
|
|
|
+ .ne(FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ //如果当前节点没有全部审批完成 || 当前节点处理方式是抄送 直接跳过
|
|
|
+ if (count > 0 || NodeHandleTypeEnum.CARBON_COPY.getKey().equals(currentNode.getNodeHandleType())) {
|
|
|
+ //回填流程当前状态
|
|
|
+ context.setFlowStatus(FlowStatusEnum.getEnum(context.getFlowExample().getStatus()));
|
|
|
+ context.setJumpNodeList(new ArrayList<>());
|
|
|
+ return new FlowResult(true);
|
|
|
}
|
|
|
|
|
|
- context.setJumpNode(jumpNode);
|
|
|
+ List<FlowDefinitionNode> newJumpNodes = new ArrayList<>();
|
|
|
|
|
|
- // 如果下一节点为结束节点
|
|
|
- if (NodeTypeEnum.END.equals(NodeTypeEnum.getEnum(jumpNode.getNodeType()))) {
|
|
|
- // 流程已通过
|
|
|
- context.setFlowStatus(FlowStatusEnum.PASS);
|
|
|
- // 流程结束,则流程节点审批人不存在
|
|
|
- context.setJumpHandleUserId(null);
|
|
|
- return new FlowResult(true);
|
|
|
+ for (FlowDefinitionNode jumpNode : jumpNodes) {
|
|
|
+ // 如果下一节点包含结束节点
|
|
|
+ if (NodeTypeEnum.END.getKey().equals(jumpNode.getNodeType())) {
|
|
|
+ // 流程已通过
|
|
|
+ context.setFlowStatus(FlowStatusEnum.PASS);
|
|
|
+ context.setJumpNodeList(Collections.singletonList(jumpNode));
|
|
|
+ // 流程结束,则流程节点审批人不存在
|
|
|
+ jumpNode.setJumpHandleUserId(null);
|
|
|
+ return new FlowResult(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果下一节点包含聚合节点
|
|
|
+ if (NodeHandleTypeEnum.POLYMERIZE.getKey().equals(jumpNode.getNodeHandleType())) {
|
|
|
+ List<FlowDefinitionNode> lastUserNodeList = getLastOneUserNode(jumpNode, context.getFlowDefinitionNodeList(), context.getFlowExample().getDefinitionId());
|
|
|
+ List<Long> lastNodeIds = lastUserNodeList.stream().map(FlowDefinitionNode::getId).collect(Collectors.toList());
|
|
|
+ long count1 = flowExampleCurrentService.count(q -> q
|
|
|
+ .eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId())
|
|
|
+ .in(FlowExampleCurrent::getNodeId, lastNodeIds)
|
|
|
+ .ne(FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ //聚合节点存在未完成的前置节点
|
|
|
+ if (count1 > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ newJumpNodes.add(jumpNode);
|
|
|
}
|
|
|
|
|
|
- // 寻找节点审批人
|
|
|
- FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
+ // 寻找节点审批人,并生成待审批数据
|
|
|
+// FlowResult flowResult = getHandleUser(jumpNode, context.getSelectUserList());
|
|
|
+ FlowResult flowResult = setNextHandleNodeHandleUser(newJumpNodes, context.getSelectUserList());
|
|
|
// 流程进行中
|
|
|
context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
- // 赋值流程节点审批人
|
|
|
- context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
+// // 赋值流程节点审批人
|
|
|
+// context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
+ context.setJumpNodeList(newJumpNodes);
|
|
|
|
|
|
return flowResult;
|
|
|
}
|
|
@@ -363,12 +452,14 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowResult reject(FlowJumpContext context) {
|
|
|
// 流程已驳回
|
|
|
context.setFlowStatus(FlowStatusEnum.REJECT);
|
|
|
- // 流程结束,则流程节点审批人不存在
|
|
|
- context.setJumpHandleUserId(null);
|
|
|
+// // 流程结束,则流程节点审批人不存在
|
|
|
+// context.setJumpHandleUserId(null);
|
|
|
+
|
|
|
+ flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
|
|
|
|
|
|
for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
|
|
|
if (NodeTypeEnum.END.getKey().equals(flowDefinitionNode.getNodeType())) {
|
|
|
- context.setJumpNode(flowDefinitionNode);
|
|
|
+ context.setJumpNodeList(new ArrayList<>());
|
|
|
return new FlowResult(true);
|
|
|
}
|
|
|
}
|
|
@@ -380,24 +471,32 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
*/
|
|
|
private FlowResult returnToPrevious(FlowJumpContext context) {
|
|
|
|
|
|
+ FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
+
|
|
|
// 寻找跳转节点
|
|
|
- FlowDefinitionNode jumpNode = getLastOneUserNode(context.getCurrentNode(), context.getFlowDefinitionNodeList());
|
|
|
- context.setJumpNode(jumpNode);
|
|
|
+ Long definitionId = context.getFlowExample().getDefinitionId();
|
|
|
+ List<FlowDefinitionNode> jumpNodes = getLastOneUserNode(currentNode, context.getFlowDefinitionNodeList(), definitionId);
|
|
|
+ context.setJumpNodeList(jumpNodes);
|
|
|
+
|
|
|
+ FlowDefinitionNode startNode = jumpNodes.stream()
|
|
|
+ .filter(item -> ObjectUtil.equals(NodeTypeEnum.getEnum(item.getNodeType()), NodeTypeEnum.START))
|
|
|
+ .findFirst().orElse(null);
|
|
|
|
|
|
// 如果流程回退到开始节点
|
|
|
- if (NodeTypeEnum.START.getKey().equals(jumpNode.getNodeType())) {
|
|
|
+ if (startNode != null) {
|
|
|
// 流程未发起
|
|
|
context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
// 流程节点处理人为流程发起人
|
|
|
- context.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
+ startNode.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
+
|
|
|
+ context.setJumpNodeList(Collections.singletonList(startNode));
|
|
|
return new FlowResult(true);
|
|
|
}
|
|
|
|
|
|
- FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
+ // 赋值流程节点审批人
|
|
|
+ FlowResult flowResult = setNextHandleNodeHandleUser(jumpNodes, context.getSelectUserList());
|
|
|
// 流程进行中
|
|
|
context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
- // 赋值流程节点审批人
|
|
|
- context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
|
|
|
return flowResult;
|
|
|
}
|
|
@@ -408,12 +507,13 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowResult returnToSubmitter(FlowJumpContext context) {
|
|
|
// 流程未发起
|
|
|
context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
- // 赋值发起人为节点审批人
|
|
|
- context.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
|
|
|
for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
|
|
|
if (NodeTypeEnum.START.getKey().equals(flowDefinitionNode.getNodeType())) {
|
|
|
- context.setJumpNode(flowDefinitionNode);
|
|
|
+ // 赋值发起人为节点审批人
|
|
|
+ flowDefinitionNode.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
+
|
|
|
+ context.setJumpNodeList(Collections.singletonList(flowDefinitionNode));
|
|
|
return new FlowResult(true);
|
|
|
}
|
|
|
}
|
|
@@ -426,12 +526,15 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowResult cancellation(FlowJumpContext context) {
|
|
|
// 流程未发起
|
|
|
context.setFlowStatus(FlowStatusEnum.CANCELLATION);
|
|
|
- // 流程作废,则流程节点审批人不存在
|
|
|
- context.setJumpHandleUserId(null);
|
|
|
+
|
|
|
+ flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
|
|
|
|
|
|
for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
|
|
|
if (NodeTypeEnum.END.getKey().equals(flowDefinitionNode.getNodeType())) {
|
|
|
- context.setJumpNode(flowDefinitionNode);
|
|
|
+ // 流程作废,则流程节点审批人不存在
|
|
|
+ flowDefinitionNode.setJumpHandleUserId(null);
|
|
|
+
|
|
|
+ context.setJumpNodeList(new ArrayList<>());
|
|
|
return new FlowResult(true);
|
|
|
}
|
|
|
}
|
|
@@ -439,8 +542,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
private FlowResult transfer(FlowJumpContext context, JumpDto dto) {
|
|
|
- String handleUserId = dto.getHandleUserId();
|
|
|
- if (ObjectUtil.isEmpty(handleUserId)) {
|
|
|
+ List<FlowResult.SelectUser> handleUserList = dto.getSelectUserList();
|
|
|
+ if (ObjectUtil.isEmpty(handleUserList)) {
|
|
|
List<SysUser> userList = sysUserService.list(Wrappers.<SysUser>query().eq("company_id", SecurityUtils.getCompanyId()));
|
|
|
|
|
|
FlowResult flowResult = new FlowResult();
|
|
@@ -450,29 +553,15 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
//生成下一节点信息(复制当前节点)
|
|
|
- FlowResult flowResult = getHandleUser(context.getCurrentNode(), context.getJumpHandleUserId());
|
|
|
+ FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
// 流程进行中
|
|
|
context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
|
|
- //如果当前节点是动态并行节点
|
|
|
- if (HandleObjectTypeEnum.PARALLEL.getKey().equals(context.getCurrentNode().getHandleObjectType())) {
|
|
|
- String jumpHandleUserId = context.getJumpHandleUserId();
|
|
|
- List<Long> collect = Arrays.stream(jumpHandleUserId.split(",")).map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
- collect.remove(SecurityUtils.getUserId());
|
|
|
- //添加加签用户
|
|
|
- collect.add(Long.valueOf(jumpHandleUserId));
|
|
|
- if (ObjectUtil.isNotEmpty(collect)) {
|
|
|
- jumpHandleUserId = collect.stream().map(item -> String.valueOf(item)).collect(Collectors.joining(","));
|
|
|
- }
|
|
|
- context.setJumpHandleUserId(jumpHandleUserId);
|
|
|
- } else {
|
|
|
- // 赋值流程节点审批人为加签用户
|
|
|
- context.setJumpHandleUserId(handleUserId);
|
|
|
- }
|
|
|
-
|
|
|
+ String handleUserIdStr = handleUserList.stream().map(FlowResult.SelectUser::getHandleUserId).collect(Collectors.joining(","));
|
|
|
+ currentNode.setJumpHandleUserId(handleUserIdStr);
|
|
|
|
|
|
- context.setJumpNode(context.getCurrentNode());
|
|
|
- return flowResult;
|
|
|
+ context.setJumpNodeList(Collections.singletonList(currentNode));
|
|
|
+ return new FlowResult(true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -511,22 +600,22 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 查找指定节点信息
|
|
|
FlowDefinitionNode jumpNode = nodeMap.get(handleNodeId);
|
|
|
|
|
|
- context.setJumpNode(jumpNode);
|
|
|
+ context.setJumpNodeList(Collections.singletonList(jumpNode));
|
|
|
|
|
|
// 如果流程回退到开始节点
|
|
|
if (NodeTypeEnum.START.getKey().equals(jumpNode.getNodeType())) {
|
|
|
// 流程未发起
|
|
|
context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
// 流程节点处理人为流程发起人
|
|
|
- context.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
+ jumpNode.setJumpHandleUserId(String.valueOf(context.getFlowExample().getCreateUser()));
|
|
|
return new FlowResult(true);
|
|
|
}
|
|
|
|
|
|
- FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
+ FlowResult flowResult = getHandleUser(jumpNode, context.getSelectUserList());
|
|
|
// 流程进行中
|
|
|
context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
// 赋值流程节点审批人
|
|
|
- context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
+ jumpNode.setJumpHandleUserId(flowResult.getUserId());
|
|
|
|
|
|
return flowResult;
|
|
|
}
|
|
@@ -579,7 +668,10 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
// 结束节点
|
|
|
if (FlowStatusEnum.PASS.equals(flowStatus)) {
|
|
|
- invokeEndMethod(context.getJumpNode(), flowDelegate);
|
|
|
+ FlowDefinitionNode endNode = context.getJumpNodeList().stream()
|
|
|
+ .filter(item -> ObjectUtil.equals(NodeTypeEnum.getEnum(item.getNodeType()), NodeTypeEnum.END))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ invokeEndMethod(endNode, flowDelegate);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -635,7 +727,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
JumpDto dto = context.getJumpDto();
|
|
|
FlowExample flowExample = context.getFlowExample();
|
|
|
FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
- FlowDefinitionNode jumpNode = context.getJumpNode();
|
|
|
+// FlowDefinitionNode jumpNode = context.getJumpNode();
|
|
|
|
|
|
//退回发起人后 重新赋值流程标题
|
|
|
if (ObjectUtil.isNotEmpty(dto.getData())) {
|
|
@@ -658,8 +750,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
// 更新流程实例
|
|
|
- flowExample.setDefinitionNodeId(jumpNode.getId());
|
|
|
- flowExample.setHandleUserId(context.getJumpHandleUserId());
|
|
|
+// flowExample.setDefinitionNodeId(jumpNode.getId());
|
|
|
+// flowExample.setHandleUserId(context.getJumpHandleUserId());
|
|
|
flowExample.setStatus(context.getFlowStatus().getKey());
|
|
|
boolean updateFlag = flowExampleService.updateById(flowExample);
|
|
|
if (!updateFlag) {
|
|
@@ -677,14 +769,23 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
nodeExampleDetail.setSubmitData(JSONObject.toJSONString(dto));
|
|
|
flowExampleDetailList.add(nodeExampleDetail);
|
|
|
|
|
|
+
|
|
|
+ List<FlowDefinitionNode> jumpNodeList = context.getJumpNodeList();
|
|
|
// 如果流程已结束
|
|
|
if (FlowStatusEnum.PASS.equals(context.getFlowStatus())) {
|
|
|
- FlowExampleDetail endExampleDetail = new FlowExampleDetail();
|
|
|
- endExampleDetail.setFlowExampleId(flowExample.getId());
|
|
|
- endExampleDetail.setFlowDefinitionNodeId(jumpNode.getId());
|
|
|
- endExampleDetail.setFlowDefinitionNodeType(jumpNode.getNodeType());
|
|
|
- endExampleDetail.setHandleType(HandleTypeEnum.SKIP_TO_NEXT.getKey());
|
|
|
- flowExampleDetailList.add(endExampleDetail);
|
|
|
+ for (FlowDefinitionNode flowDefinitionNode : jumpNodeList) {
|
|
|
+ if (NodeTypeEnum.END.equals(NodeTypeEnum.getEnum(flowDefinitionNode.getNodeType()))) {
|
|
|
+ FlowExampleDetail endExampleDetail = new FlowExampleDetail();
|
|
|
+ endExampleDetail.setFlowExampleId(flowExample.getId());
|
|
|
+ endExampleDetail.setFlowDefinitionNodeId(flowDefinitionNode.getId());
|
|
|
+ endExampleDetail.setFlowDefinitionNodeType(flowDefinitionNode.getNodeType());
|
|
|
+ endExampleDetail.setHandleType(HandleTypeEnum.SKIP_TO_NEXT.getKey());
|
|
|
+ flowExampleDetailList.add(endExampleDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //保存待办信息
|
|
|
+ createPendingInfo(jumpNodeList, context.getFlowExample().getId());
|
|
|
}
|
|
|
|
|
|
// 保存流程明细
|
|
@@ -696,85 +797,90 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 创建待办信息
|
|
|
+ */
|
|
|
+ void createPendingInfo(List<FlowDefinitionNode> jumpNodeList, Long flowId) {
|
|
|
+ List<FlowExampleCurrent> flowExampleCurrentList = new ArrayList<>();
|
|
|
+ for (FlowDefinitionNode flowDefinitionNode : jumpNodeList) {
|
|
|
+ String jumpHandleUserId = flowDefinitionNode.getJumpHandleUserId();
|
|
|
+ List<Long> collect = Arrays.stream(jumpHandleUserId.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ for (Long userId : collect) {
|
|
|
+ FlowExampleCurrent flowExampleCurrent = new FlowExampleCurrent();
|
|
|
+ flowExampleCurrent.setFlowExampleId(flowId);
|
|
|
+ flowExampleCurrent.setNodeId(flowDefinitionNode.getId());
|
|
|
+ flowExampleCurrent.setHandleUserId(userId);
|
|
|
+ flowExampleCurrentList.add(flowExampleCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存待办信息
|
|
|
+ flowExampleCurrentService.saveBatch(flowExampleCurrentList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查找上一个节点
|
|
|
*
|
|
|
* @param currentNode 当前节点
|
|
|
* @param flowDefinitionNodeList 流程节点列表
|
|
|
* @return 用户节点
|
|
|
*/
|
|
|
- private FlowDefinitionNode getLastOneUserNode(FlowDefinitionNode currentNode, List<FlowDefinitionNode> flowDefinitionNodeList) {
|
|
|
+ private List<FlowDefinitionNode> getLastOneUserNode(FlowDefinitionNode currentNode, List<FlowDefinitionNode> flowDefinitionNodeList, Long flowDefinitionId) {
|
|
|
+ List<Long> lastNodeIds = flowDefinitionLineService.listObject(FlowDefinitionLine::getSourceId, q -> q
|
|
|
+ .eq(FlowDefinitionLine::getFlowDefinitionId, flowDefinitionId)
|
|
|
+ .eq(FlowDefinitionLine::getTargetId, currentNode.getId()));
|
|
|
+
|
|
|
// 节点map
|
|
|
Map<Long, FlowDefinitionNode> nodeMap = flowDefinitionNodeList.stream()
|
|
|
.collect(Collectors.toMap(FlowDefinitionNode::getId, Function.identity()));
|
|
|
|
|
|
// 查找上个节点
|
|
|
- FlowDefinitionNode lastNode = nodeMap.get(currentNode.getParentId());
|
|
|
-
|
|
|
- // 如果为分支
|
|
|
- if (NodeTypeEnum.BRANCH.equals(NodeTypeEnum.getEnum(lastNode.getNodeType()))) {
|
|
|
- return getLastOneUserNode(lastNode, flowDefinitionNodeList);
|
|
|
+ List<FlowDefinitionNode> lastNodeList = new ArrayList<>();
|
|
|
+ for (Long lastNodeId : lastNodeIds) {
|
|
|
+ lastNodeList.add(nodeMap.get(lastNodeId));
|
|
|
}
|
|
|
+//
|
|
|
+// // 如果为分支
|
|
|
+// if (NodeTypeEnum.BRANCH.equals(NodeTypeEnum.getEnum(lastNode.getNodeType()))) {
|
|
|
+// return getLastOneUserNode(lastNode, flowDefinitionNodeList);
|
|
|
+// }
|
|
|
|
|
|
- return lastNode;
|
|
|
+ return lastNodeList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查找下一个节点
|
|
|
*
|
|
|
* @param currentNode 当前节点
|
|
|
- * @param flowDefinitionNodeList 流程节点列表
|
|
|
+ * @param flowDefinitionLineList 流程节点连线列表
|
|
|
* @return 用户节点
|
|
|
*/
|
|
|
- private FlowDefinitionNode getNextUserNode(FlowDefinitionNode currentNode, List<FlowDefinitionNode> flowDefinitionNodeList) {
|
|
|
-
|
|
|
- // 父级节点map
|
|
|
- Map<Long, List<FlowDefinitionNode>> parentNodeMap = flowDefinitionNodeList.stream()
|
|
|
- .collect(Collectors.groupingBy(FlowDefinitionNode::getParentId));
|
|
|
-
|
|
|
- // 查找下个节点
|
|
|
- List<FlowDefinitionNode> nextNodeList = parentNodeMap.get(currentNode.getId());
|
|
|
- FlowDefinitionNode nextNode = null;
|
|
|
-
|
|
|
- // 如果为分支
|
|
|
- if (NodeTypeEnum.BRANCH.equals(NodeTypeEnum.getEnum(currentNode.getNodeType()))) {
|
|
|
- // 循环分支
|
|
|
- for (FlowDefinitionNode flowDefinitionNode : nextNodeList) {
|
|
|
- // 获取跳转条件
|
|
|
- String jumpCondition = flowDefinitionNode.getJumpCondition();
|
|
|
- // 跳转条件为空表示默认跳转
|
|
|
- if (StrUtil.isBlank(jumpCondition)) {
|
|
|
- nextNode = flowDefinitionNode;
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 符合条件
|
|
|
- if (expressionResult(FlowThreadLocalUtil.getTemplateData(), jumpCondition)) {
|
|
|
- nextNode = flowDefinitionNode;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (nextNode == null) {
|
|
|
- throw new ServiceException("流程定义错误:分支节点未识别到有效跳转节点");
|
|
|
- }
|
|
|
- }
|
|
|
+ private List<FlowDefinitionNode> getNextUserNode(FlowDefinitionNode currentNode, List<FlowDefinitionLine> flowDefinitionLineList) {
|
|
|
|
|
|
- // 如果不为分支
|
|
|
- else {
|
|
|
- if (nextNodeList == null || nextNodeList.size() == 0) {
|
|
|
- throw new ServiceException("流程定义错误:用户节点未找到跳转节点");
|
|
|
- }
|
|
|
- if (nextNodeList.size() > 1) {
|
|
|
- throw new ServiceException("流程定义错误:用户节点找到多个跳转节点");
|
|
|
- }
|
|
|
- // 查找下一个节点方法
|
|
|
- nextNode = nextNodeList.get(0);
|
|
|
+ //获取当前节点之后的连线
|
|
|
+ List<FlowDefinitionLine> nextLineList = flowDefinitionLineList.stream()
|
|
|
+ .filter(item -> ObjectUtil.equals(item.getSourceId(), currentNode.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> targetIds = nextLineList.stream().map(FlowDefinitionLine::getTargetId).collect(Collectors.toList());
|
|
|
+ Map<Long, FlowDefinitionNode> targetNodeMap = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(targetIds)) {
|
|
|
+ targetNodeMap = flowDefinitionNodeService.mapKEntity(FlowDefinitionNode::getId, q -> q.in(FlowDefinitionNode::getId, targetIds));
|
|
|
}
|
|
|
|
|
|
- // 如果下一节点为分支,递归找下一节点
|
|
|
- if (NodeTypeEnum.BRANCH.equals(NodeTypeEnum.getEnum(nextNode.getNodeType()))) {
|
|
|
- return getNextUserNode(nextNode, flowDefinitionNodeList);
|
|
|
+ List<FlowDefinitionNode> nextNodeList = new ArrayList<>();
|
|
|
+ for (FlowDefinitionLine flowDefinitionLine : nextLineList) {
|
|
|
+ // 获取跳转条件
|
|
|
+ String jumpCondition = flowDefinitionLine.getJumpCondition();
|
|
|
+ // 跳转条件为空表示默认跳转,或者符合表达式条件
|
|
|
+ if (StrUtil.isBlank(jumpCondition) || expressionResult(FlowThreadLocalUtil.getTemplateData(), jumpCondition)) {
|
|
|
+ FlowDefinitionNode targetNode = targetNodeMap.get(flowDefinitionLine.getTargetId());
|
|
|
+ if (ObjectUtil.isEmpty(flowDefinitionLine)) {
|
|
|
+ throw new ServiceException("目标节点不存在!");
|
|
|
+ }
|
|
|
+ nextNodeList.add(targetNode);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return nextNode;
|
|
|
+ return nextNodeList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -783,9 +889,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
* @param node 处理节点
|
|
|
* @return 处理用户
|
|
|
*/
|
|
|
- private FlowResult getHandleUser(FlowDefinitionNode node, String handleUserId) {
|
|
|
+ private FlowResult getHandleUser(FlowDefinitionNode node, List<FlowResult.SelectUser> handleUserList) {
|
|
|
+ Map<Long, String> handleUserMap = handleUserList.stream().collect(Collectors.toMap(FlowResult.SelectUser::getNodeId, FlowResult.SelectUser::getHandleUserId));
|
|
|
FlowResult flowResult = new FlowResult();
|
|
|
|
|
|
+ String handleUserId = handleUserMap.get(node.getId());
|
|
|
if (ObjectUtil.isNotEmpty(handleUserId)) {
|
|
|
flowResult.setSuccess(true);
|
|
|
flowResult.setUserId(handleUserId);
|
|
@@ -873,8 +981,9 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowResult.setUserId(dynamicUserIdsStr);
|
|
|
return flowResult;
|
|
|
case DEPT_MANAGER:
|
|
|
+ SysUser createUser = sysUserService.getById(FlowThreadLocalUtil.getFlowCreateUser());
|
|
|
List<SysUserIdentity> identityList = sysUserIdentityService.list(Wrappers.<SysUserIdentity>lambdaQuery()
|
|
|
- .eq(SysUserIdentity::getDeptId, SecurityUtils.getDeptId())
|
|
|
+ .eq(SysUserIdentity::getDeptId, createUser.getDeptId())
|
|
|
.eq(SysUserIdentity::getIdentity, 20)
|
|
|
);
|
|
|
if (identityList.size() == 0) {
|
|
@@ -890,6 +999,20 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowResult.setSuccess(false);
|
|
|
flowResult.setUserList(identityUserList);
|
|
|
return flowResult;
|
|
|
+ case BUSINESS_USER:
|
|
|
+ Expression exp = AviatorEvaluator.compile(node.getJumpCondition());
|
|
|
+ Object execute = exp.execute(FlowThreadLocalUtil.getTemplateData());
|
|
|
+ if (ObjectUtil.isEmpty(execute)) {
|
|
|
+ throw new ServiceException("节点用户表达式结果不能为空!");
|
|
|
+ }
|
|
|
+ String userId = String.valueOf(execute);
|
|
|
+ SysUser sysUser = sysUserService.getById(Long.valueOf(userId));
|
|
|
+ if (ObjectUtil.isEmpty(sysUser)) {
|
|
|
+ throw new ServiceException("节点表达式用户不存在!");
|
|
|
+ }
|
|
|
+ flowResult.setSuccess(true);
|
|
|
+ flowResult.setUserId(userId);
|
|
|
+ return flowResult;
|
|
|
|
|
|
default:
|
|
|
throw new ServiceException("未知用户处理类型:" + handleObjectType);
|
|
@@ -900,22 +1023,30 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
/**
|
|
|
* 开始节点消息推送
|
|
|
*/
|
|
|
- private void pushInitiateMessage(long flowId, FlowDefinition flowDefinition, NodeTypeEnum nextNodeType, FlowExample flowExample) {
|
|
|
+ private void pushInitiateMessage(long flowId, FlowDefinition flowDefinition, List<FlowDefinitionNode> nextNodes) {
|
|
|
Map<String, Object> businessData = new HashMap<>();
|
|
|
businessData.put("flowId", flowId);
|
|
|
businessData.put("flowKey", flowDefinition.getFlowKey());
|
|
|
|
|
|
+ FlowDefinitionNode endNode = nextNodes.stream()
|
|
|
+ .filter(item -> ObjectUtil.equals(NodeTypeEnum.getEnum(item.getNodeType()), NodeTypeEnum.END))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+
|
|
|
List<Long> pushUserIds = new ArrayList<>();
|
|
|
String title;
|
|
|
- if (NodeTypeEnum.END.equals(nextNodeType)) {
|
|
|
+
|
|
|
+ //下一节点包含 结束节点
|
|
|
+ if (endNode != null) {
|
|
|
FlowInfo flowInfo = flowInfoService.getById(flowDefinition.getFlowInfoId());
|
|
|
String flowName = flowInfo == null ? StringPool.EMPTY : flowInfo.getFlowName();
|
|
|
|
|
|
pushUserIds.add(SecurityUtils.getUserId());
|
|
|
title = StrUtil.format("您于【{}】发起的【{}】已经审批通过。", DateUtil.formatDateTime(new Date()), flowName);
|
|
|
} else {
|
|
|
- for (String s : flowExample.getHandleUserId().split(",")) {
|
|
|
- pushUserIds.add(Long.valueOf(s));
|
|
|
+ for (FlowDefinitionNode nextNode : nextNodes) {
|
|
|
+ for (String s : nextNode.getJumpHandleUserId().split(",")) {
|
|
|
+ pushUserIds.add(Long.valueOf(s));
|
|
|
+ }
|
|
|
}
|
|
|
title = "您有一条新的待审批事项,请及时处理。";
|
|
|
}
|
|
@@ -938,9 +1069,19 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
FlowExample flowExample = context.getFlowExample();
|
|
|
FlowStatusEnum flowStatusEnum = context.getFlowStatus();
|
|
|
- FlowDefinitionNode jumpNode = context.getJumpNode();
|
|
|
FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
- String jumpHandleUserId = context.getJumpHandleUserId();
|
|
|
+
|
|
|
+ //获取所有下一节点处理用户
|
|
|
+ List<Long> jumpHandleUserIdList = new ArrayList<>();
|
|
|
+ List<FlowDefinitionNode> jumpNodeList = context.getJumpNodeList();
|
|
|
+ String jumpHandleUserIds = jumpNodeList.stream()
|
|
|
+ .map(FlowDefinitionNode::getJumpHandleUserId).collect(Collectors.joining(","));
|
|
|
+ if (ObjectUtil.isNotEmpty(jumpHandleUserIdList)) {
|
|
|
+ String[] split = jumpHandleUserIds.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ jumpHandleUserIdList.add(Long.valueOf(s));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Map<String, Object> businessData = new HashMap<>();
|
|
|
businessData.put("flowId", flowExample.getId());
|
|
@@ -949,8 +1090,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
FlowInfo flowInfo = flowInfoService.getOne(q -> q.eq(FlowInfo::getFlowKey, flowExample.getFlowKey()));
|
|
|
String flowName = flowInfo == null ? StringPool.EMPTY : flowInfo.getFlowName();
|
|
|
|
|
|
- String title;
|
|
|
- List<Long> pushUserIds = new ArrayList<>();
|
|
|
+ List<PushParam> pushUserList = new ArrayList<>();
|
|
|
|
|
|
switch (handleTypeEnum) {
|
|
|
// 跳转下一节点
|
|
@@ -959,65 +1099,80 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
case SKIP_TO_NEXT:
|
|
|
// 如果流程结束
|
|
|
if (FlowStatusEnum.PASS.equals(flowStatusEnum)) {
|
|
|
- title = StrUtil.format("您于【{}】发起的【{}】已经审批通过。",
|
|
|
+ String title = StrUtil.format("您于【{}】发起的【{}】已经审批通过。",
|
|
|
DateUtil.formatDateTime(flowExample.getCreateTime()),
|
|
|
flowName);
|
|
|
- pushUserIds.add(flowExample.getCreateUser());
|
|
|
+ PushParam pushParam = new PushParam();
|
|
|
+ pushParam.setUserId(flowExample.getCreateUser());
|
|
|
+ pushParam.setTitle(title);
|
|
|
+ pushUserList.add(pushParam);
|
|
|
}
|
|
|
// 如果下一节点不为结束节点
|
|
|
else {
|
|
|
- title = "您有一条新的待审批事项,请及时处理。";
|
|
|
- for (String s : jumpHandleUserId.split(",")) {
|
|
|
- pushUserIds.add(Long.valueOf(s));
|
|
|
+ String title = "您有一条新的待审批事项,请及时处理。";
|
|
|
+ for (Long userId : jumpHandleUserIdList) {
|
|
|
+ PushParam pushParam = new PushParam();
|
|
|
+ pushParam.setUserId(userId);
|
|
|
+ pushParam.setTitle(title);
|
|
|
+ pushUserList.add(pushParam);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
// 驳回流程
|
|
|
case REJECT:
|
|
|
- title = StrUtil.format("您于【{}】发起的【{}】在【{}】被驳回。",
|
|
|
+ String title = StrUtil.format("您于【{}】发起的【{}】在【{}】被驳回。",
|
|
|
DateUtil.formatDateTime(flowExample.getCreateTime()),
|
|
|
flowName,
|
|
|
currentNode.getNodeName());
|
|
|
- pushUserIds.add(flowExample.getCreateUser());
|
|
|
+ PushParam pushParam = new PushParam();
|
|
|
+ pushParam.setUserId(flowExample.getCreateUser());
|
|
|
+ pushParam.setTitle(title);
|
|
|
+ pushUserList.add(pushParam);
|
|
|
break;
|
|
|
|
|
|
// 退回上一节点
|
|
|
case RETURN_TO_NODE:
|
|
|
case RETURN_TO_PREVIOUS:
|
|
|
|
|
|
+ List<Long> lastNodeIds = flowDefinitionLineService.listObject(FlowDefinitionLine::getSourceId, q -> q
|
|
|
+ .eq(FlowDefinitionLine::getFlowDefinitionId, context.getFlowExample().getDefinitionId())
|
|
|
+ .eq(FlowDefinitionLine::getTargetId, context.getCurrentNode().getId()));
|
|
|
+
|
|
|
// 查找上次审批节点
|
|
|
- FlowExampleDetail flowExampleDetail = flowExampleDetailService.getOne(q -> q
|
|
|
+ List<FlowExampleDetail> flowExampleDetailList = flowExampleDetailService.list(q -> q
|
|
|
.eq(FlowExampleDetail::getFlowExampleId, flowExample.getId())
|
|
|
- .eq(FlowExampleDetail::getFlowDefinitionNodeId, jumpNode.getId())
|
|
|
+ .in(FlowExampleDetail::getFlowDefinitionNodeId, lastNodeIds)
|
|
|
.orderByDesc(BaseIdPo::getId));
|
|
|
-
|
|
|
- title = StrUtil.format("您于【{}】提交的【{}】被退回,请及时处理。",
|
|
|
- DateUtil.formatDateTime(flowExampleDetail.getCreateTime()),
|
|
|
- flowName);
|
|
|
-
|
|
|
- for (String s : jumpHandleUserId.split(",")) {
|
|
|
- pushUserIds.add(Long.valueOf(s));
|
|
|
+ for (FlowExampleDetail flowExampleDetail : flowExampleDetailList) {
|
|
|
+ String title1 = StrUtil.format("您于【{}】提交的【{}】被退回,请及时处理。",
|
|
|
+ DateUtil.formatDateTime(flowExampleDetail.getCreateTime()),
|
|
|
+ flowName);
|
|
|
+ PushParam pushParam1 = new PushParam();
|
|
|
+ pushParam1.setUserId(flowExampleDetail.getCreateUser());
|
|
|
+ pushParam1.setTitle(title1);
|
|
|
+ pushUserList.add(pushParam1);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
// 退回到发起人
|
|
|
case RETURN_TO_SUBMITTER:
|
|
|
- title = StrUtil.format("您于【{}】提交的【{}】被退回,请及时处理。",
|
|
|
+ String title2 = StrUtil.format("您于【{}】提交的【{}】被退回,请及时处理。",
|
|
|
DateUtil.formatDateTime(flowExample.getCreateTime()),
|
|
|
flowName);
|
|
|
|
|
|
- for (String s : jumpHandleUserId.split(",")) {
|
|
|
- pushUserIds.add(Long.valueOf(s));
|
|
|
- }
|
|
|
+ PushParam pushParam2 = new PushParam();
|
|
|
+ pushParam2.setUserId(flowExample.getCreateUser());
|
|
|
+ pushParam2.setTitle(title2);
|
|
|
+ pushUserList.add(pushParam2);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
throw new ServiceException("未知流程跳转类型");
|
|
|
}
|
|
|
|
|
|
- for (Long pushUserId : pushUserIds) {
|
|
|
- WebSocketPush.byUser(PushTypeEnum.MESSAGE, pushUserId, title, 0, businessData);
|
|
|
+ for (PushParam pushParam : pushUserList) {
|
|
|
+ WebSocketPush.byUser(PushTypeEnum.MESSAGE, pushParam.getUserId(), pushParam.getTitle(), 0, businessData);
|
|
|
}
|
|
|
}
|
|
|
|