org.jeecg.modules.quartz.entity.QuartzJob Java Examples

The following examples show how to use org.jeecg.modules.quartz.entity.QuartzJob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuartzJobController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
@RequiresRoles("admin")
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #2
Source File: QuartzJobController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
//@RequiresRoles({"admin"})
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #3
Source File: QuartzJobController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param job
 * @return
 */
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #4
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
//@RequiresRoles({"admin"})
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #5
Source File: QuartzJobServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 删除&停止删除定时任务
 */
@Override
public boolean deleteAndStopJob(QuartzJob job) {
	schedulerDelete(job.getJobClassName().trim());
	boolean ok = this.removeById(job.getId());
	return ok;
}
 
Example #6
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 导出excel
 * 
 * @param request
 * @param quartzJob
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
	// Step.1 组装查询条件
	QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, request.getParameterMap());
	// Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<QuartzJob> pageList = quartzJobService.list(queryWrapper);
	// 导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME, "定时任务列表");
	mv.addObject(NormalExcelConstants.CLASS, QuartzJob.class);
	mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("定时任务列表数据", "导出人:Jeecg", "导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
	return mv;
}
 
Example #7
Source File: QuartzJobServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 编辑&启停定时任务
 * @throws SchedulerException 
 */
@Override
public boolean editAndScheduleJob(QuartzJob quartzJob) throws SchedulerException {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		schedulerDelete(quartzJob.getJobClassName().trim());
		schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}else{
		scheduler.pauseJob(JobKey.jobKey(quartzJob.getJobClassName().trim()));
	}
	return this.updateById(quartzJob);
}
 
Example #8
Source File: QuartzJobServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 恢复定时任务
 */
@Override
public boolean resumeJob(QuartzJob quartzJob) {
	schedulerDelete(quartzJob.getJobClassName().trim());
	schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	quartzJob.setStatus(CommonConstant.STATUS_NORMAL);
	return this.updateById(quartzJob);
}
 
Example #9
Source File: QuartzJobServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 保存&启动定时任务
 */
@Override
public boolean saveAndScheduleJob(QuartzJob quartzJob) {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		// 定时器添加
		this.schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}
	// DB设置修改
	quartzJob.setDelFlag(CommonConstant.DEL_FLAG_0);
	return this.save(quartzJob);
}
 
Example #10
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 导出excel
 * 
 * @param request
 * @param quartzJob
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
	// Step.1 组装查询条件
	QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, request.getParameterMap());
	// Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<QuartzJob> pageList = quartzJobService.list(queryWrapper);
	// 导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME, "定时任务列表");
	mv.addObject(NormalExcelConstants.CLASS, QuartzJob.class);
	mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("定时任务列表数据", "导出人:Jeecg", "导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
	return mv;
}
 
Example #11
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 启动定时任务
 * 
 * @param jobClassName
 * @return
 */
//@RequiresRoles({"admin"})
@GetMapping(value = "/resume")
@ApiOperation(value = "恢复定时任务")
public Result<Object> resumeJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
	if (job == null) {
		return Result.error("定时任务不存在!");
	}
	quartzJobService.resumeJob(job);
	//scheduler.resumeJob(JobKey.jobKey(job.getJobClassName().trim()));
	return Result.ok("恢复定时任务成功");
}
 
Example #12
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 添加定时任务
 * 
 * @param quartzJob
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<?> add(@RequestBody QuartzJob quartzJob) {
	List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
	if (list != null && list.size() > 0) {
		return Result.error("该定时任务类名已存在");
	}
	quartzJobService.saveAndScheduleJob(quartzJob);
	return Result.ok("创建定时任务成功");
}
 
Example #13
Source File: QuartzJobController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 添加定时任务
 * 
 * @param quartzJob
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<?> add(@RequestBody QuartzJob quartzJob) {
	List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
	if (list != null && list.size() > 0) {
		return Result.error("该定时任务类名已存在");
	}
	quartzJobService.saveAndScheduleJob(quartzJob);
	return Result.ok("创建定时任务成功");
}
 
Example #14
Source File: QuartzJobServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 删除&停止删除定时任务
 */
@Override
public boolean deleteAndStopJob(QuartzJob job) {
	schedulerDelete(job.getJobClassName().trim());
	boolean ok = this.removeById(job.getId());
	return ok;
}
 
Example #15
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 分页列表查询
 * 
 * @param quartzJob
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<?> queryPageList(QuartzJob quartzJob, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
		@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
	QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, req.getParameterMap());
	Page<QuartzJob> page = new Page<QuartzJob>(pageNo, pageSize);
	IPage<QuartzJob> pageList = quartzJobService.page(page, queryWrapper);
       return Result.ok(pageList);

}
 
Example #16
Source File: QuartzJobServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 恢复定时任务
 */
@Override
public boolean resumeJob(QuartzJob quartzJob) {
	schedulerDelete(quartzJob.getJobClassName().trim());
	schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	quartzJob.setStatus(CommonConstant.STATUS_NORMAL);
	return this.updateById(quartzJob);
}
 
Example #17
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 更新定时任务
 * 
 * @param quartzJob
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
	try {
		quartzJobService.editAndScheduleJob(quartzJob);
	} catch (SchedulerException e) {
		log.error(e.getMessage(),e);
		return Result.error("更新定时任务失败!");
	}
    return Result.ok("更新定时任务成功!");
}
 
Example #18
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除
 * 
 * @param ids
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
	if (ids == null || "".equals(ids.trim())) {
		return Result.error("参数不识别!");
	}
	for (String id : Arrays.asList(ids.split(","))) {
		QuartzJob job = quartzJobService.getById(id);
		quartzJobService.deleteAndStopJob(job);
	}
       return Result.ok("删除定时任务成功!");
}
 
Example #19
Source File: QuartzJobServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 保存&启动定时任务
 */
@Override
public boolean saveAndScheduleJob(QuartzJob quartzJob) {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		// 定时器添加
		this.schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}
	// DB设置修改
	quartzJob.setDelFlag(CommonConstant.DEL_FLAG_0);
	return this.save(quartzJob);
}
 
Example #20
Source File: QuartzJobServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 编辑&启停定时任务
 * @throws SchedulerException 
 */
@Override
public boolean editAndScheduleJob(QuartzJob quartzJob) throws SchedulerException {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		schedulerDelete(quartzJob.getJobClassName().trim());
		schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}else{
		scheduler.pauseJob(JobKey.jobKey(quartzJob.getJobClassName().trim()));
	}
	return this.updateById(quartzJob);
}
 
Example #21
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 启动定时任务
 * 
 * @param jobClassName
 * @return
 */
@RequiresRoles("admin")
@GetMapping(value = "/resume")
@ApiOperation(value = "恢复定时任务")
public Result<Object> resumeJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
	if (job == null) {
		return Result.error("定时任务不存在!");
	}
	quartzJobService.resumeJob(job);
	//scheduler.resumeJob(JobKey.jobKey(job.getJobClassName().trim()));
	return Result.ok("恢复定时任务成功");
}
 
Example #22
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 批量删除
 * 
 * @param ids
 * @return
 */
@RequiresRoles("admin")
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
	if (ids == null || "".equals(ids.trim())) {
		return Result.error("参数不识别!");
	}
	for (String id : Arrays.asList(ids.split(","))) {
		QuartzJob job = quartzJobService.getById(id);
		quartzJobService.deleteAndStopJob(job);
	}
       return Result.ok("删除定时任务成功!");
}
 
Example #23
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 通过id删除
 * 
 * @param id
 * @return
 */
@RequiresRoles("admin")
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
	QuartzJob quartzJob = quartzJobService.getById(id);
	if (quartzJob == null) {
		return Result.error("未找到对应实体");
	}
	quartzJobService.deleteAndStopJob(quartzJob);
       return Result.ok("删除成功!");

}
 
Example #24
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 更新定时任务
 * 
 * @param quartzJob
 * @return
 */
@RequiresRoles("admin")
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
	try {
		quartzJobService.editAndScheduleJob(quartzJob);
	} catch (SchedulerException e) {
		log.error(e.getMessage(),e);
		return Result.error("更新定时任务失败!");
	}
    return Result.ok("更新定时任务成功!");
}
 
Example #25
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 添加定时任务
 * 
 * @param quartzJob
 * @return
 */
@RequiresRoles("admin")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<?> add(@RequestBody QuartzJob quartzJob) {
	List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
	if (list != null && list.size() > 0) {
		return Result.error("该定时任务类名已存在");
	}
	quartzJobService.saveAndScheduleJob(quartzJob);
	return Result.ok("创建定时任务成功");
}
 
Example #26
Source File: QuartzJobController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 分页列表查询
 * 
 * @param quartzJob
 * @param pageNo
 * @param pageSize
 * @param req
 * @return
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<?> queryPageList(QuartzJob quartzJob, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
		@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
	QueryWrapper<QuartzJob> queryWrapper = QueryGenerator.initQueryWrapper(quartzJob, req.getParameterMap());
	Page<QuartzJob> page = new Page<QuartzJob>(pageNo, pageSize);
	IPage<QuartzJob> pageList = quartzJobService.page(page, queryWrapper);
       return Result.ok(pageList);

}
 
Example #27
Source File: QuartzJobServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 删除&停止删除定时任务
 */
@Override
public boolean deleteAndStopJob(QuartzJob job) {
	schedulerDelete(job.getJobClassName().trim());
	boolean ok = this.removeById(job.getId());
	return ok;
}
 
Example #28
Source File: QuartzJobServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 编辑&启停定时任务
 * @throws SchedulerException 
 */
@Override
public boolean editAndScheduleJob(QuartzJob quartzJob) throws SchedulerException {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		schedulerDelete(quartzJob.getJobClassName().trim());
		schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}else{
		scheduler.pauseJob(JobKey.jobKey(quartzJob.getJobClassName().trim()));
	}
	return this.updateById(quartzJob);
}
 
Example #29
Source File: QuartzJobServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 恢复定时任务
 */
@Override
public boolean resumeJob(QuartzJob quartzJob) {
	schedulerDelete(quartzJob.getJobClassName().trim());
	schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	quartzJob.setStatus(CommonConstant.STATUS_NORMAL);
	return this.updateById(quartzJob);
}
 
Example #30
Source File: QuartzJobServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 保存&启动定时任务
 */
@Override
public boolean saveAndScheduleJob(QuartzJob quartzJob) {
	if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
		// 定时器添加
		this.schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
	}
	// DB设置修改
	quartzJob.setDelFlag(CommonConstant.DEL_FLAG_0);
	return this.save(quartzJob);
}