2019-01-26 18:02:44 +06:00
|
|
|
|
package com.nis.web.service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.ScheduleCfg;
|
|
|
|
|
|
import com.nis.domain.ScheduleExceInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseCfg;
|
|
|
|
|
|
import com.nis.util.SchedulerTaskUtil;
|
|
|
|
|
|
import com.nis.util.ServiceConfigTemplateUtil;
|
|
|
|
|
|
import com.nis.web.dao.SchedulerDao;
|
|
|
|
|
|
import com.nis.web.dao.configuration.ConfigSynchronizationDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class ScheduleService extends BaseService{
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SchedulerDao dao ;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ConfigSynchronizationDao configSynchronizationDao;
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2019-04-19 18:35:20 +08:00
|
|
|
|
public void issueCompileInfo(ScheduleCfg cfg,Integer isValid)throws Exception {
|
2019-01-26 18:02:44 +06:00
|
|
|
|
Integer compileId = cfg.getCompileId();
|
|
|
|
|
|
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
|
2019-04-19 18:35:20 +08:00
|
|
|
|
ScheduleCfg curSchedule = dao.get(cfg.getId());//查询当前任务的最新状态
|
2019-01-26 18:02:44 +06:00
|
|
|
|
Integer curIsValid = baseCfg.getIsValid();//当前配置的最新 是否有效信息
|
2019-04-19 18:35:20 +08:00
|
|
|
|
Integer curScheduleFlag = curSchedule.getDelFlag();//当前任务最新状态是否有效
|
|
|
|
|
|
if(curScheduleFlag == 0) {
|
|
|
|
|
|
logger.info(String.format("当前任务已失效 : id:%s,delFlag:%s", cfg.getId(),curScheduleFlag));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-26 18:02:44 +06:00
|
|
|
|
if(curIsValid == isValid) {
|
|
|
|
|
|
logger.info(String.format("当前isValid状态没有变化,不需执行,compileId:%s,isValid : %s", compileId,isValid));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-04-19 18:35:20 +08:00
|
|
|
|
//下发内容
|
2019-04-09 09:10:40 +08:00
|
|
|
|
Integer isIssueContent = 1;
|
2019-01-26 18:02:44 +06:00
|
|
|
|
String errorInfo = null;
|
|
|
|
|
|
String tableName = cfg.getTableName();
|
|
|
|
|
|
SchedulerTaskUtil scheduler = new SchedulerTaskUtil();
|
|
|
|
|
|
boolean udpateConfigStatus = false;
|
2019-04-19 18:35:20 +08:00
|
|
|
|
isIssueContent=1;
|
|
|
|
|
|
if(isValid == 0) {
|
2019-04-09 09:10:40 +08:00
|
|
|
|
isIssueContent=0;
|
|
|
|
|
|
}
|
|
|
|
|
|
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
|
|
|
|
|
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByServiceId(cfg.getServiceId());
|
|
|
|
|
|
//根据编译ID查询配置表中的配置信息
|
|
|
|
|
|
for(Map<String,Object> service:serviceList){
|
|
|
|
|
|
//获取业务下的配置域
|
|
|
|
|
|
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) service.get("cfgList");
|
|
|
|
|
|
//查询子域配置详情
|
|
|
|
|
|
if(cfgList!=null){
|
|
|
|
|
|
for(Map<String,Object> m:cfgList){
|
|
|
|
|
|
String regionTable = m.get("tableName").toString();
|
|
|
|
|
|
//更新配置域表的isValid字段
|
|
|
|
|
|
dao.updateCfgTableStatus(regionTable, compileId, isValid);
|
|
|
|
|
|
}
|
2019-01-26 18:02:44 +06:00
|
|
|
|
}
|
2019-04-09 09:10:40 +08:00
|
|
|
|
}
|
2019-04-19 18:35:20 +08:00
|
|
|
|
dao.updateCfgTableStatus(tableName, compileId, isValid);
|
2019-04-09 09:10:40 +08:00
|
|
|
|
//3、更新 配置表的 isValid 字段,添加 exce_log 记录
|
2019-04-19 18:35:20 +08:00
|
|
|
|
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());
|
2019-04-09 09:10:40 +08:00
|
|
|
|
dao.insertScheduleExceLog(exceNew);
|
|
|
|
|
|
|
|
|
|
|
|
//数据库操作完成后与服务端交互
|
2019-04-19 18:35:20 +08:00
|
|
|
|
scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, isIssueContent,configSynchronizationDao);
|
|
|
|
|
|
logger.info(String.format("定时器下发配置内容,compileId:%s,isValid:%s,errorInfo:%s",compileId,isValid,errorInfo));
|
2019-01-26 18:02:44 +06:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|