mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-11-26 10:39:23 +08:00
Compare commits
92 Commits
aa76859a05
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65d677ac90 | ||
|
|
aca2b6d498 | ||
|
|
dd5f72cc99 | ||
|
|
b1d3d87360 | ||
|
|
e67fc5ebd4 | ||
|
|
6a2c74537e | ||
|
|
041e226059 | ||
|
|
0418b6c6ff | ||
|
|
c9272acce2 | ||
|
|
8d51adee10 | ||
|
|
6d4cc28dcd | ||
|
|
fc35a1469f | ||
|
|
f70a37c050 | ||
|
|
181f461984 | ||
|
|
75618347fa | ||
|
|
5a57e6b835 | ||
|
|
d1d47d2599 | ||
|
|
f35938a068 | ||
|
|
888c14615d | ||
|
|
fa6c9696f0 | ||
|
|
37038449ab | ||
|
|
9bff358afd | ||
|
|
d2a45156a2 | ||
|
|
9df0a8de1c | ||
|
|
5ea8d8c950 | ||
|
|
3318109044 | ||
|
|
aa1f89e253 | ||
|
|
35c77403d6 | ||
|
|
603fb7b92d | ||
|
|
6cf0c79433 | ||
|
|
3934e119d6 | ||
|
|
33a6a21fdf | ||
|
|
7800b1259f | ||
|
|
3623fc33d9 | ||
|
|
f8612eb52e | ||
|
|
8d32b0311a | ||
|
|
60bcd2d6e9 | ||
|
|
5ccb511064 | ||
|
|
78baf6497a | ||
|
|
0719e53f01 | ||
|
|
5f2c4205a5 | ||
|
|
2fe4c96706 | ||
|
|
5c634940c2 | ||
|
|
6036f8750b | ||
|
|
dbcd8f58eb | ||
|
|
8905e232e5 | ||
|
|
4f15158486 | ||
|
|
d2413abd5c | ||
|
|
f7ffadeaff | ||
|
|
f9eec856e7 | ||
|
|
62562650fe | ||
|
|
df171097c3 | ||
|
|
1977aabc9a | ||
|
|
483c4e6d0a | ||
|
|
f616c6931c | ||
|
|
26e10293f5 | ||
|
|
60e578f763 | ||
|
|
5cd4d8ca11 | ||
|
|
41a6230b6e | ||
|
|
effda4f6e8 | ||
|
|
af4c38e439 | ||
|
|
fafa8cd573 | ||
|
|
8909b8a7d4 | ||
|
|
8ae9bde731 | ||
|
|
a703cb2ad1 | ||
|
|
a918b880d6 | ||
|
|
e795e315eb | ||
|
|
81869cfeb3 | ||
|
|
fc6f61bc95 | ||
|
|
d44e45ad3b | ||
|
|
00ed9ddd10 | ||
|
|
341fc144a1 | ||
|
|
b6b1b2de18 | ||
|
|
c19f2b9e4e | ||
|
|
3a11f18656 | ||
|
|
5a43212ccc | ||
|
|
f4cfd1c913 | ||
|
|
26ce8f30c9 | ||
|
|
2258962770 | ||
|
|
655e84012c | ||
|
|
f683ef00b8 | ||
|
|
424b2ea164 | ||
|
|
7bb4838132 | ||
|
|
20516758ea | ||
|
|
2d5f84ebc2 | ||
|
|
6bc28e41de | ||
|
|
a4fb3fadaf | ||
|
|
cfa67fcd8c | ||
|
|
e5e8d305d2 | ||
|
|
9d0084409e | ||
|
|
ee02f46dfd | ||
|
|
25de0b3530 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -38,6 +38,7 @@ nbdist/
|
||||
######################################################################
|
||||
# Others
|
||||
*.log
|
||||
*.log.gz
|
||||
*.xml.versionsBackup
|
||||
*.swp
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="ruoyi/ruoyi-monitor-admin:5.4.1" />
|
||||
<option name="imageTag" value="ruoyi/ruoyi-monitor-admin:5.5.1" />
|
||||
<option name="buildOnly" value="true" />
|
||||
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-monitor-admin/Dockerfile" />
|
||||
</settings>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="ruoyi-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="ruoyi/ruoyi-server:5.4.1" />
|
||||
<option name="imageTag" value="ruoyi/ruoyi-server:5.5.1" />
|
||||
<option name="buildOnly" value="true" />
|
||||
<option name="sourceFilePath" value="ruoyi-admin/Dockerfile" />
|
||||
</settings>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="ruoyi-snailjob-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="ruoyi/ruoyi-snailjob-server:5.4.1" />
|
||||
<option name="imageTag" value="ruoyi/ruoyi-snailjob-server:5.5.1" />
|
||||
<option name="buildOnly" value="true" />
|
||||
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-snailjob-server/Dockerfile" />
|
||||
</settings>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[](https://gitee.com/dromara/RuoYi-Vue-Plus/blob/5.X/LICENSE)
|
||||
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
||||
<br>
|
||||
[](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
||||
[](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
|
||||
22
pom.xml
22
pom.xml
@@ -13,28 +13,28 @@
|
||||
<description>Dromara RuoYi-Vue-Plus多租户管理系统</description>
|
||||
|
||||
<properties>
|
||||
<revision>5.4.1</revision>
|
||||
<spring-boot.version>3.5.4</spring-boot.version>
|
||||
<revision>5.5.1</revision>
|
||||
<spring-boot.version>3.5.8</spring-boot.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>17</java.version>
|
||||
<mybatis.version>3.5.16</mybatis.version>
|
||||
<springdoc.version>2.8.11</springdoc.version>
|
||||
<springdoc.version>2.8.14</springdoc.version>
|
||||
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
||||
<fastexcel.version>1.3.0</fastexcel.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<satoken.version>1.44.0</satoken.version>
|
||||
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.5.14</mybatis-plus.version>
|
||||
<p6spy.version>3.9.1</p6spy.version>
|
||||
<hutool.version>5.8.40</hutool.version>
|
||||
<spring-boot-admin.version>3.5.1</spring-boot-admin.version>
|
||||
<redisson.version>3.51.0</redisson.version>
|
||||
<spring-boot-admin.version>3.5.5</spring-boot-admin.version>
|
||||
<redisson.version>3.52.0</redisson.version>
|
||||
<lock4j.version>2.2.7</lock4j.version>
|
||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||
<snailjob.version>1.7.2</snailjob.version>
|
||||
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>
|
||||
<snailjob.version>1.8.0</snailjob.version>
|
||||
<mapstruct-plus.version>1.5.0</mapstruct-plus.version>
|
||||
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
||||
<lombok.version>1.18.38</lombok.version>
|
||||
<lombok.version>1.18.40</lombok.version>
|
||||
<bouncycastle.version>1.80</bouncycastle.version>
|
||||
<justauth.version>1.16.7</justauth.version>
|
||||
<!-- 离线IP地址定位库 -->
|
||||
@@ -42,13 +42,13 @@
|
||||
<!-- OSS 配置 -->
|
||||
<aws.sdk.version>2.28.22</aws.sdk.version>
|
||||
<!-- SMS 配置 -->
|
||||
<sms4j.version>3.3.4</sms4j.version>
|
||||
<sms4j.version>3.3.5</sms4j.version>
|
||||
<!-- 限制框架中的fastjson版本 -->
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<!-- 面向运行时的D-ORM依赖 -->
|
||||
<anyline.version>8.7.2-20250603</anyline.version>
|
||||
<!-- 工作流配置 -->
|
||||
<warm-flow.version>1.8.1</warm-flow.version>
|
||||
<warm-flow.version>1.8.3</warm-flow.version>
|
||||
|
||||
<!-- 插件版本 -->
|
||||
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
|
||||
|
||||
@@ -259,5 +259,7 @@ warm-flow:
|
||||
ui: true
|
||||
# 是否显示流程图顶部文字
|
||||
top-text-show: true
|
||||
# 是否渲染节点悬浮提示,默认true
|
||||
node-tooltip: true
|
||||
# 默认Authorization,如果有多个token,用逗号分隔
|
||||
token-name: ${sa-token.token-name},clientid
|
||||
|
||||
Binary file not shown.
@@ -38,7 +38,7 @@
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
@@ -60,7 +60,7 @@
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<revision>5.4.1</revision>
|
||||
<revision>5.5.1</revision>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -5,15 +5,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.dromara.common.core.config.properties.ThreadPoolProperties;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.Threads;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 线程池配置
|
||||
@@ -50,7 +47,7 @@ public class ThreadPoolConfig {
|
||||
@Override
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
super.afterExecute(r, t);
|
||||
Threads.printException(r, t);
|
||||
printException(r, t);
|
||||
}
|
||||
};
|
||||
this.scheduledExecutorService = scheduledThreadPoolExecutor;
|
||||
@@ -59,15 +56,57 @@ public class ThreadPoolConfig {
|
||||
|
||||
/**
|
||||
* 销毁事件
|
||||
* 停止线程池
|
||||
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
||||
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
|
||||
* 如果仍然超時,則強制退出.
|
||||
* 另对在shutdown时线程本身被调用中断做了处理.
|
||||
*/
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
try {
|
||||
log.info("====关闭后台任务任务线程池====");
|
||||
Threads.shutdownAndAwaitTermination(scheduledExecutorService);
|
||||
ScheduledExecutorService pool = scheduledExecutorService;
|
||||
if (pool != null && !pool.isShutdown()) {
|
||||
pool.shutdown();
|
||||
try {
|
||||
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
||||
pool.shutdownNow();
|
||||
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
||||
log.info("Pool did not terminate");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
pool.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印线程异常信息
|
||||
*/
|
||||
public static void printException(Runnable r, Throwable t) {
|
||||
if (t == null && r instanceof Future<?>) {
|
||||
try {
|
||||
Future<?> future = (Future<?>) r;
|
||||
if (future.isDone()) {
|
||||
future.get();
|
||||
}
|
||||
} catch (CancellationException ce) {
|
||||
t = ce;
|
||||
} catch (ExecutionException ee) {
|
||||
t = ee.getCause();
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if (t != null) {
|
||||
log.error(t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,5 +72,10 @@ public interface Constants {
|
||||
*/
|
||||
Long TOP_PARENT_ID = 0L;
|
||||
|
||||
/**
|
||||
* 加密头
|
||||
*/
|
||||
String ENCRYPT_HEADER = "ENC_";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,8 @@ public class CompleteTaskDTO implements Serializable {
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
if (variables == null) {
|
||||
return new HashMap<>(16);
|
||||
variables = new HashMap<>(16);
|
||||
return variables;
|
||||
}
|
||||
variables.entrySet().removeIf(entry -> Objects.isNull(entry.getValue()));
|
||||
return variables;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.dromara.common.core.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展对象
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
@Data
|
||||
public class FlowInstanceBizExtDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.common.core.domain.dto;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -40,6 +41,11 @@ public class StartProcessDTO implements Serializable {
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 流程业务扩展信息
|
||||
*/
|
||||
private FlowInstanceBizExtDTO bizExt;
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
if (variables == null) {
|
||||
return new HashMap<>(16);
|
||||
@@ -47,4 +53,11 @@ public class StartProcessDTO implements Serializable {
|
||||
variables.entrySet().removeIf(entry -> Objects.isNull(entry.getValue()));
|
||||
return variables;
|
||||
}
|
||||
|
||||
public FlowInstanceBizExtDTO getBizExt() {
|
||||
if (ObjectUtil.isNull(bizExt)) {
|
||||
bizExt = new FlowInstanceBizExtDTO();
|
||||
}
|
||||
return bizExt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package org.dromara.common.core.service;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用 参数配置服务
|
||||
*
|
||||
@@ -15,4 +21,80 @@ public interface ConfigService {
|
||||
*/
|
||||
String getConfigValue(String configKey);
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取布尔值
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Boolean 值
|
||||
*/
|
||||
default Boolean getConfigBool(String configKey) {
|
||||
return Convert.toBool(getConfigValue(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取整数值
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Integer 值
|
||||
*/
|
||||
default Integer getConfigInt(String configKey) {
|
||||
return Convert.toInt(getConfigValue(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取长整型值
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Long 值
|
||||
*/
|
||||
default Long getConfigLong(String configKey) {
|
||||
return Convert.toLong(getConfigValue(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取 BigDecimal 值
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return BigDecimal 值
|
||||
*/
|
||||
default BigDecimal getConfigDecimal(String configKey) {
|
||||
return Convert.toBigDecimal(getConfigValue(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取 Map 类型的配置
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Dict 对象,如果配置为空或无法解析,返回空 Dict
|
||||
*/
|
||||
Dict getConfigMap(String configKey);
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取 Map 类型的配置列表
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Dict 列表,如果配置为空或无法解析,返回空列表
|
||||
*/
|
||||
List<Dict> getConfigArrayMap(String configKey);
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取指定类型的配置对象
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @param clazz 目标对象类型
|
||||
* @param <T> 目标对象泛型
|
||||
* @return 对象实例,如果配置为空或无法解析,返回 null
|
||||
*/
|
||||
<T> T getConfigObject(String configKey, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取指定类型的配置列表
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @param clazz 目标元素类型
|
||||
* @param <T> 元素类型泛型
|
||||
* @return 指定类型列表,如果配置为空或无法解析,返回空列表
|
||||
*/
|
||||
<T> List<T> getConfigArray(String configKey, Class<T> clazz);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface WorkflowService {
|
||||
* @param businessIds 业务id
|
||||
* @return 结果
|
||||
*/
|
||||
boolean deleteInstance(List<Long> businessIds);
|
||||
boolean deleteInstance(List<String> businessIds);
|
||||
|
||||
/**
|
||||
* 获取当前流程状态
|
||||
|
||||
@@ -30,8 +30,10 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||
return collection.stream().filter(function).collect(Collectors.toList());
|
||||
return collection.stream()
|
||||
.filter(function)
|
||||
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,13 +41,26 @@ public class StreamUtils {
|
||||
*
|
||||
* @param collection 需要查询的集合
|
||||
* @param function 过滤方法
|
||||
* @return 找到符合条件的第一个元素,没有则返回null
|
||||
* @return 找到符合条件的第一个元素,没有则返回 Optional.empty()
|
||||
*/
|
||||
public static <E> E findFirst(Collection<E> collection, Predicate<E> function) {
|
||||
public static <E> Optional<E> findFirst(Collection<E> collection, Predicate<E> function) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
return collection.stream().filter(function).findFirst().orElse(null);
|
||||
return collection.stream()
|
||||
.filter(function)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到流中满足条件的第一个元素值
|
||||
*
|
||||
* @param collection 需要查询的集合
|
||||
* @param function 过滤方法
|
||||
* @return 找到符合条件的第一个元素,没有则返回 null
|
||||
*/
|
||||
public static <E> E findFirstValue(Collection<E> collection, Predicate<E> function) {
|
||||
return findFirst(collection,function).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,13 +68,26 @@ public class StreamUtils {
|
||||
*
|
||||
* @param collection 需要查询的集合
|
||||
* @param function 过滤方法
|
||||
* @return 找到符合条件的任意一个元素,没有则返回null
|
||||
* @return 找到符合条件的任意一个元素,没有则返回 Optional.empty()
|
||||
*/
|
||||
public static <E> Optional<E> findAny(Collection<E> collection, Predicate<E> function) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return collection.stream().filter(function).findAny();
|
||||
return collection.stream()
|
||||
.filter(function)
|
||||
.findAny();
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到流中任意一个满足条件的元素值
|
||||
*
|
||||
* @param collection 需要查询的集合
|
||||
* @param function 过滤方法
|
||||
* @return 找到符合条件的任意一个元素,没有则返回null
|
||||
*/
|
||||
public static <E> E findAnyValue(Collection<E> collection, Predicate<E> function) {
|
||||
return findAny(collection,function).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +113,10 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return collection.stream().map(function).filter(Objects::nonNull).collect(Collectors.joining(delimiter));
|
||||
return collection.stream()
|
||||
.map(function)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.joining(delimiter));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +130,11 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||
return collection.stream().filter(Objects::nonNull).sorted(comparing).collect(Collectors.toList());
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.sorted(comparing)
|
||||
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +151,9 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return collection.stream().filter(Objects::nonNull).collect(Collectors.toMap(key, Function.identity(), (l, r) -> l));
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(key, Function.identity(), (l, r) -> l));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +172,25 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return collection.stream().filter(Objects::nonNull).collect(Collectors.toMap(key, value, (l, r) -> l));
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(key, value, (l, r) -> l));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 map 中的数据作为新 Map 的 value ,key 不变
|
||||
* @param map 需要处理的map
|
||||
* @param take 取值函数
|
||||
* @param <K> map中的key类型
|
||||
* @param <E> map中的value类型
|
||||
* @param <V> 新map中的value类型
|
||||
* @return 新的map
|
||||
*/
|
||||
public static <K, E, V> Map<K, V> toMap(Map<K, E> map, BiFunction<K, E, V> take) {
|
||||
if (CollUtil.isEmpty(map)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return toMap(map.entrySet(), Map.Entry::getKey, entry -> take.apply(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,8 +207,8 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return collection
|
||||
.stream().filter(Objects::nonNull)
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(key, LinkedHashMap::new, Collectors.toList()));
|
||||
}
|
||||
|
||||
@@ -174,8 +228,8 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return collection
|
||||
.stream().filter(Objects::nonNull)
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.groupingBy(key2, LinkedHashMap::new, Collectors.toList())));
|
||||
}
|
||||
|
||||
@@ -192,11 +246,11 @@ public class StreamUtils {
|
||||
* @return 分类后的map
|
||||
*/
|
||||
public static <E, T, U> Map<T, Map<U, E>> group2Map(Collection<E> collection, Function<E, T> key1, Function<E, U> key2) {
|
||||
if (CollUtil.isEmpty(collection) || key1 == null || key2 == null) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
return collection
|
||||
.stream().filter(Objects::nonNull)
|
||||
return collection.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.toMap(key2, Function.identity(), (l, r) -> l)));
|
||||
}
|
||||
|
||||
@@ -214,8 +268,7 @@ public class StreamUtils {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return collection
|
||||
.stream()
|
||||
return collection.stream()
|
||||
.map(function)
|
||||
.filter(Objects::nonNull)
|
||||
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
|
||||
@@ -233,11 +286,10 @@ public class StreamUtils {
|
||||
* @return 转化后的Set
|
||||
*/
|
||||
public static <E, T> Set<T> toSet(Collection<E> collection, Function<E, T> function) {
|
||||
if (CollUtil.isEmpty(collection) || function == null) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return CollUtil.newHashSet();
|
||||
}
|
||||
return collection
|
||||
.stream()
|
||||
return collection.stream()
|
||||
.map(function)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
@@ -257,26 +309,20 @@ public class StreamUtils {
|
||||
* @return 合并后的map
|
||||
*/
|
||||
public static <K, X, Y, V> Map<K, V> merge(Map<K, X> map1, Map<K, Y> map2, BiFunction<X, Y, V> merge) {
|
||||
if (MapUtil.isEmpty(map1) && MapUtil.isEmpty(map2)) {
|
||||
if (CollUtil.isEmpty(map1) && CollUtil.isEmpty(map2)) {
|
||||
// 如果两个 map 都为空,则直接返回空的 map
|
||||
return MapUtil.newHashMap();
|
||||
} else if (MapUtil.isEmpty(map1)) {
|
||||
map1 = MapUtil.newHashMap();
|
||||
} else if (MapUtil.isEmpty(map2)) {
|
||||
map2 = MapUtil.newHashMap();
|
||||
} else if (CollUtil.isEmpty(map1)) {
|
||||
// 如果 map1 为空,则直接处理返回 map2
|
||||
return toMap(map2.entrySet(), Map.Entry::getKey, entry -> merge.apply(null, entry.getValue()));
|
||||
} else if (CollUtil.isEmpty(map2)) {
|
||||
// 如果 map2 为空,则直接处理返回 map1
|
||||
return toMap(map1.entrySet(), Map.Entry::getKey, entry -> merge.apply(entry.getValue(), null));
|
||||
}
|
||||
Set<K> key = new HashSet<>();
|
||||
key.addAll(map1.keySet());
|
||||
key.addAll(map2.keySet());
|
||||
Map<K, V> map = new HashMap<>();
|
||||
for (K t : key) {
|
||||
X x = map1.get(t);
|
||||
Y y = map2.get(t);
|
||||
V z = merge.apply(x, y);
|
||||
if (z != null) {
|
||||
map.put(t, z);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
Set<K> keySet = new HashSet<>();
|
||||
keySet.addAll(map1.keySet());
|
||||
keySet.addAll(map2.keySet());
|
||||
return toMap(keySet, key -> key, key -> merge.apply(map1.get(key), map2.get(key)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 线程相关工具类.
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class Threads {
|
||||
/**
|
||||
* 停止线程池
|
||||
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
|
||||
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
|
||||
* 如果仍然超時,則強制退出.
|
||||
* 另对在shutdown时线程本身被调用中断做了处理.
|
||||
*/
|
||||
public static void shutdownAndAwaitTermination(ExecutorService pool) {
|
||||
if (pool != null && !pool.isShutdown()) {
|
||||
pool.shutdown();
|
||||
try {
|
||||
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
||||
pool.shutdownNow();
|
||||
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
|
||||
log.info("Pool did not terminate");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
pool.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印线程异常信息
|
||||
*/
|
||||
public static void printException(Runnable r, Throwable t) {
|
||||
if (t == null && r instanceof Future<?>) {
|
||||
try {
|
||||
Future<?> future = (Future<?>) r;
|
||||
if (future.isDone()) {
|
||||
future.get();
|
||||
}
|
||||
} catch (CancellationException ce) {
|
||||
t = ce;
|
||||
} catch (ExecutionException ee) {
|
||||
t = ee.getCause();
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if (t != null) {
|
||||
log.error(t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.io.Resources;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.encrypt.annotation.EncryptField;
|
||||
@@ -92,8 +93,12 @@ public class EncryptorManager {
|
||||
* @param encryptContext 加密相关的配置信息
|
||||
*/
|
||||
public String encrypt(String value, EncryptContext encryptContext) {
|
||||
if (StringUtils.startsWith(value, Constants.ENCRYPT_HEADER)) {
|
||||
return value;
|
||||
}
|
||||
IEncryptor encryptor = this.registAndGetEncryptor(encryptContext);
|
||||
return encryptor.encrypt(value, encryptContext.getEncode());
|
||||
String encrypt = encryptor.encrypt(value, encryptContext.getEncode());
|
||||
return Constants.ENCRYPT_HEADER + encrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +108,12 @@ public class EncryptorManager {
|
||||
* @param encryptContext 加密相关的配置信息
|
||||
*/
|
||||
public String decrypt(String value, EncryptContext encryptContext) {
|
||||
if (!StringUtils.startsWith(value, Constants.ENCRYPT_HEADER)) {
|
||||
return value;
|
||||
}
|
||||
IEncryptor encryptor = this.registAndGetEncryptor(encryptContext);
|
||||
return encryptor.decrypt(value);
|
||||
String str = StringUtils.removeStart(value, Constants.ENCRYPT_HEADER);
|
||||
return encryptor.decrypt(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.dromara.common.excel.annotation;
|
||||
|
||||
import org.dromara.common.excel.core.ExcelOptionsProvider;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Excel动态下拉选项注解
|
||||
*
|
||||
* @author Angus
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface ExcelDynamicOptions {
|
||||
|
||||
/**
|
||||
* 提供者类全限定名
|
||||
* <p>
|
||||
* {@link org.dromara.common.excel.core.ExcelOptionsProvider} 接口实现类 class
|
||||
*/
|
||||
Class<? extends ExcelOptionsProvider> providerClass();
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ExcelBigNumberConvert implements Converter<Long> {
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.annotation.ExcelDynamicOptions;
|
||||
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -117,6 +118,15 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
||||
ExcelEnumFormat format = field.getDeclaredAnnotation(ExcelEnumFormat.class);
|
||||
List<Object> values = EnumUtil.getFieldValues(format.enumClass(), format.textField());
|
||||
options = StreamUtils.toList(values, Convert::toStr);
|
||||
} else if (field.isAnnotationPresent(ExcelDynamicOptions.class)) {
|
||||
// 处理动态下拉选项
|
||||
ExcelDynamicOptions dynamicOptions = field.getDeclaredAnnotation(ExcelDynamicOptions.class);
|
||||
// 获取提供者实例
|
||||
ExcelOptionsProvider provider = SpringUtils.getBean(dynamicOptions.providerClass());
|
||||
Set<String> providerOptions = provider.getOptions();
|
||||
if (CollUtil.isNotEmpty(providerOptions)) {
|
||||
options = new ArrayList<>(providerOptions);
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(options)) {
|
||||
// 仅当下拉可选项不为空时执行
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.dromara.common.excel.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Excel下拉选项数据提供接口
|
||||
*
|
||||
* @author Angus
|
||||
*/
|
||||
public interface ExcelOptionsProvider {
|
||||
|
||||
/**
|
||||
* 获取下拉选项数据
|
||||
*
|
||||
* @return 下拉选项列表
|
||||
*/
|
||||
Set<String> getOptions();
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
@@ -203,6 +204,44 @@ public class ExcelUtil {
|
||||
builder.doWrite(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param headType 带Excel注解的类型
|
||||
* @param os 输出流
|
||||
* @param options Excel下拉可选项
|
||||
* @param consumer 导出助手消费函数
|
||||
*/
|
||||
public static <T> void exportExcel(Class<T> headType, OutputStream os, List<DropDownOptions> options, Consumer<ExcelWriterWrapper<T>> consumer) {
|
||||
try (ExcelWriter writer = FastExcel.write(os, headType)
|
||||
.autoCloseStream(false)
|
||||
// 自动适配
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
// 大数值自动转换 防止失真
|
||||
.registerConverter(new ExcelBigNumberConvert())
|
||||
// 批注必填项处理
|
||||
.registerWriteHandler(new DataWriteHandler(headType))
|
||||
// 添加下拉框操作
|
||||
.registerWriteHandler(new ExcelDownHandler(options))
|
||||
.build()) {
|
||||
// 执行消费函数
|
||||
consumer.accept(ExcelWriterWrapper.of(writer));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param headType 带Excel注解的类型
|
||||
* @param os 输出流
|
||||
* @param consumer 导出助手消费函数
|
||||
*/
|
||||
public static <T> void exportExcel(Class<T> headType, OutputStream os, Consumer<ExcelWriterWrapper<T>> consumer) {
|
||||
exportExcel(headType, os, null, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单表多数据模板导出 模板格式为 {.属性}
|
||||
*
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.dromara.common.excel.utils;
|
||||
|
||||
import cn.idev.excel.ExcelWriter;
|
||||
import cn.idev.excel.FastExcel;
|
||||
import cn.idev.excel.context.WriteContext;
|
||||
import cn.idev.excel.write.builder.ExcelWriterSheetBuilder;
|
||||
import cn.idev.excel.write.builder.ExcelWriterTableBuilder;
|
||||
import cn.idev.excel.write.metadata.WriteSheet;
|
||||
import cn.idev.excel.write.metadata.WriteTable;
|
||||
import cn.idev.excel.write.metadata.fill.FillConfig;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* ExcelWriterWrapper Excel写出包装器
|
||||
* <br>
|
||||
* 提供了一组与 ExcelWriter 一一对应的写出方法,避免直接提供 ExcelWriter 而导致的一些不可控问题(比如提前关闭了IO流等)
|
||||
*
|
||||
* @author 秋辞未寒
|
||||
* @see ExcelWriter
|
||||
*/
|
||||
public record ExcelWriterWrapper<T>(ExcelWriter excelWriter) {
|
||||
|
||||
public void write(Collection<T> data, WriteSheet writeSheet) {
|
||||
excelWriter.write(data, writeSheet);
|
||||
}
|
||||
|
||||
public void write(Supplier<Collection<T>> supplier, WriteSheet writeSheet) {
|
||||
excelWriter.write(supplier.get(), writeSheet);
|
||||
}
|
||||
|
||||
public void write(Collection<T> data, WriteSheet writeSheet, WriteTable writeTable) {
|
||||
excelWriter.write(data, writeSheet, writeTable);
|
||||
}
|
||||
|
||||
public void write(Supplier<Collection<T>> supplier, WriteSheet writeSheet, WriteTable writeTable) {
|
||||
excelWriter.write(supplier.get(), writeSheet, writeTable);
|
||||
}
|
||||
|
||||
public void fill(Object data, WriteSheet writeSheet) {
|
||||
excelWriter.fill(data, writeSheet);
|
||||
}
|
||||
|
||||
public void fill(Object data, FillConfig fillConfig, WriteSheet writeSheet) {
|
||||
excelWriter.fill(data, fillConfig, writeSheet);
|
||||
}
|
||||
|
||||
public void fill(Supplier<Object> supplier, WriteSheet writeSheet) {
|
||||
excelWriter.fill(supplier, writeSheet);
|
||||
}
|
||||
|
||||
public void fill(Supplier<Object> supplier, FillConfig fillConfig, WriteSheet writeSheet) {
|
||||
excelWriter.fill(supplier, fillConfig, writeSheet);
|
||||
}
|
||||
|
||||
public WriteContext writeContext() {
|
||||
return excelWriter.writeContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个 ExcelWriterWrapper
|
||||
*
|
||||
* @param excelWriter ExcelWriter
|
||||
* @return ExcelWriterWrapper
|
||||
*/
|
||||
public static <T> ExcelWriterWrapper<T> of(ExcelWriter excelWriter) {
|
||||
return new ExcelWriterWrapper<>(excelWriter);
|
||||
}
|
||||
|
||||
// -------------------------------- sheet start
|
||||
|
||||
public static WriteSheet buildSheet(Integer sheetNo, String sheetName) {
|
||||
return sheetBuilder(sheetNo, sheetName).build();
|
||||
}
|
||||
|
||||
public static WriteSheet buildSheet(Integer sheetNo) {
|
||||
return sheetBuilder(sheetNo).build();
|
||||
}
|
||||
|
||||
public static WriteSheet buildSheet(String sheetName) {
|
||||
return sheetBuilder(sheetName).build();
|
||||
}
|
||||
|
||||
public static WriteSheet buildSheet() {
|
||||
return sheetBuilder().build();
|
||||
}
|
||||
|
||||
public static ExcelWriterSheetBuilder sheetBuilder(Integer sheetNo, String sheetName) {
|
||||
return FastExcel.writerSheet(sheetNo, sheetName);
|
||||
}
|
||||
|
||||
public static ExcelWriterSheetBuilder sheetBuilder(Integer sheetNo) {
|
||||
return FastExcel.writerSheet(sheetNo);
|
||||
}
|
||||
|
||||
public static ExcelWriterSheetBuilder sheetBuilder(String sheetName) {
|
||||
return FastExcel.writerSheet(sheetName);
|
||||
}
|
||||
|
||||
public static ExcelWriterSheetBuilder sheetBuilder() {
|
||||
return FastExcel.writerSheet();
|
||||
}
|
||||
|
||||
// -------------------------------- sheet end
|
||||
|
||||
// -------------------------------- table start
|
||||
|
||||
public static WriteTable buildTable(Integer tableNo) {
|
||||
return tableBuilder(tableNo).build();
|
||||
}
|
||||
|
||||
public static WriteTable buildTable() {
|
||||
return tableBuilder().build();
|
||||
}
|
||||
|
||||
public static ExcelWriterTableBuilder tableBuilder(Integer tableNo) {
|
||||
return FastExcel.writerTable(tableNo);
|
||||
}
|
||||
|
||||
public static ExcelWriterTableBuilder tableBuilder() {
|
||||
return FastExcel.writerTable();
|
||||
}
|
||||
|
||||
// -------------------------------- table end
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.common.json.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
@@ -28,20 +29,24 @@ import java.util.TimeZone;
|
||||
@AutoConfiguration(before = JacksonAutoConfiguration.class)
|
||||
public class JacksonConfig {
|
||||
|
||||
@Bean
|
||||
public Module registerJavaTimeModule() {
|
||||
// 全局配置序列化返回 JSON 处理
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
||||
javaTimeModule.addDeserializer(Date.class, new CustomDateDeserializer());
|
||||
return javaTimeModule;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||
return builder -> {
|
||||
// 全局配置序列化返回 JSON 处理
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
||||
javaTimeModule.addDeserializer(Date.class, new CustomDateDeserializer());
|
||||
builder.modules(javaTimeModule);
|
||||
builder.timeZone(TimeZone.getDefault());
|
||||
log.info("初始化 jackson 配置");
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import lombok.AccessLevel;
|
||||
@@ -167,4 +168,58 @@ public class JsonUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为合法 JSON(对象或数组)
|
||||
*
|
||||
* @param str 待校验字符串
|
||||
* @return true = 合法 JSON,false = 非法或空
|
||||
*/
|
||||
public static boolean isJson(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
OBJECT_MAPPER.readTree(str);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 JSON 对象({})
|
||||
*
|
||||
* @param str 待校验字符串
|
||||
* @return true = JSON 对象
|
||||
*/
|
||||
public static boolean isJsonObject(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
JsonNode node = OBJECT_MAPPER.readTree(str);
|
||||
return node.isObject();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 JSON 数组([])
|
||||
*
|
||||
* @param str 待校验字符串
|
||||
* @return true = JSON 数组
|
||||
*/
|
||||
public static boolean isJsonArray(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
JsonNode node = OBJECT_MAPPER.readTree(str);
|
||||
return node.isArray();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.dromara.common.json.validate;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* JSON 格式校验注解
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Constraint(validatedBy = JsonPatternValidator.class)
|
||||
public @interface JsonPattern {
|
||||
|
||||
/**
|
||||
* 限制 JSON 类型,默认为 {@link JsonType#ANY},即对象或数组都允许
|
||||
*/
|
||||
JsonType type() default JsonType.ANY;
|
||||
|
||||
/**
|
||||
* 校验失败时的提示消息
|
||||
*/
|
||||
String message() default "不是有效的 JSON 格式";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.dromara.common.json.validate;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
|
||||
/**
|
||||
* JSON 格式校验器
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
public class JsonPatternValidator implements ConstraintValidator<JsonPattern, String> {
|
||||
|
||||
/**
|
||||
* 注解中指定的 JSON 类型枚举
|
||||
*/
|
||||
private JsonType jsonType;
|
||||
|
||||
/**
|
||||
* 初始化校验器,从注解中提取 JSON 类型
|
||||
*
|
||||
* @param annotation 注解实例
|
||||
*/
|
||||
@Override
|
||||
public void initialize(JsonPattern annotation) {
|
||||
this.jsonType = annotation.type();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验字符串是否为合法 JSON
|
||||
*
|
||||
* @param value 待校验字符串
|
||||
* @param context 校验上下文,可用于自定义错误信息
|
||||
* @return true = 合法 JSON 或为空,false = 非法 JSON
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
// 交给 @NotBlank 或 @NotNull 控制是否允许为空
|
||||
return true;
|
||||
}
|
||||
// 根据 JSON 类型进行不同的校验
|
||||
return switch (jsonType) {
|
||||
case ANY -> JsonUtils.isJson(value);
|
||||
case OBJECT -> JsonUtils.isJsonObject(value);
|
||||
case ARRAY -> JsonUtils.isJsonArray(value);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.dromara.common.json.validate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* JSON 类型枚举
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum JsonType {
|
||||
|
||||
/**
|
||||
* JSON 对象,例如 {"a":1}
|
||||
*/
|
||||
OBJECT,
|
||||
|
||||
/**
|
||||
* JSON 数组,例如 [1,2,3]
|
||||
*/
|
||||
ARRAY,
|
||||
|
||||
/**
|
||||
* 任意 JSON 类型,对象或数组都可以
|
||||
*/
|
||||
ANY
|
||||
|
||||
}
|
||||
@@ -6,11 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
import org.apache.ibatis.logging.LogFactory;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
@@ -132,7 +130,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的单个VO对象
|
||||
*/
|
||||
default V selectVoById(Serializable id) {
|
||||
return this.selectVoById(id, this.currentVoClass());
|
||||
return selectVoById(id, this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +156,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的VO对象列表
|
||||
*/
|
||||
default List<V> selectVoByIds(Collection<? extends Serializable> idList) {
|
||||
return this.selectVoByIds(idList, this.currentVoClass());
|
||||
return selectVoByIds(idList, this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +182,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的VO对象列表
|
||||
*/
|
||||
default List<V> selectVoByMap(Map<String, Object> map) {
|
||||
return this.selectVoByMap(map, this.currentVoClass());
|
||||
return selectVoByMap(map, this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +208,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的单个VO对象
|
||||
*/
|
||||
default V selectVoOne(Wrapper<T> wrapper) {
|
||||
return this.selectVoOne(wrapper, this.currentVoClass());
|
||||
return selectVoOne(wrapper, this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,12 +219,11 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的单个VO对象
|
||||
*/
|
||||
default V selectVoOne(Wrapper<T> wrapper, boolean throwEx) {
|
||||
return this.selectVoOne(wrapper, this.currentVoClass(), throwEx);
|
||||
return selectVoOne(wrapper, this.currentVoClass(), throwEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询单个VO对象,并指定返回的VO对象的类型(自动拼接 limit 1)
|
||||
* 注意不要再自己添加 limit 1 做限制了
|
||||
* 根据条件查询单个VO对象,并指定返回的VO对象的类型
|
||||
*
|
||||
* @param wrapper 查询条件Wrapper
|
||||
* @param voClass 返回的VO对象的Class对象
|
||||
@@ -234,12 +231,11 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的单个VO对象,经过类型转换为指定的VO类后返回
|
||||
*/
|
||||
default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) {
|
||||
return this.selectVoOne(wrapper, voClass, true);
|
||||
return selectVoOne(wrapper, voClass, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询单个实体对象,并将其转换为指定的VO对象(自动拼接 limit 1)
|
||||
* 注意不要再自己添加 limit 1 做限制了
|
||||
* 根据条件查询单个实体对象,并将其转换为指定的VO对象
|
||||
*
|
||||
* @param wrapper 查询条件Wrapper
|
||||
* @param voClass 要转换的VO类的Class对象
|
||||
@@ -255,33 +251,13 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
return MapstructUtils.convert(obj, voClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询单条记录(自动拼接 limit 1 限制返回 1 条数据,不依赖 {@code throwEx} 参数)
|
||||
* 注意不要再自己添加 limit 1 做限制了
|
||||
* <p>
|
||||
* <strong>注意:</strong>
|
||||
* 1. 使用 {@code Page<>(1, 1)} 强制分页查询,确保 SQL 自动添加 {@code LIMIT 1},因此 {@code throwEx} 参数不再生效
|
||||
* 2. 原方法的 {@code throwEx} 逻辑(多条数据抛异常)已被优化掉,因为分页查询不会返回多条记录
|
||||
* </p>
|
||||
*
|
||||
* @param queryWrapper 查询条件(可为 null)
|
||||
* @param throwEx <del>是否抛出异常(已弃用,此参数不再生效)</del>
|
||||
* @return 单条记录或无数据时返回 null
|
||||
*/
|
||||
@Override
|
||||
default T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, boolean throwEx) {
|
||||
// 强制分页查询(LIMIT 1),确保最多返回 1 条记录
|
||||
List<T> list = this.selectList(new Page<>(1, 1), queryWrapper);
|
||||
return CollUtil.isEmpty(list) ? null : list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有VO对象列表
|
||||
*
|
||||
* @return 查询到的VO对象列表
|
||||
*/
|
||||
default List<V> selectVoList() {
|
||||
return this.selectVoList(new QueryWrapper<>(), this.currentVoClass());
|
||||
return selectVoList(new QueryWrapper<>(), this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +294,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
* @return 查询到的VO对象分页列表
|
||||
*/
|
||||
default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) {
|
||||
return this.selectVoPage(page, wrapper, this.currentVoClass());
|
||||
return selectVoPage(page, wrapper, this.currentVoClass());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package org.dromara.common.mybatis.handler;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.mybatis.spring.MyBatisSystemException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
@@ -35,13 +36,54 @@ public class MybatisExceptionHandler {
|
||||
@ExceptionHandler(MyBatisSystemException.class)
|
||||
public R<Void> handleCannotFindDataSourceException(MyBatisSystemException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
String message = e.getMessage();
|
||||
if (StringUtils.contains(message, "CannotFindDataSourceException")) {
|
||||
Throwable root = getRootCause(e);
|
||||
if (root instanceof NotLoginException) {
|
||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, root.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||
}
|
||||
if (root instanceof CannotFindDataSourceException) {
|
||||
log.error("请求地址'{}', 未找到数据源", requestURI);
|
||||
return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, "未找到数据源,请联系管理员确认");
|
||||
}
|
||||
log.error("请求地址'{}', Mybatis系统异常", requestURI, e);
|
||||
return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, message);
|
||||
return R.fail(HttpStatus.HTTP_INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常的根因(递归查找)
|
||||
*
|
||||
* @param e 当前异常
|
||||
* @return 根因异常(最底层的 cause)
|
||||
* <p>
|
||||
* 逻辑说明:
|
||||
* 1. 如果 e 没有 cause,说明 e 本身就是根因,直接返回
|
||||
* 2. 如果 e 的 cause 和自身相同(防止循环引用),也返回 e
|
||||
* 3. 否则递归调用,继续向下寻找最底层的 cause
|
||||
*/
|
||||
public static Throwable getRootCause(Throwable e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause == null || cause == e) {
|
||||
return e;
|
||||
}
|
||||
return getRootCause(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在异常链中查找指定类型的异常
|
||||
*
|
||||
* @param e 当前异常
|
||||
* @param clazz 目标异常类
|
||||
* @return 找到的指定类型异常,如果没有找到返回 null
|
||||
*/
|
||||
public static Throwable findCause(Throwable e, Class<? extends Throwable> clazz) {
|
||||
Throwable t = e;
|
||||
while (t != null && t != t.getCause()) {
|
||||
if (clazz.isInstance(t)) {
|
||||
return t;
|
||||
}
|
||||
t = t.getCause();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class DataPermissionHelper {
|
||||
/**
|
||||
* 开启忽略数据权限(开启后需手动调用 {@link #disableIgnore()} 关闭)
|
||||
*/
|
||||
public static void enableIgnore() {
|
||||
private static void enableIgnore() {
|
||||
IgnoreStrategy ignoreStrategy = getIgnoreStrategy();
|
||||
if (ObjectUtil.isNull(ignoreStrategy)) {
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().dataPermission(true).build());
|
||||
@@ -126,7 +126,7 @@ public class DataPermissionHelper {
|
||||
/**
|
||||
* 关闭忽略数据权限
|
||||
*/
|
||||
public static void disableIgnore() {
|
||||
private static void disableIgnore() {
|
||||
IgnoreStrategy ignoreStrategy = getIgnoreStrategy();
|
||||
if (ObjectUtil.isNotNull(ignoreStrategy)) {
|
||||
boolean noOtherIgnoreStrategy = !Boolean.TRUE.equals(ignoreStrategy.getDynamicTableName())
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.nio.channels.WritableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -317,13 +318,13 @@ public class OssClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取私有URL链接
|
||||
* 创建下载请求的预签名URL
|
||||
*
|
||||
* @param objectKey 对象KEY
|
||||
* @param expiredTime 链接授权到期时间
|
||||
*/
|
||||
public String getPrivateUrl(String objectKey, Duration expiredTime) {
|
||||
// 使用 AWS S3 预签名 URL 的生成器 获取对象的预签名 URL
|
||||
public String createPresignedGetUrl(String objectKey, Duration expiredTime) {
|
||||
// 使用 AWS S3 预签名 URL 的生成器 获取下载对象的预签名 URL
|
||||
URL url = presigner.presignGetObject(
|
||||
x -> x.signatureDuration(expiredTime)
|
||||
.getObjectRequest(
|
||||
@@ -332,7 +333,28 @@ public class OssClient {
|
||||
.build())
|
||||
.build())
|
||||
.url();
|
||||
return url.toString();
|
||||
return url.toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建上传请求的预签名URL
|
||||
*
|
||||
* @param objectKey 对象KEY
|
||||
* @param expiredTime 链接授权到期时间
|
||||
* @param metadata 元数据
|
||||
*/
|
||||
public String createPresignedPutUrl(String objectKey, Duration expiredTime, Map<String, String> metadata) {
|
||||
// 使用 AWS S3 预签名 URL 的生成器 获取上传文件对象的预签名 URL
|
||||
URL url = presigner.presignPutObject(
|
||||
x -> x.signatureDuration(expiredTime)
|
||||
.putObjectRequest(
|
||||
y -> y.bucket(properties.getBucketName())
|
||||
.key(objectKey)
|
||||
.metadata(metadata)
|
||||
.build())
|
||||
.build())
|
||||
.url();
|
||||
return url.toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,16 +43,12 @@
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– redis序列化替代方案 比json快无数的跨语言二进制序列化 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.fury</groupId>-->
|
||||
<!-- <artifactId>fury-core</artifactId>-->
|
||||
<!-- <version>0.9.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.slf4j</groupId>-->
|
||||
<!-- <artifactId>slf4j-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- redis序列化替代方案 比json快无数的跨语言二进制序列化 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.fory</groupId>
|
||||
<artifactId>fory-core</artifactId>
|
||||
<version>0.13.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ public class RedisConfig {
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// 指定序列化输入的类型,类必须是非final修饰的。序列化时将对象全类名一起保存下来
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// LoggerFactory.useSlf4jLogging(true);
|
||||
// FuryCodec furyCodec = new FuryCodec();
|
||||
// CompositeCodec codec = new CompositeCodec(StringCodec.INSTANCE, furyCodec, furyCodec);
|
||||
// org.apache.fory.logging.LoggerFactory 包别引入错了
|
||||
// LoggerFactory.useSlf4jLogging(true);
|
||||
// ForyCodec foryCodec = new ForyCodec();
|
||||
// CompositeCodec codec = new CompositeCodec(StringCodec.INSTANCE, foryCodec, foryCodec);
|
||||
TypedJsonJacksonCodec jsonCodec = new TypedJsonJacksonCodec(Object.class, om);
|
||||
// 组合序列化 key 使用 String 内容使用通用 json 格式
|
||||
CompositeCodec codec = new CompositeCodec(StringCodec.INSTANCE, jsonCodec, jsonCodec);
|
||||
|
||||
@@ -7,7 +7,9 @@ import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import cn.dev33.satoken.util.SaTokenConsts;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
@@ -55,6 +57,8 @@ public class SecurityConfig implements WebMvcConfigurer {
|
||||
// 对未排除的路径进行检查
|
||||
.check(() -> {
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
HttpServletResponse response = ServletUtils.getResponse();
|
||||
response.setContentType(SaTokenConsts.CONTENT_TYPE_APPLICATION_JSON);
|
||||
// 检查是否登录 是否有token
|
||||
StpUtil.checkLogin();
|
||||
|
||||
@@ -94,7 +98,11 @@ public class SecurityConfig implements WebMvcConfigurer {
|
||||
.setAuth(obj -> {
|
||||
SaHttpBasicUtil.check(username + ":" + password);
|
||||
})
|
||||
.setError(e -> SaResult.error(e.getMessage()).setCode(HttpStatus.UNAUTHORIZED));
|
||||
.setError(e -> {
|
||||
HttpServletResponse response = ServletUtils.getResponse();
|
||||
response.setContentType(SaTokenConsts.CONTENT_TYPE_APPLICATION_JSON);
|
||||
return SaResult.error(e.getMessage()).setCode(HttpStatus.UNAUTHORIZED);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dromara.common.sensitive.core;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.common.sensitive.utils.DesensitizedUtils;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -80,6 +81,13 @@ public enum SensitiveStrategy {
|
||||
*/
|
||||
FIRST_MASK(DesensitizedUtil::firstMask),
|
||||
|
||||
/**
|
||||
* 通用字符串脱敏
|
||||
* 可配置前后可见长度和中间掩码长度
|
||||
* 默认示例:前4位可见,后4位可见,中间固定4个*
|
||||
*/
|
||||
STRING_MASK(s -> DesensitizedUtils.mask(s, 4, 4, 4)),
|
||||
|
||||
/**
|
||||
* 清空为""
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.dromara.common.sensitive.utils;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 脱敏工具类
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class DesensitizedUtils extends DesensitizedUtil {
|
||||
|
||||
/**
|
||||
* 灵活脱敏方法
|
||||
*
|
||||
* @param value 原始字符串
|
||||
* @param prefixVisible 前面可见长度
|
||||
* @param suffixVisible 后面可见长度
|
||||
* @param maskLength 中间掩码长度(固定显示多少 *,如果总长度不足则自动缩减)
|
||||
* @return 脱敏后字符串
|
||||
*/
|
||||
public static String mask(String value, int prefixVisible, int suffixVisible, int maskLength) {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
int len = value.length();
|
||||
|
||||
// 总长度小于等于前后可见长度 → 全部掩码
|
||||
if (len <= prefixVisible + suffixVisible) {
|
||||
return StrUtil.repeat('*', len);
|
||||
}
|
||||
|
||||
// 可用长度 = 总长度 - 前后可见长度
|
||||
int available = len - prefixVisible - suffixVisible;
|
||||
|
||||
// 中间掩码长度不能超过可用长度
|
||||
int actualMaskLength = Math.min(maskLength, available);
|
||||
|
||||
// 剩余字符尽量显示在中间掩码旁
|
||||
int remaining = available - actualMaskLength;
|
||||
String middleChars = remaining > 0 ? value.substring(prefixVisible, prefixVisible + remaining) : "";
|
||||
String middleMask = StrUtil.repeat('*', actualMaskLength);
|
||||
|
||||
String prefix = value.substring(0, prefixVisible);
|
||||
String suffix = value.substring(len - suffixVisible);
|
||||
|
||||
return prefix + middleChars + middleMask + suffix;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
import me.zhyd.oauth.enums.scope.AuthDingTalkScope;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 新版钉钉二维码登录
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @since 1.16.7
|
||||
*/
|
||||
public class AuthDingTalkV2Request extends AuthDefaultRequest {
|
||||
|
||||
public AuthDingTalkV2Request(AuthConfig config) {
|
||||
super(config, AuthDefaultSource.DINGTALK_V2);
|
||||
}
|
||||
|
||||
public AuthDingTalkV2Request(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSource.DINGTALK_V2, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("scope", this.getScopes(",", true, AuthScopeUtils.getDefaultScopes(AuthDingTalkScope.values())))
|
||||
.queryParam("redirect_uri", GlobalAuthUtils.urlEncode(config.getRedirectUri()))
|
||||
.queryParam("prompt", "consent")
|
||||
.queryParam("org_type", config.getDingTalkOrgType())
|
||||
.queryParam("corpId", config.getDingTalkCorpId())
|
||||
.queryParam("exclusiveLogin", config.isDingTalkExclusiveLogin())
|
||||
.queryParam("exclusiveCorpId", config.getDingTalkExclusiveCorpId())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("grantType", "authorization_code");
|
||||
params.put("clientId", config.getClientId());
|
||||
params.put("clientSecret", config.getClientSecret());
|
||||
params.put("code", authCallback.getCode());
|
||||
String response = new HttpUtils(config.getHttpConfig()).post(this.source.accessToken(), JSONObject.toJSONString(params)).getBody();
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
if (!accessTokenObject.containsKey("accessToken")) {
|
||||
throw new AuthException(JSONObject.toJSONString(response), source);
|
||||
}
|
||||
return AuthToken.builder()
|
||||
.accessToken(accessTokenObject.getString("accessToken"))
|
||||
.refreshToken(accessTokenObject.getString("refreshToken"))
|
||||
.expireIn(accessTokenObject.getIntValue("expireIn"))
|
||||
.corpId(accessTokenObject.getString("corpId"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpHeader header = new HttpHeader();
|
||||
header.add("x-acs-dingtalk-access-token", authToken.getAccessToken());
|
||||
|
||||
String response = new HttpUtils(config.getHttpConfig()).get(this.source.userInfo(), null, header, false).getBody();
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
|
||||
authToken.setOpenId(object.getString("openId"));
|
||||
authToken.setUnionId(object.getString("unionId"));
|
||||
return AuthUser.builder()
|
||||
.rawUserInfo(object)
|
||||
.uuid(object.getString("unionId"))
|
||||
.username(object.getString("nick"))
|
||||
.nickname(object.getString("nick"))
|
||||
.avatar(object.getString("avatarUrl"))
|
||||
.snapshotUser(object.getBooleanValue("visitor"))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param code 授权码
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
protected String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(source.accessToken())
|
||||
.queryParam("code", code)
|
||||
.queryParam("clientId", config.getClientId())
|
||||
.queryParam("clientSecret", config.getClientSecret())
|
||||
.queryParam("grantType", "authorization_code")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,6 @@ import org.dromara.common.social.gitea.AuthGiteaRequest;
|
||||
import org.dromara.common.social.maxkey.AuthMaxKeyRequest;
|
||||
import org.dromara.common.social.topiam.AuthTopIamRequest;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 认证授权工具类
|
||||
*
|
||||
@@ -43,7 +40,7 @@ public class SocialUtils {
|
||||
AuthConfig.AuthConfigBuilder builder = AuthConfig.builder()
|
||||
.clientId(obj.getClientId())
|
||||
.clientSecret(obj.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(obj.getRedirectUri(), StandardCharsets.UTF_8))
|
||||
.redirectUri(obj.getRedirectUri())
|
||||
.scopes(obj.getScopes());
|
||||
return switch (source.toLowerCase()) {
|
||||
case "dingtalk" -> new AuthDingTalkV2Request(builder.build(), STATE_CACHE);
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package org.dromara.common.sse.core;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -26,6 +33,12 @@ public class SseEmitterManager {
|
||||
|
||||
private final static Map<Long, Map<String, SseEmitter>> USER_TOKEN_EMITTERS = new ConcurrentHashMap<>();
|
||||
|
||||
public SseEmitterManager() {
|
||||
// 定时执行 SSE 心跳检测
|
||||
SpringUtils.getBean(ScheduledExecutorService.class)
|
||||
.scheduleWithFixedDelay(this::sseMonitor, 60L, 60L, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立与指定用户的 SSE 连接
|
||||
*
|
||||
@@ -38,6 +51,12 @@ public class SseEmitterManager {
|
||||
// 每个用户可以有多个 SSE 连接,通过 token 进行区分
|
||||
Map<String, SseEmitter> emitters = USER_TOKEN_EMITTERS.computeIfAbsent(userId, k -> new ConcurrentHashMap<>());
|
||||
|
||||
// 关闭已存在的SseEmitter,防止超过最大连接数
|
||||
SseEmitter oldEmitter = emitters.remove(token);
|
||||
if (oldEmitter != null) {
|
||||
oldEmitter.complete();
|
||||
}
|
||||
|
||||
// 创建一个新的 SseEmitter 实例,超时时间设置为一天 避免连接之后直接关闭浏览器导致连接停滞
|
||||
SseEmitter emitter = new SseEmitter(86400000L);
|
||||
|
||||
@@ -97,6 +116,44 @@ public class SseEmitterManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SSE 心跳检测,关闭无效连接
|
||||
*/
|
||||
public void sseMonitor() {
|
||||
final SseEmitter.SseEventBuilder heartbeat = SseEmitter.event().comment("heartbeat");
|
||||
// 记录需要移除的用户ID
|
||||
List<Long> toRemoveUsers = new ArrayList<>();
|
||||
|
||||
USER_TOKEN_EMITTERS.forEach((userId, emitterMap) -> {
|
||||
if (CollUtil.isEmpty(emitterMap)) {
|
||||
toRemoveUsers.add(userId);
|
||||
return;
|
||||
}
|
||||
|
||||
emitterMap.entrySet().removeIf(entry -> {
|
||||
try {
|
||||
entry.getValue().send(heartbeat);
|
||||
return false;
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
entry.getValue().complete();
|
||||
} catch (Exception ignore) {
|
||||
// 忽略重复关闭异常
|
||||
}
|
||||
return true; // 发送失败 → 移除该连接
|
||||
}
|
||||
});
|
||||
|
||||
// 移除空连接用户
|
||||
if (emitterMap.isEmpty()) {
|
||||
toRemoveUsers.add(userId);
|
||||
}
|
||||
});
|
||||
|
||||
// 循环结束后统一清理空用户,避免并发修改异常
|
||||
toRemoveUsers.forEach(USER_TOKEN_EMITTERS::remove);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅SSE消息主题,并提供一个消费者函数来处理接收到的消息
|
||||
*
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TenantHelper {
|
||||
/**
|
||||
* 开启忽略租户(开启后需手动调用 {@link #disableIgnore()} 关闭)
|
||||
*/
|
||||
public static void enableIgnore() {
|
||||
private static void enableIgnore() {
|
||||
IgnoreStrategy ignoreStrategy = getIgnoreStrategy();
|
||||
if (ObjectUtil.isNull(ignoreStrategy)) {
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
|
||||
@@ -69,7 +69,7 @@ public class TenantHelper {
|
||||
/**
|
||||
* 关闭忽略租户
|
||||
*/
|
||||
public static void disableIgnore() {
|
||||
private static void disableIgnore() {
|
||||
IgnoreStrategy ignoreStrategy = getIgnoreStrategy();
|
||||
if (ObjectUtil.isNotNull(ignoreStrategy)) {
|
||||
boolean noOtherIgnoreStrategy = !Boolean.TRUE.equals(ignoreStrategy.getDynamicTableName())
|
||||
|
||||
@@ -46,8 +46,14 @@ public class TranslationHandler extends JsonSerializer<Object> implements Contex
|
||||
gen.writeNull();
|
||||
return;
|
||||
}
|
||||
Object result = trans.translation(value, translation.other());
|
||||
gen.writeObject(result);
|
||||
try {
|
||||
Object result = trans.translation(value, translation.other());
|
||||
gen.writeObject(result);
|
||||
} catch (Exception e) {
|
||||
log.error("翻译处理异常,type: {}, value: {}", translation.type(), value, e);
|
||||
// 出现异常时输出原始值而不是中断序列化
|
||||
gen.writeObject(value);
|
||||
}
|
||||
} else {
|
||||
gen.writeObject(value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.dromara.common.web.config;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.web.handler.GlobalExceptionHandler;
|
||||
import org.dromara.common.web.interceptor.PlusWebInvokeTimeInterceptor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
@@ -34,10 +35,11 @@ public class ResourcesConfig implements WebMvcConfigurer {
|
||||
public void addFormatters(FormatterRegistry registry) {
|
||||
// 全局日期格式转换配置
|
||||
registry.addConverter(String.class, Date.class, source -> {
|
||||
if (StringUtils.isBlank(source)) {
|
||||
DateTime parse = DateUtil.parse(source);
|
||||
if (ObjectUtils.isNull(parse)) {
|
||||
return null;
|
||||
}
|
||||
return DateUtil.parse(source);
|
||||
return parse.toJdkDate();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.web.bind.MissingPathVariableException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
@@ -123,7 +124,7 @@ public class GlobalExceptionHandler {
|
||||
*/
|
||||
@ResponseStatus(org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(IOException.class)
|
||||
public void handleRuntimeException(IOException e, HttpServletRequest request) {
|
||||
public void handleIoException(IOException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
if (requestURI.contains("sse")) {
|
||||
// sse 经常性连接中断 例如关闭浏览器 直接屏蔽
|
||||
@@ -132,6 +133,13 @@ public class GlobalExceptionHandler {
|
||||
log.error("请求地址'{}',连接中断", requestURI, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* sse 连接超时异常 不需要处理
|
||||
*/
|
||||
@ExceptionHandler(AsyncRequestTimeoutException.class)
|
||||
public void handleRuntimeException(AsyncRequestTimeoutException e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ spring:
|
||||
snail-job:
|
||||
# 服务端节点IP(默认按照`NetUtil.getLocalIpStr()`)
|
||||
server-host:
|
||||
# 服务端netty的端口号
|
||||
# 服务端端口号
|
||||
server-port: 17888
|
||||
# 合并日志默认保存天数
|
||||
merge-Log-days: 1
|
||||
|
||||
@@ -18,7 +18,7 @@ spring:
|
||||
snail-job:
|
||||
# 服务端节点IP(默认按照`NetUtil.getLocalIpStr()`)
|
||||
server-host:
|
||||
# 服务端netty的端口号
|
||||
# 服务端端口号
|
||||
server-port: 17888
|
||||
# 合并日志默认保存天数
|
||||
merge-Log-days: 1
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -94,6 +96,16 @@ public class TestExcelController {
|
||||
exportExcelService.exportWithOptions(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义导出
|
||||
*
|
||||
* @param response /
|
||||
*/
|
||||
@GetMapping("/customExport")
|
||||
public void customExport(HttpServletResponse response) throws IOException {
|
||||
exportExcelService.customExport(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个sheet导出
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.dromara.demo.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 导出下拉框Excel示例
|
||||
*
|
||||
@@ -15,4 +17,11 @@ public interface IExportExcelService {
|
||||
* @param response /
|
||||
*/
|
||||
void exportWithOptions(HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 自定义导出
|
||||
*
|
||||
* @param response /
|
||||
*/
|
||||
void customExport(HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,21 @@ package org.dromara.demo.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.idev.excel.write.metadata.WriteSheet;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.excel.core.DropDownOptions;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.excel.utils.ExcelWriterWrapper;
|
||||
import org.dromara.demo.domain.vo.ExportDemoVo;
|
||||
import org.dromara.demo.service.IExportExcelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -233,4 +237,61 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void customExport(HttpServletResponse response) throws IOException {
|
||||
String filename = ExcelUtil.encodingFilename("自定义导出");
|
||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||
|
||||
ExcelUtil.exportExcel(ExportDemoVo.class, response.getOutputStream(), wrapper -> {
|
||||
// 创建表格数据,业务中一般通过数据库查询
|
||||
List<ExportDemoVo> excelDataList = new ArrayList<>();
|
||||
for (int i = 0; i < 30; i++) {
|
||||
// 模拟数据库中的一条数据
|
||||
ExportDemoVo everyRowData = new ExportDemoVo();
|
||||
everyRowData.setNickName("用户-" + i);
|
||||
everyRowData.setUserStatus(SystemConstants.NORMAL);
|
||||
everyRowData.setGender("1");
|
||||
everyRowData.setPhoneNumber(String.format("175%08d", i));
|
||||
everyRowData.setEmail(String.format("175%08d", i) + "@163.com");
|
||||
everyRowData.setProvinceId(i);
|
||||
everyRowData.setCityId(i);
|
||||
everyRowData.setAreaId(i);
|
||||
excelDataList.add(everyRowData);
|
||||
}
|
||||
|
||||
// 创建表格
|
||||
WriteSheet sheet = ExcelWriterWrapper.sheetBuilder("自定义导出demo")
|
||||
// 合并单元格
|
||||
// .registerWriteHandler(new CellMergeStrategy(excelDataList, true))
|
||||
.build();
|
||||
|
||||
|
||||
wrapper.write(excelDataList, sheet);
|
||||
|
||||
List<ExportDemoVo> excelDataList2 = new ArrayList<>();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
int index = 1000 + i;
|
||||
// 模拟数据库中的一条数据
|
||||
ExportDemoVo everyRowData = new ExportDemoVo();
|
||||
everyRowData.setNickName("用户-" + index);
|
||||
everyRowData.setUserStatus(SystemConstants.NORMAL);
|
||||
everyRowData.setGender("1");
|
||||
everyRowData.setPhoneNumber(String.format("175%08d", index));
|
||||
everyRowData.setEmail(String.format("175%08d", index) + "@163.com");
|
||||
everyRowData.setProvinceId(index);
|
||||
everyRowData.setCityId(index);
|
||||
everyRowData.setAreaId(index);
|
||||
excelDataList2.add(everyRowData);
|
||||
}
|
||||
|
||||
wrapper.write(excelDataList2, sheet);
|
||||
|
||||
// 或者在同一个excel中创建多个表格
|
||||
// WriteSheet sheet2 = ExcelWriterWrapper.sheetBuilder("自定义导出demo2").build();
|
||||
// wrapper.write(excelDataList2, sheet2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']" />
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']"></el-button>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package org.dromara.system.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.bo.SysClientBo;
|
||||
import org.dromara.system.service.ISysClientService;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
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.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysClientBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.service.ISysClientService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端管理
|
||||
@@ -76,6 +77,9 @@ public class SysClientController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysClientBo bo) {
|
||||
if (!sysClientService.checkClickKeyUnique(bo)) {
|
||||
return R.fail("新增客户端'" + bo.getClientKey() + "'失败,客户端key已存在");
|
||||
}
|
||||
return toAjax(sysClientService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@@ -87,6 +91,9 @@ public class SysClientController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysClientBo bo) {
|
||||
if (!sysClientService.checkClickKeyUnique(bo)) {
|
||||
return R.fail("修改客户端'" + bo.getClientKey() + "'失败,客户端key已存在");
|
||||
}
|
||||
return toAjax(sysClientService.updateByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -13,8 +14,10 @@ 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.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysDeptBo;
|
||||
import org.dromara.system.domain.bo.SysPostBo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.system.service.ISysPostService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -35,6 +38,7 @@ import java.util.List;
|
||||
public class SysPostController extends BaseController {
|
||||
|
||||
private final ISysPostService postService;
|
||||
private final ISysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
@@ -134,4 +138,14 @@ public class SysPostController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@SaCheckPermission("system:post:list")
|
||||
@GetMapping("/deptTree")
|
||||
public R<List<Tree<Long>>> deptTree(SysDeptBo dept) {
|
||||
return R.ok(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -193,4 +193,19 @@ public class SysTenantController extends BaseController {
|
||||
return R.ok("同步租户字典成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步租户参数配置
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@Log(title = "租户管理", businessType = BusinessType.INSERT)
|
||||
@Lock4j
|
||||
@GetMapping("/syncTenantConfig")
|
||||
public R<Void> syncTenantConfig() {
|
||||
if (!TenantHelper.isEnable()) {
|
||||
return R.fail("当前未开启租户模式");
|
||||
}
|
||||
tenantService.syncTenantConfig();
|
||||
return R.ok("同步租户参数配置成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.core.constant.RegexConstants;
|
||||
import org.dromara.common.json.validate.JsonPattern;
|
||||
import org.dromara.common.json.validate.JsonType;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.system.domain.SysMenu;
|
||||
|
||||
@@ -61,6 +63,7 @@ public class SysMenuBo extends BaseEntity {
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
@JsonPattern(type = JsonType.OBJECT, message = "路由参数必须符合JSON格式")
|
||||
private String queryParam;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,11 @@ public class MetaVo {
|
||||
*/
|
||||
private String link;
|
||||
|
||||
/**
|
||||
* 激活菜单
|
||||
*/
|
||||
private String activeMenu;
|
||||
|
||||
public MetaVo(String title, String icon) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
@@ -58,4 +63,16 @@ public class MetaVo {
|
||||
}
|
||||
}
|
||||
|
||||
public MetaVo(String title, String icon, Boolean noCache, String link, String activeMenu) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.noCache = noCache;
|
||||
if (StringUtils.ishttp(link)) {
|
||||
this.link = link;
|
||||
}
|
||||
if (StringUtils.startWithAnyIgnoreCase(activeMenu, "/")) {
|
||||
this.activeMenu = activeMenu;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
return """
|
||||
select srd.dept_id from sys_role_dept srd
|
||||
left join sys_role sr on sr.role_id = srd.role_id
|
||||
where srd.role_id = %d and sr.status = 0
|
||||
where srd.role_id = %d and sr.status = '0'
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
select parent_id from sys_dept where dept_id in (
|
||||
select srd.dept_id from sys_role_dept srd
|
||||
left join sys_role sr on sr.role_id = srd.role_id
|
||||
where srd.role_id = %d and sr.status = 0
|
||||
where srd.role_id = %d and sr.status = '0'
|
||||
)
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
select menu_id from sys_role_menu where role_id in (
|
||||
select sur.role_id from sys_user_role sur
|
||||
left join sys_role sr on sr.role_id = sur.role_id
|
||||
where sur.user_id = %d and sr.status = 0
|
||||
where sur.user_id = %d and sr.status = '0'
|
||||
)
|
||||
""".formatted(userId);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
return """
|
||||
select srm.menu_id from sys_role_menu srm
|
||||
left join sys_role sr on sr.role_id = srm.role_id
|
||||
where srm.role_id = %d and sr.status = 0
|
||||
where srm.role_id = %d and sr.status = '0'
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
select parent_id from sys_menu where menu_id in (
|
||||
select srm.menu_id from sys_role_menu srm
|
||||
left join sys_role sr on sr.role_id = srm.role_id
|
||||
where srm.role_id = %d and sr.status = 0
|
||||
where srm.role_id = %d and sr.status = '0'
|
||||
)
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.dromara.system.service;
|
||||
|
||||
import org.dromara.system.domain.SysClient;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.bo.SysClientBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.bo.SysClientBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -57,4 +56,11 @@ public interface ISysClientService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 校验客户端key是否唯一
|
||||
*
|
||||
* @param client 客户端信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean checkClickKeyUnique(SysClientBo client);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.dromara.system.service;
|
||||
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -84,4 +84,9 @@ public interface ISysTenantService {
|
||||
* 同步租户字典
|
||||
*/
|
||||
void syncTenantDict();
|
||||
|
||||
/**
|
||||
* 同步租户参数配置
|
||||
*/
|
||||
void syncTenantConfig();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -136,4 +137,19 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验客户端key是否唯一
|
||||
*
|
||||
* @param client 客户端信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkClickKeyUnique(SysClientBo client) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysClient>()
|
||||
.eq(SysClient::getClientKey, client.getClientKey())
|
||||
.ne(ObjectUtil.isNotNull(client.getId()), SysClient::getId, client.getId()));
|
||||
return !exist;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -14,6 +15,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
@@ -82,6 +84,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
|
||||
/**
|
||||
* 获取注册开关
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @return true开启,false关闭
|
||||
*/
|
||||
@@ -212,4 +215,54 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
return SpringUtils.getAopProxy(this).selectConfigByKey(configKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取 Map 类型的配置
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Dict 对象,如果配置为空或无法解析,返回空 Dict
|
||||
*/
|
||||
@Override
|
||||
public Dict getConfigMap(String configKey) {
|
||||
String configValue = getConfigValue(configKey);
|
||||
return JsonUtils.parseMap(configValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取 Map 类型的配置列表
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @return Dict 列表,如果配置为空或无法解析,返回空列表
|
||||
*/
|
||||
@Override
|
||||
public List<Dict> getConfigArrayMap(String configKey) {
|
||||
String configValue = getConfigValue(configKey);
|
||||
return JsonUtils.parseArrayMap(configValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取指定类型的配置对象
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @param clazz 目标对象类型
|
||||
* @return 对象实例,如果配置为空或无法解析,返回 null
|
||||
*/
|
||||
@Override
|
||||
public <T> T getConfigObject(String configKey, Class<T> clazz) {
|
||||
String configValue = getConfigValue(configKey);
|
||||
return JsonUtils.parseObject(configValue, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取指定类型的配置列表=
|
||||
*
|
||||
* @param configKey 参数 key
|
||||
* @param clazz 目标元素类型
|
||||
* @return 指定类型列表,如果配置为空或无法解析,返回空列表
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> getConfigArray(String configKey, Class<T> clazz) {
|
||||
String configValue = getConfigValue(configKey);
|
||||
return JsonUtils.parseArray(configValue, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
});
|
||||
}
|
||||
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getMenuId)
|
||||
.in(SysMenu::getMenuId, menuIds)
|
||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {
|
||||
return Convert.toLong(x);
|
||||
@@ -185,7 +186,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
router.setPath(menu.getRouterPath());
|
||||
router.setComponent(menu.getComponentInfo());
|
||||
router.setQuery(menu.getQueryParam());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getRemark()));
|
||||
List<SysMenu> cMenus = menu.getChildren();
|
||||
if (CollUtil.isNotEmpty(cMenus) && SystemConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||
router.setAlwaysShow(true);
|
||||
@@ -199,7 +200,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
children.setPath(menu.getPath());
|
||||
children.setComponent(menu.getComponent());
|
||||
children.setName(frameName);
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getRemark()));
|
||||
children.setQuery(menu.getQueryParam());
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
@@ -240,6 +241,8 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
.setWeight(menu.getOrderNum());
|
||||
menuTree.put("menuType", menu.getMenuType());
|
||||
menuTree.put("icon", menu.getIcon());
|
||||
menuTree.put("visible", menu.getVisible());
|
||||
menuTree.put("status", menu.getStatus());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
OssClient storage = OssFactory.instance(oss.getService());
|
||||
// 仅修改桶类型为 private 的URL,临时URL时长为120s
|
||||
if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
|
||||
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), Duration.ofSeconds(120)));
|
||||
oss.setUrl(storage.createPresignedGetUrl(oss.getFileName(), Duration.ofSeconds(120)));
|
||||
}
|
||||
return oss;
|
||||
}
|
||||
|
||||
@@ -508,4 +508,60 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步租户参数配置
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void syncTenantConfig() {
|
||||
// 查询超管 所有参数配置
|
||||
List<SysConfig> configList = TenantHelper.ignore(() -> configMapper.selectList());
|
||||
|
||||
// 所有租户参数配置
|
||||
Map<String, List<SysConfig>> configMap = StreamUtils.groupByKey(configList, TenantEntity::getTenantId);
|
||||
|
||||
// 默认租户字典类型列表
|
||||
List<SysConfig> defaultConfigList = configMap.get(TenantConstants.DEFAULT_TENANT_ID);
|
||||
|
||||
// 获取所有租户编号
|
||||
List<String> tenantIds = baseMapper.selectObjs(
|
||||
new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId)
|
||||
.eq(SysTenant::getStatus, SystemConstants.NORMAL), x -> {
|
||||
return Convert.toStr(x);
|
||||
});
|
||||
// 待入库的字典类型和字典数据
|
||||
List<SysConfig> saveConfigList = new ArrayList<>();
|
||||
// 待同步的租户编号(用于清除对于租户的字典缓存)
|
||||
Set<String> syncTenantIds = new HashSet<>();
|
||||
// 循环所有租户,处理需要同步的数据
|
||||
for (String tenantId : tenantIds) {
|
||||
// 排除默认租户
|
||||
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||
continue;
|
||||
}
|
||||
// 根据默认租户的字典类型进行数据同步
|
||||
for (SysConfig config : defaultConfigList) {
|
||||
// 获取当前租户的字典类型列表
|
||||
List<String> typeList = StreamUtils.toList(configMap.get(tenantId), SysConfig::getConfigKey);
|
||||
if (!typeList.contains(config.getConfigKey())) {
|
||||
SysConfig type = BeanUtil.toBean(config, SysConfig.class);
|
||||
type.setConfigId(null);
|
||||
type.setTenantId(tenantId);
|
||||
type.setCreateTime(null);
|
||||
type.setUpdateTime(null);
|
||||
syncTenantIds.add(tenantId);
|
||||
saveConfigList.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
TenantHelper.ignore(() -> {
|
||||
if (CollUtil.isNotEmpty(saveConfigList)) {
|
||||
configMapper.insertBatch(saveConfigList);
|
||||
}
|
||||
});
|
||||
for (String tenantId : syncTenantIds) {
|
||||
TenantHelper.dynamic(tenantId, () -> CacheUtils.clear(CacheNames.SYS_CONFIG));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
w.in(SysUser::getDeptId, ids);
|
||||
}).orderByAsc(SysUser::getUserId);
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
wrapper.notIn(SysUser::getUserId, StringUtils.splitList(user.getExcludeUserIds()));
|
||||
wrapper.notIn(SysUser::getUserId, StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum ButtonPermissionEnum implements NodeExtEnum {
|
||||
/**
|
||||
* 是否能抄送
|
||||
*/
|
||||
COPY("是否能抄送", "copy", false),
|
||||
COPY("是否能抄送", "copy", true),
|
||||
|
||||
/**
|
||||
* 是否显示退回
|
||||
|
||||
@@ -187,6 +187,7 @@ public class FlwDefinitionController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/active/{id}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Log(title = "流程定义", businessType = BusinessType.UPDATE)
|
||||
public R<Boolean> active(@PathVariable Long id, @RequestParam boolean active) {
|
||||
return R.ok(active ? defService.active(id) : defService.unActive(id));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.dromara.workflow.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
@@ -75,8 +77,9 @@ public class FlwInstanceController extends BaseController {
|
||||
* @param businessIds 业务id
|
||||
*/
|
||||
@DeleteMapping("/deleteByBusinessIds/{businessIds}")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.DELETE)
|
||||
public R<Void> deleteByBusinessIds(@PathVariable List<Long> businessIds) {
|
||||
return toAjax(flwInstanceService.deleteByBusinessIds(businessIds));
|
||||
return toAjax(flwInstanceService.deleteByBusinessIds(StreamUtils.toList(businessIds, Convert::toStr)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,6 +88,7 @@ public class FlwInstanceController extends BaseController {
|
||||
* @param instanceIds 实例id
|
||||
*/
|
||||
@DeleteMapping("/deleteByInstanceIds/{instanceIds}")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.DELETE)
|
||||
public R<Void> deleteByInstanceIds(@PathVariable List<Long> instanceIds) {
|
||||
return toAjax(flwInstanceService.deleteByInstanceIds(instanceIds));
|
||||
}
|
||||
@@ -95,6 +99,7 @@ public class FlwInstanceController extends BaseController {
|
||||
* @param instanceIds 实例id
|
||||
*/
|
||||
@DeleteMapping("/deleteHisByInstanceIds/{instanceIds}")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.DELETE)
|
||||
public R<Void> deleteHisByInstanceIds(@PathVariable List<Long> instanceIds) {
|
||||
return toAjax(flwInstanceService.deleteHisByInstanceIds(instanceIds));
|
||||
}
|
||||
@@ -106,6 +111,7 @@ public class FlwInstanceController extends BaseController {
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/cancelProcessApply")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.UPDATE)
|
||||
public R<Void> cancelProcessApply(@RequestBody FlowCancelBo bo) {
|
||||
return toAjax(flwInstanceService.cancelProcessApply(bo));
|
||||
}
|
||||
@@ -118,6 +124,7 @@ public class FlwInstanceController extends BaseController {
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/active/{id}")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.UPDATE)
|
||||
public R<Boolean> active(@PathVariable Long id, @RequestParam boolean active) {
|
||||
return R.ok(active ? insService.active(id) : insService.unActive(id));
|
||||
}
|
||||
@@ -160,6 +167,7 @@ public class FlwInstanceController extends BaseController {
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/updateVariable")
|
||||
@Log(title = "流程实例管理", businessType = BusinessType.UPDATE)
|
||||
public R<Void> updateVariable(@Validated @RequestBody FlowVariableBo bo) {
|
||||
return toAjax(flwInstanceService.updateVariable(bo));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义
|
||||
* 流程spel表达式定义
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
@@ -38,7 +38,7 @@ public class FlwSpelController extends BaseController {
|
||||
private final IFlwSpelService flwSpelService;
|
||||
|
||||
/**
|
||||
* 查询流程spel达式定义列表
|
||||
* 查询流程spel表达式定义列表
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:list")
|
||||
@GetMapping("/list")
|
||||
@@ -47,7 +47,7 @@ public class FlwSpelController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程spel达式定义详细信息
|
||||
* 获取流程spel表达式定义详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@@ -58,10 +58,10 @@ public class FlwSpelController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程spel达式定义
|
||||
* 新增流程spel表达式定义
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:add")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.INSERT)
|
||||
@Log(title = "流程spel表达式定义", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody FlowSpelBo bo) {
|
||||
@@ -69,10 +69,10 @@ public class FlwSpelController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程spel达式定义
|
||||
* 修改流程spel表达式定义
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:edit")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "流程spel表达式定义", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowSpelBo bo) {
|
||||
@@ -80,12 +80,12 @@ public class FlwSpelController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程spel达式定义
|
||||
* 删除流程spel表达式定义
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:remove")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.DELETE)
|
||||
@Log(title = "流程spel表达式定义", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(flwSpelService.deleteWithValidByIds(List.of(ids), true));
|
||||
|
||||
@@ -216,6 +216,7 @@ public class FlwTaskController extends BaseController {
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/urgeTask")
|
||||
@Log(title = "任务管理", businessType = BusinessType.INSERT)
|
||||
public R<Void> urgeTask(@RequestBody FlowUrgeTaskBo bo) {
|
||||
return toAjax(flwTaskService.urgeTask(bo));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义对象 flow_spel
|
||||
* 流程spel表达式定义对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
|
||||
@@ -50,6 +50,6 @@ public class FlowInstanceBo implements Serializable {
|
||||
/**
|
||||
* 申请人Ids
|
||||
*/
|
||||
private List<Long> createByIds;
|
||||
private List<String> createByIds;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import jakarta.validation.constraints.*;
|
||||
import org.dromara.workflow.domain.FlowSpel;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义业务对象 flow_spel
|
||||
* 流程spel表达式定义业务对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 抄送对象
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Data
|
||||
public class FlowCopyVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "userId")
|
||||
private String userName;
|
||||
|
||||
public FlowCopyVo(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 流程spel达式定义视图对象 flow_spel
|
||||
* 流程spel表达式定义视图对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 任务视图
|
||||
@@ -185,6 +186,20 @@ public class FlowTaskVo implements Serializable {
|
||||
*/
|
||||
private List<ButtonPermissionVo> buttonList;
|
||||
|
||||
/**
|
||||
* 抄送对象 ID 集合
|
||||
* <p>
|
||||
* 根据扩展属性中 CopySettingEnum 类型的数据生成,存储需要抄送的对象 ID
|
||||
*/
|
||||
private List<FlowCopyVo> copyList;
|
||||
|
||||
/**
|
||||
* 自定义参数 Map
|
||||
* <p>
|
||||
* 根据扩展属性中 VariablesEnum 类型的数据生成,存储 key=value 格式的自定义参数
|
||||
*/
|
||||
private Map<String, String> varList;
|
||||
|
||||
//业务扩展信息开始
|
||||
/**
|
||||
* 业务编码
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Node 扩展属性解析结果 VO
|
||||
* <p>
|
||||
* 用于封装从扩展属性 JSON 中解析出的各类信息,包括按钮权限、抄送对象和自定义参数。
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Data
|
||||
public class NodeExtVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 按钮权限列表
|
||||
* <p>
|
||||
* 根据扩展属性中 ButtonPermissionEnum 类型的数据生成,每个元素表示一个按钮及其是否勾选。
|
||||
*/
|
||||
private List<ButtonPermissionVo> buttonPermissions;
|
||||
|
||||
/**
|
||||
* 抄送对象 ID 集合
|
||||
* <p>
|
||||
* 根据扩展属性中 CopySettingEnum 类型的数据生成,存储需要抄送的对象 ID
|
||||
*/
|
||||
private Set<String> copySettings;
|
||||
|
||||
/**
|
||||
* 自定义参数 Map
|
||||
* <p>
|
||||
* 根据扩展属性中 VariablesEnum 类型的数据生成,存储 key=value 格式的自定义参数
|
||||
*/
|
||||
private Map<String, String> variables;
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
public class FlowProcessEventHandler {
|
||||
|
||||
/**
|
||||
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
|
||||
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成等)
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param instance 实例数据
|
||||
|
||||
@@ -1,33 +1,40 @@
|
||||
package org.dromara.workflow.listener;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.service.UserService;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.Definition;
|
||||
import org.dromara.warm.flow.core.entity.Instance;
|
||||
import org.dromara.warm.flow.core.entity.Task;
|
||||
import org.dromara.warm.flow.core.listener.GlobalListener;
|
||||
import org.dromara.warm.flow.core.listener.ListenerVariable;
|
||||
import org.dromara.warm.flow.core.service.InsService;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
||||
import org.dromara.workflow.domain.vo.NodeExtVo;
|
||||
import org.dromara.workflow.handler.FlowProcessEventHandler;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwInstanceService;
|
||||
import org.dromara.workflow.service.IFlwNodeExtService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 全局任务办理监听
|
||||
@@ -41,10 +48,11 @@ import java.util.Map;
|
||||
public class WorkflowGlobalListener implements GlobalListener {
|
||||
|
||||
private final IFlwTaskService flwTaskService;
|
||||
private final IFlwInstanceService instanceService;
|
||||
private final IFlwInstanceService flwInstanceService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
private final IFlwCommonService flwCommonService;
|
||||
private final InsService insService;
|
||||
private final IFlwNodeExtService nodeExtService;
|
||||
private final UserService userService;
|
||||
|
||||
/**
|
||||
* 创建监听器,任务创建时执行
|
||||
@@ -63,6 +71,25 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
*/
|
||||
@Override
|
||||
public void start(ListenerVariable listenerVariable) {
|
||||
String ext = listenerVariable.getNode().getExt();
|
||||
if (StringUtils.isNotBlank(ext)) {
|
||||
Map<String, Object> variable = listenerVariable.getVariable();
|
||||
NodeExtVo nodeExt = nodeExtService.parseNodeExt(ext, variable);
|
||||
Set<String> copyList = nodeExt.getCopySettings();
|
||||
if (CollUtil.isNotEmpty(copyList)) {
|
||||
List<FlowCopyBo> list = StreamUtils.toList(copyList, x -> {
|
||||
FlowCopyBo bo = new FlowCopyBo();
|
||||
Long id = Convert.toLong(x);
|
||||
bo.setUserId(id);
|
||||
bo.setUserName(userService.selectUserNameById(id));
|
||||
return bo;
|
||||
});
|
||||
variable.put(FlowConstant.FLOW_COPY_LIST, list);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nodeExt.getVariables())) {
|
||||
variable.putAll(nodeExt.getVariables());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,20 +105,61 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
String applyNodeCode = flwCommonService.applyNodeCode(definition.getId());
|
||||
String hisStatus = flowParams != null ? flowParams.getHisStatus() : null;
|
||||
|
||||
for (Task flowTask : nextTasks) {
|
||||
// 如果办理或者退回并行存在需要指定办理人,则直接覆盖办理人
|
||||
if (variable.containsKey(flowTask.getNodeCode()) && TaskStatusEnum.isPassOrBack(flowParams.getHisStatus())) {
|
||||
String userIds = variable.get(flowTask.getNodeCode()).toString();
|
||||
flowTask.setPermissionList(List.of(userIds.split(StringUtils.SEPARATOR)));
|
||||
variable.remove(flowTask.getNodeCode());
|
||||
String nodeCode = flowTask.getNodeCode();
|
||||
|
||||
// 处理办理或退回时指定办理人的情况
|
||||
if (TaskStatusEnum.PASS.getStatus().equals(hisStatus)) {
|
||||
processTaskPermission(variable, flowTask, hisStatus);
|
||||
} else if (TaskStatusEnum.BACK.getStatus().equals(hisStatus)) {
|
||||
processTaskPermission(variable, flowTask, hisStatus);
|
||||
}
|
||||
|
||||
// 如果是申请节点,则把启动人添加到办理人
|
||||
if (flowTask.getNodeCode().equals(applyNodeCode)) {
|
||||
if (nodeCode.equals(applyNodeCode) && StringUtils.isNotBlank(instance.getCreateBy())) {
|
||||
flowTask.setPermissionList(List.of(instance.getCreateBy()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理任务权限设置
|
||||
*
|
||||
* @param variable 变量集合
|
||||
* @param flowTask 流程任务
|
||||
* @param taskStatus 任务状态
|
||||
*/
|
||||
private void processTaskPermission(Map<String, Object> variable, Task flowTask, String taskStatus) {
|
||||
String nodeKey = taskStatus + StrUtil.COLON + flowTask.getNodeCode();
|
||||
|
||||
// 检查是否存在状态相关的变量
|
||||
if (!variable.containsKey(nodeKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取用户ID字符串
|
||||
Object userIdsObj = variable.get(nodeKey);
|
||||
if (userIdsObj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String userIds = userIdsObj.toString();
|
||||
if (StringUtils.isBlank(userIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 分割用户ID并设置权限列表
|
||||
String[] userIdArray = userIds.split(StringUtils.SEPARATOR);
|
||||
if (userIdArray.length > 0) {
|
||||
flowTask.setPermissionList(List.of(userIdArray));
|
||||
// 移除已处理的状态变量
|
||||
variable.remove(nodeKey);
|
||||
FlowEngine.insService().removeVariables(flowTask.getInstanceId(),nodeKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成监听器,当前任务完成后执行
|
||||
*
|
||||
@@ -118,7 +186,8 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
//申请人提交事件
|
||||
Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT);
|
||||
if (submit != null && submit) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true);
|
||||
String status = determineFlowStatus(instance);
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, status, variable, true);
|
||||
} else {
|
||||
// 判断流程状态(发布:撤销,退回,作废,终止,已完成事件)
|
||||
String status = determineFlowStatus(instance);
|
||||
@@ -132,7 +201,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, BusinessStatusEnum.BACK.getStatus(), params, false);
|
||||
// 修改流程实例状态
|
||||
instance.setFlowStatus(BusinessStatusEnum.BACK.getStatus());
|
||||
insService.updateById(instance);
|
||||
FlowEngine.insService().updateById(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,19 +223,18 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
}
|
||||
|
||||
if (variable.containsKey(FlowConstant.FLOW_COPY_LIST)) {
|
||||
List<FlowCopyBo> flowCopyList = MapUtil.get(variable, FlowConstant.FLOW_COPY_LIST, new TypeReference<>() {});
|
||||
List<FlowCopyBo> flowCopyList = MapUtil.get(variable, FlowConstant.FLOW_COPY_LIST, new TypeReference<>() {
|
||||
});
|
||||
// 添加抄送人
|
||||
flwTaskService.setCopy(task, flowCopyList);
|
||||
}
|
||||
if (variable.containsKey(FlowConstant.MESSAGE_TYPE)) {
|
||||
List<String> messageType = MapUtil.get(variable, FlowConstant.MESSAGE_TYPE, new TypeReference<>() {});
|
||||
List<String> messageType = MapUtil.get(variable, FlowConstant.MESSAGE_TYPE, new TypeReference<>() {
|
||||
});
|
||||
String notice = MapUtil.getStr(variable, FlowConstant.MESSAGE_NOTICE);
|
||||
// 消息通知
|
||||
if (CollUtil.isNotEmpty(messageType)) {
|
||||
flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice);
|
||||
}
|
||||
flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice);
|
||||
}
|
||||
insService.removeVariables(instance.getId(),
|
||||
FlowEngine.insService().removeVariables(instance.getId(),
|
||||
FlowConstant.FLOW_COPY_LIST,
|
||||
FlowConstant.MESSAGE_TYPE,
|
||||
FlowConstant.MESSAGE_NOTICE,
|
||||
@@ -190,7 +258,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
if (flwTaskService.isTaskEnd(instanceId)) {
|
||||
String status = BusinessStatusEnum.FINISH.getStatus();
|
||||
// 更新流程状态为已完成
|
||||
instanceService.updateStatus(instanceId, status);
|
||||
flwInstanceService.updateStatus(instanceId, status);
|
||||
log.info("流程已结束,状态更新为: {}", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.dromara.workflow.domain.vo.FlowSpelVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义Mapper接口
|
||||
* 流程spel表达式定义Mapper接口
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
|
||||
@@ -75,7 +75,7 @@ public interface IFlwInstanceService {
|
||||
* @param businessIds 业务id
|
||||
* @return 结果
|
||||
*/
|
||||
boolean deleteByBusinessIds(List<Long> businessIds);
|
||||
boolean deleteByBusinessIds(List<String> businessIds);
|
||||
|
||||
/**
|
||||
* 按照实例id删除流程实例
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.dromara.workflow.service;
|
||||
|
||||
import org.dromara.workflow.domain.vo.ButtonPermissionVo;
|
||||
import org.dromara.workflow.domain.vo.NodeExtVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程节点扩展属性 服务层
|
||||
@@ -12,11 +12,24 @@ import java.util.List;
|
||||
public interface IFlwNodeExtService {
|
||||
|
||||
/**
|
||||
* 从扩展属性构建按钮权限列表:根据 ext 中记录的权限值,标记每个按钮是否勾选
|
||||
* 解析扩展属性 JSON 并构建 Node 扩展属性对象
|
||||
* <p>
|
||||
* 根据传入的 JSON 字符串,将扩展属性分为三类:
|
||||
* 1. ButtonPermissionEnum:解析为按钮权限列表,标记每个按钮是否勾选
|
||||
* 2. CopySettingEnum:解析为抄送对象 ID 集合
|
||||
* 3. VariablesEnum:解析为自定义参数 Map
|
||||
*
|
||||
* @param ext 扩展属性 JSON 字符串
|
||||
* @return 按钮权限 VO 列表
|
||||
* <p>示例 JSON:
|
||||
* [
|
||||
* {"code": "ButtonPermissionEnum", "value": "back,termination"},
|
||||
* {"code": "CopySettingEnum", "value": "1"},
|
||||
* {"code": "VariablesEnum", "value": "key1=value1,key2=value2"}
|
||||
* ]
|
||||
*
|
||||
* @param ext 扩展属性 JSON 字符串
|
||||
* @param variable 流程变量
|
||||
* @return NodeExtVo 对象,封装按钮权限列表、抄送对象集合和自定义参数 Map
|
||||
*/
|
||||
List<ButtonPermissionVo> buildButtonPermissionsFromExt(String ext);
|
||||
NodeExtVo parseNodeExt(String ext, Map<String, Object> variable);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义Service接口
|
||||
* 流程spel表达式定义Service接口
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
@@ -20,48 +20,48 @@ import java.util.Map;
|
||||
public interface IFlwSpelService {
|
||||
|
||||
/**
|
||||
* 查询流程spel达式定义
|
||||
* 查询流程spel表达式定义
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 流程spel达式定义
|
||||
* @return 流程spel表达式定义
|
||||
*/
|
||||
FlowSpelVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询流程spel达式定义列表
|
||||
* 分页查询流程spel表达式定义列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 流程spel达式定义分页列表
|
||||
* @return 流程spel表达式定义分页列表
|
||||
*/
|
||||
TableDataInfo<FlowSpelVo> queryPageList(FlowSpelBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的流程spel达式定义列表
|
||||
* 查询符合条件的流程spel表达式定义列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 流程spel达式定义列表
|
||||
* @return 流程spel表达式定义列表
|
||||
*/
|
||||
List<FlowSpelVo> queryList(FlowSpelBo bo);
|
||||
|
||||
/**
|
||||
* 新增流程spel达式定义
|
||||
* 新增流程spel表达式定义
|
||||
*
|
||||
* @param bo 流程spel达式定义
|
||||
* @param bo 流程spel表达式定义
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(FlowSpelBo bo);
|
||||
|
||||
/**
|
||||
* 修改流程spel达式定义
|
||||
* 修改流程spel表达式定义
|
||||
*
|
||||
* @param bo 流程spel达式定义
|
||||
* @param bo 流程spel表达式定义
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(FlowSpelBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除流程spel达式定义信息
|
||||
* 校验并批量删除流程spel表达式定义信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.dromara.warm.flow.orm.mapper.FlowHisTaskMapper;
|
||||
import org.dromara.warm.flow.ui.service.ChartExtService;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -48,6 +49,8 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
private final DeptService deptService;
|
||||
private final FlowHisTaskMapper flowHisTaskMapper;
|
||||
private final DictService dictService;
|
||||
@Value("${warm-flow.node-tooltip:true}")
|
||||
private boolean nodeTooltip;
|
||||
|
||||
/**
|
||||
* 设置流程图提示信息
|
||||
@@ -56,6 +59,11 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
*/
|
||||
@Override
|
||||
public void execute(DefJson defJson) {
|
||||
// 配置关闭,直接返回,不渲染悬浮窗
|
||||
if (!nodeTooltip) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据流程实例ID查询所有相关的历史任务列表
|
||||
List<FlowHisTask> flowHisTasks = this.getHisTaskGroupedByNode(defJson.getInstance().getId());
|
||||
if (CollUtil.isEmpty(flowHisTasks)) {
|
||||
@@ -103,6 +111,11 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
*/
|
||||
@Override
|
||||
public void initPromptContent(DefJson defJson) {
|
||||
// 配置关闭,直接返回,不渲染悬浮窗
|
||||
if (!nodeTooltip) {
|
||||
return;
|
||||
}
|
||||
|
||||
defJson.setTopText("流程名称: " + defJson.getFlowName());
|
||||
defJson.getNodeList().forEach(nodeJson -> {
|
||||
nodeJson.setPromptContent(
|
||||
@@ -152,8 +165,10 @@ public class FlwChartExtServiceImpl implements ChartExtService {
|
||||
/**
|
||||
* 处理节点的扩展信息,构建用于流程图悬浮提示的内容
|
||||
*
|
||||
* @param nodeJson 当前节点对象
|
||||
* @param taskList 当前节点对应的历史审批任务列表
|
||||
* @param nodeJson 当前流程节点对象,包含节点基础信息和提示内容容器
|
||||
* @param taskList 当前节点关联的历史审批任务列表,用于生成提示信息
|
||||
* @param userMap 用户信息映射表,key 为用户ID,value 为用户DTO对象,用于获取审批人信息
|
||||
* @param dictType 数据字典映射表,key 为字典项编码,value 为对应显示值,用于翻译审批状态等
|
||||
*/
|
||||
private void processNodeExtInfo(NodeJson nodeJson, List<FlowHisTask> taskList, Map<Long, UserDTO> userMap, Map<String, String> dictType) {
|
||||
|
||||
|
||||
@@ -11,9 +11,8 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mail.utils.MailUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
import org.dromara.warm.flow.core.enums.SkipType;
|
||||
import org.dromara.warm.flow.core.service.NodeService;
|
||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
||||
@@ -21,8 +20,10 @@ import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,19 +36,27 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
private final NodeService nodeService;
|
||||
|
||||
private static final String DEFAULT_SUBJECT = "单据审批提醒";
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* 根据流程实例发送消息给当前处理人
|
||||
*
|
||||
* @param flowName 流程定义名称
|
||||
* @param messageType 消息类型
|
||||
* @param message 消息内容,为空则发送默认配置的消息内容
|
||||
* @param instId 流程实例ID
|
||||
* @param messageType 消息类型列表
|
||||
* @param message 消息内容,为空则使用默认消息
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(String flowName, Long instId, List<String> messageType, String message) {
|
||||
if (CollUtil.isEmpty(messageType)) {
|
||||
return;
|
||||
}
|
||||
IFlwTaskService flwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
||||
List<FlowTask> list = flwTaskService.selectByInstId(instId);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isBlank(message)) {
|
||||
message = "有新的【" + flowName + "】单据已经提交至您,请您及时处理。";
|
||||
}
|
||||
@@ -55,43 +64,52 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return;
|
||||
}
|
||||
sendMessage(messageType, message, "单据审批提醒", userList);
|
||||
sendMessage(messageType, message, DEFAULT_SUBJECT, userList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* 发送消息给指定用户列表
|
||||
*
|
||||
* @param messageType 消息类型
|
||||
* @param messageType 消息类型列表
|
||||
* @param message 消息内容
|
||||
* @param subject 邮件标题
|
||||
* @param userList 接收用户
|
||||
* @param userList 接收用户列表
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(List<String> messageType, String message, String subject, List<UserDTO> userList) {
|
||||
if (CollUtil.isEmpty(messageType) || CollUtil.isEmpty(userList)) {
|
||||
return;
|
||||
}
|
||||
List<Long> userIds = new ArrayList<>(StreamUtils.toSet(userList, UserDTO::getUserId));
|
||||
Set<String> emails = StreamUtils.toSet(userList, UserDTO::getEmail);
|
||||
|
||||
for (String code : messageType) {
|
||||
MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code);
|
||||
if (ObjectUtil.isEmpty(messageTypeEnum)) {
|
||||
continue;
|
||||
}
|
||||
switch (messageTypeEnum) {
|
||||
case SYSTEM_MESSAGE -> {
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
dto.setUserIds(StreamUtils.toList(userList, UserDTO::getUserId).stream().distinct().collect(Collectors.toList()));
|
||||
dto.setMessage(message);
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
try {
|
||||
switch (messageTypeEnum) {
|
||||
case SYSTEM_MESSAGE -> {
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
dto.setUserIds(userIds);
|
||||
dto.setMessage(message);
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
}
|
||||
case EMAIL_MESSAGE -> MailUtils.sendText(emails, subject, message);
|
||||
case SMS_MESSAGE -> {
|
||||
// TODO: 补充短信发送逻辑
|
||||
log.info("【短信发送 - TODO】用户数量={} 内容={}", userList.size(), message);
|
||||
}
|
||||
default -> log.warn("【消息发送】未处理的消息类型:{}", messageTypeEnum);
|
||||
}
|
||||
case EMAIL_MESSAGE -> {
|
||||
MailUtils.sendText(StreamUtils.join(userList, UserDTO::getEmail), subject, message);
|
||||
}
|
||||
case SMS_MESSAGE -> {
|
||||
//todo 短信发送
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + messageTypeEnum);
|
||||
} catch (Exception ex) {
|
||||
// 记录错误但不抛出,确保主逻辑不受影响
|
||||
log.error("【消息发送失败】类型={},原因={}", messageTypeEnum, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 申请人节点编码
|
||||
*
|
||||
@@ -100,8 +118,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
*/
|
||||
@Override
|
||||
public String applyNodeCode(Long definitionId) {
|
||||
Node startNode = nodeService.getStartNode(definitionId);
|
||||
Node nextNode = nodeService.getNextNode(definitionId, startNode.getNodeCode(), null, SkipType.PASS.getKey());
|
||||
return nextNode.getNodeCode();
|
||||
List<Node> firstBetweenNode = FlowEngine.nodeService().getFirstBetweenNode(definitionId, new HashMap<>());
|
||||
return firstBetweenNode.get(0).getNodeCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteByBusinessIds(List<Long> businessIds) {
|
||||
List<FlowInstance> flowInstances = flowInstanceMapper.selectList(new LambdaQueryWrapper<FlowInstance>().in(FlowInstance::getBusinessId, StreamUtils.toList(businessIds, Convert::toStr)));
|
||||
public boolean deleteByBusinessIds(List<String> businessIds) {
|
||||
List<FlowInstance> flowInstances = flowInstanceMapper.selectList(new LambdaQueryWrapper<FlowInstance>().in(FlowInstance::getBusinessId, businessIds));
|
||||
if (CollUtil.isEmpty(flowInstances)) {
|
||||
log.warn("未找到对应的流程实例信息,无法执行删除操作。");
|
||||
return false;
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.DictTypeDTO;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.utils.CollUtil;
|
||||
import org.dromara.warm.flow.core.utils.ExpressionUtil;
|
||||
import org.dromara.warm.flow.ui.service.NodeExtService;
|
||||
import org.dromara.warm.flow.ui.vo.NodeExt;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
@@ -17,12 +20,12 @@ import org.dromara.workflow.common.enums.CopySettingEnum;
|
||||
import org.dromara.workflow.common.enums.NodeExtEnum;
|
||||
import org.dromara.workflow.common.enums.VariablesEnum;
|
||||
import org.dromara.workflow.domain.vo.ButtonPermissionVo;
|
||||
import org.dromara.workflow.domain.vo.NodeExtVo;
|
||||
import org.dromara.workflow.service.IFlwNodeExtService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 流程设计器-节点扩展属性
|
||||
@@ -45,7 +48,7 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
||||
CopySettingEnum.class.getSimpleName(),
|
||||
Map.of(
|
||||
"label", "抄送对象",
|
||||
"type", 2,
|
||||
"type", 5,
|
||||
"must", false,
|
||||
"multiple", false,
|
||||
"desc", "设置该节点的抄送办理人"
|
||||
@@ -56,7 +59,7 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
||||
"type", 2,
|
||||
"must", false,
|
||||
"multiple", false,
|
||||
"desc", "节点执行时可以使用的自定义参数"
|
||||
"desc", "节点执行时可设置自定义参数,多个参数以逗号分隔,如:key1=value1,key2=value2"
|
||||
),
|
||||
ButtonPermissionEnum.class.getSimpleName(),
|
||||
Map.of(
|
||||
@@ -137,7 +140,7 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
||||
childNode.setCode(simpleName);
|
||||
// label名称
|
||||
childNode.setLabel(Convert.toStr(map.get("label")));
|
||||
// 1:输入框 2:文本域 3:下拉框 4:选择框
|
||||
// 1:输入框 2:文本域 3:下拉框 4:选择框 5:用户选择器
|
||||
childNode.setType(Convert.toInt(map.get("type"), 1));
|
||||
// 是否必填
|
||||
childNode.setMust(Convert.toBool(map.get("must"), false));
|
||||
@@ -170,7 +173,7 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
||||
childNode.setCode(dictType);
|
||||
// label名称
|
||||
childNode.setLabel(dictTypeDTO.getDictName());
|
||||
// 1:输入框 2:文本域 3:下拉框 4:选择框
|
||||
// 1:输入框 2:文本域 3:下拉框 4:选择框 5:用户选择器
|
||||
childNode.setType(3);
|
||||
// 是否必填
|
||||
childNode.setMust(false);
|
||||
@@ -187,73 +190,165 @@ public class FlwNodeExtServiceImpl implements NodeExtService, IFlwNodeExtService
|
||||
}
|
||||
|
||||
/**
|
||||
* 从扩展属性构建按钮权限列表:根据 ext 中记录的权限值,标记每个按钮是否勾选
|
||||
* 解析扩展属性 JSON 并构建 Node 扩展属性对象
|
||||
* <p>
|
||||
* 根据传入的 JSON 字符串,将扩展属性分为三类:
|
||||
* 1. ButtonPermissionEnum:解析为按钮权限列表,标记每个按钮是否勾选
|
||||
* 2. CopySettingEnum:解析为抄送对象 ID 集合
|
||||
* 3. VariablesEnum:解析为自定义参数 Map
|
||||
*
|
||||
* @param ext 扩展属性 JSON 字符串
|
||||
* @return 按钮权限 VO 列表
|
||||
* <p>示例 JSON:
|
||||
* [
|
||||
* {"code": "ButtonPermissionEnum", "value": "back,termination"},
|
||||
* {"code": "CopySettingEnum", "value": "1,3,4,#{@spelRuleComponent.selectDeptLeaderById(#deptId", "#roleId)}"},
|
||||
* {"code": "VariablesEnum", "value": "key1=value1,key2=value2"}
|
||||
* ]
|
||||
*
|
||||
* @param ext 扩展属性 JSON 字符串
|
||||
* @param variable 流程变量
|
||||
* @return NodeExtVo 对象,封装按钮权限列表、抄送对象集合和自定义参数 Map
|
||||
*/
|
||||
@Override
|
||||
public List<ButtonPermissionVo> buildButtonPermissionsFromExt(String ext) {
|
||||
// 解析 ext 为 Map<code, Set<value>>,用于标记权限
|
||||
Map<String, Set<String>> permissionMap = JsonUtils.parseArray(ext, ButtonPermissionVo.class)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
ButtonPermissionVo::getCode,
|
||||
item -> StringUtils.splitList(item.getValue()).stream()
|
||||
.map(String::trim)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toSet()),
|
||||
(a, b) -> b,
|
||||
HashMap::new
|
||||
));
|
||||
public NodeExtVo parseNodeExt(String ext, Map<String, Object> variable) {
|
||||
NodeExtVo nodeExtVo = new NodeExtVo();
|
||||
|
||||
// 构建按钮权限列表,标记哪些按钮在 permissionMap 中出现(表示已勾选)
|
||||
return buildPermissionsFromSources(permissionMap, List.of(ButtonPermissionEnum.class));
|
||||
// 解析 JSON 为 Dict 列表
|
||||
List<Dict> nodeExtMap = JsonUtils.parseArrayMap(ext);
|
||||
if (ObjectUtil.isEmpty(nodeExtMap)) {
|
||||
return nodeExtVo;
|
||||
}
|
||||
|
||||
for (Dict nodeExt : nodeExtMap) {
|
||||
String code = nodeExt.getStr("code");
|
||||
String value = nodeExt.getStr("value");
|
||||
|
||||
if (ButtonPermissionEnum.class.getSimpleName().equals(code)) {
|
||||
// 解析按钮权限
|
||||
// 将 value 拆分为 Set<String>,便于精确匹配
|
||||
Set<String> buttonSet = StringUtils.str2Set(value, StringUtils.SEPARATOR);
|
||||
|
||||
// 获取按钮字典配置
|
||||
NodeExt.ChildNode childNode = buildChildNode(ButtonPermissionEnum.class);
|
||||
|
||||
// 构建 ButtonPermissionVo 列表
|
||||
List<ButtonPermissionVo> buttonList = Optional.ofNullable(childNode)
|
||||
.map(NodeExt.ChildNode::getDict)
|
||||
.orElse(List.of())
|
||||
.stream()
|
||||
.map(dict -> new ButtonPermissionVo(dict.getValue(), buttonSet.contains(dict.getValue())))
|
||||
.toList();
|
||||
|
||||
nodeExtVo.setButtonPermissions(buttonList);
|
||||
|
||||
} else if (CopySettingEnum.class.getSimpleName().equals(code)) {
|
||||
List<String> permissions = spelSmartSplit(value).stream()
|
||||
.map(s -> {
|
||||
List<String> result = ExpressionUtil.evalVariable(s, variable);
|
||||
if (CollUtil.isNotEmpty(result)) {
|
||||
return result;
|
||||
}
|
||||
return Collections.singletonList(s);
|
||||
}).filter(Objects::nonNull)
|
||||
.flatMap(List::stream)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<String> copySettings = FlowEngine.permissionHandler().convertPermissions(permissions);
|
||||
// 解析抄送对象 ID 集合
|
||||
nodeExtVo.setCopySettings(new HashSet<>(copySettings));
|
||||
|
||||
} else if (VariablesEnum.class.getSimpleName().equals(code)) {
|
||||
// 解析自定义参数
|
||||
// 将 key=value 字符串拆分为 Map
|
||||
Map<String, String> variables = Arrays.stream(StringUtils.split(value, StringUtils.SEPARATOR))
|
||||
.map(s -> StringUtils.split(s, "="))
|
||||
.filter(arr -> arr.length == 2)
|
||||
.collect(Collectors.toMap(arr -> arr[0], arr -> arr[1]));
|
||||
|
||||
nodeExtVo.setVariables(variables);
|
||||
} else {
|
||||
// 未知扩展类型,记录日志
|
||||
log.warn("未知扩展类型:code={}, value={}", code, value);
|
||||
}
|
||||
}
|
||||
return nodeExtVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将权限映射与按钮权限来源(枚举类或字典类型)进行匹配,生成权限视图列表
|
||||
* <p>
|
||||
* 使用说明:
|
||||
* - sources 支持传入多个来源类型,支持 NodeExtEnum 枚举类 或 字典类型字符串(dictType)
|
||||
* - 若需要扩展更多按钮权限,只需在 sources 中新增对应的枚举类或字典类型
|
||||
* <p>
|
||||
* 示例:
|
||||
* buildPermissionsFromSources(permissionMap, List.of(ButtonPermissionEnum.class, "custom_button_dict"));
|
||||
*
|
||||
* @param permissionMap 权限映射
|
||||
* @param sources 枚举类或字典类型列表
|
||||
* @return 按钮权限视图对象列表
|
||||
* 按逗号分割字符串,但保留 #{...} 表达式和字符串常量中的逗号
|
||||
*/
|
||||
@SuppressWarnings("unchecked cast")
|
||||
private List<ButtonPermissionVo> buildPermissionsFromSources(Map<String, Set<String>> permissionMap, List<Object> sources) {
|
||||
return sources.stream()
|
||||
.flatMap(source -> {
|
||||
if (source instanceof Class<?> clazz && NodeExtEnum.class.isAssignableFrom(clazz)) {
|
||||
Set<String> selectedSet = permissionMap.getOrDefault(clazz.getSimpleName(), Collections.emptySet());
|
||||
return extractDictItems(this.buildChildNode((Class<? extends NodeExtEnum>) clazz), selectedSet).stream();
|
||||
} else if (source instanceof String dictType) {
|
||||
Set<String> selectedSet = permissionMap.getOrDefault(dictType, Collections.emptySet());
|
||||
return extractDictItems(this.buildChildNode(dictType), selectedSet).stream();
|
||||
private static List<String> spelSmartSplit(String str) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
StringBuilder token = new StringBuilder();
|
||||
// #{...} 的嵌套深度
|
||||
int depth = 0;
|
||||
// 是否在字符串常量中(" 或 ')
|
||||
boolean inString = false;
|
||||
// 当前字符串引号类型
|
||||
char stringQuote = 0;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
|
||||
// 检测进入 SpEL 表达式 #{...}
|
||||
if (!inString && c == '#' && depth == 0 && checkNext(str, i, '{')) {
|
||||
depth++;
|
||||
token.append("#{");
|
||||
// 跳过 {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 在表达式中遇到 { 或 } 改变嵌套深度
|
||||
if (!inString && depth > 0) {
|
||||
if (c == '{') {
|
||||
depth++;
|
||||
} else if (c == '}') {
|
||||
depth--;
|
||||
}
|
||||
return Stream.empty();
|
||||
}).toList();
|
||||
token.append(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检测字符串开始/结束
|
||||
if (depth > 0 && (c == '"' || c == '\'')) {
|
||||
if (!inString) {
|
||||
inString = true;
|
||||
stringQuote = c;
|
||||
} else if (stringQuote == c) {
|
||||
inString = false;
|
||||
}
|
||||
token.append(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 外层逗号才分割
|
||||
if (c == ',' && depth == 0 && !inString) {
|
||||
String part = token.toString().trim();
|
||||
if (!part.isEmpty()) {
|
||||
result.add(part);
|
||||
}
|
||||
token.setLength(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
token.append(c);
|
||||
}
|
||||
|
||||
// 添加最后一个
|
||||
String part = token.toString().trim();
|
||||
if (!part.isEmpty()) {
|
||||
result.add(part);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从节点子项中提取字典项,并构建按钮权限视图对象列表
|
||||
*
|
||||
* @param childNode 子节点
|
||||
* @param selectedSet 已选中的值集
|
||||
* @return 按钮权限视图对象列表
|
||||
*/
|
||||
private List<ButtonPermissionVo> extractDictItems(NodeExt.ChildNode childNode, Set<String> selectedSet) {
|
||||
return Optional.ofNullable(childNode)
|
||||
.map(NodeExt.ChildNode::getDict)
|
||||
.orElse(List.of())
|
||||
.stream()
|
||||
.map(dict -> new ButtonPermissionVo(dict.getValue(), selectedSet.contains(dict.getValue())))
|
||||
.toList();
|
||||
private static boolean checkNext(String str, int index, char expected) {
|
||||
return index + 1 < str.length() && str.charAt(index + 1) == expected;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义Service业务层处理
|
||||
* 流程spel表达式定义Service业务层处理
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
@@ -42,10 +42,10 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
private final FlwSpelMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询流程spel达式定义
|
||||
* 查询流程spel表达式定义
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 流程spel达式定义
|
||||
* @return 流程spel表达式定义
|
||||
*/
|
||||
@Override
|
||||
public FlowSpelVo queryById(Long id){
|
||||
@@ -53,11 +53,11 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询流程spel达式定义列表
|
||||
* 分页查询流程spel表达式定义列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 流程spel达式定义分页列表
|
||||
* @return 流程spel表达式定义分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<FlowSpelVo> queryPageList(FlowSpelBo bo, PageQuery pageQuery) {
|
||||
@@ -67,10 +67,10 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的流程spel达式定义列表
|
||||
* 查询符合条件的流程spel表达式定义列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 流程spel达式定义列表
|
||||
* @return 流程spel表达式定义列表
|
||||
*/
|
||||
@Override
|
||||
public List<FlowSpelVo> queryList(FlowSpelBo bo) {
|
||||
@@ -92,9 +92,9 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程spel达式定义
|
||||
* 新增流程spel表达式定义
|
||||
*
|
||||
* @param bo 流程spel达式定义
|
||||
* @param bo 流程spel表达式定义
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@@ -109,9 +109,9 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程spel达式定义
|
||||
* 修改流程spel表达式定义
|
||||
*
|
||||
* @param bo 流程spel达式定义
|
||||
* @param bo 流程spel表达式定义
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@@ -129,7 +129,7 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除流程spel达式定义信息
|
||||
* 校验并批量删除流程spel表达式定义信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
@@ -46,8 +47,10 @@ import org.dromara.workflow.common.enums.TaskAssigneeType;
|
||||
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
import org.dromara.workflow.domain.bo.*;
|
||||
import org.dromara.workflow.domain.vo.FlowCopyVo;
|
||||
import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||
import org.dromara.workflow.domain.vo.NodeExtVo;
|
||||
import org.dromara.workflow.mapper.FlwCategoryMapper;
|
||||
import org.dromara.workflow.mapper.FlwInstanceBizExtMapper;
|
||||
import org.dromara.workflow.mapper.FlwTaskMapper;
|
||||
@@ -135,6 +138,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
|
||||
// 将流程定义内的扩展参数设置到变量中
|
||||
Definition definition = FlowEngine.defService().getPublishByFlowCode(startProcessBo.getFlowCode());
|
||||
if (ObjectUtil.isNull(definition)) {
|
||||
throw new ServiceException("流程【" + startProcessBo.getFlowCode() + "】未发布,请先在流程设计器中发布流程定义");
|
||||
}
|
||||
Dict dict = JsonUtils.parseMap(definition.getExt());
|
||||
boolean autoPass = !ObjectUtil.isNull(dict) && dict.getBool(FlowConstant.AUTO_PASS);
|
||||
variables.put(FlowConstant.AUTO_PASS, autoPass);
|
||||
@@ -303,10 +309,12 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
List<String> variableUserIds = Arrays.asList(userIds.split(StringUtils.SEPARATOR));
|
||||
hashSet.addAll(popUserIds);
|
||||
hashSet.addAll(variableUserIds);
|
||||
map.put(entry.getKey(), StringUtils.joinComma(hashSet));
|
||||
map.put(TaskStatusEnum.PASS.getStatus() + StrUtil.COLON + entry.getKey(), StringUtils.joinComma(hashSet));
|
||||
map.put(TaskStatusEnum.BACK.getStatus() + StrUtil.COLON + entry.getKey(), StringUtils.joinComma(hashSet));
|
||||
}
|
||||
} else {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
map.put(TaskStatusEnum.PASS.getStatus() + StrUtil.COLON + entry.getKey(), entry.getValue());
|
||||
map.put(TaskStatusEnum.BACK.getStatus() + StrUtil.COLON + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@@ -380,7 +388,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo);
|
||||
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey());
|
||||
queryWrapper.in("t.approver", LoginHelper.getUserIdStr());
|
||||
queryWrapper.orderByDesc("t.create_time").orderByDesc("t.update_time");
|
||||
Page<FlowHisTaskVo> page = flwTaskMapper.getListFinishTask(pageQuery.build(), queryWrapper);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
@@ -455,7 +462,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
List<Long> categoryIds = flwCategoryMapper.selectCategoryIdsByParentId(Convert.toLong(flowTaskBo.getCategory()));
|
||||
wrapper.in("t.category", StreamUtils.toList(categoryIds, Convert::toStr));
|
||||
}
|
||||
wrapper.orderByDesc("t.create_time");
|
||||
wrapper.orderByDesc("t.create_time").orderByDesc("t.update_time");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -483,9 +490,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
|
||||
Map<String, Object> variable = new HashMap<>();
|
||||
// 消息类型
|
||||
variable.put("messageType", messageType);
|
||||
variable.put(FlowConstant.MESSAGE_TYPE, messageType);
|
||||
// 消息通知
|
||||
variable.put("notice", notice);
|
||||
variable.put(FlowConstant.MESSAGE_NOTICE, notice);
|
||||
|
||||
FlowParams flowParams = FlowParams.build()
|
||||
.nodeCode(bo.getNodeCode())
|
||||
@@ -528,8 +535,20 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
//获取可驳回的前置节点
|
||||
List<Node> nodes = nodeService.previousNodeList(task.getDefinitionId(), nowNodeCode);
|
||||
if (CollUtil.isNotEmpty(nodes)) {
|
||||
return StreamUtils.filter(nodes, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
|
||||
List<HisTask> taskList = hisTaskService.getByInsId(task.getInstanceId());
|
||||
|
||||
Map<String, Node> nodeMap = StreamUtils.toIdentityMap(nodes, Node::getNodeCode);
|
||||
List<Node> backNodeList = new ArrayList<>();
|
||||
for (HisTask hisTask : taskList) {
|
||||
Node nodeValue = nodeMap.get(hisTask.getNodeCode());
|
||||
if (nodeValue != null) {
|
||||
backNodeList.add(nodeValue);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(backNodeList)) {
|
||||
List<Node> prefixOrSuffixNodes = StreamUtils.filter(backNodeList, e -> NodeType.BETWEEN.getKey().equals(e.getNodeType()));
|
||||
Collections.reverse(prefixOrSuffixNodes);
|
||||
return prefixOrSuffixNodes;
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
@@ -597,8 +616,24 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
if (ObjectUtil.isNull(flowNode)) {
|
||||
throw new NullPointerException("当前【" + flowTaskVo.getNodeCode() + "】节点编码不存在");
|
||||
}
|
||||
NodeExtVo nodeExtVo = flwNodeExtService.parseNodeExt(flowNode.getExt(), instance.getVariableMap());
|
||||
//设置按钮权限
|
||||
flowTaskVo.setButtonList(flwNodeExtService.buildButtonPermissionsFromExt(flowNode.getExt()));
|
||||
if (CollUtil.isNotEmpty(nodeExtVo.getButtonPermissions())) {
|
||||
flowTaskVo.setButtonList(nodeExtVo.getButtonPermissions());
|
||||
} else {
|
||||
flowTaskVo.setButtonList(new ArrayList<>());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nodeExtVo.getCopySettings())) {
|
||||
List<FlowCopyVo> list = StreamUtils.toList(nodeExtVo.getCopySettings(), x -> new FlowCopyVo(Convert.toLong(x)));
|
||||
flowTaskVo.setCopyList(list);
|
||||
} else {
|
||||
flowTaskVo.setCopyList(new ArrayList<>());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nodeExtVo.getVariables())) {
|
||||
flowTaskVo.setVarList(nodeExtVo.getVariables());
|
||||
} else {
|
||||
flowTaskVo.setVarList(new HashMap<>());
|
||||
}
|
||||
flowTaskVo.setNodeRatio(flowNode.getNodeRatio());
|
||||
flowTaskVo.setApplyNode(flowNode.getNodeCode().equals(flwCommonService.applyNodeCode(task.getDefinitionId())));
|
||||
return flowTaskVo;
|
||||
@@ -628,14 +663,14 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
//办理人变量替换
|
||||
ExpressionUtil.evalVariable(buildNextTaskList, FlowParams.build().variable(mergeVariable));
|
||||
for (FlowNode flowNode : nextFlowNodes) {
|
||||
Task first = StreamUtils.findFirst(buildNextTaskList, t -> t.getNodeCode().equals(flowNode.getNodeCode()));
|
||||
if (ObjectUtil.isNotNull(first) && CollUtil.isNotEmpty(first.getPermissionList())) {
|
||||
List<UserDTO> users = flwTaskAssigneeService.fetchUsersByStorageIds(StringUtils.joinComma(first.getPermissionList()));
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
flowNode.setPermissionFlag(StreamUtils.join(users, e -> Convert.toStr(e.getUserId())));
|
||||
}
|
||||
}
|
||||
|
||||
StreamUtils.findFirst(buildNextTaskList, t -> t.getNodeCode().equals(flowNode.getNodeCode()))
|
||||
.ifPresent(first -> {
|
||||
List<UserDTO> users;
|
||||
if (CollUtil.isNotEmpty(first.getPermissionList())
|
||||
&& CollUtil.isNotEmpty(users = flwTaskAssigneeService.fetchUsersByStorageIds(StringUtils.joinComma(first.getPermissionList())))) {
|
||||
flowNode.setPermissionFlag(StreamUtils.join(users, e -> Convert.toStr(e.getUserId())));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return nextFlowNodes;
|
||||
@@ -721,7 +756,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
Long taskId = bo.getTaskId();
|
||||
Task task = taskService.getById(taskId);
|
||||
FlowNode flowNode = getByNodeCode(task.getNodeCode(), task.getDefinitionId());
|
||||
if ("addSignature".equals(taskOperation) || "reductionSignature".equals(taskOperation)) {
|
||||
if (ADD_SIGNATURE.equals(taskOperation) || REDUCTION_SIGNATURE.equals(taskOperation)) {
|
||||
if (flowNode.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw new ServiceException(task.getNodeName() + "不是会签节点!");
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@ import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.WorkflowService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.domain.TestLeave;
|
||||
import org.dromara.workflow.domain.bo.TestLeaveBo;
|
||||
import org.dromara.workflow.domain.vo.TestLeaveVo;
|
||||
@@ -166,7 +168,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(List<Long> ids) {
|
||||
workflowService.deleteInstance(ids);
|
||||
workflowService.deleteInstance(StreamUtils.toList(ids, Convert::toStr));
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@@ -193,12 +195,15 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
|
||||
String message = Convert.toStr(params.get("message"));
|
||||
}
|
||||
if (processEvent.getSubmit()) {
|
||||
if(StringUtils.isBlank(testLeave.getApplyCode())){
|
||||
String businessCode = MapUtil.getStr(params, "businessCode",StrUtil.EMPTY);
|
||||
if (StringUtils.isBlank(testLeave.getApplyCode())) {
|
||||
String businessCode = MapUtil.getStr(params, FlowConstant.BUSINESS_CODE, StrUtil.EMPTY);
|
||||
testLeave.setApplyCode(businessCode);
|
||||
}
|
||||
testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus());
|
||||
log.info("申请人提交");
|
||||
}
|
||||
String status = BusinessStatusEnum.findByStatus(processEvent.getStatus());
|
||||
log.info("当前流程状态为{}", status);
|
||||
baseMapper.updateById(testLeave);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.warm.flow.orm.entity.FlowInstance;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
import org.dromara.workflow.domain.bo.CompleteTaskBo;
|
||||
import org.dromara.workflow.domain.bo.StartProcessBo;
|
||||
import org.dromara.workflow.service.IFlwDefinitionService;
|
||||
@@ -45,7 +46,7 @@ public class WorkflowServiceImpl implements WorkflowService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteInstance(List<Long> businessIds) {
|
||||
public boolean deleteInstance(List<String> businessIds) {
|
||||
return flwInstanceService.deleteByBusinessIds(businessIds);
|
||||
}
|
||||
|
||||
@@ -166,6 +167,7 @@ public class WorkflowServiceImpl implements WorkflowService {
|
||||
processBo.setFlowCode(startProcess.getFlowCode());
|
||||
processBo.setVariables(startProcess.getVariables());
|
||||
processBo.setHandler(startProcess.getHandler());
|
||||
processBo.setBizExt(BeanUtil.toBean(startProcess.getBizExt(), FlowInstanceBizExt.class));
|
||||
|
||||
StartProcessReturnDTO result = flwTaskService.startWorkFlow(processBo);
|
||||
CompleteTaskBo taskBo = new CompleteTaskBo();
|
||||
|
||||
@@ -99,7 +99,7 @@ services:
|
||||
network_mode: "host"
|
||||
|
||||
ruoyi-server1:
|
||||
image: ruoyi/ruoyi-server:5.4.1
|
||||
image: ruoyi/ruoyi-server:5.5.1
|
||||
container_name: ruoyi-server1
|
||||
environment:
|
||||
# 时区上海
|
||||
@@ -115,7 +115,7 @@ services:
|
||||
network_mode: "host"
|
||||
|
||||
ruoyi-server2:
|
||||
image: ruoyi/ruoyi-server:5.4.1
|
||||
image: ruoyi/ruoyi-server:5.5.1
|
||||
container_name: ruoyi-server2
|
||||
environment:
|
||||
# 时区上海
|
||||
@@ -131,7 +131,7 @@ services:
|
||||
network_mode: "host"
|
||||
|
||||
ruoyi-monitor-admin:
|
||||
image: ruoyi/ruoyi-monitor-admin:5.4.1
|
||||
image: ruoyi/ruoyi-monitor-admin:5.5.1
|
||||
container_name: ruoyi-monitor-admin
|
||||
environment:
|
||||
# 时区上海
|
||||
@@ -143,7 +143,7 @@ services:
|
||||
network_mode: "host"
|
||||
|
||||
ruoyi-snailjob-server:
|
||||
image: ruoyi/ruoyi-snailjob-server:5.4.1
|
||||
image: ruoyi/ruoyi-snailjob-server:5.5.1
|
||||
container_name: ruoyi-snailjob-server
|
||||
environment:
|
||||
# 时区上海
|
||||
|
||||
@@ -4,18 +4,30 @@ error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
# 可以根据业务并发量适当调高
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
# 高效传输文件
|
||||
sendfile on;
|
||||
# 长连接超时时间
|
||||
keepalive_timeout 65;
|
||||
# 单连接最大请求数,提高长连接复用率
|
||||
keepalive_requests 100000;
|
||||
# 限制body大小
|
||||
client_max_body_size 100m;
|
||||
client_header_buffer_size 32k;
|
||||
client_body_buffer_size 512k;
|
||||
# 开启静态资源压缩
|
||||
gzip_static on;
|
||||
# 连接数限制 (防御类配置) 10m 一般够用了,能存储上万 IP 的计数
|
||||
limit_conn_zone $binary_remote_addr zone=perip:10m;
|
||||
limit_conn_zone $server_name zone=perserver:10m;
|
||||
# 隐藏 nginx 版本号,防止暴露版本信息
|
||||
server_tokens off;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
@@ -50,7 +62,7 @@ http {
|
||||
#ssl_certificate_key /etc/nginx/cert/xxx.local.key; # /etc/nginx/cert/ 为docker映射路径 不允许更改
|
||||
#ssl_session_timeout 5m;
|
||||
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
||||
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
#ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1;
|
||||
#ssl_prefer_server_ciphers on;
|
||||
# https配置参考 end
|
||||
|
||||
@@ -76,17 +88,29 @@ http {
|
||||
}
|
||||
|
||||
location /prod-api/ {
|
||||
# 设置客户端请求头中的 Host 信息(保持原始 Host)
|
||||
proxy_set_header Host $http_host;
|
||||
# 获取客户端真实 IP
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
# 自定义头 REMOTE-HOST,记录客户端 IP
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
# 获取完整的客户端 IP 链(经过多级代理时)
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# 设置后端响应超时时间(这里是 24 小时,适合长连接/SSE)
|
||||
proxy_read_timeout 86400s;
|
||||
# sse 与 websocket参数
|
||||
# SSE (Server-Sent Events) 与 WebSocket 支持参数
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
# 禁用代理缓冲,数据直接传给客户端
|
||||
proxy_buffering off;
|
||||
# 禁用代理缓存
|
||||
proxy_cache off;
|
||||
# 按 IP 限制连接数(防 CC 攻击) 小型站:10~20 就够 中型站:50~100
|
||||
limit_conn perip 20;
|
||||
|
||||
# 按 Server 限制总并发连接数 根据服务器的最大并发处理能力来定 太小会限制合法用户访问,太大会占满服务器资源
|
||||
limit_conn perserver 500;
|
||||
proxy_pass http://server/;
|
||||
}
|
||||
|
||||
@@ -94,23 +118,37 @@ http {
|
||||
# 解决方案1 将 admin 服务 也配置成 https
|
||||
# 解决方案2 将菜单配置为外链访问 走独立页面 http 访问
|
||||
location /admin/ {
|
||||
# 设置客户端请求头中的 Host 信息(保持原始 Host)
|
||||
proxy_set_header Host $http_host;
|
||||
# 获取客户端真实 IP
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
# 自定义头 REMOTE-HOST,记录客户端 IP
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
# 获取完整的客户端 IP 链(经过多级代理时)
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# 禁用代理缓冲,数据直接传给客户端
|
||||
proxy_buffering off;
|
||||
# 禁用代理缓存
|
||||
proxy_cache off;
|
||||
proxy_pass http://monitor-admin/admin/;
|
||||
}
|
||||
|
||||
location /snail-job/ {
|
||||
# 设置客户端请求头中的 Host 信息(保持原始 Host)
|
||||
proxy_set_header Host $http_host;
|
||||
# 获取客户端真实 IP
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
# 自定义头 REMOTE-HOST,记录客户端 IP
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
# 获取完整的客户端 IP 链(经过多级代理时)
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# sse 与 websocket参数
|
||||
# SSE (Server-Sent Events) 与 WebSocket 支持参数
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
# 禁用代理缓冲,直接传输给客户端
|
||||
proxy_buffering off;
|
||||
# 禁用代理缓存
|
||||
proxy_cache off;
|
||||
proxy_pass http://snailjob-server/snail-job/;
|
||||
}
|
||||
|
||||
@@ -1,75 +1,129 @@
|
||||
{
|
||||
"flowCode" : "leave1",
|
||||
"flowName" : "请假申请-普通",
|
||||
"category" : "100",
|
||||
"version" : "1",
|
||||
"formCustom" : "N",
|
||||
"formPath" : "/workflow/leaveEdit/index",
|
||||
"nodeList" : [ {
|
||||
"nodeType" : 0,
|
||||
"nodeCode" : "d5ee3ddf-3968-4379-a86f-9ceabde5faac",
|
||||
"nodeName" : "开始",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "200,200|200,200",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "d5ee3ddf-3968-4379-a86f-9ceabde5faac",
|
||||
"nextNodeCode" : "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "220,200;310,200"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"nodeName" : "申请人",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "360,200|360,200",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"nextNodeCode" : "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "410,200;490,200"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"nodeName" : "组长",
|
||||
"permissionFlag" : "role:1",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "540,200|540,200",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination\"}]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"nextNodeCode" : "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "590,200;670,200"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"nodeName" : "部门主管",
|
||||
"permissionFlag" : "role:3@@role:4",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "720,200|720,200",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination\"}]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"nextNodeCode" : "8b82b7d7-8660-455e-b880-d6d22ea3eb6d",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "770,200;880,200"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 2,
|
||||
"nodeCode" : "8b82b7d7-8660-455e-b880-d6d22ea3eb6d",
|
||||
"nodeName" : "结束",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "900,200|900,200",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]"
|
||||
} ]
|
||||
"nodeList": [
|
||||
{
|
||||
"nodeType": "0",
|
||||
"nodeCode": "d5ee3ddf-3968-4379-a86f-9ceabde5faac",
|
||||
"nodeName": "开始",
|
||||
"permissionFlag": null,
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": null,
|
||||
"listenerPath": null,
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[]",
|
||||
"coordinate": "200,200|200,200",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "d5ee3ddf-3968-4379-a86f-9ceabde5faac",
|
||||
"nextNodeCode": "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"coordinate": "220,200;310,200"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"nodeName": "申请人",
|
||||
"permissionFlag": "",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,file,copy\"}]",
|
||||
"coordinate": "360,200|360,200",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "dd515cdd-59f6-446f-94ca-25ca062afb42",
|
||||
"nextNodeCode": "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"coordinate": "410,200;490,200"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"nodeName": "组长",
|
||||
"permissionFlag": "role:1",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,copy,transfer,trust,file\"}]",
|
||||
"coordinate": "540,200|540,200",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "78fa8e5b-e809-44ed-978a-41092409ebcf",
|
||||
"nextNodeCode": "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"coordinate": "590,200;670,200"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"nodeName": "部门主管",
|
||||
"permissionFlag": "role:3@@role:4",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,copy,transfer,trust,file\"}]",
|
||||
"coordinate": "720,200|720,200",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "a8abf15f-b83e-428a-86cc-033555ea9bbe",
|
||||
"nextNodeCode": "8b82b7d7-8660-455e-b880-d6d22ea3eb6d",
|
||||
"coordinate": "770,200;880,200"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "2",
|
||||
"nodeCode": "8b82b7d7-8660-455e-b880-d6d22ea3eb6d",
|
||||
"nodeName": "结束",
|
||||
"permissionFlag": null,
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": null,
|
||||
"listenerPath": null,
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[]",
|
||||
"coordinate": "900,200|900,200",
|
||||
"version": "1",
|
||||
"skipList": []
|
||||
}
|
||||
],
|
||||
"flowCode": "leave1",
|
||||
"flowName": "请假申请-普通",
|
||||
"modelValue": "CLASSICS",
|
||||
"category": "103",
|
||||
"version": "1",
|
||||
"formCustom": "N",
|
||||
"formPath": "/workflow/leaveEdit/index",
|
||||
"listenerType": null,
|
||||
"listenerPath": null
|
||||
}
|
||||
|
||||
@@ -1,111 +1,187 @@
|
||||
{
|
||||
"flowCode" : "leave2",
|
||||
"flowName" : "请假申请-排他网关",
|
||||
"category" : "100",
|
||||
"version" : "1",
|
||||
"formCustom" : "N",
|
||||
"formPath" : "/workflow/leaveEdit/index",
|
||||
"nodeList" : [ {
|
||||
"nodeType" : 0,
|
||||
"nodeCode" : "cef3895c-f7d8-4598-8bf3-8ec2ef6ce84a",
|
||||
"nodeName" : "开始",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "300,240|300,240",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "cef3895c-f7d8-4598-8bf3-8ec2ef6ce84a",
|
||||
"nextNodeCode" : "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "320,240;390,240"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"nodeName" : "申请人",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "440,240|440,240",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"nextNodeCode" : "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "490,240;535,240"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 3,
|
||||
"nodeCode" : "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "560,240",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"nextNodeCode" : "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"skipType" : "PASS",
|
||||
"skipCondition" : "le@@leaveDays|2",
|
||||
"coordinate" : "560,265;560,320;670,320"
|
||||
}, {
|
||||
"nowNodeCode" : "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"nextNodeCode" : "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"skipName" : "大于两天",
|
||||
"skipType" : "PASS",
|
||||
"skipCondition" : "gt@@leaveDays|2",
|
||||
"coordinate" : "560,215;560,160;670,160|560,187"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"nodeName" : "组长",
|
||||
"permissionFlag" : "3@@4",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "720,320|720,320",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination\"}]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"nextNodeCode" : "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "770,320;860,320;860,280"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"nodeName" : "总经理",
|
||||
"permissionFlag" : "role:1",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "860,240|860,240",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"nextNodeCode" : "40aa65fd-0712-4d23-b6f7-d0432b920fd1",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "910,240;980,240"
|
||||
} ]
|
||||
}, {
|
||||
"nodeType" : 2,
|
||||
"nodeCode" : "40aa65fd-0712-4d23-b6f7-d0432b920fd1",
|
||||
"nodeName" : "结束",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "1000,240|1000,240",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[]"
|
||||
}, {
|
||||
"nodeType" : 1,
|
||||
"nodeCode" : "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"nodeName" : "部门领导",
|
||||
"permissionFlag" : "role:1",
|
||||
"nodeRatio" : 0.000,
|
||||
"coordinate" : "720,160|720,160",
|
||||
"formCustom" : "N",
|
||||
"ext" : "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination\"}]",
|
||||
"skipList" : [ {
|
||||
"nowNodeCode" : "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"nextNodeCode" : "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"skipType" : "PASS",
|
||||
"coordinate" : "770,160;860,160;860,200"
|
||||
} ]
|
||||
} ]
|
||||
"nodeList": [
|
||||
{
|
||||
"nodeType": "0",
|
||||
"nodeCode": "cef3895c-f7d8-4598-8bf3-8ec2ef6ce84a",
|
||||
"nodeName": "开始",
|
||||
"permissionFlag": null,
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": null,
|
||||
"listenerPath": null,
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[]",
|
||||
"coordinate": "300,240|300,240",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "cef3895c-f7d8-4598-8bf3-8ec2ef6ce84a",
|
||||
"nextNodeCode": "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"coordinate": "320,240;390,240"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"nodeName": "申请人",
|
||||
"permissionFlag": "",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,file\"}]",
|
||||
"coordinate": "440,240|440,240",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "fdcae93b-b69c-498a-b231-09255e74bcbd",
|
||||
"nextNodeCode": "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"coordinate": "490,240;535,240"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "3",
|
||||
"nodeCode": "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"permissionFlag": null,
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": null,
|
||||
"listenerPath": null,
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[]",
|
||||
"coordinate": "560,240",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": "le@@leaveDays|2",
|
||||
"skipName": null,
|
||||
"nowNodeCode": "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"nextNodeCode": "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"coordinate": "560,265;560,320;670,320"
|
||||
},
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": "gt@@leaveDays|2",
|
||||
"skipName": "大于两天",
|
||||
"nowNodeCode": "7b8c7ead-7dc8-4951-a7f3-f0c41995909e",
|
||||
"nextNodeCode": "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"coordinate": "560,215;560,160;670,160|560,187"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"nodeName": "组长",
|
||||
"permissionFlag": "3@@4",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,file,transfer,trust,copy\"}]",
|
||||
"coordinate": "720,320|720,320",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "b3528155-dcb7-4445-bbdf-3d00e3499e86",
|
||||
"nextNodeCode": "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"coordinate": "770,320;860,320;860,280"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"nodeName": "总经理",
|
||||
"permissionFlag": "role:1",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,file,transfer,trust,copy\"}]",
|
||||
"coordinate": "860,240|860,240",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"nextNodeCode": "40aa65fd-0712-4d23-b6f7-d0432b920fd1",
|
||||
"coordinate": "910,240;980,240"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeType": "2",
|
||||
"nodeCode": "40aa65fd-0712-4d23-b6f7-d0432b920fd1",
|
||||
"nodeName": "结束",
|
||||
"permissionFlag": null,
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": null,
|
||||
"listenerPath": null,
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[]",
|
||||
"coordinate": "1000,240|1000,240",
|
||||
"version": "1",
|
||||
"skipList": []
|
||||
},
|
||||
{
|
||||
"nodeType": "1",
|
||||
"nodeCode": "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"nodeName": "部门领导",
|
||||
"permissionFlag": "role:1",
|
||||
"nodeRatio": "0.000",
|
||||
"anyNodeSkip": null,
|
||||
"listenerType": "",
|
||||
"listenerPath": "",
|
||||
"formCustom": "N",
|
||||
"formPath": null,
|
||||
"ext": "[{\"code\":\"ButtonPermissionEnum\",\"value\":\"back,termination,file,transfer,trust,copy\"}]",
|
||||
"coordinate": "720,160|720,160",
|
||||
"version": "1",
|
||||
"skipList": [
|
||||
{
|
||||
"skipType": "PASS",
|
||||
"skipCondition": null,
|
||||
"skipName": null,
|
||||
"nowNodeCode": "5ed2362b-fc0c-4d52-831f-95208b830605",
|
||||
"nextNodeCode": "c9fa6d7d-2a74-4e78-b947-0cad8a6af869",
|
||||
"nextNodeType": "1",
|
||||
"coordinate": "770,160;860,160;860,200"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"flowCode": "leave2",
|
||||
"flowName": "请假申请-排他网关",
|
||||
"modelValue": "CLASSICS",
|
||||
"category": "103",
|
||||
"version": "1",
|
||||
"formCustom": "N",
|
||||
"formPath": "/workflow/leaveEdit/index",
|
||||
"listenerType": null,
|
||||
"listenerPath": null
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user