|
@@ -22,12 +22,9 @@ import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.ValidatorUtils;
|
|
import org.dromara.common.core.utils.ValidatorUtils;
|
|
import org.dromara.common.core.validate.AddGroup;
|
|
import org.dromara.common.core.validate.AddGroup;
|
|
import org.dromara.common.core.validate.EditGroup;
|
|
import org.dromara.common.core.validate.EditGroup;
|
|
-import org.dromara.common.mail.utils.MailUtils;
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
-import org.dromara.common.sse.dto.SseMessageDto;
|
|
|
|
-import org.dromara.common.sse.utils.SseMessageUtils;
|
|
|
|
import org.dromara.warm.flow.core.dto.FlowParams;
|
|
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;
|
|
@@ -41,7 +38,6 @@ import org.dromara.warm.flow.orm.mapper.FlowInstanceMapper;
|
|
import org.dromara.warm.flow.orm.mapper.FlowNodeMapper;
|
|
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.common.ConditionalOnEnable;
|
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
|
-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.bo.*;
|
|
import org.dromara.workflow.domain.bo.*;
|
|
@@ -51,9 +47,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.IFlwCommonService;
|
|
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
|
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.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -89,6 +85,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
private final FlwCategoryMapper flwCategoryMapper;
|
|
private final FlwCategoryMapper flwCategoryMapper;
|
|
private final FlowNodeMapper flowNodeMapper;
|
|
private final FlowNodeMapper flowNodeMapper;
|
|
private final IFlwTaskAssigneeService flwTaskAssigneeService;
|
|
private final IFlwTaskAssigneeService flwTaskAssigneeService;
|
|
|
|
+ private final IFlwCommonService flwCommonService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 启动任务
|
|
* 启动任务
|
|
@@ -182,7 +179,7 @@ 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);
|
|
// 消息通知
|
|
// 消息通知
|
|
- this.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice);
|
|
|
|
|
|
+ flwCommonService.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice);
|
|
//设置下一环节处理人
|
|
//设置下一环节处理人
|
|
setNextHandler(ins.getId());
|
|
setNextHandler(ins.getId());
|
|
return true;
|
|
return true;
|
|
@@ -205,10 +202,10 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
if (variableMap != null && variableMap.containsKey(task.getNodeCode())) {
|
|
if (variableMap != null && variableMap.containsKey(task.getNodeCode())) {
|
|
String userIds = variableMap.get(task.getNodeCode()).toString();
|
|
String userIds = variableMap.get(task.getNodeCode()).toString();
|
|
// 批量删除现有任务的办理人记录
|
|
// 批量删除现有任务的办理人记录
|
|
- WorkflowUtils.getFlowUserService().deleteByTaskIds(List.of(task.getId()));
|
|
|
|
|
|
+ flwCommonService.getFlowUserService().deleteByTaskIds(List.of(task.getId()));
|
|
// 批量新增任务办理人记录
|
|
// 批量新增任务办理人记录
|
|
- Set<User> users = WorkflowUtils.buildFlowUser(List.of(userIds.split(StringUtils.SEPARATOR)), task.getId());
|
|
|
|
- WorkflowUtils.getFlowUserService().saveBatch(new ArrayList<>(users));
|
|
|
|
|
|
+ Set<User> users = flwCommonService.buildFlowUser(List.of(userIds.split(StringUtils.SEPARATOR)), task.getId());
|
|
|
|
+ flwCommonService.getFlowUserService().saveBatch(new ArrayList<>(users));
|
|
variableMap.remove(task.getNodeCode());
|
|
variableMap.remove(task.getNodeCode());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -266,7 +263,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;
|
|
}
|
|
}
|
|
@@ -275,16 +272,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);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -324,7 +321,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
return flowUser;
|
|
return flowUser;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
// 批量保存抄送人员
|
|
// 批量保存抄送人员
|
|
- WorkflowUtils.getFlowUserService().saveBatch(userList);
|
|
|
|
|
|
+ flwCommonService.getFlowUserService().saveBatch(userList);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -452,7 +449,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);
|
|
@@ -465,7 +462,7 @@ 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);
|
|
// 消息通知
|
|
// 消息通知
|
|
- this.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice);
|
|
|
|
|
|
+ flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice);
|
|
return true;
|
|
return true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
@@ -565,7 +562,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
}
|
|
}
|
|
flowTaskVo.setButtonList(flowTaskVo.getButtonList(flowNode.getExt()));
|
|
flowTaskVo.setButtonList(flowTaskVo.getButtonList(flowNode.getExt()));
|
|
flowTaskVo.setNodeRatio(flowNode.getNodeRatio());
|
|
flowTaskVo.setNodeRatio(flowNode.getNodeRatio());
|
|
- flowTaskVo.setApplyNode(flowNode.getNodeCode().equals(WorkflowUtils.applyNodeCode(task.getDefinitionId())));
|
|
|
|
|
|
+ flowTaskVo.setApplyNode(flowNode.getNodeCode().equals(flwCommonService.applyNodeCode(task.getDefinitionId())));
|
|
return flowTaskVo;
|
|
return flowTaskVo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -737,7 +734,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();
|
|
@@ -748,7 +745,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) {
|
|
@@ -767,7 +764,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
public Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList) {
|
|
public Map<Long, List<UserDTO>> currentTaskAllUser(List<Long> taskIdList) {
|
|
Map<Long, List<UserDTO>> map = new HashMap<>();
|
|
Map<Long, List<UserDTO>> 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();
|
|
@@ -787,7 +784,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
@Override
|
|
@Override
|
|
public List<UserDTO> currentTaskAllUser(Long taskId) {
|
|
public List<UserDTO> 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();
|
|
}
|
|
}
|
|
@@ -807,48 +804,4 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
|
.eq(FlowNode::getDefinitionId, definitionId));
|
|
.eq(FlowNode::getDefinitionId, definitionId));
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 发送消息
|
|
|
|
- *
|
|
|
|
- * @param flowName 流程定义名称
|
|
|
|
- * @param messageType 消息类型
|
|
|
|
- * @param message 消息内容,为空则发送默认配置的消息内容
|
|
|
|
- */
|
|
|
|
- public void sendMessage(String flowName, Long instId, List<String> messageType, String message) {
|
|
|
|
- List<UserDTO> userList = new ArrayList<>();
|
|
|
|
- List<FlowTask> list = this.selectByInstId(instId);
|
|
|
|
- if (StringUtils.isBlank(message)) {
|
|
|
|
- message = "有新的【" + flowName + "】单据已经提交至您,请您及时处理。";
|
|
|
|
- }
|
|
|
|
- for (Task task : list) {
|
|
|
|
- List<UserDTO> users = this.currentTaskAllUser(task.getId());
|
|
|
|
- if (CollUtil.isNotEmpty(users)) {
|
|
|
|
- userList.addAll(users);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (CollUtil.isNotEmpty(userList)) {
|
|
|
|
- for (String code : messageType) {
|
|
|
|
- MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code);
|
|
|
|
- if (ObjectUtil.isNotEmpty(messageTypeEnum)) {
|
|
|
|
- switch (messageTypeEnum) {
|
|
|
|
- case SYSTEM_MESSAGE:
|
|
|
|
- SseMessageDto dto = new SseMessageDto();
|
|
|
|
- dto.setUserIds(StreamUtils.toList(userList, UserDTO::getUserId).stream().distinct().collect(Collectors.toList()));
|
|
|
|
- dto.setMessage(message);
|
|
|
|
- SseMessageUtils.publishMessage(dto);
|
|
|
|
- break;
|
|
|
|
- case EMAIL_MESSAGE:
|
|
|
|
- MailUtils.sendText(StreamUtils.join(userList, UserDTO::getEmail), "单据审批提醒", message);
|
|
|
|
- break;
|
|
|
|
- case SMS_MESSAGE:
|
|
|
|
- //todo 短信发送
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- throw new IllegalStateException("Unexpected value: " + messageTypeEnum);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|