diff --git a/blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/FlowEntity.java b/blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/FlowEntity.java
index a8cfa6ca..87551749 100644
--- a/blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/FlowEntity.java
+++ b/blade-service-api/blade-flow-api/src/main/java/org/springblade/flowable/core/entity/FlowEntity.java
@@ -17,7 +17,6 @@
package org.springblade.flowable.core.entity;
import com.baomidou.mybatisplus.annotation.TableField;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
@@ -31,8 +30,14 @@ import org.springblade.core.mp.base.BaseEntity;
@EqualsAndHashCode(callSuper = true)
public class FlowEntity extends BaseEntity {
- @JsonIgnore
@TableField(exist = false)
private BladeFlow flow;
+ public BladeFlow getFlow() {
+ if (flow == null) {
+ flow = new BladeFlow();
+ }
+ return flow;
+ }
+
}
diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml
index 09c21383..943d4406 100644
--- a/blade-service-api/blade-user-api/pom.xml
+++ b/blade-service-api/blade-user-api/pom.xml
@@ -14,4 +14,12 @@
${bladex.project.version}
jar
+
+
+ org.springblade
+ blade-starter-cache
+ ${bladex.tool.version}
+
+
+
diff --git a/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/cache/UserCache.java b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/cache/UserCache.java
new file mode 100644
index 00000000..f945af24
--- /dev/null
+++ b/blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/cache/UserCache.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.system.user.cache;
+
+import org.springblade.core.cache.utils.CacheUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+
+/**
+ * 系统缓存
+ *
+ * @author Chill
+ */
+public class UserCache {
+ private static final String USER_CACHE = "blade:user";
+ private static final String USER_CACHE_ID_ = "user:id";
+
+
+ private static IUserClient userClient;
+
+ static {
+ userClient = SpringUtil.getBean(IUserClient.class);
+ }
+
+ /**
+ * 获取用户名
+ *
+ * @param userId 用户id
+ * @return
+ */
+ public static User getUser(Integer userId) {
+ User user = CacheUtil.get(USER_CACHE, USER_CACHE_ID_ + userId, User.class);
+ if (Func.isEmpty(user)) {
+ R result = userClient.userInfoById(userId);
+ if (result.isSuccess()) {
+ user = result.getData();
+ if (Func.isNotEmpty(user)) {
+ CacheUtil.put(USER_CACHE, USER_CACHE_ID_ + userId, user);
+ }
+ }
+ }
+ return user;
+ }
+
+}
diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml
index 3598072e..1c6d7073 100644
--- a/blade-service/blade-desk/pom.xml
+++ b/blade-service/blade-desk/pom.xml
@@ -37,6 +37,11 @@
blade-dict-api
${bladex.project.version}
+
+ org.springblade
+ blade-user-api
+ ${bladex.project.version}
+
org.springblade
blade-flow-api
diff --git a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/LeaveController.java b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/LeaveController.java
index 6902e824..60c8dee4 100644
--- a/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/LeaveController.java
+++ b/blade-service/blade-desk/src/main/java/org/springblade/desk/controller/LeaveController.java
@@ -22,6 +22,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.desk.entity.ProcessLeave;
import org.springblade.desk.service.ILeaveService;
+import org.springblade.system.user.cache.UserCache;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@@ -46,6 +47,8 @@ public class LeaveController extends BladeController implements CacheNames {
@GetMapping("detail")
public R detail(Integer businessId) {
ProcessLeave detail = leaveService.getById(businessId);
+ String name = UserCache.getUser(detail.getCreateUser()).getName();
+ detail.getFlow().setAssigneeName(name);
return R.data(detail);
}
diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java
index 9a5a19fa..5459d556 100644
--- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java
+++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/service/impl/FlowServiceImpl.java
@@ -51,6 +51,7 @@ import org.springblade.flowable.engine.entity.FlowProcess;
import org.springblade.flowable.engine.mapper.FlowMapper;
import org.springblade.flowable.engine.service.FlowService;
import org.springblade.flowable.engine.utils.FlowCache;
+import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -138,7 +139,7 @@ public class FlowServiceImpl extends ServiceImpl implemen
if (processInstanceList.size() > 0) {
if (StringUtil.isNotBlank(processInstanceList.get(0).getStartUserId())) {
String userId = processInstanceList.get(0).getStartUserId();
- User user = FlowCache.getUser(Func.toInt(userId));
+ User user = UserCache.getUser(Func.toInt(userId));
if (user != null) {
flow.setAssignee(historicActivityInstance.getAssignee());
flow.setAssigneeName(user.getName());
@@ -148,7 +149,7 @@ public class FlowServiceImpl extends ServiceImpl implemen
}
// 获取任务执行人名称
if (StringUtil.isNotBlank(historicActivityInstance.getAssignee())) {
- User user = FlowCache.getUser(Func.toInt(historicActivityInstance.getAssignee()));
+ User user = UserCache.getUser(Func.toInt(historicActivityInstance.getAssignee()));
if (user != null) {
flow.setAssignee(historicActivityInstance.getAssignee());
flow.setAssigneeName(user.getName());
diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java
index e6c52c7b..87f0e5da 100644
--- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java
+++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/engine/utils/FlowCache.java
@@ -19,12 +19,9 @@ package org.springblade.flowable.engine.utils;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.ProcessDefinition;
import org.springblade.core.cache.utils.CacheUtil;
-import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringPool;
-import org.springblade.system.user.entity.User;
-import org.springblade.system.user.feign.IUserClient;
import org.springblade.system.utils.DictUtil;
/**
@@ -36,15 +33,10 @@ public class FlowCache {
private static final String FLOW_CACHE = "flow:process";
private static final String FLOW_CACHE_ID_ = "definition:id";
- private static final String USER_CACHE = "blade:user";
- private static final String USER_CACHE_ID_ = "user:id";
-
private static RepositoryService repositoryService;
- private static IUserClient userClient;
static {
repositoryService = SpringUtil.getBean(RepositoryService.class);
- userClient = SpringUtil.getBean(IUserClient.class);
}
/**
@@ -77,24 +69,4 @@ public class FlowCache {
return DictUtil.getValue(category.split(StringPool.UNDERSCORE)[0], Func.toInt(category.split(StringPool.UNDERSCORE)[1]));
}
- /**
- * 获取用户名
- *
- * @param userId 用户id
- * @return
- */
- public static User getUser(Integer userId) {
- User user = CacheUtil.get(USER_CACHE, USER_CACHE_ID_ + userId, User.class);
- if (Func.isEmpty(user)) {
- R result = userClient.userInfoById(userId);
- if (result.isSuccess()) {
- user = result.getData();
- if (Func.isNotEmpty(user)) {
- CacheUtil.put(USER_CACHE, USER_CACHE_ID_ + userId, user);
- }
- }
- }
- return user;
- }
-
}