Compare commits

..

No commits in common. "c85f693ca6c4eb02df526dabf97ecdfa44c6cfd2" and "127eaf936cce8b4a9a123caa9ce533a6e7c57b0b" have entirely different histories.

3 changed files with 25 additions and 36 deletions

View File

@ -191,12 +191,12 @@ public class FlwTaskController extends BaseController {
/**
* 获取可驳回的前置节点
*
* @param taskId 任务id
* @param definitionId 流程定义id
* @param nowNodeCode 当前节点
*/
@GetMapping("/getBackTaskNode/{taskId}/{nowNodeCode}")
public R<List<Node>> getBackTaskNode(@PathVariable Long taskId, @PathVariable String nowNodeCode) {
return R.ok(flwTaskService.getBackTaskNode(taskId, nowNodeCode));
@GetMapping("/getBackTaskNode/{definitionId}/{nowNodeCode}")
public R<List<Node>> getBackTaskNode(@PathVariable Long definitionId, @PathVariable String nowNodeCode) {
return R.ok(flwTaskService.getBackTaskNode(definitionId, nowNodeCode));
}
/**

View File

@ -111,11 +111,11 @@ public interface IFlwTaskService {
/**
* 获取可驳回的前置节点
*
* @param taskId 任务id
* @param definitionId 流程定义id
* @param nowNodeCode 当前节点
* @return 结果
*/
List<Node> getBackTaskNode(Long taskId, String nowNodeCode);
List<Node> getBackTaskNode(Long definitionId, String nowNodeCode);
/**
* 终止任务

View File

@ -31,7 +31,6 @@ import org.dromara.warm.flow.core.dto.FlowParams;
import org.dromara.warm.flow.core.entity.*;
import org.dromara.warm.flow.core.enums.NodeType;
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.utils.ExpressionUtil;
import org.dromara.warm.flow.core.utils.MapUtil;
@ -119,12 +118,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
dto.setTaskId(taskList.get(0).getId());
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()
.flowCode(startProcessBo.getFlowCode())
.variable(startProcessBo.getVariables())
@ -162,12 +155,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
// 获取抄送人
List<FlowCopyBo> flowCopyList = completeTaskBo.getFlowCopyList();
// 设置抄送人
Map<String, Object> variables = completeTaskBo.getVariables();
variables.put(FlowConstant.FLOW_COPY_LIST, flowCopyList);
completeTaskBo.getVariables().put(FlowConstant.FLOW_COPY_LIST, flowCopyList);
// 消息类型
variables.put(FlowConstant.MESSAGE_TYPE, messageType);
completeTaskBo.getVariables().put(FlowConstant.MESSAGE_TYPE, messageType);
// 消息通知
variables.put(FlowConstant.MESSAGE_NOTICE, notice);
completeTaskBo.getVariables().put(FlowConstant.MESSAGE_NOTICE, notice);
FlowTask flowTask = flowTaskMapper.selectById(taskId);
@ -175,25 +167,25 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
throw new ServiceException("流程任务不存在或任务已审批!");
}
Instance ins = insService.getById(flowTask.getInstanceId());
FlowDefinition flowDefinition = flowDefinitionMapper.selectOne(new LambdaQueryWrapper<>(FlowDefinition.class).eq(FlowDefinition::getId, ins.getDefinitionId()));
// 检查流程状态是否为草稿已撤销或已退回状态若是则执行流程提交监听
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
variables.put(FlowConstant.SUBMIT, true);
completeTaskBo.getVariables().put(FlowConstant.SUBMIT, true);
}
// 设置弹窗处理人
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
if (CollUtil.isNotEmpty(assigneeMap)) {
variables.putAll(assigneeMap);
completeTaskBo.getVariables().putAll(assigneeMap);
}
// 构建流程参数包括变量跳转类型消息处理人权限等信息
FlowParams flowParams = FlowParams.build()
.variable(variables)
.variable(completeTaskBo.getVariables())
.skipType(SkipType.PASS.getKey())
.message(completeTaskBo.getMessage())
.flowStatus(BusinessStatusEnum.WAITING.getStatus())
.hisStatus(TaskStatusEnum.PASS.getStatus())
.hisTaskExt(completeTaskBo.getFileId());
Boolean autoPass = Convert.toBool(variables.getOrDefault(AUTO_PASS, false));
skipTask(taskId, flowParams, flowTask.getInstanceId(), autoPass);
skipTask(taskId, flowParams, flowTask.getInstanceId(), flowDefinition);
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
@ -207,9 +199,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
* @param taskId 任务ID
* @param flowParams 参数
* @param instanceId 实例ID
* @param autoPass 自动审批
* @param flowDefinition 流程定义
*/
private void skipTask(Long taskId, FlowParams flowParams, Long instanceId, Boolean autoPass) {
private void skipTask(Long taskId, FlowParams flowParams, Long instanceId, FlowDefinition flowDefinition) {
// 执行任务跳转并根据返回的处理人设置下一步处理人
taskService.skip(taskId, flowParams);
List<FlowTask> flowTaskList = selectByInstId(instanceId);
@ -221,7 +213,10 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
if (CollUtil.isEmpty(userList)) {
return;
}
Dict dict = JsonUtils.parseMap(flowDefinition.getExt());
for (FlowTask task : flowTaskList) {
//自动审批
boolean autoPass = !ObjectUtil.isNull(dict) && dict.getBool(FlowConstant.AUTO_PASS);
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()));
if (CollUtil.isEmpty(users)) {
@ -233,7 +228,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
FlowConstant.SUBMIT, false,
FlowConstant.FLOW_COPY_LIST, Collections.emptyList(),
FlowConstant.MESSAGE_NOTICE, StringUtils.EMPTY));
skipTask(task.getId(), flowParams, instanceId, true);
skipTask(task.getId(), flowParams, instanceId, flowDefinition);
}
}
}
@ -463,28 +458,22 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
/**
* 获取可驳回的前置节点
*
* @param taskId 任务id
* @param definitionId 流程定义id
* @param nowNodeCode 当前节点
*/
@Override
public List<Node> getBackTaskNode(Long taskId, String nowNodeCode) {
FlowTask task = flowTaskMapper.selectById(taskId);
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), task.getDefinitionId());
public List<Node> getBackTaskNode(Long definitionId, String nowNodeCode) {
List<Node> nodeCodes = nodeService.getByNodeCodes(Collections.singletonList(nowNodeCode), definitionId);
if (!CollUtil.isNotEmpty(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);
if (StringUtils.isNotBlank(node.getAnyNodeSkip())) {
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), task.getDefinitionId());
return nodeService.getByNodeCodes(Collections.singletonList(node.getAnyNodeSkip()), definitionId);
}
//获取可驳回的前置节点
List<Node> nodes = nodeService.previousNodeList(task.getDefinitionId(), nowNodeCode);
List<Node> nodes = nodeService.previousNodeList(definitionId, nowNodeCode);
if (CollUtil.isNotEmpty(nodes)) {
return StreamUtils.filter(nodes, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
}