update 优化 特殊service传值方式
This commit is contained in:
parent
20a3396128
commit
6186881615
@ -3,7 +3,6 @@ package org.dromara.workflow.flowable.cmd;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import org.dromara.common.core.domain.dto.OssDTO;
|
import org.dromara.common.core.domain.dto.OssDTO;
|
||||||
import org.dromara.common.core.service.OssService;
|
import org.dromara.common.core.service.OssService;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.flowable.common.engine.impl.interceptor.Command;
|
import org.flowable.common.engine.impl.interceptor.Command;
|
||||||
@ -28,17 +27,20 @@ public class AttachmentCmd implements Command<Boolean> {
|
|||||||
|
|
||||||
private final String processInstanceId;
|
private final String processInstanceId;
|
||||||
|
|
||||||
public AttachmentCmd(String fileId, String taskId, String processInstanceId) {
|
private final OssService ossService;
|
||||||
|
|
||||||
|
public AttachmentCmd(String fileId, String taskId, String processInstanceId, OssService ossService) {
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
this.processInstanceId = processInstanceId;
|
this.processInstanceId = processInstanceId;
|
||||||
|
this.ossService = ossService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute(CommandContext commandContext) {
|
public Boolean execute(CommandContext commandContext) {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isNotBlank(fileId)) {
|
if (StringUtils.isNotBlank(fileId)) {
|
||||||
List<OssDTO> ossList = SpringUtils.getBean(OssService.class).selectByIds(fileId);
|
List<OssDTO> ossList = ossService.selectByIds(fileId);
|
||||||
if (CollUtil.isNotEmpty(ossList)) {
|
if (CollUtil.isNotEmpty(ossList)) {
|
||||||
for (OssDTO oss : ossList) {
|
for (OssDTO oss : ossList) {
|
||||||
AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager();
|
AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager();
|
||||||
|
@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.service.UserService;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
@ -77,6 +78,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
||||||
private final IWfNodeConfigService wfNodeConfigService;
|
private final IWfNodeConfigService wfNodeConfigService;
|
||||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
@Value("${flowable.activity-font-name}")
|
@Value("${flowable.activity-font-name}")
|
||||||
private String activityFontName;
|
private String activityFontName;
|
||||||
@ -323,7 +325,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime());
|
historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime());
|
||||||
historyInfoVo.setRunDuration(infoVo.getEndTime() == null ? null : infoVo.getRunDuration());
|
historyInfoVo.setRunDuration(infoVo.getEndTime() == null ? null : infoVo.getRunDuration());
|
||||||
if (ObjectUtil.isEmpty(infoVo.getAssignee())) {
|
if (ObjectUtil.isEmpty(infoVo.getAssignee())) {
|
||||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId());
|
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId(), userService);
|
||||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||||
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||||
}
|
}
|
||||||
@ -338,7 +340,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
historyInfoVo.setEndTime(e.getEndTime() == null ? null : e.getEndTime());
|
historyInfoVo.setEndTime(e.getEndTime() == null ? null : e.getEndTime());
|
||||||
historyInfoVo.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration());
|
historyInfoVo.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration());
|
||||||
if (ObjectUtil.isEmpty(e.getAssignee())) {
|
if (ObjectUtil.isEmpty(e.getAssignee())) {
|
||||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId());
|
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId(), userService);
|
||||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||||
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||||
}
|
}
|
||||||
@ -394,7 +396,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
}
|
}
|
||||||
//设置人员id
|
//设置人员id
|
||||||
if (ObjectUtil.isEmpty(historicTaskInstance.getAssignee())) {
|
if (ObjectUtil.isEmpty(historicTaskInstance.getAssignee())) {
|
||||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId());
|
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId(), userService);
|
||||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||||
actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||||
}
|
}
|
||||||
@ -675,7 +677,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
message = "您的【" + processInstance.getName() + "】单据还未审批,请您及时处理。";
|
message = "您的【" + processInstance.getName() + "】单据还未审批,请您及时处理。";
|
||||||
}
|
}
|
||||||
List<Task> list = QueryUtils.taskQuery(taskUrgingBo.getProcessInstanceId()).list();
|
List<Task> list = QueryUtils.taskQuery(taskUrgingBo.getProcessInstanceId()).list();
|
||||||
WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message);
|
WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message, userService);
|
||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||||
import org.dromara.common.core.domain.dto.UserDTO;
|
import org.dromara.common.core.domain.dto.UserDTO;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.service.OssService;
|
||||||
import org.dromara.common.core.service.UserService;
|
import org.dromara.common.core.service.UserService;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@ -78,8 +79,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
private final ActHiTaskinstMapper actHiTaskinstMapper;
|
private final ActHiTaskinstMapper actHiTaskinstMapper;
|
||||||
private final IWfNodeConfigService wfNodeConfigService;
|
private final IWfNodeConfigService wfNodeConfigService;
|
||||||
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
||||||
private final UserService userService;
|
|
||||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||||
|
private final UserService userService;
|
||||||
|
private final OssService ossService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动任务
|
* 启动任务
|
||||||
@ -175,7 +177,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//附件上传
|
//附件上传
|
||||||
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId());
|
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId(), ossService);
|
||||||
managementService.executeCommand(attachmentCmd);
|
managementService.executeCommand(attachmentCmd);
|
||||||
String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey());
|
String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey());
|
||||||
//流程提交监听
|
//流程提交监听
|
||||||
@ -239,7 +241,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
|
public void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
|
||||||
WorkflowUtils.sendMessage(list, name, messageType, message);
|
WorkflowUtils.sendMessage(list, name, messageType, message, userService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,7 +275,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
||||||
for (TaskVo task : taskList) {
|
for (TaskVo task : taskList) {
|
||||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||||
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
|
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||||
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||||
@ -338,7 +340,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
taskVo.setAssignee(StringUtils.isNotBlank(task.getAssignee()) ? Long.valueOf(task.getAssignee()) : null);
|
taskVo.setAssignee(StringUtils.isNotBlank(task.getAssignee()) ? Long.valueOf(task.getAssignee()) : null);
|
||||||
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
|
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
|
||||||
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
||||||
|
@ -125,8 +125,7 @@ public class WorkflowUtils {
|
|||||||
*
|
*
|
||||||
* @param taskId 任务id
|
* @param taskId 任务id
|
||||||
*/
|
*/
|
||||||
public static ParticipantVo getCurrentTaskParticipant(String taskId) {
|
public static ParticipantVo getCurrentTaskParticipant(String taskId, UserService userService) {
|
||||||
UserService userService = SpringUtils.getBean(UserService.class);
|
|
||||||
ParticipantVo participantVo = new ParticipantVo();
|
ParticipantVo participantVo = new ParticipantVo();
|
||||||
List<HistoricIdentityLink> linksForTask = PROCESS_ENGINE.getHistoryService().getHistoricIdentityLinksForTask(taskId);
|
List<HistoricIdentityLink> linksForTask = PROCESS_ENGINE.getHistoryService().getHistoricIdentityLinksForTask(taskId);
|
||||||
Task task = QueryUtils.taskQuery().taskId(taskId).singleResult();
|
Task task = QueryUtils.taskQuery().taskId(taskId).singleResult();
|
||||||
@ -234,14 +233,13 @@ public class WorkflowUtils {
|
|||||||
* @param messageType 消息类型
|
* @param messageType 消息类型
|
||||||
* @param message 消息内容,为空则发送默认配置的消息内容
|
* @param message 消息内容,为空则发送默认配置的消息内容
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
|
public static void sendMessage(List<Task> list, String name, List<String> messageType, String message, UserService userService) {
|
||||||
UserService userService = SpringUtils.getBean(UserService.class);
|
|
||||||
Set<Long> userIds = new HashSet<>();
|
Set<Long> userIds = new HashSet<>();
|
||||||
if (StringUtils.isBlank(message)) {
|
if (StringUtils.isBlank(message)) {
|
||||||
message = "有新的【" + name + "】单据已经提交至您的待办,请您及时处理。";
|
message = "有新的【" + name + "】单据已经提交至您的待办,请您及时处理。";
|
||||||
}
|
}
|
||||||
for (Task t : list) {
|
for (Task t : list) {
|
||||||
ParticipantVo taskParticipant = WorkflowUtils.getCurrentTaskParticipant(t.getId());
|
ParticipantVo taskParticipant = WorkflowUtils.getCurrentTaskParticipant(t.getId(), userService);
|
||||||
if (CollUtil.isNotEmpty(taskParticipant.getGroupIds())) {
|
if (CollUtil.isNotEmpty(taskParticipant.getGroupIds())) {
|
||||||
List<Long> userIdList = userService.selectUserIdsByRoleIds(taskParticipant.getGroupIds());
|
List<Long> userIdList = userService.selectUserIdsByRoleIds(taskParticipant.getGroupIds());
|
||||||
if (CollUtil.isNotEmpty(userIdList)) {
|
if (CollUtil.isNotEmpty(userIdList)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user