白名单增加各个操作的定时任务处理;
各种批量操作增加定时任务的处理;
This commit is contained in:
@@ -14,6 +14,7 @@ public class ScheduleCfg extends BaseCfg<ScheduleCfg>{
|
|||||||
private String cronValid;//生效cron表达式
|
private String cronValid;//生效cron表达式
|
||||||
private String cronInvalid;//失效cron表达式
|
private String cronInvalid;//失效cron表达式
|
||||||
private String whereStr;//动态where 条件
|
private String whereStr;//动态where 条件
|
||||||
|
private int delFlag;
|
||||||
private int type;
|
private int type;
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -45,5 +46,11 @@ public class ScheduleCfg extends BaseCfg<ScheduleCfg>{
|
|||||||
public void setType(int type) {
|
public void setType(int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
public int getDelFlag() {
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
public void setDelFlag(int delFlag) {
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,15 +82,21 @@ public class ScheduleCfgJob implements Job {
|
|||||||
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
||||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||||
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
||||||
long limit = dataMap.get("limit") == null ? 1000:dataMap.getLong("limit");
|
long limit = dataMap.get("limit") == null ? Constants.MAAT_JSON_SEND_SIZE:dataMap.getLong("limit");
|
||||||
log.info(String.format("定时配置任务开始执行,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
log.info(String.format("定时配置任务开始执行,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
||||||
List<ScheduleCfg> newlyCfg = null;
|
List<ScheduleCfg> allNewlySche = null;
|
||||||
int totalNum = 0;
|
int totalNum = 0;
|
||||||
do {
|
do {
|
||||||
newlyCfg = dao.findNewlyCfg(scheduleCfgId, limit,1);
|
allNewlySche = dao.findNewlyCfg(scheduleCfgId, limit,1,1);
|
||||||
if(newlyCfg != null && newlyCfg.size() > 0) {
|
if(allNewlySche != null && allNewlySche.size() > 0) {
|
||||||
totalNum += newlyCfg.size();
|
List<ScheduleCfg> allAddSche = new ArrayList<>();
|
||||||
for(ScheduleCfg cfg : newlyCfg) {//先取消之前的定时配置
|
totalNum += allNewlySche.size();
|
||||||
|
//先取消之前的定时配置
|
||||||
|
for(ScheduleCfg cfg : allNewlySche) {
|
||||||
|
//获取有效的任务
|
||||||
|
if(cfg.getDelFlag()==1) {
|
||||||
|
allAddSche.add(cfg);
|
||||||
|
}
|
||||||
Integer compileId = cfg.getCompileId();
|
Integer compileId = cfg.getCompileId();
|
||||||
try {
|
try {
|
||||||
//取消之前所有的 trigger
|
//取消之前所有的 trigger
|
||||||
@@ -106,7 +112,7 @@ public class ScheduleCfgJob implements Job {
|
|||||||
log.error(String.format("定时任务取消异常,compileId:%s", compileId),e);
|
log.error(String.format("定时任务取消异常,compileId:%s", compileId),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ScheduleCfg cfg : newlyCfg) {
|
for(ScheduleCfg cfg : allAddSche) {
|
||||||
Integer compileId = cfg.getCompileId();
|
Integer compileId = cfg.getCompileId();
|
||||||
try {
|
try {
|
||||||
//判断状态,重新添加最新的 trigger
|
//判断状态,重新添加最新的 trigger
|
||||||
@@ -123,12 +129,12 @@ public class ScheduleCfgJob implements Job {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//最后 保存此次 最后的id
|
//最后 保存此次 最后的id
|
||||||
ScheduleCfg lastCfg = newlyCfg.get(newlyCfg.size() -1);
|
ScheduleCfg lastCfg = allNewlySche.get(allNewlySche.size() -1);
|
||||||
scheduleCfgId = lastCfg.getId();
|
scheduleCfgId = lastCfg.getId();
|
||||||
dataMap.put("scheduleCfgId", scheduleCfgId);
|
dataMap.put("scheduleCfgId", scheduleCfgId);
|
||||||
log.info(String.format("加载定时任务,total num :%s", newlyCfg.size()));
|
log.info(String.format("加载定时任务,total num :%s", allNewlySche.size()));
|
||||||
}
|
}
|
||||||
} while (newlyCfg != null && newlyCfg.size() > 0);
|
} while (allNewlySche != null && allNewlySche.size() > 0);
|
||||||
log.info(String.format("定时配置任务结束执行,total num:%s",totalNum));
|
log.info(String.format("定时配置任务结束执行,total num:%s",totalNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,14 @@ public class ScheduleStatusJob implements Job{
|
|||||||
log.debug(String.format("任务开始执行,compileId:%s,isValid:%s",compileId,isValid ));
|
log.debug(String.format("任务开始执行,compileId:%s,isValid:%s",compileId,isValid ));
|
||||||
//配置下发,并修改 配置表的状态,保存下发记录等
|
//配置下发,并修改 配置表的状态,保存下发记录等
|
||||||
ScheduleService scheduleService = SpringContextHolder.getBean(ScheduleService.class);
|
ScheduleService scheduleService = SpringContextHolder.getBean(ScheduleService.class);
|
||||||
|
try {
|
||||||
scheduleService.issueCompileInfo(cfg, isValid?1:0);
|
scheduleService.issueCompileInfo(cfg, isValid?1:0);
|
||||||
log.debug(String.format("任务开始执行,compileId:%s,isValid:%s",compileId,isValid ));
|
} catch (Exception e) {
|
||||||
|
log.error("定时任务"+cfg.getId()+"执行失败",e);
|
||||||
|
}finally {
|
||||||
|
log.debug(String.format("任务执行完成,compileId:%s,isValid:%s",compileId,isValid ));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class ScheduleSyncCfgJob implements Job {
|
|||||||
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
||||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||||
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
||||||
long limit = dataMap.get("limit") == null ? 1000:dataMap.getLong("limit");
|
long limit = dataMap.get("limit") == null ? Constants.MAAT_JSON_SEND_SIZE:dataMap.getLong("limit");
|
||||||
log.info(String.format("Sync定时配置任务开始扫描,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
log.info(String.format("Sync定时配置任务开始扫描,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
||||||
List<ScheduleCfg> newlyCfg = null;
|
List<ScheduleCfg> newlyCfg = null;
|
||||||
int totalNum = 0;
|
int totalNum = 0;
|
||||||
@@ -94,7 +94,7 @@ public class ScheduleSyncCfgJob implements Job {
|
|||||||
String currentStatus = DictUtils.getDictLabel("currrent_sync_status", "status","0");
|
String currentStatus = DictUtils.getDictLabel("currrent_sync_status", "status","0");
|
||||||
if(!(currentStatus.equals("0") || currentStatus.equals("1") || currentStatus.equals("2"))) {
|
if(!(currentStatus.equals("0") || currentStatus.equals("1") || currentStatus.equals("2"))) {
|
||||||
do {
|
do {
|
||||||
newlyCfg = dao.findNewlyCfg(scheduleCfgId, limit,2);
|
newlyCfg = dao.findNewlyCfg(scheduleCfgId, limit,2,null);
|
||||||
if(newlyCfg != null && newlyCfg.size() > 0) {
|
if(newlyCfg != null && newlyCfg.size() > 0) {
|
||||||
totalNum += newlyCfg.size();
|
totalNum += newlyCfg.size();
|
||||||
for(ScheduleCfg cfg : newlyCfg) {//先取消之前的定时配置
|
for(ScheduleCfg cfg : newlyCfg) {//先取消之前的定时配置
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class SchedulerTaskUtil {
|
|||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
public boolean updateConfigByServiceAndCompile(Integer serviceId,Integer compileId,Integer isValid,Integer isIssueContent,ConfigSynchronizationDao configSynchronizationDao) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
public void updateConfigByServiceAndCompile(Integer serviceId,Integer compileId,Integer isValid,Integer isIssueContent,ConfigSynchronizationDao configSynchronizationDao)throws Exception{
|
||||||
// SecurityManagerInit();
|
// SecurityManagerInit();
|
||||||
// Subject subject = login("admin","zdjzsoft");
|
// Subject subject = login("admin","zdjzsoft");
|
||||||
// System.out.println(subject.getPrincipal());
|
// System.out.println(subject.getPrincipal());
|
||||||
@@ -328,9 +328,6 @@ public class SchedulerTaskUtil {
|
|||||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容响应信息:"+result.getMsg());
|
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容响应信息:"+result.getMsg());
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/*maatCfg = new MaatCfg();
|
/*maatCfg = new MaatCfg();
|
||||||
@@ -473,9 +470,6 @@ public class SchedulerTaskUtil {
|
|||||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
logger.info("定时任务修改DDOS配置内容响应信息:"+result.getMsg());
|
logger.info("定时任务修改DDOS配置内容响应信息:"+result.getMsg());
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/*maatCfg = new MaatCfg();
|
/*maatCfg = new MaatCfg();
|
||||||
@@ -614,9 +608,6 @@ public class SchedulerTaskUtil {
|
|||||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
logger.info("定时任务修改文件摘要类配置内容响应信息:"+result.getMsg());
|
logger.info("定时任务修改文件摘要类配置内容响应信息:"+result.getMsg());
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/*maatCfg = new MaatCfg();
|
/*maatCfg = new MaatCfg();
|
||||||
@@ -776,9 +767,6 @@ public class SchedulerTaskUtil {
|
|||||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
logger.info("定时任务更新APP POLICY配置内容响应信息:"+result.getMsg());
|
logger.info("定时任务更新APP POLICY配置内容响应信息:"+result.getMsg());
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/*maatCfg = new MaatCfg();
|
/*maatCfg = new MaatCfg();
|
||||||
@@ -818,7 +806,7 @@ public class SchedulerTaskUtil {
|
|||||||
|
|
||||||
}else{//只修改配置状态
|
}else{//只修改配置状态
|
||||||
//下发并修改配置状态的参数类
|
//下发并修改配置状态的参数类
|
||||||
ToUpdateMaatBeanStatus maatStatusBean = new ToUpdateMaatBeanStatus();
|
/*ToUpdateMaatBeanStatus maatStatusBean = new ToUpdateMaatBeanStatus();
|
||||||
UpdateMaatCfgStatus updateCfg = new UpdateMaatCfgStatus();
|
UpdateMaatCfgStatus updateCfg = new UpdateMaatCfgStatus();
|
||||||
List<UpdateMaatCfgStatus> configCompileStartStopList = new ArrayList();
|
List<UpdateMaatCfgStatus> configCompileStartStopList = new ArrayList();
|
||||||
maatStatusBean.setVersion(Constants.MAAT_VERSION);
|
maatStatusBean.setVersion(Constants.MAAT_VERSION);
|
||||||
@@ -864,13 +852,13 @@ public class SchedulerTaskUtil {
|
|||||||
String json=BaseService.gsonToJson(maatStatusBean);
|
String json=BaseService.gsonToJson(maatStatusBean);
|
||||||
logger.info("MAAT类配置启停状态修改内容:"+json);
|
logger.info("MAAT类配置启停状态修改内容:"+json);
|
||||||
//调用服务启停接口
|
//调用服务启停接口
|
||||||
String result = ConfigServiceUtil.configStatusUpdate(json);
|
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
logger.info("MAAT类配置启停状态修改结果:"+result);
|
logger.info("MAAT类配置启停状态修改结果:"+result.getMsg());
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
/*maatCfg = new MaatCfg();
|
maatCfg = new MaatCfg();
|
||||||
maatCfg.initDefaultValue();
|
maatCfg.initDefaultValue();
|
||||||
maatBean = new ToMaatBean();
|
maatBean = new ToMaatBean();
|
||||||
configCompileList = new ArrayList();
|
configCompileList = new ArrayList();
|
||||||
@@ -880,7 +868,7 @@ public class SchedulerTaskUtil {
|
|||||||
configCompileList.add(maatCfg);
|
configCompileList.add(maatCfg);
|
||||||
maatBean.setConfigCompileList(configCompileList);
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
maatBean.setAuditTime(entity.getAuditTime());
|
maatBean.setAuditTime(entity.getAuditTime());
|
||||||
maatBean.setCreatorName(entity.getCurrentUser().getName());
|
maatBean.setCreatorName("TaskScheduler");
|
||||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||||
//调用服务接口取消配置
|
//调用服务接口取消配置
|
||||||
@@ -888,7 +876,7 @@ public class SchedulerTaskUtil {
|
|||||||
logger.info("定时器修改配置状态:"+json);
|
logger.info("定时器修改配置状态:"+json);
|
||||||
//调用服务接口下发配置
|
//调用服务接口下发配置
|
||||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||||
logger.info("定时器修改配置状态响应时间:"+result.getMsg());*/
|
logger.info("定时器修改配置状态响应时间:"+result.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if("2".equals(serviceType)){//回调类配置
|
}else if("2".equals(serviceType)){//回调类配置
|
||||||
@@ -948,17 +936,11 @@ public class SchedulerTaskUtil {
|
|||||||
//调用服务接口修改回调类配置状态
|
//调用服务接口修改回调类配置状态
|
||||||
ToMaatResult result = ConfigServiceUtil.put(json,2);
|
ToMaatResult result = ConfigServiceUtil.put(json,2);
|
||||||
logger.info("定时器修改回调类配置状态响应信息:"+result);
|
logger.info("定时器修改回调类配置状态响应信息:"+result);
|
||||||
if(result==null){
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
//定时器非前台业务,需要设置shiro的SecurityManager
|
//定时器非前台业务,需要设置shiro的SecurityManager
|
||||||
private void SecurityManagerInit(){
|
private void SecurityManagerInit(){
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ public interface SchedulerDao extends CrudDao<ScheduleCfg> {
|
|||||||
* @param size
|
* @param size
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ScheduleCfg> findNewlyCfg(@Param("id")Long id,@Param("limit")Long limit,@Param("type")int type);
|
List<ScheduleCfg> findNewlyCfg(@Param("id")Long id,@Param("limit")Long limit,@Param("type")int type,@Param("delFlag")Integer delFlag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新 del_flag 字段为删除标识
|
* 更新 del_flag 字段为删除标识
|
||||||
* @param cfg
|
* @param cfg
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int deleteByCompileId(ScheduleCfg cfg);
|
int deleteByCompileIds(String compileIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找 配置 下发 最新记录
|
* 查找 配置 下发 最新记录
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<result property="userRegion4" column="user_region4"/>
|
<result property="userRegion4" column="user_region4"/>
|
||||||
<result property="userRegion5" column="user_region5"/>
|
<result property="userRegion5" column="user_region5"/>
|
||||||
<result property="delFlag" column="del_flag"/>
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="type" column="type"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
@@ -123,6 +124,36 @@
|
|||||||
order by a.id
|
order by a.id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 查找最新的更新数据 -->
|
||||||
|
<select id="get" resultType="com.nis.domain.ScheduleCfg">
|
||||||
|
select
|
||||||
|
a.ID,
|
||||||
|
a.NAME,
|
||||||
|
a.cron_valid,
|
||||||
|
a.cron_invalid,
|
||||||
|
a.SERVICE_ID,
|
||||||
|
a.COMPILE_ID,
|
||||||
|
a.CFG_ID,
|
||||||
|
a.IS_VALID,
|
||||||
|
a.IS_AUDIT,
|
||||||
|
a.function_id,
|
||||||
|
a.CREATOR_ID,
|
||||||
|
a.CREATE_TIME,
|
||||||
|
a.EDITOR_ID,
|
||||||
|
a.EDIT_TIME,
|
||||||
|
a.table_name,
|
||||||
|
a.user_region1,
|
||||||
|
a.user_region2,
|
||||||
|
a.user_region3,
|
||||||
|
a.user_region4,
|
||||||
|
a.user_region5,
|
||||||
|
a.del_flag,
|
||||||
|
a.type
|
||||||
|
from schedule_cfg a
|
||||||
|
<where>
|
||||||
|
and id = #{id}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
<!-- 查找最新的更新数据 -->
|
<!-- 查找最新的更新数据 -->
|
||||||
<select id="findNewlyCfg" resultMap="scheduleCfgMap">
|
<select id="findNewlyCfg" resultMap="scheduleCfgMap">
|
||||||
select
|
select
|
||||||
@@ -145,12 +176,16 @@
|
|||||||
a.user_region2,
|
a.user_region2,
|
||||||
a.user_region3,
|
a.user_region3,
|
||||||
a.user_region4,
|
a.user_region4,
|
||||||
a.user_region5
|
a.user_region5,
|
||||||
|
a.del_flag,
|
||||||
|
a.type
|
||||||
from schedule_cfg a
|
from schedule_cfg a
|
||||||
<where>
|
<where>
|
||||||
del_Flag = 1
|
|
||||||
and id > #{id}
|
and id > #{id}
|
||||||
and type=#{type}
|
and type=#{type}
|
||||||
|
<if test=" delFlag != null">
|
||||||
|
and del_flag = #{delFlag}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by a.id
|
order by a.id
|
||||||
limit #{limit}
|
limit #{limit}
|
||||||
@@ -179,6 +214,7 @@
|
|||||||
user_region3,
|
user_region3,
|
||||||
user_region4,
|
user_region4,
|
||||||
user_region5,
|
user_region5,
|
||||||
|
del_flag,
|
||||||
type
|
type
|
||||||
) values (
|
) values (
|
||||||
#{name,jdbcType=VARCHAR},
|
#{name,jdbcType=VARCHAR},
|
||||||
@@ -200,23 +236,18 @@
|
|||||||
#{userRegion3,jdbcType=VARCHAR},
|
#{userRegion3,jdbcType=VARCHAR},
|
||||||
#{userRegion4,jdbcType=VARCHAR},
|
#{userRegion4,jdbcType=VARCHAR},
|
||||||
#{userRegion5,jdbcType=VARCHAR},
|
#{userRegion5,jdbcType=VARCHAR},
|
||||||
|
#{delFlag,jdbcType=INTEGER},
|
||||||
#{type,jdbcType=INTEGER}
|
#{type,jdbcType=INTEGER}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 根据 compileId 将定时任务失效,定时任务的修改策略为:删除之前的所有配置,新增 -->
|
<!-- 根据 compileIds 将定时任务失效,定时任务的修改策略为:删除之前的所有配置,新增 -->
|
||||||
<update id="deleteByCompileId" parameterType="com.nis.domain.ScheduleCfg">
|
<update id="deleteByCompileIds" parameterType="com.nis.domain.ScheduleCfg">
|
||||||
update schedule_cfg
|
update schedule_cfg
|
||||||
<set>
|
<set>
|
||||||
<if test="editorId != null ">
|
del_flag = 0
|
||||||
editor_Id = #{editorId,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="editTime != null ">
|
|
||||||
edit_Time = #{editTime,jdbcType=TIMESTAMP},
|
|
||||||
</if>
|
|
||||||
del_flag = #{DEL_FLAG_DELETE}
|
|
||||||
</set>
|
</set>
|
||||||
WHERE compile_Id = #{compileId} and del_flag =1
|
WHERE compile_Id in (#{compileIds}) and del_flag =1
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,56 +25,31 @@ public class ScheduleService extends BaseService{
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
@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();
|
Integer compileId = cfg.getCompileId();
|
||||||
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
|
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
|
||||||
|
ScheduleCfg curSchedule = dao.get(cfg.getId());//查询当前任务的最新状态
|
||||||
Integer curIsValid = baseCfg.getIsValid();//当前配置的最新 是否有效信息
|
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) {
|
if(curIsValid == isValid) {
|
||||||
logger.info(String.format("当前isValid状态没有变化,不需执行,compileId:%s,isValid : %s", compileId,isValid));
|
logger.info(String.format("当前isValid状态没有变化,不需执行,compileId:%s,isValid : %s", compileId,isValid));
|
||||||
return;
|
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;
|
Integer isIssueContent = 1;
|
||||||
String errorInfo = null;
|
String errorInfo = null;
|
||||||
String tableName = cfg.getTableName();
|
String tableName = cfg.getTableName();
|
||||||
SchedulerTaskUtil scheduler = new SchedulerTaskUtil();
|
SchedulerTaskUtil scheduler = new SchedulerTaskUtil();
|
||||||
boolean udpateConfigStatus = false;
|
boolean udpateConfigStatus = false;
|
||||||
//生效配置需要下发
|
|
||||||
if(isValid == 1 && (exceNew == null || exceNew.getIsIssue() == 1)) {
|
|
||||||
isIssueContent=1;
|
isIssueContent=1;
|
||||||
}else {
|
if(isValid == 0) {
|
||||||
//之下发状态
|
|
||||||
isIssueContent=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();
|
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||||
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByServiceId(cfg.getServiceId());
|
List<Map<String,Object>> serviceList = serviceTemplate.getServiceListByServiceId(cfg.getServiceId());
|
||||||
//根据编译ID查询配置表中的配置信息
|
//根据编译ID查询配置表中的配置信息
|
||||||
@@ -90,30 +65,21 @@ public class ScheduleService extends BaseService{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//3、更新 配置表的 isValid 字段,添加 exce_log 记录
|
|
||||||
dao.insertScheduleExceLog(exceNew);
|
|
||||||
dao.updateCfgTableStatus(tableName, compileId, isValid);
|
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 {
|
scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, isIssueContent,configSynchronizationDao);
|
||||||
udpateConfigStatus = scheduler.updateConfigByServiceAndCompile(cfg.getServiceId(), compileId, isValid, isIssueContent,configSynchronizationDao);
|
logger.info(String.format("定时器下发配置内容,compileId:%s,isValid:%s,errorInfo:%s",compileId,isValid,errorInfo));
|
||||||
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));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(httpUrlCfgs, entity.getTableName());
|
||||||
}
|
}
|
||||||
if(!StringUtil.isEmpty(auditHttpCompileIds)) {
|
if(!StringUtil.isEmpty(auditHttpCompileIds)) {
|
||||||
commonPolicyDao.auditCfgBatch("cfg_index_info", entity,auditHttpCompileIds,null);
|
commonPolicyDao.auditCfgBatch("cfg_index_info", entity,auditHttpCompileIds,null);
|
||||||
@@ -138,6 +140,8 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
|||||||
commonPolicyDao.deleteHttpUrlCfg("http_url_cfg", entity,deleteHttpCompileIds);
|
commonPolicyDao.deleteHttpUrlCfg("http_url_cfg", entity,deleteHttpCompileIds);
|
||||||
}
|
}
|
||||||
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null);
|
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null);
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(list, entity.getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cfgList!=null){
|
if(cfgList!=null){
|
||||||
@@ -269,14 +273,26 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
|||||||
* @param isUpdateCfg
|
* @param isUpdateCfg
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public void auditCallBackData(List auditList,List compileIds,List ids,BaseCfg entity){
|
public void auditCallBackData(List auditList,List notAuditList,List compileIds,List ids,BaseCfg entity){
|
||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
||||||
commonPolicyDao.auditCfgBatch( "cfg_index_info", entity,compileIds,null);
|
commonPolicyDao.auditCfgBatch( "cfg_index_info", entity,compileIds,null);
|
||||||
|
if(entity.getIsAudit()!=1) {
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(auditList, entity.getTableName());
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(notAuditList, entity.getTableName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!StringUtil.isEmpty(ids) && !StringUtil.isEmpty(entity.getTableName())) {
|
if(!StringUtil.isEmpty(ids) && !StringUtil.isEmpty(entity.getTableName())) {
|
||||||
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,ids,null);
|
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,ids,null);
|
||||||
|
if(entity.getIsAudit()!=1) {
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(auditList, entity.getTableName());
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(notAuditList, entity.getTableName());
|
||||||
|
}
|
||||||
if(entity.getTableName().equals("pxy_obj_trusted_ca_cert")) {
|
if(entity.getTableName().equals("pxy_obj_trusted_ca_cert")) {
|
||||||
commonPolicyDao.auditCfgBatch("pxy_obj_trusted_ca_crl", entity,ids,null);
|
commonPolicyDao.auditCfgBatch("pxy_obj_trusted_ca_crl", entity,ids,null);
|
||||||
}
|
}
|
||||||
@@ -334,6 +350,8 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
|||||||
// 2.更新配置审核状态(主表)
|
// 2.更新配置审核状态(主表)
|
||||||
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
||||||
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null); // 批量审核并修改配置审核状态(主表)
|
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null); // 批量审核并修改配置审核状态(主表)
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(list, entity.getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.更新域配置审核状态(子表)
|
// 3.更新域配置审核状态(子表)
|
||||||
@@ -364,11 +382,15 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
|||||||
}else {
|
}else {
|
||||||
compileIds.add(cfg.getCompileId());
|
compileIds.add(cfg.getCompileId());
|
||||||
}
|
}
|
||||||
|
cfg.setIsValid(-1);
|
||||||
|
cfg.setIsAudit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.更新配置状态(主表)
|
// 2.更新配置状态(主表)
|
||||||
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
|
||||||
commonPolicyDao.deleteCfgBatch(entity.getTableName(), entity,compileIds); // 批量修改配置状态(主表)
|
commonPolicyDao.deleteCfgBatch(entity.getTableName(), entity,compileIds); // 批量修改配置状态(主表)
|
||||||
|
//更新各配置定时任务信息
|
||||||
|
handelScheduleCfg(list, entity.getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.更新域配置状态(子表)
|
// 3.更新域配置状态(子表)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin interceptor="com.nis.persistence.interceptor.PaginationInterceptor" />
|
<plugin interceptor="com.nis.persistence.interceptor.PaginationInterceptor" />
|
||||||
<!-- 定时任务 更新保存 拦截器 -->
|
<!-- 定时任务 更新保存 拦截器 -->
|
||||||
<plugin interceptor="com.nis.persistence.interceptor.ScheduleUpdateInterceptor" />
|
<!-- <plugin interceptor="com.nis.persistence.interceptor.ScheduleUpdateInterceptor" /> -->
|
||||||
<!-- 定时任务 查询 -->
|
<!-- 定时任务 查询 -->
|
||||||
<plugin interceptor="com.nis.persistence.interceptor.ScheduleSelectInterceptor" />
|
<plugin interceptor="com.nis.persistence.interceptor.ScheduleSelectInterceptor" />
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
Reference in New Issue
Block a user