域清空时取消obj-group-list maat配置
This commit is contained in:
@@ -605,7 +605,6 @@ public class ConfigConvertUtil {
|
||||
if (!groupIdSet.contains(baseIpCfg.getGroupId())) {
|
||||
GroupCfg group = new GroupCfg();
|
||||
//groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
groupIdSet.add(baseIpCfg.getGroupId());
|
||||
group.setGroupId(baseIpCfg.getGroupId());
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
@@ -695,7 +694,7 @@ public class ConfigConvertUtil {
|
||||
// List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
// 一条业务配置创建一个分组
|
||||
com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg();
|
||||
NumBoundaryCfg cfg = new NumBoundaryCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), cfg);
|
||||
if(!groupIdSet.contains(cfg.getGroupId())){
|
||||
GroupCfg group = new GroupCfg();
|
||||
@@ -741,6 +740,43 @@ public class ConfigConvertUtil {
|
||||
map.put("dstList", dstList);
|
||||
return map;
|
||||
}
|
||||
public static <T> Map<String, List> emptyGroupConvert(Integer cfgType, BaseCfg baseCfg,
|
||||
List groupRelationList, Map<String,Object> maatTableMap, Set<Integer> groupIdSet) {
|
||||
Map<String, List> map = new HashMap();
|
||||
if (cfgType == 1) {
|
||||
if(maatTableMap.containsKey("ipMaatTable")){
|
||||
Map<String,String> groupMap=(Map<String,String>)maatTableMap.get("ipMaatTable");
|
||||
for(Map.Entry<String,String> e:groupMap.entrySet()){
|
||||
if(!groupIdSet.contains(Integer.parseInt(e.getKey()))){
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(Integer.parseInt(e.getKey()));
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
groupIdSet.add(Integer.parseInt(e.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (cfgType == 2 || cfgType == 3) {
|
||||
if(maatTableMap.containsKey("stringMaatTable")){
|
||||
Map<String,String> groupMap=(Map<String,String>)maatTableMap.get("stringMaatTable");
|
||||
for(Map.Entry<String,String> e:groupMap.entrySet()){
|
||||
if(!groupIdSet.contains(Integer.parseInt(e.getKey()))){
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(Integer.parseInt(e.getKey()));
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
groupIdSet.add(Integer.parseInt(e.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("groupList", groupRelationList);
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* 转换成字符串
|
||||
*
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface CommonPolicyDao {
|
||||
|
||||
List<CfgIndexInfo> getObjGroupListByGroupIds(@Param("groupIds")String groupIds,@Param("functionId")Integer functionId,@Param("isValid") Integer isValid);
|
||||
|
||||
void updateCfgIndexCommonGroupIds(List<CfgIndexInfo> cfgIndexInfos);
|
||||
void updateCfgIndexCommonGroupIds(CfgIndexInfo cfgIndexInfo);
|
||||
|
||||
List<ObjGroupCfg> getObjGroupList(@Param("ids")String ids);
|
||||
|
||||
|
||||
@@ -779,6 +779,12 @@
|
||||
<if test="commonGroupIds != null">
|
||||
common_group_ids= #{commonGroupIds,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isValid != null">
|
||||
is_valid= #{isValid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isAudit != null">
|
||||
is_audit= #{isAudit,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
|
||||
@@ -3362,6 +3362,7 @@ public abstract class BaseService {
|
||||
realGroupIds.deleteCharAt(realGroupIds.toString().length()-1);
|
||||
}
|
||||
List<CfgIndexInfo> toUpdateCfgIndexInfos=new ArrayList<>();
|
||||
List<CfgIndexInfo> toCancelCfgIndexInfos=new ArrayList<>();
|
||||
//查询cfg_index_info表,获取所有用到了这个group_id的非删除配置
|
||||
List<CfgIndexInfo> cfgIndexInfos=commonPolicyDao.getObjGroupListByGroupIds(realGroupIds.toString(),null,null);
|
||||
|
||||
@@ -3373,6 +3374,7 @@ public abstract class BaseService {
|
||||
List compileIds=new ArrayList();
|
||||
//组织一个大的json
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
ToMaatBean cancelMaatBean = new ToMaatBean();
|
||||
ServiceConfigTemplateUtil templateUtil=new ServiceConfigTemplateUtil();
|
||||
Map<String,Object> interceptUserRegionMap=new HashMap<>();
|
||||
for(CfgIndexInfo cfgIndexInfo:cfgIndexInfos){
|
||||
@@ -3381,6 +3383,7 @@ public abstract class BaseService {
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
Set<Integer> groupIdSet=new HashSet<>();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<MaatCfg> cancelConfigCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
@@ -3398,17 +3401,27 @@ public abstract class BaseService {
|
||||
|
||||
//需要更新的组
|
||||
cfgIndexInfo.setCommonGroupIds(gsonToJson(userRgionMap));
|
||||
if(!oldCommonGroupIds.equals(cfgIndexInfo.getCommonGroupIds())){
|
||||
if(CollectionUtils.isEmpty(cfgIndexInfo.getIpCommGroupCfgList())&&
|
||||
CollectionUtils.isEmpty(cfgIndexInfo.getUrlCommGroupList())&&CollectionUtils.isEmpty(cfgIndexInfo.getScriberIdCommGroupList())&&
|
||||
CollectionUtils.isEmpty(cfgIndexInfo.getDomainCommGroupList())){
|
||||
cfgIndexInfo.setIsValid(Constants.VALID_NO);
|
||||
cfgIndexInfo.setIsAudit(Constants.AUDIT_NOT_YES);
|
||||
cfgIndexInfo.setCommonGroupIds("");
|
||||
toCancelCfgIndexInfos.add(cfgIndexInfo);
|
||||
}else if(!oldCommonGroupIds.equals(cfgIndexInfo.getCommonGroupIds())){
|
||||
toUpdateCfgIndexInfos.add(cfgIndexInfo);
|
||||
//commonPolicyDao.updateCfgIndexCommonGroupIds(cfgIndexInfo);
|
||||
}
|
||||
|
||||
if(cfgIndexInfo.getIsValid().equals(Constants.VALID_YES)){
|
||||
//没组了,取消配置
|
||||
if(userRgionMap.isEmpty()){
|
||||
//没组了,取消配置,没域了,取消配置
|
||||
if(userRgionMap.isEmpty()||(CollectionUtils.isEmpty(cfgIndexInfo.getIpCommGroupCfgList())&&
|
||||
CollectionUtils.isEmpty(cfgIndexInfo.getUrlCommGroupList())&&CollectionUtils.isEmpty(cfgIndexInfo.getScriberIdCommGroupList())&&
|
||||
CollectionUtils.isEmpty(cfgIndexInfo.getDomainCommGroupList()))){
|
||||
maatCfg.setCompileId(cfgIndexInfo.getCompileId());
|
||||
maatCfg.setServiceId(cfgIndexInfo.getServiceId());
|
||||
maatCfg.setIsValid(0);//无效
|
||||
configCompileList.add(maatCfg);
|
||||
cancelConfigCompileList.add(maatCfg);
|
||||
}else{//有组,重新下发配置
|
||||
//保存区域IP信息
|
||||
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(cfgIndexInfo.getCompileId());
|
||||
@@ -3519,22 +3532,49 @@ public abstract class BaseService {
|
||||
|
||||
configCompileList.add(maatCfg);
|
||||
}
|
||||
if(CollectionUtils.isEmpty(maatBean.getConfigCompileList())){
|
||||
if(configCompileList.size()>0&&CollectionUtils.isEmpty(maatBean.getConfigCompileList())){
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(cfgIndexInfo.getAuditTime());
|
||||
maatBean.setCreatorName(cfgIndexInfo.getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
}
|
||||
}else if(cfgIndexInfo.getIsValid().equals(Constants.VALID_NO)){//生效的配置置为了失效
|
||||
maatCfg.setCompileId(cfgIndexInfo.getCompileId());
|
||||
maatCfg.setServiceId(cfgIndexInfo.getServiceId());
|
||||
maatCfg.setIsValid(0);//无效
|
||||
cancelConfigCompileList.add(maatCfg);
|
||||
}
|
||||
if(cancelConfigCompileList.size()>0&&CollectionUtils.isEmpty(cancelMaatBean.getConfigCompileList())){
|
||||
cancelMaatBean.setConfigCompileList(cancelConfigCompileList);
|
||||
cancelMaatBean.setAuditTime(cfgIndexInfo.getAuditTime());
|
||||
cancelMaatBean.setCreatorName(cfgIndexInfo.getCurrentUser().getName());
|
||||
cancelMaatBean.setVersion(Constants.MAAT_VERSION);
|
||||
cancelMaatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
}
|
||||
|
||||
//下发maat配置
|
||||
//auditPolicy(cfgIndexInfo,cfgIndexInfo.getIsAudit(),Constants.UPDATE_ACTION);
|
||||
}
|
||||
}
|
||||
//需要更新的cfg_index_info数据库更新
|
||||
if(toCancelCfgIndexInfos.size()>0){
|
||||
for(CfgIndexInfo info:toCancelCfgIndexInfos){
|
||||
commonPolicyDao.updateCfgIndexCommonGroupIds(info);
|
||||
}
|
||||
}
|
||||
if(toUpdateCfgIndexInfos.size()>0){
|
||||
commonPolicyDao.updateCfgIndexCommonGroupIds(toUpdateCfgIndexInfos);
|
||||
for(CfgIndexInfo info:toUpdateCfgIndexInfos){
|
||||
commonPolicyDao.updateCfgIndexCommonGroupIds(info);
|
||||
}
|
||||
}
|
||||
//向maat发送配置
|
||||
if(CollectionUtils.isNotEmpty(cancelMaatBean.getConfigCompileList())){
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(cancelMaatBean);
|
||||
logger.info("策略对象组取消配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("策略对象组取消响应信息:"+result.getMsg());
|
||||
}
|
||||
//向maat发送配置
|
||||
if(CollectionUtils.isNotEmpty(maatBean.getConfigCompileList())){
|
||||
|
||||
@@ -152,7 +152,7 @@ public class CommonGroupManageService extends BaseService{
|
||||
if(size > 0 && info.getUdFlag().equals(0)) {
|
||||
update=true;
|
||||
udFlag = 1;
|
||||
}else if(size == 0 && !info.getUdFlag().equals(2)){
|
||||
}else if(size == 0 /*&& !info.getUdFlag().equals(2)*/){
|
||||
update=true;
|
||||
}
|
||||
if(update){
|
||||
|
||||
Reference in New Issue
Block a user