mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-20 02:06:38 +08:00
发布 v4.2.0
This commit is contained in:
parent
e0527b3350
commit
c5f4dec559
@ -1,4 +1,4 @@
|
|||||||
### 更改目的 解决了什么问题
|
### 更改目的 解决了什么问题(请提交到dev分支)
|
||||||
|
|
||||||
|
|
||||||
### 描述 做了哪些改动
|
### 描述 做了哪些改动
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE)
|
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE)
|
||||||
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
||||||
<br>
|
<br>
|
||||||
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
@ -42,6 +42,7 @@
|
|||||||
| 分布式任务调度 | Xxl-Job | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/) | 高性能 高可靠 易扩展 |
|
| 分布式任务调度 | Xxl-Job | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/) | 高性能 高可靠 易扩展 |
|
||||||
| 文件存储 | Minio | [Minio文档](https://docs.min.io/) | 本地存储 |
|
| 文件存储 | Minio | [Minio文档](https://docs.min.io/) | 本地存储 |
|
||||||
| 文件存储 | 七牛、阿里、腾讯 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | 云存储 |
|
| 文件存储 | 七牛、阿里、腾讯 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | 云存储 |
|
||||||
|
| 短信模块 | 阿里、腾讯 | [短信使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5578491&doc_id=1469725) | 短信发送 |
|
||||||
| 监控框架 | SpringBoot-Admin | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/) | 全方位服务监控 |
|
| 监控框架 | SpringBoot-Admin | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/) | 全方位服务监控 |
|
||||||
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
||||||
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
||||||
|
89
pom.xml
89
pom.xml
@ -6,49 +6,46 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<version>4.1.0</version>
|
<version>4.2.0</version>
|
||||||
|
|
||||||
<name>RuoYi-Vue-Plus</name>
|
<name>RuoYi-Vue-Plus</name>
|
||||||
<url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url>
|
<url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url>
|
||||||
<description>RuoYi-Vue-Plus后台管理系统</description>
|
<description>RuoYi-Vue-Plus后台管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi-vue-plus.version>4.1.0</ruoyi-vue-plus.version>
|
<ruoyi-vue-plus.version>4.2.0</ruoyi-vue-plus.version>
|
||||||
<spring-boot.version>2.6.7</spring-boot.version>
|
<spring-boot.version>2.6.9</spring-boot.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
||||||
<spring-boot.mybatis>2.2.0</spring-boot.mybatis>
|
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
||||||
<druid.version>1.2.8</druid.version>
|
<druid.version>1.2.11</druid.version>
|
||||||
<knife4j.version>3.0.3</knife4j.version>
|
<knife4j.version>3.0.3</knife4j.version>
|
||||||
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>5.2.2</poi.version>
|
||||||
<commons-compress.version>1.21</commons-compress.version>
|
<easyexcel.version>3.1.1</easyexcel.version>
|
||||||
<easyexcel.version>3.0.5</easyexcel.version>
|
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<satoken.version>1.29.0</satoken.version>
|
<satoken.version>1.30.0</satoken.version>
|
||||||
<mybatis-plus.version>3.5.1</mybatis-plus.version>
|
<mybatis-plus.version>3.5.2</mybatis-plus.version>
|
||||||
<p6spy.version>3.9.1</p6spy.version>
|
<p6spy.version>3.9.1</p6spy.version>
|
||||||
<hutool.version>5.7.22</hutool.version>
|
<hutool.version>5.8.3</hutool.version>
|
||||||
<okhttp.version>4.9.3</okhttp.version>
|
<okhttp.version>4.9.3</okhttp.version>
|
||||||
<spring-boot-admin.version>2.6.6</spring-boot-admin.version>
|
<spring-boot-admin.version>2.6.7</spring-boot-admin.version>
|
||||||
<redisson.version>3.17.0</redisson.version>
|
<redisson.version>3.17.4</redisson.version>
|
||||||
<lock4j.version>2.2.1</lock4j.version>
|
<lock4j.version>2.2.1</lock4j.version>
|
||||||
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
<dynamic-ds.version>3.5.1</dynamic-ds.version>
|
||||||
<tlog.version>1.3.6</tlog.version>
|
<tlog.version>1.4.3</tlog.version>
|
||||||
<xxl-job.version>2.3.0</xxl-job.version>
|
<xxl-job.version>2.3.1</xxl-job.version>
|
||||||
|
|
||||||
<!-- jdk11 缺失依赖 jaxb-->
|
|
||||||
<jaxb.version>3.0.1</jaxb.version>
|
|
||||||
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
||||||
<guava.version>30.0-jre</guava.version>
|
<guava.version>30.0-jre</guava.version>
|
||||||
|
|
||||||
<!-- OSS 配置 -->
|
<!-- OSS 配置 -->
|
||||||
<qiniu.version>7.9.5</qiniu.version>
|
<aws-java-sdk-s3.version>1.12.248</aws-java-sdk-s3.version>
|
||||||
<aliyun.oss.version>3.14.0</aliyun.oss.version>
|
<!-- SMS 配置 -->
|
||||||
<qcloud.cos.version>5.6.72</qcloud.cos.version>
|
<aliyun.sms.version>2.0.9</aliyun.sms.version>
|
||||||
<minio.version>8.3.8</minio.version>
|
<tencent.sms.version>3.1.537</tencent.sms.version>
|
||||||
|
|
||||||
<!-- docker 配置 -->
|
<!-- docker 配置 -->
|
||||||
<docker.registry.url>localhost</docker.registry.url>
|
<docker.registry.url>localhost</docker.registry.url>
|
||||||
@ -105,29 +102,21 @@
|
|||||||
<version>${swagger-annotations.version}</version>
|
<version>${swagger-annotations.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 修复poi漏洞 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-compress</artifactId>
|
|
||||||
<version>${commons-compress.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
<version>${easyexcel.version}</version>
|
<version>${easyexcel.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml-schemas</artifactId>
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
@ -155,13 +144,6 @@
|
|||||||
<version>${satoken.version}</version>
|
<version>${satoken.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- jdk11 缺失依赖 jaxb-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-impl</artifactId>
|
|
||||||
<version>${jaxb.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- dynamic-datasource 多数据源-->
|
<!-- dynamic-datasource 多数据源-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
@ -192,6 +174,24 @@
|
|||||||
<version>${okhttp.version}</version>
|
<version>${okhttp.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
|
<version>${aws-java-sdk-s3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
|
<version>${aliyun.sms.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
|
<version>${tencent.sms.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||||
@ -248,6 +248,13 @@
|
|||||||
<version>${tlog.version}</version>
|
<version>${tlog.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.1.0</version>
|
<version>4.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>ruoyi-extend</artifactId>
|
<artifactId>ruoyi-extend</artifactId>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-extend</artifactId>
|
<artifactId>ruoyi-extend</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.1.0</version>
|
<version>4.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-extend</artifactId>
|
<artifactId>ruoyi-extend</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.1.0</version>
|
<version>4.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>ruoyi-xxl-job-admin</artifactId>
|
<artifactId>ruoyi-xxl-job-admin</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -56,13 +56,13 @@ public class IndexController {
|
|||||||
@PermissionLimit(limit = false)
|
@PermissionLimit(limit = false)
|
||||||
public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
|
public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
|
||||||
if (loginService.ifLogin(request, response) != null) {
|
if (loginService.ifLogin(request, response) != null) {
|
||||||
modelAndView.setView(new RedirectView("/" , true, false));
|
modelAndView.setView(new RedirectView("/", true, false));
|
||||||
return modelAndView;
|
return modelAndView;
|
||||||
}
|
}
|
||||||
return new ModelAndView("login");
|
return new ModelAndView("login");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "login" , method = RequestMethod.POST)
|
@RequestMapping(value = "login", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PermissionLimit(limit = false)
|
@PermissionLimit(limit = false)
|
||||||
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
|
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
|
||||||
@ -70,7 +70,7 @@ public class IndexController {
|
|||||||
return loginService.login(request, response, userName, password, ifRem);
|
return loginService.login(request, response, userName, password, ifRem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "logout" , method = RequestMethod.POST)
|
@RequestMapping(value = "logout", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PermissionLimit(limit = false)
|
@PermissionLimit(limit = false)
|
||||||
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
|
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
@ -37,19 +37,19 @@ public class JobApiController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping("/{uri}")
|
@RequestMapping("/{uri}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PermissionLimit(limit=false)
|
@PermissionLimit(limit = false)
|
||||||
public ReturnT<String> api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = false) String data) {
|
public ReturnT<String> api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = false) String data) {
|
||||||
|
|
||||||
// valid
|
// valid
|
||||||
if (!"POST".equalsIgnoreCase(request.getMethod())) {
|
if (!"POST".equalsIgnoreCase(request.getMethod())) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
|
||||||
}
|
}
|
||||||
if (uri==null || uri.trim().length()==0) {
|
if (uri == null || uri.trim().length() == 0) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
|
||||||
}
|
}
|
||||||
if (XxlJobAdminConfig.getAdminConfig().getAccessToken()!=null
|
if (XxlJobAdminConfig.getAdminConfig().getAccessToken() != null
|
||||||
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
|
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length() > 0
|
||||||
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
|
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class JobApiController {
|
|||||||
RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class);
|
RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class);
|
||||||
return adminBiz.registryRemove(registryParam);
|
return adminBiz.registryRemove(registryParam);
|
||||||
} else {
|
} else {
|
||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping(" + uri + ") not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@ public class JobCodeController {
|
|||||||
JobInfoController.validPermission(request, jobInfo.getJobGroup());
|
JobInfoController.validPermission(request, jobInfo.getJobGroup());
|
||||||
|
|
||||||
// Glue类型-字典
|
// Glue类型-字典
|
||||||
model.addAttribute("GlueTypeEnum" , GlueTypeEnum.values());
|
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());
|
||||||
|
|
||||||
model.addAttribute("jobInfo" , jobInfo);
|
model.addAttribute("jobInfo", jobInfo);
|
||||||
model.addAttribute("jobLogGlues" , jobLogGlues);
|
model.addAttribute("jobLogGlues", jobLogGlues);
|
||||||
return "jobcode/jobcode.index";
|
return "jobcode/jobcode.index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ public class JobGroupController {
|
|||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<String, Object>();
|
||||||
maps.put("recordsTotal" , list_count); // 总记录数
|
maps.put("recordsTotal", list_count); // 总记录数
|
||||||
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
||||||
maps.put("data" , list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ public class JobInfoController {
|
|||||||
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) {
|
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) {
|
||||||
|
|
||||||
// 枚举-字典
|
// 枚举-字典
|
||||||
model.addAttribute("ExecutorRouteStrategyEnum" , ExecutorRouteStrategyEnum.values()); // 路由策略-列表
|
model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表
|
||||||
model.addAttribute("GlueTypeEnum" , GlueTypeEnum.values()); // Glue类型-字典
|
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典
|
||||||
model.addAttribute("ExecutorBlockStrategyEnum" , ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
|
||||||
model.addAttribute("ScheduleTypeEnum" , ScheduleTypeEnum.values()); // 调度类型
|
model.addAttribute("ScheduleTypeEnum", ScheduleTypeEnum.values()); // 调度类型
|
||||||
model.addAttribute("MisfireStrategyEnum" , MisfireStrategyEnum.values()); // 调度过期策略
|
model.addAttribute("MisfireStrategyEnum", MisfireStrategyEnum.values()); // 调度过期策略
|
||||||
|
|
||||||
// 执行器列表
|
// 执行器列表
|
||||||
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
|
||||||
@ -64,8 +64,8 @@ public class JobInfoController {
|
|||||||
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("JobGroupList" , jobGroupList);
|
model.addAttribute("JobGroupList", jobGroupList);
|
||||||
model.addAttribute("jobGroup" , jobGroup);
|
model.addAttribute("jobGroup", jobGroup);
|
||||||
|
|
||||||
return "jobinfo/jobinfo.index";
|
return "jobinfo/jobinfo.index";
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.xxl.job.admin.controller;
|
package com.xxl.job.admin.controller;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.complete.XxlJobCompleter;
|
|
||||||
import com.xxl.job.admin.core.exception.XxlJobException;
|
import com.xxl.job.admin.core.exception.XxlJobException;
|
||||||
|
import com.xxl.job.admin.core.complete.XxlJobCompleter;
|
||||||
import com.xxl.job.admin.core.model.XxlJobGroup;
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
||||||
import com.xxl.job.admin.core.model.XxlJobLog;
|
import com.xxl.job.admin.core.model.XxlJobLog;
|
||||||
@ -60,7 +60,7 @@ public class JobLogController {
|
|||||||
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("JobGroupList" , jobGroupList);
|
model.addAttribute("JobGroupList", jobGroupList);
|
||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
if (jobId > 0) {
|
if (jobId > 0) {
|
||||||
@ -69,7 +69,7 @@ public class JobLogController {
|
|||||||
throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid"));
|
throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("jobInfo" , jobInfo);
|
model.addAttribute("jobInfo", jobInfo);
|
||||||
|
|
||||||
// valid permission
|
// valid permission
|
||||||
JobInfoController.validPermission(request, jobInfo.getJobGroup());
|
JobInfoController.validPermission(request, jobInfo.getJobGroup());
|
||||||
@ -112,9 +112,9 @@ public class JobLogController {
|
|||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<String, Object>();
|
||||||
maps.put("recordsTotal" , list_count); // 总记录数
|
maps.put("recordsTotal", list_count); // 总记录数
|
||||||
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
||||||
maps.put("data" , list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +128,11 @@ public class JobLogController {
|
|||||||
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAttribute("triggerCode" , jobLog.getTriggerCode());
|
model.addAttribute("triggerCode", jobLog.getTriggerCode());
|
||||||
model.addAttribute("handleCode" , jobLog.getHandleCode());
|
model.addAttribute("handleCode", jobLog.getHandleCode());
|
||||||
model.addAttribute("executorAddress" , jobLog.getExecutorAddress());
|
model.addAttribute("executorAddress", jobLog.getExecutorAddress());
|
||||||
model.addAttribute("triggerTime" , jobLog.getTriggerTime().getTime());
|
model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
|
||||||
model.addAttribute("logId" , jobLog.getId());
|
model.addAttribute("logId", jobLog.getId());
|
||||||
return "joblog/joblog.detail";
|
return "joblog/joblog.detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class UserController {
|
|||||||
|
|
||||||
// 执行器列表
|
// 执行器列表
|
||||||
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
|
||||||
model.addAttribute("groupList" , groupList);
|
model.addAttribute("groupList", groupList);
|
||||||
|
|
||||||
return "user/user.index";
|
return "user/user.index";
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ public class UserController {
|
|||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<String, Object>();
|
||||||
maps.put("recordsTotal" , list_count); // 总记录数
|
maps.put("recordsTotal", list_count); // 总记录数
|
||||||
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
||||||
maps.put("data" , list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,14 @@ public class CookieInterceptor implements AsyncHandlerInterceptor {
|
|||||||
for (Cookie ck : request.getCookies()) {
|
for (Cookie ck : request.getCookies()) {
|
||||||
cookieMap.put(ck.getName(), ck);
|
cookieMap.put(ck.getName(), ck);
|
||||||
}
|
}
|
||||||
modelAndView.addObject("cookieMap" , cookieMap);
|
modelAndView.addObject("cookieMap", cookieMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static method
|
// static method
|
||||||
if (modelAndView != null) {
|
if (modelAndView != null) {
|
||||||
modelAndView.addObject("I18nUtil" , FtlUtil.generateStaticModel(I18nUtil.class.getName()));
|
modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncHandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
|
|||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
|
||||||
if (!(handler instanceof HandlerMethod)) {
|
if (!(handler instanceof HandlerMethod)) {
|
||||||
return AsyncHandlerInterceptor.super.preHandle(request, response, handler);
|
return true; // proceed with the next interceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
// if need login
|
// if need login
|
||||||
@ -44,7 +44,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
|
|||||||
XxlJobUser loginUser = loginService.ifLogin(request, response);
|
XxlJobUser loginUser = loginService.ifLogin(request, response);
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
response.setStatus(302);
|
response.setStatus(302);
|
||||||
response.setHeader("location" , request.getContextPath() + "/toLogin");
|
response.setHeader("location", request.getContextPath() + "/toLogin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (needAdminuser && loginUser.getRole() != 1) {
|
if (needAdminuser && loginUser.getRole() != 1) {
|
||||||
@ -53,7 +53,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
|
|||||||
request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser);
|
request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AsyncHandlerInterceptor.super.preHandle(request, response, handler);
|
return true; // proceed with the next interceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.xxl.job.admin.controller.resolver;
|
package com.xxl.job.admin.controller.resolver;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.exception.XxlJobException;
|
import com.xxl.job.admin.core.exception.XxlJobException;
|
||||||
import com.xxl.job.admin.core.util.JacksonUtil;
|
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
|
import com.xxl.job.admin.core.util.JacksonUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -29,7 +29,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
|
|||||||
HttpServletResponse response, Object handler, Exception ex) {
|
HttpServletResponse response, Object handler, Exception ex) {
|
||||||
|
|
||||||
if (!(ex instanceof XxlJobException)) {
|
if (!(ex instanceof XxlJobException)) {
|
||||||
logger.error("WebExceptionResolver:{}" , ex);
|
logger.error("WebExceptionResolver:{}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if json
|
// if json
|
||||||
@ -43,7 +43,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// error result
|
// error result
|
||||||
ReturnT<String> errorResult = new ReturnT<String>(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n" , "<br/>"));
|
ReturnT<String> errorResult = new ReturnT<String>(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n", "<br/>"));
|
||||||
|
|
||||||
// response
|
// response
|
||||||
ModelAndView mv = new ModelAndView();
|
ModelAndView mv = new ModelAndView();
|
||||||
@ -57,7 +57,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
|
|||||||
return mv;
|
return mv;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
mv.addObject("exceptionMsg" , errorResult.getMsg());
|
mv.addObject("exceptionMsg", errorResult.getMsg());
|
||||||
mv.setViewName("/common/common.exception");
|
mv.setViewName("/common/common.exception");
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ public class JobAlarmer implements ApplicationContextAware, InitializingBean {
|
|||||||
public boolean alarm(XxlJobInfo info, XxlJobLog jobLog) {
|
public boolean alarm(XxlJobInfo info, XxlJobLog jobLog) {
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (jobAlarmList!=null && jobAlarmList.size()>0) {
|
if (jobAlarmList != null && jobAlarmList.size() > 0) {
|
||||||
result = true; // success means all-success
|
result = true; // success means all-success
|
||||||
for (JobAlarm alarm: jobAlarmList) {
|
for (JobAlarm alarm : jobAlarmList) {
|
||||||
boolean resultItem = false;
|
boolean resultItem = false;
|
||||||
try {
|
try {
|
||||||
resultItem = alarm.doAlarm(info, jobLog);
|
resultItem = alarm.doAlarm(info, jobLog);
|
||||||
|
@ -32,18 +32,19 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
*
|
*
|
||||||
* @param jobLog
|
* @param jobLog
|
||||||
*/
|
*/
|
||||||
public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog){
|
@Override
|
||||||
|
public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog) {
|
||||||
boolean alarmResult = true;
|
boolean alarmResult = true;
|
||||||
|
|
||||||
// send monitor email
|
// send monitor email
|
||||||
if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) {
|
if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) {
|
||||||
|
|
||||||
// alarmContent
|
// alarmContent
|
||||||
String alarmContent = "Alarm Job LogId=" + jobLog.getId();
|
String alarmContent = "Alarm Job LogId=" + jobLog.getId();
|
||||||
if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) {
|
if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) {
|
||||||
alarmContent += "<br>TriggerMsg=<br>" + jobLog.getTriggerMsg();
|
alarmContent += "<br>TriggerMsg=<br>" + jobLog.getTriggerMsg();
|
||||||
}
|
}
|
||||||
if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) {
|
if (jobLog.getHandleCode() > 0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) {
|
||||||
alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg();
|
alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,13 +53,13 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
String personal = I18nUtil.getString("admin_name_full");
|
String personal = I18nUtil.getString("admin_name_full");
|
||||||
String title = I18nUtil.getString("jobconf_monitor");
|
String title = I18nUtil.getString("jobconf_monitor");
|
||||||
String content = MessageFormat.format(loadEmailJobAlarmTemplate(),
|
String content = MessageFormat.format(loadEmailJobAlarmTemplate(),
|
||||||
group!=null?group.getTitle():"null",
|
group != null ? group.getTitle() : "null",
|
||||||
info.getId(),
|
info.getId(),
|
||||||
info.getJobDesc(),
|
info.getJobDesc(),
|
||||||
alarmContent);
|
alarmContent);
|
||||||
|
|
||||||
Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(",")));
|
Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(",")));
|
||||||
for (String email: emailSet) {
|
for (String email : emailSet) {
|
||||||
|
|
||||||
// make mail
|
// make mail
|
||||||
try {
|
try {
|
||||||
@ -88,28 +89,28 @@ public class EmailJobAlarm implements JobAlarm {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static final String loadEmailJobAlarmTemplate(){
|
private static final String loadEmailJobAlarmTemplate() {
|
||||||
String mailBodyTemplate = "<h5>" + I18nUtil.getString("jobconf_monitor_detail") + ":</span>" +
|
String mailBodyTemplate = "<h5>" + I18nUtil.getString("jobconf_monitor_detail") + ":</span>" +
|
||||||
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
|
||||||
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
|
||||||
" <tr>\n" +
|
" <tr>\n" +
|
||||||
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobgroup") +"</td>\n" +
|
" <td width=\"20%\" >" + I18nUtil.getString("jobinfo_field_jobgroup") + "</td>\n" +
|
||||||
" <td width=\"10%\" >"+ I18nUtil.getString("jobinfo_field_id") +"</td>\n" +
|
" <td width=\"10%\" >" + I18nUtil.getString("jobinfo_field_id") + "</td>\n" +
|
||||||
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobdesc") +"</td>\n" +
|
" <td width=\"20%\" >" + I18nUtil.getString("jobinfo_field_jobdesc") + "</td>\n" +
|
||||||
" <td width=\"10%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_title") +"</td>\n" +
|
" <td width=\"10%\" >" + I18nUtil.getString("jobconf_monitor_alarm_title") + "</td>\n" +
|
||||||
" <td width=\"40%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_content") +"</td>\n" +
|
" <td width=\"40%\" >" + I18nUtil.getString("jobconf_monitor_alarm_content") + "</td>\n" +
|
||||||
" </tr>\n" +
|
" </tr>\n" +
|
||||||
" </thead>\n" +
|
" </thead>\n" +
|
||||||
" <tbody>\n" +
|
" <tbody>\n" +
|
||||||
" <tr>\n" +
|
" <tr>\n" +
|
||||||
" <td>{0}</td>\n" +
|
" <td>{0}</td>\n" +
|
||||||
" <td>{1}</td>\n" +
|
" <td>{1}</td>\n" +
|
||||||
" <td>{2}</td>\n" +
|
" <td>{2}</td>\n" +
|
||||||
" <td>"+ I18nUtil.getString("jobconf_monitor_alarm_type") +"</td>\n" +
|
" <td>" + I18nUtil.getString("jobconf_monitor_alarm_type") + "</td>\n" +
|
||||||
" <td>{3}</td>\n" +
|
" <td>{3}</td>\n" +
|
||||||
" </tr>\n" +
|
" </tr>\n" +
|
||||||
" </tbody>\n" +
|
" </tbody>\n" +
|
||||||
"</table>";
|
"</table>";
|
||||||
|
|
||||||
return mailBodyTemplate;
|
return mailBodyTemplate;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class XxlJobCompleter {
|
|||||||
|
|
||||||
// text最大64kb 避免长度过长
|
// text最大64kb 避免长度过长
|
||||||
if (xxlJobLog.getHandleMsg().length() > 15000) {
|
if (xxlJobLog.getHandleMsg().length() > 15000) {
|
||||||
xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg().substring(0, 15000) );
|
xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg().substring(0, 15000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// fresh handle
|
// fresh handle
|
||||||
@ -43,18 +43,18 @@ public class XxlJobCompleter {
|
|||||||
/**
|
/**
|
||||||
* do somethind to finish job
|
* do somethind to finish job
|
||||||
*/
|
*/
|
||||||
private static void finishJob(XxlJobLog xxlJobLog){
|
private static void finishJob(XxlJobLog xxlJobLog) {
|
||||||
|
|
||||||
// 1、handle success, to trigger child job
|
// 1、handle success, to trigger child job
|
||||||
String triggerChildMsg = null;
|
String triggerChildMsg = null;
|
||||||
if (XxlJobContext.HANDLE_COCE_SUCCESS == xxlJobLog.getHandleCode()) {
|
if (XxlJobContext.HANDLE_CODE_SUCCESS == xxlJobLog.getHandleCode()) {
|
||||||
XxlJobInfo xxlJobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(xxlJobLog.getJobId());
|
XxlJobInfo xxlJobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(xxlJobLog.getJobId());
|
||||||
if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) {
|
if (xxlJobInfo != null && xxlJobInfo.getChildJobId() != null && xxlJobInfo.getChildJobId().trim().length() > 0) {
|
||||||
triggerChildMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_child_run") +"<<<<<<<<<<< </span><br>";
|
triggerChildMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>";
|
||||||
|
|
||||||
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
|
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
|
||||||
for (int i = 0; i < childJobIds.length; i++) {
|
for (int i = 0; i < childJobIds.length; i++) {
|
||||||
int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
|
int childJobId = (childJobIds[i] != null && childJobIds[i].trim().length() > 0 && isNumeric(childJobIds[i])) ? Integer.valueOf(childJobIds[i]) : -1;
|
||||||
if (childJobId > 0) {
|
if (childJobId > 0) {
|
||||||
|
|
||||||
JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
|
JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
|
||||||
@ -62,16 +62,16 @@ public class XxlJobCompleter {
|
|||||||
|
|
||||||
// add msg
|
// add msg
|
||||||
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
|
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
|
||||||
(i+1),
|
(i + 1),
|
||||||
childJobIds.length,
|
childJobIds.length,
|
||||||
childJobIds[i],
|
childJobIds[i],
|
||||||
(triggerChildResult.getCode()==ReturnT.SUCCESS_CODE?I18nUtil.getString("system_success"):I18nUtil.getString("system_fail")),
|
(triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")),
|
||||||
triggerChildResult.getMsg());
|
triggerChildResult.getMsg());
|
||||||
} else {
|
} else {
|
||||||
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
|
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
|
||||||
(i+1),
|
(i + 1),
|
||||||
childJobIds.length,
|
childJobIds.length,
|
||||||
childJobIds[i]);
|
childJobIds[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class XxlJobCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (triggerChildMsg != null) {
|
if (triggerChildMsg != null) {
|
||||||
xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg() + triggerChildMsg );
|
xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg() + triggerChildMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2、fix_delay trigger next
|
// 2、fix_delay trigger next
|
||||||
@ -87,7 +87,7 @@ public class XxlJobCompleter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isNumeric(String str){
|
private static boolean isNumeric(String str) {
|
||||||
try {
|
try {
|
||||||
int result = Integer.valueOf(str);
|
int result = Integer.valueOf(str);
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,6 +23,7 @@ import java.util.Arrays;
|
|||||||
public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
|
public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
|
||||||
|
|
||||||
private static XxlJobAdminConfig adminConfig = null;
|
private static XxlJobAdminConfig adminConfig = null;
|
||||||
|
|
||||||
public static XxlJobAdminConfig getAdminConfig() {
|
public static XxlJobAdminConfig getAdminConfig() {
|
||||||
return adminConfig;
|
return adminConfig;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
|
* All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations
|
* License for the specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.xxl.job.admin.core.cron;
|
package com.xxl.job.admin.core.cron;
|
||||||
@ -31,14 +31,14 @@ import java.util.TimeZone;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a parser and evaluator for unix-like cron expressions. Cron
|
* Provides a parser and evaluator for unix-like cron expressions. Cron
|
||||||
* expressions provide the ability to specify complex time combinations such as
|
* expressions provide the ability to specify complex time combinations such as
|
||||||
* "At 8:00am every Monday through Friday" or "At 1:30am every
|
* "At 8:00am every Monday through Friday" or "At 1:30am every
|
||||||
* last Friday of the month".
|
* last Friday of the month".
|
||||||
* <P>
|
* <P>
|
||||||
* Cron expressions are comprised of 6 required fields and one optional field
|
* Cron expressions are comprised of 6 required fields and one optional field
|
||||||
* separated by white space. The fields respectively are described as follows:
|
* separated by white space. The fields respectively are described as follows:
|
||||||
*
|
*
|
||||||
* <table cellspacing="8">
|
* <table cellspacing="8">
|
||||||
* <tr>
|
* <tr>
|
||||||
* <th align="left">Field Name</th>
|
* <th align="left">Field Name</th>
|
||||||
@ -98,7 +98,7 @@ import java.util.TreeSet;
|
|||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
* <P>
|
* <P>
|
||||||
* The '*' character is used to specify all values. For example, "*"
|
* The '*' character is used to specify all values. For example, "*"
|
||||||
* in the minute field means "every minute".
|
* in the minute field means "every minute".
|
||||||
* <P>
|
* <P>
|
||||||
* The '?' character is allowed for the day-of-month and day-of-week fields. It
|
* The '?' character is allowed for the day-of-month and day-of-week fields. It
|
||||||
@ -113,55 +113,55 @@ import java.util.TreeSet;
|
|||||||
* Wednesday, and Friday".
|
* Wednesday, and Friday".
|
||||||
* <P>
|
* <P>
|
||||||
* The '/' character is used to specify increments. For example "0/15"
|
* The '/' character is used to specify increments. For example "0/15"
|
||||||
* in the seconds field means "the seconds 0, 15, 30, and 45". And
|
* in the seconds field means "the seconds 0, 15, 30, and 45". And
|
||||||
* "5/15" in the seconds field means "the seconds 5, 20, 35, and
|
* "5/15" in the seconds field means "the seconds 5, 20, 35, and
|
||||||
* 50". Specifying '*' before the '/' is equivalent to specifying 0 is
|
* 50". Specifying '*' before the '/' is equivalent to specifying 0 is
|
||||||
* the value to start with. Essentially, for each field in the expression, there
|
* the value to start with. Essentially, for each field in the expression, there
|
||||||
* is a set of numbers that can be turned on or off. For seconds and minutes,
|
* is a set of numbers that can be turned on or off. For seconds and minutes,
|
||||||
* the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to
|
* the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to
|
||||||
* 31, and for months 0 to 11 (JAN to DEC). The "/" character simply helps you turn
|
* 31, and for months 0 to 11 (JAN to DEC). The "/" character simply helps you turn
|
||||||
* on every "nth" value in the given set. Thus "7/6" in the
|
* on every "nth" value in the given set. Thus "7/6" in the
|
||||||
* month field only turns on month "7", it does NOT mean every 6th
|
* month field only turns on month "7", it does NOT mean every 6th
|
||||||
* month, please note that subtlety.
|
* month, please note that subtlety.
|
||||||
* <P>
|
* <P>
|
||||||
* The 'L' character is allowed for the day-of-month and day-of-week fields.
|
* The 'L' character is allowed for the day-of-month and day-of-week fields.
|
||||||
* This character is short-hand for "last", but it has different
|
* This character is short-hand for "last", but it has different
|
||||||
* meaning in each of the two fields. For example, the value "L" in
|
* meaning in each of the two fields. For example, the value "L" in
|
||||||
* the day-of-month field means "the last day of the month" - day 31
|
* the day-of-month field means "the last day of the month" - day 31
|
||||||
* for January, day 28 for February on non-leap years. If used in the
|
* for January, day 28 for February on non-leap years. If used in the
|
||||||
* day-of-week field by itself, it simply means "7" or
|
* day-of-week field by itself, it simply means "7" or
|
||||||
* "SAT". But if used in the day-of-week field after another value, it
|
* "SAT". But if used in the day-of-week field after another value, it
|
||||||
* means "the last xxx day of the month" - for example "6L"
|
* means "the last xxx day of the month" - for example "6L"
|
||||||
* means "the last friday of the month". You can also specify an offset
|
* means "the last friday of the month". You can also specify an offset
|
||||||
* from the last day of the month, such as "L-3" which would mean the third-to-last
|
* from the last day of the month, such as "L-3" which would mean the third-to-last
|
||||||
* day of the calendar month. <i>When using the 'L' option, it is important not to
|
* day of the calendar month. <i>When using the 'L' option, it is important not to
|
||||||
* specify lists, or ranges of values, as you'll get confusing/unexpected results.</i>
|
* specify lists, or ranges of values, as you'll get confusing/unexpected results.</i>
|
||||||
* <P>
|
* <P>
|
||||||
* The 'W' character is allowed for the day-of-month field. This character
|
* The 'W' character is allowed for the day-of-month field. This character
|
||||||
* is used to specify the weekday (Monday-Friday) nearest the given day. As an
|
* is used to specify the weekday (Monday-Friday) nearest the given day. As an
|
||||||
* example, if you were to specify "15W" as the value for the
|
* example, if you were to specify "15W" as the value for the
|
||||||
* day-of-month field, the meaning is: "the nearest weekday to the 15th of
|
* day-of-month field, the meaning is: "the nearest weekday to the 15th of
|
||||||
* the month". So if the 15th is a Saturday, the trigger will fire on
|
* the month". So if the 15th is a Saturday, the trigger will fire on
|
||||||
* Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the
|
* Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the
|
||||||
* 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th.
|
* 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th.
|
||||||
* However if you specify "1W" as the value for day-of-month, and the
|
* However if you specify "1W" as the value for day-of-month, and the
|
||||||
* 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not
|
* 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not
|
||||||
* 'jump' over the boundary of a month's days. The 'W' character can only be
|
* 'jump' over the boundary of a month's days. The 'W' character can only be
|
||||||
* specified when the day-of-month is a single day, not a range or list of days.
|
* specified when the day-of-month is a single day, not a range or list of days.
|
||||||
* <P>
|
* <P>
|
||||||
* The 'L' and 'W' characters can also be combined for the day-of-month
|
* The 'L' and 'W' characters can also be combined for the day-of-month
|
||||||
* expression to yield 'LW', which translates to "last weekday of the
|
* expression to yield 'LW', which translates to "last weekday of the
|
||||||
* month".
|
* month".
|
||||||
* <P>
|
* <P>
|
||||||
* The '#' character is allowed for the day-of-week field. This character is
|
* The '#' character is allowed for the day-of-week field. This character is
|
||||||
* used to specify "the nth" XXX day of the month. For example, the
|
* used to specify "the nth" XXX day of the month. For example, the
|
||||||
* value of "6#3" in the day-of-week field means the third Friday of
|
* value of "6#3" in the day-of-week field means the third Friday of
|
||||||
* the month (day 6 = Friday and "#3" = the 3rd one in the month).
|
* the month (day 6 = Friday and "#3" = the 3rd one in the month).
|
||||||
* Other examples: "2#1" = the first Monday of the month and
|
* Other examples: "2#1" = the first Monday of the month and
|
||||||
* "4#5" = the fifth Wednesday of the month. Note that if you specify
|
* "4#5" = the fifth Wednesday of the month. Note that if you specify
|
||||||
* "#5" and there is not 5 of the given day-of-week in the month, then
|
* "#5" and there is not 5 of the given day-of-week in the month, then
|
||||||
* no firing will occur that month. If the '#' character is used, there can
|
* no firing will occur that month. If the '#' character is used, there can
|
||||||
* only be one expression in the day-of-week field ("3#1,6#3" is
|
* only be one expression in the day-of-week field ("3#1,6#3" is
|
||||||
* not valid, since there are two expressions).
|
* not valid, since there are two expressions).
|
||||||
* <P>
|
* <P>
|
||||||
* <!--The 'C' character is allowed for the day-of-month and day-of-week fields.
|
* <!--The 'C' character is allowed for the day-of-month and day-of-week fields.
|
||||||
@ -174,35 +174,33 @@ import java.util.TreeSet;
|
|||||||
* <P>
|
* <P>
|
||||||
* The legal characters and the names of months and days of the week are not
|
* The legal characters and the names of months and days of the week are not
|
||||||
* case sensitive.
|
* case sensitive.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>NOTES:</b>
|
* <b>NOTES:</b>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Support for specifying both a day-of-week and a day-of-month value is
|
* <li>Support for specifying both a day-of-week and a day-of-month value is
|
||||||
* not complete (you'll need to use the '?' character in one of these fields).
|
* not complete (you'll need to use the '?' character in one of these fields).
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Overflowing ranges is supported - that is, having a larger number on
|
* <li>Overflowing ranges is supported - that is, having a larger number on
|
||||||
* the left hand side than the right. You might do 22-2 to catch 10 o'clock
|
* the left hand side than the right. You might do 22-2 to catch 10 o'clock
|
||||||
* at night until 2 o'clock in the morning, or you might have NOV-FEB. It is
|
* at night until 2 o'clock in the morning, or you might have NOV-FEB. It is
|
||||||
* very important to note that overuse of overflowing ranges creates ranges
|
* very important to note that overuse of overflowing ranges creates ranges
|
||||||
* that don't make sense and no effort has been made to determine which
|
* that don't make sense and no effort has been made to determine which
|
||||||
* interpretation CronExpression chooses. An example would be
|
* interpretation CronExpression chooses. An example would be
|
||||||
* "0 0 14-6 ? * FRI-MON". </li>
|
* "0 0 14-6 ? * FRI-MON". </li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Sharada Jambula, James House
|
* @author Sharada Jambula, James House
|
||||||
* @author Contributions from Mads Henderson
|
* @author Contributions from Mads Henderson
|
||||||
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven
|
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven
|
||||||
*
|
* <p>
|
||||||
* Borrowed from quartz v2.3.1
|
* Borrowed from quartz v2.3.1
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class CronExpression implements Serializable, Cloneable {
|
public final class CronExpression implements Serializable, Cloneable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 12423409423L;
|
private static final long serialVersionUID = 12423409423L;
|
||||||
|
|
||||||
protected static final int SECOND = 0;
|
protected static final int SECOND = 0;
|
||||||
protected static final int MINUTE = 1;
|
protected static final int MINUTE = 1;
|
||||||
protected static final int HOUR = 2;
|
protected static final int HOUR = 2;
|
||||||
@ -214,9 +212,10 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
protected static final int NO_SPEC_INT = 98; // '?'
|
protected static final int NO_SPEC_INT = 98; // '?'
|
||||||
protected static final Integer ALL_SPEC = ALL_SPEC_INT;
|
protected static final Integer ALL_SPEC = ALL_SPEC_INT;
|
||||||
protected static final Integer NO_SPEC = NO_SPEC_INT;
|
protected static final Integer NO_SPEC = NO_SPEC_INT;
|
||||||
|
|
||||||
protected static final Map<String, Integer> monthMap = new HashMap<String, Integer>(20);
|
protected static final Map<String, Integer> monthMap = new HashMap<String, Integer>(20);
|
||||||
protected static final Map<String, Integer> dayMap = new HashMap<String, Integer>(60);
|
protected static final Map<String, Integer> dayMap = new HashMap<String, Integer>(60);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
monthMap.put("JAN", 0);
|
monthMap.put("JAN", 0);
|
||||||
monthMap.put("FEB", 1);
|
monthMap.put("FEB", 1);
|
||||||
@ -256,35 +255,33 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
protected transient boolean nearestWeekday = false;
|
protected transient boolean nearestWeekday = false;
|
||||||
protected transient int lastdayOffset = 0;
|
protected transient int lastdayOffset = 0;
|
||||||
protected transient boolean expressionParsed = false;
|
protected transient boolean expressionParsed = false;
|
||||||
|
|
||||||
public static final int MAX_YEAR = Calendar.getInstance().get(Calendar.YEAR) + 100;
|
public static final int MAX_YEAR = Calendar.getInstance().get(Calendar.YEAR) + 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <CODE>CronExpression</CODE> based on the specified
|
* Constructs a new <CODE>CronExpression</CODE> based on the specified
|
||||||
* parameter.
|
* parameter.
|
||||||
*
|
*
|
||||||
* @param cronExpression String representation of the cron expression the
|
* @param cronExpression String representation of the cron expression the
|
||||||
* new object should represent
|
* new object should represent
|
||||||
* @throws java.text.ParseException
|
* @throws ParseException if the string expression cannot be parsed into a valid
|
||||||
* if the string expression cannot be parsed into a valid
|
* <CODE>CronExpression</CODE>
|
||||||
* <CODE>CronExpression</CODE>
|
|
||||||
*/
|
*/
|
||||||
public CronExpression(String cronExpression) throws ParseException {
|
public CronExpression(String cronExpression) throws ParseException {
|
||||||
if (cronExpression == null) {
|
if (cronExpression == null) {
|
||||||
throw new IllegalArgumentException("cronExpression cannot be null");
|
throw new IllegalArgumentException("cronExpression cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cronExpression = cronExpression.toUpperCase(Locale.US);
|
this.cronExpression = cronExpression.toUpperCase(Locale.US);
|
||||||
|
|
||||||
buildExpression(this.cronExpression);
|
buildExpression(this.cronExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@code CronExpression} as a copy of an existing
|
* Constructs a new {@code CronExpression} as a copy of an existing
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
* @param expression
|
* @param expression The existing cron expression to be copied
|
||||||
* The existing cron expression to be copied
|
|
||||||
*/
|
*/
|
||||||
public CronExpression(CronExpression expression) {
|
public CronExpression(CronExpression expression) {
|
||||||
/*
|
/*
|
||||||
@ -307,28 +304,28 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
* Indicates whether the given date satisfies the cron expression. Note that
|
* Indicates whether the given date satisfies the cron expression. Note that
|
||||||
* milliseconds are ignored, so two Dates falling on different milliseconds
|
* milliseconds are ignored, so two Dates falling on different milliseconds
|
||||||
* of the same second will always have the same result here.
|
* of the same second will always have the same result here.
|
||||||
*
|
*
|
||||||
* @param date the date to evaluate
|
* @param date the date to evaluate
|
||||||
* @return a boolean indicating whether the given date satisfies the cron
|
* @return a boolean indicating whether the given date satisfies the cron
|
||||||
* expression
|
* expression
|
||||||
*/
|
*/
|
||||||
public boolean isSatisfiedBy(Date date) {
|
public boolean isSatisfiedBy(Date date) {
|
||||||
Calendar testDateCal = Calendar.getInstance(getTimeZone());
|
Calendar testDateCal = Calendar.getInstance(getTimeZone());
|
||||||
testDateCal.setTime(date);
|
testDateCal.setTime(date);
|
||||||
testDateCal.set(Calendar.MILLISECOND, 0);
|
testDateCal.set(Calendar.MILLISECOND, 0);
|
||||||
Date originalDate = testDateCal.getTime();
|
Date originalDate = testDateCal.getTime();
|
||||||
|
|
||||||
testDateCal.add(Calendar.SECOND, -1);
|
testDateCal.add(Calendar.SECOND, -1);
|
||||||
|
|
||||||
Date timeAfter = getTimeAfter(testDateCal.getTime());
|
Date timeAfter = getTimeAfter(testDateCal.getTime());
|
||||||
|
|
||||||
return ((timeAfter != null) && (timeAfter.equals(originalDate)));
|
return ((timeAfter != null) && (timeAfter.equals(originalDate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next date/time <I>after</I> the given date/time which
|
* Returns the next date/time <I>after</I> the given date/time which
|
||||||
* satisfies the cron expression.
|
* satisfies the cron expression.
|
||||||
*
|
*
|
||||||
* @param date the date/time at which to begin the search for the next valid
|
* @param date the date/time at which to begin the search for the next valid
|
||||||
* date/time
|
* date/time
|
||||||
* @return the next valid date/time
|
* @return the next valid date/time
|
||||||
@ -336,48 +333,48 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
public Date getNextValidTimeAfter(Date date) {
|
public Date getNextValidTimeAfter(Date date) {
|
||||||
return getTimeAfter(date);
|
return getTimeAfter(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next date/time <I>after</I> the given date/time which does
|
* Returns the next date/time <I>after</I> the given date/time which does
|
||||||
* <I>not</I> satisfy the expression
|
* <I>not</I> satisfy the expression
|
||||||
*
|
*
|
||||||
* @param date the date/time at which to begin the search for the next
|
* @param date the date/time at which to begin the search for the next
|
||||||
* invalid date/time
|
* invalid date/time
|
||||||
* @return the next valid date/time
|
* @return the next valid date/time
|
||||||
*/
|
*/
|
||||||
public Date getNextInvalidTimeAfter(Date date) {
|
public Date getNextInvalidTimeAfter(Date date) {
|
||||||
long difference = 1000;
|
long difference = 1000;
|
||||||
|
|
||||||
//move back to the nearest second so differences will be accurate
|
//move back to the nearest second so differences will be accurate
|
||||||
Calendar adjustCal = Calendar.getInstance(getTimeZone());
|
Calendar adjustCal = Calendar.getInstance(getTimeZone());
|
||||||
adjustCal.setTime(date);
|
adjustCal.setTime(date);
|
||||||
adjustCal.set(Calendar.MILLISECOND, 0);
|
adjustCal.set(Calendar.MILLISECOND, 0);
|
||||||
Date lastDate = adjustCal.getTime();
|
Date lastDate = adjustCal.getTime();
|
||||||
|
|
||||||
Date newDate;
|
Date newDate;
|
||||||
|
|
||||||
//FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution.
|
//FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution.
|
||||||
|
|
||||||
//keep getting the next included time until it's farther than one second
|
//keep getting the next included time until it's farther than one second
|
||||||
// apart. At that point, lastDate is the last valid fire time. We return
|
// apart. At that point, lastDate is the last valid fire time. We return
|
||||||
// the second immediately following it.
|
// the second immediately following it.
|
||||||
while (difference == 1000) {
|
while (difference == 1000) {
|
||||||
newDate = getTimeAfter(lastDate);
|
newDate = getTimeAfter(lastDate);
|
||||||
if(newDate == null)
|
if (newDate == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
difference = newDate.getTime() - lastDate.getTime();
|
difference = newDate.getTime() - lastDate.getTime();
|
||||||
|
|
||||||
if (difference == 1000) {
|
if (difference == 1000) {
|
||||||
lastDate = newDate;
|
lastDate = newDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Date(lastDate.getTime() + 1000);
|
return new Date(lastDate.getTime() + 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time zone for which this <code>CronExpression</code>
|
* Returns the time zone for which this <code>CronExpression</code>
|
||||||
* will be resolved.
|
* will be resolved.
|
||||||
*/
|
*/
|
||||||
public TimeZone getTimeZone() {
|
public TimeZone getTimeZone() {
|
||||||
@ -389,16 +386,16 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time zone for which this <code>CronExpression</code>
|
* Sets the time zone for which this <code>CronExpression</code>
|
||||||
* will be resolved.
|
* will be resolved.
|
||||||
*/
|
*/
|
||||||
public void setTimeZone(TimeZone timeZone) {
|
public void setTimeZone(TimeZone timeZone) {
|
||||||
this.timeZone = timeZone;
|
this.timeZone = timeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representation of the <CODE>CronExpression</CODE>
|
* Returns the string representation of the <CODE>CronExpression</CODE>
|
||||||
*
|
*
|
||||||
* @return a string representation of the <CODE>CronExpression</CODE>
|
* @return a string representation of the <CODE>CronExpression</CODE>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -407,30 +404,30 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the specified cron expression can be parsed into a
|
* Indicates whether the specified cron expression can be parsed into a
|
||||||
* valid cron expression
|
* valid cron expression
|
||||||
*
|
*
|
||||||
* @param cronExpression the expression to evaluate
|
* @param cronExpression the expression to evaluate
|
||||||
* @return a boolean indicating whether the given expression is a valid cron
|
* @return a boolean indicating whether the given expression is a valid cron
|
||||||
* expression
|
* expression
|
||||||
*/
|
*/
|
||||||
public static boolean isValidExpression(String cronExpression) {
|
public static boolean isValidExpression(String cronExpression) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new CronExpression(cronExpression);
|
new CronExpression(cronExpression);
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateExpression(String cronExpression) throws ParseException {
|
public static void validateExpression(String cronExpression) throws ParseException {
|
||||||
|
|
||||||
new CronExpression(cronExpression);
|
new CronExpression(cronExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Expression Parsing Functions
|
// Expression Parsing Functions
|
||||||
@ -467,23 +464,23 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
int exprOn = SECOND;
|
int exprOn = SECOND;
|
||||||
|
|
||||||
StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
|
StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
|
while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
|
||||||
String expr = exprsTok.nextToken().trim();
|
String expr = exprsTok.nextToken().trim();
|
||||||
|
|
||||||
// throw an exception if L is used with other days of the month
|
// throw an exception if L is used with other days of the month
|
||||||
if(exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
|
if (exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
|
||||||
throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
|
throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
|
||||||
}
|
}
|
||||||
// throw an exception if L is used with other days of the week
|
// throw an exception if L is used with other days of the week
|
||||||
if(exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
|
if (exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
|
||||||
throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1);
|
throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1);
|
||||||
}
|
}
|
||||||
if(exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') +1) != -1) {
|
if (exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') + 1) != -1) {
|
||||||
throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1);
|
throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTokenizer vTok = new StringTokenizer(expr, ",");
|
StringTokenizer vTok = new StringTokenizer(expr, ",");
|
||||||
while (vTok.hasMoreTokens()) {
|
while (vTok.hasMoreTokens()) {
|
||||||
String v = vTok.nextToken();
|
String v = vTok.nextToken();
|
||||||
@ -495,7 +492,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
if (exprOn <= DAY_OF_WEEK) {
|
if (exprOn <= DAY_OF_WEEK) {
|
||||||
throw new ParseException("Unexpected end of expression.",
|
throw new ParseException("Unexpected end of expression.",
|
||||||
expression.length());
|
expression.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exprOn <= YEAR) {
|
if (exprOn <= YEAR) {
|
||||||
@ -512,14 +509,14 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
if (!dayOfMSpec || dayOfWSpec) {
|
if (!dayOfMSpec || dayOfWSpec) {
|
||||||
if (!dayOfWSpec || dayOfMSpec) {
|
if (!dayOfWSpec || dayOfMSpec) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0);
|
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
throw pe;
|
throw pe;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParseException("Illegal cron expression format ("
|
throw new ParseException("Illegal cron expression format ("
|
||||||
+ e.toString() + ")", 0);
|
+ e.toString() + ")", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +553,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
sval = getDayOfWeekNumber(sub);
|
sval = getDayOfWeekNumber(sub);
|
||||||
if (sval < 0) {
|
if (sval < 0) {
|
||||||
throw new ParseException("Invalid Day-of-Week value: '"
|
throw new ParseException("Invalid Day-of-Week value: '"
|
||||||
+ sub + "'", i);
|
+ sub + "'", i);
|
||||||
}
|
}
|
||||||
if (s.length() > i + 3) {
|
if (s.length() > i + 3) {
|
||||||
c = s.charAt(i + 3);
|
c = s.charAt(i + 3);
|
||||||
@ -566,8 +563,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
eval = getDayOfWeekNumber(sub);
|
eval = getDayOfWeekNumber(sub);
|
||||||
if (eval < 0) {
|
if (eval < 0) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Invalid Day-of-Week value: '" + sub
|
"Invalid Day-of-Week value: '" + sub
|
||||||
+ "'", i);
|
+ "'", i);
|
||||||
}
|
}
|
||||||
} else if (c == '#') {
|
} else if (c == '#') {
|
||||||
try {
|
try {
|
||||||
@ -578,8 +575,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"A numeric value between 1 and 5 must follow the '#' option",
|
"A numeric value between 1 and 5 must follow the '#' option",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
} else if (c == 'L') {
|
} else if (c == 'L') {
|
||||||
lastdayOfWeek = true;
|
lastdayOfWeek = true;
|
||||||
@ -589,8 +586,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Illegal characters for this position: '" + sub + "'",
|
"Illegal characters for this position: '" + sub + "'",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
if (eval != -1) {
|
if (eval != -1) {
|
||||||
incr = 1;
|
incr = 1;
|
||||||
@ -601,22 +598,22 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
if (c == '?') {
|
if (c == '?') {
|
||||||
i++;
|
i++;
|
||||||
if ((i + 1) < s.length()
|
if ((i + 1) < s.length()
|
||||||
&& (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) {
|
&& (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) {
|
||||||
throw new ParseException("Illegal character after '?': "
|
throw new ParseException("Illegal character after '?': "
|
||||||
+ s.charAt(i), i);
|
+ s.charAt(i), i);
|
||||||
}
|
}
|
||||||
if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) {
|
if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"'?' can only be specified for Day-of-Month or Day-of-Week.",
|
"'?' can only be specified for Day-of-Month or Day-of-Week.",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
if (type == DAY_OF_WEEK && !lastdayOfMonth) {
|
if (type == DAY_OF_WEEK && !lastdayOfMonth) {
|
||||||
int val = daysOfMonth.last();
|
int val = daysOfMonth.last();
|
||||||
if (val == NO_SPEC_INT) {
|
if (val == NO_SPEC_INT) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"'?' can only be specified for Day-of-Month -OR- Day-of-Week.",
|
"'?' can only be specified for Day-of-Month -OR- Day-of-Week.",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,8 +626,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
addToSet(ALL_SPEC_INT, -1, incr, type);
|
addToSet(ALL_SPEC_INT, -1, incr, type);
|
||||||
return i + 1;
|
return i + 1;
|
||||||
} else if (c == '/'
|
} else if (c == '/'
|
||||||
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
|
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
|
||||||
.charAt(i + 1) == '\t')) {
|
.charAt(i + 1) == '\t')) {
|
||||||
throw new ParseException("'/' must be followed by an integer.", i);
|
throw new ParseException("'/' must be followed by an integer.", i);
|
||||||
} else if (c == '*') {
|
} else if (c == '*') {
|
||||||
i++;
|
i++;
|
||||||
@ -663,18 +660,18 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
if (type == DAY_OF_WEEK) {
|
if (type == DAY_OF_WEEK) {
|
||||||
addToSet(7, 7, 0, type);
|
addToSet(7, 7, 0, type);
|
||||||
}
|
}
|
||||||
if(type == DAY_OF_MONTH && s.length() > i) {
|
if (type == DAY_OF_MONTH && s.length() > i) {
|
||||||
c = s.charAt(i);
|
c = s.charAt(i);
|
||||||
if(c == '-') {
|
if (c == '-') {
|
||||||
ValueSet vs = getValue(0, s, i+1);
|
ValueSet vs = getValue(0, s, i + 1);
|
||||||
lastdayOffset = vs.value;
|
lastdayOffset = vs.value;
|
||||||
if(lastdayOffset > 30)
|
if (lastdayOffset > 30)
|
||||||
throw new ParseException("Offset from last day must be <= 30", i+1);
|
throw new ParseException("Offset from last day must be <= 30", i + 1);
|
||||||
i = vs.pos;
|
i = vs.pos;
|
||||||
}
|
}
|
||||||
if(s.length() > i) {
|
if (s.length() > i) {
|
||||||
c = s.charAt(i);
|
c = s.charAt(i);
|
||||||
if(c == 'W') {
|
if (c == 'W') {
|
||||||
nearestWeekday = true;
|
nearestWeekday = true;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -719,7 +716,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
protected int checkNext(int pos, String s, int val, int type)
|
protected int checkNext(int pos, String s, int val, int type)
|
||||||
throws ParseException {
|
throws ParseException {
|
||||||
|
|
||||||
int end = -1;
|
int end = -1;
|
||||||
int i = pos;
|
int i = pos;
|
||||||
|
|
||||||
@ -732,7 +729,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
if (c == 'L') {
|
if (c == 'L') {
|
||||||
if (type == DAY_OF_WEEK) {
|
if (type == DAY_OF_WEEK) {
|
||||||
if(val < 1 || val > 7)
|
if (val < 1 || val > 7)
|
||||||
throw new ParseException("Day-of-Week values must be between 1 and 7", -1);
|
throw new ParseException("Day-of-Week values must be between 1 and 7", -1);
|
||||||
lastdayOfWeek = true;
|
lastdayOfWeek = true;
|
||||||
} else {
|
} else {
|
||||||
@ -743,15 +740,15 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
i++;
|
i++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 'W') {
|
if (c == 'W') {
|
||||||
if (type == DAY_OF_MONTH) {
|
if (type == DAY_OF_MONTH) {
|
||||||
nearestWeekday = true;
|
nearestWeekday = true;
|
||||||
} else {
|
} else {
|
||||||
throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
|
throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
|
||||||
}
|
}
|
||||||
if(val > 31)
|
if (val > 31)
|
||||||
throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
|
throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
|
||||||
TreeSet<Integer> set = getSet(type);
|
TreeSet<Integer> set = getSet(type);
|
||||||
set.add(val);
|
set.add(val);
|
||||||
i++;
|
i++;
|
||||||
@ -770,8 +767,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"A numeric value between 1 and 5 must follow the '#' option",
|
"A numeric value between 1 and 5 must follow the '#' option",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeSet<Integer> set = getSet(type);
|
TreeSet<Integer> set = getSet(type);
|
||||||
@ -857,7 +854,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
public String getCronExpression() {
|
public String getCronExpression() {
|
||||||
return cronExpression;
|
return cronExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpressionSummary() {
|
public String getExpressionSummary() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
@ -966,36 +963,36 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
|
|
||||||
protected void addToSet(int val, int end, int incr, int type)
|
protected void addToSet(int val, int end, int incr, int type)
|
||||||
throws ParseException {
|
throws ParseException {
|
||||||
|
|
||||||
TreeSet<Integer> set = getSet(type);
|
TreeSet<Integer> set = getSet(type);
|
||||||
|
|
||||||
if (type == SECOND || type == MINUTE) {
|
if (type == SECOND || type == MINUTE) {
|
||||||
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
|
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Minute and Second values must be between 0 and 59",
|
"Minute and Second values must be between 0 and 59",
|
||||||
-1);
|
-1);
|
||||||
}
|
}
|
||||||
} else if (type == HOUR) {
|
} else if (type == HOUR) {
|
||||||
if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {
|
if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Hour values must be between 0 and 23", -1);
|
"Hour values must be between 0 and 23", -1);
|
||||||
}
|
}
|
||||||
} else if (type == DAY_OF_MONTH) {
|
} else if (type == DAY_OF_MONTH) {
|
||||||
if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)
|
if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)
|
||||||
&& (val != NO_SPEC_INT)) {
|
&& (val != NO_SPEC_INT)) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Day of month values must be between 1 and 31", -1);
|
"Day of month values must be between 1 and 31", -1);
|
||||||
}
|
}
|
||||||
} else if (type == MONTH) {
|
} else if (type == MONTH) {
|
||||||
if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) {
|
if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Month values must be between 1 and 12", -1);
|
"Month values must be between 1 and 12", -1);
|
||||||
}
|
}
|
||||||
} else if (type == DAY_OF_WEEK) {
|
} else if (type == DAY_OF_WEEK) {
|
||||||
if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT)
|
if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT)
|
||||||
&& (val != NO_SPEC_INT)) {
|
&& (val != NO_SPEC_INT)) {
|
||||||
throw new ParseException(
|
throw new ParseException(
|
||||||
"Day-of-Week values must be between 1 and 7", -1);
|
"Day-of-Week values must be between 1 and 7", -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,7 +1002,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
} else {
|
} else {
|
||||||
set.add(NO_SPEC);
|
set.add(NO_SPEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,20 +1058,34 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the end of the range is before the start, then we need to overflow into
|
// if the end of the range is before the start, then we need to overflow into
|
||||||
// the next day, month etc. This is done by adding the maximum amount for that
|
// the next day, month etc. This is done by adding the maximum amount for that
|
||||||
// type, and using modulus max to determine the value being added.
|
// type, and using modulus max to determine the value being added.
|
||||||
int max = -1;
|
int max = -1;
|
||||||
if (stopAt < startAt) {
|
if (stopAt < startAt) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SECOND : max = 60; break;
|
case SECOND:
|
||||||
case MINUTE : max = 60; break;
|
max = 60;
|
||||||
case HOUR : max = 24; break;
|
break;
|
||||||
case MONTH : max = 12; break;
|
case MINUTE:
|
||||||
case DAY_OF_WEEK : max = 7; break;
|
max = 60;
|
||||||
case DAY_OF_MONTH : max = 31; break;
|
break;
|
||||||
case YEAR : throw new IllegalArgumentException("Start year must be less than stop year");
|
case HOUR:
|
||||||
default : throw new IllegalArgumentException("Unexpected type encountered");
|
max = 24;
|
||||||
|
break;
|
||||||
|
case MONTH:
|
||||||
|
max = 12;
|
||||||
|
break;
|
||||||
|
case DAY_OF_WEEK:
|
||||||
|
max = 7;
|
||||||
|
break;
|
||||||
|
case DAY_OF_MONTH:
|
||||||
|
max = 31;
|
||||||
|
break;
|
||||||
|
case YEAR:
|
||||||
|
throw new IllegalArgumentException("Start year must be less than stop year");
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unexpected type encountered");
|
||||||
}
|
}
|
||||||
stopAt += max;
|
stopAt += max;
|
||||||
}
|
}
|
||||||
@ -1088,7 +1099,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
int i2 = i % max;
|
int i2 = i % max;
|
||||||
|
|
||||||
// 1-indexed ranges should not include 0, and should include their max
|
// 1-indexed ranges should not include 0, and should include their max
|
||||||
if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH) ) {
|
if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH)) {
|
||||||
i2 = max;
|
i2 = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1141,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
c = s.charAt(i);
|
c = s.charAt(i);
|
||||||
}
|
}
|
||||||
ValueSet val = new ValueSet();
|
ValueSet val = new ValueSet();
|
||||||
|
|
||||||
val.pos = (i < s.length()) ? i : i + 1;
|
val.pos = (i < s.length()) ? i : i + 1;
|
||||||
val.value = Integer.parseInt(s1.toString());
|
val.value = Integer.parseInt(s1.toString());
|
||||||
return val;
|
return val;
|
||||||
@ -1171,7 +1182,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
public Date getTimeAfter(Date afterTime) {
|
public Date getTimeAfter(Date afterTime) {
|
||||||
|
|
||||||
// Computation is based on Gregorian year only.
|
// Computation is based on Gregorian year only.
|
||||||
Calendar cl = new java.util.GregorianCalendar(getTimeZone());
|
Calendar cl = new java.util.GregorianCalendar(getTimeZone());
|
||||||
|
|
||||||
// move ahead one second, since we're computing the time *after* the
|
// move ahead one second, since we're computing the time *after* the
|
||||||
// given time
|
// given time
|
||||||
@ -1185,7 +1196,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
while (!gotOne) {
|
while (!gotOne) {
|
||||||
|
|
||||||
//if (endTime != null && cl.getTime().after(endTime)) return null;
|
//if (endTime != null && cl.getTime().after(endTime)) return null;
|
||||||
if(cl.get(Calendar.YEAR) > 2999) { // prevent endless loop...
|
if (cl.get(Calendar.YEAR) > 2999) { // prevent endless loop...
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1255,20 +1266,20 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
// 1-based
|
// 1-based
|
||||||
t = -1;
|
t = -1;
|
||||||
int tmon = mon;
|
int tmon = mon;
|
||||||
|
|
||||||
// get day...................................................
|
// get day...................................................
|
||||||
boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
|
boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
|
||||||
boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
|
boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
|
||||||
if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule
|
if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule
|
||||||
st = daysOfMonth.tailSet(day);
|
st = daysOfMonth.tailSet(day);
|
||||||
if (lastdayOfMonth) {
|
if (lastdayOfMonth) {
|
||||||
if(!nearestWeekday) {
|
if (!nearestWeekday) {
|
||||||
t = day;
|
t = day;
|
||||||
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
||||||
day -= lastdayOffset;
|
day -= lastdayOffset;
|
||||||
if(t > day) {
|
if (t > day) {
|
||||||
mon++;
|
mon++;
|
||||||
if(mon > 12) {
|
if (mon > 12) {
|
||||||
mon = 1;
|
mon = 1;
|
||||||
tmon = 3333; // ensure test of mon != tmon further below fails
|
tmon = 3333; // ensure test of mon != tmon further below fails
|
||||||
cl.add(Calendar.YEAR, 1);
|
cl.add(Calendar.YEAR, 1);
|
||||||
@ -1279,72 +1290,72 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
t = day;
|
t = day;
|
||||||
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
||||||
day -= lastdayOffset;
|
day -= lastdayOffset;
|
||||||
|
|
||||||
java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
|
Calendar tcal = Calendar.getInstance(getTimeZone());
|
||||||
tcal.set(Calendar.SECOND, 0);
|
tcal.set(Calendar.SECOND, 0);
|
||||||
tcal.set(Calendar.MINUTE, 0);
|
tcal.set(Calendar.MINUTE, 0);
|
||||||
tcal.set(Calendar.HOUR_OF_DAY, 0);
|
tcal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
tcal.set(Calendar.DAY_OF_MONTH, day);
|
tcal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
tcal.set(Calendar.MONTH, mon - 1);
|
tcal.set(Calendar.MONTH, mon - 1);
|
||||||
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
|
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
|
||||||
|
|
||||||
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
||||||
int dow = tcal.get(Calendar.DAY_OF_WEEK);
|
int dow = tcal.get(Calendar.DAY_OF_WEEK);
|
||||||
|
|
||||||
if(dow == Calendar.SATURDAY && day == 1) {
|
if (dow == Calendar.SATURDAY && day == 1) {
|
||||||
day += 2;
|
day += 2;
|
||||||
} else if(dow == Calendar.SATURDAY) {
|
} else if (dow == Calendar.SATURDAY) {
|
||||||
day -= 1;
|
day -= 1;
|
||||||
} else if(dow == Calendar.SUNDAY && day == ldom) {
|
} else if (dow == Calendar.SUNDAY && day == ldom) {
|
||||||
day -= 2;
|
day -= 2;
|
||||||
} else if(dow == Calendar.SUNDAY) {
|
} else if (dow == Calendar.SUNDAY) {
|
||||||
day += 1;
|
day += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcal.set(Calendar.SECOND, sec);
|
tcal.set(Calendar.SECOND, sec);
|
||||||
tcal.set(Calendar.MINUTE, min);
|
tcal.set(Calendar.MINUTE, min);
|
||||||
tcal.set(Calendar.HOUR_OF_DAY, hr);
|
tcal.set(Calendar.HOUR_OF_DAY, hr);
|
||||||
tcal.set(Calendar.DAY_OF_MONTH, day);
|
tcal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
tcal.set(Calendar.MONTH, mon - 1);
|
tcal.set(Calendar.MONTH, mon - 1);
|
||||||
Date nTime = tcal.getTime();
|
Date nTime = tcal.getTime();
|
||||||
if(nTime.before(afterTime)) {
|
if (nTime.before(afterTime)) {
|
||||||
day = 1;
|
day = 1;
|
||||||
mon++;
|
mon++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(nearestWeekday) {
|
} else if (nearestWeekday) {
|
||||||
t = day;
|
t = day;
|
||||||
day = daysOfMonth.first();
|
day = daysOfMonth.first();
|
||||||
|
|
||||||
java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
|
Calendar tcal = Calendar.getInstance(getTimeZone());
|
||||||
tcal.set(Calendar.SECOND, 0);
|
tcal.set(Calendar.SECOND, 0);
|
||||||
tcal.set(Calendar.MINUTE, 0);
|
tcal.set(Calendar.MINUTE, 0);
|
||||||
tcal.set(Calendar.HOUR_OF_DAY, 0);
|
tcal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
tcal.set(Calendar.DAY_OF_MONTH, day);
|
tcal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
tcal.set(Calendar.MONTH, mon - 1);
|
tcal.set(Calendar.MONTH, mon - 1);
|
||||||
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
|
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
|
||||||
|
|
||||||
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
|
||||||
int dow = tcal.get(Calendar.DAY_OF_WEEK);
|
int dow = tcal.get(Calendar.DAY_OF_WEEK);
|
||||||
|
|
||||||
if(dow == Calendar.SATURDAY && day == 1) {
|
if (dow == Calendar.SATURDAY && day == 1) {
|
||||||
day += 2;
|
day += 2;
|
||||||
} else if(dow == Calendar.SATURDAY) {
|
} else if (dow == Calendar.SATURDAY) {
|
||||||
day -= 1;
|
day -= 1;
|
||||||
} else if(dow == Calendar.SUNDAY && day == ldom) {
|
} else if (dow == Calendar.SUNDAY && day == ldom) {
|
||||||
day -= 2;
|
day -= 2;
|
||||||
} else if(dow == Calendar.SUNDAY) {
|
} else if (dow == Calendar.SUNDAY) {
|
||||||
day += 1;
|
day += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tcal.set(Calendar.SECOND, sec);
|
tcal.set(Calendar.SECOND, sec);
|
||||||
tcal.set(Calendar.MINUTE, min);
|
tcal.set(Calendar.MINUTE, min);
|
||||||
tcal.set(Calendar.HOUR_OF_DAY, hr);
|
tcal.set(Calendar.HOUR_OF_DAY, hr);
|
||||||
tcal.set(Calendar.DAY_OF_MONTH, day);
|
tcal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
tcal.set(Calendar.MONTH, mon - 1);
|
tcal.set(Calendar.MONTH, mon - 1);
|
||||||
Date nTime = tcal.getTime();
|
Date nTime = tcal.getTime();
|
||||||
if(nTime.before(afterTime)) {
|
if (nTime.before(afterTime)) {
|
||||||
day = daysOfMonth.first();
|
day = daysOfMonth.first();
|
||||||
mon++;
|
mon++;
|
||||||
}
|
}
|
||||||
@ -1361,7 +1372,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
day = daysOfMonth.first();
|
day = daysOfMonth.first();
|
||||||
mon++;
|
mon++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (day != t || mon != tmon) {
|
if (day != t || mon != tmon) {
|
||||||
cl.set(Calendar.SECOND, 0);
|
cl.set(Calendar.SECOND, 0);
|
||||||
cl.set(Calendar.MINUTE, 0);
|
cl.set(Calendar.MINUTE, 0);
|
||||||
@ -1442,8 +1453,8 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
daysToAdd = (nthdayOfWeek - weekOfMonth) * 7;
|
daysToAdd = (nthdayOfWeek - weekOfMonth) * 7;
|
||||||
day += daysToAdd;
|
day += daysToAdd;
|
||||||
if (daysToAdd < 0
|
if (daysToAdd < 0
|
||||||
|| day > getLastDayOfMonth(mon, cl
|
|| day > getLastDayOfMonth(mon, cl
|
||||||
.get(Calendar.YEAR))) {
|
.get(Calendar.YEAR))) {
|
||||||
cl.set(Calendar.SECOND, 0);
|
cl.set(Calendar.SECOND, 0);
|
||||||
cl.set(Calendar.MINUTE, 0);
|
cl.set(Calendar.MINUTE, 0);
|
||||||
cl.set(Calendar.HOUR_OF_DAY, 0);
|
cl.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
@ -1501,7 +1512,7 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
} else { // dayOfWSpec && !dayOfMSpec
|
} else { // dayOfWSpec && !dayOfMSpec
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
|
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
|
||||||
}
|
}
|
||||||
cl.set(Calendar.DAY_OF_MONTH, day);
|
cl.set(Calendar.DAY_OF_MONTH, day);
|
||||||
|
|
||||||
@ -1575,35 +1586,35 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
/**
|
/**
|
||||||
* Advance the calendar to the particular hour paying particular attention
|
* Advance the calendar to the particular hour paying particular attention
|
||||||
* to daylight saving problems.
|
* to daylight saving problems.
|
||||||
*
|
*
|
||||||
* @param cal the calendar to operate on
|
* @param cal the calendar to operate on
|
||||||
* @param hour the hour to set
|
* @param hour the hour to set
|
||||||
*/
|
*/
|
||||||
protected void setCalendarHour(Calendar cal, int hour) {
|
protected void setCalendarHour(Calendar cal, int hour) {
|
||||||
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
|
cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
|
if (cal.get(Calendar.HOUR_OF_DAY) != hour && hour != 24) {
|
||||||
cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
|
cal.set(Calendar.HOUR_OF_DAY, hour + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOT YET IMPLEMENTED: Returns the time before the given time
|
* NOT YET IMPLEMENTED: Returns the time before the given time
|
||||||
* that the <code>CronExpression</code> matches.
|
* that the <code>CronExpression</code> matches.
|
||||||
*/
|
*/
|
||||||
public Date getTimeBefore(Date endTime) {
|
public Date getTimeBefore(Date endTime) {
|
||||||
// FUTURE_TODO: implement QUARTZ-423
|
// FUTURE_TODO: implement QUARTZ-423
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOT YET IMPLEMENTED: Returns the final time that the
|
* NOT YET IMPLEMENTED: Returns the final time that the
|
||||||
* <code>CronExpression</code> will match.
|
* <code>CronExpression</code> will match.
|
||||||
*/
|
*/
|
||||||
public Date getFinalFireTime() {
|
public Date getFinalFireTime() {
|
||||||
// FUTURE_TODO: implement QUARTZ-423
|
// FUTURE_TODO: implement QUARTZ-423
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isLeapYear(int year) {
|
protected boolean isLeapYear(int year) {
|
||||||
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
|
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
|
||||||
}
|
}
|
||||||
@ -1637,21 +1648,21 @@ public final class CronExpression implements Serializable, Cloneable {
|
|||||||
return 31;
|
return 31;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Illegal month number: "
|
throw new IllegalArgumentException("Illegal month number: "
|
||||||
+ monthNum);
|
+ monthNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream)
|
private void readObject(java.io.ObjectInputStream stream)
|
||||||
throws java.io.IOException, ClassNotFoundException {
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
|
|
||||||
stream.defaultReadObject();
|
stream.defaultReadObject();
|
||||||
try {
|
try {
|
||||||
buildExpression(cronExpression);
|
buildExpression(cronExpression);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
} // never happens
|
} // never happens
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
@ -7,6 +7,7 @@ public class XxlJobException extends RuntimeException {
|
|||||||
|
|
||||||
public XxlJobException() {
|
public XxlJobException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public XxlJobException(String message) {
|
public XxlJobException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,9 @@ public class XxlJobGroup {
|
|||||||
|
|
||||||
// registry list
|
// registry list
|
||||||
private List<String> registryList; // 执行器地址列表(系统注册)
|
private List<String> registryList; // 执行器地址列表(系统注册)
|
||||||
|
|
||||||
public List<String> getRegistryList() {
|
public List<String> getRegistryList() {
|
||||||
if (addressList!=null && addressList.trim().length()>0) {
|
if (addressList != null && addressList.trim().length() > 0) {
|
||||||
registryList = new ArrayList<String>(Arrays.asList(addressList.split(",")));
|
registryList = new ArrayList<String>(Arrays.asList(addressList.split(",")));
|
||||||
}
|
}
|
||||||
return registryList;
|
return registryList;
|
||||||
|
@ -31,7 +31,7 @@ public class XxlJobInfo {
|
|||||||
private int executorTimeout; // 任务执行超时时间,单位秒
|
private int executorTimeout; // 任务执行超时时间,单位秒
|
||||||
private int executorFailRetryCount; // 失败重试次数
|
private int executorFailRetryCount; // 失败重试次数
|
||||||
|
|
||||||
private String glueType; // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
|
private String glueType; // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
|
||||||
private String glueSource; // GLUE源代码
|
private String glueSource; // GLUE源代码
|
||||||
private String glueRemark; // GLUE备注
|
private String glueRemark; // GLUE备注
|
||||||
private Date glueUpdatetime; // GLUE更新时间
|
private Date glueUpdatetime; // GLUE更新时间
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//package com.xxl.job.admin.core.jobbean;
|
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.jobbean;
|
||||||
//
|
//
|
||||||
//import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
//import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
|
||||||
//import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
//import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
|
||||||
@ -29,4 +29,4 @@
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//package com.xxl.job.admin.core.schedule;
|
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.schedule;
|
||||||
//
|
//
|
||||||
//import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
//import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
|
||||||
//import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
|
//import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
|
||||||
@ -410,4 +410,4 @@
|
|||||||
// return jobList;
|
// return jobList;
|
||||||
// }*/
|
// }*/
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//package com.xxl.job.admin.core.quartz;
|
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.quartz;
|
||||||
//
|
//
|
||||||
//import org.quartz.SchedulerConfigException;
|
//import org.quartz.SchedulerConfigException;
|
||||||
//import org.quartz.spi.ThreadPool;
|
//import org.quartz.spi.ThreadPool;
|
||||||
|
@ -30,13 +30,14 @@ public enum ExecutorRouteStrategyEnum {
|
|||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutorRouter getRouter() {
|
public ExecutorRouter getRouter() {
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem){
|
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
for (ExecutorRouteStrategyEnum item: ExecutorRouteStrategyEnum.values()) {
|
for (ExecutorRouteStrategyEnum item : ExecutorRouteStrategyEnum.values()) {
|
||||||
if (item.name().equals(name)) {
|
if (item.name().equals(name)) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public abstract class ExecutorRouter {
|
|||||||
* route address
|
* route address
|
||||||
*
|
*
|
||||||
* @param addressList
|
* @param addressList
|
||||||
* @return ReturnT.content=address
|
* @return ReturnT.content=address
|
||||||
*/
|
*/
|
||||||
public abstract ReturnT<String> route(TriggerParam triggerParam, List<String> addressList);
|
public abstract ReturnT<String> route(TriggerParam triggerParam, List<String> addressList);
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@ public class ExecutorRouteBusyover extends ExecutorRouter {
|
|||||||
idleBeatResult = executorBiz.idleBeat(new IdleBeatParam(triggerParam.getJobId()));
|
idleBeatResult = executorBiz.idleBeat(new IdleBeatParam(triggerParam.getJobId()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
|
||||||
}
|
}
|
||||||
idleBeatResultSB.append( (idleBeatResultSB.length()>0)?"<br><br>":"")
|
idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "")
|
||||||
.append(I18nUtil.getString("jobconf_idleBeat") + ":")
|
.append(I18nUtil.getString("jobconf_idleBeat") + ":")
|
||||||
.append("<br>address:").append(address)
|
.append("<br>address:").append(address)
|
||||||
.append("<br>code:").append(idleBeatResult.getCode())
|
.append("<br>code:").append(idleBeatResult.getCode())
|
||||||
.append("<br>msg:").append(idleBeatResult.getMsg());
|
.append("<br>msg:").append(idleBeatResult.getMsg());
|
||||||
|
|
||||||
// beat success
|
// beat success
|
||||||
if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
||||||
|
@ -13,8 +13,8 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组下机器地址相同,不同JOB均匀散列在不同机器上,保证分组下机器分配JOB平均;且每个JOB固定调度其中一台机器;
|
* 分组下机器地址相同,不同JOB均匀散列在不同机器上,保证分组下机器分配JOB平均;且每个JOB固定调度其中一台机器;
|
||||||
* a、virtual node:解决不均衡问题
|
* a、virtual node:解决不均衡问题
|
||||||
* b、hash method replace hashCode:String的hashCode可能重复,需要进一步扩大hashCode的取值范围
|
* b、hash method replace hashCode:String的hashCode可能重复,需要进一步扩大hashCode的取值范围
|
||||||
* Created by xuxueli on 17/3/10.
|
* Created by xuxueli on 17/3/10.
|
||||||
*/
|
*/
|
||||||
public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
||||||
@ -23,6 +23,7 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get hash code on 2^32 ring (md5散列的方式计算hash值)
|
* get hash code on 2^32 ring (md5散列的方式计算hash值)
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -48,9 +49,9 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
|||||||
|
|
||||||
// hash code, Truncate to 32-bits
|
// hash code, Truncate to 32-bits
|
||||||
long hashCode = ((long) (digest[3] & 0xFF) << 24)
|
long hashCode = ((long) (digest[3] & 0xFF) << 24)
|
||||||
| ((long) (digest[2] & 0xFF) << 16)
|
| ((long) (digest[2] & 0xFF) << 16)
|
||||||
| ((long) (digest[1] & 0xFF) << 8)
|
| ((long) (digest[1] & 0xFF) << 8)
|
||||||
| (digest[0] & 0xFF);
|
| (digest[0] & 0xFF);
|
||||||
|
|
||||||
long truncateHashCode = hashCode & 0xffffffffL;
|
long truncateHashCode = hashCode & 0xffffffffL;
|
||||||
return truncateHashCode;
|
return truncateHashCode;
|
||||||
@ -61,7 +62,7 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
|
|||||||
// ------A1------A2-------A3------
|
// ------A1------A2-------A3------
|
||||||
// -----------J1------------------
|
// -----------J1------------------
|
||||||
TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
|
TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
|
||||||
for (String address: addressList) {
|
for (String address : addressList) {
|
||||||
for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
|
for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
|
||||||
long addressHash = hash("SHARD-" + address + "-NODE-" + i);
|
long addressHash = hash("SHARD-" + address + "-NODE-" + i);
|
||||||
addressRing.put(addressHash, address);
|
addressRing.put(addressHash, address);
|
||||||
|
@ -26,13 +26,13 @@ public class ExecutorRouteFailover extends ExecutorRouter {
|
|||||||
beatResult = executorBiz.beat();
|
beatResult = executorBiz.beat();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
|
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
|
||||||
}
|
}
|
||||||
beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"")
|
beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "")
|
||||||
.append(I18nUtil.getString("jobconf_beat") + ":")
|
.append(I18nUtil.getString("jobconf_beat") + ":")
|
||||||
.append("<br>address:").append(address)
|
.append("<br>address:").append(address)
|
||||||
.append("<br>code:").append(beatResult.getCode())
|
.append("<br>code:").append(beatResult.getCode())
|
||||||
.append("<br>msg:").append(beatResult.getMsg());
|
.append("<br>msg:").append(beatResult.getMsg());
|
||||||
|
|
||||||
// beat success
|
// beat success
|
||||||
if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
public class ExecutorRouteFirst extends ExecutorRouter {
|
public class ExecutorRouteFirst extends ExecutorRouter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList){
|
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
|
||||||
return new ReturnT<String>(addressList.get(0));
|
return new ReturnT<String>(addressList.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个JOB对应的每个执行器,使用频率最低的优先被选举
|
* 单个JOB对应的每个执行器,使用频率最低的优先被选举
|
||||||
* a(*)、LFU(Least Frequently Used):最不经常使用,频率/次数
|
* a(*)、LFU(Least Frequently Used):最不经常使用,频率/次数
|
||||||
* b、LRU(Least Recently Used):最近最久未使用,时间
|
* b、LRU(Least Recently Used):最近最久未使用,时间
|
||||||
*
|
* <p>
|
||||||
* Created by xuxueli on 17/3/10.
|
* Created by xuxueli on 17/3/10.
|
||||||
*/
|
*/
|
||||||
public class ExecutorRouteLFU extends ExecutorRouter {
|
public class ExecutorRouteLFU extends ExecutorRouter {
|
||||||
@ -25,7 +25,7 @@ public class ExecutorRouteLFU extends ExecutorRouter {
|
|||||||
// cache clear
|
// cache clear
|
||||||
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
||||||
jobLfuMap.clear();
|
jobLfuMap.clear();
|
||||||
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
|
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lfu item init
|
// lfu item init
|
||||||
@ -36,20 +36,20 @@ public class ExecutorRouteLFU extends ExecutorRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// put new
|
// put new
|
||||||
for (String address: addressList) {
|
for (String address : addressList) {
|
||||||
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) >1000000 ) {
|
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) > 1000000) {
|
||||||
lfuItemMap.put(address, new Random().nextInt(addressList.size())); // 初始化时主动Random一次,缓解首次压力
|
lfuItemMap.put(address, new Random().nextInt(addressList.size())); // 初始化时主动Random一次,缓解首次压力
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove old
|
// remove old
|
||||||
List<String> delKeys = new ArrayList<>();
|
List<String> delKeys = new ArrayList<>();
|
||||||
for (String existKey: lfuItemMap.keySet()) {
|
for (String existKey : lfuItemMap.keySet()) {
|
||||||
if (!addressList.contains(existKey)) {
|
if (!addressList.contains(existKey)) {
|
||||||
delKeys.add(existKey);
|
delKeys.add(existKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delKeys.size() > 0) {
|
if (delKeys.size() > 0) {
|
||||||
for (String delKey: delKeys) {
|
for (String delKey : delKeys) {
|
||||||
lfuItemMap.remove(delKey);
|
lfuItemMap.remove(delKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个JOB对应的每个执行器,最久为使用的优先被选举
|
* 单个JOB对应的每个执行器,最久为使用的优先被选举
|
||||||
* a、LFU(Least Frequently Used):最不经常使用,频率/次数
|
* a、LFU(Least Frequently Used):最不经常使用,频率/次数
|
||||||
* b(*)、LRU(Least Recently Used):最近最久未使用,时间
|
* b(*)、LRU(Least Recently Used):最近最久未使用,时间
|
||||||
*
|
* <p>
|
||||||
* Created by xuxueli on 17/3/10.
|
* Created by xuxueli on 17/3/10.
|
||||||
*/
|
*/
|
||||||
public class ExecutorRouteLRU extends ExecutorRouter {
|
public class ExecutorRouteLRU extends ExecutorRouter {
|
||||||
@ -27,7 +27,7 @@ public class ExecutorRouteLRU extends ExecutorRouter {
|
|||||||
// cache clear
|
// cache clear
|
||||||
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
||||||
jobLRUMap.clear();
|
jobLRUMap.clear();
|
||||||
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
|
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
// init lru
|
// init lru
|
||||||
@ -43,20 +43,20 @@ public class ExecutorRouteLRU extends ExecutorRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// put new
|
// put new
|
||||||
for (String address: addressList) {
|
for (String address : addressList) {
|
||||||
if (!lruItem.containsKey(address)) {
|
if (!lruItem.containsKey(address)) {
|
||||||
lruItem.put(address, address);
|
lruItem.put(address, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove old
|
// remove old
|
||||||
List<String> delKeys = new ArrayList<>();
|
List<String> delKeys = new ArrayList<>();
|
||||||
for (String existKey: lruItem.keySet()) {
|
for (String existKey : lruItem.keySet()) {
|
||||||
if (!addressList.contains(existKey)) {
|
if (!addressList.contains(existKey)) {
|
||||||
delKeys.add(existKey);
|
delKeys.add(existKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delKeys.size() > 0) {
|
if (delKeys.size() > 0) {
|
||||||
for (String delKey: delKeys) {
|
for (String delKey : delKeys) {
|
||||||
lruItem.remove(delKey);
|
lruItem.remove(delKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class ExecutorRouteLast extends ExecutorRouter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
|
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
|
||||||
return new ReturnT<String>(addressList.get(addressList.size()-1));
|
return new ReturnT<String>(addressList.get(addressList.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
|
|||||||
// cache clear
|
// cache clear
|
||||||
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
|
||||||
routeCountEachJob.clear();
|
routeCountEachJob.clear();
|
||||||
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
|
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomicInteger count = routeCountEachJob.get(jobId);
|
AtomicInteger count = routeCountEachJob.get(jobId);
|
||||||
@ -39,7 +39,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
|
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
|
||||||
String address = addressList.get(count(triggerParam.getJobId())%addressList.size());
|
String address = addressList.get(count(triggerParam.getJobId()) % addressList.size());
|
||||||
return new ReturnT<String>(address);
|
return new ReturnT<String>(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ public enum MisfireStrategyEnum {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem){
|
public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem) {
|
||||||
for (MisfireStrategyEnum item: MisfireStrategyEnum.values()) {
|
for (MisfireStrategyEnum item : MisfireStrategyEnum.values()) {
|
||||||
if (item.name().equals(name)) {
|
if (item.name().equals(name)) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ public enum ScheduleTypeEnum {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem){
|
public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem) {
|
||||||
for (ScheduleTypeEnum item: ScheduleTypeEnum.values()) {
|
for (ScheduleTypeEnum item : ScheduleTypeEnum.values()) {
|
||||||
if (item.name().equals(name)) {
|
if (item.name().equals(name)) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
* @author xuxueli 2018-10-28 00:18:17
|
* @author xuxueli 2018-10-28 00:18:17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class XxlJobScheduler {
|
public class XxlJobScheduler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class);
|
private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class);
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class XxlJobScheduler {
|
|||||||
logger.info(">>>>>>>>> init xxl-job admin success.");
|
logger.info(">>>>>>>>> init xxl-job admin success.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
|
|
||||||
// stop-schedule
|
// stop-schedule
|
||||||
@ -70,17 +70,18 @@ public class XxlJobScheduler {
|
|||||||
|
|
||||||
// ---------------------- I18n ----------------------
|
// ---------------------- I18n ----------------------
|
||||||
|
|
||||||
private void initI18n(){
|
private void initI18n() {
|
||||||
for (ExecutorBlockStrategyEnum item:ExecutorBlockStrategyEnum.values()) {
|
for (ExecutorBlockStrategyEnum item : ExecutorBlockStrategyEnum.values()) {
|
||||||
item.setTitle(I18nUtil.getString("jobconf_block_".concat(item.name())));
|
item.setTitle(I18nUtil.getString("jobconf_block_".concat(item.name())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- executor-client ----------------------
|
// ---------------------- executor-client ----------------------
|
||||||
private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>();
|
private static ConcurrentMap<String, ExecutorBiz> executorBizRepository = new ConcurrentHashMap<String, ExecutorBiz>();
|
||||||
|
|
||||||
public static ExecutorBiz getExecutorBiz(String address) throws Exception {
|
public static ExecutorBiz getExecutorBiz(String address) throws Exception {
|
||||||
// valid
|
// valid
|
||||||
if (address==null || address.trim().length()==0) {
|
if (address == null || address.trim().length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class JobCompleteHelper {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!toStop) {
|
if (!toStop) {
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}" , e);
|
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ public class JobCompleteHelper {
|
|||||||
public void run() {
|
public void run() {
|
||||||
for (HandleCallbackParam handleCallbackParam : callbackParamList) {
|
for (HandleCallbackParam handleCallbackParam : callbackParamList) {
|
||||||
ReturnT<String> callbackResult = callback(handleCallbackParam);
|
ReturnT<String> callbackResult = callback(handleCallbackParam);
|
||||||
logger.debug(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}" ,
|
logger.debug(">>>>>>>>> JobApiController.callback {}, handleCallbackParam={}, callbackResult={}",
|
||||||
(callbackResult.getCode() == ReturnT.SUCCESS_CODE ? "success" : "fail"), handleCallbackParam, callbackResult);
|
(callbackResult.getCode() == ReturnT.SUCCESS_CODE ? "success" : "fail"), handleCallbackParam, callbackResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class JobFailMonitorHelper {
|
|||||||
|
|
||||||
// 2、fail alarm monitor
|
// 2、fail alarm monitor
|
||||||
int newAlarmStatus = 0; // 告警状态:0-默认、-1=锁定状态、1-无需告警、2-告警成功、3-告警失败
|
int newAlarmStatus = 0; // 告警状态:0-默认、-1=锁定状态、1-无需告警、2-告警成功、3-告警失败
|
||||||
if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) {
|
if (info != null) {
|
||||||
boolean alarmResult = XxlJobAdminConfig.getAdminConfig().getJobAlarmer().alarm(info, log);
|
boolean alarmResult = XxlJobAdminConfig.getAdminConfig().getJobAlarmer().alarm(info, log);
|
||||||
newAlarmStatus = alarmResult ? 2 : 3;
|
newAlarmStatus = alarmResult ? 2 : 3;
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +75,7 @@ public class JobFailMonitorHelper {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!toStop) {
|
if (!toStop) {
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}" , e);
|
logger.error(">>>>>>>>>>> xxl-job, job fail monitor thread error:{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,16 @@ public class JobLogReportHelper {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(JobLogReportHelper.class);
|
private static Logger logger = LoggerFactory.getLogger(JobLogReportHelper.class);
|
||||||
|
|
||||||
private static JobLogReportHelper instance = new JobLogReportHelper();
|
private static JobLogReportHelper instance = new JobLogReportHelper();
|
||||||
public static JobLogReportHelper getInstance(){
|
|
||||||
|
public static JobLogReportHelper getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Thread logrThread;
|
private Thread logrThread;
|
||||||
private volatile boolean toStop = false;
|
private volatile boolean toStop = false;
|
||||||
public void start(){
|
|
||||||
|
public void start() {
|
||||||
logrThread = new Thread(new Runnable() {
|
logrThread = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,10 +71,10 @@ public class JobLogReportHelper {
|
|||||||
xxlJobLogReport.setFailCount(0);
|
xxlJobLogReport.setFailCount(0);
|
||||||
|
|
||||||
Map<String, Object> triggerCountMap = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLogReport(todayFrom, todayTo);
|
Map<String, Object> triggerCountMap = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLogReport(todayFrom, todayTo);
|
||||||
if (triggerCountMap!=null && triggerCountMap.size()>0) {
|
if (triggerCountMap != null && triggerCountMap.size() > 0) {
|
||||||
int triggerDayCount = triggerCountMap.containsKey("triggerDayCount")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCount"))):0;
|
int triggerDayCount = triggerCountMap.containsKey("triggerDayCount") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCount"))) : 0;
|
||||||
int triggerDayCountRunning = triggerCountMap.containsKey("triggerDayCountRunning")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountRunning"))):0;
|
int triggerDayCountRunning = triggerCountMap.containsKey("triggerDayCountRunning") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountRunning"))) : 0;
|
||||||
int triggerDayCountSuc = triggerCountMap.containsKey("triggerDayCountSuc")?Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountSuc"))):0;
|
int triggerDayCountSuc = triggerCountMap.containsKey("triggerDayCountSuc") ? Integer.valueOf(String.valueOf(triggerCountMap.get("triggerDayCountSuc"))) : 0;
|
||||||
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
int triggerDayCountFail = triggerDayCount - triggerDayCountRunning - triggerDayCountSuc;
|
||||||
|
|
||||||
xxlJobLogReport.setRunningCount(triggerDayCountRunning);
|
xxlJobLogReport.setRunningCount(triggerDayCountRunning);
|
||||||
@ -94,8 +96,8 @@ public class JobLogReportHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2、log-clean: switch open & once each day
|
// 2、log-clean: switch open & once each day
|
||||||
if (XxlJobAdminConfig.getAdminConfig().getLogretentiondays()>0
|
if (XxlJobAdminConfig.getAdminConfig().getLogretentiondays() > 0
|
||||||
&& System.currentTimeMillis() - lastCleanLogTime > 24*60*60*1000) {
|
&& System.currentTimeMillis() - lastCleanLogTime > 24 * 60 * 60 * 1000) {
|
||||||
|
|
||||||
// expire-time
|
// expire-time
|
||||||
Calendar expiredDay = Calendar.getInstance();
|
Calendar expiredDay = Calendar.getInstance();
|
||||||
@ -110,10 +112,10 @@ public class JobLogReportHelper {
|
|||||||
List<Long> logIds = null;
|
List<Long> logIds = null;
|
||||||
do {
|
do {
|
||||||
logIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findClearLogIds(0, 0, clearBeforeTime, 0, 1000);
|
logIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findClearLogIds(0, 0, clearBeforeTime, 0, 1000);
|
||||||
if (logIds!=null && logIds.size()>0) {
|
if (logIds != null && logIds.size() > 0) {
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().clearLog(logIds);
|
XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().clearLog(logIds);
|
||||||
}
|
}
|
||||||
} while (logIds!=null && logIds.size()>0);
|
} while (logIds != null && logIds.size() > 0);
|
||||||
|
|
||||||
// update clean time
|
// update clean time
|
||||||
lastCleanLogTime = System.currentTimeMillis();
|
lastCleanLogTime = System.currentTimeMillis();
|
||||||
@ -138,7 +140,7 @@ public class JobLogReportHelper {
|
|||||||
logrThread.start();
|
logrThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toStop(){
|
public void toStop() {
|
||||||
toStop = true;
|
toStop = true;
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
logrThread.interrupt();
|
logrThread.interrupt();
|
||||||
|
@ -111,14 +111,14 @@ public class JobRegistryHelper {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!toStop) {
|
if (!toStop) {
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}" , e);
|
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
|
TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
if (!toStop) {
|
if (!toStop) {
|
||||||
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}" , e);
|
logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ public class JobScheduleHelper {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(JobScheduleHelper.class);
|
private static Logger logger = LoggerFactory.getLogger(JobScheduleHelper.class);
|
||||||
|
|
||||||
private static JobScheduleHelper instance = new JobScheduleHelper();
|
private static JobScheduleHelper instance = new JobScheduleHelper();
|
||||||
public static JobScheduleHelper getInstance(){
|
|
||||||
|
public static JobScheduleHelper getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ public class JobScheduleHelper {
|
|||||||
private volatile boolean ringThreadToStop = false;
|
private volatile boolean ringThreadToStop = false;
|
||||||
private volatile static Map<Integer, List<Integer>> ringData = new ConcurrentHashMap<>();
|
private volatile static Map<Integer, List<Integer>> ringData = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void start(){
|
public void start() {
|
||||||
|
|
||||||
// schedule thread
|
// schedule thread
|
||||||
scheduleThread = new Thread(new Runnable() {
|
scheduleThread = new Thread(new Runnable() {
|
||||||
@ -43,7 +44,7 @@ public class JobScheduleHelper {
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(5000 - System.currentTimeMillis()%1000 );
|
TimeUnit.MILLISECONDS.sleep(5000 - System.currentTimeMillis() % 1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
if (!scheduleThreadToStop) {
|
if (!scheduleThreadToStop) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
@ -70,7 +71,7 @@ public class JobScheduleHelper {
|
|||||||
connAutoCommit = conn.getAutoCommit();
|
connAutoCommit = conn.getAutoCommit();
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
|
|
||||||
preparedStatement = conn.prepareStatement( "select * from xxl_job_lock where lock_name = 'schedule_lock' for update" );
|
preparedStatement = conn.prepareStatement("select * from xxl_job_lock where lock_name = 'schedule_lock' for update");
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
|
|
||||||
// tx start
|
// tx start
|
||||||
@ -78,9 +79,9 @@ public class JobScheduleHelper {
|
|||||||
// 1、pre read
|
// 1、pre read
|
||||||
long nowTime = System.currentTimeMillis();
|
long nowTime = System.currentTimeMillis();
|
||||||
List<XxlJobInfo> scheduleList = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleJobQuery(nowTime + PRE_READ_MS, preReadCount);
|
List<XxlJobInfo> scheduleList = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleJobQuery(nowTime + PRE_READ_MS, preReadCount);
|
||||||
if (scheduleList!=null && scheduleList.size()>0) {
|
if (scheduleList != null && scheduleList.size() > 0) {
|
||||||
// 2、push time-ring
|
// 2、push time-ring
|
||||||
for (XxlJobInfo jobInfo: scheduleList) {
|
for (XxlJobInfo jobInfo : scheduleList) {
|
||||||
|
|
||||||
// time-ring jump
|
// time-ring jump
|
||||||
if (nowTime > jobInfo.getTriggerNextTime() + PRE_READ_MS) {
|
if (nowTime > jobInfo.getTriggerNextTime() + PRE_READ_MS) {
|
||||||
@ -92,7 +93,7 @@ public class JobScheduleHelper {
|
|||||||
if (MisfireStrategyEnum.FIRE_ONCE_NOW == misfireStrategyEnum) {
|
if (MisfireStrategyEnum.FIRE_ONCE_NOW == misfireStrategyEnum) {
|
||||||
// FIRE_ONCE_NOW 》 trigger
|
// FIRE_ONCE_NOW 》 trigger
|
||||||
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.MISFIRE, -1, null, null, null);
|
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.MISFIRE, -1, null, null, null);
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId() );
|
logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2、fresh next
|
// 2、fresh next
|
||||||
@ -103,16 +104,16 @@ public class JobScheduleHelper {
|
|||||||
|
|
||||||
// 1、trigger
|
// 1、trigger
|
||||||
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null);
|
JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null);
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId() );
|
logger.debug(">>>>>>>>>>> xxl-job, schedule push trigger : jobId = " + jobInfo.getId());
|
||||||
|
|
||||||
// 2、fresh next
|
// 2、fresh next
|
||||||
refreshNextValidTime(jobInfo, new Date());
|
refreshNextValidTime(jobInfo, new Date());
|
||||||
|
|
||||||
// next-trigger-time in 5s, pre-read again
|
// next-trigger-time in 5s, pre-read again
|
||||||
if (jobInfo.getTriggerStatus()==1 && nowTime + PRE_READ_MS > jobInfo.getTriggerNextTime()) {
|
if (jobInfo.getTriggerStatus() == 1 && nowTime + PRE_READ_MS > jobInfo.getTriggerNextTime()) {
|
||||||
|
|
||||||
// 1、make ring second
|
// 1、make ring second
|
||||||
int ringSecond = (int)((jobInfo.getTriggerNextTime()/1000)%60);
|
int ringSecond = (int) ((jobInfo.getTriggerNextTime() / 1000) % 60);
|
||||||
|
|
||||||
// 2、push time ring
|
// 2、push time ring
|
||||||
pushTimeRing(ringSecond, jobInfo.getId());
|
pushTimeRing(ringSecond, jobInfo.getId());
|
||||||
@ -126,7 +127,7 @@ public class JobScheduleHelper {
|
|||||||
// 2.3、trigger-pre-read:time-ring trigger && make next-trigger-time
|
// 2.3、trigger-pre-read:time-ring trigger && make next-trigger-time
|
||||||
|
|
||||||
// 1、make ring second
|
// 1、make ring second
|
||||||
int ringSecond = (int)((jobInfo.getTriggerNextTime()/1000)%60);
|
int ringSecond = (int) ((jobInfo.getTriggerNextTime() / 1000) % 60);
|
||||||
|
|
||||||
// 2、push time ring
|
// 2、push time ring
|
||||||
pushTimeRing(ringSecond, jobInfo.getId());
|
pushTimeRing(ringSecond, jobInfo.getId());
|
||||||
@ -139,7 +140,7 @@ public class JobScheduleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3、update trigger info
|
// 3、update trigger info
|
||||||
for (XxlJobInfo jobInfo: scheduleList) {
|
for (XxlJobInfo jobInfo : scheduleList) {
|
||||||
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,14 +193,14 @@ public class JobScheduleHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long cost = System.currentTimeMillis()-start;
|
long cost = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
|
|
||||||
// Wait seconds, align second
|
// Wait seconds, align second
|
||||||
if (cost < 1000) { // scan-overtime, not wait
|
if (cost < 1000) { // scan-overtime, not wait
|
||||||
try {
|
try {
|
||||||
// pre-read period: success > scan each second; fail > skip this period;
|
// pre-read period: success > scan each second; fail > skip this period;
|
||||||
TimeUnit.MILLISECONDS.sleep((preReadSuc?1000:PRE_READ_MS) - System.currentTimeMillis()%1000);
|
TimeUnit.MILLISECONDS.sleep((preReadSuc ? 1000 : PRE_READ_MS) - System.currentTimeMillis() % 1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
if (!scheduleThreadToStop) {
|
if (!scheduleThreadToStop) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
@ -238,17 +239,17 @@ public class JobScheduleHelper {
|
|||||||
List<Integer> ringItemData = new ArrayList<>();
|
List<Integer> ringItemData = new ArrayList<>();
|
||||||
int nowSecond = Calendar.getInstance().get(Calendar.SECOND); // 避免处理耗时太长,跨过刻度,向前校验一个刻度;
|
int nowSecond = Calendar.getInstance().get(Calendar.SECOND); // 避免处理耗时太长,跨过刻度,向前校验一个刻度;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
List<Integer> tmpData = ringData.remove( (nowSecond+60-i)%60 );
|
List<Integer> tmpData = ringData.remove((nowSecond + 60 - i) % 60);
|
||||||
if (tmpData != null) {
|
if (tmpData != null) {
|
||||||
ringItemData.addAll(tmpData);
|
ringItemData.addAll(tmpData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ring trigger
|
// ring trigger
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, time-ring beat : " + nowSecond + " = " + Arrays.asList(ringItemData) );
|
logger.debug(">>>>>>>>>>> xxl-job, time-ring beat : " + nowSecond + " = " + Arrays.asList(ringItemData));
|
||||||
if (ringItemData.size() > 0) {
|
if (ringItemData.size() > 0) {
|
||||||
// do trigger
|
// do trigger
|
||||||
for (int jobId: ringItemData) {
|
for (int jobId : ringItemData) {
|
||||||
// do trigger
|
// do trigger
|
||||||
JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);
|
JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);
|
||||||
}
|
}
|
||||||
@ -279,11 +280,11 @@ public class JobScheduleHelper {
|
|||||||
jobInfo.setTriggerLastTime(0);
|
jobInfo.setTriggerLastTime(0);
|
||||||
jobInfo.setTriggerNextTime(0);
|
jobInfo.setTriggerNextTime(0);
|
||||||
logger.warn(">>>>>>>>>>> xxl-job, refreshNextValidTime fail for job: jobId={}, scheduleType={}, scheduleConf={}",
|
logger.warn(">>>>>>>>>>> xxl-job, refreshNextValidTime fail for job: jobId={}, scheduleType={}, scheduleConf={}",
|
||||||
jobInfo.getId(), jobInfo.getScheduleType(), jobInfo.getScheduleConf());
|
jobInfo.getId(), jobInfo.getScheduleType(), jobInfo.getScheduleConf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushTimeRing(int ringSecond, int jobId){
|
private void pushTimeRing(int ringSecond, int jobId) {
|
||||||
// push async ring
|
// push async ring
|
||||||
List<Integer> ringItemData = ringData.get(ringSecond);
|
List<Integer> ringItemData = ringData.get(ringSecond);
|
||||||
if (ringItemData == null) {
|
if (ringItemData == null) {
|
||||||
@ -292,10 +293,10 @@ public class JobScheduleHelper {
|
|||||||
}
|
}
|
||||||
ringItemData.add(jobId);
|
ringItemData.add(jobId);
|
||||||
|
|
||||||
logger.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData) );
|
logger.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toStop(){
|
public void toStop() {
|
||||||
|
|
||||||
// 1、stop schedule
|
// 1、stop schedule
|
||||||
scheduleThreadToStop = true;
|
scheduleThreadToStop = true;
|
||||||
@ -304,7 +305,7 @@ public class JobScheduleHelper {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
if (scheduleThread.getState() != Thread.State.TERMINATED){
|
if (scheduleThread.getState() != Thread.State.TERMINATED) {
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
scheduleThread.interrupt();
|
scheduleThread.interrupt();
|
||||||
try {
|
try {
|
||||||
@ -319,7 +320,7 @@ public class JobScheduleHelper {
|
|||||||
if (!ringData.isEmpty()) {
|
if (!ringData.isEmpty()) {
|
||||||
for (int second : ringData.keySet()) {
|
for (int second : ringData.keySet()) {
|
||||||
List<Integer> tmpData = ringData.get(second);
|
List<Integer> tmpData = ringData.get(second);
|
||||||
if (tmpData!=null && tmpData.size()>0) {
|
if (tmpData != null && tmpData.size() > 0) {
|
||||||
hasRingData = true;
|
hasRingData = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -340,7 +341,7 @@ public class JobScheduleHelper {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
if (ringThread.getState() != Thread.State.TERMINATED){
|
if (ringThread.getState() != Thread.State.TERMINATED) {
|
||||||
// interrupt and wait
|
// interrupt and wait
|
||||||
ringThread.interrupt();
|
ringThread.interrupt();
|
||||||
try {
|
try {
|
||||||
@ -361,7 +362,7 @@ public class JobScheduleHelper {
|
|||||||
Date nextValidTime = new CronExpression(jobInfo.getScheduleConf()).getNextValidTimeAfter(fromTime);
|
Date nextValidTime = new CronExpression(jobInfo.getScheduleConf()).getNextValidTimeAfter(fromTime);
|
||||||
return nextValidTime;
|
return nextValidTime;
|
||||||
} else if (ScheduleTypeEnum.FIX_RATE == scheduleTypeEnum /*|| ScheduleTypeEnum.FIX_DELAY == scheduleTypeEnum*/) {
|
} else if (ScheduleTypeEnum.FIX_RATE == scheduleTypeEnum /*|| ScheduleTypeEnum.FIX_DELAY == scheduleTypeEnum*/) {
|
||||||
return new Date(fromTime.getTime() + Integer.valueOf(jobInfo.getScheduleConf())*1000 );
|
return new Date(fromTime.getTime() + Integer.valueOf(jobInfo.getScheduleConf()) * 1000);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,12 @@ public enum TriggerTypeEnum {
|
|||||||
API(I18nUtil.getString("jobconf_trigger_type_api")),
|
API(I18nUtil.getString("jobconf_trigger_type_api")),
|
||||||
MISFIRE(I18nUtil.getString("jobconf_trigger_type_misfire"));
|
MISFIRE(I18nUtil.getString("jobconf_trigger_type_misfire"));
|
||||||
|
|
||||||
private TriggerTypeEnum(String title){
|
private TriggerTypeEnum(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,13 @@ public class XxlJobTrigger {
|
|||||||
*
|
*
|
||||||
* @param jobId
|
* @param jobId
|
||||||
* @param triggerType
|
* @param triggerType
|
||||||
* @param failRetryCount
|
* @param failRetryCount >=0: use this param
|
||||||
* >=0: use this param
|
* <0: use param from job info config
|
||||||
* <0: use param from job info config
|
|
||||||
* @param executorShardingParam
|
* @param executorShardingParam
|
||||||
* @param executorParam
|
* @param executorParam null: use job param
|
||||||
* null: use job param
|
* not null: cover job param
|
||||||
* not null: cover job param
|
* @param addressList null: use executor addressList
|
||||||
* @param addressList
|
* not null: cover
|
||||||
* null: use executor addressList
|
|
||||||
* not null: cover
|
|
||||||
*/
|
*/
|
||||||
public static void trigger(int jobId,
|
public static void trigger(int jobId,
|
||||||
TriggerTypeEnum triggerType,
|
TriggerTypeEnum triggerType,
|
||||||
@ -57,28 +54,28 @@ public class XxlJobTrigger {
|
|||||||
if (executorParam != null) {
|
if (executorParam != null) {
|
||||||
jobInfo.setExecutorParam(executorParam);
|
jobInfo.setExecutorParam(executorParam);
|
||||||
}
|
}
|
||||||
int finalFailRetryCount = failRetryCount>=0?failRetryCount:jobInfo.getExecutorFailRetryCount();
|
int finalFailRetryCount = failRetryCount >= 0 ? failRetryCount : jobInfo.getExecutorFailRetryCount();
|
||||||
XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(jobInfo.getJobGroup());
|
XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(jobInfo.getJobGroup());
|
||||||
|
|
||||||
// cover addressList
|
// cover addressList
|
||||||
if (addressList!=null && addressList.trim().length()>0) {
|
if (addressList != null && addressList.trim().length() > 0) {
|
||||||
group.setAddressType(1);
|
group.setAddressType(1);
|
||||||
group.setAddressList(addressList.trim());
|
group.setAddressList(addressList.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
// sharding param
|
// sharding param
|
||||||
int[] shardingParam = null;
|
int[] shardingParam = null;
|
||||||
if (executorShardingParam!=null){
|
if (executorShardingParam != null) {
|
||||||
String[] shardingArr = executorShardingParam.split("/");
|
String[] shardingArr = executorShardingParam.split("/");
|
||||||
if (shardingArr.length==2 && isNumeric(shardingArr[0]) && isNumeric(shardingArr[1])) {
|
if (shardingArr.length == 2 && isNumeric(shardingArr[0]) && isNumeric(shardingArr[1])) {
|
||||||
shardingParam = new int[2];
|
shardingParam = new int[2];
|
||||||
shardingParam[0] = Integer.valueOf(shardingArr[0]);
|
shardingParam[0] = Integer.valueOf(shardingArr[0]);
|
||||||
shardingParam[1] = Integer.valueOf(shardingArr[1]);
|
shardingParam[1] = Integer.valueOf(shardingArr[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST==ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null)
|
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null)
|
||||||
&& group.getRegistryList()!=null && !group.getRegistryList().isEmpty()
|
&& group.getRegistryList() != null && !group.getRegistryList().isEmpty()
|
||||||
&& shardingParam==null) {
|
&& shardingParam == null) {
|
||||||
for (int i = 0; i < group.getRegistryList().size(); i++) {
|
for (int i = 0; i < group.getRegistryList().size(); i++) {
|
||||||
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, i, group.getRegistryList().size());
|
processTrigger(group, jobInfo, finalFailRetryCount, triggerType, i, group.getRegistryList().size());
|
||||||
}
|
}
|
||||||
@ -91,7 +88,7 @@ public class XxlJobTrigger {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isNumeric(String str){
|
private static boolean isNumeric(String str) {
|
||||||
try {
|
try {
|
||||||
int result = Integer.valueOf(str);
|
int result = Integer.valueOf(str);
|
||||||
return true;
|
return true;
|
||||||
@ -101,19 +98,19 @@ public class XxlJobTrigger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param group job group, registry list may be empty
|
* @param group job group, registry list may be empty
|
||||||
* @param jobInfo
|
* @param jobInfo
|
||||||
* @param finalFailRetryCount
|
* @param finalFailRetryCount
|
||||||
* @param triggerType
|
* @param triggerType
|
||||||
* @param index sharding index
|
* @param index sharding index
|
||||||
* @param total sharding index
|
* @param total sharding index
|
||||||
*/
|
*/
|
||||||
private static void processTrigger(XxlJobGroup group, XxlJobInfo jobInfo, int finalFailRetryCount, TriggerTypeEnum triggerType, int index, int total){
|
private static void processTrigger(XxlJobGroup group, XxlJobInfo jobInfo, int finalFailRetryCount, TriggerTypeEnum triggerType, int index, int total) {
|
||||||
|
|
||||||
// param
|
// param
|
||||||
ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), ExecutorBlockStrategyEnum.SERIAL_EXECUTION); // block strategy
|
ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(), ExecutorBlockStrategyEnum.SERIAL_EXECUTION); // block strategy
|
||||||
ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null); // route strategy
|
ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null); // route strategy
|
||||||
String shardingParam = (ExecutorRouteStrategyEnum.SHARDING_BROADCAST==executorRouteStrategyEnum)?String.valueOf(index).concat("/").concat(String.valueOf(total)):null;
|
String shardingParam = (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) ? String.valueOf(index).concat("/").concat(String.valueOf(total)) : null;
|
||||||
|
|
||||||
// 1、save log-id
|
// 1、save log-id
|
||||||
XxlJobLog jobLog = new XxlJobLog();
|
XxlJobLog jobLog = new XxlJobLog();
|
||||||
@ -141,7 +138,7 @@ public class XxlJobTrigger {
|
|||||||
// 3、init address
|
// 3、init address
|
||||||
String address = null;
|
String address = null;
|
||||||
ReturnT<String> routeAddressResult = null;
|
ReturnT<String> routeAddressResult = null;
|
||||||
if (group.getRegistryList()!=null && !group.getRegistryList().isEmpty()) {
|
if (group.getRegistryList() != null && !group.getRegistryList().isEmpty()) {
|
||||||
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) {
|
if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) {
|
||||||
if (index < group.getRegistryList().size()) {
|
if (index < group.getRegistryList().size()) {
|
||||||
address = group.getRegistryList().get(index);
|
address = group.getRegistryList().get(index);
|
||||||
@ -171,18 +168,18 @@ public class XxlJobTrigger {
|
|||||||
triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_type")).append(":").append(triggerType.getTitle());
|
triggerMsgSb.append(I18nUtil.getString("jobconf_trigger_type")).append(":").append(triggerType.getTitle());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_admin_adress")).append(":").append(IpUtil.getIp());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_admin_adress")).append(":").append(IpUtil.getIp());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regtype")).append(":")
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regtype")).append(":")
|
||||||
.append( (group.getAddressType() == 0)?I18nUtil.getString("jobgroup_field_addressType_0"):I18nUtil.getString("jobgroup_field_addressType_1") );
|
.append((group.getAddressType() == 0) ? I18nUtil.getString("jobgroup_field_addressType_0") : I18nUtil.getString("jobgroup_field_addressType_1"));
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append(":").append(group.getRegistryList());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobconf_trigger_exe_regaddress")).append(":").append(group.getRegistryList());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append(":").append(executorRouteStrategyEnum.getTitle());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorRouteStrategy")).append(":").append(executorRouteStrategyEnum.getTitle());
|
||||||
if (shardingParam != null) {
|
if (shardingParam != null) {
|
||||||
triggerMsgSb.append("("+shardingParam+")");
|
triggerMsgSb.append("(" + shardingParam + ")");
|
||||||
}
|
}
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append(":").append(blockStrategy.getTitle());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorBlockStrategy")).append(":").append(blockStrategy.getTitle());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append(":").append(jobInfo.getExecutorTimeout());
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_timeout")).append(":").append(jobInfo.getExecutorTimeout());
|
||||||
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append(":").append(finalFailRetryCount);
|
triggerMsgSb.append("<br>").append(I18nUtil.getString("jobinfo_field_executorFailRetryCount")).append(":").append(finalFailRetryCount);
|
||||||
|
|
||||||
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_run") +"<<<<<<<<<<< </span><br>")
|
triggerMsgSb.append("<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_run") + "<<<<<<<<<<< </span><br>")
|
||||||
.append((routeAddressResult!=null&&routeAddressResult.getMsg()!=null)?routeAddressResult.getMsg()+"<br><br>":"").append(triggerResult.getMsg()!=null?triggerResult.getMsg():"");
|
.append((routeAddressResult != null && routeAddressResult.getMsg() != null) ? routeAddressResult.getMsg() + "<br><br>" : "").append(triggerResult.getMsg() != null ? triggerResult.getMsg() : "");
|
||||||
|
|
||||||
// 6、save log trigger-info
|
// 6、save log trigger-info
|
||||||
jobLog.setExecutorAddress(address);
|
jobLog.setExecutorAddress(address);
|
||||||
@ -200,11 +197,12 @@ public class XxlJobTrigger {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* run executor
|
* run executor
|
||||||
|
*
|
||||||
* @param triggerParam
|
* @param triggerParam
|
||||||
* @param address
|
* @param address
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address){
|
public static ReturnT<String> runExecutor(TriggerParam triggerParam, String address) {
|
||||||
ReturnT<String> runResult = null;
|
ReturnT<String> runResult = null;
|
||||||
try {
|
try {
|
||||||
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
|
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);
|
||||||
|
@ -91,7 +91,7 @@ public class CookieUtil {
|
|||||||
public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
|
public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
|
||||||
Cookie cookie = get(request, key);
|
Cookie cookie = get(request, key);
|
||||||
if (cookie != null) {
|
if (cookie != null) {
|
||||||
set(response, key, "" , null, COOKIE_PATH, 0, true);
|
set(response, key, "", null, COOKIE_PATH, 0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ public class I18nUtil {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
|
||||||
|
|
||||||
private static Properties prop = null;
|
private static Properties prop = null;
|
||||||
public static Properties loadI18nProp(){
|
|
||||||
|
public static Properties loadI18nProp() {
|
||||||
if (prop != null) {
|
if (prop != null) {
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ public class I18nUtil {
|
|||||||
|
|
||||||
// load prop
|
// load prop
|
||||||
Resource resource = new ClassPathResource(i18nFile);
|
Resource resource = new ClassPathResource(i18nFile);
|
||||||
EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
|
EncodedResource encodedResource = new EncodedResource(resource, "UTF-8");
|
||||||
prop = PropertiesLoaderUtils.loadProperties(encodedResource);
|
prop = PropertiesLoaderUtils.loadProperties(encodedResource);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
@ -62,12 +63,12 @@ public class I18nUtil {
|
|||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
|
||||||
Properties prop = loadI18nProp();
|
Properties prop = loadI18nProp();
|
||||||
if (keys!=null && keys.length>0) {
|
if (keys != null && keys.length > 0) {
|
||||||
for (String key: keys) {
|
for (String key : keys) {
|
||||||
map.put(key, prop.getProperty(key));
|
map.put(key, prop.getProperty(key));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String key: prop.stringPropertyNames()) {
|
for (String key : prop.stringPropertyNames()) {
|
||||||
map.put(key, prop.getProperty(key));
|
map.put(key, prop.getProperty(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
public class LocalCacheUtil {
|
public class LocalCacheUtil {
|
||||||
|
|
||||||
private static ConcurrentMap<String, LocalCacheData> cacheRepository = new ConcurrentHashMap<String, LocalCacheData>(); // 类型建议用抽象父类,兼容性更好;
|
private static ConcurrentMap<String, LocalCacheData> cacheRepository = new ConcurrentHashMap<String, LocalCacheData>(); // 类型建议用抽象父类,兼容性更好;
|
||||||
private static class LocalCacheData{
|
|
||||||
|
private static class LocalCacheData {
|
||||||
private String key;
|
private String key;
|
||||||
private Object val;
|
private Object val;
|
||||||
private long timeoutTime;
|
private long timeoutTime;
|
||||||
@ -59,13 +60,13 @@ public class LocalCacheUtil {
|
|||||||
* @param cacheTime
|
* @param cacheTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean set(String key, Object val, long cacheTime){
|
public static boolean set(String key, Object val, long cacheTime) {
|
||||||
|
|
||||||
// clean timeout cache, before set new cache (avoid cache too much)
|
// clean timeout cache, before set new cache (avoid cache too much)
|
||||||
cleanTimeoutCache();
|
cleanTimeoutCache();
|
||||||
|
|
||||||
// set new cache
|
// set new cache
|
||||||
if (key==null || key.trim().length()==0) {
|
if (key == null || key.trim().length() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
@ -86,8 +87,8 @@ public class LocalCacheUtil {
|
|||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean remove(String key){
|
public static boolean remove(String key) {
|
||||||
if (key==null || key.trim().length()==0) {
|
if (key == null || key.trim().length() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cacheRepository.remove(key);
|
cacheRepository.remove(key);
|
||||||
@ -100,12 +101,12 @@ public class LocalCacheUtil {
|
|||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Object get(String key){
|
public static Object get(String key) {
|
||||||
if (key==null || key.trim().length()==0) {
|
if (key == null || key.trim().length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
LocalCacheData localCacheData = cacheRepository.get(key);
|
LocalCacheData localCacheData = cacheRepository.get(key);
|
||||||
if (localCacheData!=null && System.currentTimeMillis()<localCacheData.getTimeoutTime()) {
|
if (localCacheData != null && System.currentTimeMillis() < localCacheData.getTimeoutTime()) {
|
||||||
return localCacheData.getVal();
|
return localCacheData.getVal();
|
||||||
} else {
|
} else {
|
||||||
remove(key);
|
remove(key);
|
||||||
@ -118,11 +119,11 @@ public class LocalCacheUtil {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean cleanTimeoutCache(){
|
public static boolean cleanTimeoutCache() {
|
||||||
if (!cacheRepository.keySet().isEmpty()) {
|
if (!cacheRepository.keySet().isEmpty()) {
|
||||||
for (String key: cacheRepository.keySet()) {
|
for (String key : cacheRepository.keySet()) {
|
||||||
LocalCacheData localCacheData = cacheRepository.get(key);
|
LocalCacheData localCacheData = cacheRepository.get(key);
|
||||||
if (localCacheData!=null && System.currentTimeMillis()>=localCacheData.getTimeoutTime()) {
|
if (localCacheData != null && System.currentTimeMillis() >= localCacheData.getTimeoutTime()) {
|
||||||
cacheRepository.remove(key);
|
cacheRepository.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public interface XxlJobRegistryDao {
|
|||||||
@Param("updateTime") Date updateTime);
|
@Param("updateTime") Date updateTime);
|
||||||
|
|
||||||
public int registryDelete(@Param("registryGroup") String registryGroup,
|
public int registryDelete(@Param("registryGroup") String registryGroup,
|
||||||
@Param("registryKey") String registryKey,
|
@Param("registryKey") String registryKey,
|
||||||
@Param("registryValue") String registryValue);
|
@Param("registryValue") String registryValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@ public class LoginService {
|
|||||||
private XxlJobUserDao xxlJobUserDao;
|
private XxlJobUserDao xxlJobUserDao;
|
||||||
|
|
||||||
|
|
||||||
private String makeToken(XxlJobUser xxlJobUser){
|
private String makeToken(XxlJobUser xxlJobUser) {
|
||||||
String tokenJson = JacksonUtil.writeValueAsString(xxlJobUser);
|
String tokenJson = JacksonUtil.writeValueAsString(xxlJobUser);
|
||||||
String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
|
String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
|
||||||
return tokenHex;
|
return tokenHex;
|
||||||
}
|
}
|
||||||
private XxlJobUser parseToken(String tokenHex){
|
|
||||||
|
private XxlJobUser parseToken(String tokenHex) {
|
||||||
XxlJobUser xxlJobUser = null;
|
XxlJobUser xxlJobUser = null;
|
||||||
if (tokenHex != null) {
|
if (tokenHex != null) {
|
||||||
String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
|
String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
|
||||||
@ -41,10 +42,10 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){
|
public ReturnT<String> login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember) {
|
||||||
|
|
||||||
// param
|
// param
|
||||||
if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){
|
if (username == null || username.trim().length() == 0 || password == null || password.trim().length() == 0) {
|
||||||
return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
|
return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class LoginService {
|
|||||||
* @param request
|
* @param request
|
||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
|
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
|
||||||
CookieUtil.remove(request, response, LOGIN_IDENTITY_KEY);
|
CookieUtil.remove(request, response, LOGIN_IDENTITY_KEY);
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ public class LoginService {
|
|||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response){
|
public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response) {
|
||||||
String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY_KEY);
|
String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY_KEY);
|
||||||
if (cookieToken != null) {
|
if (cookieToken != null) {
|
||||||
XxlJobUser cookieUser = null;
|
XxlJobUser cookieUser = null;
|
||||||
@ -103,8 +104,5 @@ public class LoginService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("121312");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
|
|
||||||
// package result
|
// package result
|
||||||
Map<String, Object> maps = new HashMap<String, Object>();
|
Map<String, Object> maps = new HashMap<String, Object>();
|
||||||
maps.put("recordsTotal" , list_count); // 总记录数
|
maps.put("recordsTotal", list_count); // 总记录数
|
||||||
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
||||||
maps.put("data" , list); // 分页列表
|
maps.put("data", list); // 分页列表
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
}
|
}
|
||||||
// 》fix "\r" in shell
|
// 》fix "\r" in shell
|
||||||
if (GlueTypeEnum.GLUE_SHELL == GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource() != null) {
|
if (GlueTypeEnum.GLUE_SHELL == GlueTypeEnum.match(jobInfo.getGlueType()) && jobInfo.getGlueSource() != null) {
|
||||||
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r" , ""));
|
jobInfo.setGlueSource(jobInfo.getGlueSource().replaceAll("\r", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid advanced
|
// valid advanced
|
||||||
@ -373,10 +373,10 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
int executorCount = executorAddressSet.size();
|
int executorCount = executorAddressSet.size();
|
||||||
|
|
||||||
Map<String, Object> dashboardMap = new HashMap<String, Object>();
|
Map<String, Object> dashboardMap = new HashMap<String, Object>();
|
||||||
dashboardMap.put("jobInfoCount" , jobInfoCount);
|
dashboardMap.put("jobInfoCount", jobInfoCount);
|
||||||
dashboardMap.put("jobLogCount" , jobLogCount);
|
dashboardMap.put("jobLogCount", jobLogCount);
|
||||||
dashboardMap.put("jobLogSuccessCount" , jobLogSuccessCount);
|
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
|
||||||
dashboardMap.put("executorCount" , executorCount);
|
dashboardMap.put("executorCount", executorCount);
|
||||||
return dashboardMap;
|
return dashboardMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,14 +420,14 @@ public class XxlJobServiceImpl implements XxlJobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
result.put("triggerDayList" , triggerDayList);
|
result.put("triggerDayList", triggerDayList);
|
||||||
result.put("triggerDayCountRunningList" , triggerDayCountRunningList);
|
result.put("triggerDayCountRunningList", triggerDayCountRunningList);
|
||||||
result.put("triggerDayCountSucList" , triggerDayCountSucList);
|
result.put("triggerDayCountSucList", triggerDayCountSucList);
|
||||||
result.put("triggerDayCountFailList" , triggerDayCountFailList);
|
result.put("triggerDayCountFailList", triggerDayCountFailList);
|
||||||
|
|
||||||
result.put("triggerCountRunningTotal" , triggerCountRunningTotal);
|
result.put("triggerCountRunningTotal", triggerCountRunningTotal);
|
||||||
result.put("triggerCountSucTotal" , triggerCountSucTotal);
|
result.put("triggerCountSucTotal", triggerCountSucTotal);
|
||||||
result.put("triggerCountFailTotal" , triggerCountFailTotal);
|
result.put("triggerCountFailTotal", triggerCountFailTotal);
|
||||||
|
|
||||||
return new ReturnT<Map<String, Object>>(result);
|
return new ReturnT<Map<String, Object>>(result);
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
admin_name=Scheduling Center
|
admin_name=Scheduling Center
|
||||||
admin_name_full=Distributed Task Scheduling Platform XXL-JOB
|
admin_name_full=Distributed Task Scheduling Platform XXL-JOB
|
||||||
admin_version=2.3.0
|
admin_version=2.3.1
|
||||||
admin_i18n=en
|
admin_i18n=en
|
||||||
|
|
||||||
## system
|
## system
|
||||||
system_tips=System message
|
system_tips=System message
|
||||||
system_ok=Confirm
|
system_ok=Confirm
|
||||||
system_close=Close
|
system_close=Close
|
||||||
system_save=Save
|
system_save=Save
|
||||||
system_cancel=Cancel
|
system_cancel=Cancel
|
||||||
system_search=Search
|
system_search=Search
|
||||||
system_status=Status
|
system_status=Status
|
||||||
system_opt=Operate
|
system_opt=Operate
|
||||||
system_please_input=please input
|
system_please_input=please input
|
||||||
system_please_choose=please choose
|
system_please_choose=please choose
|
||||||
system_success=success
|
system_success=success
|
||||||
system_fail=fail
|
system_fail=fail
|
||||||
system_add_suc=add success
|
system_add_suc=add success
|
||||||
@ -191,7 +191,7 @@ joblog_kill_log_limit=Trigger Fail, can not kill job
|
|||||||
joblog_kill_log_byman=Manual operation, kill job
|
joblog_kill_log_byman=Manual operation, kill job
|
||||||
joblog_lost_fail=Job result lost, marked as failure
|
joblog_lost_fail=Job result lost, marked as failure
|
||||||
joblog_rolling_log=Rolling log
|
joblog_rolling_log=Rolling log
|
||||||
joblog_rolling_log_refresh=Refresh
|
joblog_rolling_log_refresh=Refresh
|
||||||
joblog_rolling_log_triggerfail=The job trigger fail, can not view the rolling log
|
joblog_rolling_log_triggerfail=The job trigger fail, can not view the rolling log
|
||||||
joblog_rolling_log_failoften=The request for the Rolling log is terminated, the number of failed requests exceeds the limit, Reload the log on the refresh page
|
joblog_rolling_log_failoften=The request for the Rolling log is terminated, the number of failed requests exceeds the limit, Reload the log on the refresh page
|
||||||
joblog_logid_unvalid=Log ID is illegal
|
joblog_logid_unvalid=Log ID is illegal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
admin_name=任务调度中心
|
admin_name=任务调度中心
|
||||||
admin_name_full=分布式任务调度平台XXL-JOB
|
admin_name_full=分布式任务调度平台XXL-JOB
|
||||||
admin_version=2.3.0
|
admin_version=2.3.1
|
||||||
admin_i18n=
|
admin_i18n=
|
||||||
|
|
||||||
## system
|
## system
|
||||||
@ -273,4 +273,4 @@ user_update_loginuser_limit=禁止操作当前登录账号
|
|||||||
|
|
||||||
## help
|
## help
|
||||||
job_help=使用教程
|
job_help=使用教程
|
||||||
job_help_document=官方文档
|
job_help_document=官方文档
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
admin_name=任務調度中心
|
admin_name=任務調度中心
|
||||||
admin_name_full=分布式任務調度平臺XXL-JOB
|
admin_name_full=分布式任務調度平臺XXL-JOB
|
||||||
admin_version=2.3.0
|
admin_version=2.3.1
|
||||||
admin_i18n=
|
admin_i18n=
|
||||||
|
|
||||||
## system
|
## system
|
||||||
@ -273,4 +273,4 @@ user_update_loginuser_limit=禁止操作當前登入帳號
|
|||||||
|
|
||||||
## help
|
## help
|
||||||
job_help=使用教程
|
job_help=使用教程
|
||||||
job_help_document=官方文件
|
job_help_document=官方文件
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// init date tables
|
// init date tables
|
||||||
var userListTable = $("#user_list").dataTable({
|
var userListTable = $("#user_list").dataTable({
|
||||||
"deferRender": true,
|
"deferRender": true,
|
||||||
"processing" : true,
|
"processing" : true,
|
||||||
"serverSide": true,
|
"serverSide": true,
|
||||||
"ajax": {
|
"ajax": {
|
||||||
url: base_url + "/user/pageList",
|
url: base_url + "/user/pageList",
|
||||||
type:"post",
|
type:"post",
|
||||||
data : function ( d ) {
|
data : function ( d ) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
obj.username = $('#username').val();
|
obj.username = $('#username').val();
|
||||||
obj.role = $('#role').val();
|
obj.role = $('#role').val();
|
||||||
obj.start = d.start;
|
obj.start = d.start;
|
||||||
obj.length = d.length;
|
obj.length = d.length;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"searching": false,
|
"searching": false,
|
||||||
"ordering": false,
|
"ordering": false,
|
||||||
//"scrollX": true, // scroll x,close self-adaption
|
//"scrollX": true, // scroll x,close self-adaption
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"data": 'id',
|
"data": 'id',
|
||||||
"visible" : false,
|
"visible" : false,
|
||||||
"width":'10%'
|
"width":'10%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": 'username',
|
"data": 'username',
|
||||||
"visible" : true,
|
"visible" : true,
|
||||||
"width":'20%'
|
"width":'20%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": 'password',
|
"data": 'password',
|
||||||
"visible" : false,
|
"visible" : false,
|
||||||
"width":'20%',
|
"width":'20%',
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
return '*********';
|
return '*********';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": 'role',
|
"data": 'role',
|
||||||
"visible" : true,
|
"visible" : true,
|
||||||
"width":'10%',
|
"width":'10%',
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
if (data == 1) {
|
if (data == 1) {
|
||||||
return I18n.user_role_admin
|
return I18n.user_role_admin
|
||||||
@ -50,101 +50,101 @@ $(function() {
|
|||||||
return I18n.user_role_normal
|
return I18n.user_role_normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": 'permission',
|
"data": 'permission',
|
||||||
"width":'10%',
|
"width":'10%',
|
||||||
"visible" : false
|
"visible" : false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": I18n.system_opt ,
|
"data": I18n.system_opt ,
|
||||||
"width":'15%',
|
"width":'15%',
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
return function(){
|
return function(){
|
||||||
// html
|
// html
|
||||||
tableData['key'+row.id] = row;
|
tableData['key'+row.id] = row;
|
||||||
var html = '<p id="'+ row.id +'" >'+
|
var html = '<p id="'+ row.id +'" >'+
|
||||||
'<button class="btn btn-warning btn-xs update" type="button">'+ I18n.system_opt_edit +'</button> '+
|
'<button class="btn btn-warning btn-xs update" type="button">'+ I18n.system_opt_edit +'</button> '+
|
||||||
'<button class="btn btn-danger btn-xs delete" type="button">'+ I18n.system_opt_del +'</button> '+
|
'<button class="btn btn-danger btn-xs delete" type="button">'+ I18n.system_opt_del +'</button> '+
|
||||||
'</p>';
|
'</p>';
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"language" : {
|
"language" : {
|
||||||
"sProcessing" : I18n.dataTable_sProcessing ,
|
"sProcessing" : I18n.dataTable_sProcessing ,
|
||||||
"sLengthMenu" : I18n.dataTable_sLengthMenu ,
|
"sLengthMenu" : I18n.dataTable_sLengthMenu ,
|
||||||
"sZeroRecords" : I18n.dataTable_sZeroRecords ,
|
"sZeroRecords" : I18n.dataTable_sZeroRecords ,
|
||||||
"sInfo" : I18n.dataTable_sInfo ,
|
"sInfo" : I18n.dataTable_sInfo ,
|
||||||
"sInfoEmpty" : I18n.dataTable_sInfoEmpty ,
|
"sInfoEmpty" : I18n.dataTable_sInfoEmpty ,
|
||||||
"sInfoFiltered" : I18n.dataTable_sInfoFiltered ,
|
"sInfoFiltered" : I18n.dataTable_sInfoFiltered ,
|
||||||
"sInfoPostFix" : "",
|
"sInfoPostFix" : "",
|
||||||
"sSearch" : I18n.dataTable_sSearch ,
|
"sSearch" : I18n.dataTable_sSearch ,
|
||||||
"sUrl" : "",
|
"sUrl" : "",
|
||||||
"sEmptyTable" : I18n.dataTable_sEmptyTable ,
|
"sEmptyTable" : I18n.dataTable_sEmptyTable ,
|
||||||
"sLoadingRecords" : I18n.dataTable_sLoadingRecords ,
|
"sLoadingRecords" : I18n.dataTable_sLoadingRecords ,
|
||||||
"sInfoThousands" : ",",
|
"sInfoThousands" : ",",
|
||||||
"oPaginate" : {
|
"oPaginate" : {
|
||||||
"sFirst" : I18n.dataTable_sFirst ,
|
"sFirst" : I18n.dataTable_sFirst ,
|
||||||
"sPrevious" : I18n.dataTable_sPrevious ,
|
"sPrevious" : I18n.dataTable_sPrevious ,
|
||||||
"sNext" : I18n.dataTable_sNext ,
|
"sNext" : I18n.dataTable_sNext ,
|
||||||
"sLast" : I18n.dataTable_sLast
|
"sLast" : I18n.dataTable_sLast
|
||||||
},
|
},
|
||||||
"oAria" : {
|
"oAria" : {
|
||||||
"sSortAscending" : I18n.dataTable_sSortAscending ,
|
"sSortAscending" : I18n.dataTable_sSortAscending ,
|
||||||
"sSortDescending" : I18n.dataTable_sSortDescending
|
"sSortDescending" : I18n.dataTable_sSortDescending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// table data
|
// table data
|
||||||
var tableData = {};
|
var tableData = {};
|
||||||
|
|
||||||
// search btn
|
// search btn
|
||||||
$('#searchBtn').on('click', function(){
|
$('#searchBtn').on('click', function(){
|
||||||
userListTable.fnDraw();
|
userListTable.fnDraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// job operate
|
||||||
|
$("#user_list").on('click', '.delete',function() {
|
||||||
|
var id = $(this).parent('p').attr("id");
|
||||||
|
|
||||||
// job operate
|
layer.confirm( I18n.system_ok + I18n.system_opt_del + '?', {
|
||||||
$("#user_list").on('click', '.delete',function() {
|
icon: 3,
|
||||||
var id = $(this).parent('p').attr("id");
|
title: I18n.system_tips ,
|
||||||
|
|
||||||
layer.confirm( I18n.system_ok + I18n.system_opt_del + '?', {
|
|
||||||
icon: 3,
|
|
||||||
title: I18n.system_tips ,
|
|
||||||
btn: [ I18n.system_ok, I18n.system_cancel ]
|
btn: [ I18n.system_ok, I18n.system_cancel ]
|
||||||
}, function(index){
|
}, function(index){
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'POST',
|
type : 'POST',
|
||||||
url : base_url + "/user/remove",
|
url : base_url + "/user/remove",
|
||||||
data : {
|
data : {
|
||||||
"id" : id
|
"id" : id
|
||||||
},
|
},
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
success : function(data){
|
success : function(data){
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
layer.msg( I18n.system_success );
|
layer.msg( I18n.system_success );
|
||||||
userListTable.fnDraw(false);
|
userListTable.fnDraw(false);
|
||||||
} else {
|
} else {
|
||||||
layer.msg( data.msg || I18n.system_opt_del + I18n.system_fail );
|
layer.msg( data.msg || I18n.system_opt_del + I18n.system_fail );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// add role
|
// add role
|
||||||
$("#addModal .form input[name=role]").change(function () {
|
$("#addModal .form input[name=role]").change(function () {
|
||||||
var role = $(this).val();
|
var role = $(this).val();
|
||||||
if (role == 1) {
|
if (role == 1) {
|
||||||
$("#addModal .form input[name=permission]").parents('.form-group').hide();
|
$("#addModal .form input[name=permission]").parents('.form-group').hide();
|
||||||
} else {
|
} else {
|
||||||
$("#addModal .form input[name=permission]").parents('.form-group').show();
|
$("#addModal .form input[name=permission]").parents('.form-group').show();
|
||||||
}
|
}
|
||||||
$("#addModal .form input[name='permission']").prop("checked",false);
|
$("#addModal .form input[name='permission']").prop("checked",false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -154,28 +154,28 @@ $(function() {
|
|||||||
return this.optional(element) || valid.test(value);
|
return this.optional(element) || valid.test(value);
|
||||||
}, I18n.user_username_valid );
|
}, I18n.user_username_valid );
|
||||||
|
|
||||||
// add
|
// add
|
||||||
$(".add").click(function(){
|
$(".add").click(function(){
|
||||||
$('#addModal').modal({backdrop: false, keyboard: false}).modal('show');
|
$('#addModal').modal({backdrop: false, keyboard: false}).modal('show');
|
||||||
});
|
});
|
||||||
var addModalValidate = $("#addModal .form").validate({
|
var addModalValidate = $("#addModal .form").validate({
|
||||||
errorElement : 'span',
|
errorElement : 'span',
|
||||||
errorClass : 'help-block',
|
errorClass : 'help-block',
|
||||||
focusInvalid : true,
|
focusInvalid : true,
|
||||||
rules : {
|
rules : {
|
||||||
username : {
|
username : {
|
||||||
required : true,
|
required : true,
|
||||||
rangelength:[4, 20],
|
rangelength:[4, 20],
|
||||||
myValid01: true
|
myValid01: true
|
||||||
},
|
},
|
||||||
password : {
|
password : {
|
||||||
required : true,
|
required : true,
|
||||||
rangelength:[4, 20]
|
rangelength:[4, 20]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
messages : {
|
messages : {
|
||||||
username : {
|
username : {
|
||||||
required : I18n.system_please_input + I18n.user_username,
|
required : I18n.system_please_input + I18n.user_username,
|
||||||
rangelength: I18n.system_lengh_limit + "[4-20]"
|
rangelength: I18n.system_lengh_limit + "[4-20]"
|
||||||
},
|
},
|
||||||
password : {
|
password : {
|
||||||
@ -183,15 +183,15 @@ $(function() {
|
|||||||
rangelength: I18n.system_lengh_limit + "[4-20]"
|
rangelength: I18n.system_lengh_limit + "[4-20]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
highlight : function(element) {
|
highlight : function(element) {
|
||||||
$(element).closest('.form-group').addClass('has-error');
|
$(element).closest('.form-group').addClass('has-error');
|
||||||
},
|
},
|
||||||
success : function(label) {
|
success : function(label) {
|
||||||
label.closest('.form-group').removeClass('has-error');
|
label.closest('.form-group').removeClass('has-error');
|
||||||
label.remove();
|
label.remove();
|
||||||
},
|
},
|
||||||
errorPlacement : function(error, element) {
|
errorPlacement : function(error, element) {
|
||||||
element.parent('div').append(error);
|
element.parent('div').append(error);
|
||||||
},
|
},
|
||||||
submitHandler : function(form) {
|
submitHandler : function(form) {
|
||||||
|
|
||||||
@ -200,38 +200,38 @@ $(function() {
|
|||||||
permissionArr.push($(this).val());
|
permissionArr.push($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
var paramData = {
|
var paramData = {
|
||||||
"username": $("#addModal .form input[name=username]").val(),
|
"username": $("#addModal .form input[name=username]").val(),
|
||||||
"password": $("#addModal .form input[name=password]").val(),
|
"password": $("#addModal .form input[name=password]").val(),
|
||||||
"role": $("#addModal .form input[name=role]:checked").val(),
|
"role": $("#addModal .form input[name=role]:checked").val(),
|
||||||
"permission": permissionArr.join(',')
|
"permission": permissionArr.join(',')
|
||||||
};
|
};
|
||||||
|
|
||||||
$.post(base_url + "/user/add", paramData, function(data, status) {
|
$.post(base_url + "/user/add", paramData, function(data, status) {
|
||||||
if (data.code == "200") {
|
if (data.code == "200") {
|
||||||
$('#addModal').modal('hide');
|
$('#addModal').modal('hide');
|
||||||
|
|
||||||
layer.msg( I18n.system_add_suc );
|
layer.msg( I18n.system_add_suc );
|
||||||
userListTable.fnDraw();
|
userListTable.fnDraw();
|
||||||
} else {
|
} else {
|
||||||
layer.open({
|
layer.open({
|
||||||
title: I18n.system_tips ,
|
title: I18n.system_tips ,
|
||||||
btn: [ I18n.system_ok ],
|
btn: [ I18n.system_ok ],
|
||||||
content: (data.msg || I18n.system_add_fail),
|
content: (data.msg || I18n.system_add_fail),
|
||||||
icon: '2'
|
icon: '2'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#addModal").on('hide.bs.modal', function () {
|
$("#addModal").on('hide.bs.modal', function () {
|
||||||
$("#addModal .form")[0].reset();
|
$("#addModal .form")[0].reset();
|
||||||
addModalValidate.resetForm();
|
addModalValidate.resetForm();
|
||||||
$("#addModal .form .form-group").removeClass("has-error");
|
$("#addModal .form .form-group").removeClass("has-error");
|
||||||
$(".remote_panel").show(); // remote
|
$(".remote_panel").show(); // remote
|
||||||
|
|
||||||
$("#addModal .form input[name=permission]").parents('.form-group').show();
|
$("#addModal .form input[name=permission]").parents('.form-group').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
// update role
|
// update role
|
||||||
$("#updateModal .form input[name=role]").change(function () {
|
$("#updateModal .form input[name=role]").change(function () {
|
||||||
@ -244,21 +244,21 @@ $(function() {
|
|||||||
$("#updateModal .form input[name='permission']").prop("checked",false);
|
$("#updateModal .form input[name='permission']").prop("checked",false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// update
|
// update
|
||||||
$("#user_list").on('click', '.update',function() {
|
$("#user_list").on('click', '.update',function() {
|
||||||
|
|
||||||
var id = $(this).parent('p').attr("id");
|
var id = $(this).parent('p').attr("id");
|
||||||
var row = tableData['key'+id];
|
var row = tableData['key'+id];
|
||||||
|
|
||||||
// base data
|
// base data
|
||||||
$("#updateModal .form input[name='id']").val( row.id );
|
$("#updateModal .form input[name='id']").val( row.id );
|
||||||
$("#updateModal .form input[name='username']").val( row.username );
|
$("#updateModal .form input[name='username']").val( row.username );
|
||||||
$("#updateModal .form input[name='password']").val( '' );
|
$("#updateModal .form input[name='password']").val( '' );
|
||||||
$("#updateModal .form input[name='role'][value='"+ row.role +"']").click();
|
$("#updateModal .form input[name='role'][value='"+ row.role +"']").click();
|
||||||
var permissionArr = [];
|
var permissionArr = [];
|
||||||
if (row.permission) {
|
if (row.permission) {
|
||||||
permissionArr = row.permission.split(",");
|
permissionArr = row.permission.split(",");
|
||||||
}
|
}
|
||||||
$("#updateModal .form input[name='permission']").each(function () {
|
$("#updateModal .form input[name='permission']").each(function () {
|
||||||
if($.inArray($(this).val(), permissionArr) > -1) {
|
if($.inArray($(this).val(), permissionArr) > -1) {
|
||||||
$(this).prop("checked",true);
|
$(this).prop("checked",true);
|
||||||
@ -267,22 +267,22 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// show
|
// show
|
||||||
$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
|
$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
|
||||||
});
|
});
|
||||||
var updateModalValidate = $("#updateModal .form").validate({
|
var updateModalValidate = $("#updateModal .form").validate({
|
||||||
errorElement : 'span',
|
errorElement : 'span',
|
||||||
errorClass : 'help-block',
|
errorClass : 'help-block',
|
||||||
focusInvalid : true,
|
focusInvalid : true,
|
||||||
highlight : function(element) {
|
highlight : function(element) {
|
||||||
$(element).closest('.form-group').addClass('has-error');
|
$(element).closest('.form-group').addClass('has-error');
|
||||||
},
|
},
|
||||||
success : function(label) {
|
success : function(label) {
|
||||||
label.closest('.form-group').removeClass('has-error');
|
label.closest('.form-group').removeClass('has-error');
|
||||||
label.remove();
|
label.remove();
|
||||||
},
|
},
|
||||||
errorPlacement : function(error, element) {
|
errorPlacement : function(error, element) {
|
||||||
element.parent('div').append(error);
|
element.parent('div').append(error);
|
||||||
},
|
},
|
||||||
submitHandler : function(form) {
|
submitHandler : function(form) {
|
||||||
|
|
||||||
@ -314,15 +314,15 @@ $(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#updateModal").on('hide.bs.modal', function () {
|
$("#updateModal").on('hide.bs.modal', function () {
|
||||||
$("#updateModal .form")[0].reset();
|
$("#updateModal .form")[0].reset();
|
||||||
updateModalValidate.resetForm();
|
updateModalValidate.resetForm();
|
||||||
$("#updateModal .form .form-group").removeClass("has-error");
|
$("#updateModal .form .form-group").removeClass("has-error");
|
||||||
$(".remote_panel").show(); // remote
|
$(".remote_panel").show(); // remote
|
||||||
|
|
||||||
$("#updateModal .form input[name=permission]").parents('.form-group').show();
|
$("#updateModal .form input[name=permission]").parents('.form-group').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ruoyi-vue-plus",
|
"name": "ruoyi-vue-plus",
|
||||||
"version": "4.1.0",
|
"version": "4.2.0",
|
||||||
"description": "RuoYi-Vue-Plus后台管理系统",
|
"description": "RuoYi-Vue-Plus后台管理系统",
|
||||||
"author": "LionLi",
|
"author": "LionLi",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -57,3 +57,15 @@ export function getCodeImg() {
|
|||||||
timeout: 20000
|
timeout: 20000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 短信验证码
|
||||||
|
export function getCodeSms() {
|
||||||
|
return request({
|
||||||
|
url: '/captchaSms',
|
||||||
|
headers: {
|
||||||
|
isToken: false
|
||||||
|
},
|
||||||
|
method: 'get',
|
||||||
|
timeout: 20000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -9,6 +9,14 @@ export function listOss(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询OSS对象基于id串
|
||||||
|
export function listByIds(ossId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/oss/listByIds/' + ossId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 删除OSS对象存储
|
// 删除OSS对象存储
|
||||||
export function delOss(ossId) {
|
export function delOss(ossId) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -17,7 +17,7 @@ $--button-font-weight: 400;
|
|||||||
$--border-color-light: #dfe4ed;
|
$--border-color-light: #dfe4ed;
|
||||||
$--border-color-lighter: #e6ebf5;
|
$--border-color-lighter: #e6ebf5;
|
||||||
|
|
||||||
$--table-border:1px solid#dfe6ec;
|
$--table-border: 1px solid #dfe6ec;
|
||||||
|
|
||||||
/* icon font path, required */
|
/* icon font path, required */
|
||||||
$--font-path: '~element-ui/lib/theme-chalk/fonts';
|
$--font-path: '~element-ui/lib/theme-chalk/fonts';
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import { delOss } from "@/api/system/oss";
|
import { listByIds, delOss } from "@/api/system/oss";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "FileUpload",
|
name: "FileUpload",
|
||||||
@ -83,11 +83,21 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: {
|
value: {
|
||||||
handler(val) {
|
async handler(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
let temp = 1;
|
let temp = 1;
|
||||||
// 首先将值转为数组
|
// 首先将值转为数组
|
||||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
let list;
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
list = val;
|
||||||
|
} else {
|
||||||
|
await listByIds(val).then(res => {
|
||||||
|
list = res.data.map(oss => {
|
||||||
|
oss = { name: oss.originalName, url: oss.url, ossId: oss.ossId };
|
||||||
|
return oss;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
// 然后将数组转为对象数组
|
// 然后将数组转为对象数组
|
||||||
this.fileList = list.map(item => {
|
this.fileList = list.map(item => {
|
||||||
item = { name: item.name, url: item.url, ossId: item.ossId };
|
item = { name: item.name, url: item.url, ossId: item.ossId };
|
||||||
@ -157,7 +167,7 @@ export default {
|
|||||||
this.fileList = this.fileList.concat(this.uploadList);
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
this.uploadList = [];
|
this.uploadList = [];
|
||||||
this.number = 0;
|
this.number = 0;
|
||||||
this.$emit("input", this.fileList);
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
this.$modal.closeLoading();
|
this.$modal.closeLoading();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -170,7 +180,7 @@ export default {
|
|||||||
let ossId = this.fileList[index].ossId;
|
let ossId = this.fileList[index].ossId;
|
||||||
delOss(ossId);
|
delOss(ossId);
|
||||||
this.fileList.splice(index, 1);
|
this.fileList.splice(index, 1);
|
||||||
this.$emit("input", this.fileList);
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
},
|
},
|
||||||
// 获取文件名称
|
// 获取文件名称
|
||||||
getFileName(name) {
|
getFileName(name) {
|
||||||
@ -181,6 +191,15 @@ export default {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 对象转成指定字符串分隔
|
||||||
|
listToString(list, separator) {
|
||||||
|
let strs = "";
|
||||||
|
separator = separator || ",";
|
||||||
|
for (let i in list) {
|
||||||
|
strs += list[i].ossId + separator;
|
||||||
|
}
|
||||||
|
return strs != "" ? strs.substr(0, strs.length - 1) : "";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isExternal } from "@/utils/validate";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ImagePreview",
|
name: "ImagePreview",
|
||||||
@ -33,19 +32,13 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
realSrc() {
|
realSrc() {
|
||||||
let real_src = this.src.split(",")[0];
|
let real_src = this.src.split(",")[0];
|
||||||
if (isExternal(real_src)) {
|
return real_src;
|
||||||
return real_src;
|
|
||||||
}
|
|
||||||
return process.env.VUE_APP_BASE_API + real_src;
|
|
||||||
},
|
},
|
||||||
realSrcList() {
|
realSrcList() {
|
||||||
let real_src_list = this.src.split(",");
|
let real_src_list = this.src.split(",");
|
||||||
let srcList = [];
|
let srcList = [];
|
||||||
real_src_list.forEach(item => {
|
real_src_list.forEach(item => {
|
||||||
if (isExternal(item)) {
|
return srcList.push(item);
|
||||||
return srcList.push(item);
|
|
||||||
}
|
|
||||||
return srcList.push(process.env.VUE_APP_BASE_API + item);
|
|
||||||
});
|
});
|
||||||
return srcList;
|
return srcList;
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import { delOss } from "@/api/system/oss";
|
import { listByIds, delOss } from "@/api/system/oss";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@ -87,10 +87,17 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: {
|
value: {
|
||||||
handler(val) {
|
async handler(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
// 首先将值转为数组
|
// 首先将值转为数组
|
||||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
let list;
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
list = val;
|
||||||
|
} else {
|
||||||
|
await listByIds(val).then(res => {
|
||||||
|
list = res.data;
|
||||||
|
})
|
||||||
|
}
|
||||||
// 然后将数组转为对象数组
|
// 然后将数组转为对象数组
|
||||||
this.fileList = list.map(item => {
|
this.fileList = list.map(item => {
|
||||||
// 此处name使用ossId 防止删除出现重名
|
// 此处name使用ossId 防止删除出现重名
|
||||||
@ -120,7 +127,7 @@ export default {
|
|||||||
let ossId = this.fileList[findex].ossId;
|
let ossId = this.fileList[findex].ossId;
|
||||||
delOss(ossId);
|
delOss(ossId);
|
||||||
this.fileList.splice(findex, 1);
|
this.fileList.splice(findex, 1);
|
||||||
this.$emit("input", this.fileList);
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 上传成功回调
|
// 上传成功回调
|
||||||
@ -131,7 +138,7 @@ export default {
|
|||||||
this.fileList = this.fileList.concat(this.uploadList);
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
this.uploadList = [];
|
this.uploadList = [];
|
||||||
this.number = 0;
|
this.number = 0;
|
||||||
this.$emit("input", this.fileList);
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
this.$modal.closeLoading();
|
this.$modal.closeLoading();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -184,6 +191,15 @@ export default {
|
|||||||
this.dialogImageUrl = file.url;
|
this.dialogImageUrl = file.url;
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
},
|
},
|
||||||
|
// 对象转成指定字符串分隔
|
||||||
|
listToString(list, separator) {
|
||||||
|
let strs = "";
|
||||||
|
separator = separator || ",";
|
||||||
|
for (let i in list) {
|
||||||
|
strs += list[i].ossId + separator;
|
||||||
|
}
|
||||||
|
return strs != "" ? strs.substr(0, strs.length - 1) : "";
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -73,6 +73,9 @@ DictData.install()
|
|||||||
* please remove it before going online! ! !
|
* please remove it before going online! ! !
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// 修改 el-dialog 默认点击遮照为不关闭
|
||||||
|
Element.Dialog.props.closeOnClickModal.default = false
|
||||||
|
|
||||||
Vue.use(Element, {
|
Vue.use(Element, {
|
||||||
size: Cookies.get('size') || 'medium' // set element-ui default size
|
size: Cookies.get('size') || 'medium' // set element-ui default size
|
||||||
})
|
})
|
||||||
|
@ -11,7 +11,7 @@ import DictOptions from './DictOptions'
|
|||||||
export default class DictMeta {
|
export default class DictMeta {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.type = options.type
|
this.type = options.type
|
||||||
this.request = options.request,
|
this.request = options.request
|
||||||
this.responseConverter = options.responseConverter
|
this.responseConverter = options.responseConverter
|
||||||
this.labelField = options.labelField
|
this.labelField = options.labelField
|
||||||
this.valueField = options.valueField
|
this.valueField = options.valueField
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
export default [
|
|
||||||
{
|
|
||||||
layout: 'colFormItem',
|
|
||||||
tagIcon: 'input',
|
|
||||||
label: '手机号',
|
|
||||||
vModel: 'mobile',
|
|
||||||
formId: 6,
|
|
||||||
tag: 'el-input',
|
|
||||||
placeholder: '请输入手机号',
|
|
||||||
defaultValue: '',
|
|
||||||
span: 24,
|
|
||||||
style: { width: '100%' },
|
|
||||||
clearable: true,
|
|
||||||
prepend: '',
|
|
||||||
append: '',
|
|
||||||
'prefix-icon': 'el-icon-mobile',
|
|
||||||
'suffix-icon': '',
|
|
||||||
maxlength: 11,
|
|
||||||
'show-word-limit': true,
|
|
||||||
readonly: false,
|
|
||||||
disabled: false,
|
|
||||||
required: true,
|
|
||||||
changeTag: true,
|
|
||||||
regList: [{
|
|
||||||
pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
|
|
||||||
message: '手机号格式错误'
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
@ -68,7 +68,7 @@ export function addDateRange(params, dateRange, propName) {
|
|||||||
return search;
|
return search;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回显数据字典
|
// 回显数据字典
|
||||||
export function selectDictLabel(datas, value) {
|
export function selectDictLabel(datas, value) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return "";
|
return "";
|
||||||
@ -207,10 +207,10 @@ export function tansParams(params) {
|
|||||||
for (const propName of Object.keys(params)) {
|
for (const propName of Object.keys(params)) {
|
||||||
const value = params[propName];
|
const value = params[propName];
|
||||||
var part = encodeURIComponent(propName) + "=";
|
var part = encodeURIComponent(propName) + "=";
|
||||||
if (value !== null && typeof (value) !== "undefined") {
|
if (value !== null && value !== "" && typeof (value) !== "undefined") {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
for (const key of Object.keys(value)) {
|
for (const key of Object.keys(value)) {
|
||||||
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
|
||||||
let params = propName + '[' + key + ']';
|
let params = propName + '[' + key + ']';
|
||||||
var subPart = encodeURIComponent(params) + "=";
|
var subPart = encodeURIComponent(params) + "=";
|
||||||
result += subPart + encodeURIComponent(value[key]) + "&";
|
result += subPart + encodeURIComponent(value[key]) + "&";
|
||||||
@ -233,4 +233,4 @@ export async function blobValidate(data) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 版本号
|
// 版本号
|
||||||
version: "4.1.0",
|
version: "4.2.0",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -191,7 +191,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
|
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
|
||||||
import { listType, getType } from "@/api/system/dict/type";
|
import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Data",
|
name: "Data",
|
||||||
@ -287,8 +287,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 查询字典类型列表 */
|
/** 查询字典类型列表 */
|
||||||
getTypeList() {
|
getTypeList() {
|
||||||
listType().then(response => {
|
getDictOptionselect().then(response => {
|
||||||
this.typeOptions = response.rows;
|
this.typeOptions = response.data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 查询字典数据列表 */
|
/** 查询字典数据列表 */
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="配置key" prop="configKey">
|
<el-form-item label="配置key" prop="configKey">
|
||||||
<el-select v-model="queryParams.configKey" placeholder="请选择配置key" clearable size="small">
|
<el-input
|
||||||
<el-option
|
v-model="queryParams.configKey"
|
||||||
v-for="configKey in configKeyOptions"
|
placeholder="配置key"
|
||||||
:key="configKey.configKey"
|
clearable
|
||||||
:label="configKey.label"
|
size="small"
|
||||||
:value="configKey.configKey"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="桶名称" prop="bucketName">
|
<el-form-item label="桶名称" prop="bucketName">
|
||||||
<el-input
|
<el-input
|
||||||
@ -77,6 +76,7 @@
|
|||||||
<el-table-column label="主建" align="center" prop="ossConfigId" v-if="false"/>
|
<el-table-column label="主建" align="center" prop="ossConfigId" v-if="false"/>
|
||||||
<el-table-column label="配置key" align="center" prop="configKey" />
|
<el-table-column label="配置key" align="center" prop="configKey" />
|
||||||
<el-table-column label="访问站点" align="center" prop="endpoint" width="200" />
|
<el-table-column label="访问站点" align="center" prop="endpoint" width="200" />
|
||||||
|
<el-table-column label="自定义域名" align="center" prop="domain" width="200" />
|
||||||
<el-table-column label="桶名称" align="center" prop="bucketName" />
|
<el-table-column label="桶名称" align="center" prop="bucketName" />
|
||||||
<el-table-column label="前缀" align="center" prop="prefix" />
|
<el-table-column label="前缀" align="center" prop="prefix" />
|
||||||
<el-table-column label="域" align="center" prop="region" />
|
<el-table-column label="域" align="center" prop="region" />
|
||||||
@ -122,18 +122,14 @@
|
|||||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||||
<el-form-item label="配置key" prop="configKey">
|
<el-form-item label="配置key" prop="configKey">
|
||||||
<el-select v-model="form.configKey" placeholder="请选择配置key">
|
<el-input v-model="form.configKey" placeholder="请输入配置key" />
|
||||||
<el-option
|
|
||||||
v-for="configKey in configKeyOptions"
|
|
||||||
:key="configKey.configKey"
|
|
||||||
:label="configKey.label"
|
|
||||||
:value="configKey.configKey"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="访问站点" prop="endpoint">
|
<el-form-item label="访问站点" prop="endpoint">
|
||||||
<el-input v-model="form.endpoint" placeholder="请输入访问站点" />
|
<el-input v-model="form.endpoint" placeholder="请输入访问站点" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义域名" prop="domain">
|
||||||
|
<el-input v-model="form.domain" placeholder="请输入自定义域名" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="accessKey" prop="accessKey">
|
<el-form-item label="accessKey" prop="accessKey">
|
||||||
<el-input v-model="form.accessKey" placeholder="请输入accessKey" />
|
<el-input v-model="form.accessKey" placeholder="请输入accessKey" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -204,14 +200,6 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
// 对象存储配置表格数据
|
// 对象存储配置表格数据
|
||||||
ossConfigList: [],
|
ossConfigList: [],
|
||||||
// configKeyOptions
|
|
||||||
configKeyOptions: [],
|
|
||||||
configKeyDatas: [
|
|
||||||
{ configKey: "minio", label: "Minio" },
|
|
||||||
{ configKey: "qiniu", label: "七牛云" },
|
|
||||||
{ configKey: "aliyun", label: "阿里云" },
|
|
||||||
{ configKey: "qcloud", label: "腾讯云" },
|
|
||||||
],
|
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
@ -276,7 +264,6 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.configKeyOptions = this.configKeyDatas;
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询对象存储配置列表 */
|
/** 查询对象存储配置列表 */
|
||||||
@ -303,6 +290,7 @@ export default {
|
|||||||
bucketName: undefined,
|
bucketName: undefined,
|
||||||
prefix: undefined,
|
prefix: undefined,
|
||||||
endpoint: undefined,
|
endpoint: undefined,
|
||||||
|
domain: undefined,
|
||||||
isHttps: "N",
|
isHttps: "N",
|
||||||
region: undefined,
|
region: undefined,
|
||||||
status: "1",
|
status: "1",
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
ref="tree"
|
ref="tree"
|
||||||
default-expand-all
|
default-expand-all
|
||||||
|
highlight-current
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -486,7 +486,7 @@
|
|||||||
</el-tree>
|
</el-tree>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="activeData.layout === 'colFormItem'">
|
<template v-if="activeData.layout === 'colFormItem' && activeData.tag !== 'el-button'">
|
||||||
<el-divider>正则校验</el-divider>
|
<el-divider>正则校验</el-divider>
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in activeData.regList"
|
v-for="(item, index) in activeData.regList"
|
||||||
|
@ -316,7 +316,7 @@ export default {
|
|||||||
return result.value || ' ';
|
return result.value || ' ';
|
||||||
},
|
},
|
||||||
/** 复制代码成功 */
|
/** 复制代码成功 */
|
||||||
clipboardSuccess(){
|
clipboardSuccess() {
|
||||||
this.$modal.msgSuccess("复制成功");
|
this.$modal.msgSuccess("复制成功");
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>4.1.0</version>
|
<version>4.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
@ -111,21 +111,15 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- jdk11 缺失依赖 jaxb-->
|
<!-- yml解析器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- servlet包 -->
|
<!-- servlet包 -->
|
||||||
@ -179,6 +173,11 @@
|
|||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.mail</groupId>
|
||||||
|
<artifactId>jakarta.mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@ -225,36 +224,27 @@
|
|||||||
<artifactId>tlog-xxljob-spring-boot-starter</artifactId>
|
<artifactId>tlog-xxljob-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.qiniu</groupId>
|
|
||||||
<artifactId>qiniu-java-sdk</artifactId>
|
|
||||||
<version>${qiniu.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun.oss</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aliyun-sdk-oss</artifactId>
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
<version>${aliyun.oss.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 短信 使用方法查看 SmsConfig 说明 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.qcloud</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>cos_api</artifactId>
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
<version>${qcloud.cos.version}</version>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>com.squareup.okio</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>okio</artifactId>
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.minio</groupId>
|
|
||||||
<artifactId>minio</artifactId>
|
|
||||||
<version>${minio.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匿名访问不鉴权注解
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface Anonymous {
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
|
import com.ruoyi.common.excel.CellMergeStrategy;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel 列单元格合并(合并列相同项)
|
||||||
|
*
|
||||||
|
* 需搭配 {@link CellMergeStrategy} 策略使用
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Inherited
|
||||||
|
public @interface CellMerge {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* col index
|
||||||
|
*/
|
||||||
|
int index() default -1;
|
||||||
|
|
||||||
|
}
|
@ -108,12 +108,6 @@ public class SysUser extends BaseEntity {
|
|||||||
)
|
)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@JsonProperty
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 帐号状态(0正常 1停用)
|
* 帐号状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
package com.ruoyi.common.excel;
|
||||||
|
|
||||||
|
import com.alibaba.excel.metadata.Head;
|
||||||
|
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
||||||
|
import com.ruoyi.common.annotation.CellMerge;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列值重复合并策略
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class CellMergeStrategy extends AbstractMergeStrategy {
|
||||||
|
|
||||||
|
private List<?> list;
|
||||||
|
private boolean hasTitle;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
|
||||||
|
List<CellRangeAddress> cellList = handle(list, hasTitle);
|
||||||
|
// judge the list is not null
|
||||||
|
if (CollectionUtils.isNotEmpty(cellList)) {
|
||||||
|
// the judge is necessary
|
||||||
|
if (cell.getRowIndex() == 1 && cell.getColumnIndex() == 0) {
|
||||||
|
for (CellRangeAddress item : cellList) {
|
||||||
|
sheet.addMergedRegion(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private static List<CellRangeAddress> handle(List<?> list, boolean hasTitle) {
|
||||||
|
List<CellRangeAddress> cellList = new ArrayList<>();
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return cellList;
|
||||||
|
}
|
||||||
|
Class<?> clazz = list.get(0).getClass();
|
||||||
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
|
// 有注解的字段
|
||||||
|
List<Field> mergeFields = new ArrayList<>();
|
||||||
|
List<Integer> mergeFieldsIndex = new ArrayList<>();
|
||||||
|
for (int i = 0; i < fields.length; i++) {
|
||||||
|
Field field = fields[i];
|
||||||
|
if (field.isAnnotationPresent(CellMerge.class)) {
|
||||||
|
CellMerge cm = field.getAnnotation(CellMerge.class);
|
||||||
|
mergeFields.add(field);
|
||||||
|
mergeFieldsIndex.add(cm.index() == -1 ? i : cm.index());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 行合并开始下标
|
||||||
|
int rowIndex = hasTitle ? 1 : 0;
|
||||||
|
Map<Field, RepeatCell> map = new HashMap<>();
|
||||||
|
// 生成两两合并单元格
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
for (int j = 0; j < mergeFields.size(); j++) {
|
||||||
|
Field field = mergeFields.get(j);
|
||||||
|
String name = field.getName();
|
||||||
|
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||||
|
Method readMethod = clazz.getMethod(methodName);
|
||||||
|
Object val = readMethod.invoke(list.get(i));
|
||||||
|
|
||||||
|
int colNum = mergeFieldsIndex.get(j);
|
||||||
|
if (!map.containsKey(field)) {
|
||||||
|
map.put(field, new RepeatCell(val, i));
|
||||||
|
} else {
|
||||||
|
RepeatCell repeatCell = map.get(field);
|
||||||
|
Object cellValue = repeatCell.getValue();
|
||||||
|
if (cellValue == null || "".equals(cellValue)) {
|
||||||
|
// 空值跳过不合并
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (cellValue != val) {
|
||||||
|
if (i - repeatCell.getCurrent() > 1) {
|
||||||
|
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
|
||||||
|
}
|
||||||
|
map.put(field, new RepeatCell(val, i));
|
||||||
|
} else if (i == list.size() - 1) {
|
||||||
|
if (i > repeatCell.getCurrent()) {
|
||||||
|
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cellList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
static class RepeatCell {
|
||||||
|
|
||||||
|
private Object value;
|
||||||
|
|
||||||
|
private int current;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package com.ruoyi.common.helper;
|
package com.ruoyi.common.helper;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
|
import cn.dev33.satoken.context.model.SaStorage;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ public class DataPermissionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> getContext() {
|
public static Map<String, Object> getContext() {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
SaStorage saStorage = SaHolder.getStorage();
|
||||||
Object attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
|
||||||
if (ObjectUtil.isNull(attribute)) {
|
if (ObjectUtil.isNull(attribute)) {
|
||||||
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
|
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
||||||
attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
||||||
}
|
}
|
||||||
if (attribute instanceof Map) {
|
if (attribute instanceof Map) {
|
||||||
return (Map<String, Object>) attribute;
|
return (Map<String, Object>) attribute;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.helper;
|
package com.ruoyi.common.helper;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
@ -13,7 +14,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录鉴权助手
|
* 登录鉴权助手
|
||||||
*
|
*
|
||||||
* user_type 为 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
|
* user_type 为 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
|
||||||
* deivce 为 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
|
* deivce 为 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
|
||||||
* 可以组成 用户类型与设备类型多对多的 权限灵活控制
|
* 可以组成 用户类型与设备类型多对多的 权限灵活控制
|
||||||
@ -29,15 +30,13 @@ public class LoginHelper {
|
|||||||
public static final String JOIN_CODE = ":";
|
public static final String JOIN_CODE = ":";
|
||||||
public static final String LOGIN_USER_KEY = "loginUser";
|
public static final String LOGIN_USER_KEY = "loginUser";
|
||||||
|
|
||||||
private static final ThreadLocal<LoginUser> LOGIN_CACHE = new ThreadLocal<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录系统
|
* 登录系统
|
||||||
*
|
*
|
||||||
* @param loginUser 登录用户信息
|
* @param loginUser 登录用户信息
|
||||||
*/
|
*/
|
||||||
public static void login(LoginUser loginUser) {
|
public static void login(LoginUser loginUser) {
|
||||||
LOGIN_CACHE.set(loginUser);
|
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
||||||
StpUtil.login(loginUser.getLoginId());
|
StpUtil.login(loginUser.getLoginId());
|
||||||
setLoginUser(loginUser);
|
setLoginUser(loginUser);
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ public class LoginHelper {
|
|||||||
* @param loginUser 登录用户信息
|
* @param loginUser 登录用户信息
|
||||||
*/
|
*/
|
||||||
public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) {
|
public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) {
|
||||||
LOGIN_CACHE.set(loginUser);
|
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
||||||
StpUtil.login(loginUser.getLoginId(), deviceType.getDevice());
|
StpUtil.login(loginUser.getLoginId(), deviceType.getDevice());
|
||||||
setLoginUser(loginUser);
|
setLoginUser(loginUser);
|
||||||
}
|
}
|
||||||
@ -65,18 +64,13 @@ public class LoginHelper {
|
|||||||
* 获取用户(多级缓存)
|
* 获取用户(多级缓存)
|
||||||
*/
|
*/
|
||||||
public static LoginUser getLoginUser() {
|
public static LoginUser getLoginUser() {
|
||||||
LoginUser loginUser = LOGIN_CACHE.get();
|
LoginUser loginUser = (LoginUser) SaHolder.getStorage().get(LOGIN_USER_KEY);
|
||||||
if (loginUser != null) {
|
if (loginUser != null) {
|
||||||
return loginUser;
|
return loginUser;
|
||||||
}
|
}
|
||||||
return (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
|
loginUser = (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
|
||||||
}
|
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
|
||||||
|
return loginUser;
|
||||||
/**
|
|
||||||
* 清除一级缓存 防止内存问题
|
|
||||||
*/
|
|
||||||
public static void clearCache() {
|
|
||||||
LOGIN_CACHE.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,9 +27,9 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
|
|||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
||||||
if (sensitiveService.isSensitive()) {
|
if (sensitiveService.isSensitive()) {
|
||||||
gen.writeString(value);
|
|
||||||
} else {
|
|
||||||
gen.writeString(strategy.desensitizer().apply(value));
|
gen.writeString(strategy.desensitizer().apply(value));
|
||||||
|
} else {
|
||||||
|
gen.writeString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
468
ruoyi/src/main/java/com/ruoyi/common/utils/email/MailUtils.java
Normal file
468
ruoyi/src/main/java/com/ruoyi/common/utils/email/MailUtils.java
Normal file
@ -0,0 +1,468 @@
|
|||||||
|
package com.ruoyi.common.utils.email;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.CharUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.mail.*;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.mail.Authenticator;
|
||||||
|
import javax.mail.Session;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件工具类
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class MailUtils {
|
||||||
|
|
||||||
|
private static final MailAccount ACCOUNT = SpringUtils.getBean(MailAccount.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邮件发送实例
|
||||||
|
*/
|
||||||
|
public static MailAccount getMailAccount() {
|
||||||
|
return ACCOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邮件发送实例 (自定义发送人以及授权码)
|
||||||
|
*
|
||||||
|
* @param user 发送人
|
||||||
|
* @param pass 授权码
|
||||||
|
*/
|
||||||
|
public static MailAccount getMailAccount(String from, String user, String pass) {
|
||||||
|
ACCOUNT.setFrom(StringUtils.blankToDefault(from, ACCOUNT.getFrom()));
|
||||||
|
ACCOUNT.setUser(StringUtils.blankToDefault(user, ACCOUNT.getUser()));
|
||||||
|
ACCOUNT.setPass(StringUtils.blankToDefault(pass, ACCOUNT.getPass()));
|
||||||
|
return ACCOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送文本邮件,发送给单个或多个收件人<br>
|
||||||
|
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String sendText(String to, String subject, String content, File... files) {
|
||||||
|
return send(to, subject, content, false, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
||||||
|
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String sendHtml(String to, String subject, String content, File... files) {
|
||||||
|
return send(to, subject, content, true, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
|
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String send(String to, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(splitAddress(to), subject, content, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
|
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public static String send(String to, String cc, String bcc, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送文本邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String sendText(Collection<String> tos, String subject, String content, File... files) {
|
||||||
|
return send(tos, subject, content, false, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String sendHtml(Collection<String> tos, String subject, String content, File... files) {
|
||||||
|
return send(tos, subject, content, true, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String send(Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(tos, null, null, subject, content, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param ccs 抄送人列表,可以为null或空
|
||||||
|
* @param bccs 密送人列表,可以为null或空
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, null, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件认证对象
|
||||||
|
* @param to 收件人,多个收件人逗号或者分号隔开
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, String to, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, splitAddress(to), subject, content, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件帐户信息
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, tos, null, null, subject, content, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件帐户信息
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param ccs 抄送人列表,可以为null或空
|
||||||
|
* @param bccs 密送人列表,可以为null或空
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, false, tos, ccs, bccs, subject, content, null, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送HTML邮件,发送给单个或多个收件人<br>
|
||||||
|
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String sendHtml(String to, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
||||||
|
return send(to, subject, content, imageMap, true, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
|
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String send(String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(splitAddress(to), subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
|
||||||
|
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
*
|
||||||
|
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public static String send(String to, String cc, String bcc, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送HTML邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String sendHtml(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, File... files) {
|
||||||
|
return send(tos, subject, content, imageMap, true, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
*/
|
||||||
|
public static String send(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(tos, null, null, subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用配置文件中设置的账户发送邮件,发送给多人
|
||||||
|
*
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param ccs 抄送人列表,可以为null或空
|
||||||
|
* @param bccs 密送人列表,可以为null或空
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件认证对象
|
||||||
|
* @param to 收件人,多个收件人逗号或者分号隔开
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, splitAddress(to), subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件帐户信息
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, tos, null, null, subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件帐户信息
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param ccs 抄送人列表,可以为null或空
|
||||||
|
* @param bccs 密送人列表,可以为null或空
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:$IMAGE_PLACEHOLDER
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap,
|
||||||
|
boolean isHtml, File... files) {
|
||||||
|
return send(mailAccount, false, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置文件,获取邮件客户端会话
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件账户配置
|
||||||
|
* @param isSingleton 是否单例(全局共享会话)
|
||||||
|
* @return {@link Session}
|
||||||
|
* @since 5.5.7
|
||||||
|
*/
|
||||||
|
public static Session getSession(MailAccount mailAccount, boolean isSingleton) {
|
||||||
|
Authenticator authenticator = null;
|
||||||
|
if (mailAccount.isAuth()) {
|
||||||
|
authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
||||||
|
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------------ Private method start
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件给多人
|
||||||
|
*
|
||||||
|
* @param mailAccount 邮件帐户信息
|
||||||
|
* @param useGlobalSession 是否全局共享Session
|
||||||
|
* @param tos 收件人列表
|
||||||
|
* @param ccs 抄送人列表,可以为null或空
|
||||||
|
* @param bccs 密送人列表,可以为null或空
|
||||||
|
* @param subject 标题
|
||||||
|
* @param content 正文
|
||||||
|
* @param imageMap 图片与占位符,占位符格式为cid:${cid}
|
||||||
|
* @param isHtml 是否为HTML格式
|
||||||
|
* @param files 附件列表
|
||||||
|
* @return message-id
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content,
|
||||||
|
Map<String, InputStream> imageMap, boolean isHtml, File... files) {
|
||||||
|
final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession);
|
||||||
|
|
||||||
|
// 可选抄送人
|
||||||
|
if (CollUtil.isNotEmpty(ccs)) {
|
||||||
|
mail.setCcs(ccs.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
// 可选密送人
|
||||||
|
if (CollUtil.isNotEmpty(bccs)) {
|
||||||
|
mail.setBccs(bccs.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
mail.setTos(tos.toArray(new String[0]));
|
||||||
|
mail.setTitle(subject);
|
||||||
|
mail.setContent(content);
|
||||||
|
mail.setHtml(isHtml);
|
||||||
|
mail.setFiles(files);
|
||||||
|
|
||||||
|
// 图片
|
||||||
|
if (MapUtil.isNotEmpty(imageMap)) {
|
||||||
|
for (Map.Entry<String, InputStream> entry : imageMap.entrySet()) {
|
||||||
|
mail.addImage(entry.getKey(), entry.getValue());
|
||||||
|
// 关闭流
|
||||||
|
IoUtil.close(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mail.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将多个联系人转为列表,分隔符为逗号或者分号
|
||||||
|
*
|
||||||
|
* @param addresses 多个联系人,如果为空返回null
|
||||||
|
* @return 联系人列表
|
||||||
|
*/
|
||||||
|
private static List<String> splitAddress(String addresses) {
|
||||||
|
if (StrUtil.isBlank(addresses)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> result;
|
||||||
|
if (StrUtil.contains(addresses, CharUtil.COMMA)) {
|
||||||
|
result = StrUtil.splitTrim(addresses, CharUtil.COMMA);
|
||||||
|
} else if (StrUtil.contains(addresses, ';')) {
|
||||||
|
result = StrUtil.splitTrim(addresses, ';');
|
||||||
|
} else {
|
||||||
|
result = CollUtil.newArrayList(addresses);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------------ Private method end
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 媒体类型工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class MimeTypeUtils {
|
||||||
|
public static final String IMAGE_PNG = "image/png";
|
||||||
|
|
||||||
|
public static final String IMAGE_JPG = "image/jpg";
|
||||||
|
|
||||||
|
public static final String IMAGE_JPEG = "image/jpeg";
|
||||||
|
|
||||||
|
public static final String IMAGE_BMP = "image/bmp";
|
||||||
|
|
||||||
|
public static final String IMAGE_GIF = "image/gif";
|
||||||
|
|
||||||
|
public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"};
|
||||||
|
|
||||||
|
public static final String[] FLASH_EXTENSION = {"swf", "flv"};
|
||||||
|
|
||||||
|
public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
|
||||||
|
"asf", "rm", "rmvb"};
|
||||||
|
|
||||||
|
public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"};
|
||||||
|
|
||||||
|
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
||||||
|
// 图片
|
||||||
|
"bmp", "gif", "jpg", "jpeg", "png",
|
||||||
|
// word excel powerpoint
|
||||||
|
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
||||||
|
// 压缩文件
|
||||||
|
"rar", "zip", "gz", "bz2",
|
||||||
|
// 视频格式
|
||||||
|
"mp4", "avi", "rmvb",
|
||||||
|
// pdf
|
||||||
|
"pdf"};
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,17 @@
|
|||||||
package com.ruoyi.common.utils.poi;
|
package com.ruoyi.common.utils.poi;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.io.resource.ClassPathResource;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.ExcelWriter;
|
||||||
|
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
|
||||||
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||||
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||||
|
import com.alibaba.excel.write.metadata.fill.FillWrapper;
|
||||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||||
import com.ruoyi.common.convert.ExcelBigNumberConvert;
|
import com.ruoyi.common.convert.ExcelBigNumberConvert;
|
||||||
|
import com.ruoyi.common.excel.CellMergeStrategy;
|
||||||
import com.ruoyi.common.excel.DefaultExcelListener;
|
import com.ruoyi.common.excel.DefaultExcelListener;
|
||||||
import com.ruoyi.common.excel.ExcelListener;
|
import com.ruoyi.common.excel.ExcelListener;
|
||||||
import com.ruoyi.common.excel.ExcelResult;
|
import com.ruoyi.common.excel.ExcelResult;
|
||||||
@ -16,7 +24,10 @@ import javax.servlet.ServletOutputStream;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel相关处理
|
* Excel相关处理
|
||||||
@ -69,27 +80,125 @@ public class ExcelUtil {
|
|||||||
*
|
*
|
||||||
* @param list 导出数据集合
|
* @param list 导出数据集合
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @return 结果
|
* @param clazz 实体类
|
||||||
|
* @param response 响应体
|
||||||
*/
|
*/
|
||||||
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
|
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
|
||||||
|
exportExcel(list, sheetName, clazz, false, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param list 导出数据集合
|
||||||
|
* @param sheetName 工作表的名称
|
||||||
|
* @param clazz 实体类
|
||||||
|
* @param merge 是否合并单元格
|
||||||
|
* @param response 响应体
|
||||||
|
*/
|
||||||
|
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, boolean merge, HttpServletResponse response) {
|
||||||
try {
|
try {
|
||||||
String filename = encodingFilename(sheetName);
|
resetResponse(sheetName, response);
|
||||||
response.reset();
|
|
||||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
|
||||||
ServletOutputStream os = response.getOutputStream();
|
ServletOutputStream os = response.getOutputStream();
|
||||||
EasyExcel.write(os, clazz)
|
ExcelWriterSheetBuilder builder = EasyExcel.write(os, clazz)
|
||||||
.autoCloseStream(false)
|
.autoCloseStream(false)
|
||||||
// 自动适配
|
// 自动适配
|
||||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||||
// 大数值自动转换 防止失真
|
// 大数值自动转换 防止失真
|
||||||
.registerConverter(new ExcelBigNumberConvert())
|
.registerConverter(new ExcelBigNumberConvert())
|
||||||
.sheet(sheetName).doWrite(list);
|
.sheet(sheetName);
|
||||||
|
if (merge) {
|
||||||
|
// 合并处理器
|
||||||
|
builder.registerWriteHandler(new CellMergeStrategy(list, true));
|
||||||
|
}
|
||||||
|
builder.doWrite(list);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("导出Excel异常");
|
throw new RuntimeException("导出Excel异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单表多数据模板导出 模板格式为 {.属性}
|
||||||
|
*
|
||||||
|
* @param filename 文件名
|
||||||
|
* @param templatePath 模板路径 resource 目录下的路径包括模板文件名
|
||||||
|
* 例如: excel/temp.xlsx
|
||||||
|
* 重点: 模板文件必须放置到启动类对应的 resource 目录下
|
||||||
|
* @param data 模板需要的数据
|
||||||
|
*/
|
||||||
|
public static void exportTemplate(List<Object> data, String filename, String templatePath, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
resetResponse(filename, response);
|
||||||
|
ClassPathResource templateResource = new ClassPathResource(templatePath);
|
||||||
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
|
||||||
|
.withTemplate(templateResource.getStream())
|
||||||
|
.autoCloseStream(false)
|
||||||
|
// 大数值自动转换 防止失真
|
||||||
|
.registerConverter(new ExcelBigNumberConvert())
|
||||||
|
.build();
|
||||||
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||||
|
if (CollUtil.isEmpty(data)) {
|
||||||
|
throw new IllegalArgumentException("数据为空");
|
||||||
|
}
|
||||||
|
// 单表多数据导出 模板格式为 {.属性}
|
||||||
|
for (Object d : data) {
|
||||||
|
excelWriter.fill(d, writeSheet);
|
||||||
|
}
|
||||||
|
excelWriter.finish();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("导出Excel异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多表多数据模板导出 模板格式为 {key.属性}
|
||||||
|
*
|
||||||
|
* @param filename 文件名
|
||||||
|
* @param templatePath 模板路径 resource 目录下的路径包括模板文件名
|
||||||
|
* 例如: excel/temp.xlsx
|
||||||
|
* 重点: 模板文件必须放置到启动类对应的 resource 目录下
|
||||||
|
* @param data 模板需要的数据
|
||||||
|
*/
|
||||||
|
public static void exportTemplateMultiList(Map<String, Object> data, String filename, String templatePath, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
resetResponse(filename, response);
|
||||||
|
ClassPathResource templateResource = new ClassPathResource(templatePath);
|
||||||
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
|
||||||
|
.withTemplate(templateResource.getStream())
|
||||||
|
.autoCloseStream(false)
|
||||||
|
// 大数值自动转换 防止失真
|
||||||
|
.registerConverter(new ExcelBigNumberConvert())
|
||||||
|
.build();
|
||||||
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||||
|
if (CollUtil.isEmpty(data)) {
|
||||||
|
throw new IllegalArgumentException("数据为空");
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Object> map : data.entrySet()) {
|
||||||
|
// 设置列表后续还有数据
|
||||||
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||||
|
if (map.getValue() instanceof Collection) {
|
||||||
|
// 多表导出必须使用 FillWrapper
|
||||||
|
excelWriter.fill(new FillWrapper(map.getKey(), (Collection<?>) map.getValue()), fillConfig, writeSheet);
|
||||||
|
} else {
|
||||||
|
excelWriter.fill(map.getValue(), writeSheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
excelWriter.finish();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("导出Excel异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置响应体
|
||||||
|
*/
|
||||||
|
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
||||||
|
String filename = encodingFilename(sheetName);
|
||||||
|
response.reset();
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析导出值 0=男,1=女,2=未知
|
* 解析导出值 0=男,1=女,2=未知
|
||||||
*
|
*
|
||||||
@ -103,7 +212,7 @@ public class ExcelUtil {
|
|||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(",");
|
||||||
for (String item : convertSource) {
|
for (String item : convertSource) {
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(separator, propertyValue)) {
|
if (StringUtils.containsAny(propertyValue, separator)) {
|
||||||
for (String value : propertyValue.split(separator)) {
|
for (String value : propertyValue.split(separator)) {
|
||||||
if (itemArray[0].equals(value)) {
|
if (itemArray[0].equals(value)) {
|
||||||
propertyString.append(itemArray[1] + separator);
|
propertyString.append(itemArray[1] + separator);
|
||||||
@ -132,7 +241,7 @@ public class ExcelUtil {
|
|||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(",");
|
||||||
for (String item : convertSource) {
|
for (String item : convertSource) {
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(separator, propertyValue)) {
|
if (StringUtils.containsAny(propertyValue, separator)) {
|
||||||
for (String value : propertyValue.split(separator)) {
|
for (String value : propertyValue.split(separator)) {
|
||||||
if (itemArray[1].equals(value)) {
|
if (itemArray[1].equals(value)) {
|
||||||
propertyString.append(itemArray[0] + separator);
|
propertyString.append(itemArray[0] + separator);
|
||||||
|
@ -6,11 +6,11 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.redisson.api.*;
|
import org.redisson.api.*;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ public class RedisUtils {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
long timeToLive = bucket.remainTimeToLive();
|
long timeToLive = bucket.remainTimeToLive();
|
||||||
bucket.set(value);
|
bucket.set(value);
|
||||||
bucket.expire(timeToLive, TimeUnit.MILLISECONDS);
|
bucket.expire(Duration.ofMillis(timeToLive));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bucket.set(value);
|
bucket.set(value);
|
||||||
@ -119,13 +119,12 @@ public class RedisUtils {
|
|||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @param value 缓存的值
|
* @param value 缓存的值
|
||||||
* @param timeout 时间
|
* @param duration 时间
|
||||||
* @param timeUnit 时间颗粒度
|
|
||||||
*/
|
*/
|
||||||
public static <T> void setCacheObject(final String key, final T value, final long timeout, final TimeUnit timeUnit) {
|
public static <T> void setCacheObject(final String key, final T value, final Duration duration) {
|
||||||
RBucket<T> result = CLIENT.getBucket(key);
|
RBucket<T> result = CLIENT.getBucket(key);
|
||||||
result.set(value);
|
result.set(value);
|
||||||
result.expire(timeout, timeUnit);
|
result.expire(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,20 +148,19 @@ public class RedisUtils {
|
|||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public static boolean expire(final String key, final long timeout) {
|
public static boolean expire(final String key, final long timeout) {
|
||||||
return expire(key, timeout, TimeUnit.SECONDS);
|
return expire(key, Duration.ofSeconds(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置有效时间
|
* 设置有效时间
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param timeout 超时时间
|
* @param duration 超时时间
|
||||||
* @param unit 时间单位
|
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public static boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
public static boolean expire(final String key, final Duration duration) {
|
||||||
RBucket rBucket = CLIENT.getBucket(key);
|
RBucket rBucket = CLIENT.getBucket(key);
|
||||||
return rBucket.expire(timeout, unit);
|
return rBucket.expire(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -366,6 +364,50 @@ public class RedisUtils {
|
|||||||
return rMap.getAll(hKeys);
|
return rMap.getAll(hKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置原子值
|
||||||
|
*
|
||||||
|
* @param key Redis键
|
||||||
|
* @param value 值
|
||||||
|
*/
|
||||||
|
public static void setAtomicValue(String key, long value) {
|
||||||
|
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
||||||
|
atomic.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取原子值
|
||||||
|
*
|
||||||
|
* @param key Redis键
|
||||||
|
* @return 当前值
|
||||||
|
*/
|
||||||
|
public static long getAtomicValue(String key) {
|
||||||
|
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
||||||
|
return atomic.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递增原子值
|
||||||
|
*
|
||||||
|
* @param key Redis键
|
||||||
|
* @return 当前值
|
||||||
|
*/
|
||||||
|
public static long incrAtomicValue(String key) {
|
||||||
|
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
||||||
|
return atomic.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递减原子值
|
||||||
|
*
|
||||||
|
* @param key Redis键
|
||||||
|
* @return 当前值
|
||||||
|
*/
|
||||||
|
public static long decrAtomicValue(String key) {
|
||||||
|
RAtomicLong atomic = CLIENT.getAtomicLong(key);
|
||||||
|
return atomic.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的基本对象列表
|
* 获得缓存的基本对象列表
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.utils.email.MailUtils;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件发送案例
|
||||||
|
*
|
||||||
|
* @author Michelle.Chung
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "邮件发送案例", tags = {"邮件发送案例"})
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/demo/mail")
|
||||||
|
public class MailController {
|
||||||
|
|
||||||
|
@ApiOperation("发送邮件")
|
||||||
|
@GetMapping("/sendSimpleMessage")
|
||||||
|
public R<Void> sendSimpleMessage(@ApiParam("接收人") String to,
|
||||||
|
@ApiParam("标题") String subject,
|
||||||
|
@ApiParam("内容") String text) {
|
||||||
|
MailUtils.sendText(to, subject, text);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("发送邮件(带附件)")
|
||||||
|
@GetMapping("/sendMessageWithAttachment")
|
||||||
|
public R<Void> sendMessageWithAttachment(@ApiParam("接收人") String to,
|
||||||
|
@ApiParam("标题") String subject,
|
||||||
|
@ApiParam("内容") String text,
|
||||||
|
@ApiParam("附件路径") String filePath) {
|
||||||
|
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring-cache 演示案例
|
* spring-cache 演示案例
|
||||||
@ -87,7 +87,7 @@ public class RedisCacheController {
|
|||||||
@GetMapping("/test6")
|
@GetMapping("/test6")
|
||||||
public R<Boolean> test6(String key, String value) {
|
public R<Boolean> test6(String key, String value) {
|
||||||
RedisUtils.setCacheObject(key, value);
|
RedisUtils.setCacheObject(key, value);
|
||||||
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
|
boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10));
|
||||||
System.out.println("***********" + flag);
|
System.out.println("***********" + flag);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(11 * 1000);
|
Thread.sleep(11 * 1000);
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import com.ruoyi.sms.config.properties.SmsProperties;
|
||||||
|
import com.ruoyi.sms.core.SmsTemplate;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信演示案例
|
||||||
|
* 请先阅读文档 否则无法使用
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
* @version 4.2.0
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Api(value = "短信演示案例", tags = {"短信演示案例"})
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/demo/sms")
|
||||||
|
public class SmsController {
|
||||||
|
|
||||||
|
private final SmsProperties smsProperties;
|
||||||
|
// private final SmsTemplate smsTemplate; // 可以使用spring注入
|
||||||
|
// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
|
||||||
|
|
||||||
|
@ApiOperation("发送短信Aliyun")
|
||||||
|
@GetMapping("/sendAliyun")
|
||||||
|
public R<Object> sendAliyun(@ApiParam("电话号") String phones,
|
||||||
|
@ApiParam("模板ID") String templateId) {
|
||||||
|
if (!smsProperties.getEnabled()) {
|
||||||
|
return R.fail("当前系统没有开启短信功能!");
|
||||||
|
}
|
||||||
|
if (!SpringUtils.containsBean("aliyunSmsTemplate")) {
|
||||||
|
return R.fail("阿里云依赖未引入!");
|
||||||
|
}
|
||||||
|
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
||||||
|
Map<String, String> map = new HashMap<>(1);
|
||||||
|
map.put("code", "1234");
|
||||||
|
Object send = smsTemplate.send(phones, templateId, map);
|
||||||
|
return R.ok(send);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("发送短信Tencent")
|
||||||
|
@GetMapping("/sendTencent")
|
||||||
|
public R<Object> sendTencent(@ApiParam("电话号") String phones,
|
||||||
|
@ApiParam("模板ID") String templateId) {
|
||||||
|
if (!smsProperties.getEnabled()) {
|
||||||
|
return R.fail("当前系统没有开启短信功能!");
|
||||||
|
}
|
||||||
|
if (!SpringUtils.containsBean("tencentSmsTemplate")) {
|
||||||
|
return R.fail("腾讯云依赖未引入!");
|
||||||
|
}
|
||||||
|
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
||||||
|
Map<String, String> map = new HashMap<>(1);
|
||||||
|
// map.put("2", "测试测试");
|
||||||
|
map.put("1", "1234");
|
||||||
|
Object send = smsTemplate.send(phones, templateId, map);
|
||||||
|
return R.ok(send);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -70,7 +71,7 @@ public class TestDemoController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("导入测试-校验")
|
@ApiOperation("导入测试-校验")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
|
@ApiImplicitParam(name = "file", value = "导入文件", paramType = "query", dataTypeClass = File.class, required = true),
|
||||||
})
|
})
|
||||||
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
|
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
|
||||||
@SaCheckPermission("demo:demo:import")
|
@SaCheckPermission("demo:demo:import")
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试Excel功能
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Api(value = "测试Excel功能", tags = {"测试Excel功能"})
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/demo/excel")
|
||||||
|
public class TestExcelController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单列表多数据
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "单列表多数据")
|
||||||
|
@GetMapping("/exportTemplateOne")
|
||||||
|
public void exportTemplateOne(HttpServletResponse response) {
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("title","单列表多数据");
|
||||||
|
map.put("test1","数据测试1");
|
||||||
|
map.put("test2","数据测试2");
|
||||||
|
map.put("test3","数据测试3");
|
||||||
|
map.put("test4","数据测试4");
|
||||||
|
map.put("testTest","666");
|
||||||
|
List<TestObj> list = new ArrayList<>();
|
||||||
|
list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4"));
|
||||||
|
list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8"));
|
||||||
|
list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12"));
|
||||||
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(map,list),"单列表.xlsx", "excel/单列表.xlsx", response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多列表多数据
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "多列表多数据")
|
||||||
|
@GetMapping("/exportTemplateMuliti")
|
||||||
|
public void exportTemplateMuliti(HttpServletResponse response) {
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("title1","标题1");
|
||||||
|
map.put("title2","标题2");
|
||||||
|
map.put("title3","标题3");
|
||||||
|
map.put("title4","标题4");
|
||||||
|
map.put("author","Lion Li");
|
||||||
|
List<TestObj1> list1 = new ArrayList<>();
|
||||||
|
list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3"));
|
||||||
|
list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6"));
|
||||||
|
list1.add(new TestObj1("list1测试7", "list1测试8", "list1测试9"));
|
||||||
|
List<TestObj1> list2 = new ArrayList<>();
|
||||||
|
list2.add(new TestObj1("list2测试1", "list2测试2", "list2测试3"));
|
||||||
|
list2.add(new TestObj1("list2测试4", "list2测试5", "list2测试6"));
|
||||||
|
List<TestObj1> list3 = new ArrayList<>();
|
||||||
|
list3.add(new TestObj1("list3测试1", "list3测试2", "list3测试3"));
|
||||||
|
List<TestObj1> list4 = new ArrayList<>();
|
||||||
|
list4.add(new TestObj1("list4测试1", "list4测试2", "list4测试3"));
|
||||||
|
list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6"));
|
||||||
|
list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9"));
|
||||||
|
list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12"));
|
||||||
|
Map<String,Object> multiListMap = new HashMap<>();
|
||||||
|
multiListMap.put("map",map);
|
||||||
|
multiListMap.put("data1",list1);
|
||||||
|
multiListMap.put("data2",list2);
|
||||||
|
multiListMap.put("data3",list3);
|
||||||
|
multiListMap.put("data4",list4);
|
||||||
|
ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
static class TestObj1 {
|
||||||
|
private String test1;
|
||||||
|
private String test2;
|
||||||
|
private String test3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
static class TestObj {
|
||||||
|
private String name;
|
||||||
|
private String list1;
|
||||||
|
private String list2;
|
||||||
|
private String list3;
|
||||||
|
private String list4;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -49,7 +49,7 @@ public class TestDemoBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("排序号")
|
@ApiModelProperty("排序号")
|
||||||
@NotNull(message = "排序号不能为空", groups = {AddGroup.class, EditGroup.class})
|
@NotNull(message = "排序号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Long orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key键
|
* key键
|
||||||
|
@ -48,7 +48,7 @@ public class TestDemoVo {
|
|||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "排序号")
|
@ExcelProperty(value = "排序号")
|
||||||
@ApiModelProperty("排序号")
|
@ApiModelProperty("排序号")
|
||||||
private Long orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key键
|
* key键
|
||||||
|
@ -54,5 +54,5 @@ public interface TestDemoMapper extends BaseMapperPlus<TestDemoMapper, TestDemo,
|
|||||||
@DataColumn(key = "deptName", value = "dept_id"),
|
@DataColumn(key = "deptName", value = "dept_id"),
|
||||||
@DataColumn(key = "userName", value = "user_id")
|
@DataColumn(key = "userName", value = "user_id")
|
||||||
})
|
})
|
||||||
int deleteBatchIds(@Param(Constants.COLLECTION) Collection<?> idList);
|
int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList);
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防止重复提交(参考美团GTIS防重系统)
|
* 防止重复提交(参考美团GTIS防重系统)
|
||||||
@ -66,7 +66,7 @@ public class RepeatSubmitAspect {
|
|||||||
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
|
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
|
||||||
String key = RedisUtils.getCacheObject(cacheRepeatKey);
|
String key = RedisUtils.getCacheObject(cacheRepeatKey);
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
RedisUtils.setCacheObject(cacheRepeatKey, "", interval, TimeUnit.MILLISECONDS);
|
RedisUtils.setCacheObject(cacheRepeatKey, "", Duration.ofMillis(interval));
|
||||||
KEY_CACHE.set(cacheRepeatKey);
|
KEY_CACHE.set(cacheRepeatKey);
|
||||||
} else {
|
} else {
|
||||||
String message = repeatSubmit.message();
|
String message = repeatSubmit.message();
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
import com.ruoyi.framework.jackson.BigNumberSerializer;
|
import com.ruoyi.framework.jackson.BigNumberSerializer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -28,23 +25,22 @@ import java.util.TimeZone;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class JacksonConfig {
|
public class JacksonConfig {
|
||||||
|
|
||||||
@Primary
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper getObjectMapper(Jackson2ObjectMapperBuilder builder, JacksonProperties jacksonProperties) {
|
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||||
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
return builder -> {
|
||||||
// 全局配置序列化返回 JSON 处理
|
// 全局配置序列化返回 JSON 处理
|
||||||
SimpleModule simpleModule = new SimpleModule();
|
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||||
simpleModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
|
javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
|
||||||
simpleModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
|
javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
|
||||||
simpleModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
|
javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
|
||||||
simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
|
javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(jacksonProperties.getDateFormat());
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
simpleModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
||||||
simpleModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
||||||
objectMapper.registerModule(simpleModule);
|
builder.modules(javaTimeModule);
|
||||||
objectMapper.setTimeZone(TimeZone.getDefault());
|
builder.timeZone(TimeZone.getDefault());
|
||||||
log.info("初始化 jackson 配置");
|
log.info("初始化 jackson 配置");
|
||||||
return objectMapper;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
|
import cn.hutool.extra.mail.MailAccount;
|
||||||
|
import com.ruoyi.framework.config.properties.MailProperties;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JavaMail 配置
|
||||||
|
*
|
||||||
|
* @author Michelle.Chung
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MailConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(value = "mail.enabled", havingValue = "true")
|
||||||
|
public MailAccount mailAccount(MailProperties mailProperties) {
|
||||||
|
MailAccount account = new MailAccount();
|
||||||
|
account.setHost(mailProperties.getHost());
|
||||||
|
account.setPort(mailProperties.getPort());
|
||||||
|
account.setAuth(mailProperties.getAuth());
|
||||||
|
account.setFrom(mailProperties.getFrom());
|
||||||
|
account.setUser(mailProperties.getUser());
|
||||||
|
account.setPass(mailProperties.getPass());
|
||||||
|
account.setSocketFactoryPort(mailProperties.getPort());
|
||||||
|
account.setStarttlsEnable(mailProperties.getStarttlsEnable());
|
||||||
|
account.setSslEnable(mailProperties.getSslEnable());
|
||||||
|
account.setTimeout(mailProperties.getTimeout());
|
||||||
|
account.setConnectionTimeout(mailProperties.getConnectionTimeout());
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,28 +1,25 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.ruoyi.framework.config.properties.RedissonProperties;
|
import com.ruoyi.framework.config.properties.RedissonProperties;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.redisson.Redisson;
|
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.redisson.codec.JsonJacksonCodec;
|
import org.redisson.codec.JsonJacksonCodec;
|
||||||
import org.redisson.config.Config;
|
|
||||||
import org.redisson.spring.cache.CacheConfig;
|
import org.redisson.spring.cache.CacheConfig;
|
||||||
import org.redisson.spring.cache.RedissonSpringCacheManager;
|
import org.redisson.spring.cache.RedissonSpringCacheManager;
|
||||||
|
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis配置
|
* redis配置
|
||||||
@ -32,72 +29,49 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
|
@EnableConfigurationProperties(RedissonProperties.class)
|
||||||
public class RedisConfig extends CachingConfigurerSupport {
|
public class RedisConfig extends CachingConfigurerSupport {
|
||||||
|
|
||||||
private static final String REDIS_PROTOCOL_PREFIX = "redis://";
|
|
||||||
private static final String REDISS_PROTOCOL_PREFIX = "rediss://";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisProperties redisProperties;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedissonProperties redissonProperties;
|
private RedissonProperties redissonProperties;
|
||||||
|
|
||||||
@Primary
|
@Autowired
|
||||||
@Bean(destroyMethod = "shutdown")
|
private ObjectMapper objectMapper;
|
||||||
public RedissonClient redisson() {
|
|
||||||
String prefix = REDIS_PROTOCOL_PREFIX;
|
|
||||||
if (redisProperties.isSsl()) {
|
|
||||||
prefix = REDISS_PROTOCOL_PREFIX;
|
|
||||||
}
|
|
||||||
Config config = new Config();
|
|
||||||
config.setThreads(redissonProperties.getThreads())
|
|
||||||
.setNettyThreads(redissonProperties.getNettyThreads())
|
|
||||||
.setCodec(JsonJacksonCodec.INSTANCE);
|
|
||||||
|
|
||||||
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
|
@Bean
|
||||||
if (ObjectUtil.isNotNull(singleServerConfig)) {
|
public RedissonAutoConfigurationCustomizer redissonCustomizer() {
|
||||||
// 使用单机模式
|
return config -> {
|
||||||
config.useSingleServer()
|
config.setThreads(redissonProperties.getThreads())
|
||||||
.setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort())
|
.setNettyThreads(redissonProperties.getNettyThreads())
|
||||||
.setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue())
|
.setCodec(new JsonJacksonCodec(objectMapper));
|
||||||
.setDatabase(redisProperties.getDatabase())
|
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
|
||||||
.setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null)
|
if (ObjectUtil.isNotNull(singleServerConfig)) {
|
||||||
.setTimeout(singleServerConfig.getTimeout())
|
// 使用单机模式
|
||||||
.setClientName(singleServerConfig.getClientName())
|
config.useSingleServer()
|
||||||
.setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout())
|
.setTimeout(singleServerConfig.getTimeout())
|
||||||
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
|
.setClientName(singleServerConfig.getClientName())
|
||||||
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
|
.setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout())
|
||||||
.setConnectionPoolSize(singleServerConfig.getConnectionPoolSize());
|
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
|
||||||
}
|
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
|
||||||
// 集群配置方式 参考下方注释
|
.setConnectionPoolSize(singleServerConfig.getConnectionPoolSize());
|
||||||
RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig();
|
}
|
||||||
if (ObjectUtil.isNotNull(clusterServersConfig)) {
|
// 集群配置方式 参考下方注释
|
||||||
// 使用集群模式
|
RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig();
|
||||||
String finalPrefix = prefix;
|
if (ObjectUtil.isNotNull(clusterServersConfig)) {
|
||||||
List<String> nodes = redisProperties.getCluster().getNodes()
|
config.useClusterServers()
|
||||||
.stream()
|
.setTimeout(clusterServersConfig.getTimeout())
|
||||||
.map(node -> finalPrefix + node)
|
.setClientName(clusterServersConfig.getClientName())
|
||||||
.collect(Collectors.toList());
|
.setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout())
|
||||||
|
.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize())
|
||||||
config.useClusterServers()
|
.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize())
|
||||||
.setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue())
|
.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize())
|
||||||
.setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null)
|
.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize())
|
||||||
.setTimeout(clusterServersConfig.getTimeout())
|
.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize())
|
||||||
.setClientName(clusterServersConfig.getClientName())
|
.setReadMode(clusterServersConfig.getReadMode())
|
||||||
.setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout())
|
.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
||||||
.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize())
|
}
|
||||||
.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize())
|
log.info("初始化 redis 配置");
|
||||||
.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize())
|
};
|
||||||
.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize())
|
|
||||||
.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize())
|
|
||||||
.setReadMode(clusterServersConfig.getReadMode())
|
|
||||||
.setSubscriptionMode(clusterServersConfig.getSubscriptionMode())
|
|
||||||
.setNodeAddresses(nodes);
|
|
||||||
}
|
|
||||||
RedissonClient redissonClient = Redisson.create(config);
|
|
||||||
log.info("初始化 redis 配置");
|
|
||||||
return redissonClient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +86,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||||||
cacheConfig.setMaxSize(group.getMaxSize());
|
cacheConfig.setMaxSize(group.getMaxSize());
|
||||||
config.put(group.getGroupId(), cacheConfig);
|
config.put(group.getGroupId(), cacheConfig);
|
||||||
}
|
}
|
||||||
return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE);
|
return new RedissonSpringCacheManager(redissonClient, config, new JsonJacksonCodec(objectMapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,11 +2,12 @@ package com.ruoyi.framework.config;
|
|||||||
|
|
||||||
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
|
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
|
||||||
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
|
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
|
||||||
import cn.dev33.satoken.jwt.StpLogicJwtForStyle;
|
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||||
import cn.dev33.satoken.router.SaRouter;
|
import cn.dev33.satoken.router.SaRouter;
|
||||||
import cn.dev33.satoken.stp.StpLogic;
|
import cn.dev33.satoken.stp.StpLogic;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.ruoyi.common.helper.LoginHelper;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import com.ruoyi.framework.config.properties.ExcludeUrlProperties;
|
||||||
import com.ruoyi.framework.config.properties.SecurityProperties;
|
import com.ruoyi.framework.config.properties.SecurityProperties;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -15,9 +16,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sa-token 配置
|
* sa-token 配置
|
||||||
*
|
*
|
||||||
@ -37,12 +35,14 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 注册路由拦截器,自定义验证规则
|
// 注册路由拦截器,自定义验证规则
|
||||||
registry.addInterceptor(new SaRouteInterceptor((request, response, handler) -> {
|
registry.addInterceptor(new SaRouteInterceptor((request, response, handler) -> {
|
||||||
|
ExcludeUrlProperties excludeUrlProperties = SpringUtils.getBean(ExcludeUrlProperties.class);
|
||||||
// 登录验证 -- 排除多个路径
|
// 登录验证 -- 排除多个路径
|
||||||
SaRouter
|
SaRouter
|
||||||
// 获取所有的
|
// 获取所有的
|
||||||
.match("/**")
|
.match("/**")
|
||||||
// 排除下不需要拦截的
|
// 排除下不需要拦截的
|
||||||
.notMatch(securityProperties.getExcludes())
|
.notMatch(securityProperties.getExcludes())
|
||||||
|
.notMatch(excludeUrlProperties.getExcludes())
|
||||||
// 对未排除的路径进行检查
|
// 对未排除的路径进行检查
|
||||||
.check(() -> {
|
.check(() -> {
|
||||||
// 检查是否登录 是否有token
|
// 检查是否登录 是否有token
|
||||||
@ -55,20 +55,14 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
});
|
});
|
||||||
}) {
|
})).addPathPatterns("/**");
|
||||||
@SuppressWarnings("all")
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
|
||||||
LoginHelper.clearCache();
|
|
||||||
}
|
|
||||||
}).addPathPatterns("/**");
|
|
||||||
registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
|
registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public StpLogic getStpLogicJwt() {
|
public StpLogic getStpLogicJwt() {
|
||||||
// Sa-Token 整合 jwt (Style模式)
|
// Sa-Token 整合 jwt (简单模式)
|
||||||
return new StpLogicJwtForStyle();
|
return new StpLogicJwtForSimple();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class SwaggerConfig {
|
|||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
*/
|
*/
|
||||||
private List<SecurityScheme> securitySchemes() {
|
private List<SecurityScheme> securitySchemes() {
|
||||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
List<SecurityScheme> apiKeyList = new ArrayList<>();
|
||||||
String header = saTokenConfig.getTokenName();
|
String header = saTokenConfig.getTokenName();
|
||||||
apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue()));
|
apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue()));
|
||||||
return apiKeyList;
|
return apiKeyList;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user