增加APP策略,APP多域特征的批量下发数据处理逻辑
This commit is contained in:
@@ -11,6 +11,7 @@ import com.nis.domain.basics.AsnIpCfg;
|
|||||||
import com.nis.domain.configuration.AppByteCfg;
|
import com.nis.domain.configuration.AppByteCfg;
|
||||||
import com.nis.domain.configuration.AppComplexKeywordCfg;
|
import com.nis.domain.configuration.AppComplexKeywordCfg;
|
||||||
import com.nis.domain.configuration.AppDomainCfg;
|
import com.nis.domain.configuration.AppDomainCfg;
|
||||||
|
import com.nis.domain.configuration.AppFeatureIndex;
|
||||||
import com.nis.domain.configuration.AppHeaderCfg;
|
import com.nis.domain.configuration.AppHeaderCfg;
|
||||||
import com.nis.domain.configuration.AppHttpCfg;
|
import com.nis.domain.configuration.AppHttpCfg;
|
||||||
import com.nis.domain.configuration.AppIdCfg;
|
import com.nis.domain.configuration.AppIdCfg;
|
||||||
@@ -73,7 +74,6 @@ public interface ConfigSynchronizationDao {
|
|||||||
public List<BaseStringCfg> getStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
public List<BaseStringCfg> getStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||||
public List<ComplexkeywordCfg> getComplexStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
public List<ComplexkeywordCfg> getComplexStrList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||||
public List<FileDigestCfg> getFileDigestList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
public List<FileDigestCfg> getFileDigestList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||||
|
|
||||||
public List<DdosIpCfg> getDdosIpCfgList(BaseCfg entity);
|
public List<DdosIpCfg> getDdosIpCfgList(BaseCfg entity);
|
||||||
|
|
||||||
public List<AvFileSampleCfg> getAvFileCfgList(BaseCfg entity);
|
public List<AvFileSampleCfg> getAvFileCfgList(BaseCfg entity);
|
||||||
@@ -83,4 +83,10 @@ public interface ConfigSynchronizationDao {
|
|||||||
public List<DnsResStrategy> getDnsStrategyList(BaseCfg entity);
|
public List<DnsResStrategy> getDnsStrategyList(BaseCfg entity);
|
||||||
public List<DnsIpCfg> getDnsIpCfgList(BaseCfg entity);
|
public List<DnsIpCfg> getDnsIpCfgList(BaseCfg entity);
|
||||||
public List<IpPortCfg> getIpPortListByService(BaseCfg entity);
|
public List<IpPortCfg> getIpPortListByService(BaseCfg entity);
|
||||||
|
|
||||||
|
public List<AppPolicyCfg> getAppPolicyList(BaseCfg entity);
|
||||||
|
public List<AppFeatureIndex> getAppFeatureIndexList(BaseCfg entity);
|
||||||
|
public List<BaseStringCfg> getStrListByService(BaseCfg entity);
|
||||||
|
public List<ComplexkeywordCfg> getComplexStrListByService(BaseCfg entity);
|
||||||
|
public List<IpPortCfg> getAppIpPortList(@Param("tableName")String tableName,@Param("compileIds")List compileIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappea.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappea.dtd" >
|
||||||
<mapper namespace="com.nis.web.dao.configuration.ConfigSynchronizationDao" >
|
<mapper namespace="com.nis.web.dao.configuration.ConfigSynchronizationDao" >
|
||||||
|
|
||||||
<!-- <resultMap id="AppPolicyCfgMap" type="com.nis.domain.configuration.AppPolicyCfg" >
|
<resultMap id="AppPolicyCfgMap" type="com.nis.domain.configuration.AppPolicyCfg" >
|
||||||
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||||
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||||
<result column="app_code" property="appCode" jdbcType="INTEGER" />
|
<result column="app_code" property="appCode" jdbcType="INTEGER" />
|
||||||
@@ -37,6 +37,41 @@
|
|||||||
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
|
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
|
||||||
<result column="do_log" property="doLog" jdbcType="INTEGER" />
|
<result column="do_log" property="doLog" jdbcType="INTEGER" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<resultMap id="AppFeatureIndexMap" type="com.nis.domain.configuration.AppFeatureIndex" >
|
||||||
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||||
|
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
|
||||||
|
<result column="action" property="action" jdbcType="INTEGER" />
|
||||||
|
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||||
|
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
|
||||||
|
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
|
||||||
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||||
|
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
|
||||||
|
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
||||||
|
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
|
||||||
|
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
|
||||||
|
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
|
||||||
|
<result column="request_id" property="requestId" jdbcType="INTEGER" />
|
||||||
|
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
|
||||||
|
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
|
||||||
|
<result column="classify" property="classify" jdbcType="VARCHAR" />
|
||||||
|
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
|
||||||
|
<result column="lable" property="lable" jdbcType="VARCHAR" />
|
||||||
|
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
|
||||||
|
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
||||||
|
<result column="do_log" property="doLog" jdbcType="INTEGER" />
|
||||||
|
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
|
||||||
|
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
|
||||||
|
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
|
||||||
|
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
|
||||||
|
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
|
||||||
|
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||||
|
<result column="app_code" property="appCode" jdbcType="INTEGER" />
|
||||||
|
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
|
||||||
|
<result column="cfg_region_type" property="cfgRegionType" jdbcType="VARCHAR" />
|
||||||
|
<result column="cfg_region_value" property="cfgRegionValue" jdbcType="VARCHAR" />
|
||||||
|
<result column="cfg_region_code" property="cfgRegionCode1" jdbcType="VARCHAR" />
|
||||||
|
</resultMap>
|
||||||
|
<!--
|
||||||
|
|
||||||
<resultMap id="AppIpCfgMap" type="com.nis.domain.configuration.AppIpCfg" >
|
<resultMap id="AppIpCfgMap" type="com.nis.domain.configuration.AppIpCfg" >
|
||||||
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||||
@@ -402,6 +437,9 @@
|
|||||||
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
||||||
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
|
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
|
||||||
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
|
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
|
||||||
|
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||||
|
<result column="app_code" property="appCode" jdbcType="INTEGER" />
|
||||||
|
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="complexCfgMap" type="com.nis.domain.configuration.ComplexkeywordCfg" >
|
<resultMap id="complexCfgMap" type="com.nis.domain.configuration.ComplexkeywordCfg" >
|
||||||
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||||
@@ -432,6 +470,9 @@
|
|||||||
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
||||||
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
|
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
|
||||||
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
|
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
|
||||||
|
<result column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
|
||||||
|
<result column="app_code" property="appCode" jdbcType="INTEGER" />
|
||||||
|
<result column="behav_code" property="behavCode" jdbcType="INTEGER" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="digestCfgMap" type="com.nis.domain.configuration.FileDigestCfg" >
|
<resultMap id="digestCfgMap" type="com.nis.domain.configuration.FileDigestCfg" >
|
||||||
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
||||||
@@ -712,11 +753,11 @@
|
|||||||
a.user_region1
|
a.user_region1
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="StrCfg_Column" >
|
<sql id="StrCfg_Column" >
|
||||||
a.cfg_desc,a.cfg_keywords,a.cfg_type,
|
a.cfg_keywords,a.cfg_type,
|
||||||
a.expr_type,a.match_method,a.is_hexbin,a.compile_id
|
a.expr_type,a.match_method,a.is_hexbin,a.compile_id
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="ComplexCfg_Column" >
|
<sql id="ComplexCfg_Column" >
|
||||||
a.cfg_desc,a.cfg_keywords,a.district,a.cfg_type,
|
a.cfg_keywords,a.district,a.cfg_type,
|
||||||
a.expr_type,a.match_method,a.is_hexbin,a.compile_id
|
a.expr_type,a.match_method,a.is_hexbin,a.compile_id
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="DigestCfg_Column" >
|
<sql id="DigestCfg_Column" >
|
||||||
@@ -795,10 +836,7 @@
|
|||||||
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
|
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
|
||||||
,a.area_effective_ids,a.function_id,a.cfg_region_code,a.dns_strategy_id
|
,a.area_effective_ids,a.function_id,a.cfg_region_code,a.dns_strategy_id
|
||||||
</sql>
|
</sql>
|
||||||
<!-- <sql id="WebsiteDomainTopic_Column">
|
<sql id="AppPolicyCfg_Column" >
|
||||||
id,website_service_id websiteServiceId,domain,topic_id topicId,create_time createTime,creator_id creatorId,is_valid isValid
|
|
||||||
</sql>
|
|
||||||
<sql id="AppPolicyCfg_Column" >
|
|
||||||
a.CFG_ID, a.APP_CODE,a.BEHAV_CODE,a.SPEC_SERVICE_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
a.CFG_ID, a.APP_CODE,a.BEHAV_CODE,a.SPEC_SERVICE_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
||||||
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
|
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
|
||||||
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
|
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
|
||||||
@@ -806,6 +844,22 @@
|
|||||||
a.CFG_TYPE,a.CFG_REGION_CODE,a.EXPR_TYPE,a.MATCH_METHOD,a.IS_HEXBIN,a.USER_REGION1,a.USER_REGION2,
|
a.CFG_TYPE,a.CFG_REGION_CODE,a.EXPR_TYPE,a.MATCH_METHOD,a.IS_HEXBIN,a.USER_REGION1,a.USER_REGION2,
|
||||||
a.USER_REGION3,a.USER_REGION4,a.USER_REGION5,a.DO_LOG
|
a.USER_REGION3,a.USER_REGION4,a.USER_REGION5,a.DO_LOG
|
||||||
</sql>
|
</sql>
|
||||||
|
<sql id="AppFeatureIndex_Column" >
|
||||||
|
a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
||||||
|
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
|
||||||
|
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
|
||||||
|
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.CFG_REGION_TYPE,a.CFG_REGION_VALUE,a.user_region1,
|
||||||
|
a.user_region2,a.user_region3,a.user_region4,a.user_region5,a.do_log,a.feature_table,
|
||||||
|
a.feature_table_type,a.app_code,a.spec_service_id,a.cfg_region_code
|
||||||
|
</sql>
|
||||||
|
<sql id="AppIpCfg_Column" >
|
||||||
|
a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
|
||||||
|
,a.protocol,a.direction,a.dest_port,a.dest_ip_address,a.cfg_type,a.compile_id
|
||||||
|
</sql>
|
||||||
|
<!-- <sql id="WebsiteDomainTopic_Column">
|
||||||
|
id,website_service_id websiteServiceId,domain,topic_id topicId,create_time createTime,creator_id creatorId,is_valid isValid
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<sql id="AppIpCfg_Column" >
|
<sql id="AppIpCfg_Column" >
|
||||||
a.CFG_ID, a.APP_CODE,a.BEHAV_CODE,a.SPEC_SERVICE_ID, a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
a.CFG_ID, a.APP_CODE,a.BEHAV_CODE,a.SPEC_SERVICE_ID, a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
|
||||||
@@ -837,7 +891,52 @@
|
|||||||
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.RATELIMIT,a.FUNCTION_ID,a.CFG_TYPE,a.CFG_REGION_CODE,
|
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.RATELIMIT,a.FUNCTION_ID,a.CFG_TYPE,a.CFG_REGION_CODE,
|
||||||
a.BYTES,a.EXPR_TYPE,a.MATCH_METHOD,a.IS_HEXBIN,a.DO_LOG
|
a.BYTES,a.EXPR_TYPE,a.MATCH_METHOD,a.IS_HEXBIN,a.DO_LOG
|
||||||
</sql> -->
|
</sql> -->
|
||||||
|
<select id="getAppPolicyList" resultMap="AppPolicyCfgMap" parameterType="com.nis.domain.configuration.AppPolicyCfg" >
|
||||||
|
select
|
||||||
|
<include refid="AppPolicyCfg_Column"/>
|
||||||
|
<trim prefix="," prefixOverrides=",">
|
||||||
|
, s.name as creator_name,u.name as auditor_name
|
||||||
|
</trim>
|
||||||
|
from app_policy_cfg a
|
||||||
|
left join sys_user s on a.creator_id=s.id
|
||||||
|
left join sys_user u on a.auditor_id=u.id
|
||||||
|
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||||
|
<if test="serviceId != null">
|
||||||
|
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="action != null">
|
||||||
|
AND a.action=#{action,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
and a.is_valid=#{isValid} and a.is_audit=#{isAudit} and a.is_valid!=-1
|
||||||
|
</trim>
|
||||||
|
ORDER BY a.CFG_ID
|
||||||
|
</select>
|
||||||
|
<select id="getAppFeatureIndexList" resultMap="AppFeatureIndexMap">
|
||||||
|
select
|
||||||
|
<include refid="AppFeatureIndex_Column"/>
|
||||||
|
<trim prefix="," prefixOverrides=",">
|
||||||
|
, s.name as creator_name,u.name as auditor_name
|
||||||
|
</trim>
|
||||||
|
from app_feature_index a
|
||||||
|
left join sys_user s on a.creator_id=s.id
|
||||||
|
left join sys_user u on a.auditor_id=u.id
|
||||||
|
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||||
|
<if test="serviceId != null">
|
||||||
|
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="action != null">
|
||||||
|
AND a.action=#{action,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
and a.is_valid=#{isValid} and a.is_audit=#{isAudit} and a.is_valid!=-1
|
||||||
|
</trim>
|
||||||
|
ORDER BY a.CFG_ID
|
||||||
|
</select>
|
||||||
<select id="getCfgIndexList" resultMap="CfgIndexInfoMap" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
|
<select id="getCfgIndexList" resultMap="CfgIndexInfoMap" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
|
||||||
SELECT
|
SELECT
|
||||||
<include refid="BaseCfg_Column" />
|
<include refid="BaseCfg_Column" />
|
||||||
@@ -871,22 +970,24 @@
|
|||||||
</select>
|
</select>
|
||||||
<select id="getIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
|
<select id="getIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
|
||||||
SELECT
|
SELECT
|
||||||
<include refid="IpCfg_Column" />
|
<include refid="IpCfg_Column" />
|
||||||
|
FROM ${tableName} a
|
||||||
|
<where>
|
||||||
|
and a.compile_id in
|
||||||
|
<foreach collection="compileIds" index="index" item="compileId" open="(" separator="," close=")">
|
||||||
|
#{compileId}
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<select id="getAppIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
|
||||||
|
SELECT
|
||||||
|
<include refid="AppIpCfg_Column" />
|
||||||
FROM ${tableName} a
|
FROM ${tableName} a
|
||||||
<where>
|
<where>
|
||||||
and a.compile_id in
|
and a.compile_id in
|
||||||
<foreach collection="compileIds" index="index" item="compileId" open="(" separator="," close=")">
|
<foreach collection="compileIds" index="index" item="compileId" open="(" separator="," close=")">
|
||||||
#{compileId}
|
#{compileId}
|
||||||
</foreach>
|
</foreach>
|
||||||
<!-- <if test="compileId != null">
|
|
||||||
AND a.compile_id =#{compileId}
|
|
||||||
</if>
|
|
||||||
<if test="functionId != null">
|
|
||||||
AND a.function_id =#{functionId}
|
|
||||||
</if>
|
|
||||||
<if test="serviceId!= null">
|
|
||||||
AND a.service_id =#{serviceId}
|
|
||||||
</if> -->
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="getAsnIpList" resultType="com.nis.domain.basics.AsnIpCfg">
|
<select id="getAsnIpList" resultType="com.nis.domain.basics.AsnIpCfg">
|
||||||
@@ -1117,11 +1218,15 @@
|
|||||||
|
|
||||||
<select id="getIpPortListByService" resultMap="ipPortMap" >
|
<select id="getIpPortListByService" resultMap="ipPortMap" >
|
||||||
select
|
select
|
||||||
|
<include refid="BaseCfg_Column"></include>,
|
||||||
<include refid="IpCfg_Column"></include>
|
<include refid="IpCfg_Column"></include>
|
||||||
<trim prefix="," prefixOverrides=",">
|
<trim prefix="," prefixOverrides=",">
|
||||||
,s.name as creator_name,u.name as auditor_name
|
,s.name as creator_name,u.name as auditor_name
|
||||||
|
<if test="serviceId=1028">
|
||||||
|
,a.app_code,a.spec_service_id,a.behav_code
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
from ip_port_cfg a
|
from ${tableName} a
|
||||||
left join sys_user s on a.creator_id=s.id
|
left join sys_user s on a.creator_id=s.id
|
||||||
left join sys_user u on a.auditor_id=u.id
|
left join sys_user u on a.auditor_id=u.id
|
||||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||||
@@ -1163,6 +1268,62 @@
|
|||||||
</trim>
|
</trim>
|
||||||
ORDER BY a.CFG_ID
|
ORDER BY a.CFG_ID
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getStrListByService" resultMap="stringCfgMap" >
|
||||||
|
select
|
||||||
|
<include refid="BaseCfg_Column"></include>,
|
||||||
|
<include refid="StrCfg_Column"></include>
|
||||||
|
<trim prefix="," prefixOverrides=",">
|
||||||
|
,s.name as creator_name,u.name as auditor_name
|
||||||
|
<if test="serviceId=1024 or serviceId=1026 or serviceId=1029">
|
||||||
|
,a.app_code,a.spec_service_id,a.behav_code
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
from ${tableName} a
|
||||||
|
left join sys_user s on a.creator_id=s.id
|
||||||
|
left join sys_user u on a.auditor_id=u.id
|
||||||
|
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||||
|
<if test="serviceId != null">
|
||||||
|
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="action != null">
|
||||||
|
AND a.action=#{action,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
and a.is_valid=#{isValid} and a.is_audit=#{isAudit}
|
||||||
|
and a.is_valid!=-1
|
||||||
|
</trim>
|
||||||
|
ORDER BY a.CFG_ID
|
||||||
|
</select>
|
||||||
|
<select id="getComplexStrListByService" resultMap="complexCfgMap" >
|
||||||
|
select
|
||||||
|
<include refid="BaseCfg_Column"></include>,
|
||||||
|
<include refid="ComplexCfg_Column"></include>
|
||||||
|
<trim prefix="," prefixOverrides=",">
|
||||||
|
,s.name as creator_name,u.name as auditor_name
|
||||||
|
<if test="serviceId=1024 or serviceId=1026 or serviceId=1029">
|
||||||
|
,a.app_code,a.spec_service_id,a.behav_code
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
from ${tableName} a
|
||||||
|
left join sys_user s on a.creator_id=s.id
|
||||||
|
left join sys_user u on a.auditor_id=u.id
|
||||||
|
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||||
|
<if test="serviceId != null">
|
||||||
|
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="functionId != null">
|
||||||
|
AND a.function_id=#{functionId,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
<if test="action != null">
|
||||||
|
AND a.action=#{action,jdbcType=INTEGER}
|
||||||
|
</if>
|
||||||
|
and a.is_valid=#{isValid} and a.is_audit=#{isAudit}
|
||||||
|
and a.is_valid!=-1
|
||||||
|
</trim>
|
||||||
|
ORDER BY a.CFG_ID
|
||||||
|
</select>
|
||||||
<!-- <select id="findAppPolicyList" resultMap="AppPolicyCfgMap" parameterType="com.nis.domain.configuration.AppPolicyCfg" >
|
<!-- <select id="findAppPolicyList" resultMap="AppPolicyCfgMap" parameterType="com.nis.domain.configuration.AppPolicyCfg" >
|
||||||
select
|
select
|
||||||
<include refid="AppPolicyCfg_Column"/>
|
<include refid="AppPolicyCfg_Column"/>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.nis.domain.FunctionServiceDict;
|
import com.nis.domain.FunctionServiceDict;
|
||||||
import com.nis.domain.Page;
|
import com.nis.domain.Page;
|
||||||
import com.nis.domain.basics.AsnIpCfg;
|
import com.nis.domain.basics.AsnIpCfg;
|
||||||
|
import com.nis.domain.configuration.AppFeatureIndex;
|
||||||
import com.nis.domain.configuration.AppPolicyCfg;
|
import com.nis.domain.configuration.AppPolicyCfg;
|
||||||
import com.nis.domain.configuration.AvFileSampleCfg;
|
import com.nis.domain.configuration.AvFileSampleCfg;
|
||||||
import com.nis.domain.configuration.BaseCfg;
|
import com.nis.domain.configuration.BaseCfg;
|
||||||
@@ -89,16 +90,30 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
entity.setServiceId(Integer.valueOf(serviceId));
|
entity.setServiceId(Integer.valueOf(serviceId));
|
||||||
entity.setIsAudit(1);
|
entity.setIsAudit(1);
|
||||||
entity.setIsValid(1);
|
entity.setIsValid(1);
|
||||||
|
entity.setTableName(tableName);
|
||||||
if("1".equals(serviceType)){//maat类配置
|
if("1".equals(serviceType)){//maat类配置
|
||||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) service.get("cfgList");
|
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) service.get("cfgList");
|
||||||
List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) service.get("userRegionList");
|
List<Map<String,Object>> userRegionList = (List<Map<String, Object>>) service.get("userRegionList");
|
||||||
if("cfg_index_info".equals(tableName)){
|
if(cfgList.size()>0){
|
||||||
|
Page page=new Page(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||||
|
handleNtcMaatData(cfgList,userRegionList,page,entity,request,response,false,tableName);
|
||||||
|
}else{
|
||||||
|
int cfgType = Integer.parseInt(service.get("cfgType").toString());
|
||||||
|
if("ddos_ip_cfg".equals(tableName)){
|
||||||
|
Page<DdosIpCfg> page=new Page<DdosIpCfg>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||||
|
handleDdosMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
||||||
|
}else{
|
||||||
|
Page<T> page=new Page<T>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||||
|
handleSingleMaatData(cfgType,userRegionList,page,entity,request,response,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*if("cfg_index_info".equals(tableName)){
|
||||||
Page<CfgIndexInfo> page=new Page<CfgIndexInfo>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
Page<CfgIndexInfo> page=new Page<CfgIndexInfo>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||||
handleNtcMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
handleNtcMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
||||||
}else if("ddos_ip_cfg".equals(tableName)){
|
}else if("ddos_ip_cfg".equals(tableName)){
|
||||||
Page<DdosIpCfg> page=new Page<DdosIpCfg>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
Page<DdosIpCfg> page=new Page<DdosIpCfg>(request,response,Constants.MAAT_JSON_SEND_SIZE,"a");
|
||||||
handleDdosMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
handleDdosMaatData(cfgList,userRegionList,page,entity,request,response,false);
|
||||||
}
|
}*/
|
||||||
}else if("2".equals(serviceType)){//回调类配置
|
}else if("2".equals(serviceType)){//回调类配置
|
||||||
entity.setTableName(tableName);
|
entity.setTableName(tableName);
|
||||||
entity.setServiceId(Integer.valueOf(serviceId));
|
entity.setServiceId(Integer.valueOf(serviceId));
|
||||||
@@ -127,21 +142,48 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
public void handleNtcMaatData(List<Map<String,Object>>cfgList,List<Map<String,Object>>userRegionList,
|
public void handleNtcMaatData(List<Map<String,Object>>cfgList,List<Map<String,Object>>userRegionList,
|
||||||
Page<CfgIndexInfo> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
Page<T> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||||
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
boolean isUpdateCfg,String tableName) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
|
||||||
boolean hasData = true;
|
boolean hasData = true;
|
||||||
while(hasData){
|
while(hasData){
|
||||||
entity.setPage(page);
|
entity.setPage(page);
|
||||||
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
|
List list = Lists.newArrayList();
|
||||||
if(!StringUtil.isEmpty(list)){
|
if("cfg_index_info".equals(tableName)){
|
||||||
hasData=auditNtcMaatData(cfgList,userRegionList,page,entity,list,hasData,isUpdateCfg);
|
list = configSynchronizationDao.getCfgIndexList(entity);
|
||||||
if(hasData) {
|
if(!StringUtil.isEmpty(list)){
|
||||||
page.setPageNo(page.getNext());
|
hasData=auditNtcMaatData(cfgList,userRegionList,page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
}else if("app_policy_cfg".equals(tableName)){
|
||||||
|
list = configSynchronizationDao.getAppPolicyList(entity);
|
||||||
|
if(!StringUtil.isEmpty(list)){
|
||||||
|
hasData=auditAppPolicyData(cfgList,userRegionList,page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
}else if("app_feature_index".equals(tableName)){
|
||||||
|
list = configSynchronizationDao.getAppFeatureIndexList(entity);
|
||||||
|
if(!StringUtil.isEmpty(list)){
|
||||||
|
hasData=auditAppFeatureData(cfgList,userRegionList,page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
logger.info("全量同步未知业务");
|
||||||
hasData = false;
|
hasData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -284,12 +326,12 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
for(int index=0;index<ipList.size();index++){
|
for(int index=0;index<ipList.size();index++){
|
||||||
IpPortCfg ip = ipList.get(index);
|
IpPortCfg ip = ipList.get(index);
|
||||||
if(ip.getCompileId().equals(cfg.getCompileId())){
|
if(ip.getCompileId().equals(cfg.getCompileId())){
|
||||||
BeanUtils.copyProperties(cfg, ip);
|
// BeanUtils.copyProperties(cfg, ip);
|
||||||
ip.setRegionId(regionIds.get(index));
|
ip.setRegionId(regionIds.get(0));
|
||||||
regionIds.remove(index);
|
regionIds.remove(0);
|
||||||
ip.setGroupId(ipGroupId.get(0));
|
ip.setGroupId(ipGroupId.get(0));
|
||||||
ip.setIsValid(entity.getIsValid());
|
ip.setIsValid(entity.getIsValid());
|
||||||
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? entity.getAuditTime():ip.getAuditTime());
|
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? cfg.getAuditTime():ip.getAuditTime());
|
||||||
list1.add(ip);
|
list1.add(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,20 +340,20 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
for(AsnIpCfg ip:asnIpList){//asn不需要再次获取regionId,groupId
|
for(AsnIpCfg ip:asnIpList){//asn不需要再次获取regionId,groupId
|
||||||
if(ip.getAsnIpGroup().toString().equals(cfg.getUserRegion4())){//根据组号对应
|
if(ip.getAsnIpGroup().toString().equals(cfg.getUserRegion4())){//根据组号对应
|
||||||
ip.setIsValid(entity.getIsValid());
|
ip.setIsValid(entity.getIsValid());
|
||||||
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? entity.getAuditTime():ip.getAuditTime());
|
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? cfg.getAuditTime():ip.getAuditTime());
|
||||||
list1.add(ip);
|
list1.add(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int index=0;index<strList.size();index++){
|
for(int index=0;index<strList.size();index++){
|
||||||
BaseStringCfg str = strList.get(index);
|
BaseStringCfg str = strList.get(index);
|
||||||
if(str.getCompileId().equals(cfg.getCompileId())){
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
BeanUtils.copyProperties(cfg, str);
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
str.setRegionId(regionIds.get(index));
|
str.setRegionId(regionIds.get(0));
|
||||||
regionIds.remove(index);
|
regionIds.remove(0);
|
||||||
str.setGroupId(groupIds.get(index));
|
str.setGroupId(groupIds.get(0));
|
||||||
groupIds.remove(index);
|
groupIds.remove(0);
|
||||||
str.setIsValid(entity.getIsValid());
|
str.setIsValid(entity.getIsValid());
|
||||||
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? entity.getAuditTime():str.getAuditTime());
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
list2.add(str);
|
list2.add(str);
|
||||||
if(entity.getServiceId().equals(513)||entity.getServiceId().equals(515)){
|
if(entity.getServiceId().equals(513)||entity.getServiceId().equals(515)){
|
||||||
if(userRegion.equals("")){
|
if(userRegion.equals("")){
|
||||||
@@ -325,13 +367,13 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
for(int index=0;index<complexStrList.size();index++){
|
for(int index=0;index<complexStrList.size();index++){
|
||||||
ComplexkeywordCfg str = complexStrList.get(index);
|
ComplexkeywordCfg str = complexStrList.get(index);
|
||||||
if(str.getCompileId().equals(cfg.getCompileId())){
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
BeanUtils.copyProperties(cfg, str);
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
str.setRegionId(regionIds.get(index));
|
str.setRegionId(regionIds.get(0));
|
||||||
regionIds.remove(index);
|
regionIds.remove(0);
|
||||||
str.setGroupId(groupIds.get(index));
|
str.setGroupId(groupIds.get(0));
|
||||||
groupIds.remove(index);
|
groupIds.remove(0);
|
||||||
str.setIsValid(entity.getIsValid());
|
str.setIsValid(entity.getIsValid());
|
||||||
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? entity.getAuditTime():str.getAuditTime());
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
list3.add(str);
|
list3.add(str);
|
||||||
if(entity.getServiceId().equals(129) && str.getDistrict()!=null){//http监测
|
if(entity.getServiceId().equals(129) && str.getDistrict()!=null){//http监测
|
||||||
String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, str.getDistrict());
|
String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, str.getDistrict());
|
||||||
@@ -348,26 +390,26 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
for(int index=0;index<numList.size();index++){
|
for(int index=0;index<numList.size();index++){
|
||||||
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
|
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
|
||||||
if(num.getCompileId().equals(cfg.getCompileId())){
|
if(num.getCompileId().equals(cfg.getCompileId())){
|
||||||
BeanUtils.copyProperties(cfg, num);
|
// BeanUtils.copyProperties(cfg, num);
|
||||||
num.setRegionId(regionIds.get(index));
|
num.setRegionId(regionIds.get(0));
|
||||||
regionIds.remove(index);
|
regionIds.remove(0);
|
||||||
num.setGroupId(groupIds.get(index));
|
num.setGroupId(groupIds.get(0));
|
||||||
groupIds.remove(index);
|
groupIds.remove(0);
|
||||||
num.setIsValid(entity.getIsValid());
|
num.setIsValid(entity.getIsValid());
|
||||||
num.setAuditTime(StringUtil.isEmpty(num.getAuditTime()) ? entity.getAuditTime():num.getAuditTime());
|
num.setAuditTime(StringUtil.isEmpty(num.getAuditTime()) ? cfg.getAuditTime():num.getAuditTime());
|
||||||
list4.add(num);
|
list4.add(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int index=0;index<fileList.size();index++){
|
for(int index=0;index<fileList.size();index++){
|
||||||
FileDigestCfg file = fileList.get(index);
|
FileDigestCfg file = fileList.get(index);
|
||||||
if(file.getCompileId().equals(cfg.getCompileId())){
|
if(file.getCompileId().equals(cfg.getCompileId())){
|
||||||
BeanUtils.copyProperties(cfg, file);
|
// BeanUtils.copyProperties(cfg, file);
|
||||||
file.setRegionId(regionIds.get(index));
|
file.setRegionId(regionIds.get(0));
|
||||||
regionIds.remove(index);
|
regionIds.remove(0);
|
||||||
file.setGroupId(groupIds.get(index));
|
file.setGroupId(groupIds.get(0));
|
||||||
groupIds.remove(index);
|
groupIds.remove(0);
|
||||||
file.setIsValid(entity.getIsValid());
|
file.setIsValid(entity.getIsValid());
|
||||||
file.setAuditTime(StringUtil.isEmpty(file.getAuditTime()) ? entity.getAuditTime():file.getAuditTime());
|
file.setAuditTime(StringUtil.isEmpty(file.getAuditTime()) ? cfg.getAuditTime():file.getAuditTime());
|
||||||
list5.add(file);
|
list5.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,12 +495,543 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//调用服务接口配置全量更新
|
//调用服务接口配置全量更新
|
||||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
// JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasData;
|
return hasData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP策略配置批量下发
|
||||||
|
* @param cfgList
|
||||||
|
* @param userRegionList
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param list
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg 业务配置全部生效时需同步更新库表配置状态
|
||||||
|
* @return
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public boolean auditAppPolicyData(List<Map<String,Object>> cfgList,
|
||||||
|
List<Map<String,Object>> userRegionList,
|
||||||
|
Page page,
|
||||||
|
BaseCfg entity,
|
||||||
|
List<AppPolicyCfg> list,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
|
List<IpPortCfg> ipList = new ArrayList();
|
||||||
|
List<BaseStringCfg> strList = new ArrayList();
|
||||||
|
List<ComplexkeywordCfg> complexStrList = new ArrayList();
|
||||||
|
List<com.nis.domain.configuration.NumBoundaryCfg> numList = new ArrayList();
|
||||||
|
List<FileDigestCfg> fileList = new ArrayList();
|
||||||
|
maatBean = new ToMaatBean();
|
||||||
|
configCompileList = new ArrayList();
|
||||||
|
List<Integer> compileIds = new ArrayList();
|
||||||
|
List<String> asnGroupIds = new ArrayList();
|
||||||
|
for(AppPolicyCfg cfg:list){
|
||||||
|
compileIds.add(cfg.getCompileId());
|
||||||
|
}
|
||||||
|
if(cfgList!=null){
|
||||||
|
for(Map<String,Object> m:cfgList){
|
||||||
|
String tableName = m.get("tableName").toString();
|
||||||
|
if("1".equals(m.get("cfgType"))){
|
||||||
|
ipList.addAll(configSynchronizationDao.getIpPortList(tableName, compileIds));
|
||||||
|
}else if("2".equals(m.get("cfgType"))){
|
||||||
|
strList.addAll(configSynchronizationDao.getStrList(tableName,compileIds));
|
||||||
|
}else if("3".equals(m.get("cfgType"))){
|
||||||
|
complexStrList.addAll(configSynchronizationDao.getComplexStrList(tableName,compileIds));
|
||||||
|
}else if("4".equals(m.get("cfgType"))){
|
||||||
|
|
||||||
|
}else if("5".equals(m.get("cfgType"))){
|
||||||
|
fileList.addAll(configSynchronizationDao.getFileDigestList(tableName, compileIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//批量获取regionId,groupId(相同编译下的IP类配置多条ip只获取一个组号),compileIds.size()表示app策略本身有一个字符串域
|
||||||
|
List<Integer> regionIds = ConfigServiceUtil.getId(3, ipList.size()+strList.size()+compileIds.size()+complexStrList.size()+numList.size()+fileList.size());
|
||||||
|
List<Integer> groupIds = ConfigServiceUtil.getId(2, strList.size()+compileIds.size()+complexStrList.size()+numList.size()+fileList.size());
|
||||||
|
for(AppPolicyCfg cfg:list){
|
||||||
|
maatCfg = new MaatCfg();
|
||||||
|
maatCfg.initDefaultValue();
|
||||||
|
groupRelationList = new ArrayList();
|
||||||
|
ipRegionList = new ArrayList();
|
||||||
|
strRegionList = new ArrayList();
|
||||||
|
numRegionList = new ArrayList();
|
||||||
|
digestRegionList = new ArrayList();
|
||||||
|
areaIpRegionList = new ArrayList();
|
||||||
|
List list1 = new ArrayList();
|
||||||
|
List<BaseStringCfg> list2 = new ArrayList();
|
||||||
|
List<ComplexkeywordCfg> list3 = new ArrayList();
|
||||||
|
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
|
||||||
|
List<FileDigestCfg> list5 = new ArrayList();
|
||||||
|
String userRegion = "";
|
||||||
|
//处理自定义域
|
||||||
|
if(userRegionList!=null){
|
||||||
|
for(Map<String,Object> n:userRegionList){
|
||||||
|
Object userRegionPosition = n.get("userRegionPosition");
|
||||||
|
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||||
|
//通过反射机制获取自定义域字段值
|
||||||
|
String regionColumn = n.get("regionColumn").toString();
|
||||||
|
Class aClass = null;
|
||||||
|
if(userRegionPosition.toString().equals(("0"))){
|
||||||
|
aClass = BaseCfg.class;
|
||||||
|
}else{
|
||||||
|
aClass = AppPolicyCfg.class;
|
||||||
|
}
|
||||||
|
Object value = "";
|
||||||
|
Field field = aClass.getDeclaredField(regionColumn);
|
||||||
|
field.setAccessible(true);
|
||||||
|
value = field.get(cfg);
|
||||||
|
if(!StringUtil.isEmpty(value)){
|
||||||
|
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||||
|
userRegion = value.toString();
|
||||||
|
}else{
|
||||||
|
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||||
|
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将app码与行为码设置为字符串域
|
||||||
|
StringBuffer cfgKeywords = new StringBuffer();
|
||||||
|
BaseStringCfg strCfg = new BaseStringCfg();
|
||||||
|
if(cfg.getServiceId().equals(35)||cfg.getServiceId().equals(147)||cfg.getServiceId().equals(1059)){//基础协议
|
||||||
|
cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + cfg.getAppCode());
|
||||||
|
}else if(cfg.getServiceId().equals(33)||cfg.getServiceId().equals(145)||cfg.getServiceId().equals(1056)){
|
||||||
|
cfgKeywords.append(Constants.APP_ID_REGION + "=" + cfg.getAppCode());
|
||||||
|
if(cfg.getBehavCode()!=null){
|
||||||
|
cfgKeywords.append(Constants.KEYWORD_EXPR);
|
||||||
|
cfgKeywords.append(Constants.BEHAV_ID_REGION + "=" + cfg.getBehavCode());
|
||||||
|
}
|
||||||
|
}else if(cfg.getServiceId().equals(36)||cfg.getServiceId().equals(148)||cfg.getServiceId().equals(1060)){//隧道加密协议
|
||||||
|
cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + cfg.getAppCode());
|
||||||
|
if(cfg.getBehavCode()!=null){
|
||||||
|
cfgKeywords.append(Constants.KEYWORD_EXPR);
|
||||||
|
cfgKeywords.append(Constants.BEHAV_ID_REGION + "=" + cfg.getBehavCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg.setCfgKeywords(cfgKeywords.toString());
|
||||||
|
BeanUtils.copyProperties(cfg, strCfg);
|
||||||
|
strList.add(strCfg);
|
||||||
|
|
||||||
|
|
||||||
|
if(ipList.size()>0){
|
||||||
|
List<Integer> ipGroupId = ConfigServiceUtil.getId(2,1);//多条IP只获取一个groupId
|
||||||
|
for(int index=0;index<ipList.size();index++){
|
||||||
|
IpPortCfg ip = ipList.get(index);
|
||||||
|
if(ip.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, ip);
|
||||||
|
ip.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
ip.setGroupId(ipGroupId.get(0));
|
||||||
|
ip.setIsValid(entity.getIsValid());
|
||||||
|
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? cfg.getAuditTime():ip.getAuditTime());
|
||||||
|
list1.add(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<strList.size();index++){
|
||||||
|
BaseStringCfg str = strList.get(index);
|
||||||
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
|
str.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
str.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
str.setIsValid(entity.getIsValid());
|
||||||
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
|
list2.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<complexStrList.size();index++){
|
||||||
|
ComplexkeywordCfg str = complexStrList.get(index);
|
||||||
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
|
str.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
str.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
str.setIsValid(entity.getIsValid());
|
||||||
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
|
list3.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<numList.size();index++){
|
||||||
|
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
|
||||||
|
if(num.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, num);
|
||||||
|
num.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
num.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
num.setIsValid(entity.getIsValid());
|
||||||
|
num.setAuditTime(StringUtil.isEmpty(num.getAuditTime()) ? cfg.getAuditTime():num.getAuditTime());
|
||||||
|
list4.add(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<fileList.size();index++){
|
||||||
|
FileDigestCfg file = fileList.get(index);
|
||||||
|
if(file.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, file);
|
||||||
|
file.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
file.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
file.setIsValid(entity.getIsValid());
|
||||||
|
file.setAuditTime(StringUtil.isEmpty(file.getAuditTime()) ? cfg.getAuditTime():file.getAuditTime());
|
||||||
|
list5.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(list1.size()>0){
|
||||||
|
ipList.removeAll(list1);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(ipRegionList,list1,1,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
ipRegionList=map.get("dstList");
|
||||||
|
if(map.get("numRegionList")!=null){
|
||||||
|
numRegionList.addAll(map.get("numRegionList"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(list2.size()>0){
|
||||||
|
strList.removeAll(list2);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(strRegionList,list2,2,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
strRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(list3.size()>0){
|
||||||
|
complexStrList.removeAll(list3);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(strRegionList,list3,3,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
strRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
if(list4.size()>0){
|
||||||
|
numList.removeAll(list4);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(numRegionList,list4,4,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
numRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
if(list5.size()>0){
|
||||||
|
fileList.removeAll(list5);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(digestRegionList,list5,5,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
digestRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanUtils.copyProperties(cfg, maatCfg);
|
||||||
|
maatCfg.setAction(cfg.getAction());
|
||||||
|
maatCfg.setAuditTime(StringUtil.isEmpty(cfg.getAuditTime()) ? new Date():cfg.getAuditTime());
|
||||||
|
maatCfg.setIpRegionList(ipRegionList);
|
||||||
|
maatCfg.setStrRegionList(strRegionList);
|
||||||
|
maatCfg.setNumRegionList(numRegionList);
|
||||||
|
maatCfg.setDigestRegionList(digestRegionList);
|
||||||
|
maatCfg.setGroupRelationList(groupRelationList);
|
||||||
|
maatCfg.setGroupNum(groupRelationList.size());
|
||||||
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||||
|
maatCfg.setIsValid(entity.getIsValid());
|
||||||
|
maatCfg.setAuditTime(new Date());
|
||||||
|
if(!StringUtil.isEmpty(userRegion)){
|
||||||
|
maatCfg.setUserRegion(userRegion);
|
||||||
|
}
|
||||||
|
configCompileList.add(maatCfg);
|
||||||
|
}
|
||||||
|
page.setList(list);
|
||||||
|
if(page.isLastPage()){
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||||
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
|
maatBean.setAuditTime(new Date());
|
||||||
|
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||||
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
|
String json=gsonToJson(maatBean);
|
||||||
|
//调用服务接口下发配置数据
|
||||||
|
if(isUpdateCfg) {
|
||||||
|
logger.info("配置批量下发:"+json);
|
||||||
|
//调用服务接口同步回调类配置
|
||||||
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
|
if(result!=null){
|
||||||
|
logger.info("配置批量下发响应信息:"+result.getMsg());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//调用服务接口配置全量更新
|
||||||
|
// JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasData;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* APP特征批量下发
|
||||||
|
* @param cfgList
|
||||||
|
* @param userRegionList
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param list
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg 业务配置全部生效时需同步更新库表配置状态
|
||||||
|
* @return
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public boolean auditAppFeatureData(List<Map<String,Object>> cfgList,
|
||||||
|
List<Map<String,Object>> userRegionList,
|
||||||
|
Page page,
|
||||||
|
BaseCfg entity,
|
||||||
|
List<AppFeatureIndex> list,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
|
List<IpPortCfg> ipList = new ArrayList();
|
||||||
|
List<BaseStringCfg> strList = new ArrayList();
|
||||||
|
List<ComplexkeywordCfg> complexStrList = new ArrayList();
|
||||||
|
List<com.nis.domain.configuration.NumBoundaryCfg> numList = new ArrayList();
|
||||||
|
List<FileDigestCfg> fileList = new ArrayList();
|
||||||
|
maatBean = new ToMaatBean();
|
||||||
|
configCompileList = new ArrayList();
|
||||||
|
List<Integer> compileIds = new ArrayList();
|
||||||
|
List<String> asnGroupIds = new ArrayList();
|
||||||
|
for(AppFeatureIndex cfg:list){
|
||||||
|
compileIds.add(cfg.getCompileId());
|
||||||
|
if(entity.getServiceId().equals(37)||entity.getServiceId().equals(149)){
|
||||||
|
asnGroupIds.add(cfg.getUserRegion4());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(cfgList!=null){
|
||||||
|
for(Map<String,Object> m:cfgList){
|
||||||
|
String tableName = m.get("tableName").toString();
|
||||||
|
if("1".equals(m.get("cfgType"))){
|
||||||
|
ipList.addAll(configSynchronizationDao.getAppIpPortList(tableName, compileIds));
|
||||||
|
}else if("2".equals(m.get("cfgType"))){
|
||||||
|
strList.addAll(configSynchronizationDao.getStrList(tableName,compileIds));
|
||||||
|
}else if("3".equals(m.get("cfgType"))){
|
||||||
|
complexStrList.addAll(configSynchronizationDao.getComplexStrList(tableName,compileIds));
|
||||||
|
}else if("4".equals(m.get("cfgType"))){
|
||||||
|
|
||||||
|
}else if("5".equals(m.get("cfgType"))){
|
||||||
|
fileList.addAll(configSynchronizationDao.getFileDigestList(tableName, compileIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//批量获取regionId,groupId(相同编译下的IP类配置多条ip只获取一个组号),分组复用的域配置不需要重新获取regionId,groupId
|
||||||
|
List<Integer> regionIds = ConfigServiceUtil.getId(3, ipList.size()+strList.size()+complexStrList.size()+numList.size()+fileList.size());
|
||||||
|
List<Integer> groupIds = ConfigServiceUtil.getId(2, strList.size()+complexStrList.size()+numList.size()+fileList.size());
|
||||||
|
for(AppFeatureIndex cfg:list){
|
||||||
|
maatCfg = new MaatCfg();
|
||||||
|
maatCfg.initDefaultValue();
|
||||||
|
groupRelationList = new ArrayList();
|
||||||
|
ipRegionList = new ArrayList();
|
||||||
|
strRegionList = new ArrayList();
|
||||||
|
numRegionList = new ArrayList();
|
||||||
|
digestRegionList = new ArrayList();
|
||||||
|
areaIpRegionList = new ArrayList();
|
||||||
|
List list1 = new ArrayList();
|
||||||
|
List<BaseStringCfg> list2 = new ArrayList();
|
||||||
|
List<ComplexkeywordCfg> list3 = new ArrayList();
|
||||||
|
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
|
||||||
|
List<FileDigestCfg> list5 = new ArrayList();
|
||||||
|
String userRegion = "";
|
||||||
|
//处理自定义域
|
||||||
|
if(userRegionList!=null){
|
||||||
|
for(Map<String,Object> n:userRegionList){
|
||||||
|
Object userRegionPosition = n.get("userRegionPosition");
|
||||||
|
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||||
|
//通过反射机制获取自定义域字段值
|
||||||
|
String regionColumn = n.get("regionColumn").toString();
|
||||||
|
Class aClass = null;
|
||||||
|
if(userRegionPosition.toString().equals(("0"))){
|
||||||
|
aClass = BaseCfg.class;
|
||||||
|
}else{
|
||||||
|
aClass = AppFeatureIndex.class;
|
||||||
|
}
|
||||||
|
Object value = "";
|
||||||
|
Field field = aClass.getDeclaredField(regionColumn);
|
||||||
|
field.setAccessible(true);
|
||||||
|
value = field.get(cfg);
|
||||||
|
if(!StringUtil.isEmpty(value)){
|
||||||
|
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||||
|
userRegion = value.toString();
|
||||||
|
}else{
|
||||||
|
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||||
|
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ipList.size()>0){
|
||||||
|
List<Integer> ipGroupId = ConfigServiceUtil.getId(2,1);//多条IP只获取一个groupId
|
||||||
|
for(int index=0;index<ipList.size();index++){
|
||||||
|
IpPortCfg ip = ipList.get(index);
|
||||||
|
if(ip.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, ip);
|
||||||
|
ip.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
ip.setGroupId(ipGroupId.get(0));
|
||||||
|
ip.setIsValid(entity.getIsValid());
|
||||||
|
ip.setAuditTime(StringUtil.isEmpty(ip.getAuditTime()) ? cfg.getAuditTime():ip.getAuditTime());
|
||||||
|
list1.add(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<strList.size();index++){
|
||||||
|
BaseStringCfg str = strList.get(index);
|
||||||
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
|
str.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
str.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
str.setIsValid(entity.getIsValid());
|
||||||
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
|
list2.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<complexStrList.size();index++){
|
||||||
|
ComplexkeywordCfg str = complexStrList.get(index);
|
||||||
|
if(str.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, str);
|
||||||
|
str.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
str.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
str.setIsValid(entity.getIsValid());
|
||||||
|
str.setAuditTime(StringUtil.isEmpty(str.getAuditTime()) ? cfg.getAuditTime():str.getAuditTime());
|
||||||
|
list3.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<numList.size();index++){
|
||||||
|
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
|
||||||
|
if(num.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, num);
|
||||||
|
num.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
num.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
num.setIsValid(entity.getIsValid());
|
||||||
|
num.setAuditTime(StringUtil.isEmpty(num.getAuditTime()) ? cfg.getAuditTime():num.getAuditTime());
|
||||||
|
list4.add(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int index=0;index<fileList.size();index++){
|
||||||
|
FileDigestCfg file = fileList.get(index);
|
||||||
|
if(file.getCompileId().equals(cfg.getCompileId())){
|
||||||
|
// BeanUtils.copyProperties(cfg, file);
|
||||||
|
file.setRegionId(regionIds.get(0));
|
||||||
|
regionIds.remove(0);
|
||||||
|
file.setGroupId(groupIds.get(0));
|
||||||
|
groupIds.remove(0);
|
||||||
|
file.setIsValid(entity.getIsValid());
|
||||||
|
file.setAuditTime(StringUtil.isEmpty(file.getAuditTime()) ? cfg.getAuditTime():file.getAuditTime());
|
||||||
|
list5.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(list1.size()>0){
|
||||||
|
ipList.removeAll(list1);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(ipRegionList,list1,1,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
ipRegionList=map.get("dstList");
|
||||||
|
if(map.get("numRegionList")!=null){
|
||||||
|
numRegionList.addAll(map.get("numRegionList"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(list2.size()>0){
|
||||||
|
strList.removeAll(list2);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(strRegionList,list2,2,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
strRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
if(list3.size()>0){
|
||||||
|
complexStrList.removeAll(list3);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(strRegionList,list3,3,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
strRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
if(list4.size()>0){
|
||||||
|
numList.removeAll(list4);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(numRegionList,list4,4,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
numRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
if(list5.size()>0){
|
||||||
|
fileList.removeAll(list5);
|
||||||
|
Map<String,List> map = cfgToMaatConvert(digestRegionList,list5,5,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
digestRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanUtils.copyProperties(cfg, maatCfg);
|
||||||
|
maatCfg.setAction(cfg.getAction());
|
||||||
|
maatCfg.setAuditTime(StringUtil.isEmpty(cfg.getAuditTime()) ? new Date():cfg.getAuditTime());
|
||||||
|
maatCfg.setIpRegionList(ipRegionList);
|
||||||
|
maatCfg.setStrRegionList(strRegionList);
|
||||||
|
maatCfg.setNumRegionList(numRegionList);
|
||||||
|
maatCfg.setDigestRegionList(digestRegionList);
|
||||||
|
maatCfg.setGroupRelationList(groupRelationList);
|
||||||
|
maatCfg.setGroupNum(groupRelationList.size());
|
||||||
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||||
|
maatCfg.setIsValid(entity.getIsValid());
|
||||||
|
maatCfg.setAuditTime(new Date());
|
||||||
|
if(!StringUtil.isEmpty(userRegion)){
|
||||||
|
maatCfg.setUserRegion(userRegion);
|
||||||
|
}
|
||||||
|
configCompileList.add(maatCfg);
|
||||||
|
}
|
||||||
|
page.setList(list);
|
||||||
|
if(page.isLastPage()){
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||||
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
|
maatBean.setAuditTime(new Date());
|
||||||
|
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||||
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
|
String json=gsonToJson(maatBean);
|
||||||
|
//调用服务接口下发配置数据
|
||||||
|
if(isUpdateCfg) {
|
||||||
|
logger.info("配置批量下发:"+json);
|
||||||
|
//调用服务接口同步回调类配置
|
||||||
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
|
if(result!=null){
|
||||||
|
logger.info("配置批量下发响应信息:"+result.getMsg());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//调用服务接口配置全量更新
|
||||||
|
// JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasData;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 处理ddos配置
|
* 处理ddos配置
|
||||||
* @param serviceId
|
* @param serviceId
|
||||||
@@ -488,7 +1061,42 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 处理单域maat配置
|
||||||
|
* @param serviceId
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
*/
|
||||||
|
public void handleSingleMaatData(int cfgType,List<Map<String,Object>>userRegionList,
|
||||||
|
Page<T> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||||
|
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
|
||||||
|
boolean hasData = true;
|
||||||
|
while(hasData){
|
||||||
|
entity.setPage(page);
|
||||||
|
List list = Lists.newArrayList();
|
||||||
|
if(cfgType==1){
|
||||||
|
list = configSynchronizationDao.getIpPortListByService(entity);
|
||||||
|
}else if(cfgType==2){
|
||||||
|
list = configSynchronizationDao.getStrListByService(entity);
|
||||||
|
}else if(cfgType==3){
|
||||||
|
list = configSynchronizationDao.getComplexStrListByService(entity);
|
||||||
|
}
|
||||||
|
if(!StringUtil.isEmpty(list)){
|
||||||
|
hasData=auditSingleMaatData(cfgType,userRegionList,
|
||||||
|
page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* ddos配置批量下发
|
* ddos配置批量下发
|
||||||
* @param cfgList
|
* @param cfgList
|
||||||
@@ -627,6 +1235,161 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
}
|
}
|
||||||
return hasData;
|
return hasData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 单域配置批量下发
|
||||||
|
* @param cfgList
|
||||||
|
* @param userRegionList
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param list
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg 业务配置全部生效时需同步更新库表配置状态
|
||||||
|
* @return
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public boolean auditSingleMaatData(int cfgType,
|
||||||
|
List<Map<String,Object>>userRegionList,
|
||||||
|
Page<T> page,
|
||||||
|
BaseCfg entity,
|
||||||
|
List<T> list,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
|
|
||||||
|
List<IpPortCfg> ipList = new ArrayList();
|
||||||
|
maatBean = new ToMaatBean();
|
||||||
|
configCompileList = new ArrayList();
|
||||||
|
//批量获取regionId,groupId
|
||||||
|
List<Integer> regionIds = ConfigServiceUtil.getId(3, list.size());
|
||||||
|
List<Integer> groupIds = ConfigServiceUtil.getId(2, list.size());
|
||||||
|
IpPortCfg ipCfg = null;
|
||||||
|
BaseStringCfg strCfg = null;
|
||||||
|
ComplexkeywordCfg complexStr = null;
|
||||||
|
for(int i=0;i<list.size();i++){
|
||||||
|
BaseCfg cfg = new BaseCfg();
|
||||||
|
BeanUtils.copyProperties(list.get(i), cfg);
|
||||||
|
cfg.setRegionId(regionIds.get(i));
|
||||||
|
cfg.setGroupId(groupIds.get(i));
|
||||||
|
cfg.setIsValid(entity.getIsValid());
|
||||||
|
cfg.setAuditTime(StringUtil.isEmpty(cfg.getAuditTime()) ? entity.getAuditTime():cfg.getAuditTime());
|
||||||
|
maatCfg = new MaatCfg();
|
||||||
|
maatCfg.initDefaultValue();
|
||||||
|
groupRelationList = new ArrayList();
|
||||||
|
ipRegionList = new ArrayList();
|
||||||
|
strRegionList = new ArrayList();
|
||||||
|
numRegionList = new ArrayList();
|
||||||
|
digestRegionList = new ArrayList();
|
||||||
|
areaIpRegionList = new ArrayList();
|
||||||
|
List list1 = new ArrayList();
|
||||||
|
String userRegion = "";
|
||||||
|
//处理自定义域
|
||||||
|
if(userRegionList!=null){
|
||||||
|
for(Map<String,Object> n:userRegionList){
|
||||||
|
Object userRegionPosition = n.get("userRegionPosition");
|
||||||
|
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||||
|
//通过反射机制获取自定义域字段值
|
||||||
|
String regionColumn = n.get("regionColumn").toString();
|
||||||
|
Class aClass = null;
|
||||||
|
if(userRegionPosition.toString().equals(("0"))){
|
||||||
|
aClass = BaseCfg.class;
|
||||||
|
}else{
|
||||||
|
if(cfgType==1){
|
||||||
|
aClass = IpPortCfg.class;
|
||||||
|
}else if(cfgType==2){
|
||||||
|
aClass = BaseStringCfg.class;
|
||||||
|
}else if(cfgType==3){
|
||||||
|
aClass = ComplexkeywordCfg.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Object value = "";
|
||||||
|
Field field = aClass.getDeclaredField(regionColumn);
|
||||||
|
field.setAccessible(true);
|
||||||
|
value = field.get(cfg);
|
||||||
|
if(!StringUtil.isEmpty(value)){
|
||||||
|
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||||
|
userRegion = value.toString();
|
||||||
|
}else{
|
||||||
|
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||||
|
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list1.add(cfg);
|
||||||
|
if(list1.size()>0){
|
||||||
|
ipList.removeAll(list1);
|
||||||
|
if(cfgType==1){
|
||||||
|
Map<String,List> map = cfgToMaatConvert(ipRegionList,list1,1,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
ipRegionList=map.get("dstList");
|
||||||
|
if(map.get("numRegionList")!=null){
|
||||||
|
numRegionList.addAll(map.get("numRegionList"));
|
||||||
|
}
|
||||||
|
}else if(cfgType==2||cfgType==3){
|
||||||
|
Map<String,List> map = cfgToMaatConvert(strRegionList,list1,2,groupRelationList);
|
||||||
|
groupRelationList=map.get("groupList");
|
||||||
|
strRegionList=map.get("dstList");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(cfg, maatCfg);
|
||||||
|
maatCfg.setAction(cfg.getAction());
|
||||||
|
maatCfg.setAuditTime(StringUtil.isEmpty(cfg.getAuditTime()) ? new Date():cfg.getAuditTime());
|
||||||
|
maatCfg.setIpRegionList(ipRegionList);
|
||||||
|
maatCfg.setStrRegionList(strRegionList);
|
||||||
|
maatCfg.setNumRegionList(numRegionList);
|
||||||
|
maatCfg.setDigestRegionList(digestRegionList);
|
||||||
|
maatCfg.setGroupRelationList(groupRelationList);
|
||||||
|
maatCfg.setGroupNum(groupRelationList.size());
|
||||||
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||||
|
maatCfg.setIsValid(entity.getIsValid());
|
||||||
|
if(!StringUtil.isEmpty(userRegion)){
|
||||||
|
maatCfg.setUserRegion(userRegion);
|
||||||
|
}
|
||||||
|
configCompileList.add(maatCfg);
|
||||||
|
}
|
||||||
|
page.setList(list);
|
||||||
|
if(page.isLastPage()){
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||||
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
|
maatBean.setAuditTime(new Date());
|
||||||
|
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||||
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
|
String json=gsonToJson(maatBean);
|
||||||
|
//调用服务接口下发配置数据
|
||||||
|
if(isUpdateCfg) {
|
||||||
|
logger.info("配置批量下发:"+json);
|
||||||
|
//调用服务接口同步回调类配置
|
||||||
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
|
if(result!=null){
|
||||||
|
logger.info("配置批量下发响应信息:"+result.getMsg());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//调用服务接口配置全量更新
|
||||||
|
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return hasData;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 处理app业务maat类配置
|
* 处理app业务maat类配置
|
||||||
* @param serviceId
|
* @param serviceId
|
||||||
|
|||||||
Reference in New Issue
Block a user