mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-10-08 02:56:40 +08:00
Compare commits
2 Commits
127eaf936c
...
c85f693ca6
Author | SHA1 | Date | |
---|---|---|---|
|
c85f693ca6 | ||
|
5f466fd0c4 |
@ -191,12 +191,12 @@ public class FlwTaskController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取可驳回的前置节点
|
* 获取可驳回的前置节点
|
||||||
*
|
*
|
||||||
* @param definitionId 流程定义id
|
* @param taskId 任务id
|
||||||
* @param nowNodeCode 当前节点
|
* @param nowNodeCode 当前节点
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getBackTaskNode/{definitionId}/{nowNodeCode}")
|
@GetMapping("/getBackTaskNode/{taskId}/{nowNodeCode}")
|
||||||
public R<List<Node>> getBackTaskNode(@PathVariable Long definitionId, @PathVariable String nowNodeCode) {
|
public R<List<Node>> getBackTaskNode(@PathVariable Long taskId, @PathVariable String nowNodeCode) {
|
||||||
return R.ok(flwTaskService.getBackTaskNode(definitionId, nowNodeCode));
|
return R.ok(flwTaskService.getBackTaskNode(taskId, nowNodeCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,11 +111,11 @@ public interface IFlwTaskService {
|
|||||||
/**
|
/**
|
||||||
* 获取可驳回的前置节点
|
* 获取可驳回的前置节点
|
||||||
*
|
*
|
||||||
* @param definitionId 流程定义id
|
* @param taskId 任务id
|
||||||
* @param nowNodeCode 当前节点
|
* @param nowNodeCode 当前节点
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
List<Node> getBackTaskNode(Long definitionId, String nowNodeCode);
|
List<Node> getBackTaskNode(Long taskId, String nowNodeCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 终止任务
|
* 终止任务
|
||||||
|
@ -31,6 +31,7 @@ import org.dromara.warm.flow.core.dto.FlowParams;
|
|||||||
import org.dromara.warm.flow.core.entity.*;
|
import org.dromara.warm.flow.core.entity.*;
|
||||||
import org.dromara.warm.flow.core.enums.NodeType;
|
import org.dromara.warm.flow.core.enums.NodeType;
|
||||||
import org.dromara.warm.flow.core.enums.SkipType;
|
import org.dromara.warm.flow.core.enums.SkipType;
|
||||||
|
import org.dromara.warm.flow.core.enums.UserType;
|
||||||
import org.dromara.warm.flow.core.service.*;
|
import org.dromara.warm.flow.core.service.*;
|
||||||
import org.dromara.warm.flow.core.utils.ExpressionUtil;
|
import org.dromara.warm.flow.core.utils.ExpressionUtil;
|
||||||
import org.dromara.warm.flow.core.utils.MapUtil;
|
import org.dromara.warm.flow.core.utils.MapUtil;
|
||||||
@ -118,6 +119,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
dto.setTaskId(taskList.get(0).getId());
|
dto.setTaskId(taskList.get(0).getId());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
// 将流程定义内的扩展参数设置到变量中
|
||||||
|
Definition definition = FlowEngine.defService().getPublishByFlowCode(startProcessBo.getFlowCode());
|
||||||
|
Dict dict = JsonUtils.parseMap(definition.getExt());
|
||||||
|
boolean autoPass = !ObjectUtil.isNull(dict) && dict.getBool(FlowConstant.AUTO_PASS);
|
||||||
|
variables.put(FlowConstant.AUTO_PASS, autoPass);
|
||||||
|
|
||||||
FlowParams flowParams = FlowParams.build()
|
FlowParams flowParams = FlowParams.build()
|
||||||
.flowCode(startProcessBo.getFlowCode())
|
.flowCode(startProcessBo.getFlowCode())
|
||||||
.variable(startProcessBo.getVariables())
|
.variable(startProcessBo.getVariables())
|
||||||
@ -155,11 +162,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
// 获取抄送人
|
// 获取抄送人
|
||||||
List<FlowCopyBo> flowCopyList = completeTaskBo.getFlowCopyList();
|
List<FlowCopyBo> flowCopyList = completeTaskBo.getFlowCopyList();
|
||||||
// 设置抄送人
|
// 设置抄送人
|
||||||
completeTaskBo.getVariables().put(FlowConstant.FLOW_COPY_LIST, flowCopyList);
|
Map<String, Object> variables = completeTaskBo.getVariables();
|
||||||
|
variables.put(FlowConstant.FLOW_COPY_LIST, flowCopyList);
|
||||||
// 消息类型
|
// 消息类型
|
||||||
completeTaskBo.getVariables().put(FlowConstant.MESSAGE_TYPE, messageType);
|
variables.put(FlowConstant.MESSAGE_TYPE, messageType);
|
||||||
// 消息通知
|
// 消息通知
|
||||||
completeTaskBo.getVariables().put(FlowConstant.MESSAGE_NOTICE, notice);
|
variables.put(FlowConstant.MESSAGE_NOTICE, notice);
|
||||||
|
|
||||||
|
|
||||||
FlowTask flowTask = flowTaskMapper.selectById(taskId);
|
FlowTask flowTask = flowTaskMapper.selectById(taskId);
|
||||||
@ -167,25 +175,25 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
throw new ServiceException("流程任务不存在或任务已审批!");
|
throw new ServiceException("流程任务不存在或任务已审批!");
|
||||||
}
|
}
|
||||||
Instance ins = insService.getById(flowTask.getInstanceId());
|
Instance ins = insService.getById(flowTask.getInstanceId());
|
||||||
FlowDefinition flowDefinition = flowDefinitionMapper.selectOne(new LambdaQueryWrapper<>(FlowDefinition.class).eq(FlowDefinition::getId, ins.getDefinitionId()));
|
|
||||||
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
||||||
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
||||||
completeTaskBo.getVariables().put(FlowConstant.SUBMIT, true);
|
variables.put(FlowConstant.SUBMIT, true);
|
||||||
}
|
}
|
||||||
// 设置弹窗处理人
|
// 设置弹窗处理人
|
||||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||||
if (CollUtil.isNotEmpty(assigneeMap)) {
|
if (CollUtil.isNotEmpty(assigneeMap)) {
|
||||||
completeTaskBo.getVariables().putAll(assigneeMap);
|
variables.putAll(assigneeMap);
|
||||||
}
|
}
|
||||||
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
||||||
FlowParams flowParams = FlowParams.build()
|
FlowParams flowParams = FlowParams.build()
|
||||||
.variable(completeTaskBo.getVariables())
|
.variable(variables)
|
||||||
.skipType(SkipType.PASS.getKey())
|
.skipType(SkipType.PASS.getKey())
|
||||||
.message(completeTaskBo.getMessage())
|
.message(completeTaskBo.getMessage())
|
||||||
.flowStatus(BusinessStatusEnum.WAITING.getStatus())
|
.flowStatus(BusinessStatusEnum.WAITING.getStatus())
|
||||||
.hisStatus(TaskStatusEnum.PASS.getStatus())
|
.hisStatus(TaskStatusEnum.PASS.getStatus())
|
||||||
.hisTaskExt(completeTaskBo.getFileId());
|
.hisTaskExt(completeTaskBo.getFileId());
|
||||||
skipTask(taskId, flowParams, flowTask.getInstanceId(), flowDefinition);
|
Boolean autoPass = Convert.toBool(variables.getOrDefault(AUTO_PASS, false));
|
||||||
|
skipTask(taskId, flowParams, flowTask.getInstanceId(), autoPass);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@ -199,9 +207,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
* @param taskId 任务ID
|
* @param taskId 任务ID
|
||||||
* @param flowParams 参数
|
* @param flowParams 参数
|
||||||
* @param instanceId 实例ID
|
* @param instanceId 实例ID
|
||||||
* @param flowDefinition 流程定义
|
* @param autoPass 自动审批
|
||||||
*/
|
*/
|
||||||
private void skipTask(Long taskId, FlowParams flowParams, Long instanceId, FlowDefinition flowDefinition) {
|
private void skipTask(Long taskId, FlowParams flowParams, Long instanceId, Boolean autoPass) {
|
||||||
// 执行任务跳转,并根据返回的处理人设置下一步处理人
|
// 执行任务跳转,并根据返回的处理人设置下一步处理人
|
||||||
taskService.skip(taskId, flowParams);
|
taskService.skip(taskId, flowParams);
|
||||||
List<FlowTask> flowTaskList = selectByInstId(instanceId);
|
List<FlowTask> flowTaskList = selectByInstId(instanceId);
|
||||||
@ -213,10 +221,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
if (CollUtil.isEmpty(userList)) {
|
if (CollUtil.isEmpty(userList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Dict dict = JsonUtils.parseMap(flowDefinition.getExt());
|
|
||||||
for (FlowTask task : flowTaskList) {
|
for (FlowTask task : flowTaskList) {
|
||||||
//自动审批
|
|
||||||
boolean autoPass = !ObjectUtil.isNull(dict) && dict.getBool(FlowConstant.AUTO_PASS);
|
|
||||||
if (!task.getId().equals(taskId) && autoPass) {
|
if (!task.getId().equals(taskId) && autoPass) {
|
||||||
List<User> users = StreamUtils.filter(userList, e -> ObjectUtil.equals(task.getId(), e.getAssociated()) && ObjectUtil.equal(e.getProcessedBy(), LoginHelper.getUserIdStr()));
|
List<User> users = StreamUtils.filter(userList, e -> ObjectUtil.equals(task.getId(), e.getAssociated()) && ObjectUtil.equal(e.getProcessedBy(), LoginHelper.getUserIdStr()));
|
||||||
if (CollUtil.isEmpty(users)) {
|
if (CollUtil.isEmpty(users)) {
|
||||||
@ -228,7 +233,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
FlowConstant.SUBMIT, false,
|
FlowConstant.SUBMIT, false,
|
||||||
FlowConstant.FLOW_COPY_LIST, Collections.emptyList(),
|
FlowConstant.FLOW_COPY_LIST, Collections.emptyList(),
|
||||||
FlowConstant.MESSAGE_NOTICE, StringUtils.EMPTY));
|
FlowConstant.MESSAGE_NOTICE, StringUtils.EMPTY));
|
||||||
skipTask(task.getId(), flowParams, instanceId, flowDefinition);
|
skipTask(task.getId(), flowParams, instanceId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,22 +463,28 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|||||||
/**
|
/**
|
||||||
* 获取可驳回的前置节点
|
* 获取可驳回的前置节点
|
||||||
*
|
*
|
||||||
* @param definitionId 流程定义id
|
* @param taskId 任务id
|
||||||
* @param nowNodeCode 当前节点
|
* @param nowNodeCode 当前节点
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Node> getBackTaskNode(Long definitionId, String nowNodeCode) {
|
public List<Node> getBackTaskNode(Long taskId, String nowNodeCode) {
|
||||||
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), definitionId);
|
FlowTask task = flowTaskMapper.selectById(taskId);
|
||||||
|
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), task.getDefinitionId());
|
||||||
if (!CollUtil.isNotEmpty(nodeCodes)) {
|
if (!CollUtil.isNotEmpty(nodeCodes)) {
|
||||||
return nodeCodes;
|
return nodeCodes;
|
||||||
}
|
}
|
||||||
|
List<User> userList = FlowEngine.userService()
|
||||||
|
.getByAssociateds(Collections.singletonList(task.getId()), UserType.DEPUTE.getKey());
|
||||||
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
|
return nodeCodes;
|
||||||
|
}
|
||||||
//判断是否配置了固定驳回节点
|
//判断是否配置了固定驳回节点
|
||||||
Node node = nodeCodes.get(0);
|
Node node = nodeCodes.get(0);
|
||||||
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
|
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
|
||||||
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), definitionId);
|
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
|
||||||
}
|
}
|
||||||
//获取可驳回的前置节点
|
//获取可驳回的前置节点
|
||||||
List<Node> nodes = nodeService.previousNodeList(definitionId, nowNodeCode);
|
List<Node> nodes = nodeService.previousNodeList(task.getDefinitionId(), nowNodeCode);
|
||||||
if (CollUtil.isNotEmpty(nodes)) {
|
if (CollUtil.isNotEmpty(nodes)) {
|
||||||
return StreamUtils.filter(nodes, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
|
return StreamUtils.filter(nodes, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user