|
@ -31,17 +31,18 @@ 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.service.*; |
|
|
import org.dromara.warm.flow.core.service.*; |
|
|
|
|
|
import org.dromara.warm.flow.core.utils.ExpressionUtil; |
|
|
|
|
|
import org.dromara.warm.flow.core.utils.MapUtil; |
|
|
import org.dromara.warm.flow.orm.entity.*; |
|
|
import org.dromara.warm.flow.orm.entity.*; |
|
|
import org.dromara.warm.flow.orm.mapper.FlowHisTaskMapper; |
|
|
import org.dromara.warm.flow.orm.mapper.FlowHisTaskMapper; |
|
|
import org.dromara.warm.flow.orm.mapper.FlowInstanceMapper; |
|
|
import org.dromara.warm.flow.orm.mapper.FlowInstanceMapper; |
|
|
|
|
|
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.api.domain.FlowLabelVo; |
|
|
|
|
|
import org.dromara.workflow.api.domain.RemoteStartProcessReturn; |
|
|
import org.dromara.workflow.api.domain.RemoteStartProcessReturn; |
|
|
import org.dromara.workflow.common.ConditionalOnEnable; |
|
|
import org.dromara.workflow.common.ConditionalOnEnable; |
|
|
import org.dromara.workflow.common.enums.MessageTypeEnum; |
|
|
import org.dromara.workflow.common.enums.MessageTypeEnum; |
|
|
import org.dromara.workflow.common.enums.TaskAssigneeType; |
|
|
import org.dromara.workflow.common.enums.TaskAssigneeType; |
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum; |
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum; |
|
|
import org.dromara.workflow.domain.FlowLabel; |
|
|
|
|
|
import org.dromara.workflow.domain.bo.*; |
|
|
import org.dromara.workflow.domain.bo.*; |
|
|
import org.dromara.workflow.domain.vo.FlowHisTaskVo; |
|
|
import org.dromara.workflow.domain.vo.FlowHisTaskVo; |
|
|
import org.dromara.workflow.domain.vo.FlowTaskVo; |
|
|
import org.dromara.workflow.domain.vo.FlowTaskVo; |
|
@ -49,10 +50,9 @@ import org.dromara.workflow.handler.FlowProcessEventHandler; |
|
|
import org.dromara.workflow.handler.WorkflowPermissionHandler; |
|
|
import org.dromara.workflow.handler.WorkflowPermissionHandler; |
|
|
import org.dromara.workflow.mapper.FlwCategoryMapper; |
|
|
import org.dromara.workflow.mapper.FlwCategoryMapper; |
|
|
import org.dromara.workflow.mapper.FlwTaskMapper; |
|
|
import org.dromara.workflow.mapper.FlwTaskMapper; |
|
|
import org.dromara.workflow.service.FlwLabelService; |
|
|
import org.dromara.workflow.service.IFlwCommonService; |
|
|
|
|
|
import org.dromara.workflow.service.IFlwTaskAssigneeService; |
|
|
import org.dromara.workflow.service.IFlwTaskService; |
|
|
import org.dromara.workflow.service.IFlwTaskService; |
|
|
import org.dromara.workflow.utils.WorkflowUtils; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -87,9 +87,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
private final FlowProcessEventHandler flowProcessEventHandler; |
|
|
private final FlowProcessEventHandler flowProcessEventHandler; |
|
|
private final FlwTaskMapper flwTaskMapper; |
|
|
private final FlwTaskMapper flwTaskMapper; |
|
|
private final FlwCategoryMapper flwCategoryMapper; |
|
|
private final FlwCategoryMapper flwCategoryMapper; |
|
|
private final FlwLabelService flwDepartService; |
|
|
private final FlowNodeMapper flowNodeMapper; |
|
|
@DubboReference |
|
|
@DubboReference |
|
|
private RemoteUserService remoteUserService; |
|
|
private RemoteUserService remoteUserService; |
|
|
|
|
|
private final IFlwTaskAssigneeService flwTaskAssigneeService; |
|
|
|
|
|
private final IFlwCommonService flwCommonService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private ApplicationContext applicationContext; |
|
|
private ApplicationContext applicationContext; |
|
@ -117,6 +119,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
if (ObjectUtil.isNotNull(flowInstance)) { |
|
|
if (ObjectUtil.isNotNull(flowInstance)) { |
|
|
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())); |
|
|
|
|
|
taskService.mergeVariable(flowInstance, variables); |
|
|
|
|
|
insService.updateById(flowInstance); |
|
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn(); |
|
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn(); |
|
|
dto.setProcessInstanceId(taskList.get(0).getInstanceId()); |
|
|
dto.setProcessInstanceId(taskList.get(0).getInstanceId()); |
|
|
dto.setTaskId(taskList.get(0).getId()); |
|
|
dto.setTaskId(taskList.get(0).getId()); |
|
@ -147,6 +151,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
return dto; |
|
|
return dto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 办理任务 |
|
|
* 办理任务 |
|
|
* |
|
|
* |
|
@ -173,6 +178,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) { |
|
|
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) { |
|
|
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getFlowStatus(), null, true); |
|
|
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getFlowStatus(), null, true); |
|
|
} |
|
|
} |
|
|
|
|
|
// 设置弹窗处理人
|
|
|
|
|
|
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap()); |
|
|
|
|
|
if (CollUtil.isNotEmpty(assigneeMap)) { |
|
|
|
|
|
completeTaskBo.getVariables().putAll(assigneeMap); |
|
|
|
|
|
} |
|
|
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
|
|
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
|
|
FlowParams flowParams = new FlowParams(); |
|
|
FlowParams flowParams = new FlowParams(); |
|
|
|
|
|
|
|
@ -199,8 +209,14 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
// 执行任务跳转,并根据返回的处理人设置下一步处理人
|
|
|
// 执行任务跳转,并根据返回的处理人设置下一步处理人
|
|
|
Instance instance = taskService.skip(taskId, flowParams); |
|
|
Instance instance = taskService.skip(taskId, flowParams); |
|
|
this.setHandler(instance, flowTask, flowCopyList); |
|
|
this.setHandler(instance, flowTask, flowCopyList); |
|
|
// 待办消息通知
|
|
|
// 消息通知
|
|
|
WorkflowUtils.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice); |
|
|
try { |
|
|
|
|
|
flwCommonService.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
|
} |
|
|
|
|
|
//设置下一环节处理人
|
|
|
|
|
|
setNextHandler(ins.getId()); |
|
|
return true; |
|
|
return true; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error(e.getMessage(), e); |
|
|
log.error(e.getMessage(), e); |
|
@ -208,6 +224,61 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 设置下一环节处理人 |
|
|
|
|
|
* |
|
|
|
|
|
* @param instanceId 实例ID |
|
|
|
|
|
*/ |
|
|
|
|
|
private void setNextHandler(Long instanceId) { |
|
|
|
|
|
Instance inst = insService.getById(instanceId); |
|
|
|
|
|
List<FlowTask> flowTaskList = selectByInstId(instanceId); |
|
|
|
|
|
Map<String, Object> variableMap = inst.getVariableMap(); |
|
|
|
|
|
for (FlowTask task : flowTaskList) { |
|
|
|
|
|
if (variableMap != null && variableMap.containsKey(task.getNodeCode())) { |
|
|
|
|
|
String userIds = variableMap.get(task.getNodeCode()).toString(); |
|
|
|
|
|
// 批量删除现有任务的办理人记录
|
|
|
|
|
|
flwCommonService.getFlowUserService().deleteByTaskIds(List.of(task.getId())); |
|
|
|
|
|
// 批量新增任务办理人记录
|
|
|
|
|
|
Set<User> users = flwCommonService.buildFlowUser(List.of(userIds.split(StringUtils.SEPARATOR)), task.getId()); |
|
|
|
|
|
flwCommonService.getFlowUserService().saveBatch(new ArrayList<>(users)); |
|
|
|
|
|
variableMap.remove(task.getNodeCode()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
taskService.mergeVariable(inst, variableMap); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 设置弹窗处理人 |
|
|
|
|
|
* |
|
|
|
|
|
* @param assigneeMap 处理人 |
|
|
|
|
|
* @param variablesMap 变量 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> setPopAssigneeMap(Map<String, Object> assigneeMap, Map<String, Object> variablesMap) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
if (CollUtil.isEmpty(assigneeMap)) { |
|
|
|
|
|
return map; |
|
|
|
|
|
} |
|
|
|
|
|
for (Map.Entry<String, Object> entry : assigneeMap.entrySet()) { |
|
|
|
|
|
if (variablesMap.containsKey(entry.getKey())) { |
|
|
|
|
|
String userIds = variablesMap.get(entry.getKey()).toString(); |
|
|
|
|
|
if (StringUtils.isNotBlank(userIds)) { |
|
|
|
|
|
Set<String> hashSet = new HashSet<>(); |
|
|
|
|
|
//弹窗传入的选人
|
|
|
|
|
|
List<String> popUserIds = Arrays.asList(entry.getValue().toString().split(StringUtils.SEPARATOR)); |
|
|
|
|
|
//已有的选人
|
|
|
|
|
|
List<String> variableUserIds = Arrays.asList(userIds.split(StringUtils.SEPARATOR)); |
|
|
|
|
|
hashSet.addAll(popUserIds); |
|
|
|
|
|
hashSet.addAll(variableUserIds); |
|
|
|
|
|
map.put(entry.getKey(), String.join(StringUtils.SEPARATOR, hashSet)); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
map.put(entry.getKey(), entry.getValue()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return map; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 设置办理人 |
|
|
* 设置办理人 |
|
|
* |
|
|
* |
|
@ -228,7 +299,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
List<Long> taskIdList = StreamUtils.toList(flowTasks, FlowTask::getId); |
|
|
List<Long> taskIdList = StreamUtils.toList(flowTasks, FlowTask::getId); |
|
|
// 获取与当前任务关联的用户列表
|
|
|
// 获取与当前任务关联的用户列表
|
|
|
List<User> associatedUsers = WorkflowUtils.getFlowUserService().getByAssociateds(taskIdList); |
|
|
List<User> associatedUsers = flwCommonService.getFlowUserService().getByAssociateds(taskIdList); |
|
|
if (CollUtil.isEmpty(associatedUsers)) { |
|
|
if (CollUtil.isEmpty(associatedUsers)) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -237,16 +308,16 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
for (FlowTask flowTask : flowTasks) { |
|
|
for (FlowTask flowTask : flowTasks) { |
|
|
List<User> users = StreamUtils.filter(associatedUsers, user -> Objects.equals(user.getAssociated(), flowTask.getId())); |
|
|
List<User> users = StreamUtils.filter(associatedUsers, user -> Objects.equals(user.getAssociated(), flowTask.getId())); |
|
|
if (CollUtil.isNotEmpty(users)) { |
|
|
if (CollUtil.isNotEmpty(users)) { |
|
|
userList.addAll(WorkflowUtils.buildUser(users, flowTask.getId())); |
|
|
userList.addAll(flwCommonService.buildUser(users, flowTask.getId())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 批量删除现有任务的办理人记录
|
|
|
// 批量删除现有任务的办理人记录
|
|
|
WorkflowUtils.getFlowUserService().deleteByTaskIds(taskIdList); |
|
|
flwCommonService.getFlowUserService().deleteByTaskIds(taskIdList); |
|
|
// 确保要保存的 userList 不为空
|
|
|
// 确保要保存的 userList 不为空
|
|
|
if (CollUtil.isEmpty(userList)) { |
|
|
if (CollUtil.isEmpty(userList)) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
WorkflowUtils.getFlowUserService().saveBatch(userList); |
|
|
flwCommonService.getFlowUserService().saveBatch(userList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -286,7 +357,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
return flowUser; |
|
|
return flowUser; |
|
|
}).collect(Collectors.toList()); |
|
|
}).collect(Collectors.toList()); |
|
|
// 批量保存抄送人员
|
|
|
// 批量保存抄送人员
|
|
|
WorkflowUtils.getFlowUserService().saveBatch(userList); |
|
|
flwCommonService.getFlowUserService().saveBatch(userList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -435,7 +506,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
BusinessStatusEnum.checkBackStatus(inst.getFlowStatus()); |
|
|
BusinessStatusEnum.checkBackStatus(inst.getFlowStatus()); |
|
|
Long definitionId = task.getDefinitionId(); |
|
|
Long definitionId = task.getDefinitionId(); |
|
|
Definition definition = defService.getById(definitionId); |
|
|
Definition definition = defService.getById(definitionId); |
|
|
String applyNodeCode = WorkflowUtils.applyNodeCode(definitionId); |
|
|
String applyNodeCode = flwCommonService.applyNodeCode(definitionId); |
|
|
FlowParams flowParams = FlowParams.build(); |
|
|
FlowParams flowParams = FlowParams.build(); |
|
|
flowParams.nodeCode(bo.getNodeCode()); |
|
|
flowParams.nodeCode(bo.getNodeCode()); |
|
|
flowParams.message(message); |
|
|
flowParams.message(message); |
|
@ -448,7 +519,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
Instance instance = insService.getById(inst.getId()); |
|
|
Instance instance = insService.getById(inst.getId()); |
|
|
this.setHandler(instance, task, null); |
|
|
this.setHandler(instance, task, null); |
|
|
// 消息通知
|
|
|
// 消息通知
|
|
|
WorkflowUtils.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); |
|
|
try { |
|
|
|
|
|
flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error(e.getMessage(), e); |
|
|
log.error(e.getMessage(), e); |
|
@ -541,11 +617,14 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
flowTaskVo.setFlowCode(definition.getFlowCode()); |
|
|
flowTaskVo.setFlowCode(definition.getFlowCode()); |
|
|
flowTaskVo.setFlowName(definition.getFlowName()); |
|
|
flowTaskVo.setFlowName(definition.getFlowName()); |
|
|
flowTaskVo.setBusinessId(instance.getBusinessId()); |
|
|
flowTaskVo.setBusinessId(instance.getBusinessId()); |
|
|
List<Node> nodeList = nodeService.getByNodeCodes(Collections.singletonList(flowTaskVo.getNodeCode()), instance.getDefinitionId()); |
|
|
//设置按钮权限
|
|
|
if (CollUtil.isNotEmpty(nodeList)) { |
|
|
FlowNode flowNode = getByNodeCode(flowTaskVo.getNodeCode(), instance.getDefinitionId()); |
|
|
Node node = nodeList.get(0); |
|
|
if (ObjectUtil.isNull(flowNode)) { |
|
|
flowTaskVo.setNodeRatio(node.getNodeRatio()); |
|
|
throw new NullPointerException("当前【" + flowTaskVo.getNodeCode() + "】节点编码不存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
flowTaskVo.setButtonList(flowTaskVo.getButtonList(flowNode.getExt())); |
|
|
|
|
|
flowTaskVo.setNodeRatio(flowNode.getNodeRatio()); |
|
|
|
|
|
flowTaskVo.setApplyNode(flowNode.getNodeCode().equals(flwCommonService.applyNodeCode(task.getDefinitionId()))); |
|
|
return flowTaskVo; |
|
|
return flowTaskVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -605,15 +684,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public boolean taskOperation(TaskOperationBo bo, String taskOperation) { |
|
|
public boolean taskOperation(TaskOperationBo bo, String taskOperation) { |
|
|
FlowParams flowParams = new FlowParams(); |
|
|
FlowParams flowParams = new FlowParams(); |
|
|
|
|
|
|
|
|
// 构建 JSON 对象
|
|
|
|
|
|
JSONObject extJson = new JSONObject(); |
|
|
|
|
|
extJson.put("isIllegal", ObjectUtil.isNotEmpty(bo.getIsIllegal())?bo.getIsIllegal():false); |
|
|
|
|
|
extJson.put("alertType", bo.getAlertType()); |
|
|
|
|
|
extJson.put("alertTypeContent", bo.getAlertTypeContent()); |
|
|
|
|
|
|
|
|
|
|
|
flowParams.ext(extJson.toJSONString()); |
|
|
|
|
|
|
|
|
|
|
|
flowParams.message(bo.getMessage()); |
|
|
flowParams.message(bo.getMessage()); |
|
|
if (LoginHelper.isSuperAdmin() || LoginHelper.isTenantAdmin()) { |
|
|
if (LoginHelper.isSuperAdmin() || LoginHelper.isTenantAdmin()) { |
|
|
flowParams.ignore(true); |
|
|
flowParams.ignore(true); |
|
@ -640,10 +710,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Long taskId = bo.getTaskId(); |
|
|
Long taskId = bo.getTaskId(); |
|
|
FlowTaskVo flowTaskVo = selectById(taskId); |
|
|
Task task = taskService.getById(taskId); |
|
|
|
|
|
FlowNode flowNode = getByNodeCode(task.getNodeCode(), task.getDefinitionId()); |
|
|
if ("addSignature".equals(taskOperation) || "reductionSignature".equals(taskOperation)) { |
|
|
if ("addSignature".equals(taskOperation) || "reductionSignature".equals(taskOperation)) { |
|
|
if (flowTaskVo.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) { |
|
|
if (flowNode.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) { |
|
|
throw new ServiceException(flowTaskVo.getNodeName() + "不是会签节点!"); |
|
|
throw new ServiceException(task.getNodeName() + "不是会签节点!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 设置任务状态并执行对应的任务操作
|
|
|
// 设置任务状态并执行对应的任务操作
|
|
@ -675,6 +746,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 修改任务办理人(此方法将会批量修改所有任务的办理人) |
|
|
* 修改任务办理人(此方法将会批量修改所有任务的办理人) |
|
|
* |
|
|
* |
|
@ -691,7 +763,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
List<FlowTask> flowTasks = this.selectByIdList(taskIdList); |
|
|
List<FlowTask> flowTasks = this.selectByIdList(taskIdList); |
|
|
// 批量删除现有任务的办理人记录
|
|
|
// 批量删除现有任务的办理人记录
|
|
|
if (CollUtil.isNotEmpty(flowTasks)) { |
|
|
if (CollUtil.isNotEmpty(flowTasks)) { |
|
|
WorkflowUtils.getFlowUserService().deleteByTaskIds(StreamUtils.toList(flowTasks, FlowTask::getId)); |
|
|
flwCommonService.getFlowUserService().deleteByTaskIds(StreamUtils.toList(flowTasks, FlowTask::getId)); |
|
|
List<User> userList = flowTasks.stream() |
|
|
List<User> userList = flowTasks.stream() |
|
|
.map(flowTask -> { |
|
|
.map(flowTask -> { |
|
|
FlowUser flowUser = new FlowUser(); |
|
|
FlowUser flowUser = new FlowUser(); |
|
@ -702,7 +774,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
}) |
|
|
}) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
if (CollUtil.isNotEmpty(userList)) { |
|
|
if (CollUtil.isNotEmpty(userList)) { |
|
|
WorkflowUtils.getFlowUserService().saveBatch(userList); |
|
|
flwCommonService.getFlowUserService().saveBatch(userList); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
@ -721,7 +793,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
public Map<Long, List<RemoteUserVo>> currentTaskAllUser(List<Long> taskIdList) { |
|
|
public Map<Long, List<RemoteUserVo>> currentTaskAllUser(List<Long> taskIdList) { |
|
|
Map<Long, List<RemoteUserVo>> map = new HashMap<>(); |
|
|
Map<Long, List<RemoteUserVo>> map = new HashMap<>(); |
|
|
// 获取与当前任务关联的用户列表
|
|
|
// 获取与当前任务关联的用户列表
|
|
|
List<User> associatedUsers = WorkflowUtils.getFlowUserService().getByAssociateds(taskIdList); |
|
|
List<User> associatedUsers = flwCommonService.getFlowUserService().getByAssociateds(taskIdList); |
|
|
Map<Long, List<User>> listMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated); |
|
|
Map<Long, List<User>> listMap = StreamUtils.groupByKey(associatedUsers, User::getAssociated); |
|
|
for (Map.Entry<Long, List<User>> entry : listMap.entrySet()) { |
|
|
for (Map.Entry<Long, List<User>> entry : listMap.entrySet()) { |
|
|
List<User> value = entry.getValue(); |
|
|
List<User> value = entry.getValue(); |
|
@ -741,13 +813,48 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
@Override |
|
|
@Override |
|
|
public List<RemoteUserVo> currentTaskAllUser(Long taskId) { |
|
|
public List<RemoteUserVo> currentTaskAllUser(Long taskId) { |
|
|
// 获取与当前任务关联的用户列表
|
|
|
// 获取与当前任务关联的用户列表
|
|
|
List<User> userList = WorkflowUtils.getFlowUserService().getByAssociateds(Collections.singletonList(taskId)); |
|
|
List<User> userList = flwCommonService.getFlowUserService().getByAssociateds(Collections.singletonList(taskId)); |
|
|
if (CollUtil.isEmpty(userList)) { |
|
|
if (CollUtil.isEmpty(userList)) { |
|
|
return Collections.emptyList(); |
|
|
return Collections.emptyList(); |
|
|
} |
|
|
} |
|
|
return remoteUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy()))); |
|
|
return remoteUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy()))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取下一节点信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param bo 参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<FlowNode> getNextNodeList(FlowNextNodeBo bo) { |
|
|
|
|
|
Long taskId = bo.getTaskId(); |
|
|
|
|
|
Map<String, Object> variables = bo.getVariables(); |
|
|
|
|
|
Task task = taskService.getById(taskId); |
|
|
|
|
|
Instance instance = insService.getById(task.getInstanceId()); |
|
|
|
|
|
Definition definition = defService.getById(task.getDefinitionId()); |
|
|
|
|
|
Map<String, Object> mergeVariable = MapUtil.mergeAll(instance.getVariableMap(), variables); |
|
|
|
|
|
//获取下一节点列表
|
|
|
|
|
|
List<Node> nextNodeList = nodeService.getNextNodeList(task.getDefinitionId(), task.getNodeCode(), null, SkipType.PASS.getKey(), mergeVariable); |
|
|
|
|
|
List<FlowNode> nextFlowNodes = BeanUtil.copyToList(nextNodeList, FlowNode.class); |
|
|
|
|
|
if (CollUtil.isNotEmpty(nextNodeList)) { |
|
|
|
|
|
//构建以下节点数据
|
|
|
|
|
|
List<Task> buildNextTaskList = StreamUtils.toList(nextNodeList, node -> taskService.addTask(node, instance, definition, null)); |
|
|
|
|
|
//办理人变量替换
|
|
|
|
|
|
ExpressionUtil.evalVariable(buildNextTaskList, mergeVariable); |
|
|
|
|
|
for (FlowNode flowNode : nextFlowNodes) { |
|
|
|
|
|
buildNextTaskList.stream().filter(t -> t.getNodeCode().equals(flowNode.getNodeCode())).findFirst().ifPresent(t -> { |
|
|
|
|
|
if (CollUtil.isNotEmpty(t.getPermissionList())) { |
|
|
|
|
|
List<RemoteUserVo> users = flwTaskAssigneeService.fetchUsersByStorageId(String.join(StringUtils.SEPARATOR, t.getPermissionList())); |
|
|
|
|
|
if (CollUtil.isNotEmpty(users)) { |
|
|
|
|
|
flowNode.setPermissionFlag(StreamUtils.join(users, e -> String.valueOf(e.getUserId()))); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return nextFlowNodes; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 初始化流程任务 |
|
|
* 初始化流程任务 |
|
|
* @param taskId |
|
|
* @param taskId |
|
@ -760,4 +867,17 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
return service.completeTask(completeTaskBo); |
|
|
return service.completeTask(completeTaskBo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 按照节点编码查询节点 |
|
|
|
|
|
* |
|
|
|
|
|
* @param nodeCode 节点编码 |
|
|
|
|
|
* @param definitionId 流程定义id |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public FlowNode getByNodeCode(String nodeCode, Long definitionId) { |
|
|
|
|
|
return flowNodeMapper.selectOne(new LambdaQueryWrapper<FlowNode>() |
|
|
|
|
|
.eq(FlowNode::getNodeCode, nodeCode) |
|
|
|
|
|
.eq(FlowNode::getDefinitionId, definitionId)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|