Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
7cafbec8
Commit
7cafbec8
authored
Mar 27, 2020
by
邓实川
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改了下配置application,删了没用的quartz文件
parent
8b048405
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
260 deletions
+142
-260
src/main/java/cn/timer/api/config/quartz/SchedulerConfig.java
+0
-38
src/main/java/cn/timer/api/controller/quartz/JobController.java
+140
-166
src/main/java/cn/timer/api/controller/zzgl/ZzglController.java
+0
-9
src/main/java/cn/timer/api/dao/quartz/JobAndTriggerMapper.java
+0
-18
src/main/resources/application-pro.yml
+2
-2
src/main/resources/mapping/quartz/JobAndTriggerMapper.xml
+0
-27
No files found.
src/main/java/cn/timer/api/config/quartz/SchedulerConfig.java
deleted
100644 → 0
View file @
8b048405
package
cn
.
timer
.
api
.
config
.
quartz
;
//@Configuration
public
class
SchedulerConfig
{
// @Bean(name = "SchedulerFactory")
// public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
// SchedulerFactoryBean factory = new SchedulerFactoryBean();
// factory.setQuartzProperties(quartzProperties());
// return factory;
// }
//
// @Bean
// public Properties quartzProperties() throws IOException {
// PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
// propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
// // 在quartz.properties中的属性被读取并注入后再初始化对象
// propertiesFactoryBean.afterPropertiesSet();
// return propertiesFactoryBean.getObject();
// }
//
// /*
// * quartz初始化监听器
// */
// @Bean
// public QuartzInitializerListener executorListener() {
// return new QuartzInitializerListener();
// }
//
// /*
// * 通过SchedulerFactoryBean获取Scheduler的实例
// */
// @Bean(name = "Scheduler")
// public Scheduler scheduler() throws IOException {
// return schedulerFactoryBean().getScheduler();
// }
}
src/main/java/cn/timer/api/controller/quartz/JobController.java
View file @
7cafbec8
package
cn
.
timer
.
api
.
controller
.
quartz
;
//package cn.timer.api.controller.quartz;
//
import
java.util.HashMap
;
//import java.util.HashMap;
import
java.util.Map
;
//import java.util.Map;
//
import
org.quartz.CronScheduleBuilder
;
//import org.quartz.CronScheduleBuilder;
import
org.quartz.CronTrigger
;
//import org.quartz.CronTrigger;
import
org.quartz.JobBuilder
;
//import org.quartz.JobBuilder;
import
org.quartz.JobDetail
;
//import org.quartz.JobDetail;
import
org.quartz.JobKey
;
//import org.quartz.JobKey;
import
org.quartz.Scheduler
;
//import org.quartz.Scheduler;
import
org.quartz.SchedulerException
;
//import org.quartz.SchedulerException;
import
org.quartz.TriggerBuilder
;
//import org.quartz.TriggerBuilder;
import
org.quartz.TriggerKey
;
//import org.quartz.TriggerKey;
import
org.slf4j.Logger
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.slf4j.LoggerFactory
;
//import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.GetMapping
;
//import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.PostMapping
;
//import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RequestMapping
;
//import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.bind.annotation.RequestParam
;
//
import
org.springframework.web.bind.annotation.RestController
;
//import com.github.pagehelper.PageInfo;
//
import
com.github.pagehelper.PageInfo
;
//import cn.timer.api.bean.quartz.JobAndTrigger;
//import cn.timer.api.config.quartz.TestJob;
import
cn.timer.api.bean.quartz.JobAndTrigger
;
//import cn.timer.api.dao.quartz.JobAndTriggerMapper;
import
cn.timer.api.config.quartz.BaseJob
;
//import cn.timer.api.utils.Result;
import
cn.timer.api.dao.quartz.JobAndTriggerMapper
;
//import cn.timer.api.utils.ResultUtil;
import
cn.timer.api.utils.Result
;
//import io.swagger.annotations.Api;
import
cn.timer.api.utils.ResultUtil
;
//import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.Api
;
//
import
io.swagger.annotations.ApiOperation
;
//@Api(tags = "99.0 Quartz")
//@RestController
@Api
(
tags
=
"99.0 Quartz"
)
//@RequestMapping(value = "/quartz", produces = { "application/json" })
@RestController
//public class JobController {
@RequestMapping
(
value
=
"/quartz"
,
produces
=
{
"application/json"
})
//
public
class
JobController
{
// @Autowired
@Autowired
// private Scheduler scheduler;
private
JobAndTriggerMapper
jobAndTriggerMapper
;
//
// @PostMapping(value = "/addjob")
// @ApiOperation(value = "新增任务", httpMethod = "POST", notes = "接口发布说明")
// 加入Qulifier注解,通过名称注入bean
// public Result<Void> addjob(@RequestParam(value = "jobClassName") String jobClassName,
@Autowired
// @RequestParam(value = "jobGroupName") String jobGroupName,
// @Qualifier("Scheduler")
// @RequestParam(value = "cronExpression") String cronExpression) throws Exception {
private
Scheduler
scheduler
;
// addJob(jobClassName, jobGroupName, cronExpression);
// return ResultUtil.success("新增定时任务成功");
@SuppressWarnings
(
"unused"
)
// }
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
JobController
.
class
);
//
// public void addJob(String jobClassName, String jobGroupName, String cronExpression) throws Exception {
@PostMapping
(
value
=
"/addjob"
)
//
@ApiOperation
(
value
=
"新增任务"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
// // 启动调度器
public
Result
<
Void
>
addjob
(
@RequestParam
(
value
=
"jobClassName"
)
String
jobClassName
,
// scheduler.start();
@RequestParam
(
value
=
"jobGroupName"
)
String
jobGroupName
,
//
@RequestParam
(
value
=
"cronExpression"
)
String
cronExpression
)
throws
Exception
{
// // 构建job信息
addJob
(
jobClassName
,
jobGroupName
,
cronExpression
);
// JobDetail jobDetail = JobBuilder.newJob(TestJob.class)
return
ResultUtil
.
success
(
"新增定时任务成功"
);
// .withIdentity(jobClassName, jobGroupName).build();
}
//
// // 表达式调度构建器(即任务执行的时间)
public
void
addJob
(
String
jobClassName
,
String
jobGroupName
,
String
cronExpression
)
throws
Exception
{
// CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
//
// 启动调度器
// // 按新的cronExpression表达式构建一个新的trigger
scheduler
.
start
();
// CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(jobClassName, jobGroupName)
// .withSchedule(scheduleBuilder).build();
// 构建job信息
//
JobDetail
jobDetail
=
JobBuilder
.
newJob
(
getClass
(
jobClassName
).
getClass
())
// try {
.
withIdentity
(
jobClassName
,
jobGroupName
).
build
();
// scheduler.scheduleJob(jobDetail, trigger);
//
// 表达式调度构建器(即任务执行的时间)
// } catch (SchedulerException e) {
CronScheduleBuilder
scheduleBuilder
=
CronScheduleBuilder
.
cronSchedule
(
cronExpression
);
// System.out.println("创建定时任务失败" + e);
// throw new Exception("创建定时任务失败");
// 按新的cronExpression表达式构建一个新的trigger
// }
CronTrigger
trigger
=
TriggerBuilder
.
newTrigger
().
withIdentity
(
jobClassName
,
jobGroupName
)
// }
.
withSchedule
(
scheduleBuilder
).
build
();
//
// @PostMapping(value = "/pausejob")
try
{
// @ApiOperation(value = "暂停任务", httpMethod = "POST", notes = "接口发布说明")
scheduler
.
scheduleJob
(
jobDetail
,
trigger
);
// public Result<Void> pausejob(@RequestParam(value = "jobClassName") String jobClassName,
// @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
}
catch
(
SchedulerException
e
)
{
// jobPause(jobClassName, jobGroupName);
System
.
out
.
println
(
"创建定时任务失败"
+
e
);
// return ResultUtil.success("暂停定时任务成功");
throw
new
Exception
(
"创建定时任务失败"
);
// }
}
//
}
// public void jobPause(String jobClassName, String jobGroupName) throws Exception {
// scheduler.pauseJob(JobKey.jobKey(jobClassName, jobGroupName));
@PostMapping
(
value
=
"/pausejob"
)
// }
@ApiOperation
(
value
=
"暂停任务"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
//
public
Result
<
Void
>
pausejob
(
@RequestParam
(
value
=
"jobClassName"
)
String
jobClassName
,
// @PostMapping(value = "/resumejob")
@RequestParam
(
value
=
"jobGroupName"
)
String
jobGroupName
)
throws
Exception
{
// @ApiOperation(value = "恢复任务", httpMethod = "POST", notes = "接口发布说明")
jobPause
(
jobClassName
,
jobGroupName
);
// public Result<Void> resumejob(@RequestParam(value = "jobClassName") String jobClassName,
return
ResultUtil
.
success
(
"暂停定时任务成功"
);
// @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
}
// jobresume(jobClassName, jobGroupName);
// return ResultUtil.success("恢复定时任务成功");
public
void
jobPause
(
String
jobClassName
,
String
jobGroupName
)
throws
Exception
{
// }
scheduler
.
pauseJob
(
JobKey
.
jobKey
(
jobClassName
,
jobGroupName
));
//
}
// public void jobresume(String jobClassName, String jobGroupName) throws Exception {
// scheduler.resumeJob(JobKey.jobKey(jobClassName, jobGroupName));
@PostMapping
(
value
=
"/resumejob"
)
// }
@ApiOperation
(
value
=
"恢复任务"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
//
public
Result
<
Void
>
resumejob
(
@RequestParam
(
value
=
"jobClassName"
)
String
jobClassName
,
// @PostMapping(value = "/reschedulejob")
@RequestParam
(
value
=
"jobGroupName"
)
String
jobGroupName
)
throws
Exception
{
// @ApiOperation(value = "重新设置任务", httpMethod = "POST", notes = "接口发布说明")
jobresume
(
jobClassName
,
jobGroupName
);
// public Result<Void> rescheduleJob(@RequestParam(value = "jobClassName") String jobClassName,
return
ResultUtil
.
success
(
"恢复定时任务成功"
);
// @RequestParam(value = "jobGroupName") String jobGroupName,
}
// @RequestParam(value = "cronExpression") String cronExpression) throws Exception {
// jobreschedule(jobClassName, jobGroupName, cronExpression);
public
void
jobresume
(
String
jobClassName
,
String
jobGroupName
)
throws
Exception
{
// return ResultUtil.success("重设定时任务成功");
scheduler
.
resumeJob
(
JobKey
.
jobKey
(
jobClassName
,
jobGroupName
));
// }
}
//
// public void jobreschedule(String jobClassName, String jobGroupName, String cronExpression) throws Exception {
@PostMapping
(
value
=
"/reschedulejob"
)
// try {
@ApiOperation
(
value
=
"重新设置任务"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
// TriggerKey triggerKey = TriggerKey.triggerKey(jobClassName, jobGroupName);
public
Result
<
Void
>
rescheduleJob
(
@RequestParam
(
value
=
"jobClassName"
)
String
jobClassName
,
// // 表达式调度构建器
@RequestParam
(
value
=
"jobGroupName"
)
String
jobGroupName
,
// CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
@RequestParam
(
value
=
"cronExpression"
)
String
cronExpression
)
throws
Exception
{
//
jobreschedule
(
jobClassName
,
jobGroupName
,
cronExpression
);
// CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
return
ResultUtil
.
success
(
"重设定时任务成功"
);
//
}
// // 按新的cronExpression表达式重新构建trigger
// trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
public
void
jobreschedule
(
String
jobClassName
,
String
jobGroupName
,
String
cronExpression
)
throws
Exception
{
//
try
{
// // 按新的trigger重新设置job执行
TriggerKey
triggerKey
=
TriggerKey
.
triggerKey
(
jobClassName
,
jobGroupName
);
// scheduler.rescheduleJob(triggerKey, trigger);
// 表达式调度构建器
// } catch (SchedulerException e) {
CronScheduleBuilder
scheduleBuilder
=
CronScheduleBuilder
.
cronSchedule
(
cronExpression
);
// System.out.println("更新定时任务失败" + e);
// throw new Exception("更新定时任务失败");
CronTrigger
trigger
=
(
CronTrigger
)
scheduler
.
getTrigger
(
triggerKey
);
// }
// }
// 按新的cronExpression表达式重新构建trigger
//
trigger
=
trigger
.
getTriggerBuilder
().
withIdentity
(
triggerKey
).
withSchedule
(
scheduleBuilder
).
build
();
// @PostMapping(value = "/deletejob")
// @ApiOperation(value = "删除任务", httpMethod = "POST", notes = "接口发布说明")
// 按新的trigger重新设置job执行
// public Result<Void> deletejob(@RequestParam(value = "jobClassName") String jobClassName,
scheduler
.
rescheduleJob
(
triggerKey
,
trigger
);
// @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
}
catch
(
SchedulerException
e
)
{
// jobdelete(jobClassName, jobGroupName);
System
.
out
.
println
(
"更新定时任务失败"
+
e
);
// return ResultUtil.success("删除成功");
throw
new
Exception
(
"更新定时任务失败"
);
// }
}
//
}
// public void jobdelete(String jobClassName, String jobGroupName) throws Exception {
// scheduler.pauseTrigger(TriggerKey.triggerKey(jobClassName, jobGroupName));
@PostMapping
(
value
=
"/deletejob"
)
// scheduler.unscheduleJob(TriggerKey.triggerKey(jobClassName, jobGroupName));
@ApiOperation
(
value
=
"删除任务"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
// scheduler.deleteJob(JobKey.jobKey(jobClassName, jobGroupName));
public
Result
<
Void
>
deletejob
(
@RequestParam
(
value
=
"jobClassName"
)
String
jobClassName
,
// }
@RequestParam
(
value
=
"jobGroupName"
)
String
jobGroupName
)
throws
Exception
{
//
jobdelete
(
jobClassName
,
jobGroupName
);
//}
return
ResultUtil
.
success
(
"删除成功"
);
}
public
void
jobdelete
(
String
jobClassName
,
String
jobGroupName
)
throws
Exception
{
scheduler
.
pauseTrigger
(
TriggerKey
.
triggerKey
(
jobClassName
,
jobGroupName
));
scheduler
.
unscheduleJob
(
TriggerKey
.
triggerKey
(
jobClassName
,
jobGroupName
));
scheduler
.
deleteJob
(
JobKey
.
jobKey
(
jobClassName
,
jobGroupName
));
}
@GetMapping
(
value
=
"/queryjob"
)
@ApiOperation
(
value
=
"查询任务"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
Map
<
String
,
Object
>>
queryjob
(
@RequestParam
(
value
=
"pageNum"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
)
{
PageInfo
<
JobAndTrigger
>
jobAndTrigger
=
jobAndTriggerMapper
.
getJobAndTriggerDetails
(
pageNum
,
pageSize
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"JobAndTrigger"
,
jobAndTrigger
);
map
.
put
(
"number"
,
jobAndTrigger
.
getTotal
());
return
ResultUtil
.
data
(
map
,
"查询成功"
);
}
public
static
BaseJob
getClass
(
String
classname
)
throws
Exception
{
Class
<?>
class1
=
Class
.
forName
(
classname
);
return
(
BaseJob
)
class1
.
newInstance
();
}
}
src/main/java/cn/timer/api/controller/zzgl/ZzglController.java
View file @
7cafbec8
...
@@ -62,15 +62,6 @@ public class ZzglController {
...
@@ -62,15 +62,6 @@ public class ZzglController {
.
eq
(
ZzglBmgwM:
:
getOrgCode
,
orgCode
).
list
();
.
eq
(
ZzglBmgwM:
:
getOrgCode
,
orgCode
).
list
();
return
ResultUtil
.
data
(
zzglBmgwMs
);
return
ResultUtil
.
data
(
zzglBmgwMs
);
}
}
@GetMapping
(
value
=
"/deptlist2"
)
@ApiOperation
(
value
=
"获取部门岗位2"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
List
<
ZzglBmgwM
>>
selectlistdept2
(
@CurrentUser
UserBean
userBean
)
{
Integer
orgCode
=
userBean
.
getOrgCode
();
List
<
ZzglBmgwM
>
zzglBmgwMs
=
new
LambdaQueryChainWrapper
<
ZzglBmgwM
>(
zzglBmgwMMapper
)
.
select
(
ZzglBmgwM:
:
getName
,
ZzglBmgwM:
:
getId
,
ZzglBmgwM:
:
getUpId
).
eq
(
ZzglBmgwM:
:
getOrgCode
,
orgCode
).
list
();
return
ResultUtil
.
data
(
zzglBmgwMs
);
}
/**
/**
* 岗位成员
* 岗位成员
...
...
src/main/java/cn/timer/api/dao/quartz/JobAndTriggerMapper.java
deleted
100644 → 0
View file @
8b048405
package
cn
.
timer
.
api
.
dao
.
quartz
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.github.pagehelper.PageInfo
;
import
cn.timer.api.bean.quartz.JobAndTrigger
;
@Repository
public
interface
JobAndTriggerMapper
extends
BaseMapper
<
JobAndTrigger
>
{
public
PageInfo
<
JobAndTrigger
>
getJobAndTriggerDetails
(
@RequestParam
(
value
=
"pageNum"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
);
}
\ No newline at end of file
src/main/resources/application-pro.yml
View file @
7cafbec8
...
@@ -12,9 +12,9 @@ spring:
...
@@ -12,9 +12,9 @@ spring:
max-request-size
:
20MB
max-request-size
:
20MB
jpa
:
jpa
:
# 配置生成表 存储引擎InnoDB
# 配置生成表 存储引擎InnoDB
#
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database-platform
:
org.hibernate.dialect.MySQL5InnoDBDialect
# database
:
# database
:
#
open-in-view: false
open-in-view
:
false
# naming
:
# naming
:
# spring boot jpa hibernate 根据实体类生成表以及字段的命名策略
# spring boot jpa hibernate 根据实体类生成表以及字段的命名策略
# 无修改命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# 无修改命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
...
...
src/main/resources/mapping/quartz/JobAndTriggerMapper.xml
deleted
100644 → 0
View file @
8b048405
<?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=
"cn.timer.api.dao.quartz.JobAndTriggerMapper"
>
<select
id=
"getJobAndTriggerDetails"
resultType=
"cn.timer.api.bean.quartz.JobAndTrigger"
>
SELECT
qrtz_job_details.JOB_NAME,
qrtz_job_details.JOB_GROUP,
qrtz_job_details.JOB_CLASS_NAME,
qrtz_triggers.TRIGGER_NAME,
qrtz_triggers.TRIGGER_GROUP,
qrtz_cron_triggers.CRON_EXPRESSION,
qrtz_cron_triggers.TIME_ZONE_ID
FROM
qrtz_job_details
JOIN qrtz_triggers
JOIN qrtz_cron_triggers ON
qrtz_job_details.JOB_NAME =
qrtz_triggers.JOB_NAME
AND
qrtz_triggers.TRIGGER_NAME = qrtz_cron_triggers.TRIGGER_NAME
AND
qrtz_triggers.TRIGGER_GROUP = qrtz_cron_triggers.TRIGGER_GROUP
</select>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment