白名单增加定时任务处理;

修复白名单热修改被覆盖jsp

Conflicts:
	src/main/java/com/nis/web/service/configuration/IpCfgService.java
	src/main/resources/sql/20190417/extends_ip_port_pattern.sql
This commit is contained in:
duandongmei
2019-04-21 13:15:29 +08:00
parent 6bcb9d6fd6
commit 7fdd0f7568
7 changed files with 716 additions and 550 deletions

View File

@@ -22,12 +22,18 @@ public interface SchedulerDao extends CrudDao<ScheduleCfg> {
*/
List<ScheduleCfg> findNewlyCfg(@Param("id")Long id,@Param("limit")Long limit,@Param("type")int type,@Param("delFlag")Integer delFlag);
/**
* 删除定时任务
* @param cfg
* @return
*/
int deleteByCompileIds(@Param("compileIds")String compileIds,@Param("type")Integer type);
/**
* 更新 del_flag 字段为删除标识
* @param cfg
* @return
*/
int deleteByCompileIds(String compileIds);
int inValidByCompileIds(@Param("compileIds")String compileIds);
/**
* 查找 配置 下发 最新记录

View File

@@ -94,7 +94,6 @@
<include refid="scheduleCfgColumns"/>
from schedule_cfg a
<where>
del_Flag = #{DEL_FLAG_NORMAL}
<if test="id != null">
and id = #{id}
</if>
@@ -116,12 +115,15 @@
<if test="tableName != null and tableName != ''">
and table_name = #{tableName}
</if>
and type = 1
<!-- del_Flag = #{DEL_FLAG_NORMAL} -->
and name is null
<!-- 动态where条件 -->
<if test=" whereStr != null and whereStr !=''">
${whereStr}
</if>
</where>
order by a.id
order by a.id desc
</select>
<!-- 查找最新的更新数据 -->
@@ -242,12 +244,17 @@
</insert>
<!-- 根据 compileIds 将定时任务失效,定时任务的修改策略为:删除之前的所有配置,新增 -->
<update id="deleteByCompileIds" parameterType="com.nis.domain.ScheduleCfg">
<update id="inValidByCompileIds" parameterType="com.nis.domain.ScheduleCfg">
update schedule_cfg
<set>
del_flag = 0
</set>
WHERE compile_Id in (#{compileIds}) and del_flag =1
WHERE compile_Id in (${compileIds}) and del_flag =1
</update>
<!-- 根据 compileIds 将定时任务删除 -->
<update id="deleteByCompileIds">
delete from schedule_cfg
WHERE compile_Id in (${compileIds}) and type=#{type}
</update>

View File

@@ -3053,7 +3053,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();
//确保 单个,批量都适用
@@ -3072,31 +3072,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);
@@ -3105,18 +3090,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) {
@@ -3124,16 +3113,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) {
@@ -3144,7 +3148,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 {

View File

@@ -30,7 +30,10 @@ public class ScheduleService extends BaseService{
BaseCfg baseCfg = dao.getCfgTableInfo(cfg.getTableName(),compileId);//查询当前配置的最新状态
ScheduleCfg curSchedule = dao.get(cfg.getId());//查询当前任务的最新状态
Integer curIsValid = baseCfg.getIsValid();//当前配置的最新 是否有效信息
Integer curScheduleFlag = curSchedule.getDelFlag();//当前任务最新状态是否有效
Integer curScheduleFlag =0;
if(curSchedule!=null){
curScheduleFlag = curSchedule.getDelFlag();//当前任务最新状态是否有效
}
if(curScheduleFlag == 0) {
logger.info(String.format("当前任务已失效 : id:%s,delFlag:%s", cfg.getId(),curScheduleFlag));
return;

View File

@@ -129,7 +129,7 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
}
}
//更新各配置定时任务信息
handelScheduleCfg(httpUrlCfgs, entity.getTableName());
handelScheduleCfg(httpUrlCfgs, entity.getTableName(),entity);
}
if(!StringUtil.isEmpty(auditHttpCompileIds)) {
commonPolicyDao.auditCfgBatch("cfg_index_info", entity,auditHttpCompileIds,null);
@@ -141,7 +141,7 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
}
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null);
//更新各配置定时任务信息
handelScheduleCfg(list, entity.getTableName());
handelScheduleCfg(list, entity.getTableName(),entity);
}
if(cfgList!=null){
@@ -280,18 +280,18 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
commonPolicyDao.auditCfgBatch( "cfg_index_info", entity,compileIds,null);
if(entity.getIsAudit()!=1) {
//更新各配置定时任务信息
handelScheduleCfg(auditList, entity.getTableName());
handelScheduleCfg(auditList, entity.getTableName(),entity);
//更新各配置定时任务信息
handelScheduleCfg(notAuditList, entity.getTableName());
handelScheduleCfg(notAuditList, entity.getTableName(),entity);
}
}
if(!StringUtil.isEmpty(ids) && !StringUtil.isEmpty(entity.getTableName())) {
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,ids,null);
if(entity.getIsAudit()!=1) {
//更新各配置定时任务信息
handelScheduleCfg(auditList, entity.getTableName());
handelScheduleCfg(auditList, entity.getTableName(),entity);
//更新各配置定时任务信息
handelScheduleCfg(notAuditList, entity.getTableName());
handelScheduleCfg(notAuditList, entity.getTableName(),entity);
}
if(entity.getTableName().equals("pxy_obj_trusted_ca_cert")) {
commonPolicyDao.auditCfgBatch("pxy_obj_trusted_ca_crl", entity,ids,null);
@@ -351,7 +351,7 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,compileIds,null); // 批量审核并修改配置审核状态(主表)
//更新各配置定时任务信息
handelScheduleCfg(list, entity.getTableName());
handelScheduleCfg(list, entity.getTableName(),entity);
}
// 3.更新域配置审核状态(子表)
@@ -390,7 +390,7 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
if(!StringUtil.isEmpty(compileIds) && !StringUtil.isEmpty(entity.getTableName())) {
commonPolicyDao.deleteCfgBatch(entity.getTableName(), entity,compileIds); // 批量修改配置状态(主表)
//更新各配置定时任务信息
handelScheduleCfg(list, entity.getTableName());
handelScheduleCfg(list, entity.getTableName(),entity);
}
// 3.更新域配置状态(子表)

View File

@@ -49,6 +49,7 @@ import com.nis.web.service.CrudService;
/**
* IP相关配置事务类
*
* @author dell
*
*/
@@ -67,15 +68,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
protected ConfigGroupInfoDao configGroupInfoDao;
@Autowired
protected AsnIpCfgDao asnIpCfgDao;
/**
*
* addIpCfg(新增IP类配置)
* (继承BaseIpCfg这个类方可使用)
* addIpCfg(新增IP类配置) (继承BaseIpCfg这个类方可使用)
*
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
* @return int
* @exception @since
* 1.0.0
*/
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void addIpCfg(BaseIpCfg cfg) {
@@ -110,6 +111,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void saveIpCfg(CfgIndexInfo entity) {
// 设置区域运营商信息
@@ -161,7 +163,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
// 保存asn组织信息 字符串域信息
if (StringUtils.isNotBlank(entity.getUserRegion4())) {
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionRegionDict> functionRegionDicts = DictUtils
.getFunctionRegionDictList(entity.getFunctionId());
FunctionRegionDict regionDict = null;
for (FunctionRegionDict dict : functionRegionDicts) {
if ("asn".equals(dict.getConfigServiceType())) {
@@ -175,7 +178,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
AsnGroupInfo info = asnGroupInfoDao.getGroupInfo(asnSearch);
if (info != null) {
BaseStringCfg<AsnKeywordCfg> asnKeywordCfg = new AsnKeywordCfg();
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgDesc","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3"});
BeanUtils.copyProperties(entity, asnKeywordCfg, new String[] { "cfgId", "cfgDesc",
"cfgRegionCode", "cfgType", "userRegion1", "userRegion2", "userRegion3" });
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
asnKeywordCfg.setCfgKeywords("AS" + info.getAsnId());
asnKeywordCfg.setExprType(0);
@@ -194,7 +198,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
// TODO 处理定时任务【如果有定时任务则新增】
handelScheduleCfg(entity, entity.getIndexTable());
handelScheduleCfg(entity, entity.getIndexTable(), entity);
if (isValid == 1) {
entity.setIsAudit(1);
@@ -238,7 +242,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
// 保存asn组织信息 字符串域信息
if (StringUtils.isNotBlank(entity.getUserRegion4())) {
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
List<FunctionRegionDict> functionRegionDicts = DictUtils
.getFunctionRegionDictList(entity.getFunctionId());
FunctionRegionDict regionDict = null;
for (FunctionRegionDict dict : functionRegionDicts) {
if ("asn".equals(dict.getConfigServiceType())) {
@@ -254,7 +259,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
AsnGroupInfo info = asnGroupInfoDao.getGroupInfo(asnSearch);
if (info != null) {
BaseStringCfg<AsnKeywordCfg> asnKeywordCfg = new AsnKeywordCfg();
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgDesc","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3"});
BeanUtils.copyProperties(entity, asnKeywordCfg, new String[] { "cfgId", "cfgDesc",
"cfgRegionCode", "cfgType", "userRegion1", "userRegion2", "userRegion3" });
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
asnKeywordCfg.setCfgKeywords("AS" + info.getAsnId());
asnKeywordCfg.setExprType(0);
@@ -275,7 +281,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
// TODO 处理定时任务【如果有定时任务则删除旧的,新增新的】
handelScheduleCfg(entity, entity.getIndexTable());
handelScheduleCfg(entity, entity.getIndexTable(), entity);
if (isValid == 1) {
entity.setIsAudit(1);
@@ -284,6 +290,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
}
public void updateIpCfgValid(Integer isValid, String ids, Integer functionId) {
String[] idArray = ids.split(",");
for (String id : idArray) {
@@ -303,15 +310,13 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
cfg.setTableName(IpPortCfg.getTablename());
ipCfgDao.updateCfgValid(cfg);
}
if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0)
{
if (entity.getNtcSubscribeIdCfgList() != null && entity.getNtcSubscribeIdCfgList().size() > 0) {
NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg();
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
cfg.setTableName(NtcSubscribeIdCfg.getTablename());
ipCfgDao.updateCfgValid(cfg);
}
if(entity.getAsnKeywords()!=null && entity.getAsnKeywords().size()>0)
{
if (entity.getAsnKeywords() != null && entity.getAsnKeywords().size() > 0) {
AsnKeywordCfg cfg = new AsnKeywordCfg();
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
cfg.setTableName(AsnKeywordCfg.getTablename());
@@ -325,19 +330,19 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
ipCfgDao.updateCfgValid(cfg);
}
// TODO 处理定时任务【如果有定时任务则删除旧的,新增新的】
handelScheduleCfg(entity, entity.getIndexTable());
handelScheduleCfg(entity, entity.getIndexTable(), entity);
}
}
/**
*
* updateIpCfg(更新IP类配置)
* (继承BaseIpCfg这个类方可使用)
* updateIpCfg(更新IP类配置) (继承BaseIpCfg这个类方可使用)
*
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
* @return int
* @exception @since
* 1.0.0
*/
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void updateIpCfg(BaseIpCfg cfg) {
@@ -362,6 +367,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
ipCfgDao.update(cfg);
}
@Deprecated
public void audit(BaseIpCfg cfg) throws Exception {
// 更新IP配置与区域IP的状态
@@ -451,8 +457,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
if (Constants.SERVICE_IP_MULITIPLEX == cfg.getServiceId().intValue()) {
String region=Constants.USERREGION_IR_STRATEGY+"="+cfg.getDnsStrategyId()+Constants.USER_REGION_SPLIT
+Constants.USERREGION_IR_TYPE+"="+cfg.getIrType();
String region = Constants.USERREGION_IR_STRATEGY + "=" + cfg.getDnsStrategyId()
+ Constants.USER_REGION_SPLIT + Constants.USERREGION_IR_TYPE + "=" + cfg.getIrType();
maatCfg.setUserRegion(region);
} else if (Constants.SERVICE_IP_RATELIMIT == cfg.getServiceId().intValue()) {
maatCfg.setUserRegion(Constants.USERREGION_RATE_LIMIT + "=" + cfg.getRatelimit());
@@ -461,22 +467,24 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
if (cfg.getAction().equals(Constants.RATELIMIT_ACTION)) {
if (cfg.getUserRegion1().equals("0")) {// 丢包率
cfg.setUserRegion2(StringUtil.isEmpty(cfg.getUserRegion2()) ? "" : cfg.getUserRegion2());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+cfg.getUserRegion2());
maatCfg.setUserRegion(
Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY + "=" + cfg.getUserRegion2());
} else if (cfg.getUserRegion1().equals("1")) {// 带宽
cfg.setUserRegion3(StringUtil.isEmpty(cfg.getUserRegion3()) ? "" : cfg.getUserRegion3());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+cfg.getUserRegion3());
maatCfg.setUserRegion(
Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY + "=" + cfg.getUserRegion3());
}
} else {
if (!StringUtil.isEmpty(cfg.getUserRegion1())) {
String userRegion = "";
if (cfg.getUserRegion1().startsWith(Constants.REDIRECT_RESPONSE_CODE_STARTWITH)) {
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+
Constants.USER_REGION_SPLIT+
Constants.REDIRECT_URL_KEY+"="+cfg.getUserRegion2();
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY + "=" + cfg.getUserRegion1()
+ Constants.USER_REGION_SPLIT + Constants.REDIRECT_URL_KEY + "="
+ cfg.getUserRegion2();
} else {
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+
Constants.USER_REGION_SPLIT+
Constants.REDIRECT_CONTENT_KEY+"="+cfg.getUserRegion2();
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY + "=" + cfg.getUserRegion1()
+ Constants.USER_REGION_SPLIT + Constants.REDIRECT_CONTENT_KEY + "="
+ cfg.getUserRegion2();
}
maatCfg.setUserRegion(userRegion);
}
@@ -501,7 +509,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
throw e;
}
} else {
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
throw new MaatConvertException(
"<spring:message code=\"request_service_failed\"/>:" + props.getProperty("unknown_cfg_type"));
}
} else if (cfg.getIsAudit() == Constants.AUDIT_NOT_YES) {
if (maatType == Constants.CALLBACK_TYPE) {
@@ -543,10 +552,12 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
throw e;
}
} else {
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
throw new MaatConvertException(
"<spring:message code=\"request_service_failed\"/>:" + props.getProperty("unknown_cfg_type"));
}
}
}
public void auditIpCfg(CfgIndexInfo entity, Integer isAudit, Integer opAction) throws MaatConvertException {
Properties props = this.getMsgProp();
// 修改数据库审核状态信息
@@ -580,14 +591,20 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
for (IpPortCfg cfg : entity.getIpPortList()) {
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId","cfgType","userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId", "cfgType", "userRegion1", "userRegion2",
"userRegion3", "userRegion4", "userRegion5" });
cfg.setTableName(IpPortCfg.getTablename());
ipCfgDao.auditCfg(cfg);
/*BeanUtils.copyProperties(entity, cfg, new String[]{"userRegion1","userRegion2","userRegion3","userRegion4","userRegion5","ipType","direction",
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
cfg.setTableName(IpPortCfg.getTablename());
ipCfgDao.auditCfg(cfg);*/
/*
* BeanUtils.copyProperties(entity, cfg, new
* String[]{"userRegion1","userRegion2","userRegion3",
* "userRegion4","userRegion5","ipType","direction",
* "protocol","protocolId","areaEffectiveIds","cfgRegionCode",
* "cfgType","ipPattern","srcIpAddress","portPattern","srcPort",
* "destIpAddress","destPort"});
* cfg.setTableName(IpPortCfg.getTablename());
* ipCfgDao.auditCfg(cfg);
*/
}
if (isAudit == 1 && maatType == Constants.MAAT_TYPE) {
Map<String, List> map = cfgConvert(ipRegionList, entity.getIpPortList(), 1, entity, groupRelationList);
@@ -604,7 +621,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
cfg.setTableName(NtcSubscribeIdCfg.getTablename());
ipCfgDao.auditCfg(cfg);
if (isAudit == 1 && maatType == Constants.MAAT_TYPE) {
Map<String,List> map = cfgConvert(strRegionList,entity.getNtcSubscribeIdCfgList(),2,entity,groupRelationList);
Map<String, List> map = cfgConvert(strRegionList, entity.getNtcSubscribeIdCfgList(), 2, entity,
groupRelationList);
groupRelationList = map.get("groupList");
strRegionList = map.get("dstList");
}
@@ -624,7 +642,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
cfg.setTableName(AsnKeywordCfg.getTablename());
ipCfgDao.auditCfg(cfg);
if (isAudit == 1 && maatType == Constants.MAAT_TYPE) {
Map<String,List> map = cfgConvert(strRegionList,entity.getAsnKeywords(),2,entity,groupRelationList);
Map<String, List> map = cfgConvert(strRegionList, entity.getAsnKeywords(), 2, entity,
groupRelationList);
groupRelationList = map.get("groupList");
strRegionList = map.get("dstList");
}
@@ -645,7 +664,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
if (isAudit != 1) {
// 处理定时任务【如果有定时任务则删除旧的,新增新的】
handelScheduleCfg(entity, entity.getIndexTable());
handelScheduleCfg(entity, entity.getIndexTable(), entity);
}
// 构造提交综合服务参数格式,一条配置提交一次综合服务
@@ -697,11 +716,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
// 限速需要发Droprate=0.001 暂不支持Bandwidth=200kbps
if (entity.getAction().equals(Constants.RATELIMIT_ACTION)) {
if (entity.getUserRegion1().equals("0")) {// 丢包率
entity.setUserRegion2(StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+entity.getUserRegion2());
entity.setUserRegion2(
StringUtil.isEmpty(entity.getUserRegion2()) ? "" : entity.getUserRegion2());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY + "="
+ entity.getUserRegion2());
} else if (entity.getUserRegion1().equals("1")) {// 带宽
entity.setUserRegion3(StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+entity.getUserRegion3());
entity.setUserRegion3(
StringUtil.isEmpty(entity.getUserRegion3()) ? "" : entity.getUserRegion3());
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY + "="
+ entity.getUserRegion3());
}
}
// 调用服务接口下发配置数据
@@ -711,7 +734,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("ip配置下发响应信息" + result.getMsg());
} else {
throw new RuntimeException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
throw new RuntimeException(
"<spring:message code=\"request_service_failed\"/>:" + props.getProperty("unknown_cfg_type"));
}
} else if (isAudit == 3 && entity.getIsValid() == 1) {
if (maatType == Constants.CALLBACK_TYPE) {
@@ -755,15 +779,18 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
ToMaatResult result = ConfigServiceUtil.put(json, 1);
logger.info("ip配置取消配置响应信息" + result.getMsg());
} else {
throw new RuntimeException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
throw new RuntimeException(
"<spring:message code=\"request_service_failed\"/>:" + props.getProperty("unknown_cfg_type"));
}
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids cfgId
* @param ids
* cfgId
* @param functionId
*/
@@ -778,7 +805,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
// List<MaatCfg> configCompileList = new ArrayList<>();
//
// if(isAudit==Constants.AUDIT_YES) {
// List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
// List<AsnKeywordCfg>
// asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
// if(asnKeywordCfgs!=null&&asnKeywordCfgs.size()>0) {
// MaatCfg maatCfg = new MaatCfg();
// List<GroupCfg> groupRelationList = new ArrayList<>();
@@ -810,7 +838,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
// maatCfg.setIpRegionList(ipRegionList);
// List<Integer> regions=ConfigServiceUtil.getId(3, asnKeywordCfgs.size());
// int index=0;
// List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
// List<FunctionRegionDict>
// functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
// String cfgType=null;
// for(FunctionRegionDict dict:functionRegionDicts) {
// if("asn".equals(dict.getConfigServiceType())) {
@@ -895,15 +924,15 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
this.deleteBatch(ipCfgs, IpCfgDao.class);
}
/**
*
* deleteIpCfg(删除IP类配置)
* (继承BaseIpCfg这个类方可使用)
* deleteIpCfg(删除IP类配置) (继承BaseIpCfg这个类方可使用)
*
* @param baseIpCfg
* @return
*int
* @exception
* @since 1.0.0
* @return int
* @exception @since
* 1.0.0
*/
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
public void deleteIpCfg(List<BaseIpCfg> baseIpCfg, List<AreaIpCfg> areaCfg) {
@@ -917,20 +946,21 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
}
/**
*
* getIpCfg(根据IP与类名获取IP配置)
* (继承BaseIpCfg这个类方可使用)
* getIpCfg(根据IP与类名获取IP配置) (继承BaseIpCfg这个类方可使用)
*
* @param clazz
* @param id
* @return
*BaseIpCfg
* @exception
* @since 1.0.0
* @return BaseIpCfg
* @exception @since
* 1.0.0
*/
public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg) {
return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId());
}
public CfgIndexInfo getIpPortCfg(Long cfgId, Integer compileId) {
CfgIndexInfo entity = ipCfgDao.getCfgIndexInfo(cfgId, compileId);
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
@@ -943,6 +973,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
return entity;
}
public CfgIndexInfo exportIpInfo(CfgIndexInfo entity) {
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
entity.setIpPortList(ipPortList);
@@ -952,30 +983,39 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
return entity;
}
public BaseIpCfg getIpCfgById(String tableName, long id) {
return ipCfgDao.getById(tableName, id);
}
public Integer getIsValid(BaseIpCfg baseIpCfg) {
return ipCfgDao.getIsValid(baseIpCfg);
}
public Integer getIsValid(String tableName, long id) {
return ipCfgDao.getIsValid(tableName, id);
}
public Integer getIsAudit(BaseIpCfg baseIpCfg) {
return ipCfgDao.getIsAudit(baseIpCfg);
}
public Integer getIsAudit(String tableName, long id) {
return ipCfgDao.getIsAudit(tableName, id);
}
public List<AreaIpCfg> getAreaCfgByCompileId(/* int functionId, */int compileId) {
return areaIpCfgDao.getByCompileId(compileId);
}
public List<BaseIpCfg> getListByComileId(String tableName, int functionId, String ids) {
return ipCfgDao.getListByComileId(tableName, functionId, ids);
}
public List<BaseIpCfg> getListByCfgId(String tableName, int functionId, String ids) {
return ipCfgDao.getListByCfgId(tableName, functionId, ids);
}
public Integer getCompileId() {
// 调用服务接口获取compileId
Integer compileId = 0;
@@ -991,23 +1031,25 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
return compileId;
}
/**
* getListByCfgIdWithName(这里用一句话描述这个方法的作用)
* (这里描述这个方法适用条件 可选)
* getListByCfgIdWithName(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 可选)
*
* @param tablename
* @param functionId
* @param ids
* @return
*List<BaseIpCfg>
* @exception
* @since 1.0.0
* @return List<BaseIpCfg>
* @exception @since
* 1.0.0
*/
public List<BaseIpCfg> getListByCfgIdWithName(String tablename, Integer functionId, String ids) {
// TODO Auto-generated method stub
return ipCfgDao.getListByCfgIdWithName(tablename, functionId, ids);
}
/**
* 获取国际化配置文件
*
* @return
*/
public Properties getMsgProp() {
@@ -1028,6 +1070,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
}
return msgProp;
}
public Page<CfgIndexInfo> getIpCfgList(Page<CfgIndexInfo> page, CfgIndexInfo entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "a"));
entity.setPage(page);

