|
|
@@ -1,286 +1,286 @@
|
|
|
-//package com.lc.ibps.cloud.timer.provider;
|
|
|
-//
|
|
|
-//import java.util.List;
|
|
|
-//
|
|
|
-//import javax.annotation.Resource;
|
|
|
-//
|
|
|
-//import org.springframework.context.annotation.Lazy;
|
|
|
-//import org.springframework.stereotype.Service;
|
|
|
-//import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-//import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-//
|
|
|
-//import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
-//import com.lc.ibps.api.base.page.Page;
|
|
|
-//import com.lc.ibps.base.core.constants.StringPool;
|
|
|
-//import com.lc.ibps.base.core.exception.BaseException;
|
|
|
-//import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
-//import com.lc.ibps.base.core.util.I18nUtil;
|
|
|
-//import com.lc.ibps.base.core.util.JacksonUtil;
|
|
|
-//import com.lc.ibps.base.framework.request.signature.annotation.Signature;
|
|
|
-//import com.lc.ibps.cloud.entity.APIPageList;
|
|
|
-//import com.lc.ibps.cloud.entity.APIRequestPage;
|
|
|
-//import com.lc.ibps.cloud.entity.APIResult;
|
|
|
-//import com.lc.ibps.cloud.provider.GenericProvider;
|
|
|
-//import com.lc.ibps.cloud.utils.QueryFilterUtil;
|
|
|
-//import com.lc.ibps.common.quartz.domain.JobDetail;
|
|
|
-//import com.lc.ibps.common.quartz.repository.JobDetailRepository;
|
|
|
-//import com.lc.ibps.common.quartz.vo.JobDetailVo;
|
|
|
-//import com.lc.ibps.components.quartz.BaseJob;
|
|
|
-//import com.lc.ibps.timer.api.IJobMgrService;
|
|
|
-//import com.lc.ibps.timer.api.IJobService;
|
|
|
-//
|
|
|
-//import io.swagger.annotations.Api;
|
|
|
-//import io.swagger.annotations.ApiOperation;
|
|
|
-//import io.swagger.annotations.ApiParam;
|
|
|
-//import io.swagger.annotations.Extension;
|
|
|
-//import io.swagger.annotations.ExtensionProperty;
|
|
|
-//
|
|
|
-//@Api(tags = "定时任务管理", value = "定时任务")
|
|
|
-//@Service
|
|
|
-//public class JobProvider extends GenericProvider implements IJobService, IJobMgrService {
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// @Lazy
|
|
|
-// private JobDetailRepository jobDetailRepository;
|
|
|
-// @Resource
|
|
|
-// @Lazy
|
|
|
-// private JobDetail jobDetailDomain;
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务列表", notes = "根据传入参数查询,并返回定时任务列表")
|
|
|
-// @Override
|
|
|
-// public APIResult<APIPageList<JobDetailVo>> query(
|
|
|
-// @ApiParam(name = "jobName", value = "任务名", required = false)
|
|
|
-// @RequestParam(name = "jobName", required = false) String jobName,
|
|
|
-// @ApiParam(name = "group", value = "分组", required = false)
|
|
|
-// @RequestParam(name = "group", required = false) String group,
|
|
|
-// @ApiParam(name = "page", value = "传入查询请求json字符串", required = true)
|
|
|
-// @RequestBody(required = true) APIRequestPage page){
|
|
|
-// APIResult<APIPageList<JobDetailVo>> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// Page dpage = QueryFilterUtil.getQueryFilterPage(page);
|
|
|
-// List<JobDetailVo> data = jobDetailRepository.query(jobName, group, dpage);
|
|
|
-// // 注意构造返回数据
|
|
|
-// APIPageList<JobDetailVo> apiPageData = getAPIPageList(data);
|
|
|
-// result.setData(apiPageData);
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.query"));
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务对象", notes = "根据传入参数查询,并返回定时任务对象")
|
|
|
-// @Override
|
|
|
-// public APIResult<JobDetailVo> get(
|
|
|
-// @ApiParam(name = "jobName", value = "任务名", required = true)
|
|
|
-// @RequestParam(name = "jobName", required = true) String jobName,
|
|
|
-// @ApiParam(name = "group", value = "分组", required = true)
|
|
|
-// @RequestParam(name = "group", required = true) String group){
|
|
|
-// APIResult<JobDetailVo> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// JobDetailVo data = jobDetailRepository.getByJobNameAndGroup(jobName, group);
|
|
|
-// result.setData(data);
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.get"));
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务分组列表", notes = "返回定时任务分组列表")
|
|
|
-// @Override
|
|
|
-// public APIResult<List<String>> groups(){
|
|
|
-// APIResult<List<String>> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// result.setData(jobDetailRepository.getAllGroups());
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.groups"));
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务创建", notes = "根据传入数据,保存定时任务",
|
|
|
-// extensions = {
|
|
|
-// @Extension(properties = {
|
|
|
-// @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
-// })
|
|
|
-// })
|
|
|
-// @Signature
|
|
|
-// @Override
|
|
|
-// public APIResult<String> create(
|
|
|
-// @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
-// @RequestBody(required = true) JobDetailVo job){
|
|
|
-// APIResult<String> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
-// if (isExist) {
|
|
|
-// throw new BaseException(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.create.ex"));
|
|
|
-// } else {
|
|
|
-// logger.debug("jobDataMap ==> {}", job.getJobDataMap());
|
|
|
-// jobDetailDomain.create(job.getJobName(),
|
|
|
-// job.getGroup(),
|
|
|
-// job.getJobClass(),
|
|
|
-// JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
-// job.getDescription());
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.create"));
|
|
|
-// }
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务编辑", notes = "根据传入数据,保存定时任务",
|
|
|
-// extensions = {
|
|
|
-// @Extension(properties = {
|
|
|
-// @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
-// })
|
|
|
-// })
|
|
|
-// @Signature
|
|
|
-// @Override
|
|
|
-// public APIResult<String> update(
|
|
|
-// @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
-// @RequestBody(required = true) JobDetailVo job){
|
|
|
-// APIResult<String> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
-// if (isExist) {
|
|
|
-// jobDetailDomain.update(job.getJobName(),
|
|
|
-// job.getGroup(),
|
|
|
-// job.getJobClass(),
|
|
|
-// JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
-// job.getDescription());
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.update"));
|
|
|
-// } else {
|
|
|
-// throw new BaseException(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.update.ex"));
|
|
|
-// }
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务保存", notes = "根据传入数据,保存定时任务", hidden = true,
|
|
|
-// extensions = {
|
|
|
-// @Extension(properties = {
|
|
|
-// @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
-// })
|
|
|
-// })
|
|
|
-// @Signature
|
|
|
-// @Override
|
|
|
-// public APIResult<String> save(
|
|
|
-// @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
-// @RequestBody(required = true) JobDetailVo job){
|
|
|
-// APIResult<String> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
-// if (isExist) {
|
|
|
-// jobDetailDomain.update(job.getJobName(),
|
|
|
-// job.getGroup(),
|
|
|
-// job.getJobClass(),
|
|
|
-// JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
-// job.getDescription());
|
|
|
-// } else {
|
|
|
-// logger.debug("jobDataMap ==> {}", job.getJobDataMap());
|
|
|
-// jobDetailDomain.create(job.getJobName(),
|
|
|
-// job.getGroup(),
|
|
|
-// job.getJobClass(),
|
|
|
-// JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
-// job.getDescription());
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.save"));
|
|
|
-// }
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务删除", notes = "删除定时任务",
|
|
|
-// extensions = {
|
|
|
-// @Extension(properties = {
|
|
|
-// @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
-// })
|
|
|
-// })
|
|
|
-// @Signature
|
|
|
-// @Override
|
|
|
-// public APIResult<Void> remove(
|
|
|
-// @ApiParam(name = "jobNames", value = "任务名数组", required = true)
|
|
|
-// @RequestParam(name = "jobNames", required = true) String[] jobNames,
|
|
|
-// @ApiParam(name = "groups", value = "分组名数组", required = true)
|
|
|
-// @RequestParam(name = "groups", required = true) String[] groups
|
|
|
-// ){
|
|
|
-// APIResult<Void> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// jobDetailDomain.remove(jobNames, groups);
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.remove"));
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "定时任务执行", notes = "执行定时任务",
|
|
|
-// extensions = {
|
|
|
-// @Extension(properties = {
|
|
|
-// @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
-// })
|
|
|
-// })
|
|
|
-// @Signature
|
|
|
-// @Override
|
|
|
-// public APIResult<Void> execute(
|
|
|
-// @ApiParam(name = "jobName", value = "任务名", required = true)
|
|
|
-// @RequestParam(name = "jobName", required = true) String jobName,
|
|
|
-// @ApiParam(name = "group", value = "分组名", required = true)
|
|
|
-// @RequestParam(name = "group", required = true) String group
|
|
|
-// ){
|
|
|
-// APIResult<Void> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// jobDetailDomain.execute(jobName, group);
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.execute"));
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 验证类
|
|
|
-// *
|
|
|
-// * @param jobClass
|
|
|
-// * @throws Exception
|
|
|
-// */
|
|
|
-// @ApiOperation(value = "验证类", notes = "验证类")
|
|
|
-// @Override
|
|
|
-// public APIResult<Void> validClass(
|
|
|
-// @ApiParam(name = "jobClass", value = "完整类名", required = true)
|
|
|
-// @RequestParam(name = "jobClass", required = true) String jobClass) throws Exception {
|
|
|
-// APIResult<Void> result = new APIResult<>();
|
|
|
-// try{
|
|
|
-// boolean exist = BeanUtils.validClass(jobClass);
|
|
|
-// boolean spClass = BeanUtils.isInherit(Class.forName(jobClass), BaseJob.class);
|
|
|
-//
|
|
|
-// if(exist && spClass)
|
|
|
-// {
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.validClass.success"));
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.validClass.failure"));
|
|
|
-// }
|
|
|
-// }catch(Exception e){
|
|
|
-// setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-//}
|
|
|
+package com.lc.ibps.cloud.timer.provider;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import com.lc.ibps.common.quartz.domain.JobDetail;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+
|
|
|
+import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
+import com.lc.ibps.api.base.page.Page;
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
+import com.lc.ibps.base.core.exception.BaseException;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.core.util.I18nUtil;
|
|
|
+import com.lc.ibps.base.core.util.JacksonUtil;
|
|
|
+import com.lc.ibps.base.framework.request.signature.annotation.Signature;
|
|
|
+import com.lc.ibps.cloud.entity.APIPageList;
|
|
|
+import com.lc.ibps.cloud.entity.APIRequestPage;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
+import com.lc.ibps.cloud.provider.GenericProvider;
|
|
|
+import com.lc.ibps.cloud.utils.QueryFilterUtil;
|
|
|
+import com.lc.ibps.common.quartz.repository.JobDetailRepository;
|
|
|
+import com.lc.ibps.common.quartz.vo.JobDetailVo;
|
|
|
+import com.lc.ibps.components.quartz.BaseJob;
|
|
|
+import com.lc.ibps.timer.api.IJobMgrService;
|
|
|
+import com.lc.ibps.timer.api.IJobService;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import io.swagger.annotations.Extension;
|
|
|
+import io.swagger.annotations.ExtensionProperty;
|
|
|
+
|
|
|
+@Api(tags = "定时任务管理", value = "定时任务")
|
|
|
+@Service
|
|
|
+public class JobProvider extends GenericProvider implements IJobService, IJobMgrService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private JobDetailRepository jobDetailRepository;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private JobDetail jobDetailDomain;
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务列表", notes = "根据传入参数查询,并返回定时任务列表")
|
|
|
+ @Override
|
|
|
+ public APIResult<APIPageList<JobDetailVo>> query(
|
|
|
+ @ApiParam(name = "jobName", value = "任务名", required = false)
|
|
|
+ @RequestParam(name = "jobName", required = false) String jobName,
|
|
|
+ @ApiParam(name = "group", value = "分组", required = false)
|
|
|
+ @RequestParam(name = "group", required = false) String group,
|
|
|
+ @ApiParam(name = "page", value = "传入查询请求json字符串", required = true)
|
|
|
+ @RequestBody(required = true) APIRequestPage page){
|
|
|
+ APIResult<APIPageList<JobDetailVo>> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ Page dpage = QueryFilterUtil.getQueryFilterPage(page);
|
|
|
+ List<JobDetailVo> data = jobDetailRepository.query(jobName, group, dpage);
|
|
|
+ // 注意构造返回数据
|
|
|
+ APIPageList<JobDetailVo> apiPageData = getAPIPageList(data);
|
|
|
+ result.setData(apiPageData);
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.query"));
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务对象", notes = "根据传入参数查询,并返回定时任务对象")
|
|
|
+ @Override
|
|
|
+ public APIResult<JobDetailVo> get(
|
|
|
+ @ApiParam(name = "jobName", value = "任务名", required = true)
|
|
|
+ @RequestParam(name = "jobName", required = true) String jobName,
|
|
|
+ @ApiParam(name = "group", value = "分组", required = true)
|
|
|
+ @RequestParam(name = "group", required = true) String group){
|
|
|
+ APIResult<JobDetailVo> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ JobDetailVo data = jobDetailRepository.getByJobNameAndGroup(jobName, group);
|
|
|
+ result.setData(data);
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.get"));
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务分组列表", notes = "返回定时任务分组列表")
|
|
|
+ @Override
|
|
|
+ public APIResult<List<String>> groups(){
|
|
|
+ APIResult<List<String>> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ result.setData(jobDetailRepository.getAllGroups());
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.groups"));
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务创建", notes = "根据传入数据,保存定时任务",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Signature
|
|
|
+ @Override
|
|
|
+ public APIResult<String> create(
|
|
|
+ @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
+ @RequestBody(required = true) JobDetailVo job){
|
|
|
+ APIResult<String> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
+ if (isExist) {
|
|
|
+ throw new BaseException(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.create.ex"));
|
|
|
+ } else {
|
|
|
+ logger.debug("jobDataMap ==> {}", job.getJobDataMap());
|
|
|
+ jobDetailDomain.create(job.getJobName(),
|
|
|
+ job.getGroup(),
|
|
|
+ job.getJobClass(),
|
|
|
+ JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
+ job.getDescription());
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.create"));
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务编辑", notes = "根据传入数据,保存定时任务",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Signature
|
|
|
+ @Override
|
|
|
+ public APIResult<String> update(
|
|
|
+ @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
+ @RequestBody(required = true) JobDetailVo job){
|
|
|
+ APIResult<String> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
+ if (isExist) {
|
|
|
+ jobDetailDomain.update(job.getJobName(),
|
|
|
+ job.getGroup(),
|
|
|
+ job.getJobClass(),
|
|
|
+ JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
+ job.getDescription());
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.update"));
|
|
|
+ } else {
|
|
|
+ throw new BaseException(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.update.ex"));
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务保存", notes = "根据传入数据,保存定时任务", hidden = true,
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Signature
|
|
|
+ @Override
|
|
|
+ public APIResult<String> save(
|
|
|
+ @ApiParam(name = "jobDetail", value = "定时任务对象", required = true)
|
|
|
+ @RequestBody(required = true) JobDetailVo job){
|
|
|
+ APIResult<String> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ boolean isExist = jobDetailRepository.isExists(job.getJobName(), job.getGroup());
|
|
|
+ if (isExist) {
|
|
|
+ jobDetailDomain.update(job.getJobName(),
|
|
|
+ job.getGroup(),
|
|
|
+ job.getJobClass(),
|
|
|
+ JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
+ job.getDescription());
|
|
|
+ } else {
|
|
|
+ logger.debug("jobDataMap ==> {}", job.getJobDataMap());
|
|
|
+ jobDetailDomain.create(job.getJobName(),
|
|
|
+ job.getGroup(),
|
|
|
+ job.getJobClass(),
|
|
|
+ JacksonUtil.toJsonString(job.getJobDataMap()),
|
|
|
+ job.getDescription());
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.save"));
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务删除", notes = "删除定时任务",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Signature
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> remove(
|
|
|
+ @ApiParam(name = "jobNames", value = "任务名数组", required = true)
|
|
|
+ @RequestParam(name = "jobNames", required = true) String[] jobNames,
|
|
|
+ @ApiParam(name = "groups", value = "分组名数组", required = true)
|
|
|
+ @RequestParam(name = "groups", required = true) String[] groups
|
|
|
+ ){
|
|
|
+ APIResult<Void> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ jobDetailDomain.remove(jobNames, groups);
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.remove"));
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "定时任务执行", notes = "执行定时任务",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Signature
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> execute(
|
|
|
+ @ApiParam(name = "jobName", value = "任务名", required = true)
|
|
|
+ @RequestParam(name = "jobName", required = true) String jobName,
|
|
|
+ @ApiParam(name = "group", value = "分组名", required = true)
|
|
|
+ @RequestParam(name = "group", required = true) String group
|
|
|
+ ){
|
|
|
+ APIResult<Void> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ jobDetailDomain.execute(jobName, group);
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.execute"));
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证类
|
|
|
+ *
|
|
|
+ * @param jobClass
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "验证类", notes = "验证类")
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> validClass(
|
|
|
+ @ApiParam(name = "jobClass", value = "完整类名", required = true)
|
|
|
+ @RequestParam(name = "jobClass", required = true) String jobClass) throws Exception {
|
|
|
+ APIResult<Void> result = new APIResult<>();
|
|
|
+ try{
|
|
|
+ boolean exist = BeanUtils.validClass(jobClass);
|
|
|
+ boolean spClass = BeanUtils.isInherit(Class.forName(jobClass), BaseJob.class);
|
|
|
+
|
|
|
+ if(exist && spClass)
|
|
|
+ {
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.validClass.success"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result.setMessage(I18nUtil.getMessage("com.lc.ibps.cloud.timer.provider.JobProvider.validClass.failure"));
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_TIMER.getCode(), I18nUtil.getMessage(StateEnum.ERROR_TIMER.getCode()+""), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|