diff --git a/README.md b/README.md index 05dd679aad25700f181a1bbbdce814debe67160e..7ac54489806e58ae1b52c7dd59b31352d69543c3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-5.2.0-success.svg)](https://gitee.com/dromara/RuoYi-Vue-Plus) -[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.1-blue.svg)]() +[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.2-blue.svg)]() [![JDK-17](https://img.shields.io/badge/JDK-17-green.svg)]() [![JDK-21](https://img.shields.io/badge/JDK-21-green.svg)]() diff --git a/pom.xml b/pom.xml index 7d89d8a855712494cc15c3865a8b2dddbc4ff58d..900b61b53b8ac3b770268a0bd0aef90c1711c0d4 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ RuoYi-Vue-Plus多租户管理系统 - 5.2.0-BETA2 + 5.2.0 3.2.6 UTF-8 UTF-8 @@ -25,16 +25,16 @@ 3.3.4 2.3 1.38.0 - 3.5.6 + 3.5.7 3.9.1 5.8.27 4.10.0 3.2.3 - 3.29.0 + 3.31.0 2.2.7 - 4.3.0 + 4.3.1 2.14.4 - 1.0.0-beta3 + 1.0.1 1.3.6 0.2.0 1.18.32 diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index 43e689be30fbf3b567fd2b0f091a1b4378fbd5b9..d99af5b62d10602e58fc4c8c20fd5673f4245bb0 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -1,6 +1,7 @@ package org.dromara.web.controller; import cn.dev33.satoken.annotation.SaIgnore; +import cn.hutool.core.codec.Base64; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import jakarta.servlet.http.HttpServletRequest; @@ -42,7 +43,10 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -112,13 +116,18 @@ public class AuthController { * @return 结果 */ @GetMapping("/binding/{source}") - public R authBinding(@PathVariable("source") String source) { + public R authBinding(@PathVariable("source") String source, + @RequestParam String tenantId, @RequestParam String domain) { SocialLoginConfigProperties obj = socialProperties.getType().get(source); if (ObjectUtil.isNull(obj)) { return R.fail(source + "平台账号暂不支持"); } AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties); - String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); + Map map = new HashMap<>(); + map.put("tenantId", tenantId); + map.put("domain", domain); + map.put("state", AuthStateUtils.createState()); + String authorizeUrl = authRequest.authorize(Base64.encode(JsonUtils.toJsonString(map), StandardCharsets.UTF_8)); return R.ok("操作成功", authorizeUrl); } diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 5b5597369492767d1c80e1fe8dc1365d50cfef36..e24b26574c1edc4f10d7b663e200f436d12b3668 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -20,6 +20,8 @@ snail-job: port: 1788 # 详见 script/sql/snail_job.sql `sj_namespace` 表 namespace: ${spring.profiles.active} + # 随主应用端口飘逸 + port: 2${server.port} --- # 数据源配置 spring: diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index d21644d42e16d0018c9cfb4883efb31e7b60a7b3..0192d59365790984e87c07b23a1c4b506c572cfc 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -23,6 +23,8 @@ snail-job: port: 1788 # 详见 script/sql/snail_job.sql `sj_namespace` 表 namespace: ${spring.profiles.active} + # 随主应用端口飘逸 + port: 2${server.port} --- # 数据源配置 spring: diff --git a/ruoyi-common/ruoyi-common-bom/pom.xml b/ruoyi-common/ruoyi-common-bom/pom.xml index 39ef2b3371208b8cf93318f949aea04e2eb1f8e4..d546275c90ed85d31a2993f14bf14b3674a35faa 100644 --- a/ruoyi-common/ruoyi-common-bom/pom.xml +++ b/ruoyi-common/ruoyi-common-bom/pom.xml @@ -14,7 +14,7 @@ - 5.2.0-BETA2 + 5.2.0 diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ApplicationConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ApplicationConfig.java index d12008706ceab681394c063d2d53f3e61c830de2..d9f70e426860c497a015b0de7a11f6c5bb355988 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ApplicationConfig.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ApplicationConfig.java @@ -10,8 +10,7 @@ import org.springframework.scheduling.annotation.EnableAsync; * @author Lion Li */ @AutoConfiguration -// 表示通过aop框架暴露该代理对象,AopContext能够访问 -@EnableAspectJAutoProxy(exposeProxy = true) +@EnableAspectJAutoProxy @EnableAsync(proxyTargetClass = true) public class ApplicationConfig { diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/domain/event/ProcessTaskEvent.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/domain/event/ProcessTaskEvent.java index 09c84bd9153d59679a082c7ea6cc1ec9cb48a3f3..019ca823b67841c198ea512c78619a51b02ba6a8 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/domain/event/ProcessTaskEvent.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/domain/event/ProcessTaskEvent.java @@ -18,9 +18,14 @@ public class ProcessTaskEvent implements Serializable { private static final long serialVersionUID = 1L; /** - * 流程定义key与流程节点标识(拼接方式:流程定义key_流程节点) + * 流程定义key */ - private String keyNode; + private String key; + + /** + * 审批节点key + */ + private String taskDefinitionKey; /** * 任务id diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/SpringUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/SpringUtils.java index e58c394acdb007279060caf450dd0c006423d84a..169c6e217e2f5226f748139570a1fb9381d504be 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/SpringUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/SpringUtils.java @@ -1,7 +1,6 @@ package org.dromara.common.core.utils; import cn.hutool.extra.spring.SpringUtil; -import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.boot.autoconfigure.thread.Threading; import org.springframework.context.ApplicationContext; @@ -50,7 +49,7 @@ public final class SpringUtils extends SpringUtil { */ @SuppressWarnings("unchecked") public static T getAopProxy(T invoker) { - return (T) AopContext.currentProxy(); + return (T) getBean(invoker.getClass()); } diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/aspect/LogAspect.java b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/aspect/LogAspect.java index 87240729cfede18bee06139aafa0be3cdd9b00ec..cdbd00f09c4edc84aea8f09833f23824491252ce 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/aspect/LogAspect.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/org/dromara/common/log/aspect/LogAspect.java @@ -56,7 +56,7 @@ public class LogAspect { * 处理请求前执行 */ @Before(value = "@annotation(controllerLog)") - public void boBefore(JoinPoint joinPoint, Log controllerLog) { + public void doBefore(JoinPoint joinPoint, Log controllerLog) { StopWatch stopWatch = new StopWatch(); KEY_CACHE.set(stopWatch); stopWatch.start(); diff --git a/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/core/mapper/BaseMapperPlus.java b/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/core/mapper/BaseMapperPlus.java index 08723f60865311cebfc19067268e149bc96eb32d..388925001a7a497a800b26fd205b77100c81caae 100644 --- a/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/core/mapper/BaseMapperPlus.java +++ b/ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/core/mapper/BaseMapperPlus.java @@ -50,49 +50,54 @@ public interface BaseMapperPlus extends BaseMapper { * 批量插入 */ default boolean insertBatch(Collection entityList) { - return Db.saveBatch(entityList); + Db.saveBatch(entityList); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } /** * 批量更新 */ default boolean updateBatchById(Collection entityList) { - return Db.updateBatchById(entityList); + Db.updateBatchById(entityList); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } /** * 批量插入或更新 */ default boolean insertOrUpdateBatch(Collection entityList) { - return Db.saveOrUpdateBatch(entityList); + Db.saveOrUpdateBatch(entityList); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } /** * 批量插入(包含限制条数) */ default boolean insertBatch(Collection entityList, int batchSize) { - return Db.saveBatch(entityList, batchSize); + Db.saveBatch(entityList, batchSize); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } /** * 批量更新(包含限制条数) */ default boolean updateBatchById(Collection entityList, int batchSize) { - return Db.updateBatchById(entityList, batchSize); + Db.updateBatchById(entityList, batchSize); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } /** * 批量插入或更新(包含限制条数) */ default boolean insertOrUpdateBatch(Collection entityList, int batchSize) { - return Db.saveOrUpdateBatch(entityList, batchSize); - } - - /** - * 插入或更新(包含限制条数) - */ - default boolean insertOrUpdate(T entity) { - return Db.saveOrUpdate(entity); + Db.saveOrUpdateBatch(entityList, batchSize); + // 临时解决 新版本 mp 插入状态判断错误问题 + return true; } default V selectVoById(Serializable id) { diff --git a/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/handler/PlusWebSocketHandler.java b/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/handler/PlusWebSocketHandler.java index 759aecea06fcd964e930acdfc59a1a4b910572f0..8b1cc5dab2c26add753de4757466d9d1f3f83f88 100644 --- a/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/handler/PlusWebSocketHandler.java +++ b/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/handler/PlusWebSocketHandler.java @@ -1,5 +1,6 @@ package org.dromara.common.websocket.handler; +import cn.hutool.core.util.ObjectUtil; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.model.LoginUser; import org.dromara.common.websocket.dto.WebSocketMessageDto; @@ -8,6 +9,7 @@ import org.dromara.common.websocket.utils.WebSocketUtils; import org.springframework.web.socket.*; import org.springframework.web.socket.handler.AbstractWebSocketHandler; +import java.io.IOException; import java.util.List; import static org.dromara.common.websocket.constant.WebSocketConstants.LOGIN_USER_KEY; @@ -24,8 +26,13 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler { * 连接成功后 */ @Override - public void afterConnectionEstablished(WebSocketSession session) { + public void afterConnectionEstablished(WebSocketSession session) throws IOException { LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY); + if (ObjectUtil.isNull(loginUser)) { + session.close(CloseStatus.BAD_DATA); + log.info("[connect] invalid token received. sessionId: {}", session.getId()); + return; + } WebSocketSessionHolder.addSession(loginUser.getUserId(), session); log.info("[connect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType()); } @@ -94,6 +101,10 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler { @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { LoginUser loginUser = (LoginUser) session.getAttributes().get(LOGIN_USER_KEY); + if (ObjectUtil.isNull(loginUser)) { + log.info("[disconnect] invalid token received. sessionId: {}", session.getId()); + return; + } WebSocketSessionHolder.removeSession(loginUser.getUserId()); log.info("[disconnect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType()); } diff --git a/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/interceptor/PlusWebSocketInterceptor.java b/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/interceptor/PlusWebSocketInterceptor.java index 0abbbd3c95bfa43e1d74281faea8abe0f6f5dec6..1ad8ad665b60707cfc8b67fc970b4b7d72ab5382 100644 --- a/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/interceptor/PlusWebSocketInterceptor.java +++ b/ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/interceptor/PlusWebSocketInterceptor.java @@ -1,7 +1,11 @@ package org.dromara.common.websocket.interceptor; +import cn.dev33.satoken.exception.NotLoginException; +import cn.dev33.satoken.stp.StpUtil; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.model.LoginUser; +import org.dromara.common.core.utils.ServletUtils; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.satoken.utils.LoginHelper; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; @@ -31,7 +35,21 @@ public class PlusWebSocketInterceptor implements HandshakeInterceptor { */ @Override public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) { + // 检查是否登录 是否有token LoginUser loginUser = LoginHelper.getLoginUser(); + + // 解决 ws 不走 mvc 拦截器问题(cloud 版本不受影响) + // 检查 header 与 param 里的 clientid 与 token 里的是否一致 + String headerCid = ServletUtils.getRequest().getHeader(LoginHelper.CLIENT_KEY); + String paramCid = ServletUtils.getParameter(LoginHelper.CLIENT_KEY); + String clientId = StpUtil.getExtra(LoginHelper.CLIENT_KEY).toString(); + if (!StringUtils.equalsAny(clientId, headerCid, paramCid)) { + // token 无效 + throw NotLoginException.newInstance(StpUtil.getLoginType(), + "-100", "客户端ID与Token不匹配", + StpUtil.getTokenValue()); + } + attributes.put(LOGIN_USER_KEY, loginUser); return true; } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java index dd9849afca6fa91c203e38008c8c06bb3d00853a..20a0a5f3ac591a4032b0200907ed1d0b98061617 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/cmd/AttachmentCmd.java @@ -3,7 +3,6 @@ package org.dromara.workflow.flowable.cmd; import cn.hutool.core.collection.CollUtil; import org.dromara.common.core.domain.dto.OssDTO; 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.satoken.utils.LoginHelper; import org.flowable.common.engine.impl.interceptor.Command; @@ -28,17 +27,20 @@ public class AttachmentCmd implements Command { 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.taskId = taskId; this.processInstanceId = processInstanceId; + this.ossService = ossService; } @Override public Boolean execute(CommandContext commandContext) { try { if (StringUtils.isNotBlank(fileId)) { - List ossList = SpringUtils.getBean(OssService.class).selectByIds(fileId); + List ossList = ossService.selectByIds(fileId); if (CollUtil.isNotEmpty(ossList)) { for (OssDTO oss : ossList) { AttachmentEntityManager attachmentEntityManager = CommandContextUtil.getAttachmentEntityManager(); diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java index 17dba8c7ad8a7978b692812ef6b25da874eafbe3..69ae70a079131f1aeb078e915939d1abfea3a957 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/handler/FlowProcessEventHandler.java @@ -34,13 +34,15 @@ public class FlowProcessEventHandler { /** * 执行办理任务监听 * - * @param keyNode 流程定义key与流程节点标识(拼接方式:流程定义key_流程节点) - * @param taskId 任务id - * @param businessKey 业务id + * @param key 流程key + * @param taskDefinitionKey 审批节点key + * @param taskId 任务id + * @param businessKey 业务id */ - public void processTaskHandler(String keyNode, String taskId, String businessKey) { + public void processTaskHandler(String key, String taskDefinitionKey, String taskId, String businessKey) { ProcessTaskEvent processTaskEvent = new ProcessTaskEvent(); - processTaskEvent.setKeyNode(keyNode); + processTaskEvent.setKey(key); + processTaskEvent.setTaskDefinitionKey(taskDefinitionKey); processTaskEvent.setTaskId(taskId); processTaskEvent.setBusinessKey(businessKey); SpringUtils.context().publishEvent(processTaskEvent); diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/ITestLeaveService.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/ITestLeaveService.java index 5c95547a5e146896c51495f8d83704e30b97d917..943c919aefb884b12879fe8a21fb8280dd286b1b 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/ITestLeaveService.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/ITestLeaveService.java @@ -2,7 +2,6 @@ package org.dromara.workflow.service; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; -import org.dromara.workflow.domain.TestLeave; import org.dromara.workflow.domain.bo.TestLeaveBo; import org.dromara.workflow.domain.vo.TestLeaveVo; diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java index 7ea53d81aa0cfaf4b804841cb594dbbc60630607..d4f696b6c1a5d7ce95da4ae55b3947840eaecd89 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java @@ -10,6 +10,7 @@ import cn.hutool.json.JSONUtil; import com.alibaba.excel.util.StringUtils; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.image.PNGTranscoder; @@ -59,6 +60,7 @@ import java.util.zip.ZipOutputStream; * * @author may */ +@Slf4j @RequiredArgsConstructor @Service public class ActModelServiceImpl implements IActModelService { @@ -131,7 +133,7 @@ public class ActModelServiceImpl implements IActModelService { repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(xml)); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -157,6 +159,7 @@ public class ActModelServiceImpl implements IActModelService { modelVo.setDescription(model.getMetaInfo()); return modelVo; } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -181,6 +184,7 @@ public class ActModelServiceImpl implements IActModelService { model.setMetaInfo(modelBo.getDescription()); repositoryService.saveModel(model); } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } return true; @@ -230,7 +234,7 @@ public class ActModelServiceImpl implements IActModelService { repositoryService.addModelEditorSourceExtra(model.getId(), result); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -325,7 +329,7 @@ public class ActModelServiceImpl implements IActModelService { } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -370,7 +374,7 @@ public class ActModelServiceImpl implements IActModelService { // 刷出响应流 response.flushBuffer(); } catch (IOException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); } } @@ -417,6 +421,7 @@ public class ActModelServiceImpl implements IActModelService { } } } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } return true; diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java index c37e0d016d665c26866ce68f339661bd40017aae..6a17289a01e8491829491332c19ec4af2afdf2b7 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java @@ -9,6 +9,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; @@ -55,6 +56,7 @@ import java.util.zip.ZipInputStream; * * @author may */ +@Slf4j @RequiredArgsConstructor @Service public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService { @@ -208,7 +210,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer wfNodeConfigService.deleteByDefIds(processDefinitionIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -233,7 +235,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException("操作失败:" + e.getMessage()); } } @@ -262,6 +264,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer .migrateProcessInstances(fromProcessDefinitionId); return true; } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -291,7 +294,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java index dafd05994a6b4ee06b490c62f9071a6753618000..b833bcc285b91493e6d5f29a56d7859255cce57a 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessInstanceServiceImpl.java @@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; 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.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; @@ -77,6 +78,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService private final IWfTaskBackNodeService wfTaskBackNodeService; private final IWfNodeConfigService wfNodeConfigService; private final FlowProcessEventHandler flowProcessEventHandler; + private final UserService userService; @Value("${flowable.activity-font-name}") private String activityFontName; @@ -323,7 +325,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(), userService); if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) { 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.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration()); 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())) { historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } @@ -394,7 +396,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService } //设置人员id 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())) { actHistoryInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr)); } @@ -486,7 +488,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -521,7 +523,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -545,7 +547,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -595,7 +597,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false); return true; } catch (Exception e) { - e.printStackTrace(); + log.error("撤销失败:" + e.getMessage(), e); throw new ServiceException("撤销失败:" + e.getMessage()); } } @@ -675,7 +677,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService message = "您的【" + processInstance.getName() + "】单据还未审批,请您及时处理。"; } List 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) { throw new ServiceException(e.getMessage()); } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java index 523a77c49d47ab2ad247bda392ab550d9df16ac4..6fe0b4e657f50f46ea5c77870d83294938c85997 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java @@ -7,9 +7,11 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.dto.RoleDTO; import org.dromara.common.core.domain.dto.UserDTO; 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.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; @@ -64,6 +66,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.*; * * @author may */ +@Slf4j @RequiredArgsConstructor @Service public class ActTaskServiceImpl implements IActTaskService { @@ -78,8 +81,9 @@ public class ActTaskServiceImpl implements IActTaskService { private final ActHiTaskinstMapper actHiTaskinstMapper; private final IWfNodeConfigService wfNodeConfigService; private final IWfDefinitionConfigService wfDefinitionConfigService; - private final UserService userService; private final FlowProcessEventHandler flowProcessEventHandler; + private final UserService userService; + private final OssService ossService; /** * 启动任务 @@ -175,7 +179,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(), ossService); managementService.executeCommand(attachmentCmd); String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey()); //流程提交监听 @@ -184,8 +188,8 @@ public class ActTaskServiceImpl implements IActTaskService { } runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus()); //办理监听 - String keyNode = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey(); - flowProcessEventHandler.processTaskHandler(keyNode, task.getId(), processInstance.getBusinessKey()); + flowProcessEventHandler.processTaskHandler(processInstance.getProcessDefinitionKey(), task.getTaskDefinitionKey(), + task.getId(), processInstance.getBusinessKey()); //办理意见 taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage()); //办理任务 @@ -225,6 +229,7 @@ public class ActTaskServiceImpl implements IActTaskService { } return true; } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -239,7 +244,7 @@ public class ActTaskServiceImpl implements IActTaskService { */ @Async public void sendMessage(List list, String name, List messageType, String message) { - WorkflowUtils.sendMessage(list, name, messageType, message); + WorkflowUtils.sendMessage(list, name, messageType, message, userService); } /** @@ -273,7 +278,7 @@ public class ActTaskServiceImpl implements IActTaskService { List 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(), userService)); 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); @@ -338,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(), userService)); 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); @@ -473,7 +478,7 @@ public class ActTaskServiceImpl implements IActTaskService { taskService.complete(newTask.getId()); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -543,7 +548,7 @@ public class ActTaskServiceImpl implements IActTaskService { taskService.setAssignee(task.getId(), transmitBo.getUserId()); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -591,7 +596,7 @@ public class ActTaskServiceImpl implements IActTaskService { taskService.complete(newTask.getId()); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -641,7 +646,7 @@ public class ActTaskServiceImpl implements IActTaskService { taskService.complete(newTask.getId()); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -721,6 +726,7 @@ public class ActTaskServiceImpl implements IActTaskService { //删除驳回后的流程节点 wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId()); } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } return task.getProcessInstanceId(); @@ -741,6 +747,7 @@ public class ActTaskServiceImpl implements IActTaskService { taskService.setAssignee(task.getId(), userId); } } catch (Exception e) { + log.error("修改失败:" + e.getMessage(), e); throw new ServiceException("修改失败:" + e.getMessage()); } return true; diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index b938a989ac30fb38e13db070b41b03a731f8ea83..13a1bb20418d1dff993b69338a85df8dfec5cd8e 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -116,10 +116,12 @@ public class TestLeaveServiceImpl implements ITestLeaveService { /** * 总体流程监听(例如: 提交 退回 撤销 终止 作废等) + * 正常使用只需#processEvent.key=='leave1' + * 示例为了方便则使用startsWith匹配了全部示例key * * @param processEvent 参数 */ - @EventListener(condition = "#processEvent.key=='leave1'") + @EventListener(condition = "#processEvent.key.startsWith('leave')") public void processHandler(ProcessEvent processEvent) { log.info("当前任务执行了{}", processEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processEvent.getBusinessKey())); @@ -132,16 +134,19 @@ public class TestLeaveServiceImpl implements ITestLeaveService { /** * 执行办理任务监听 + * 示例:也可通过 @EventListener(condition = "#processTaskEvent.key=='leave1'")进行判断 + * 在方法中判断流程节点key + * if ("xxx".equals(processTaskEvent.getTaskDefinitionKey())) { + * //执行业务逻辑 + * } * * @param processTaskEvent 参数 */ - @EventListener(condition = "#processTaskEvent.keyNode=='leave1_Activity_14633hx'") + @EventListener(condition = "#processTaskEvent.key=='leave1' && #processTaskEvent.taskDefinitionKey=='Activity_14633hx'") public void processTaskHandler(ProcessTaskEvent processTaskEvent) { log.info("当前任务执行了{}", processTaskEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey())); testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus()); baseMapper.updateById(testLeave); } - - } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java index 0992f6f08b42a18ec514e683bd7d58d39889249b..55d9883f242205507259852ff935136a5f40e1cb 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WfTaskBackNodeServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.satoken.utils.LoginHelper; @@ -29,6 +30,7 @@ import static org.dromara.workflow.common.constant.FlowConstant.USER_TASK; * @author may * @date 2024-03-13 */ +@Slf4j @RequiredArgsConstructor @Service public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService { @@ -109,7 +111,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService { } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException("删除失败"); } } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/WorkflowUtils.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/WorkflowUtils.java index 385bd23a275d46155a7b6c2385eda3ae0d63b0f8..d7c44723ba2b26181d4f5729d061ffa0282280da 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/WorkflowUtils.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/WorkflowUtils.java @@ -125,8 +125,7 @@ public class WorkflowUtils { * * @param taskId 任务id */ - public static ParticipantVo getCurrentTaskParticipant(String taskId) { - UserService userService = SpringUtils.getBean(UserService.class); + public static ParticipantVo getCurrentTaskParticipant(String taskId, UserService userService) { ParticipantVo participantVo = new ParticipantVo(); List linksForTask = PROCESS_ENGINE.getHistoryService().getHistoricIdentityLinksForTask(taskId); Task task = QueryUtils.taskQuery().taskId(taskId).singleResult(); @@ -234,14 +233,13 @@ public class WorkflowUtils { * @param messageType 消息类型 * @param message 消息内容,为空则发送默认配置的消息内容 */ - public static void sendMessage(List list, String name, List messageType, String message) { - UserService userService = SpringUtils.getBean(UserService.class); + public static void sendMessage(List list, String name, List messageType, String message, UserService userService) { Set 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(), userService); if (CollUtil.isNotEmpty(taskParticipant.getGroupIds())) { List userIdList = userService.selectUserIdsByRoleIds(taskParticipant.getGroupIds()); if (CollUtil.isNotEmpty(userIdList)) {