View File

@@ -0,0 +1,104 @@
#function_region_dict 对应ip_patternport_pattern的字段长度拓展一倍使用分号分隔源/目的
ALTER TABLE function_region_dict MODIFY config_ip_pattern VARCHAR(20) COMMENT "ip的格式 1:ip掩码;2:IP范围;3:IP;使用逗号分隔,源ip与目的IP使用;分隔";
ALTER TABLE function_region_dict MODIFY config_port_pattern VARCHAR(20) COMMENT "端口的格式1:port;2:port_mask;使用逗号分隔,源端口与目的端口使用;分隔";
#各表修改ip_patternport_pattern
#app_ip_cfg
ALTER TABLE app_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE app_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE app_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE app_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#app_ip_range_cfg
ALTER TABLE app_ip_range_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE app_ip_range_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE app_ip_range_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE app_ip_range_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#area_ip_cfg
ALTER TABLE area_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE area_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE area_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE area_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#asn_ip_cfg
ALTER TABLE asn_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE asn_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE asn_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE asn_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#av_cont_ip_cfg
ALTER TABLE av_cont_ip_cfg change ip_pattern src_ip_pattern int COMMENT '源ip格式';
ALTER TABLE av_cont_ip_cfg add dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE av_cont_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE av_cont_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#av_pic_ip_cfg
ALTER TABLE av_pic_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE av_pic_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE av_pic_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE av_pic_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#av_voip_ip_cfg
ALTER TABLE av_voip_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE av_voip_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE av_voip_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE av_voip_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#ddos_ip_cfg
ALTER TABLE ddos_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE ddos_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE ddos_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE ddos_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#dns_ip_cfg
ALTER TABLE dns_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE dns_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE dns_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE dns_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#ip_port_cfg
ALTER TABLE ip_port_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE ip_port_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE ip_port_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE ip_port_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#ip_reuse_ip_cfg
ALTER TABLE ip_reuse_ip_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE ip_reuse_ip_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
ALTER TABLE ip_reuse_ip_cfg CHANGE port_pattern src_port_pattern INT COMMENT '源端口格式';
ALTER TABLE ip_reuse_ip_cfg ADD dest_port_pattern INT COMMENT '目的端口格式';
#ip_reuse_policy_cfg
ALTER TABLE ip_reuse_policy_cfg CHANGE ip_pattern src_ip_pattern INT COMMENT '源ip格式';
ALTER TABLE ip_reuse_policy_cfg ADD dest_ip_pattern INT COMMENT '目的ip格式';
#修改字典的值
UPDATE function_region_dict SET config_ip_pattern ="1,2,3;1,2,3" WHERE config_ip_pattern="1,2,3";
UPDATE function_region_dict SET config_ip_pattern ="1;1" WHERE config_ip_pattern="1";
UPDATE function_region_dict SET config_ip_pattern ="3;3" WHERE config_ip_pattern="3";
UPDATE function_region_dict SET config_ip_pattern ="1,3;1,3" WHERE config_ip_pattern="1,3";
UPDATE function_region_dict SET config_port_pattern ="1;1" WHERE config_port_pattern="1";
UPDATE function_region_dict SET config_port_pattern ="1,2;1,2" WHERE config_port_pattern="1,2";
#Spoofing IP修改只显示目的IP
UPDATE function_region_dict SET config_ip_port_show=3 WHERE function_id=401;
#ASN IP修改只显示目的IP
UPDATE function_region_dict SET config_ip_port_show=3 WHERE function_id=600;
#sql 更新字段语句
UPDATE app_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE app_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE app_ip_range_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE app_ip_range_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE area_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE area_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE asn_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE asn_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_cont_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_cont_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_pic_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_pic_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_voip_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE av_voip_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE ddos_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE ddos_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE dns_ip_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE dns_ip_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE ip_port_cfg c SET c.dest_ip_pattern =(SELECT b.src_ip_pattern FROM ( SELECT a.src_ip_pattern,a.`cfg_id` FROM ip_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)
UPDATE ip_port_cfg c SET c.dest_port_pattern =(SELECT b.src_port_pattern FROM ( SELECT a.src_port_pattern,a.`cfg_id` FROM port_port_cfg a) b WHERE b.cfg_id=c.`cfg_id`)