白名单增加各个操作的定时任务处理;

各种批量操作增加定时任务的处理;
This commit is contained in:
段冬梅
2019-04-19 18:35:20 +08:00
committed by duandongmei
parent bf3921c9e0
commit 6bcb9d6fd6
10 changed files with 135 additions and 115 deletions

View File

@@ -25,56 +25,31 @@ public class ScheduleService extends BaseService{
@SuppressWarnings("rawtypes")
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void issueCompileInfo(ScheduleCfg cfg,Integer isValid) {
public void issueCompileInfo(ScheduleCfg cfg,Integer isValid)throws Exception {
Integer compileId = cfg.getCompileId();
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
ScheduleCfg curSchedule = dao.get(cfg.getId());//查询当前任务的最新状态
Integer curIsValid = baseCfg.getIsValid();//当前配置的最新 是否有效信息
Integer curScheduleFlag = curSchedule.getDelFlag();//当前任务最新状态是否有效
if(curScheduleFlag == 0) {
logger.info(String.format("当前任务已失效 : id:%s,delFlag:%s", cfg.getId(),curScheduleFlag));
return;
}
if(curIsValid == isValid) {
logger.info(String.format("当前isValid状态没有变化,不需执行,compileId:%s,isValid : %s", compileId,isValid));
return;
}
//1、根据 compileId isvalid 查找new 判断是否已经下发过
ScheduleExceInfo se = new ScheduleExceInfo();
se.setCompileId(compileId);
se.setIsValid(isValid);
ScheduleExceInfo exceNew = dao.findScheduleExceNew(se);
//2、如果已经下发直接下发状态否则下发配置
Integer issueResult = 1;
//是否下发内容
//下发内容
Integer isIssueContent = 1;
String errorInfo = null;
String tableName = cfg.getTableName();
SchedulerTaskUtil scheduler = new SchedulerTaskUtil();
boolean udpateConfigStatus = false;
//生效配置需要下发
if(isValid == 1 && (exceNew == null || exceNew.getIsIssue() == 1)) {
isIssueContent=1;
}else {
//之下发状态
isIssueContent=1;
if(isValid == 0) {
isIssueContent=0;
}
//首先对数据库操作
if(exceNew == null) {
//新增exce_new 表状态
exceNew = new ScheduleExceInfo();
exceNew.setCompileId(compileId);
exceNew.setIssueStatus(isValid);
exceNew.setExceTime(new Date());
exceNew.setIssueResult(issueResult);
exceNew.setErrorInfo(errorInfo);
exceNew.setIsIssue(0);
exceNew.setScheduleId(cfg.getId());
dao.insertScheduleExceNew(exceNew);
}else {
//修改 exce_new 表状态
exceNew.setExceTime(new Date());
exceNew.setIssueResult(issueResult);
exceNew.setErrorInfo(errorInfo);
exceNew.setScheduleId(cfg.getId());
dao.updateScheduleExceNew(exceNew);
}
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByServiceId(cfg.getServiceId());
//根据编译ID查询配置表中的配置信息
@@ -90,30 +65,21 @@ public class ScheduleService extends BaseService{
}
}
}
//3、更新 配置表的 isValid 字段,添加 exce_log 记录
dao.insertScheduleExceLog(exceNew);
dao.updateCfgTableStatus(tableName, compileId, isValid);
//3、更新 配置表的 isValid 字段,添加 exce_log 记录
ScheduleExceInfo exceNew = new ScheduleExceInfo();
exceNew.setCompileId(compileId);
exceNew.setIssueStatus(isValid);
exceNew.setExceTime(new Date());
exceNew.setIssueResult(1);
exceNew.setErrorInfo(errorInfo);
exceNew.setIsIssue(0);
exceNew.setScheduleId(cfg.getId());
dao.insertScheduleExceLog(exceNew);
//数据库操作完成后与服务端交互
try {
udpateConfigStatus = scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, isIssueContent,configSynchronizationDao);
logger.info(String.format("定时器下发配置内容compileId:%s,isValid:%s,issueResult:%s,errorInfo:%s",compileId,isValid,issueResult,errorInfo));
} catch (NoSuchFieldException e) {
udpateConfigStatus = false;
e.printStackTrace();
} catch (SecurityException e) {
udpateConfigStatus = false;
e.printStackTrace();
} catch (IllegalArgumentException e) {
udpateConfigStatus = false;
e.printStackTrace();
} catch (IllegalAccessException e) {
udpateConfigStatus = false;
e.printStackTrace();
}
// logger.info(String.format("配置状态更新compileId:%s,isValid:%s,issueResult:%s,errorInfo:%s",compileId,isValid,issueResult,errorInfo));
scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, isIssueContent,configSynchronizationDao);
logger.info(String.format("定时器下发配置内容compileId:%s,isValid:%s,errorInfo:%s",compileId,isValid,errorInfo));
}