Commit 49963cde by wuwenlong

定时任务服务

parent df928bdb
......@@ -23,13 +23,17 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.2.13.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
......@@ -49,11 +53,11 @@
<artifactId>share-framework</artifactId>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>share</groupId>
<artifactId>share-quartz</artifactId>
</dependency>
<!-- &lt;!&ndash; 定时任务&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>share</groupId>-->
<!-- <artifactId>share-quartz</artifactId>-->
<!-- </dependency>-->
<!-- 代码生成-->
<dependency>
......@@ -72,6 +76,10 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -229,5 +229,7 @@ order:
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
bean:
consumer: true
api:
domain: https://www.coujio.com
\ No newline at end of file
domain: https://www.coujio.com
......@@ -27,7 +27,7 @@
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>DEBUG</level>
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
......
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import share.system.domain.SOrder;
import share.system.service.ISOrderService;
/**
* @Author wwl
* @Date 2024/7/17 20:45
*/
//@RunWith(SpringRunner.class)
//@SpringBootTest
public class SOrderTest {
@Autowired
private ISOrderService sOrderService;
// @Test
public void testMyService() {
// sOrderService.pageList(new SOrder());
// 添加断言来验证结果
}
}
......@@ -8,37 +8,91 @@
<version>3.8.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>share-quartz</artifactId>
<packaging>jar</packaging>
<artifactId>share-task</artifactId>
<description>
quartz定时任务
</description>
<dependencies>
<!-- 定时任务 -->
<!-- 核心模块-->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<exclusions>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
<groupId>share</groupId>
<artifactId>share-framework</artifactId>
</dependency>
<!-- 通用工具-->
<dependency>
<groupId>share</groupId>
<artifactId>share-common</artifactId>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>share</groupId>
<artifactId>share-system</artifactId>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 定时任务 -->
<!-- <dependency>-->
<!-- <groupId>org.quartz-scheduler</groupId>-->
<!-- <artifactId>quartz</artifactId>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>com.mchange</groupId>-->
<!-- <artifactId>c3p0</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.15</version>
<configuration>
<includeSystemScope>true</includeSystemScope>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
</project>
\ No newline at end of file
package share;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 启动程序
*
* @author ruoyi
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class ShareApplication
{
public static void main(String[] args)
{
SpringApplication.run(ShareApplication.class, args);
System.out.println("启动成功");
}
}
package share;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* web容器中进行部署
*
* @author ruoyi
*/
public class ShareServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(ShareApplication.class);
}
}
package share.quartz.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author wwl
* @Date 2024/7/25 17:00
*/
@Configuration
public class XxlJobConfig {
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.appname}")
private String appname;
@Value("${xxl.job.executor.address}")
private String address;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logRetentionDays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appname);
xxlJobSpringExecutor.setAddress(address);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}
package share.quartz.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.quartz.domain.SysJobLog;
import share.quartz.service.ISysJobLogService;
/**
* 调度日志操作处理
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/jobLog")
public class SysJobLogController extends BaseController
{
@Autowired
private ISysJobLogService jobLogService;
/**
* 查询定时任务调度日志列表
*/
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list")
public TableDataInfo list(SysJobLog sysJobLog)
{
startPage();
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
return getDataTable(list);
}
/**
* 导出定时任务调度日志列表
*/
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysJobLog sysJobLog)
{
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
util.exportExcel(response, list, "调度日志");
}
/**
* 根据调度编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
@GetMapping(value = "/{jobLogId}")
public AjaxResult getInfo(@PathVariable Long jobLogId)
{
return success(jobLogService.selectJobLogById(jobLogId));
}
/**
* 删除定时任务调度日志
*/
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
@Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobLogIds}")
public AjaxResult remove(@PathVariable Long[] jobLogIds)
{
return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
}
/**
* 清空定时任务调度日志
*/
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{
jobLogService.cleanJobLog();
return success();
}
}
//
//import java.util.List;
//import javax.servlet.http.HttpServletResponse;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import share.common.annotation.Log;
//import share.common.core.controller.BaseController;
//import share.common.core.domain.AjaxResult;
//import share.common.core.page.TableDataInfo;
//import share.common.enums.BusinessType;
//import share.common.utils.poi.ExcelUtil;
//import share.quartz.domain.SysJobLog;
//import share.quartz.service.ISysJobLogService;
//
///**
// * 调度日志操作处理
// *
// * @author ruoyi
// */
////@RestController
////@RequestMapping("/monitor/jobLog")
//public class SysJobLogController extends BaseController
//{
//// @Autowired
//// private ISysJobLogService jobLogService;
////
//// /**
//// * 查询定时任务调度日志列表
//// */
//// @PreAuthorize("@ss.hasPermi('monitor:job:list')")
//// @GetMapping("/list")
//// public TableDataInfo list(SysJobLog sysJobLog)
//// {
//// startPage();
//// List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
//// return getDataTable(list);
//// }
////
//// /**
//// * 导出定时任务调度日志列表
//// */
//// @PreAuthorize("@ss.hasPermi('monitor:job:export')")
//// @Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
//// @PostMapping("/export")
//// public void export(HttpServletResponse response, SysJobLog sysJobLog)
//// {
//// List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
//// ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
//// util.exportExcel(response, list, "调度日志");
//// }
////
//// /**
//// * 根据调度编号获取详细信息
//// */
//// @PreAuthorize("@ss.hasPermi('monitor:job:query')")
//// @GetMapping(value = "/{jobLogId}")
//// public AjaxResult getInfo(@PathVariable Long jobLogId)
//// {
//// return success(jobLogService.selectJobLogById(jobLogId));
//// }
////
////
//// /**
//// * 删除定时任务调度日志
//// */
//// @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
//// @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
//// @DeleteMapping("/{jobLogIds}")
//// public AjaxResult remove(@PathVariable Long[] jobLogIds)
//// {
//// return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
//// }
////
//// /**
//// * 清空定时任务调度日志
//// */
//// @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
//// @Log(title = "调度日志", businessType = BusinessType.CLEAN)
//// @DeleteMapping("/clean")
//// public AjaxResult clean()
//// {
//// jobLogService.cleanJobLog();
//// return success();
//// }
//}
package share.quartz.domain;
import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonFormat;
import share.common.annotation.Excel;
import share.common.annotation.Excel.ColumnType;
import share.common.constant.ScheduleConstants;
import share.common.core.domain.BaseEntity;
import share.common.utils.StringUtils;
import share.quartz.util.CronUtils;
/**
* 定时任务调度表 sys_job
*
* @author ruoyi
*/
public class SysJob extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 任务ID */
@Excel(name = "任务序号", cellType = ColumnType.NUMERIC)
private Long jobId;
/** 任务名称 */
@Excel(name = "任务名称")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
private String jobGroup;
/** 调用目标字符串 */
@Excel(name = "调用目标字符串")
private String invokeTarget;
/** cron执行表达式 */
@Excel(name = "执行表达式 ")
private String cronExpression;
/** cron计划策略 */
@Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行")
private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
/** 是否并发执行(0允许 1禁止) */
@Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止")
private String concurrent;
/** 任务状态(0正常 1暂停) */
@Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停")
private String status;
public Long getJobId()
{
return jobId;
}
public void setJobId(Long jobId)
{
this.jobId = jobId;
}
@NotBlank(message = "任务名称不能为空")
@Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
public String getJobName()
{
return jobName;
}
public void setJobName(String jobName)
{
this.jobName = jobName;
}
public String getJobGroup()
{
return jobGroup;
}
public void setJobGroup(String jobGroup)
{
this.jobGroup = jobGroup;
}
@NotBlank(message = "调用目标字符串不能为空")
@Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符")
public String getInvokeTarget()
{
return invokeTarget;
}
public void setInvokeTarget(String invokeTarget)
{
this.invokeTarget = invokeTarget;
}
@NotBlank(message = "Cron执行表达式不能为空")
@Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
public String getCronExpression()
{
return cronExpression;
}
public void setCronExpression(String cronExpression)
{
this.cronExpression = cronExpression;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getNextValidTime()
{
if (StringUtils.isNotEmpty(cronExpression))
{
return CronUtils.getNextExecution(cronExpression);
}
return null;
}
public String getMisfirePolicy()
{
return misfirePolicy;
}
public void setMisfirePolicy(String misfirePolicy)
{
this.misfirePolicy = misfirePolicy;
}
public String getConcurrent()
{
return concurrent;
}
public void setConcurrent(String concurrent)
{
this.concurrent = concurrent;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("jobId", getJobId())
.append("jobName", getJobName())
.append("jobGroup", getJobGroup())
.append("cronExpression", getCronExpression())
.append("nextValidTime", getNextValidTime())
.append("misfirePolicy", getMisfirePolicy())
.append("concurrent", getConcurrent())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
//
//import java.util.Date;
//import javax.validation.constraints.NotBlank;
//import javax.validation.constraints.Size;
//import org.apache.commons.lang3.builder.ToStringBuilder;
//import org.apache.commons.lang3.builder.ToStringStyle;
//import com.fasterxml.jackson.annotation.JsonFormat;
//import share.common.annotation.Excel;
//import share.common.annotation.Excel.ColumnType;
//import share.common.constant.ScheduleConstants;
//import share.common.core.domain.BaseEntity;
//import share.common.utils.StringUtils;
//import share.quartz.util.CronUtils;
//
///**
// * 定时任务调度表 sys_job
// *
// * @author ruoyi
// */
//public class SysJob extends BaseEntity
//{
// private static final long serialVersionUID = 1L;
//
// /** 任务ID */
// @Excel(name = "任务序号", cellType = ColumnType.NUMERIC)
// private Long jobId;
//
// /** 任务名称 */
// @Excel(name = "任务名称")
// private String jobName;
//
// /** 任务组名 */
// @Excel(name = "任务组名")
// private String jobGroup;
//
// /** 调用目标字符串 */
// @Excel(name = "调用目标字符串")
// private String invokeTarget;
//
// /** cron执行表达式 */
// @Excel(name = "执行表达式 ")
// private String cronExpression;
//
// /** cron计划策略 */
// @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行")
// private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
//
// /** 是否并发执行(0允许 1禁止) */
// @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止")
// private String concurrent;
//
// /** 任务状态(0正常 1暂停) */
// @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停")
// private String status;
//
// public Long getJobId()
// {
// return jobId;
// }
//
// public void setJobId(Long jobId)
// {
// this.jobId = jobId;
// }
//
// @NotBlank(message = "任务名称不能为空")
// @Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
// public String getJobName()
// {
// return jobName;
// }
//
// public void setJobName(String jobName)
// {
// this.jobName = jobName;
// }
//
// public String getJobGroup()
// {
// return jobGroup;
// }
//
// public void setJobGroup(String jobGroup)
// {
// this.jobGroup = jobGroup;
// }
//
// @NotBlank(message = "调用目标字符串不能为空")
// @Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符")
// public String getInvokeTarget()
// {
// return invokeTarget;
// }
//
// public void setInvokeTarget(String invokeTarget)
// {
// this.invokeTarget = invokeTarget;
// }
//
// @NotBlank(message = "Cron执行表达式不能为空")
// @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
// public String getCronExpression()
// {
// return cronExpression;
// }
//
// public void setCronExpression(String cronExpression)
// {
// this.cronExpression = cronExpression;
// }
//
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// public Date getNextValidTime()
// {
// if (StringUtils.isNotEmpty(cronExpression))
// {
// return CronUtils.getNextExecution(cronExpression);
// }
// return null;
// }
//
// public String getMisfirePolicy()
// {
// return misfirePolicy;
// }
//
// public void setMisfirePolicy(String misfirePolicy)
// {
// this.misfirePolicy = misfirePolicy;
// }
//
// public String getConcurrent()
// {
// return concurrent;
// }
//
// public void setConcurrent(String concurrent)
// {
// this.concurrent = concurrent;
// }
//
// public String getStatus()
// {
// return status;
// }
//
// public void setStatus(String status)
// {
// this.status = status;
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
// .append("jobId", getJobId())
// .append("jobName", getJobName())
// .append("jobGroup", getJobGroup())
// .append("cronExpression", getCronExpression())
// .append("nextValidTime", getNextValidTime())
// .append("misfirePolicy", getMisfirePolicy())
// .append("concurrent", getConcurrent())
// .append("status", getStatus())
// .append("createBy", getCreateBy())
// .append("createTime", getCreateTime())
// .append("updateBy", getUpdateBy())
// .append("updateTime", getUpdateTime())
// .append("remark", getRemark())
// .toString();
// }
//}
package share.quartz.domain;
import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
/**
* 定时任务调度日志表 sys_job_log
*
* @author ruoyi
*/
public class SysJobLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
@Excel(name = "日志序号")
private Long jobLogId;
/** 任务名称 */
@Excel(name = "任务名称")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
private String jobGroup;
/** 调用目标字符串 */
@Excel(name = "调用目标字符串")
private String invokeTarget;
/** 日志信息 */
@Excel(name = "日志信息")
private String jobMessage;
/** 执行状态(0正常 1失败) */
@Excel(name = "执行状态", readConverterExp = "0=正常,1=失败")
private String status;
/** 异常信息 */
@Excel(name = "异常信息")
private String exceptionInfo;
/** 开始时间 */
private Date startTime;
/** 停止时间 */
private Date stopTime;
public Long getJobLogId()
{
return jobLogId;
}
public void setJobLogId(Long jobLogId)
{
this.jobLogId = jobLogId;
}
public String getJobName()
{
return jobName;
}
public void setJobName(String jobName)
{
this.jobName = jobName;
}
public String getJobGroup()
{
return jobGroup;
}
public void setJobGroup(String jobGroup)
{
this.jobGroup = jobGroup;
}
public String getInvokeTarget()
{
return invokeTarget;
}
public void setInvokeTarget(String invokeTarget)
{
this.invokeTarget = invokeTarget;
}
public String getJobMessage()
{
return jobMessage;
}
public void setJobMessage(String jobMessage)
{
this.jobMessage = jobMessage;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getExceptionInfo()
{
return exceptionInfo;
}
public void setExceptionInfo(String exceptionInfo)
{
this.exceptionInfo = exceptionInfo;
}
public Date getStartTime()
{
return startTime;
}
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
public Date getStopTime()
{
return stopTime;
}
public void setStopTime(Date stopTime)
{
this.stopTime = stopTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("jobLogId", getJobLogId())
.append("jobName", getJobName())
.append("jobGroup", getJobGroup())
.append("jobMessage", getJobMessage())
.append("status", getStatus())
.append("exceptionInfo", getExceptionInfo())
.append("startTime", getStartTime())
.append("stopTime", getStopTime())
.toString();
}
}
//
//import java.util.Date;
//import org.apache.commons.lang3.builder.ToStringBuilder;
//import org.apache.commons.lang3.builder.ToStringStyle;
//import share.common.annotation.Excel;
//import share.common.core.domain.BaseEntity;
//
///**
// * 定时任务调度日志表 sys_job_log
// *
// * @author ruoyi
// */
//public class SysJobLog extends BaseEntity
//{
// private static final long serialVersionUID = 1L;
//
// /** ID */
// @Excel(name = "日志序号")
// private Long jobLogId;
//
// /** 任务名称 */
// @Excel(name = "任务名称")
// private String jobName;
//
// /** 任务组名 */
// @Excel(name = "任务组名")
// private String jobGroup;
//
// /** 调用目标字符串 */
// @Excel(name = "调用目标字符串")
// private String invokeTarget;
//
// /** 日志信息 */
// @Excel(name = "日志信息")
// private String jobMessage;
//
// /** 执行状态(0正常 1失败) */
// @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败")
// private String status;
//
// /** 异常信息 */
// @Excel(name = "异常信息")
// private String exceptionInfo;
//
// /** 开始时间 */
// private Date startTime;
//
// /** 停止时间 */
// private Date stopTime;
//
// public Long getJobLogId()
// {
// return jobLogId;
// }
//
// public void setJobLogId(Long jobLogId)
// {
// this.jobLogId = jobLogId;
// }
//
// public String getJobName()
// {
// return jobName;
// }
//
// public void setJobName(String jobName)
// {
// this.jobName = jobName;
// }
//
// public String getJobGroup()
// {
// return jobGroup;
// }
//
// public void setJobGroup(String jobGroup)
// {
// this.jobGroup = jobGroup;
// }
//
// public String getInvokeTarget()
// {
// return invokeTarget;
// }
//
// public void setInvokeTarget(String invokeTarget)
// {
// this.invokeTarget = invokeTarget;
// }
//
// public String getJobMessage()
// {
// return jobMessage;
// }
//
// public void setJobMessage(String jobMessage)
// {
// this.jobMessage = jobMessage;
// }
//
// public String getStatus()
// {
// return status;
// }
//
// public void setStatus(String status)
// {
// this.status = status;
// }
//
// public String getExceptionInfo()
// {
// return exceptionInfo;
// }
//
// public void setExceptionInfo(String exceptionInfo)
// {
// this.exceptionInfo = exceptionInfo;
// }
//
// public Date getStartTime()
// {
// return startTime;
// }
//
// public void setStartTime(Date startTime)
// {
// this.startTime = startTime;
// }
//
// public Date getStopTime()
// {
// return stopTime;
// }
//
// public void setStopTime(Date stopTime)
// {
// this.stopTime = stopTime;
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
// .append("jobLogId", getJobLogId())
// .append("jobName", getJobName())
// .append("jobGroup", getJobGroup())
// .append("jobMessage", getJobMessage())
// .append("status", getStatus())
// .append("exceptionInfo", getExceptionInfo())
// .append("startTime", getStartTime())
// .append("stopTime", getStopTime())
// .toString();
// }
//}
package share.quartz.mapper;
import java.util.List;
import share.quartz.domain.SysJobLog;
/**
* 调度任务日志信息 数据层
*
* @author ruoyi
*/
public interface SysJobLogMapper
{
/**
* 获取quartz调度器日志的计划任务
*
* @param jobLog 调度日志信息
* @return 调度任务日志集合
*/
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
/**
* 查询所有调度任务日志
*
* @return 调度任务日志列表
*/
public List<SysJobLog> selectJobLogAll();
/**
* 通过调度任务日志ID查询调度信息
*
* @param jobLogId 调度任务日志ID
* @return 调度任务日志对象信息
*/
public SysJobLog selectJobLogById(Long jobLogId);
/**
* 新增任务日志
*
* @param jobLog 调度日志信息
* @return 结果
*/
public int insertJobLog(SysJobLog jobLog);
/**
* 批量删除调度日志信息
*
* @param logIds 需要删除的数据ID
* @return 结果
*/
public int deleteJobLogByIds(Long[] logIds);
/**
* 删除任务日志
*
* @param jobId 调度日志ID
* @return 结果
*/
public int deleteJobLogById(Long jobId);
/**
* 清空任务日志
*/
public void cleanJobLog();
}
//
//import java.util.List;
//import share.quartz.domain.SysJobLog;
//
///**
// * 调度任务日志信息 数据层
// *
// * @author ruoyi
// */
//public interface SysJobLogMapper
//{
// /**
// * 获取quartz调度器日志的计划任务
// *
// * @param jobLog 调度日志信息
// * @return 调度任务日志集合
// */
// public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
//
// /**
// * 查询所有调度任务日志
// *
// * @return 调度任务日志列表
// */
// public List<SysJobLog> selectJobLogAll();
//
// /**
// * 通过调度任务日志ID查询调度信息
// *
// * @param jobLogId 调度任务日志ID
// * @return 调度任务日志对象信息
// */
// public SysJobLog selectJobLogById(Long jobLogId);
//
// /**
// * 新增任务日志
// *
// * @param jobLog 调度日志信息
// * @return 结果
// */
// public int insertJobLog(SysJobLog jobLog);
//
// /**
// * 批量删除调度日志信息
// *
// * @param logIds 需要删除的数据ID
// * @return 结果
// */
// public int deleteJobLogByIds(Long[] logIds);
//
// /**
// * 删除任务日志
// *
// * @param jobId 调度日志ID
// * @return 结果
// */
// public int deleteJobLogById(Long jobId);
//
// /**
// * 清空任务日志
// */
// public void cleanJobLog();
//}
package share.quartz.mapper;
import java.util.List;
import share.quartz.domain.SysJob;
/**
* 调度任务信息 数据层
*
* @author ruoyi
*/
public interface SysJobMapper
{
/**
* 查询调度任务日志集合
*
* @param job 调度信息
* @return 操作日志集合
*/
public List<SysJob> selectJobList(SysJob job);
/**
* 查询所有调度任务
*
* @return 调度任务列表
*/
public List<SysJob> selectJobAll();
/**
* 通过调度ID查询调度任务信息
*
* @param jobId 调度ID
* @return 角色对象信息
*/
public SysJob selectJobById(Long jobId);
/**
* 通过调度ID删除调度任务信息
*
* @param jobId 调度ID
* @return 结果
*/
public int deleteJobById(Long jobId);
/**
* 批量删除调度任务信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteJobByIds(Long[] ids);
/**
* 修改调度任务信息
*
* @param job 调度任务信息
* @return 结果
*/
public int updateJob(SysJob job);
/**
* 新增调度任务信息
*
* @param job 调度任务信息
* @return 结果
*/
public int insertJob(SysJob job);
}
//
//import java.util.List;
//import share.quartz.domain.SysJob;
//
///**
// * 调度任务信息 数据层
// *
// * @author ruoyi
// */
//public interface SysJobMapper
//{
// /**
// * 查询调度任务日志集合
// *
// * @param job 调度信息
// * @return 操作日志集合
// */
// public List<SysJob> selectJobList(SysJob job);
//
// /**
// * 查询所有调度任务
// *
// * @return 调度任务列表
// */
// public List<SysJob> selectJobAll();
//
// /**
// * 通过调度ID查询调度任务信息
// *
// * @param jobId 调度ID
// * @return 角色对象信息
// */
// public SysJob selectJobById(Long jobId);
//
// /**
// * 通过调度ID删除调度任务信息
// *
// * @param jobId 调度ID
// * @return 结果
// */
// public int deleteJobById(Long jobId);
//
// /**
// * 批量删除调度任务信息
// *
// * @param ids 需要删除的数据ID
// * @return 结果
// */
// public int deleteJobByIds(Long[] ids);
//
// /**
// * 修改调度任务信息
// *
// * @param job 调度任务信息
// * @return 结果
// */
// public int updateJob(SysJob job);
//
// /**
// * 新增调度任务信息
// *
// * @param job 调度任务信息
// * @return 结果
// */
// public int insertJob(SysJob job);
//}
package share.quartz.service;
import java.util.List;
import share.quartz.domain.SysJobLog;
//import share.quartz.domain.SysJobLog;
/**
* 定时任务调度日志信息信息 服务层
......@@ -10,47 +10,47 @@ import share.quartz.domain.SysJobLog;
*/
public interface ISysJobLogService
{
/**
* 获取quartz调度器日志的计划任务
*
* @param jobLog 调度日志信息
* @return 调度任务日志集合
*/
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
/**
* 通过调度任务日志ID查询调度信息
*
* @param jobLogId 调度任务日志ID
* @return 调度任务日志对象信息
*/
public SysJobLog selectJobLogById(Long jobLogId);
/**
* 新增任务日志
*
* @param jobLog 调度日志信息
*/
public void addJobLog(SysJobLog jobLog);
/**
* 批量删除调度日志信息
*
* @param logIds 需要删除的日志ID
* @return 结果
*/
public int deleteJobLogByIds(Long[] logIds);
/**
* 删除任务日志
*
* @param jobId 调度日志ID
* @return 结果
*/
public int deleteJobLogById(Long jobId);
/**
* 清空任务日志
*/
public void cleanJobLog();
// /**
// * 获取quartz调度器日志的计划任务
// *
// * @param jobLog 调度日志信息
// * @return 调度任务日志集合
// */
// public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
//
// /**
// * 通过调度任务日志ID查询调度信息
// *
// * @param jobLogId 调度任务日志ID
// * @return 调度任务日志对象信息
// */
// public SysJobLog selectJobLogById(Long jobLogId);
//
// /**
// * 新增任务日志
// *
// * @param jobLog 调度日志信息
// */
// public void addJobLog(SysJobLog jobLog);
//
// /**
// * 批量删除调度日志信息
// *
// * @param logIds 需要删除的日志ID
// * @return 结果
// */
// public int deleteJobLogByIds(Long[] logIds);
//
// /**
// * 删除任务日志
// *
// * @param jobId 调度日志ID
// * @return 结果
// */
// public int deleteJobLogById(Long jobId);
//
// /**
// * 清空任务日志
// */
// public void cleanJobLog();
}
package share.quartz.service;
import java.util.List;
import org.quartz.SchedulerException;
import share.common.exception.job.TaskException;
import share.quartz.domain.SysJob;
/**
* 定时任务调度信息信息 服务层
*
* @author ruoyi
*/
public interface ISysJobService
{
/**
* 获取quartz调度器的计划任务
*
* @param job 调度信息
* @return 调度任务集合
*/
public List<SysJob> selectJobList(SysJob job);
/**
* 通过调度任务ID查询调度信息
*
* @param jobId 调度任务ID
* @return 调度任务对象信息
*/
public SysJob selectJobById(Long jobId);
/**
* 暂停任务
*
* @param job 调度信息
* @return 结果
*/
public int pauseJob(SysJob job) throws SchedulerException;
/**
* 恢复任务
*
* @param job 调度信息
* @return 结果
*/
public int resumeJob(SysJob job) throws SchedulerException;
/**
* 删除任务后,所对应的trigger也将被删除
*
* @param job 调度信息
* @return 结果
*/
public int deleteJob(SysJob job) throws SchedulerException;
/**
* 批量删除调度信息
*
* @param jobIds 需要删除的任务ID
* @return 结果
*/
public void deleteJobByIds(Long[] jobIds) throws SchedulerException;
/**
* 任务调度状态修改
*
* @param job 调度信息
* @return 结果
*/
public int changeStatus(SysJob job) throws SchedulerException;
/**
* 立即运行任务
*
* @param job 调度信息
* @return 结果
*/
public boolean run(SysJob job) throws SchedulerException;
/**
* 新增任务
*
* @param job 调度信息
* @return 结果
*/
public int insertJob(SysJob job) throws SchedulerException, TaskException;
/**
* 更新任务
*
* @param job 调度信息
* @return 结果
*/
public int updateJob(SysJob job) throws SchedulerException, TaskException;
/**
* 校验cron表达式是否有效
*
* @param cronExpression 表达式
* @return 结果
*/
public boolean checkCronExpressionIsValid(String cronExpression);
}
//
//import java.util.List;
//import org.quartz.SchedulerException;
//import share.common.exception.job.TaskException;
//import share.quartz.domain.SysJob;
//
///**
// * 定时任务调度信息信息 服务层
// *
// * @author ruoyi
// */
//public interface ISysJobService
//{
//// /**
//// * 获取quartz调度器的计划任务
//// *
//// * @param job 调度信息
//// * @return 调度任务集合
//// */
//// public List<SysJob> selectJobList(SysJob job);
////
//// /**
//// * 通过调度任务ID查询调度信息
//// *
//// * @param jobId 调度任务ID
//// * @return 调度任务对象信息
//// */
//// public SysJob selectJobById(Long jobId);
////
//// /**
//// * 暂停任务
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int pauseJob(SysJob job) throws SchedulerException;
////
//// /**
//// * 恢复任务
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int resumeJob(SysJob job) throws SchedulerException;
////
//// /**
//// * 删除任务后,所对应的trigger也将被删除
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int deleteJob(SysJob job) throws SchedulerException;
////
//// /**
//// * 批量删除调度信息
//// *
//// * @param jobIds 需要删除的任务ID
//// * @return 结果
//// */
//// public void deleteJobByIds(Long[] jobIds) throws SchedulerException;
////
//// /**
//// * 任务调度状态修改
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int changeStatus(SysJob job) throws SchedulerException;
////
//// /**
//// * 立即运行任务
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public boolean run(SysJob job) throws SchedulerException;
////
//// /**
//// * 新增任务
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int insertJob(SysJob job) throws SchedulerException, TaskException;
////
//// /**
//// * 更新任务
//// *
//// * @param job 调度信息
//// * @return 结果
//// */
//// public int updateJob(SysJob job) throws SchedulerException, TaskException;
////
//// /**
//// * 校验cron表达式是否有效
//// *
//// * @param cronExpression 表达式
//// * @return 结果
//// */
//// public boolean checkCronExpressionIsValid(String cronExpression);
//}
......@@ -3,8 +3,8 @@ package share.quartz.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.quartz.domain.SysJobLog;
import share.quartz.mapper.SysJobLogMapper;
//import share.quartz.domain.SysJobLog;
//import share.quartz.mapper.SysJobLogMapper;
import share.quartz.service.ISysJobLogService;
/**
......@@ -15,73 +15,73 @@ import share.quartz.service.ISysJobLogService;
@Service
public class SysJobLogServiceImpl implements ISysJobLogService
{
@Autowired
private SysJobLogMapper jobLogMapper;
/**
* 获取quartz调度器日志的计划任务
*
* @param jobLog 调度日志信息
* @return 调度任务日志集合
*/
@Override
public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
{
return jobLogMapper.selectJobLogList(jobLog);
}
/**
* 通过调度任务日志ID查询调度信息
*
* @param jobLogId 调度任务日志ID
* @return 调度任务日志对象信息
*/
@Override
public SysJobLog selectJobLogById(Long jobLogId)
{
return jobLogMapper.selectJobLogById(jobLogId);
}
/**
* 新增任务日志
*
* @param jobLog 调度日志信息
*/
@Override
public void addJobLog(SysJobLog jobLog)
{
jobLogMapper.insertJobLog(jobLog);
}
/**
* 批量删除调度日志信息
*
* @param logIds 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteJobLogByIds(Long[] logIds)
{
return jobLogMapper.deleteJobLogByIds(logIds);
}
/**
* 删除任务日志
*
* @param jobId 调度日志ID
*/
@Override
public int deleteJobLogById(Long jobId)
{
return jobLogMapper.deleteJobLogById(jobId);
}
/**
* 清空任务日志
*/
@Override
public void cleanJobLog()
{
jobLogMapper.cleanJobLog();
}
// @Autowired
// private SysJobLogMapper jobLogMapper;
//
// /**
// * 获取quartz调度器日志的计划任务
// *
// * @param jobLog 调度日志信息
// * @return 调度任务日志集合
// */
// @Override
// public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
// {
// return jobLogMapper.selectJobLogList(jobLog);
// }
//
// /**
// * 通过调度任务日志ID查询调度信息
// *
// * @param jobLogId 调度任务日志ID
// * @return 调度任务日志对象信息
// */
// @Override
// public SysJobLog selectJobLogById(Long jobLogId)
// {
// return jobLogMapper.selectJobLogById(jobLogId);
// }
//
// /**
// * 新增任务日志
// *
// * @param jobLog 调度日志信息
// */
// @Override
// public void addJobLog(SysJobLog jobLog)
// {
// jobLogMapper.insertJobLog(jobLog);
// }
//
// /**
// * 批量删除调度日志信息
// *
// * @param logIds 需要删除的数据ID
// * @return 结果
// */
// @Override
// public int deleteJobLogByIds(Long[] logIds)
// {
// return jobLogMapper.deleteJobLogByIds(logIds);
// }
//
// /**
// * 删除任务日志
// *
// * @param jobId 调度日志ID
// */
// @Override
// public int deleteJobLogById(Long jobId)
// {
// return jobLogMapper.deleteJobLogById(jobId);
// }
//
// /**
// * 清空任务日志
// */
// @Override
// public void cleanJobLog()
// {
// jobLogMapper.cleanJobLog();
// }
}
package share.quartz.task;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import share.system.service.ISCleanRecordsService;
......@@ -10,12 +11,13 @@ import share.system.service.ISCleanRecordsService;
* @author: lwj
* @create: 2023-11-13 10:52
*/
@Component("cleanRecordsTask")
@Component
public class CleanRecordsTask {
@Autowired
private ISCleanRecordsService cleanRecordsService;
@XxlJob("finishCleanRecords")
public void finishCleanRecords() {
cleanRecordsService.finishCleanRecords();
}
......
......@@ -25,7 +25,7 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Component("couponRetryTask")
@Component
public class CouponRetryTask {
@Autowired
private ISConsumerCouponService sConsumerCouponService;
......
......@@ -16,7 +16,7 @@ import java.util.List;
* @author: lwj
* @create: 2024-01-15 16:54
*/
@Component("deviceTask")
@Component
public class DeviceTask {
@Autowired
......
......@@ -27,7 +27,7 @@ import java.util.stream.Collectors;
* @Author wwl
* @Date 2023/10/25 13:48
*/
@Component("orderTask")
@Component
public class OrderTask {
private static final Logger logger = LoggerFactory.getLogger(OrderTask.class);
......
......@@ -37,7 +37,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Component("redisTask")
@Component
public class RedisTask {
private static final Logger logger = LoggerFactory.getLogger(RedisTask.class);
@Autowired
......
package share.quartz.task;
import org.omg.CORBA.ORB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import share.common.utils.DateUtils;
import share.common.utils.StringUtils;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.SRoomMapper;
import share.system.service.ISOrderService;
import share.system.service.ISRoomService;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 定时任务调度测试
*
* @author ruoyi
*/
@Component("ryTask")
public class RyTask
{
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
public void ryParams(String params)
{
System.out.println("执行有参方法:" + params);
}
public void ryNoParams()
{
System.out.println("执行无参方法");
}
}
package share.quartz.util;
import java.util.Date;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import share.common.constant.Constants;
import share.common.constant.ScheduleConstants;
import share.common.utils.ExceptionUtil;
import share.common.utils.StringUtils;
import share.common.utils.bean.BeanUtils;
import share.common.utils.spring.SpringUtils;
import share.quartz.domain.SysJob;
import share.quartz.domain.SysJobLog;
import share.quartz.service.ISysJobLogService;
/**
* 抽象quartz调用
*
* @author ruoyi
*/
public abstract class AbstractQuartzJob implements Job
{
private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
/**
* 线程本地变量
*/
private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
@Override
public void execute(JobExecutionContext context) throws JobExecutionException
{
SysJob sysJob = new SysJob();
BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
try
{
before(context, sysJob);
if (sysJob != null)
{
doExecute(context, sysJob);
}
after(context, sysJob, null);
}
catch (Exception e)
{
log.error("任务执行异常 - :", e);
after(context, sysJob, e);
}
}
/**
* 执行前
*
* @param context 工作执行上下文对象
* @param sysJob 系统计划任务
*/
protected void before(JobExecutionContext context, SysJob sysJob)
{
threadLocal.set(new Date());
}
/**
* 执行后
*
* @param context 工作执行上下文对象
* @param sysJob 系统计划任务
*/
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
{
Date startTime = threadLocal.get();
threadLocal.remove();
final SysJobLog sysJobLog = new SysJobLog();
sysJobLog.setJobName(sysJob.getJobName());
sysJobLog.setJobGroup(sysJob.getJobGroup());
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
sysJobLog.setStartTime(startTime);
sysJobLog.setStopTime(new Date());
long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
if (e != null)
{
sysJobLog.setStatus(Constants.FAIL);
String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
sysJobLog.setExceptionInfo(errorMsg);
}
else
{
sysJobLog.setStatus(Constants.SUCCESS);
}
// 写入数据库当中
SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
/**
* 执行方法,由子类重载
*
* @param context 工作执行上下文对象
* @param sysJob 系统计划任务
* @throws Exception 执行过程中的异常
*/
protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception;
}
//
//import java.util.Date;
//import org.quartz.Job;
//import org.quartz.JobExecutionContext;
//import org.quartz.JobExecutionException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import share.common.constant.Constants;
//import share.common.constant.ScheduleConstants;
//import share.common.utils.ExceptionUtil;
//import share.common.utils.StringUtils;
//import share.common.utils.bean.BeanUtils;
//import share.common.utils.spring.SpringUtils;
//import share.quartz.domain.SysJob;
//import share.quartz.domain.SysJobLog;
//import share.quartz.service.ISysJobLogService;
//
///**
// * 抽象quartz调用
// *
// * @author ruoyi
// */
//public abstract class AbstractQuartzJob implements Job
//{
// private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
//
// /**
// * 线程本地变量
// */
// private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
//
// @Override
// public void execute(JobExecutionContext context) throws JobExecutionException
// {
// SysJob sysJob = new SysJob();
// BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
// try
// {
// before(context, sysJob);
// if (sysJob != null)
// {
// doExecute(context, sysJob);
// }
// after(context, sysJob, null);
// }
// catch (Exception e)
// {
// log.error("任务执行异常 - :", e);
// after(context, sysJob, e);
// }
// }
//
// /**
// * 执行前
// *
// * @param context 工作执行上下文对象
// * @param sysJob 系统计划任务
// */
// protected void before(JobExecutionContext context, SysJob sysJob)
// {
// threadLocal.set(new Date());
// }
//
// /**
// * 执行后
// *
// * @param context 工作执行上下文对象
// * @param sysJob 系统计划任务
// */
// protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
// {
// Date startTime = threadLocal.get();
// threadLocal.remove();
//
// final SysJobLog sysJobLog = new SysJobLog();
// sysJobLog.setJobName(sysJob.getJobName());
// sysJobLog.setJobGroup(sysJob.getJobGroup());
// sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
// sysJobLog.setStartTime(startTime);
// sysJobLog.setStopTime(new Date());
// long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
// sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
// if (e != null)
// {
// sysJobLog.setStatus(Constants.FAIL);
// String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
// sysJobLog.setExceptionInfo(errorMsg);
// }
// else
// {
// sysJobLog.setStatus(Constants.SUCCESS);
// }
//
// // 写入数据库当中
//// SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
// }
//
// /**
// * 执行方法,由子类重载
// *
// * @param context 工作执行上下文对象
// * @param sysJob 系统计划任务
// * @throws Exception 执行过程中的异常
// */
// protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception;
//}
......@@ -2,7 +2,7 @@ package share.quartz.util;
import java.text.ParseException;
import java.util.Date;
import org.quartz.CronExpression;
//import org.quartz.CronExpression;
/**
* cron表达式工具类
......@@ -12,52 +12,52 @@ import org.quartz.CronExpression;
*/
public class CronUtils
{
/**
* 返回一个布尔值代表一个给定的Cron表达式的有效性
*
* @param cronExpression Cron表达式
* @return boolean 表达式是否有效
*/
public static boolean isValid(String cronExpression)
{
return CronExpression.isValidExpression(cronExpression);
}
/**
* 返回一个字符串值,表示该消息无效Cron表达式给出有效性
*
* @param cronExpression Cron表达式
* @return String 无效时返回表达式错误描述,如果有效返回null
*/
public static String getInvalidMessage(String cronExpression)
{
try
{
new CronExpression(cronExpression);
return null;
}
catch (ParseException pe)
{
return pe.getMessage();
}
}
/**
* 返回下一个执行时间根据给定的Cron表达式
*
* @param cronExpression Cron表达式
* @return Date 下次Cron表达式执行时间
*/
public static Date getNextExecution(String cronExpression)
{
try
{
CronExpression cron = new CronExpression(cronExpression);
return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
}
catch (ParseException e)
{
throw new IllegalArgumentException(e.getMessage());
}
}
// /**
// * 返回一个布尔值代表一个给定的Cron表达式的有效性
// *
// * @param cronExpression Cron表达式
// * @return boolean 表达式是否有效
// */
// public static boolean isValid(String cronExpression)
// {
// return CronExpression.isValidExpression(cronExpression);
// }
//
// /**
// * 返回一个字符串值,表示该消息无效Cron表达式给出有效性
// *
// * @param cronExpression Cron表达式
// * @return String 无效时返回表达式错误描述,如果有效返回null
// */
// public static String getInvalidMessage(String cronExpression)
// {
// try
// {
// new CronExpression(cronExpression);
// return null;
// }
// catch (ParseException pe)
// {
// return pe.getMessage();
// }
// }
//
// /**
// * 返回下一个执行时间根据给定的Cron表达式
// *
// * @param cronExpression Cron表达式
// * @return Date 下次Cron表达式执行时间
// */
// public static Date getNextExecution(String cronExpression)
// {
// try
// {
// CronExpression cron = new CronExpression(cronExpression);
// return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
// }
// catch (ParseException e)
// {
// throw new IllegalArgumentException(e.getMessage());
// }
// }
}
package share.quartz.util;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import share.quartz.domain.SysJob;
/**
* 定时任务处理(禁止并发执行)
*
* @author ruoyi
*
*/
@DisallowConcurrentExecution
public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
{
@Override
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
{
JobInvokeUtil.invokeMethod(sysJob);
}
}
//
//import org.quartz.DisallowConcurrentExecution;
//import org.quartz.JobExecutionContext;
//import share.quartz.domain.SysJob;
//
///**
// * 定时任务处理(禁止并发执行)
// *
// * @author ruoyi
// *
// */
////@DisallowConcurrentExecution
//public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
//{
// @Override
// protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
// {
// JobInvokeUtil.invokeMethod(sysJob);
// }
//}
package share.quartz.util;
import org.quartz.JobExecutionContext;
import share.quartz.domain.SysJob;
//import org.quartz.JobExecutionContext;
//import share.quartz.domain.SysJob;
/**
* 定时任务处理(允许并发执行)
*
* @author ruoyi
*
*/
public class QuartzJobExecution extends AbstractQuartzJob
{
@Override
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
{
JobInvokeUtil.invokeMethod(sysJob);
}
}
// */
//public class QuartzJobExecution extends AbstractQuartzJob
//{
// @Override
// protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
// {
// JobInvokeUtil.invokeMethod(sysJob);
// }
//}
restart.include.json=/com.alibaba.fastjson.*.jar
\ No newline at end of file
# 项目相关配置
ruoyi:
# 名称
name: Share
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /Users/workspace/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: char
# 微信相关配置
wechat:
appId: wxdd170b8783edf7a0
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
token: coujio
miniprogram_state: trial
wx:
miniapp:
configs:
- appid: wxdd170b8783edf7a0
secret: 7339f117e85876a0dfe10ea1ed47340e
token: coujio
aesKey: zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat: XML
#微信公众号配置
official:
account:
appId: wx687cc62ee62ef19a
appSecret: 1422a30daf21584f657f042ffc152fec
tiktok:
appId: awt50u5zommqxkl9
appSecret: c567551e0c4ce1db4f985d0233025d8d
accountId: 7325762036464355343
#扫呗支付配置
saobei:
key: 15490267
accessToken: a16f205455bb48b899ec38b9929c8962
instNo: 15490267
merchantNo: 852107997000216
terminalId: 15490267
payVer: 201
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8882
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
# 日志配置
logging:
level:
share: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
# Spring配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://127.0.0.1:3306/coujiao?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: root
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: gxpt
login-password: gxpt2023
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 127.0.0.1
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
mqtt:
url: "tcp://47.99.53.236:1883"
clientId: "coujiao_sub"
username: "coujiaomqtt"
password: "Mqtt@2023cj"
defaultTopic: "ydlink/#"
completion-timeout: 15000
is-subscribe-topic: true
sms:
url: "http://121.36.230.249:7862/smsv2"
username: "799243"
password: "RjaI8uA"
extno: "10690"
signature: "【凑角】"
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: share.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /prod-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice,/system/protocol
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
api:
domain: https://www.coujio.com
\ No newline at end of file
# 项目相关配置
ruoyi:
# 名称
name: Share
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /Users/workspace/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: char
# 微信相关配置
wechat:
appId: wxdd170b8783edf7a0
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
token: coujio
miniprogram_state: formal
wx:
miniapp:
configs:
- appid: wxdd170b8783edf7a0
secret: 7339f117e85876a0dfe10ea1ed47340e
token: coujio
aesKey: zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat: XML
#微信公众号配置
official:
account:
appId: wx687cc62ee62ef19a
appSecret: 1422a30daf21584f657f042ffc152fec
tiktok:
appId: awt50u5zommqxkl9
appSecret: c567551e0c4ce1db4f985d0233025d8d
accountId: 7325762036464355343
#扫呗支付配置
saobei:
key: 15490267
accessToken: a16f205455bb48b899ec38b9929c8962
instNo: 15490267
merchantNo: 852107997000216
terminalId: 15490267
payVer: 201
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8882
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
# 日志配置
logging:
level:
share: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
# Spring配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://47.99.53.236:3306/coujiao?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: root
password: Coujiao&031107
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: gxpt
login-password: gxpt2023
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 47.99.53.236
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password: Coujiao&031107
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
mqtt:
url: "tcp://47.99.53.236:1883"
clientId: "coujiao_sub"
username: "coujiaomqtt"
password: "Mqtt@2023cj"
defaultTopic: "ydlink/#"
completion-timeout: 15000
is-subscribe-topic: true
sms:
url: "http://121.36.230.249:7862/smsv2"
username: "799243"
password: "RjaI8uA"
extno: "10690"
signature: "【凑角】"
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: share.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /prod-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice,/system/protocol
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
api:
domain: https://www.coujio.com
xxl:
job:
accessToken: default_token
admin:
addresses: http://127.0.0.1:8080/xxl-job-admin
executor:
address: ''
#执行器名字,需要和网页中新建的执行器名字一致
appname: share-quartz
ip: ''
logpath: /var/gxpt/logs/xxl-job/jobhandler
logRetentionDays: 30
port: 9998
# 项目相关配置
ruoyi:
# 名称
name: Share
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /Users/workspace/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: char
# 微信相关配置
wechat:
appId: wxdd170b8783edf7a0
appSecret: 7339f117e85876a0dfe10ea1ed47340e
mchId: 1658895429
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
token: coujio
miniprogram_state: trial
wx:
miniapp:
configs:
- appid: wxdd170b8783edf7a0
secret: 7339f117e85876a0dfe10ea1ed47340e
token: coujio
aesKey: zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat: XML
#微信公众号配置
official:
account:
appId: wx687cc62ee62ef19a
appSecret: 1422a30daf21584f657f042ffc152fec
tiktok:
appId: awt50u5zommqxkl9
appSecret: c567551e0c4ce1db4f985d0233025d8d
accountId: 7325762036464355343
#扫呗支付配置
saobei:
key: 15490267
accessToken: a16f205455bb48b899ec38b9929c8962
instNo: 15490267
merchantNo: 852107997000216
terminalId: 15490267
payVer: 201
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8882
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
# 日志配置
logging:
level:
share: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
# Spring配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://129.211.46.84:3306/sharedb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: root
password: Whxz@2019
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: gxpt
login-password: gxpt2023
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 129.211.46.84
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
# password: whxz2019
password: 123456
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
mqtt:
url: "tcp://47.99.53.236:1883"
clientId: "coujiao_sub"
username: "coujiaomqtt"
password: "Mqtt@2023cj"
defaultTopic: "ydlink/#"
completion-timeout: 15000
is-subscribe-topic: true
# sms:
# url: "http://121.36.230.249:7862/smsv2"
# username: "799243"
# password: "RjaI8uA"
# extno: "10690"
# signature: "【凑角】"
sms:
url: "https://api-shss.zthysms.com"
username: "yxkjhy"
password: ")@nhctX7"
extno: "99999"
signature: "【凑角】"
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: share.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /prod-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice,/system/protocol
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
api:
domain: https://www.coujio.com
xxl:
job:
accessToken: default_token
admin:
addresses: http://47.99.53.236:8080/xxl-job-admin
executor:
address: ''
#执行器名字,需要和网页中新建的执行器名字一致
appname: share-quartz-test
ip: ''
logpath: /var/gxpt/logs/xxl-job/jobhandler
logRetentionDays: 30
port: 9998
\ No newline at end of file
spring:
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: test
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
\ No newline at end of file
#????
not.null=* ????
user.jcaptcha.error=?????
user.jcaptcha.expire=??????
user.not.exists=?????/????
user.password.not.match=?????/????
user.password.retry.limit.count=??????{0}?
user.password.retry.limit.exceed=??????{0}??????{1}??
user.password.delete=????????????
user.blocked=????????????
role.blocked=????????????
login.blocked=??????IP?????????
user.logout.success=????
length.not.valid=?????{min}?{max}?????
user.username.not.valid=* 2?20?????????????????????????
user.password.not.valid=* 5-50???
user.email.not.valid=??????
user.mobile.phone.number.not.valid=???????
user.login.success=????
user.register.success=????
user.notfound=?????
user.forcelogout=?????????????
user.unknown.error=??????????
##??????
upload.exceed.maxSize=?????????????????<br/>???????????{0}MB?
upload.filename.exceed.length=????????{0}???
##??
no.permission=??????????????????? [{0}]
no.create.permission=????????????????????? [{0}]
no.update.permission=????????????????????? [{0}]
no.delete.permission=????????????????????? [{0}]
no.export.permission=????????????????????? [{0}]
no.view.permission=????????????????????? [{0}]
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/var/gxpt/logs/task"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="share" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.quartz.mapper.SysJobLogMapper">
<resultMap type="SysJobLog" id="SysJobLogResult">
<id property="jobLogId" column="job_log_id" />
<result property="jobName" column="job_name" />
<result property="jobGroup" column="job_group" />
<result property="invokeTarget" column="invoke_target" />
<result property="jobMessage" column="job_message" />
<result property="status" column="status" />
<result property="exceptionInfo" column="exception_info" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectJobLogVo">
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
from sys_job_log
</sql>
<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/>
<where>
<if test="jobName != null and jobName != ''">
AND job_name like concat('%', #{jobName}, '%')
</if>
<if test="jobGroup != null and jobGroup != ''">
AND job_group = #{jobGroup}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="invokeTarget != null and invokeTarget != ''">
AND invoke_target like concat('%', #{invokeTarget}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectJobLogAll" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/>
</select>
<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
<include refid="selectJobLogVo"/>
where job_log_id = #{jobLogId}
</select>
<delete id="deleteJobLogById" parameterType="Long">
delete from sys_job_log where job_log_id = #{jobLogId}
</delete>
<delete id="deleteJobLogByIds" parameterType="Long">
delete from sys_job_log where job_log_id in
<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
#{jobLogId}
</foreach>
</delete>
<update id="cleanJobLog">
truncate table sys_job_log
</update>
<insert id="insertJobLog" parameterType="SysJobLog">
insert into sys_job_log(
<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
<if test="jobName != null and jobName != ''">job_name,</if>
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
<if test="jobMessage != null and jobMessage != ''">job_message,</if>
<if test="status != null and status != ''">status,</if>
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
create_time
)values(
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
<if test="jobName != null and jobName != ''">#{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
sysdate()
)
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.quartz.mapper.SysJobMapper">
<resultMap type="SysJob" id="SysJobResult">
<id property="jobId" column="job_id" />
<result property="jobName" column="job_name" />
<result property="jobGroup" column="job_group" />
<result property="invokeTarget" column="invoke_target" />
<result property="cronExpression" column="cron_expression" />
<result property="misfirePolicy" column="misfire_policy" />
<result property="concurrent" column="concurrent" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectJobVo">
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
from sys_job
</sql>
<select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult">
<include refid="selectJobVo"/>
<where>
<if test="jobName != null and jobName != ''">
AND job_name like concat('%', #{jobName}, '%')
</if>
<if test="jobGroup != null and jobGroup != ''">
AND job_group = #{jobGroup}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="invokeTarget != null and invokeTarget != ''">
AND invoke_target like concat('%', #{invokeTarget}, '%')
</if>
</where>
</select>
<select id="selectJobAll" resultMap="SysJobResult">
<include refid="selectJobVo"/>
</select>
<select id="selectJobById" parameterType="Long" resultMap="SysJobResult">
<include refid="selectJobVo"/>
where job_id = #{jobId}
</select>
<delete id="deleteJobById" parameterType="Long">
delete from sys_job where job_id = #{jobId}
</delete>
<delete id="deleteJobByIds" parameterType="Long">
delete from sys_job where job_id in
<foreach collection="array" item="jobId" open="(" separator="," close=")">
#{jobId}
</foreach>
</delete>
<update id="updateJob" parameterType="SysJob">
update sys_job
<set>
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
<if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if>
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if>
<if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if>
<if test="status !=null">status = #{status},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where job_id = #{jobId}
</update>
<insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId">
insert into sys_job(
<if test="jobId != null and jobId != 0">job_id,</if>
<if test="jobName != null and jobName != ''">job_name,</if>
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if>
<if test="concurrent != null and concurrent != ''">concurrent,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="jobId != null and jobId != 0">#{jobId},</if>
<if test="jobName != null and jobName != ''">#{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
<if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
<if test="concurrent != null and concurrent != ''">#{concurrent},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>
......@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttConnect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;
......@@ -135,11 +136,13 @@ public class MqttConfig {
* 接收消息通道
*/
@Bean
@ConditionalOnProperty(name = "mqtt.bean.consumer", havingValue = "true", matchIfMissing = false)
public MessageChannel mqttInputChannel() {
return new DirectChannel();
}
@Bean
@ConditionalOnProperty(name = "mqtt.bean.consumer", havingValue = "true", matchIfMissing = false)
public MessageProducer inbound() {
//clientId每个连接必须唯一,否则,两个相同的clientId相互挤掉线
String serverIdStr = clientId + snowFlakeUtil.nextId();
......@@ -162,6 +165,7 @@ public class MqttConfig {
*/
@Bean
@ServiceActivator(inputChannel = "mqttInputChannel")
@ConditionalOnProperty(name = "mqtt.bean.consumer", havingValue = "true", matchIfMissing = false)
public MessageHandler handler() {
return message -> {
// mqtt订阅消息由share_admin服务端处理
......@@ -195,6 +199,7 @@ public class MqttConfig {
// }
@EventListener(MqttSubscribedEvent.class)
@ConditionalOnProperty(name = "mqtt.bean.consumer", havingValue = "true", matchIfMissing = false)
public void mqttSubscribedEvent(MqttSubscribedEvent event) {
log.debug("mqttSubscribedEvent订阅成功信息: date={}, info={}", new Date(), event.toString());
}
......
......@@ -188,7 +188,7 @@
<if test="updateTime != null and updateTime != ''">and update_time = #{updateTime}</if>
<if test="arrivalTime != null and arrivalTime != ''">and arrival_time = #{arrivalTime}</if>
<if test="remark != null and remark != ''">and remark = #{remark}</if>
ORDER BY create_time DESC
ORDER BY id DESC
</select>
<select id="selectSOrderById" parameterType="Long" resultMap="SOrderResult">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment