白名单增加定时任务处理;
修复白名单热修改被覆盖jsp
This commit is contained in:
@@ -2951,7 +2951,7 @@ public abstract class BaseService {
|
||||
* @param tableName
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void handelScheduleCfg(Object parameterObject,String tableName){
|
||||
public void handelScheduleCfg(Object parameterObject,String tableName,BaseCfg cfg){
|
||||
logger.info("handelScheduleCfg==》开始处理定时任务");
|
||||
List<BaseCfg> cfgList = Lists.newArrayList();
|
||||
//确保 单个,批量都适用
|
||||
@@ -2970,31 +2970,16 @@ public abstract class BaseService {
|
||||
}
|
||||
|
||||
//存放需要删除的定时任务(根据compileId删除之前所有的定时任务)
|
||||
String compileIds="";
|
||||
//存放需要删除的定时任务trigger的sche
|
||||
List<ScheduleCfg> delScheduleList = Lists.newArrayList();
|
||||
String delCompileIds="";
|
||||
//存放需要失效的定时任务
|
||||
String inValidCompileIds="";
|
||||
//存放需要新增的定时任务
|
||||
List<ScheduleCfg> addScheduleList = Lists.newArrayList();
|
||||
|
||||
for(BaseCfg<?> baseCfg : cfgList) {
|
||||
//定时任务删除需要新增一条无效的sche用来清理旧的trigger
|
||||
if(baseCfg.getIsValid()==-1 || baseCfg.getIsAudit()==2 || baseCfg.getIsAudit()==3) {
|
||||
ScheduleCfg scheduleCfgdel =new ScheduleCfg();
|
||||
scheduleCfgdel.setDelFlag(0);
|
||||
scheduleCfgdel.setType(1);
|
||||
scheduleCfgdel.setTableName(tableName);
|
||||
scheduleCfgdel.setName("DELETE TRIGGER SCHE");
|
||||
scheduleCfgdel.setCompileId(baseCfg.getCompileId());
|
||||
scheduleCfgdel.setFunctionId(baseCfg.getFunctionId());
|
||||
scheduleCfgdel.setIsValid(baseCfg.getIsValid());
|
||||
scheduleCfgdel.setIsAudit(baseCfg.getIsAudit());
|
||||
scheduleCfgdel.setCfgId(baseCfg.getCfgId());
|
||||
scheduleCfgdel.setCreateTime(new Date());
|
||||
scheduleCfgdel.setCreatorId(UserUtils.getUser().getId());
|
||||
scheduleCfgdel.setServiceId(baseCfg.getServiceId());
|
||||
delScheduleList.add(scheduleCfgdel);
|
||||
}else {
|
||||
//有新的定时任务时,不需要在新增无效sche来清理旧的trigger,扫描到新增的sche时,也会有清理操作
|
||||
//有新的定时任务时,新增新的
|
||||
if(cfg.getIsValid()==0 && cfg.getIsAudit()==0){
|
||||
delCompileIds+=baseCfg.getCompileId()+",";
|
||||
ScheduleCfg scheduleCfgAdd = copyScheduleCfgFromBaseCfg(baseCfg, tableName);
|
||||
if(scheduleCfgAdd!=null){
|
||||
scheduleCfgAdd.setIsValid(0);
|
||||
@@ -3003,18 +2988,22 @@ public abstract class BaseService {
|
||||
addScheduleList.add(scheduleCfgAdd);
|
||||
}
|
||||
}
|
||||
compileIds+=baseCfg.getCompileId()+",";
|
||||
//需要失效的定时任务
|
||||
if(cfg.getIsValid()==-1 || cfg.getIsAudit()==2 ||cfg.getIsAudit()==3){
|
||||
inValidCompileIds+=baseCfg.getCompileId()+",";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//将之前的定时任务置为无效
|
||||
if(!StringUtil.isEmpty(compileIds)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
//将type=2定时任务删除
|
||||
if(!StringUtil.isEmpty(inValidCompileIds) || !StringUtil.isEmpty(delCompileIds) ) {
|
||||
String syncDelCompileIds=delCompileIds+inValidCompileIds;
|
||||
syncDelCompileIds=syncDelCompileIds.substring(0,syncDelCompileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).deleteByCompileIds(compileIds.toString());
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).deleteByCompileIds(syncDelCompileIds,2);
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
@@ -3022,16 +3011,31 @@ public abstract class BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
//新增sche,用于删除旧的定时任务
|
||||
if(!StringUtil.isEmpty(delScheduleList)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
|
||||
//将type=1定时任务删除
|
||||
if(!StringUtil.isEmpty(delCompileIds) ) {
|
||||
delCompileIds=delCompileIds.substring(0,delCompileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(ScheduleCfg entity : delScheduleList) {
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).insert(entity);
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).deleteByCompileIds(delCompileIds,1);
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//将定时任务失效
|
||||
if(!StringUtil.isEmpty(inValidCompileIds)) {
|
||||
inValidCompileIds=inValidCompileIds.substring(0,inValidCompileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
((SchedulerDao) batchSqlSession.getMapper(SchedulerDao.class)).inValidByCompileIds(inValidCompileIds);
|
||||
batchSqlSession.commit();
|
||||
} finally {
|
||||
if(batchSqlSession != null) {
|
||||
@@ -3042,7 +3046,6 @@ public abstract class BaseService {
|
||||
|
||||
//新增sche,用于新增新定时任务
|
||||
if(!StringUtil.isEmpty(addScheduleList)) {
|
||||
compileIds=compileIds.substring(0,compileIds.length()-1);
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user