mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-04 11:37:28 +00:00
update 优化 特殊service传值方式
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package org.dromara.workflow.flowable.cmd;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
@@ -28,17 +27,20 @@ public class AttachmentCmd implements Command<Boolean> {
|
||||
|
||||
private final String processInstanceId;
|
||||
|
||||
public AttachmentCmd(String fileId, String taskId, String processInstanceId) {
|
||||
private final RemoteFileService remoteFileService;
|
||||
|
||||
public AttachmentCmd(String fileId, String taskId, String processInstanceId,
|
||||
RemoteFileService remoteFileService) {
|
||||
this.fileId = fileId;
|
||||
this.taskId = taskId;
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.remoteFileService = remoteFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean execute(CommandContext commandContext) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(fileId)) {
|
||||
RemoteFileService remoteFileService = SpringUtils.getBean(RemoteFileService.class);
|
||||
List<RemoteFile> ossList = remoteFileService.selectByIds(fileId);
|
||||
if (CollUtil.isNotEmpty(ossList)) {
|
||||
for (RemoteFile oss : ossList) {
|
||||
|
@@ -9,12 +9,14 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
@@ -77,6 +79,8 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
||||
private final IWfNodeConfigService wfNodeConfigService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
@DubboReference
|
||||
private final RemoteUserService remoteUserService;
|
||||
|
||||
@Value("${flowable.activity-font-name}")
|
||||
private String activityFontName;
|
||||
@@ -323,7 +327,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime());
|
||||
historyInfoVo.setRunDuration(infoVo.getEndTime() == null ? null : infoVo.getRunDuration());
|
||||
if (ObjectUtil.isEmpty(infoVo.getAssignee())) {
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId());
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId(), remoteUserService);
|
||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||
}
|
||||
@@ -338,7 +342,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
historyInfoVo.setEndTime(e.getEndTime() == null ? null : e.getEndTime());
|
||||
historyInfoVo.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration());
|
||||
if (ObjectUtil.isEmpty(e.getAssignee())) {
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId());
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId(), remoteUserService);
|
||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||
}
|
||||
@@ -394,7 +398,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
}
|
||||
//设置人员id
|
||||
if (ObjectUtil.isEmpty(historicTaskInstance.getAssignee())) {
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId());
|
||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(historicTaskInstance.getId(), remoteUserService);
|
||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||
actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||
}
|
||||
@@ -675,7 +679,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||
message = "您的【" + processInstance.getName() + "】单据还未审批,请您及时处理。";
|
||||
}
|
||||
List<Task> list = QueryUtils.taskQuery(taskUrgingBo.getProcessInstanceId()).list();
|
||||
WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message);
|
||||
WorkflowUtils.sendMessage(list, processInstance.getName(), taskUrgingBo.getMessageType(), message, remoteUserService);
|
||||
} catch (ServiceException e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.dromara.system.api.model.RoleDTO;
|
||||
@@ -79,9 +80,11 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
private final ActHiTaskinstMapper actHiTaskinstMapper;
|
||||
private final IWfNodeConfigService wfNodeConfigService;
|
||||
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
||||
@DubboReference
|
||||
private final RemoteUserService userService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
@DubboReference
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 启动任务
|
||||
@@ -177,7 +180,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
return true;
|
||||
}
|
||||
//附件上传
|
||||
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId());
|
||||
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId(), remoteFileService);
|
||||
managementService.executeCommand(attachmentCmd);
|
||||
String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey());
|
||||
//流程提交监听
|
||||
@@ -241,7 +244,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
*/
|
||||
@Async
|
||||
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, remoteUserService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +278,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
|
||||
for (TaskVo task : taskList) {
|
||||
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
|
||||
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
|
||||
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), remoteUserService));
|
||||
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
|
||||
@@ -340,7 +343,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
});
|
||||
}
|
||||
taskVo.setAssignee(StringUtils.isNotBlank(task.getAssignee()) ? Long.valueOf(task.getAssignee()) : null);
|
||||
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
|
||||
taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), remoteUserService));
|
||||
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
|
||||
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
|
||||
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
|
||||
@@ -820,7 +823,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
|
||||
if (multiInstance.getType() instanceof SequentialMultiInstanceBehavior) {
|
||||
List<Long> userIds = StreamUtils.filter(assigneeList, e -> !String.valueOf(e).equals(task.getAssignee()));
|
||||
List<RemoteUserVo> userList = userService.selectListByIds(userIds);
|
||||
List<RemoteUserVo> userList = remoteUserService.selectListByIds(userIds);
|
||||
for (Long userId : userIds) {
|
||||
TaskVo taskVo = new TaskVo();
|
||||
taskVo.setId("串行会签");
|
||||
@@ -838,7 +841,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
List<Task> tasks = StreamUtils.filter(taskList, e -> StringUtils.isBlank(e.getParentTaskId()) && !e.getExecutionId().equals(task.getExecutionId()) && e.getTaskDefinitionKey().equals(task.getTaskDefinitionKey()));
|
||||
if (CollUtil.isNotEmpty(tasks)) {
|
||||
List<Long> userIds = StreamUtils.toList(tasks, e -> Long.valueOf(e.getAssignee()));
|
||||
List<RemoteUserVo> userList = userService.selectListByIds(userIds);
|
||||
List<RemoteUserVo> userList = remoteUserService.selectListByIds(userIds);
|
||||
for (Task t : tasks) {
|
||||
TaskVo taskVo = new TaskVo();
|
||||
taskVo.setId(t.getId());
|
||||
|
@@ -125,8 +125,7 @@ public class WorkflowUtils {
|
||||
*
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
public static ParticipantVo getCurrentTaskParticipant(String taskId) {
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
public static ParticipantVo getCurrentTaskParticipant(String taskId, RemoteUserService remoteUserService) {
|
||||
ParticipantVo participantVo = new ParticipantVo();
|
||||
List<HistoricIdentityLink> linksForTask = PROCESS_ENGINE.getHistoryService().getHistoricIdentityLinksForTask(taskId);
|
||||
Task task = QueryUtils.taskQuery().taskId(taskId).singleResult();
|
||||
@@ -235,14 +234,13 @@ public class WorkflowUtils {
|
||||
* @param messageType 消息类型
|
||||
* @param message 消息内容,为空则发送默认配置的消息内容
|
||||
*/
|
||||
public static void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
public static void sendMessage(List<Task> list, String name, List<String> messageType, String message, RemoteUserService remoteUserService) {
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
if (StringUtils.isBlank(message)) {
|
||||
message = "有新的【" + name + "】单据已经提交至您的待办,请您及时处理。";
|
||||
}
|
||||
for (Task t : list) {
|
||||
ParticipantVo taskParticipant = WorkflowUtils.getCurrentTaskParticipant(t.getId());
|
||||
ParticipantVo taskParticipant = WorkflowUtils.getCurrentTaskParticipant(t.getId(), remoteUserService);
|
||||
if (CollUtil.isNotEmpty(taskParticipant.getGroupIds())) {
|
||||
List<Long> userIdList = remoteUserService.selectUserIdsByRoleIds(taskParticipant.getGroupIds());
|
||||
if (CollUtil.isNotEmpty(userIdList)) {
|
||||
|
Reference in New Issue
Block a user