diff options
| author | wangxin <[email protected]> | 2019-07-19 12:59:25 +0800 |
|---|---|---|
| committer | wangxin <[email protected]> | 2019-07-19 12:59:25 +0800 |
| commit | 8c514c4e7e01074ff00f2bb1b32af60d1d9e997b (patch) | |
| tree | b78e38279e76914de7b5bc3d71ea814363ab3dd9 | |
| parent | 12a77173ca0c37dd935e4558434878640fcf5c7c (diff) | |
配置转换改为多线程转换,一个组类型一个线程;审核与更新组配置是查询配置下的所有域的查询改为多线程查询。在多个组的情况下处理速度会加快。
11 files changed, 842 insertions, 372 deletions
diff --git a/src/main/java/com/nis/util/SchedulerTaskUtil.java b/src/main/java/com/nis/util/SchedulerTaskUtil.java index 778bc95f4..73b8ea77b 100644 --- a/src/main/java/com/nis/util/SchedulerTaskUtil.java +++ b/src/main/java/com/nis/util/SchedulerTaskUtil.java @@ -10,6 +10,8 @@ import com.google.gson.reflect.TypeToken; import com.nis.domain.FunctionServiceDict;
import com.nis.domain.basics.*;
import com.nis.domain.configuration.*;
+import com.nis.web.service.configuration.ObjGroupCfgConvert;
+import com.nis.web.service.configuration.ObjectGroupService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.shiro.SecurityUtils;
@@ -141,7 +143,7 @@ public class SchedulerTaskUtil { //查询子域配置详情
if(cfgList!=null){
if(isCommonGroup){
- groupIdSet=new HashSet<>();
+ groupIdSet=Collections.synchronizedSet(new HashSet<Integer>());
commGroupMap=ConfigConvertUtil.gsonFromJson(list.get(0).getCommonGroupIds(),Map.class);
//将组中的域设置到cfg_index_info中
covertCommongroupIdsMap(commGroupMap,"ipGroup",list.get(0),configSynchronizationDao,IpCommCfg.class);
@@ -195,10 +197,10 @@ public class SchedulerTaskUtil { entity.setIsValid(isValid);//将最新的配置状态赋给配置对象
entity.setAuditTime(updateTime);
for(CfgIndexInfo cfg:list){
- groupRelationList = new ArrayList();
- ipRegionList = new ArrayList();
- strRegionList = new ArrayList();
- numRegionList = new ArrayList();
+ groupRelationList = Collections.synchronizedList(new ArrayList());
+ ipRegionList = Collections.synchronizedList(new ArrayList());
+ strRegionList = Collections.synchronizedList(new ArrayList());
+ numRegionList =Collections.synchronizedList(new ArrayList());
digestRegionList = new ArrayList();
areaIpRegionList = new ArrayList();
if(StringUtils.isNotBlank(cfg.getCommonGroupIds())){//公共分组
@@ -207,45 +209,82 @@ public class SchedulerTaskUtil { userRegion.append(ConfigConvertUtil.generateCommonGroupDefaultUserRegion(null,cfg.getServiceId()));
//子配置
Map<String,Object> maatTableMap=ConfigConvertUtil.convertCommonGroupMaatTable(cfg,cfgList);
- //IP公共分组
- if(CollectionUtils.isNotEmpty(cfg.getIpCommGroupCfgList())){
- IpPortCfg _cfg = new IpPortCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
- Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfg.getIpCommGroupCfgList(),1,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- ipRegionList=map.get("dstList");
- if(map.get("numRegionList")!=null){
- numRegionList.addAll(map.get("numRegionList"));
- }
-
+ //多线程转换
+ ObjGroupCfgConvert ipConvert=new ObjGroupCfgConvert("ipGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ ipConvert.setGroupRelationList(groupRelationList);
+ ipConvert.setIpRegionList(ipRegionList);
+ ipConvert.setNumRegionList(numRegionList);
+ ipConvert.setStrRegionList(strRegionList);
+ ObjGroupCfgConvert subscribeIdConvert=new ObjGroupCfgConvert("subscribeIdGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ subscribeIdConvert.setGroupRelationList(groupRelationList);
+ subscribeIdConvert.setIpRegionList(ipRegionList);
+ subscribeIdConvert.setNumRegionList(numRegionList);
+ subscribeIdConvert.setStrRegionList(strRegionList);
+ ObjGroupCfgConvert urlConvert=new ObjGroupCfgConvert("urlGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ urlConvert.setGroupRelationList(groupRelationList);
+ urlConvert.setIpRegionList(ipRegionList);
+ urlConvert.setNumRegionList(numRegionList);
+ urlConvert.setStrRegionList(strRegionList);
+ ObjGroupCfgConvert domainConvert=new ObjGroupCfgConvert("domainGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ domainConvert.setGroupRelationList(groupRelationList);
+ domainConvert.setIpRegionList(ipRegionList);
+ domainConvert.setNumRegionList(numRegionList);
+ domainConvert.setStrRegionList(strRegionList);
+ Thread t1=new Thread(ipConvert);
+ Thread t2=new Thread(subscribeIdConvert);
+ Thread t3=new Thread(urlConvert);
+ Thread t4=new Thread(domainConvert);
+ t1.start();
+ t2.start();
+ t3.start();
+ t4.start();
+ try {
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+ } catch (InterruptedException e) {
+ logger.error("多线程join异常",e);
}
+ //IP公共分组
+// if(CollectionUtils.isNotEmpty(cfg.getIpCommGroupCfgList())){
+// IpPortCfg _cfg = new IpPortCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
+// Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfg.getIpCommGroupCfgList(),1,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// ipRegionList=map.get("dstList");
+// if(map.get("numRegionList")!=null){
+// numRegionList.addAll(map.get("numRegionList"));
+// }
+//
+// }
//URL公共分组
- if(CollectionUtils.isNotEmpty(cfg.getUrlCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getUrlCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
- }
+// if(CollectionUtils.isNotEmpty(cfg.getUrlCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getUrlCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+// }
//账号公共分组
- if(CollectionUtils.isNotEmpty(cfg.getScriberIdCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
-
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getScriberIdCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
-
- }
+// if(CollectionUtils.isNotEmpty(cfg.getScriberIdCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
+//
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getScriberIdCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+//
+// }
//域名公共分组
- if(CollectionUtils.isNotEmpty(cfg.getDomainCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
-
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getDomainCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
- }
+// if(CollectionUtils.isNotEmpty(cfg.getDomainCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId","menuNameCode"});
+//
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getDomainCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+// }
BeanUtils.copyProperties(cfg, maatCfg);
if(cfg.getServiceId().equals(512)){
maatCfg.setAction(2);
diff --git a/src/main/java/com/nis/web/controller/configuration/ObjectGroupController.java b/src/main/java/com/nis/web/controller/configuration/ObjectGroupController.java index cbdc22ff3..490ae6d2c 100644 --- a/src/main/java/com/nis/web/controller/configuration/ObjectGroupController.java +++ b/src/main/java/com/nis/web/controller/configuration/ObjectGroupController.java @@ -4,10 +4,12 @@ package com.nis.web.controller.configuration; import com.nis.domain.FunctionServiceDict; import com.nis.domain.Page; +import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.configuration.BaseCfg; import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.ObjGroupCfg; +import com.nis.domain.specific.SpecificServiceCfg; import com.nis.exceptions.CallExternalProceduresException; import com.nis.exceptions.MaatConvertException; import com.nis.util.*; diff --git a/src/main/java/com/nis/web/dao/basics/DomainCommGroupDao.xml b/src/main/java/com/nis/web/dao/basics/DomainCommGroupDao.xml index 0b79a61b5..b418d17e2 100644 --- a/src/main/java/com/nis/web/dao/basics/DomainCommGroupDao.xml +++ b/src/main/java/com/nis/web/dao/basics/DomainCommGroupDao.xml @@ -454,7 +454,7 @@ AND r.group_id in(${commonGroupIds})
</if>
<!-- 数据范围过滤 -->
- ${sqlMap.dsf}
+ <!--${sqlMap.dsf}-->
</trim>
</select>
diff --git a/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml index 768b7ac0e..4cb1aa60f 100644 --- a/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml +++ b/src/main/java/com/nis/web/dao/basics/IpCommGroupCfgDao.xml @@ -642,87 +642,87 @@ AND r.group_id in(${commonGroupIds})
</if>
<!-- 数据范围过滤 -->
- ${sqlMap.dsf}
- </trim>
- </select>
-
- <select id="getGroupIds" parameterType="com.nis.domain.basics.IpCommCfg" resultMap="IpCommGroupCfgMap">
- SELECT
- <include refid="columns"></include>
- FROM
- ip_comm_cfg r
- <trim prefix="WHERE" prefixOverrides="AND |OR ">
- <if test="cfgId != null">
- AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
- </if>
- <if test="cfgDesc != null and cfgDesc != ''">
- AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
- </if>
- <if test="cfgRegionCode != null">
- AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
- </if>
- <if test="cfgType != null and cfgType != ''">
- AND r.CFG_TYPE like concat(concat('%',#{CFG_TYPE,jdbcType=VARCHAR}),'%')
- </if>
- <if test="ipType != null">
- AND r.IP_TYPE=#{ipType,jdbcType=INTEGER}
- </if>
- <if test="srcIpPattern != null">
- AND r.src_ip_pattern=#{srcIpPattern,jdbcType=INTEGER}
- </if>
- <if test="destIpPattern != null">
- AND r.dest_ip_pattern=#{destIpPattern,jdbcType=INTEGER}
- </if>
- <if test="srcIpAddress != null and srcIpAddress != ''">
- AND r.SRC_IP_ADDRESS=#{srcIpAddress,jdbcType=VARCHAR}
- </if>
- <if test="destIpAddress != null and destIpAddress != ''">
- AND r.DEST_IP_ADDRESS=#{destIpAddress,jdbcType=VARCHAR}
- </if>
- <if test="srcPortPattern != null">
- AND r.src_port_pattern=#{srcPortPattern,jdbcType=INTEGER}
- </if>
- <if test="destPortPattern != null">
- AND r.dest_port_pattern=#{destPortPattern,jdbcType=INTEGER}
- </if>
- <if test="srcPort != null and srcPort !=''">
- AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR}
- </if>
- <if test="destPort != null and destPort !=''">
- AND r.DEST_PORT=#{destPort,jdbcType=VARCHAR}
- </if>
- <if test="direction != null">
- AND r.DIRECTION=#{direction,jdbcType=INTEGER}
- </if>
- <if test="action != null">
- AND r.ACTION=#{action,jdbcType=INTEGER}
- </if>
- <if test="isAudit != null">
- AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
- </if>
- <if test="createTime != null and createTime !=''">
- AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
- </if>
- <if test="editTime != null and editTime !='' ">
- AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
- </if>
- <if test="serviceId != null">
- AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
- </if>
- <if test="isAreaEffective != null">
- AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
- </if>
- <if test="functionId != null">
- AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
- </if>
- <if test="groupId != null">
- AND r.group_id = #{groupId,jdbcType=INTEGER}
- </if>
- </trim>
- </select>
-
- <delete id="deleteCfgByGroupIds" parameterType="java.lang.String" >
- delete from ip_comm_cfg where group_id in (${groupIds})
- </delete>
-
-</mapper>
\ No newline at end of file + <!-- ${sqlMap.dsf} -->
+ </trim>
+ </select>
+
+ <select id="getGroupIds" parameterType="com.nis.domain.basics.IpCommCfg" resultMap="IpCommGroupCfgMap">
+ SELECT
+ <include refid="columns"></include>
+ FROM
+ ip_comm_cfg r
+ <trim prefix="WHERE" prefixOverrides="AND |OR ">
+ <if test="cfgId != null">
+ AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
+ </if>
+ <if test="cfgDesc != null and cfgDesc != ''">
+ AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="cfgRegionCode != null">
+ AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
+ </if>
+ <if test="cfgType != null and cfgType != ''">
+ AND r.CFG_TYPE like concat(concat('%',#{CFG_TYPE,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="ipType != null">
+ AND r.IP_TYPE=#{ipType,jdbcType=INTEGER}
+ </if>
+ <if test="srcIpPattern != null">
+ AND r.src_ip_pattern=#{srcIpPattern,jdbcType=INTEGER}
+ </if>
+ <if test="destIpPattern != null">
+ AND r.dest_ip_pattern=#{destIpPattern,jdbcType=INTEGER}
+ </if>
+ <if test="srcIpAddress != null and srcIpAddress != ''">
+ AND r.SRC_IP_ADDRESS=#{srcIpAddress,jdbcType=VARCHAR}
+ </if>
+ <if test="destIpAddress != null and destIpAddress != ''">
+ AND r.DEST_IP_ADDRESS=#{destIpAddress,jdbcType=VARCHAR}
+ </if>
+ <if test="srcPortPattern != null">
+ AND r.src_port_pattern=#{srcPortPattern,jdbcType=INTEGER}
+ </if>
+ <if test="destPortPattern != null">
+ AND r.dest_port_pattern=#{destPortPattern,jdbcType=INTEGER}
+ </if>
+ <if test="srcPort != null and srcPort !=''">
+ AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR}
+ </if>
+ <if test="destPort != null and destPort !=''">
+ AND r.DEST_PORT=#{destPort,jdbcType=VARCHAR}
+ </if>
+ <if test="direction != null">
+ AND r.DIRECTION=#{direction,jdbcType=INTEGER}
+ </if>
+ <if test="action != null">
+ AND r.ACTION=#{action,jdbcType=INTEGER}
+ </if>
+ <if test="isAudit != null">
+ AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
+ </if>
+ <if test="createTime != null and createTime !=''">
+ AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
+ </if>
+ <if test="editTime != null and editTime !='' ">
+ AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
+ </if>
+ <if test="serviceId != null">
+ AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
+ </if>
+ <if test="isAreaEffective != null">
+ AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
+ </if>
+ <if test="functionId != null">
+ AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
+ </if>
+ <if test="groupId != null">
+ AND r.group_id = #{groupId,jdbcType=INTEGER}
+ </if>
+ </trim>
+ </select>
+
+ <delete id="deleteCfgByGroupIds" parameterType="java.lang.String" >
+ delete from ip_comm_cfg where group_id in (${groupIds})
+ </delete>
+
+ </mapper>
\ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/ScriberIdCommGroupDao.xml b/src/main/java/com/nis/web/dao/basics/ScriberIdCommGroupDao.xml index 69a6b606b..19ae1a3e4 100644 --- a/src/main/java/com/nis/web/dao/basics/ScriberIdCommGroupDao.xml +++ b/src/main/java/com/nis/web/dao/basics/ScriberIdCommGroupDao.xml @@ -454,72 +454,72 @@ AND r.group_id in(${commonGroupIds})
</if>
<!-- 数据范围过滤 -->
- ${sqlMap.dsf}
- </trim>
+ <!-- ${sqlMap.dsf}-->
+ </trim>
- </select>
-
- <select id="getGroupIds" parameterType="com.nis.domain.basics.ScriberIdCommCfg" resultMap="commGroupCfgMap">
- SELECT
- <include refid="columns"></include>
- FROM
- scriberid_comm_cfg r
- <trim prefix="WHERE" prefixOverrides="AND |OR ">
- <if test="cfgId != null">
- AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
- </if>
- <if test="cfgDesc != null and cfgDesc != ''">
- AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
- </if>
- <if test="cfgKeywords != null and cfgKeywords != ''">
- AND r.cfg_keywords like concat(concat('%',#{cfgKeywords,jdbcType=VARCHAR}),'%')
- </if>
- <if test="cfgRegionCode != null">
- AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
- </if>
- <if test="cfgType != null and cfgType != ''">
- AND r.CFG_TYPE like concat(concat('%',#{cfgType,jdbcType=VARCHAR}),'%')
- </if>
- <if test="action != null">
- AND r.ACTION=#{action,jdbcType=INTEGER}
- </if>
- <if test="createTime != null and createTime !=''">
- AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
- </if>
- <if test="editTime != null and editTime !='' ">
- AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
- </if>
- <if test="serviceId != null">
- AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
- </if>
- <if test="requestId != null">
- AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
- </if>
- <if test="isAreaEffective != null">
- AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
- </if>
- <if test="classify != null and classify !=''">
- AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
- </if>
- <if test="attribute != null and attribute !=''">
- AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
- </if>
- <if test="lable != null and lable !=''">
- AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
- </if>
- <if test="areaEffectiveIds != null and areaEffectiveIds !=''">
- AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
- </if>
- <if test="functionId != null">
- AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
- </if>
- <if test="groupId != null">
- AND r.group_id = #{groupId,jdbcType=INTEGER}
- </if>
- <if test="commonGroupIds != null">
- AND r.group_id in(${commonGroupIds})
- </if>
- </trim>
- </select>
-
-</mapper>
+ </select>
+
+ <select id="getGroupIds" parameterType="com.nis.domain.basics.ScriberIdCommCfg" resultMap="commGroupCfgMap">
+ SELECT
+ <include refid="columns"></include>
+ FROM
+ scriberid_comm_cfg r
+ <trim prefix="WHERE" prefixOverrides="AND |OR ">
+ <if test="cfgId != null">
+ AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
+ </if>
+ <if test="cfgDesc != null and cfgDesc != ''">
+ AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="cfgKeywords != null and cfgKeywords != ''">
+ AND r.cfg_keywords like concat(concat('%',#{cfgKeywords,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="cfgRegionCode != null">
+ AND r.CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
+ </if>
+ <if test="cfgType != null and cfgType != ''">
+ AND r.CFG_TYPE like concat(concat('%',#{cfgType,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="action != null">
+ AND r.ACTION=#{action,jdbcType=INTEGER}
+ </if>
+ <if test="createTime != null and createTime !=''">
+ AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
+ </if>
+ <if test="editTime != null and editTime !='' ">
+ AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
+ </if>
+ <if test="serviceId != null">
+ AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
+ </if>
+ <if test="requestId != null">
+ AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
+ </if>
+ <if test="isAreaEffective != null">
+ AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
+ </if>
+ <if test="classify != null and classify !=''">
+ AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="attribute != null and attribute !=''">
+ AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="lable != null and lable !=''">
+ AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="areaEffectiveIds != null and areaEffectiveIds !=''">
+ AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
+ </if>
+ <if test="functionId != null">
+ AND r.FUNCTION_ID=#{functionId,jdbcType=INTEGER}
+ </if>
+ <if test="groupId != null">
+ AND r.group_id = #{groupId,jdbcType=INTEGER}
+ </if>
+ <if test="commonGroupIds != null">
+ AND r.group_id in(${commonGroupIds})
+ </if>
+ </trim>
+ </select>
+
+ </mapper>
diff --git a/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml index 5690636ca..717d33095 100644 --- a/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml +++ b/src/main/java/com/nis/web/dao/basics/UrlCommGroupDao.xml @@ -466,7 +466,7 @@ AND r.group_id in(${commonGroupIds})
</if>
<!-- 数据范围过滤 -->
- ${sqlMap.dsf}
+ <!--${sqlMap.dsf}-->
</trim>
</select>
diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index a73a48c8d..8a4662d17 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -8,22 +8,17 @@ import java.math.BigDecimal; import java.nio.charset.Charset; import java.sql.SQLException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import java.util.HashSet; +import java.util.concurrent.*; + import com.nis.domain.basics.*; import com.nis.domain.configuration.*; import com.nis.util.*; import com.nis.web.dao.CrudDao; import com.nis.web.dao.basics.*; import com.nis.web.dao.configuration.*; +import com.nis.web.service.configuration.ObjGroupCfgConvert; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringEscapeUtils; @@ -3379,23 +3374,56 @@ public abstract class BaseService { Integer serviceId=cfgIndexInfo.getServiceId(); if(serviceId!=null&&StringUtils.isNotBlank(cfgIndexInfo.getCommonGroupIds())){ MaatCfg maatCfg = new MaatCfg(); - Set<Integer> groupIdSet=new HashSet<>(); + Set<Integer> groupIdSet=Collections.synchronizedSet(new HashSet<Integer>()); List<MaatCfg> configCompileList = new ArrayList(); List<MaatCfg> cancelConfigCompileList = new ArrayList(); - List<GroupCfg> groupRelationList = new ArrayList(); - List<IpCfg> ipRegionList = new ArrayList(); - List<StringCfg> strRegionList = new ArrayList(); - List<NumBoundaryCfg> numRegionList = new ArrayList(); + List<GroupCfg> groupRelationList = Collections.synchronizedList(new ArrayList()); + List<IpCfg> ipRegionList = Collections.synchronizedList(new ArrayList()); + List<StringCfg> strRegionList = Collections.synchronizedList(new ArrayList()); + List<NumBoundaryCfg> numRegionList = Collections.synchronizedList(new ArrayList()); List<DigestCfg> digestRegionList = new ArrayList(); List<IpCfg> areaIpRegionList = new ArrayList(); Map<String,Object> userRgionMap=gsonFromJson(cfgIndexInfo.getCommonGroupIds(),Map.class); cfgIndexInfo.setUserRegion(userRgionMap); String oldCommonGroupIds=cfgIndexInfo.getCommonGroupIds(); //将所有要从配置中删除的组从配置中删除 - this.processUserRegionMap(userRgionMap,"ipGroup",ipDeletedGroups,cfgIndexInfo,ipCommGroupCfgDao,IpCommCfg.class); - this.processUserRegionMap(userRgionMap,"urlGroup",urlDeletedGroups,cfgIndexInfo,urlCommGroupCfgDao,UrlCommCfg.class); - this.processUserRegionMap(userRgionMap,"subscribeIdGroup",subIdDeletedGroups,cfgIndexInfo,scriberIdCommGroupDao,ScriberIdCommCfg.class); - this.processUserRegionMap(userRgionMap,"domainGroup",domainDeletedGroups,cfgIndexInfo,domainCommGroupDao,DomainCommCfg.class); + IpCommCfg ipCommCfg=(IpCommCfg)this.processUserRegionMap(userRgionMap,"ipGroup",ipDeletedGroups,cfgIndexInfo,ipCommGroupCfgDao,IpCommCfg.class); + UrlCommCfg urlCommCfg=(UrlCommCfg)this.processUserRegionMap(userRgionMap,"urlGroup",urlDeletedGroups,cfgIndexInfo,urlCommGroupCfgDao,UrlCommCfg.class); + ScriberIdCommCfg scriberIdCommCfg=(ScriberIdCommCfg)this.processUserRegionMap(userRgionMap,"subscribeIdGroup",subIdDeletedGroups,cfgIndexInfo,scriberIdCommGroupDao,ScriberIdCommCfg.class); + DomainCommCfg domainCommCfg=(DomainCommCfg)this.processUserRegionMap(userRgionMap,"domainGroup",domainDeletedGroups,cfgIndexInfo,domainCommGroupDao,DomainCommCfg.class); + ExecutorService executorService= Executors.newFixedThreadPool(4); + Future<List<IpCommCfg>> ipCommCfgF= executorService.submit(new ProcessUserRegionMapThread<IpCommCfg>(ipCommCfg,ipCommGroupCfgDao)); + Future<List<UrlCommCfg>> urlCommCfgF=executorService.submit(new ProcessUserRegionMapThread<UrlCommCfg>(urlCommCfg,urlCommGroupCfgDao)); + Future<List<ScriberIdCommCfg>> scriberIdCommCfgF=executorService.submit(new ProcessUserRegionMapThread<ScriberIdCommCfg>(scriberIdCommCfg,scriberIdCommGroupDao)); + Future<List<DomainCommCfg>> domainCommCfgF=executorService.submit(new ProcessUserRegionMapThread<DomainCommCfg>(domainCommCfg,domainCommGroupDao)); + executorService.shutdown(); + while(!executorService.isTerminated()){ + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + logger.error("error occured while sleeping",e); + } + } + try { + List<IpCommCfg> ipCommCfgList=ipCommCfgF.get(); + if(CollectionUtils.isNotEmpty(ipCommCfgList)){ + cfgIndexInfo.setIpCommGroupCfgList(ipCommCfgList); + } + List<UrlCommCfg> urlCommCfgList=urlCommCfgF.get(); + if(CollectionUtils.isNotEmpty(urlCommCfgList)){ + cfgIndexInfo.setUrlCommGroupList(urlCommCfgList); + } + List<ScriberIdCommCfg> scriberIdCommCfgList=scriberIdCommCfgF.get(); + if(CollectionUtils.isNotEmpty(scriberIdCommCfgList)){ + cfgIndexInfo.setScriberIdCommGroupList(scriberIdCommCfgList); + } + List<DomainCommCfg> domainCommCfgList=domainCommCfgF.get(); + if(CollectionUtils.isNotEmpty(domainCommCfgList)){ + cfgIndexInfo.setDomainCommGroupList(domainCommCfgList); + } + } catch (InterruptedException |ExecutionException e) { + logger.error("error occured while future get",e); + } //需要更新的组,组可能增加了,可能减少了,也有可能清空了(所有的域全删了) cfgIndexInfo.setCommonGroupIds(gsonToJson(userRgionMap)); @@ -3457,47 +3485,84 @@ public abstract class BaseService { } } compileIds.add(cfgIndexInfo.getCompileId()); + //多线程转换配置 + ObjGroupCfgConvert ipConvert=new ObjGroupCfgConvert("ipGroup",cfgIndexInfo,1,serviceDictMap,maatTableMap,groupIdSet); + ipConvert.setGroupRelationList(groupRelationList); + ipConvert.setIpRegionList(ipRegionList); + ipConvert.setNumRegionList(numRegionList); + ipConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert subscribeIdConvert=new ObjGroupCfgConvert("subscribeIdGroup",cfgIndexInfo,1,serviceDictMap,maatTableMap,groupIdSet); + subscribeIdConvert.setGroupRelationList(groupRelationList); + subscribeIdConvert.setIpRegionList(ipRegionList); + subscribeIdConvert.setNumRegionList(numRegionList); + subscribeIdConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert urlConvert=new ObjGroupCfgConvert("urlGroup",cfgIndexInfo,1,serviceDictMap,maatTableMap,groupIdSet); + urlConvert.setGroupRelationList(groupRelationList); + urlConvert.setIpRegionList(ipRegionList); + urlConvert.setNumRegionList(numRegionList); + urlConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert domainConvert=new ObjGroupCfgConvert("domainGroup",cfgIndexInfo,1,serviceDictMap,maatTableMap,groupIdSet); + domainConvert.setGroupRelationList(groupRelationList); + domainConvert.setIpRegionList(ipRegionList); + domainConvert.setNumRegionList(numRegionList); + domainConvert.setStrRegionList(strRegionList); + Thread t1=new Thread(ipConvert); + Thread t2=new Thread(subscribeIdConvert); + Thread t3=new Thread(urlConvert); + Thread t4=new Thread(domainConvert); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + } catch (InterruptedException e) { + logger.error("多线程join异常",e); + } //子表 //IP公共分组 - if(CollectionUtils.isNotEmpty(cfgIndexInfo.getIpCommGroupCfgList())){ - IpPortCfg cfg = new IpPortCfg(); - BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); - Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfgIndexInfo.getIpCommGroupCfgList(),1,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - ipRegionList=map.get("dstList"); - if(map.get("numRegionList")!=null){ - numRegionList.addAll(map.get("numRegionList")); - } - - } +// if(CollectionUtils.isNotEmpty(cfgIndexInfo.getIpCommGroupCfgList())){ +// IpPortCfg cfg = new IpPortCfg(); +// BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); +// Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfgIndexInfo.getIpCommGroupCfgList(),1,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// ipRegionList=map.get("dstList"); +// if(map.get("numRegionList")!=null){ +// numRegionList.addAll(map.get("numRegionList")); +// } +// +// } //URL公共分组 - if(CollectionUtils.isNotEmpty(cfgIndexInfo.getUrlCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getUrlCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - } +// if(CollectionUtils.isNotEmpty(cfgIndexInfo.getUrlCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getUrlCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// } //账号公共分组 - if(CollectionUtils.isNotEmpty(cfgIndexInfo.getScriberIdCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); - - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getScriberIdCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - - } +// if(CollectionUtils.isNotEmpty(cfgIndexInfo.getScriberIdCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); +// +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getScriberIdCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// +// } //域名公共分组 - if(CollectionUtils.isNotEmpty(cfgIndexInfo.getDomainCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); - - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getDomainCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - - } +// if(CollectionUtils.isNotEmpty(cfgIndexInfo.getDomainCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId"}); +// +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getDomainCommGroupList(),2,cfgIndexInfo,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// +// } //构造提交综合服务参数格式 maatCfg.initDefaultValue(); BeanUtils.copyProperties(cfgIndexInfo, maatCfg); @@ -3594,7 +3659,12 @@ public abstract class BaseService { if(CollectionUtils.isNotEmpty(maatBean.getConfigCompileList())){ //调用服务接口下发配置数据 String json=gsonToJson(maatBean); - logger.info("策略对象组下发配置参数:"+json); + if(json.length()<Constants.JSON_PRINT_LENTH) { + logger.info("策略对象组下发配置参数:" + json); + }else{ + logger.info("策略对象组下发配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印"); +// FileUtils.writeToFile("D:\\send.json",json,false); + } //调用服务接口下发配置 ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); logger.info("策略对象组下发响应信息:"+result.getMsg()); @@ -3602,7 +3672,7 @@ public abstract class BaseService { //commonPolicyDao.auditCfgBatch(CfgIndexInfo.getTablename(),auditCfg,compileIds,null); return true; } - private void processUserRegionMap(Map<String,Object> userRgionMap, String key, Set deletedGroups, CfgIndexInfo cfgIndexInfo, CrudDao dao,Class clazz) { + private BaseCfg processUserRegionMap(Map<String,Object> userRgionMap, String key, Set deletedGroups, CfgIndexInfo cfgIndexInfo, CrudDao dao,Class clazz) { if(userRgionMap.containsKey(key)){ //排除删除的组,添加新的组 for(String urlGroup:((String)userRgionMap.get(key)).split(",")){ @@ -3620,35 +3690,56 @@ public abstract class BaseService { if("IpCommCfg".equals(clazz.getSimpleName())){ IpCommCfg searchCfg=new IpCommCfg(); searchCfg.setCommonGroupIds(userRgionMap.get(key).toString().substring(1,userRgionMap.get(key).toString().length()-1)); - List commCfgs=dao.findAllList(searchCfg); - if(CollectionUtils.isNotEmpty(commCfgs)){ - cfgIndexInfo.setIpCommGroupCfgList(commCfgs); - } + //searchCfg.getSqlMap().put("dsf", configScopeFilter(UserUtils.getUser(),"r")); + return searchCfg; +// List commCfgs=dao.findAllList(searchCfg); +// if(CollectionUtils.isNotEmpty(commCfgs)){ +// cfgIndexInfo.setIpCommGroupCfgList(commCfgs); +// } }else if("ScriberIdCommCfg".equals(clazz.getSimpleName()) ){ ScriberIdCommCfg searchCfg=new ScriberIdCommCfg(); searchCfg.setCommonGroupIds(userRgionMap.get(key).toString().substring(1,userRgionMap.get(key).toString().length()-1)); - List commCfgs=dao.findAllList(searchCfg); - if(CollectionUtils.isNotEmpty(commCfgs)){ - cfgIndexInfo.setScriberIdCommGroupList(commCfgs); - } + //searchCfg.getSqlMap().put("dsf", configScopeFilter(UserUtils.getUser(),"r")); + return searchCfg; +// List commCfgs=dao.findAllList(searchCfg); +// if(CollectionUtils.isNotEmpty(commCfgs)){ +// cfgIndexInfo.setScriberIdCommGroupList(commCfgs); +// } }else if("UrlCommCfg".equals(clazz.getSimpleName())){ UrlCommCfg searchCfg=new UrlCommCfg(); searchCfg.setCommonGroupIds(userRgionMap.get(key).toString().substring(1,userRgionMap.get(key).toString().length()-1)); - List commCfgs=dao.findAllList(searchCfg); - if(CollectionUtils.isNotEmpty(commCfgs)){ - cfgIndexInfo.setUrlCommGroupList(commCfgs); - } + //searchCfg.getSqlMap().put("dsf", configScopeFilter(UserUtils.getUser(),"r")); + return searchCfg; +// List commCfgs=dao.findAllList(searchCfg); +// if(CollectionUtils.isNotEmpty(commCfgs)){ +// cfgIndexInfo.setUrlCommGroupList(commCfgs); +// } }else if("DomainCommCfg".equals(clazz.getSimpleName())){ DomainCommCfg searchCfg=new DomainCommCfg(); searchCfg.setCommonGroupIds(userRgionMap.get(key).toString().substring(1,userRgionMap.get(key).toString().length()-1)); - List commCfgs=dao.findAllList(searchCfg); - if(CollectionUtils.isNotEmpty(commCfgs)){ - cfgIndexInfo.setDomainCommGroupList(commCfgs); - } + //searchCfg.getSqlMap().put("dsf", configScopeFilter(UserUtils.getUser(),"r")); + return searchCfg; +// List commCfgs=dao.findAllList(searchCfg); +// if(CollectionUtils.isNotEmpty(commCfgs)){ +// cfgIndexInfo.setDomainCommGroupList(commCfgs); +// } } } } + return null; + } +} +class ProcessUserRegionMapThread<T extends BaseCfg> implements Callable<List<T>> { + private T searchCfg; + private CrudDao dao; + public ProcessUserRegionMapThread(T searchCfg, CrudDao dao){ + this.searchCfg=searchCfg; + this.dao=dao; + } + @Override + public List<T> call() throws Exception { + List<T> commCfgs=dao.findAllList(searchCfg); + return commCfgs; } } - diff --git a/src/main/java/com/nis/web/service/configuration/ConfigSynchronizationService.java b/src/main/java/com/nis/web/service/configuration/ConfigSynchronizationService.java index b43e1b29f..296f072c6 100644 --- a/src/main/java/com/nis/web/service/configuration/ConfigSynchronizationService.java +++ b/src/main/java/com/nis/web/service/configuration/ConfigSynchronizationService.java @@ -2430,55 +2430,100 @@ public class ConfigSynchronizationService extends BaseService{ List<Map<String,Object>> cfgList=(List<Map<String,Object>>)cfgMap.get(cfg.getServiceId());
Map<String,Object> maatTableMap=ConfigConvertUtil.convertCommonGroupMaatTable(cfg,cfgList);
Set<Integer> groupIdSet=new HashSet<>();
- //IP公共分组
- if(CollectionUtils.isNotEmpty(cfg.getIpCommGroupCfgList())){
- IpPortCfg _cfg = new IpPortCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
- _cfg.setIsValid(entity.getIsValid());
- _cfg.setIsAudit(entity.getIsAudit());
- _cfg.setAuditTime(entity.getAuditTime());
- Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfg.getIpCommGroupCfgList(),1,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- ipRegionList=map.get("dstList");
- if(map.get("numRegionList")!=null){
- numRegionList.addAll(map.get("numRegionList"));
- }
-
+ //多线程转换配置
+ ObjGroupCfgConvert ipConvert=new ObjGroupCfgConvert("ipGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ ipConvert.setGroupRelationList(groupRelationList);
+ ipConvert.setIpRegionList(ipRegionList);
+ ipConvert.setNumRegionList(numRegionList);
+ ipConvert.setStrRegionList(strRegionList);
+ ipConvert.setIsValid(entity.getIsValid());
+ ipConvert.setAuditTime(entity.getAuditTime());
+ ObjGroupCfgConvert subscribeIdConvert=new ObjGroupCfgConvert("subscribeIdGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ subscribeIdConvert.setGroupRelationList(groupRelationList);
+ subscribeIdConvert.setIpRegionList(ipRegionList);
+ subscribeIdConvert.setNumRegionList(numRegionList);
+ subscribeIdConvert.setStrRegionList(strRegionList);
+ subscribeIdConvert.setIsValid(entity.getIsValid());
+ subscribeIdConvert.setAuditTime(entity.getAuditTime());
+ ObjGroupCfgConvert urlConvert=new ObjGroupCfgConvert("urlGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ urlConvert.setGroupRelationList(groupRelationList);
+ urlConvert.setIpRegionList(ipRegionList);
+ urlConvert.setNumRegionList(numRegionList);
+ urlConvert.setStrRegionList(strRegionList);
+ urlConvert.setIsValid(entity.getIsValid());
+ urlConvert.setAuditTime(entity.getAuditTime());
+ ObjGroupCfgConvert domainConvert=new ObjGroupCfgConvert("domainGroup",cfg,1,serviceDictMap,maatTableMap,groupIdSet);
+ domainConvert.setGroupRelationList(groupRelationList);
+ domainConvert.setIpRegionList(ipRegionList);
+ domainConvert.setNumRegionList(numRegionList);
+ domainConvert.setStrRegionList(strRegionList);
+ domainConvert.setIsValid(entity.getIsValid());
+ domainConvert.setAuditTime(entity.getAuditTime());
+ Thread t1=new Thread(ipConvert);
+ Thread t2=new Thread(subscribeIdConvert);
+ Thread t3=new Thread(urlConvert);
+ Thread t4=new Thread(domainConvert);
+ t1.start();
+ t2.start();
+ t3.start();
+ t4.start();
+ try {
+ t1.join();
+ t2.join();
+ t3.join();
+ t4.join();
+ } catch (InterruptedException e) {
+ logger.error("多线程join异常",e);
}
+ //IP公共分组
+// if(CollectionUtils.isNotEmpty(cfg.getIpCommGroupCfgList())){
+// IpPortCfg _cfg = new IpPortCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
+// _cfg.setIsValid(entity.getIsValid());
+// _cfg.setIsAudit(entity.getIsAudit());
+// _cfg.setAuditTime(entity.getAuditTime());
+// Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfg.getIpCommGroupCfgList(),1,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// ipRegionList=map.get("dstList");
+// if(map.get("numRegionList")!=null){
+// numRegionList.addAll(map.get("numRegionList"));
+// }
+//
+// }
//URL公共分组
- if(CollectionUtils.isNotEmpty(cfg.getUrlCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
- _cfg.setIsValid(entity.getIsValid());
- _cfg.setIsAudit(entity.getIsAudit());
- _cfg.setAuditTime(entity.getAuditTime());
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getUrlCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
- }
+// if(CollectionUtils.isNotEmpty(cfg.getUrlCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
+// _cfg.setIsValid(entity.getIsValid());
+// _cfg.setIsAudit(entity.getIsAudit());
+// _cfg.setAuditTime(entity.getAuditTime());
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getUrlCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+// }
//账号公共分组
- if(CollectionUtils.isNotEmpty(cfg.getScriberIdCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
- _cfg.setIsValid(entity.getIsValid());
- _cfg.setIsAudit(entity.getIsAudit());
- _cfg.setAuditTime(entity.getAuditTime());
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getScriberIdCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
-
- }
+// if(CollectionUtils.isNotEmpty(cfg.getScriberIdCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId"});
+// _cfg.setIsValid(entity.getIsValid());
+// _cfg.setIsAudit(entity.getIsAudit());
+// _cfg.setAuditTime(entity.getAuditTime());
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getScriberIdCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+//
+// }
//域名公共分组
- if(CollectionUtils.isNotEmpty(cfg.getDomainCommGroupList())){
- CommonStringCfg _cfg = new CommonStringCfg();
- BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId",});
- _cfg.setIsValid(entity.getIsValid());
- _cfg.setIsAudit(entity.getIsAudit());
- _cfg.setAuditTime(entity.getAuditTime());
- Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getDomainCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
- groupRelationList=map.get("groupList");
- strRegionList=map.get("dstList");
- }
+// if(CollectionUtils.isNotEmpty(cfg.getDomainCommGroupList())){
+// CommonStringCfg _cfg = new CommonStringCfg();
+// BeanUtils.copyProperties(cfg, _cfg, new String[]{"cfgId",});
+// _cfg.setIsValid(entity.getIsValid());
+// _cfg.setIsAudit(entity.getIsAudit());
+// _cfg.setAuditTime(entity.getAuditTime());
+// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfg.getDomainCommGroupList(),2,_cfg,groupRelationList,maatTableMap,groupIdSet);
+// groupRelationList=map.get("groupList");
+// strRegionList=map.get("dstList");
+// }
BeanUtils.copyProperties(cfg, maatCfg);
if(cfg.getServiceId().equals(512)){
maatCfg.setAction(2);
@@ -2514,6 +2559,7 @@ public class ConfigSynchronizationService extends BaseService{ //调用服务接口下发配置数据
if(isUpdateCfg) {
//logger.info("配置批量下发:"+json);
+// FileUtils.writeToFile("D:\\send.json",json,false);
//调用服务接口同步回调类配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
if(result!=null){
diff --git a/src/main/java/com/nis/web/service/configuration/ObjGroupCfgConvert.java b/src/main/java/com/nis/web/service/configuration/ObjGroupCfgConvert.java new file mode 100644 index 000000000..b8a318cd1 --- /dev/null +++ b/src/main/java/com/nis/web/service/configuration/ObjGroupCfgConvert.java @@ -0,0 +1,159 @@ +package com.nis.web.service.configuration; + +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.configuration.CfgIndexInfo; +import com.nis.domain.configuration.CommonStringCfg; +import com.nis.domain.configuration.IpPortCfg; +import com.nis.domain.maat.MaatCfg; +import com.nis.util.ConfigConvertUtil; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ObjGroupCfgConvert implements Runnable{ + private CfgIndexInfo cfgIndexInfo; + private Integer isAudit; + private Map<Integer, FunctionServiceDict> serviceDictMap; + private Set<Integer> groupIdSet; + private List<MaatCfg.GroupCfg> groupRelationList; + private List<MaatCfg.IpCfg> ipRegionList; + private List<MaatCfg.StringCfg> strRegionList; + private List<MaatCfg.NumBoundaryCfg> numRegionList; + private Map<String,Object> maatTableMap; + private String groupName; + private Integer isValid; + private Date auditTime; + public ObjGroupCfgConvert(String groupName,CfgIndexInfo cfgIndexInfo,Integer isAudit,Map<Integer,FunctionServiceDict> serviceDictMap,Map<String,Object> maatTableMap,Set<Integer> groupIdSet){ + this.cfgIndexInfo=cfgIndexInfo; + this.isAudit=isAudit; + this.serviceDictMap=serviceDictMap; + this.groupIdSet=groupIdSet; + this.groupName=groupName; + this.maatTableMap=maatTableMap; + } + @Override + public void run() { + //IP公共分组 + if("ipGroup".equalsIgnoreCase(groupName)&& CollectionUtils.isNotEmpty(cfgIndexInfo.getIpCommGroupCfgList())){ + IpPortCfg cfg = new IpPortCfg(); + BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId","menuNameCode"}); + if(isValid!=null){ + cfg.setIsValid(isValid); + } + cfg.setIsAudit(isAudit); + if(auditTime!=null){ + cfg.setAuditTime(auditTime); + } + if(isAudit==1){ + Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,cfgIndexInfo.getIpCommGroupCfgList(),1,cfg,groupRelationList,maatTableMap,groupIdSet); + groupRelationList=map.get("groupList"); + ipRegionList=map.get("dstList"); + if(map.get("numRegionList")!=null){ + numRegionList.addAll(map.get("numRegionList")); + } + } + } + if("urlGroup".equalsIgnoreCase(groupName)&&CollectionUtils.isNotEmpty(cfgIndexInfo.getUrlCommGroupList())){ + CommonStringCfg cfg = new CommonStringCfg(); + BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId","menuNameCode"}); + if(isValid!=null){ + cfg.setIsValid(isValid); + } + cfg.setIsAudit(isAudit); + if(auditTime!=null){ + cfg.setAuditTime(auditTime); + } + if(isAudit==1){ + Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getUrlCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); + groupRelationList=map.get("groupList"); + strRegionList=map.get("dstList"); + } + } + //账号公共分组 + if("subscribeIdGroup".equalsIgnoreCase(groupName)&&CollectionUtils.isNotEmpty(cfgIndexInfo.getScriberIdCommGroupList())){ + CommonStringCfg cfg = new CommonStringCfg(); + BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId","menuNameCode"}); + if(isValid!=null){ + cfg.setIsValid(isValid); + } + cfg.setIsAudit(isAudit); + if(auditTime!=null){ + cfg.setAuditTime(auditTime); + } + if(isAudit==1){ + Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getScriberIdCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); + groupRelationList=map.get("groupList"); + strRegionList=map.get("dstList"); + } + } + //域名公共分组 + if("domainGroup".equalsIgnoreCase(groupName)&&CollectionUtils.isNotEmpty(cfgIndexInfo.getDomainCommGroupList())){ + CommonStringCfg cfg = new CommonStringCfg(); + BeanUtils.copyProperties(cfgIndexInfo, cfg, new String[]{"cfgId","menuNameCode"}); + if(isValid!=null){ + cfg.setIsValid(isValid); + } + cfg.setIsAudit(isAudit); + if(auditTime!=null){ + cfg.setAuditTime(auditTime); + } + if(isAudit==1){ + Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,cfgIndexInfo.getDomainCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); + groupRelationList=map.get("groupList"); + strRegionList=map.get("dstList"); + } + } + } + + public List<MaatCfg.GroupCfg> getGroupRelationList() { + return groupRelationList; + } + + public void setGroupRelationList(List<MaatCfg.GroupCfg> groupRelationList) { + this.groupRelationList = groupRelationList; + } + + public List<MaatCfg.IpCfg> getIpRegionList() { + return ipRegionList; + } + + public void setIpRegionList(List<MaatCfg.IpCfg> ipRegionList) { + this.ipRegionList = ipRegionList; + } + + public List<MaatCfg.StringCfg> getStrRegionList() { + return strRegionList; + } + + public void setStrRegionList(List<MaatCfg.StringCfg> strRegionList) { + this.strRegionList = strRegionList; + } + + public List<MaatCfg.NumBoundaryCfg> getNumRegionList() { + return numRegionList; + } + + public void setNumRegionList(List<MaatCfg.NumBoundaryCfg> numRegionList) { + this.numRegionList = numRegionList; + } + + public Integer getIsValid() { + return isValid; + } + + public void setIsValid(Integer isValid) { + this.isValid = isValid; + } + + public Date getAuditTime() { + return auditTime; + } + + public void setAuditTime(Date auditTime) { + this.auditTime = auditTime; + } +} diff --git a/src/main/java/com/nis/web/service/configuration/ObjectGroupService.java b/src/main/java/com/nis/web/service/configuration/ObjectGroupService.java index 2980785f2..b4bf27a32 100644 --- a/src/main/java/com/nis/web/service/configuration/ObjectGroupService.java +++ b/src/main/java/com/nis/web/service/configuration/ObjectGroupService.java @@ -16,8 +16,6 @@ import com.nis.web.dao.configuration.CommonPolicyDao; import com.nis.web.dao.configuration.ObjectGroupDao; import com.nis.web.security.UserUtils; import com.nis.web.service.BaseService; -import net.sf.json.JSONObject; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; @@ -339,8 +337,38 @@ public class ObjectGroupService extends BaseService { return entity; } + public CfgIndexInfo getObjGroupPolicyMultyThread(Long cfgId){ + CfgIndexInfo entity = commonPolicyDao.getPolicyById(cfgId); + entity.setUserRegion((Map<String,Object>)this.gsonFromJson(entity.getCommonGroupIds(),Map.class)); + GetSubBeanThread GetSubBeanThread1=new GetSubBeanThread(entity,"ipGroup"); + GetSubBeanThread GetSubBeanThread2=new GetSubBeanThread(entity,"subscribeIdGroup"); + GetSubBeanThread GetSubBeanThread3=new GetSubBeanThread(entity,"domainGroup"); + GetSubBeanThread GetSubBeanThread4=new GetSubBeanThread(entity,"urlGroup"); + GetSubBeanThread1.setObjectGroupDao(objectGroupDao); + GetSubBeanThread2.setObjectGroupDao(objectGroupDao); + GetSubBeanThread3.setObjectGroupDao(objectGroupDao); + GetSubBeanThread4.setObjectGroupDao(objectGroupDao); + Thread t1= new Thread(GetSubBeanThread1); + t1.start(); + Thread t2=new Thread(GetSubBeanThread2); + t2.start(); + Thread t3=new Thread(GetSubBeanThread3); + t3.start(); + Thread t4= new Thread(GetSubBeanThread4); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + } catch (InterruptedException e) { + logger.error("多线程join异常",e); + } + return entity; + } public void auditPolicy(CfgIndexInfo entity,Integer isAudit,Integer opAction) throws MaatConvertException { + long start=System.currentTimeMillis(),end=System.currentTimeMillis(); //修改数据库审核状态信息 entity.setTableName(CfgIndexInfo.getTablename()); entity.setIsAudit(isAudit); @@ -351,17 +379,23 @@ public class ObjectGroupService extends BaseService { ToMaatBean maatBean = new ToMaatBean(); MaatCfg maatCfg = new MaatCfg(); - Set<Integer> groupIdSet=new HashSet<>(); + //确保线程安全 + Set<Integer> groupIdSet=Collections.synchronizedSet(new HashSet<Integer>()); List<MaatCfg> configCompileList = new ArrayList(); - List<MaatCfg.GroupCfg> groupRelationList = new ArrayList(); - List<MaatCfg.IpCfg> ipRegionList = new ArrayList(); - List<MaatCfg.StringCfg> strRegionList = new ArrayList(); - List<MaatCfg.NumBoundaryCfg> numRegionList = new ArrayList(); + //确保线程安全 + List<MaatCfg.GroupCfg> groupRelationList = Collections.synchronizedList(new ArrayList<MaatCfg.GroupCfg>()); + List<MaatCfg.IpCfg> ipRegionList = Collections.synchronizedList(new ArrayList()); + List<MaatCfg.StringCfg> strRegionList = Collections.synchronizedList(new ArrayList()); + List<MaatCfg.NumBoundaryCfg> numRegionList = Collections.synchronizedList(new ArrayList()); List<MaatCfg.DigestCfg> digestRegionList = new ArrayList(); List<MaatCfg.IpCfg> areaIpRegionList = new ArrayList(); - //查询子配置并修改审核状态 - entity = this.getObjGroupPolicy(entity.getCfgId()); + //查询子配置 +// entity = this.getObjGroupPolicy(entity.getCfgId()); + //多线程查询 + entity = this.getObjGroupPolicyMultyThread(entity.getCfgId()); + end=System.currentTimeMillis(); + logger.info("查询子配置完成,耗时"+(end-start)+"ms"); // if(StringUtils.isBlank(entity.getCommonGroupIds())){ // // } @@ -396,57 +430,98 @@ public class ObjectGroupService extends BaseService { } } } - //IP公共分组 - if(CollectionUtils.isNotEmpty(entity.getIpCommGroupCfgList())){ - IpPortCfg cfg = new IpPortCfg(); - BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); - //cfg.setTableName("ip_comm_cfg"); - //commonPolicyDao.auditCfg(cfg); - if(isAudit==1){ - Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,entity.getIpCommGroupCfgList(),1,cfg,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - ipRegionList=map.get("dstList"); - if(map.get("numRegionList")!=null){ - numRegionList.addAll(map.get("numRegionList")); - } - } + //多线程转换配置 + long start1=System.currentTimeMillis(); + ObjGroupCfgConvert ipConvert=new ObjGroupCfgConvert("ipGroup",entity,isAudit,serviceDictMap,maatTableMap,groupIdSet); + ipConvert.setGroupRelationList(groupRelationList); + ipConvert.setIpRegionList(ipRegionList); + ipConvert.setNumRegionList(numRegionList); + ipConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert subscribeIdConvert=new ObjGroupCfgConvert("subscribeIdGroup",entity,isAudit,serviceDictMap,maatTableMap,groupIdSet); + subscribeIdConvert.setGroupRelationList(groupRelationList); + subscribeIdConvert.setIpRegionList(ipRegionList); + subscribeIdConvert.setNumRegionList(numRegionList); + subscribeIdConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert urlConvert=new ObjGroupCfgConvert("urlGroup",entity,isAudit,serviceDictMap,maatTableMap,groupIdSet); + urlConvert.setGroupRelationList(groupRelationList); + urlConvert.setIpRegionList(ipRegionList); + urlConvert.setNumRegionList(numRegionList); + urlConvert.setStrRegionList(strRegionList); + ObjGroupCfgConvert domainConvert=new ObjGroupCfgConvert("domainGroup",entity,isAudit,serviceDictMap,maatTableMap,groupIdSet); + domainConvert.setGroupRelationList(groupRelationList); + domainConvert.setIpRegionList(ipRegionList); + domainConvert.setNumRegionList(numRegionList); + domainConvert.setStrRegionList(strRegionList); + Thread t1=new Thread(ipConvert); + Thread t2=new Thread(subscribeIdConvert); + Thread t3=new Thread(urlConvert); + Thread t4=new Thread(domainConvert); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + } catch (InterruptedException e) { + logger.error("多线程join异常",e); } + + //IP公共分组 +// if(CollectionUtils.isNotEmpty(entity.getIpCommGroupCfgList())){ +// IpPortCfg cfg = new IpPortCfg(); +// BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); +// //cfg.setTableName("ip_comm_cfg"); +// //commonPolicyDao.auditCfg(cfg); +// if(isAudit==1){ +// Map<String,List> map = ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,ipRegionList,entity.getIpCommGroupCfgList(),1,cfg,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// ipRegionList=map.get("dstList"); +// if(map.get("numRegionList")!=null){ +// numRegionList.addAll(map.get("numRegionList")); +// } +// } +// } //URL公共分组 - if(CollectionUtils.isNotEmpty(entity.getUrlCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); - //cfg.setTableName(CommonStringCfg.getTablename()); - //commonPolicyDao.auditCfg(cfg); - if(isAudit==1){ - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getUrlCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - } - } +// if(CollectionUtils.isNotEmpty(entity.getUrlCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); +// //cfg.setTableName(CommonStringCfg.getTablename()); +// //commonPolicyDao.auditCfg(cfg); +// if(isAudit==1){ +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getUrlCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// } +// } //账号公共分组 - if(CollectionUtils.isNotEmpty(entity.getScriberIdCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); - //cfg.setTableName(CommonStringCfg.getTablename()); - //commonPolicyDao.auditCfg(cfg); - if(isAudit==1){ - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getScriberIdCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - } - } +// if(CollectionUtils.isNotEmpty(entity.getScriberIdCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); +// //cfg.setTableName(CommonStringCfg.getTablename()); +// //commonPolicyDao.auditCfg(cfg); +// if(isAudit==1){ +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getScriberIdCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// } +// } //域名公共分组 - if(CollectionUtils.isNotEmpty(entity.getDomainCommGroupList())){ - CommonStringCfg cfg = new CommonStringCfg(); - BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); - //cfg.setTableName(CommonStringCfg.getTablename()); - //commonPolicyDao.auditCfg(cfg); - if(isAudit==1){ - Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getDomainCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - } - } +// if(CollectionUtils.isNotEmpty(entity.getDomainCommGroupList())){ +// CommonStringCfg cfg = new CommonStringCfg(); +// BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"}); +// //cfg.setTableName(CommonStringCfg.getTablename()); +// //commonPolicyDao.auditCfg(cfg); +// if(isAudit==1){ +// Map<String,List> map =ConfigConvertUtil.objGroupCfgConvert(serviceDictMap,strRegionList,entity.getDomainCommGroupList(),2,cfg,groupRelationList,maatTableMap,groupIdSet); +// groupRelationList=map.get("groupList"); +// strRegionList=map.get("dstList"); +// } +// } + end=System.currentTimeMillis(); + logger.info("配置转换完成,耗时"+(end-start1)+"ms"); //保存区域IP信息 List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId()); if(!StringUtil.isEmpty(areaIpCfgList)){ @@ -460,7 +535,6 @@ public class ObjectGroupService extends BaseService { areaIpRegionList=map.get("dstList"); } } - //构造提交综合服务参数格式,一条配置提交一次综合服务 if(isAudit==1){ maatCfg.initDefaultValue(); @@ -501,16 +575,22 @@ public class ObjectGroupService extends BaseService { maatBean.setCreatorName(entity.getCurrentUser().getName()); maatBean.setVersion(Constants.MAAT_VERSION); maatBean.setOpAction(opAction); + start1=System.currentTimeMillis(); //调用服务接口下发配置数据 String json=gsonToJson(maatBean); + end=System.currentTimeMillis(); + logger.info("json转换完成,耗时"+(end-start1)+"ms"); if(json.length()<Constants.JSON_PRINT_LENTH){ logger.info("策略对象组下发配置参数:"+json); }else{ logger.info("策略对象组下发配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印"); +// FileUtils.writeToFile("D:\\send.json",json,false); } //调用服务接口下发配置 + start1=System.currentTimeMillis(); ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("策略对象组下发响应信息:"+result.getMsg()); + end=System.currentTimeMillis(); + logger.info("策略对象组下发响应信息:"+result.getMsg()+",耗时"+(end-start1)); }else if(isAudit==3){ maatCfg.setCompileId(entity.getCompileId()); @@ -759,4 +839,57 @@ public class ObjectGroupService extends BaseService { public void saveAndSend(FunctionRegionDict regionDict, FunctionServiceDict serviceDict, List<BaseStringCfg<?>> stringCfgs) { } -}
\ No newline at end of file +} +class GetSubBeanThread implements Runnable{ + private CfgIndexInfo cfgIndexInfo; + private ObjectGroupDao objectGroupDao; + private boolean isDone=false; + private boolean isCancelled=false; + private boolean mayInterruptIfRunning=false; + private String groupName; + public GetSubBeanThread(CfgIndexInfo cfgIndexInfo,String groupName){ + this.cfgIndexInfo=cfgIndexInfo; + this.groupName=groupName; + } + @Override + public void run() { + getObjGroupPolicy(groupName); + isDone=true; + } + + public void getObjGroupPolicy(String groupName){ + if(cfgIndexInfo.getUserRegion().containsKey(groupName)){ + String ids=cfgIndexInfo.getUserRegion().get(groupName).toString().startsWith(",")?cfgIndexInfo.getUserRegion().get(groupName).toString().substring(1):cfgIndexInfo.getUserRegion().get(groupName).toString(); + ids=ids.endsWith(",")?ids.substring(0,ids.length()-1):ids; + if("ipGroup".equalsIgnoreCase(groupName)){ + List<IpCommCfg> ipList = objectGroupDao.getIpCommonList(ids,null); + // synchronized (cfgIndexInfo){ + cfgIndexInfo.setIpCommGroupCfgList(ipList); + // } + }else if("subscribeIdGroup".equalsIgnoreCase(groupName)){ + List<ScriberIdCommCfg> stringList=objectGroupDao.getScriberIdCommonList(ids,null); + //synchronized (cfgIndexInfo){ + cfgIndexInfo.setScriberIdCommGroupList(stringList); + // } + }else if("domainGroup".equalsIgnoreCase(groupName)){ + List<DomainCommCfg> stringList=objectGroupDao.getDomainCommonList(ids,null); + // synchronized (cfgIndexInfo){ + cfgIndexInfo.setDomainCommGroupList(stringList); + //} + }else if("urlGroup".equalsIgnoreCase(groupName)){ + List<UrlCommCfg> stringList = objectGroupDao.getUrlCommonList(ids,null); + // synchronized (cfgIndexInfo){ + cfgIndexInfo.setUrlCommGroupList(stringList); + // } + } + } + } + + public ObjectGroupDao getObjectGroupDao() { + return objectGroupDao; + } + + public void setObjectGroupDao(ObjectGroupDao objectGroupDao) { + this.objectGroupDao = objectGroupDao; + } +} diff --git a/src/main/webapp/WEB-INF/views/cfg/objgroup/list.jsp b/src/main/webapp/WEB-INF/views/cfg/objgroup/list.jsp index 906452842..7e09560b9 100644 --- a/src/main/webapp/WEB-INF/views/cfg/objgroup/list.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/objgroup/list.jsp @@ -428,7 +428,7 @@ </div> <sys:message content="${message}" type="${messageType }"/> <div class="table-responsive"> - <table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap"> + <table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap commonGroup"> <thead> <tr> <th><input type="checkbox" class="i-checks" id="checkAll"></th> |
