upd: 编码规范
This commit is contained in:
+2
-2
@@ -67,7 +67,7 @@ public class ExecutionJobBean extends QuartzJobBean {
|
|||||||
if (StringUtil.isNotBlank(quartzJob.getSubTask())) {
|
if (StringUtil.isNotBlank(quartzJob.getSubTask())) {
|
||||||
String[] tasks = quartzJob.getSubTask().split("[,,]");
|
String[] tasks = quartzJob.getSubTask().split("[,,]");
|
||||||
// 执行子任务
|
// 执行子任务
|
||||||
quartzJobService.executionSubJob(tasks);
|
quartzJobService.startSubQuartJob(tasks);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (StringUtil.isNotBlank(uuid)) {
|
if (StringUtil.isNotBlank(uuid)) {
|
||||||
@@ -83,7 +83,7 @@ public class ExecutionJobBean extends QuartzJobBean {
|
|||||||
if (quartzJob.getPauseAfterFailure() != null && quartzJob.getPauseAfterFailure()) {
|
if (quartzJob.getPauseAfterFailure() != null && quartzJob.getPauseAfterFailure()) {
|
||||||
quartzJob.setIsPause(false);
|
quartzJob.setIsPause(false);
|
||||||
// 更新状态
|
// 更新状态
|
||||||
quartzJobService.switchJobPauseStatus(quartzJob);
|
quartzJobService.switchQuartzJobStatus(quartzJob);
|
||||||
}
|
}
|
||||||
if (quartzJob.getEmail() != null) {
|
if (quartzJob.getEmail() != null) {
|
||||||
EmailService emailService = SpringBeanHolder.getBean(EmailService.class);
|
EmailService emailService = SpringBeanHolder.getBean(EmailService.class);
|
||||||
|
|||||||
+7
-7
@@ -44,21 +44,21 @@ public class QuartzJobController {
|
|||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(QueryQuartzJobRequest criteria) {
|
public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(QueryQuartzJobRequest criteria) {
|
||||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(quartzJobService.queryJobPage(criteria, page), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.describeQuartzJobPage(criteria, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出任务数据")
|
@ApiOperation("导出任务数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public void exportQuartzJob(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
public void exportQuartzJob(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
||||||
quartzJobService.downloadJobExcel(quartzJobService.selectJobByCriteria(criteria), response);
|
quartzJobService.downloadQuartzJobExcel(quartzJobService.describeQuartzJobList(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出日志数据")
|
@ApiOperation("导出日志数据")
|
||||||
@GetMapping(value = "/logs/download")
|
@GetMapping(value = "/logs/download")
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public void exportQuartzJobLog(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
public void exportQuartzJobLog(HttpServletResponse response, QueryQuartzJobRequest criteria) throws IOException {
|
||||||
quartzJobService.downloadLogExcel(quartzJobService.selectLogByCriteria(criteria), response);
|
quartzJobService.downloadQuartzLogExcel(quartzJobService.describeQuartzLogList(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询任务执行日志")
|
@ApiOperation("查询任务执行日志")
|
||||||
@@ -66,7 +66,7 @@ public class QuartzJobController {
|
|||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(QueryQuartzJobRequest criteria) {
|
public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(QueryQuartzJobRequest criteria) {
|
||||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(quartzJobService.queryLogPage(criteria, page), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.describeQuartzLogPage(criteria, page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增定时任务")
|
@ApiOperation("新增定时任务")
|
||||||
@@ -88,7 +88,7 @@ public class QuartzJobController {
|
|||||||
public ResponseEntity<Object> updateQuartzJob(@Validated(QuartzJob.Update.class) @RequestBody UpdateQuartzJobRequest resources) {
|
public ResponseEntity<Object> updateQuartzJob(@Validated(QuartzJob.Update.class) @RequestBody UpdateQuartzJobRequest resources) {
|
||||||
// 验证Bean是不是合法的,合法的定时任务 Bean 需要用 @Service 定义
|
// 验证Bean是不是合法的,合法的定时任务 Bean 需要用 @Service 定义
|
||||||
checkBean(resources.getBeanName());
|
checkBean(resources.getBeanName());
|
||||||
quartzJobService.updateJob(resources);
|
quartzJobService.modifyQuartzJobResumeCron(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class QuartzJobController {
|
|||||||
@PostMapping(value = "/switchJobPauseStatus/{id}")
|
@PostMapping(value = "/switchJobPauseStatus/{id}")
|
||||||
@PreAuthorize("@el.check('timing:edit')")
|
@PreAuthorize("@el.check('timing:edit')")
|
||||||
public ResponseEntity<Object> switchJobPauseStatus(@PathVariable Long id) {
|
public ResponseEntity<Object> switchJobPauseStatus(@PathVariable Long id) {
|
||||||
quartzJobService.switchJobPauseStatus(quartzJobService.getById(id));
|
quartzJobService.switchQuartzJobStatus(quartzJobService.getById(id));
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ public class QuartzJobController {
|
|||||||
@PostMapping(value = "/executionQuartzJob/{id}")
|
@PostMapping(value = "/executionQuartzJob/{id}")
|
||||||
@PreAuthorize("@el.check('timing:edit')")
|
@PreAuthorize("@el.check('timing:edit')")
|
||||||
public ResponseEntity<Object> executionQuartzJob(@PathVariable Long id) {
|
public ResponseEntity<Object> executionQuartzJob(@PathVariable Long id) {
|
||||||
quartzJobService.executionJob(quartzJobService.getById(id));
|
quartzJobService.startQuartzJob(quartzJobService.getById(id));
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -22,7 +22,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
PageResult<QuartzJob> queryJobPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部
|
* 查询全部
|
||||||
@@ -30,7 +30,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param criteria 条件
|
* @param criteria 条件
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
List<QuartzJob> selectJobByCriteria(QueryQuartzJobRequest criteria);
|
List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询日志
|
* 分页查询日志
|
||||||
@@ -39,7 +39,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
PageResult<QuartzLog> queryLogPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询全部
|
* 查询全部
|
||||||
@@ -47,7 +47,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param criteria 条件
|
* @param criteria 条件
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
List<QuartzLog> selectLogByCriteria(QueryQuartzJobRequest criteria);
|
List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
@@ -57,11 +57,11 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
void createJob(QuartzJob resources);
|
void createJob(QuartzJob resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 修改任务并重新调度
|
||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void updateJob(UpdateQuartzJobRequest resources);
|
void modifyQuartzJobResumeCron(UpdateQuartzJobRequest resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除任务
|
* 删除任务
|
||||||
@@ -75,14 +75,14 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
void switchJobPauseStatus(QuartzJob quartzJob);
|
void switchQuartzJobStatus(QuartzJob quartzJob);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 立即执行定时任务
|
* 立即执行定时任务
|
||||||
*
|
*
|
||||||
* @param quartzJob /
|
* @param quartzJob /
|
||||||
*/
|
*/
|
||||||
void executionJob(QuartzJob quartzJob);
|
void startQuartzJob(QuartzJob quartzJob);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出定时任务
|
* 导出定时任务
|
||||||
@@ -91,7 +91,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param response /
|
* @param response /
|
||||||
* @throws IOException /
|
* @throws IOException /
|
||||||
*/
|
*/
|
||||||
void downloadJobExcel(List<QuartzJob> queryAll, HttpServletResponse response) throws IOException;
|
void downloadQuartzJobExcel(List<QuartzJob> queryAll, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出定时任务日志
|
* 导出定时任务日志
|
||||||
@@ -100,7 +100,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param response /
|
* @param response /
|
||||||
* @throws IOException /
|
* @throws IOException /
|
||||||
*/
|
*/
|
||||||
void downloadLogExcel(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException;
|
void downloadQuartzLogExcel(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行子任务
|
* 执行子任务
|
||||||
@@ -108,5 +108,5 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
|||||||
* @param tasks /
|
* @param tasks /
|
||||||
* @throws InterruptedException /
|
* @throws InterruptedException /
|
||||||
*/
|
*/
|
||||||
void executionSubJob(String[] tasks) throws InterruptedException;
|
void startSubQuartJob(String[] tasks) throws InterruptedException;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -42,22 +42,22 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
private final RedisHelper redisHelper;
|
private final RedisHelper redisHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<QuartzJob> queryJobPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
public PageResult<QuartzJob> describeQuartzJobPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||||
return PageUtil.toPage(quartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
return PageUtil.toPage(quartzJobMapper.queryQuartzJobPageByArgs(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<QuartzLog> queryLogPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
public PageResult<QuartzLog> describeQuartzLogPage(QueryQuartzJobRequest criteria, Page<Object> page) {
|
||||||
return PageUtil.toPage(quartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
return PageUtil.toPage(quartzLogMapper.queryQuartzLogPageByArgs(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QuartzJob> selectJobByCriteria(QueryQuartzJobRequest criteria) {
|
public List<QuartzJob> describeQuartzJobList(QueryQuartzJobRequest criteria) {
|
||||||
return quartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(quartzJobMapper)).getRecords();
|
return quartzJobMapper.queryQuartzJobPageByArgs(criteria, PageUtil.getCount(quartzJobMapper)).getRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QuartzLog> selectLogByCriteria(QueryQuartzJobRequest criteria) {
|
public List<QuartzLog> describeQuartzLogList(QueryQuartzJobRequest criteria) {
|
||||||
return quartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(quartzLogMapper)).getRecords();
|
return quartzLogMapper.queryQuartzLogPageByArgs(criteria, PageUtil.getCount(quartzLogMapper)).getRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateJob(UpdateQuartzJobRequest resources) {
|
public void modifyQuartzJobResumeCron(UpdateQuartzJobRequest resources) {
|
||||||
if (!CronExpression.isValidExpression(resources.getCronExpression())) {
|
if (!CronExpression.isValidExpression(resources.getCronExpression())) {
|
||||||
throw new BadRequestException("cron表达式格式错误");
|
throw new BadRequestException("cron表达式格式错误");
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void switchJobPauseStatus(QuartzJob quartzJob) {
|
public void switchQuartzJobStatus(QuartzJob quartzJob) {
|
||||||
// 置换暂停状态
|
// 置换暂停状态
|
||||||
if (quartzJob.getIsPause()) {
|
if (quartzJob.getIsPause()) {
|
||||||
quartzManage.resumeJob(quartzJob);
|
quartzManage.resumeJob(quartzJob);
|
||||||
@@ -103,7 +103,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executionJob(QuartzJob quartzJob) {
|
public void startQuartzJob(QuartzJob quartzJob) {
|
||||||
quartzManage.runJobNow(quartzJob);
|
quartzManage.runJobNow(quartzJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void executionSubJob(String[] tasks) throws InterruptedException {
|
public void startSubQuartJob(String[] tasks) throws InterruptedException {
|
||||||
for (String id : tasks) {
|
for (String id : tasks) {
|
||||||
if (StrUtil.isBlank(id)) {
|
if (StrUtil.isBlank(id)) {
|
||||||
// 如果是手动清除子任务id,会出现id为空字符串的问题
|
// 如果是手动清除子任务id,会出现id为空字符串的问题
|
||||||
@@ -130,7 +130,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
String uuid = IdUtil.simpleUUID();
|
String uuid = IdUtil.simpleUUID();
|
||||||
quartzJob.setUuid(uuid);
|
quartzJob.setUuid(uuid);
|
||||||
// 执行任务
|
// 执行任务
|
||||||
executionJob(quartzJob);
|
startQuartzJob(quartzJob);
|
||||||
// 获取执行状态,如果执行失败则停止后面的子任务执行
|
// 获取执行状态,如果执行失败则停止后面的子任务执行
|
||||||
Boolean result = redisHelper.get(uuid, Boolean.class);
|
Boolean result = redisHelper.get(uuid, Boolean.class);
|
||||||
while (result == null) {
|
while (result == null) {
|
||||||
@@ -146,7 +146,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadJobExcel(List<QuartzJob> quartzJobs, HttpServletResponse response) throws IOException {
|
public void downloadQuartzJobExcel(List<QuartzJob> quartzJobs, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (QuartzJob quartzJob : quartzJobs) {
|
for (QuartzJob quartzJob : quartzJobs) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
@@ -164,7 +164,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadLogExcel(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException {
|
public void downloadQuartzLogExcel(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
for (QuartzLog quartzLog : queryAllLog) {
|
for (QuartzLog quartzLog : queryAllLog) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user