mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-09 21:59:22 +00:00
update 优化 SpringUtils 获取 dubbo 接口代理问题
This commit is contained in:
@@ -1,152 +0,0 @@
|
||||
package org.dromara.workflow.common.enums;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 业务状态枚举
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BusinessStatusEnum {
|
||||
/**
|
||||
* 已撤销
|
||||
*/
|
||||
CANCEL("cancel", "已撤销"),
|
||||
/**
|
||||
* 草稿
|
||||
*/
|
||||
DRAFT("draft", "草稿"),
|
||||
/**
|
||||
* 待审核
|
||||
*/
|
||||
WAITING("waiting", "待审核"),
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
FINISH("finish", "已完成"),
|
||||
/**
|
||||
* 已作废
|
||||
*/
|
||||
INVALID("invalid", "已作废"),
|
||||
/**
|
||||
* 已退回
|
||||
*/
|
||||
BACK("back", "已退回"),
|
||||
/**
|
||||
* 已终止
|
||||
*/
|
||||
TERMINATION("termination", "已终止");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final String status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
|
||||
/**
|
||||
* 获取业务状态
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
public static String findByStatus(String status) {
|
||||
if (StringUtils.isBlank(status)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
return Arrays.stream(BusinessStatusEnum.values())
|
||||
.filter(statusEnum -> statusEnum.getStatus().equals(status))
|
||||
.findFirst()
|
||||
.map(BusinessStatusEnum::getDesc)
|
||||
.orElse(StrUtil.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动流程校验
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
public static void checkStartStatus(String status) {
|
||||
if (WAITING.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已提交过申请,正在审批中!");
|
||||
} else if (FINISH.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已完成申请!");
|
||||
} else if (INVALID.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已作废!");
|
||||
} else if (TERMINATION.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已终止!");
|
||||
} else if (StringUtils.isBlank(status)) {
|
||||
throw new ServiceException("流程状态为空!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销流程校验
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
public static void checkCancelStatus(String status) {
|
||||
if (CANCEL.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已撤销!");
|
||||
} else if (FINISH.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已完成申请!");
|
||||
} else if (INVALID.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已作废!");
|
||||
} else if (TERMINATION.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已终止!");
|
||||
} else if (BACK.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已退回!");
|
||||
} else if (StringUtils.isBlank(status)) {
|
||||
throw new ServiceException("流程状态为空!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回流程校验
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
public static void checkBackStatus(String status) {
|
||||
if (BACK.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已退回!");
|
||||
} else if (FINISH.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已完成申请!");
|
||||
} else if (INVALID.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已作废!");
|
||||
} else if (TERMINATION.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已终止!");
|
||||
} else if (CANCEL.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已撤销!");
|
||||
} else if (StringUtils.isBlank(status)) {
|
||||
throw new ServiceException("流程状态为空!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废,终止流程校验
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
public static void checkInvalidStatus(String status) {
|
||||
if (FINISH.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已完成申请!");
|
||||
} else if (INVALID.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已作废!");
|
||||
} else if (TERMINATION.getStatus().equals(status)) {
|
||||
throw new ServiceException("该单据已终止!");
|
||||
} else if (StringUtils.isBlank(status)) {
|
||||
throw new ServiceException("流程状态为空!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@@ -13,11 +12,7 @@ import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
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.web.core.BaseController;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.resource.api.domain.RemoteFile;
|
||||
import org.dromara.system.api.model.LoginUser;
|
||||
import org.dromara.workflow.domain.bo.ModelBo;
|
||||
import org.dromara.workflow.domain.vo.ModelVo;
|
||||
import org.dromara.workflow.service.IActModelService;
|
||||
@@ -53,8 +48,6 @@ public class ActModelController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<Model> page(ModelBo modelBo, PageQuery pageQuery) {
|
||||
RemoteFileService bean = SpringUtils.getBean(RemoteFileService.class);
|
||||
List<RemoteFile> remoteFiles = bean.selectByIds("1");
|
||||
return actModelService.page(modelBo, pageQuery);
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,8 @@ public class AttachmentCmd implements Command<Boolean> {
|
||||
public Boolean execute(CommandContext commandContext) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(fileId)) {
|
||||
List<RemoteFile> ossList = SpringUtils.getBean(RemoteFileService.class).selectByIds(fileId);
|
||||
RemoteFileService remoteFileService = SpringUtils.getBean(RemoteFileService.class);
|
||||
List<RemoteFile> ossList = remoteFileService.selectByIds(fileId);
|
||||
if (CollUtil.isNotEmpty(ossList)) {
|
||||
for (RemoteFile oss : ossList) {
|
||||
AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager();
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package org.dromara.workflow.runner;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 初始化 dubbo 接口生成接口代理 不然无法直接用 SpringUtils 注入 dubbo 接口使用
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
public class WorkflowApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
@DubboReference
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
}
|
||||
|
||||
}
|
@@ -16,7 +16,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.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.domain.ActHiProcinst;
|
||||
import org.dromara.workflow.domain.bo.ProcessInstanceBo;
|
||||
|
@@ -19,7 +19,7 @@ import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.dromara.system.api.model.RoleDTO;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.domain.ActHiTaskinst;
|
||||
import org.dromara.workflow.domain.WfTaskBackNode;
|
||||
|
@@ -15,7 +15,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.workflow.api.domain.RemoteWorkflowService;
|
||||
import org.dromara.workflow.api.domain.event.ProcessEvent;
|
||||
import org.dromara.workflow.api.domain.event.ProcessTaskEvent;
|
||||
import org.dromara.workflow.common.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.workflow.domain.TestLeave;
|
||||
import org.dromara.workflow.domain.bo.TestLeaveBo;
|
||||
import org.dromara.workflow.domain.vo.TestLeaveVo;
|
||||
|
@@ -25,7 +25,6 @@ import org.dromara.workflow.domain.vo.MultiInstanceVo;
|
||||
import org.dromara.workflow.domain.vo.ParticipantVo;
|
||||
import org.dromara.workflow.flowable.cmd.UpdateHiTaskInstCmd;
|
||||
import org.dromara.workflow.mapper.ActHiTaskinstMapper;
|
||||
import org.dromara.workflow.service.IActHiProcinstService;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.FlowNode;
|
||||
import org.flowable.common.engine.api.delegate.Expression;
|
||||
@@ -50,8 +49,6 @@ import java.util.*;
|
||||
public class WorkflowUtils {
|
||||
|
||||
private static final ProcessEngine PROCESS_ENGINE = SpringUtils.getBean(ProcessEngine.class);
|
||||
private static final RemoteUserService USER_SERVICE = SpringUtils.getBean(RemoteUserService.class);
|
||||
private static final IActHiProcinstService ACT_HI_PROCINST_SERVICE = SpringUtils.getBean(IActHiProcinstService.class);
|
||||
private static final ActHiTaskinstMapper ACT_HI_TASKINST_MAPPER = SpringUtils.getBean(ActHiTaskinstMapper.class);
|
||||
|
||||
/**
|
||||
@@ -129,6 +126,7 @@ public class WorkflowUtils {
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
public static ParticipantVo getCurrentTaskParticipant(String taskId) {
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
ParticipantVo participantVo = new ParticipantVo();
|
||||
List<HistoricIdentityLink> linksForTask = PROCESS_ENGINE.getHistoryService().getHistoricIdentityLinksForTask(taskId);
|
||||
Task task = QueryUtils.taskQuery().taskId(taskId).singleResult();
|
||||
@@ -136,10 +134,11 @@ public class WorkflowUtils {
|
||||
List<HistoricIdentityLink> groupList = StreamUtils.filter(linksForTask, e -> StringUtils.isNotBlank(e.getGroupId()));
|
||||
if (CollUtil.isNotEmpty(groupList)) {
|
||||
List<Long> groupIds = StreamUtils.toList(groupList, e -> Long.valueOf(e.getGroupId()));
|
||||
List<Long> userIds = USER_SERVICE.selectUserIdsByRoleIds(groupIds);
|
||||
|
||||
List<Long> userIds = remoteUserService.selectUserIdsByRoleIds(groupIds);
|
||||
if (CollUtil.isNotEmpty(userIds)) {
|
||||
participantVo.setGroupIds(groupIds);
|
||||
List<RemoteUserVo> userList = USER_SERVICE.selectListByIds(userIds);
|
||||
List<RemoteUserVo> userList = remoteUserService.selectListByIds(userIds);
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
List<Long> userIdList = StreamUtils.toList(userList, RemoteUserVo::getUserId);
|
||||
List<String> nickNames = StreamUtils.toList(userList, RemoteUserVo::getNickName);
|
||||
@@ -158,7 +157,7 @@ public class WorkflowUtils {
|
||||
|
||||
}
|
||||
}
|
||||
List<RemoteUserVo> userList = USER_SERVICE.selectListByIds(userIdList);
|
||||
List<RemoteUserVo> userList = remoteUserService.selectListByIds(userIdList);
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
List<Long> userIds = StreamUtils.toList(userList, RemoteUserVo::getUserId);
|
||||
List<String> nickNames = StreamUtils.toList(userList, RemoteUserVo::getNickName);
|
||||
@@ -237,6 +236,7 @@ public class WorkflowUtils {
|
||||
* @param message 消息内容,为空则发送默认配置的消息内容
|
||||
*/
|
||||
public static void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
if (StringUtils.isBlank(message)) {
|
||||
message = "有新的【" + name + "】单据已经提交至您的待办,请您及时处理。";
|
||||
@@ -244,7 +244,7 @@ public class WorkflowUtils {
|
||||
for (Task t : list) {
|
||||
ParticipantVo taskParticipant = WorkflowUtils.getCurrentTaskParticipant(t.getId());
|
||||
if (CollUtil.isNotEmpty(taskParticipant.getGroupIds())) {
|
||||
List<Long> userIdList = USER_SERVICE.selectUserIdsByRoleIds(taskParticipant.getGroupIds());
|
||||
List<Long> userIdList = remoteUserService.selectUserIdsByRoleIds(taskParticipant.getGroupIds());
|
||||
if (CollUtil.isNotEmpty(userIdList)) {
|
||||
userIds.addAll(userIdList);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ public class WorkflowUtils {
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(userIds)) {
|
||||
List<RemoteUserVo> userList = USER_SERVICE.selectListByIds(new ArrayList<>(userIds));
|
||||
List<RemoteUserVo> userList = remoteUserService.selectListByIds(new ArrayList<>(userIds));
|
||||
for (String code : messageType) {
|
||||
MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code);
|
||||
if (ObjectUtil.isNotEmpty(messageTypeEnum)) {
|
||||
|
Reference in New Issue
Block a user