diff --git a/src/main/java/com/nis/domain/basics/AsnGroupInfo.java b/src/main/java/com/nis/domain/basics/AsnGroupInfo.java index 5cd534325..9adc16b1c 100644 --- a/src/main/java/com/nis/domain/basics/AsnGroupInfo.java +++ b/src/main/java/com/nis/domain/basics/AsnGroupInfo.java @@ -32,8 +32,17 @@ public class AsnGroupInfo extends BaseCfg implements Serializable{ private Integer isUsed; private Integer regionId; + private Integer orgGroupId; + + public Integer getOrgGroupId() { + return orgGroupId; + } + public void setOrgGroupId(Integer orgGroupId) { + this.orgGroupId = orgGroupId; + } + public Integer getIsUsed() { return isUsed; } diff --git a/src/main/java/com/nis/domain/configuration/AppPolicyCfg.java b/src/main/java/com/nis/domain/configuration/AppPolicyCfg.java index ea261c737..c18a26ce0 100644 --- a/src/main/java/com/nis/domain/configuration/AppPolicyCfg.java +++ b/src/main/java/com/nis/domain/configuration/AppPolicyCfg.java @@ -109,7 +109,7 @@ public class AppPolicyCfg extends BaseCfg { @SerializedName("isHexbin") private Integer isHexbin; - @ExcelField(title="log_total",sort=31) + @ExcelField(title="log_total",sort=43) private Long totalLogs; private List ipPortList; diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index eda499889..14814c0c8 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -199,17 +199,17 @@ public class BaseCfg extends BaseEntity implements Cloneable{ /** * 来函 */ - @ExcelField(title="letter",sort=58) + @ExcelField(title="letter",sort=60) protected String requestName; /** * 是否区域gk */ - @ExcelField(title="whether_area_block",dictType="WHETHER_AREA_BLOCK",sort=40) + @ExcelField(title="whether_area_block",dictType="WHETHER_AREA_BLOCK",sort=45) protected Integer isAreaEffective; /** * 分类 */ - @ExcelField(title="classification",dictType="type",sort=60) + @ExcelField(title="classification",dictType="type",sort=62) protected String classify; /** * 性质 @@ -270,9 +270,9 @@ public class BaseCfg extends BaseEntity implements Cloneable{ /** * do_log属性在界面(do_log:0不需要1记录所有日志2只记录结构化日志。默认是2) */ - @ExcelField(title="do_log",dictType="DO_LOG",sort=30) + @ExcelField(title="do_log",dictType="DO_LOG",sort=40) protected Integer doLog = Constants.MAAT_CFG_DOLOG_DEFAULT; - @ExcelField(title="do_blacklist",dictType="DO_BLACKLIST",sort=31) + @ExcelField(title="do_blacklist",dictType="DO_BLACKLIST",sort=41) protected Integer doBlackList=Constants.MAAT_CFG_DOLOG_DOBLACKLIST_DEFAULT; protected Integer groupId;//仅用于copy属性使用 protected Integer regionId;//仅用于copy属性使用 diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index 1f9c56baf..1d543f06b 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -43,24 +43,24 @@ public class BaseIpCfg extends BaseCfg { */ @Expose @SerializedName("ipType") - @ExcelField(title="ip_type",dictType="IP_TYPE",sort=44) + @ExcelField(title="ip_type",dictType="IP_TYPE",sort=50) protected Integer ipType; - @ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=45) + @ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=51) protected Integer ipPattern; - @ExcelField(title="client_ip",sort=47) + @ExcelField(title="client_ip",sort=53) protected String srcIpAddress; - @ExcelField(title="server_ip",sort=46) + @ExcelField(title="server_ip",sort=52) protected String destIpAddress; - @ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=48) + @ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=54) protected Integer portPattern; - @ExcelField(title="client_port",sort=49) + @ExcelField(title="client_port",sort=55) protected String srcPort; - @ExcelField(title="server_port",sort=50) + @ExcelField(title="server_port",sort=56) protected String destPort; protected Integer dnsStrategyId; - @ExcelField(title="ir_type",dictType="IR_TYPE",sort=51) + @ExcelField(title="ir_type",dictType="IR_TYPE",sort=57) protected Integer irType; - @ExcelField(title="group_name",sort=52) + @ExcelField(title="group_name",sort=58) protected String groupName; private List ntcSubscribeIdCfgList; @@ -75,7 +75,7 @@ public class BaseIpCfg extends BaseCfg { protected String organization; //仅用于copy属性使用 protected String country; //仅用于copy属性使用 protected String detail; //仅用于copy属性使用 - @ExcelField(title="log_total",sort=31) + @ExcelField(title="log_total",sort=42) private Long totalLogs; public String getOrganization() { @@ -177,14 +177,14 @@ public class BaseIpCfg extends BaseCfg { */ @Expose @SerializedName("direction") - @ExcelField(title="direction",dictType="DIRECTION",sort=53) + @ExcelField(title="direction",dictType="DIRECTION",sort=58) protected Integer direction ; /** * 协议 */ @Expose @SerializedName("protocol") - @ExcelField(title="protocol",dictType="PROTOCOL",sort=54) + @ExcelField(title="protocol",dictType="PROTOCOL",sort=59) protected Integer protocol ; /** * 协议ID diff --git a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java index 5ae686d8d..78f45ea8d 100644 --- a/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java +++ b/src/main/java/com/nis/domain/configuration/CfgIndexInfo.java @@ -86,12 +86,8 @@ public class CfgIndexInfo extends BaseCfg { private String country; private String detail; private List asnKeywords; - @ExcelField(title="log_total",sort=31) + @ExcelField(title="log_total",sort=42) private Long totalLogs; - @ExcelField(title="is_audit",dictType="AUDIT_STATUS",sort=20) - private Integer isAudit; - @ExcelField(title="do_log",dictType="DO_LOG",sort=27) - private Integer doLog = Constants.MAAT_CFG_DOLOG_DEFAULT; /*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数 @@ -102,19 +98,6 @@ public class CfgIndexInfo extends BaseCfg { } }*/ - - public Integer getIsValid() { - return isValid; - } - public void setIsValid(Integer isValid) { - this.isValid = isValid; - } - public Integer getDoLog() { - return doLog; - } - public void setDoLog(Integer doLog) { - this.doLog = doLog; - } public String getOrganization() { return organization; } diff --git a/src/main/java/com/nis/domain/configuration/DdosIpCfg.java b/src/main/java/com/nis/domain/configuration/DdosIpCfg.java index c06a292e5..d57e8d577 100644 --- a/src/main/java/com/nis/domain/configuration/DdosIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/DdosIpCfg.java @@ -23,29 +23,13 @@ public class DdosIpCfg extends BaseIpCfg { */ private static final long serialVersionUID = -5446903784736960824L; private String indexTable="ddos_ip_cfg"; - @ExcelField(title="antiddos_protocol",sort=41) + @ExcelField(title="antiddos_protocol",sort=46) private String antiddosProtocol;//目前支持TCP_SYN, DNS, NTP, - @ExcelField(title="bps_threadshold",sort=42) + @ExcelField(title="bps_threadshold",sort=47) private Long bpsThreadshold;// 即DDoS攻击保护动作触发阈值,每秒Bit数和每秒包数 - @ExcelField(title="pps_threadshold",sort=43) + @ExcelField(title="pps_threadshold",sort=48) private Long ppsThreadshold; - @ExcelField(title="log_total",sort=32) - private Long totalLogs; - @ExcelField(title="is_audit",dictType="AUDIT_STATUS",sort=20) - private Integer isAudit; - - public Integer getIsAudit() { - return isAudit; - } - public void setIsAudit(Integer isAudit) { - this.isAudit = isAudit; - } - public Long getTotalLogs() { - return totalLogs; - } - public void setTotalLogs(Long totalLogs) { - this.totalLogs = totalLogs; - } + public String getAntiddosProtocol() { return antiddosProtocol; } diff --git a/src/main/java/com/nis/domain/dashboard/TrafficIpActiveStatistic.java b/src/main/java/com/nis/domain/dashboard/TrafficIpActiveStatistic.java index 70e5e593d..6e31c4bb4 100644 --- a/src/main/java/com/nis/domain/dashboard/TrafficIpActiveStatistic.java +++ b/src/main/java/com/nis/domain/dashboard/TrafficIpActiveStatistic.java @@ -24,6 +24,8 @@ public class TrafficIpActiveStatistic{ String statTime; private String _byte; private String _packet; + private String avgByte; + private String avgPacket; @ExcelField(title="Byte",sort=51,type=1) public String get_byte() { return BigInteger.valueOf(this.getC2sByteLen()).add(BigInteger.valueOf(this.getS2cByteLen())).toString(); @@ -95,5 +97,16 @@ public class TrafficIpActiveStatistic{ public void setS2cByteLen(Long s2cByteLen) { this.s2cByteLen = s2cByteLen; } - + public String getAvgByte() { + return avgByte; + } + public void setAvgByte(String avgByte) { + this.avgByte = avgByte; + } + public String getAvgPacket() { + return avgPacket; + } + public void setAvgPacket(String avgPacket) { + this.avgPacket = avgPacket; + } } \ No newline at end of file diff --git a/src/main/java/com/nis/domain/log/NtcConnRecordLog.java b/src/main/java/com/nis/domain/log/NtcConnRecordLog.java index a8d1ca1fe..f056a776e 100644 --- a/src/main/java/com/nis/domain/log/NtcConnRecordLog.java +++ b/src/main/java/com/nis/domain/log/NtcConnRecordLog.java @@ -28,6 +28,17 @@ public class NtcConnRecordLog extends BaseLogEntity { @ExcelField(title = "Total Byte", sort = 49) protected String totalByte; + protected String ispCode;//运营商 + + + + public String getIspCode() { + return ispCode; + } + + public void setIspCode(String ispCode) { + this.ispCode = ispCode; + } public String getTotalPkt() { return totalPkt; diff --git a/src/main/java/com/nis/domain/report/NtcAsnRecord.java b/src/main/java/com/nis/domain/report/NtcAsnRecord.java index 5877e78ef..f3bdcbb55 100644 --- a/src/main/java/com/nis/domain/report/NtcAsnRecord.java +++ b/src/main/java/com/nis/domain/report/NtcAsnRecord.java @@ -6,8 +6,9 @@ import com.nis.util.excel.ExcelField; public class NtcAsnRecord extends BaseLogEntity{ private static final long serialVersionUID = -4947912502754359817L; - - @ExcelField(title="bps",sort=10) + @ExcelField(title="GBps",sort=10) + protected String GBps; + //@ExcelField(title="bps",sort=10) protected String bps; @ExcelField(title="pps",sort=9) protected String pps; @@ -26,7 +27,13 @@ public class NtcAsnRecord extends BaseLogEntity{ this.searchAsnType = searchAsnType; } protected String searchAsnType;//1:d_asn;2:s_asn - + + public String getGBps() { + return bps; + } + public void setGBps(String gBps) { + GBps = this.getBps(); + } public String getBps() { return bps; } diff --git a/src/main/java/com/nis/util/DateUtils.java b/src/main/java/com/nis/util/DateUtils.java index 2869881e6..af8731e7f 100644 --- a/src/main/java/com/nis/util/DateUtils.java +++ b/src/main/java/com/nis/util/DateUtils.java @@ -188,6 +188,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { long afterTime = after.getTime(); return (afterTime - beforeTime) / (1000 * 60 * 60 * 24); } + + /** + * 获取两个日期之间的秒数 + * + * @param before + * @param after + * @return + */ + public static double getSecondsOfTwoDate(Date before, Date after) { + long beforeTime = before.getTime(); + long afterTime = after.getTime(); + return (afterTime - beforeTime) / (1000); + } + /** * * diff --git a/src/main/java/com/nis/web/controller/basics/AsnGroupController.java b/src/main/java/com/nis/web/controller/basics/AsnGroupController.java index 083aec09a..75a9b34d9 100644 --- a/src/main/java/com/nis/web/controller/basics/AsnGroupController.java +++ b/src/main/java/com/nis/web/controller/basics/AsnGroupController.java @@ -23,6 +23,7 @@ import com.nis.domain.Page; import com.nis.domain.basics.AsnGroupInfo; import com.nis.domain.basics.AsnIpCfg; import com.nis.domain.specific.ConfigGroupInfo; +import com.nis.exceptions.MaatConvertException; import com.nis.util.StringUtil; import com.nis.web.controller.BaseController; /** @@ -83,8 +84,13 @@ public class AsnGroupController extends BaseController { asnGroupInfoService.saveOrUpdate(cfg); addMessage(redirectAttributes,"success","save_success"); } catch (Exception e) { - logger.error("新增失败",e); - addMessage(redirectAttributes,"error","save_failed"); + e.printStackTrace(); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error", "request_service_failed"); + }else { + addMessage(redirectAttributes,"error","save_failed"); + } + } return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList"; @@ -99,15 +105,19 @@ public class AsnGroupController extends BaseController { */ //@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del"},logical=Logical.OR) @RequestMapping(value={"delete"}) - public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds) { + public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds,String groupIds) { try { - asnGroupInfoService.delete(ids,asnIds); + asnGroupInfoService.delete(ids,asnIds,groupIds); //TODO 查询本次删除的所有asnOrg组中是否存在asn 没有is_used=0的asn,如果存在则需要将整个组删除 addMessage(redirectAttributes,"success","delete_success"); } catch (Exception e) { logger.error("删除失败",e); - addMessage(redirectAttributes,"error","delete_failed"); + if(e instanceof MaatConvertException) { + addMessage(redirectAttributes,"error", "request_service_failed"); + }else { + addMessage(redirectAttributes,"error","delete_failed"); + } } return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList"; } @@ -162,14 +172,16 @@ public class AsnGroupController extends BaseController { */ @ResponseBody @RequestMapping(value = {"/checkAsnNo"}) - public boolean checkIp(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){ - - AsnGroupInfo policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg); - if(policyGroup == null){ - return true; + public AsnGroupInfo checkAsnNo(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){ + AsnGroupInfo policyGroup=null; + policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg); + if(policyGroup != null){ + ConfigGroupInfo group=configGroupInfoService.getAsnOrganization(policyGroup.getOrganization()); + if(group != null){ + policyGroup.setCommonGroupIds(group.getGroupId().toString()); + } } - - return false; + return policyGroup; } /** * 校验asn号是否已存在 @@ -182,7 +194,6 @@ public class AsnGroupController extends BaseController { if(asnIpCfg == null){ return false; } - return true; } /** diff --git a/src/main/java/com/nis/web/controller/configuration/maintenance/DnsIpCfgController.java b/src/main/java/com/nis/web/controller/configuration/maintenance/DnsIpCfgController.java index f28836828..4b77aebec 100644 --- a/src/main/java/com/nis/web/controller/configuration/maintenance/DnsIpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/maintenance/DnsIpCfgController.java @@ -218,7 +218,7 @@ public class DnsIpCfgController extends BaseController { } titleList.add(entity.getMenuNameCode()); classMap.put(entity.getMenuNameCode(), DnsIpCfg.class); - String cfgIndexInfoNoExport = ",whether_area_block,client_ip,port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; + String cfgIndexInfoNoExport = ",log_total,whether_area_block,client_ip,port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,"; // 时间过滤 if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) { diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java index 6a8fb2863..fa5615f78 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/WhiteListController.java @@ -500,12 +500,14 @@ public class WhiteListController extends CommonController { for (Integer id : set) { serviceIds.append(id+","); } - String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1); - String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1); - //获取日志总量 - if(!StringUtils.isBlank(serviceIdsStr)&&!StringUtils.isBlank(compileIdsStr)){ - List> logs = getLogTotal( null,serviceIdsStr,compileIdsStr); - logTotals.addAll(logs); + if(serviceIds.length()>1&&compileIds.length()>1){ + String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1); + String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1); + //获取日志总量 + if(!StringUtils.isBlank(serviceIdsStr)&&!StringUtils.isBlank(compileIdsStr)){ + List> logs = getLogTotal( null,serviceIdsStr,compileIdsStr); + logTotals.addAll(logs); + } } titleList.add(entity.getMenuNameCode()); titleList.add("NTC_HTTP_URL"); diff --git a/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java index c3f01a4e5..77c77c68e 100644 --- a/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java +++ b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java @@ -3,9 +3,11 @@ package com.nis.web.controller.configuration.proxy; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -273,6 +275,35 @@ public class InterceptController extends CommonController { Page page = ipCfgService.getIpCfgList(pageInfo, entity); ipLists = page.getList(); } + //日志总量 + List> logTotals=new ArrayList>(); + StringBuilder compileIds=new StringBuilder(",");//配置ids + Set set=new HashSet();//服务ids + for (CfgIndexInfo cfg : ipLists) { + if(cfg.getIsAudit()!=0){ + set.add(cfg.getServiceId()); + compileIds.append(cfg.getCompileId()+","); + }else{ + Map logTotal=new HashMap(); + logTotal.put("compileId", cfg.getCompileId()+""); + logTotal.put("sum",0L); + logTotals.add(logTotal); + } + + } + StringBuilder serviceIds=new StringBuilder(","); + for (Integer id : set) { + serviceIds.append(id+","); + } + if(serviceIds.length()>1&&compileIds.length()>1){ + String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1); + String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1); + //获取日志总量 + if(!StringUtils.isBlank(serviceIdsStr)&&!StringUtils.isBlank(compileIdsStr)){ + List> logs = getLogTotal( null,serviceIdsStr,compileIdsStr); + logTotals.addAll(logs); + } + } // 获取证书信息 List certificateList = new ArrayList(); if (entity.getFunctionId().equals(200)) { @@ -325,6 +356,12 @@ public class InterceptController extends CommonController { List httpUrlList = new ArrayList(); List pktBinList = new ArrayList(); for (CfgIndexInfo cfg : ipLists) { + for (Map logTotal : logTotals) { + if(cfg.getCompileId().equals(Integer.parseInt((String) logTotal.get("compileId")))){ + cfg.setTotalLogs((Long)logTotal.get("sum")); + break; + } + } Map maps = interceptCfgService.exportIpInfo(cfg); httpUrlList.addAll(maps.get("NTC_HTTP_URL")); ipList.addAll(maps.get("PXY_INTERCEPT_IP")); @@ -346,7 +383,7 @@ public class InterceptController extends CommonController { httpUrlList = BaseStringCfg.baseHexList(httpUrlList); dataMap.put(entity.getMenuNameCode(), ipLists); if (entity.getFunctionId() == 212) { // IP Payload - cfgIndexInfoNoExport = ",do_log,log_total,policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-"; + cfgIndexInfoNoExport = ",policy_name,group_name,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-"; titleList.add("PXY_INTERCEPT_IP"); titleList.add("PXY_INTERCEPT_PKT_BIN"); classMap.put("PXY_INTERCEPT_IP", IpPortCfg.class); diff --git a/src/main/java/com/nis/web/controller/dashboard/DashboardController.java b/src/main/java/com/nis/web/controller/dashboard/DashboardController.java index 62eab0f26..3a3e1226d 100644 --- a/src/main/java/com/nis/web/controller/dashboard/DashboardController.java +++ b/src/main/java/com/nis/web/controller/dashboard/DashboardController.java @@ -3,6 +3,7 @@ package com.nis.web.controller.dashboard; import java.lang.reflect.Type; import java.net.URISyntaxException; import java.net.URLEncoder; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; @@ -248,7 +249,7 @@ public class DashboardController extends BaseController{ @ResponseBody public List ajaxIpActiveList(String beginDate,String endDate,Integer entranceId){ Map fromJsonList = new HashMap(); - List list = new ArrayList(); + List list = new ArrayList(); try { String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE_ONEHOUR; url=urlAddDate(url, beginDate, endDate); @@ -260,6 +261,16 @@ public class DashboardController extends BaseController{ fromJsonList = gson.fromJson(string, new TypeToken>(){}.getType()); logger.debug("活跃IP1小时"+fromJsonList); list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken>() {}.getType()) ; + if(list.size()>0) { + DecimalFormat lf = new DecimalFormat("0"); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //两个时间段之间的秒数 + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); + for(TrafficIpActiveStatistic data:list) { + data.setAvgByte(lf.format(Integer.parseInt(data.get_byte())*8/allSeconds)); + data.setAvgPacket(lf.format(Integer.parseInt(data.get_packet())/allSeconds)); + } + } Collections.sort(list, new Comparator() { @Override @@ -282,7 +293,7 @@ public class DashboardController extends BaseController{ } catch (Exception e) { e.printStackTrace(); logger.error("活跃IP数据获取错误"+e); - list.add(Maps.newHashMap("error","request_service_failed")); + //list.add(Maps.newHashMap("error","request_service_failed")); } return list; } diff --git a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java index 8a1b1f156..a9e08f57d 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsInfoController.java @@ -44,6 +44,7 @@ import com.nis.domain.dashboard.TrafficIpActiveStatistic; import com.nis.util.CodeDicUtils; import com.nis.util.Constants; import com.nis.util.DateUtil; +import com.nis.util.DateUtils; import com.nis.util.DictUtils; import com.nis.util.StringUtil; import com.nis.util.httpclient.HttpClientUtil; @@ -301,6 +302,7 @@ public class TrafficStatisticsInfoController extends BaseController { @RequestMapping(value="protocolList") @ResponseBody public List protocolList(Model model,Integer entranceId,Integer[] protoType,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){ + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Map fromJsonList = new HashMap(); List list = new ArrayList(); String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST; @@ -327,6 +329,8 @@ public class TrafficStatisticsInfoController extends BaseController { DecimalFormat lf = new DecimalFormat("0"); DecimalFormat df = new DecimalFormat("0.0000000000"); List appCodeList = CodeDicUtils.getCodeList("appCode"); + //两个时间段之间的秒数 + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); if(!StringUtil.isEmpty(list)){ for (Object object : list) { Map m=(Map) object; @@ -336,6 +340,10 @@ public class TrafficStatisticsInfoController extends BaseController { m.put("GByte", df.format(m.get("GByte"))); m.put("packets", lf.format(m.get("packets"))); m.put("linkNum", lf.format(m.get("linkNum"))); + double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds; + m.put("pps",lf.format(avgPacket)); + double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds; + m.put("bps",lf.format(avgByte)); totalLink+=Long.parseLong( m.get("linkNum").toString()); totalPackets+=Long.parseLong(m.get("packets").toString()); // 协议没匹配的匹配app码表 @@ -407,6 +415,9 @@ public class TrafficStatisticsInfoController extends BaseController { Double totalGByte=0d; DecimalFormat lf = new DecimalFormat("0"); DecimalFormat df = new DecimalFormat("0.0000000000"); + //两个时间段之间的秒数 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); if(!StringUtil.isEmpty(list)){ for (Object object : list) { Map m=(Map) object; @@ -417,6 +428,11 @@ public class TrafficStatisticsInfoController extends BaseController { m.put("linkNum", lf.format(m.get("linkNum"))); totalLink+=Long.parseLong( m.get("linkNum").toString()); totalPackets+=Long.parseLong(m.get("packets").toString()); + + double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds; + m.put("pps",lf.format(avgPacket)); + double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds; + m.put("bps",lf.format(avgByte)); } for (Object object : list) { Map m=(Map) object; @@ -485,7 +501,7 @@ public class TrafficStatisticsInfoController extends BaseController { @ResponseBody public List ajaxAppTopList(String beginDate,String endDate,Integer appType,Integer entranceId,Integer searchQuota,Model model){ Map fromJsonList = new HashMap(); - List list = new ArrayList(); + List list = new ArrayList(); try { String url=Constants.DASHBOARD_URL+Constants.APPCONN_RECORD_TOP100; URIBuilder uriBuilder = new URIBuilder(url); @@ -508,7 +524,18 @@ public class TrafficStatisticsInfoController extends BaseController { fromJsonList = gson.fromJson(string, new TypeToken>(){}.getType()); logger.debug("app列表Top100"+fromJsonList); list = (ArrayList) fromJsonList.get("data"); - + if(list.size()>0) { + //两个时间段之间的秒数 + DecimalFormat dl = new DecimalFormat("0"); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); + for(Map m:list) { + double avgPacket=Double.parseDouble(m.get("pktNum").toString())/allSeconds; + m.put("pps",dl.format(avgPacket)); + double avgByte=Double.parseDouble(m.get("byteNum").toString())*8/allSeconds; + m.put("bps",dl.format(avgByte)); + } + } } catch (Exception e) { e.printStackTrace(); logger.error("app列表Top100"+e); @@ -610,6 +637,9 @@ public class TrafficStatisticsInfoController extends BaseController { // Double totalLink=0d; Double totalGbyte=0d; Double totalPackets=0d; + //两个时间段之间的秒数 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); for (Object object : list) { Map m=(Map)object; Double count=(Double)m.get("byteCount"); @@ -618,6 +648,11 @@ public class TrafficStatisticsInfoController extends BaseController { totalPackets+=(Double)m.get("pktCount"); String format = df.format(count/1024/1024/1024); m.put("Gbyte", format); + + double avgPacket=Double.parseDouble(m.get("pktCount").toString())/allSeconds; + m.put("pps",dl.format(avgPacket)); + double avgByte=Double.parseDouble(m.get("byteCount").toString())*8/allSeconds; + m.put("bps",dl.format(avgByte)); } List codeList = appCfgService.getDomainDict(new WebsiteDomainTopic()); Map map = new HashMap(); @@ -687,12 +722,19 @@ public class TrafficStatisticsInfoController extends BaseController { Long totalPackets=0l; Double totalGByte=0d; DecimalFormat lf = new DecimalFormat("0"); + //两个时间段之间的秒数 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate)); if(!StringUtil.isEmpty(list)){ for (Object object : list) { Map m=(Map) object; totalLink+=Long.parseLong(lf.format(m.get("linkNum"))); totalPackets+=Long.parseLong(lf.format(m.get("packets"))); totalGByte+=Double.parseDouble(lf.format(m.get("count"))); + double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds; + m.put("pps",lf.format(avgPacket)); + double avgByte=Double.parseDouble(m.get("count").toString())*8/allSeconds; + m.put("bps",lf.format(avgByte)); m.remove("domainData"); Double value1=0d; if(StringUtil.isBlank(m.get("topicId").toString())){ diff --git a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java index 8593cc1be..a1f24ef78 100644 --- a/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java +++ b/src/main/java/com/nis/web/controller/dashboard/TrafficStatisticsReportController.java @@ -87,11 +87,11 @@ public class TrafficStatisticsReportController extends BaseController { // statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天 // endTime=DateUtils.getDateTime(); - Calendar cal = Calendar.getInstance(); - cal.setTime(new Date()); - endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());// 获取到完整的时间 - cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); - statTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime()); + Calendar time = Calendar.getInstance(); + endTime = DateUtils.formatDateTimeByParm(time.getTime(),"yyyy-MM-dd HH")+":00:00"; + time.add(Calendar.HOUR_OF_DAY, -1); + statTime = DateUtils.formatDateTimeByParm(time.getTime(),"yyyy-MM-dd HH")+":00:00";; + bean.setSearchFoundStartTime(statTime); bean.setSearchFoundEndTime(endTime); statTime = URLEncoder.encode(statTime, "UTF-8"); diff --git a/src/main/java/com/nis/web/controller/log/ntc/HttpRecordLogController.java b/src/main/java/com/nis/web/controller/log/ntc/HttpRecordLogController.java index 5c4d7d93a..88a2ab78a 100644 --- a/src/main/java/com/nis/web/controller/log/ntc/HttpRecordLogController.java +++ b/src/main/java/com/nis/web/controller/log/ntc/HttpRecordLogController.java @@ -65,7 +65,7 @@ public class HttpRecordLogController extends BaseController { } List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); - serviceList.addAll(DictUtils.getFunctionServiceDictList(635)); +// serviceList.addAll(DictUtils.getFunctionServiceDictList(635)); model.addAttribute("serviceList", serviceList); String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_RECORD_LOG; @@ -133,7 +133,7 @@ public class HttpRecordLogController extends BaseController { } List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); - serviceList.addAll(DictUtils.getFunctionServiceDictList(635)); +// serviceList.addAll(DictUtils.getFunctionServiceDictList(635)); model.addAttribute("serviceList", serviceList); String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_RECORD_LOG; diff --git a/src/main/java/com/nis/web/controller/log/ntc/MailRecordLogController.java b/src/main/java/com/nis/web/controller/log/ntc/MailRecordLogController.java index e9f077f8c..2b16197f3 100644 --- a/src/main/java/com/nis/web/controller/log/ntc/MailRecordLogController.java +++ b/src/main/java/com/nis/web/controller/log/ntc/MailRecordLogController.java @@ -150,7 +150,7 @@ public class MailRecordLogController extends BaseController { } else { hColumns += ","; } - String cfgIndexInfoNoExport = "," + hColumns; + String cfgIndexInfoNoExport = ",action,cfg_id," + hColumns; noExportMap.put("mail_record", cfgIndexInfoNoExport); dataMap.put("mail_record", list); String timeRange = initLogMap(log, "mail_record"); diff --git a/src/main/java/com/nis/web/controller/log/ntc/NtcConnRecordLogController.java b/src/main/java/com/nis/web/controller/log/ntc/NtcConnRecordLogController.java index 705131779..acf3f175b 100644 --- a/src/main/java/com/nis/web/controller/log/ntc/NtcConnRecordLogController.java +++ b/src/main/java/com/nis/web/controller/log/ntc/NtcConnRecordLogController.java @@ -98,8 +98,9 @@ public class NtcConnRecordLogController extends BaseController { if (StringUtils.isNotBlank(log.getdSubscribeId())) { params.put("searchDSubscribeId", log.getdSubscribeId()); } - - + if (StringUtils.isNotBlank(log.getIspCode())) { + params.put("searchIspCode", log.getIspCode()); + } model.addAttribute("appList", appList); model.addAttribute("protocolList", protocolList); model.addAttribute("webList", webList); @@ -240,9 +241,9 @@ public class NtcConnRecordLogController extends BaseController { if (StringUtils.isNotBlank(log.getdSubscribeId())) { params.put("searchDSubscribeId", log.getdSubscribeId()); } - - - + if (StringUtils.isNotBlank(log.getIspCode())) { + params.put("searchIspCode", log.getIspCode()); + } model.addAttribute("appList", appList); model.addAttribute("protocolList", protocolList); model.addAttribute("webList", webList); diff --git a/src/main/java/com/nis/web/controller/log/ntc/SslRecordLogController.java b/src/main/java/com/nis/web/controller/log/ntc/SslRecordLogController.java index f2b9d7b44..12524cf20 100644 --- a/src/main/java/com/nis/web/controller/log/ntc/SslRecordLogController.java +++ b/src/main/java/com/nis/web/controller/log/ntc/SslRecordLogController.java @@ -137,7 +137,7 @@ public class SslRecordLogController extends BaseController { } else { hColumns += ","; } - String cfgIndexInfoNoExport = "," + hColumns; + String cfgIndexInfoNoExport = ",action,cfg_id," + hColumns; noExportMap.put("ssl_record", cfgIndexInfoNoExport); dataMap.put("ssl_record", list); String timeRange = initLogMap(log, "ssl_record"); diff --git a/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.java b/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.java index ce497c857..541a587a1 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.java +++ b/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.java @@ -30,6 +30,6 @@ public interface AsnGroupInfoDao extends CrudDao { Long getCount(); void modifyIssuedIp(AsnGroupInfo info); List findAsnGroupInfoByAsnGroup(AsnGroupInfo asnGroupInfo); - void updateIsUsedAndIsValid(@Param("asnNos")List asnNos,@Param("isUsed")Integer isUsed,@Param("isValid")Integer isValid); - List findAsnGroupInfoByAsnNos(@Param("asnNos")List asnNos,@Param("isUsed")Integer isUsed); + void updateIsUsedAndIsValid(@Param("groupIds")List groupIds,@Param("isUsed")Integer isUsed,@Param("isValid")Integer isValid); + List findAsnGroupInfoByGroupIds(@Param("groupIds")List groupIds,@Param("isUsed")Integer isUsed); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.xml b/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.xml index ff55e5c6f..49f5f55f9 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.xml +++ b/src/main/java/com/nis/web/dao/basics/AsnGroupInfoDao.xml @@ -17,10 +17,11 @@ + r.id,r.group_id,r.compile_id,r.organization,r.country,r.detail,r.is_valid,r.create_time,r.edit_time, - r.creator_id,r.editor_id,r.asn_id,r.issued_ips,r.is_used,r.region_id + r.creator_id,r.editor_id,r.asn_id,r.issued_ips,r.is_used,r.region_id,r.org_group_id @@ -62,6 +63,9 @@ AND r.is_valid =#{isValid } + + + AND r.org_group_id =#{orgGroupId } AND r.is_valid !=-1 @@ -102,7 +106,8 @@ edit_time, asn_id, is_used, - region_id + region_id, + org_group_id )values ( #{groupId,jdbcType=INTEGER}, #{compileId,jdbcType=INTEGER}, @@ -116,7 +121,8 @@ #{editTime,jdbcType=TIMESTAMP}, #{asnId,jdbcType=INTEGER}, #{isUsed,jdbcType=INTEGER}, - #{regionId,jdbcType=INTEGER} + #{regionId,jdbcType=INTEGER}, + #{orgGroupId,jdbcType=INTEGER} ) @@ -159,6 +165,9 @@ region_id = #{regionId,jdbcType=INTEGER}, + + + org_group_id = #{orgGroupId,jdbcType=INTEGER}, @@ -181,10 +190,10 @@ - - and asn_id in - - #{asnId} + + and group_id in + + #{groupId} @@ -351,7 +360,7 @@ - SELECT FROM @@ -360,11 +369,11 @@ AND r.is_used = #{isUsed,jdbcType=INTEGER} - - and r.asn_id in - - #{asnId} - + + and r.group_id in + + #{groupId} + diff --git a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java index 785ee0cf3..c55de5106 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java +++ b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java @@ -33,6 +33,6 @@ public interface AsnIpCfgDao extends CrudDao{ public void ajaxDeleteAsnIp(@Param("ids")String ids); public int hasValidAsnIp(@Param("asnId")Long asnNo); public AsnIpCfg getOne(AsnIpCfg cfg); - public void updateAsn(@Param("asnId")String asnNo,@Param("organization")String organization,@Param("country")String country,@Param("detail")String detail); + public void updateAsn(@Param("asnId")String asnNo,@Param("organization")String organization,@Param("country")String country,@Param("detail")String detail,@Param("groupId")String groupId); public void updateAsnIpByAsnGroups(@Param("entity")AsnIpCfg entity,@Param("asnGroups")List asnGroups,@Param("asnIds")String asnIds); } diff --git a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml index 2071ab66d..ce0cd9c42 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml @@ -560,7 +560,7 @@ delete from asn_ip_cfg where asn_ip_group in (${ids}) - update asn_ip_cfg set organization=#{organization}, country=#{country}, detail=#{detail} where user_region1 =#{asnId} and is_valid=0 + update asn_ip_cfg set organization=#{organization}, country=#{country}, detail=#{detail},user_region1 =#{asnId} where asn_ip_group =#{groupId} and is_valid=0 + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/specific/ConfigGroupInfoDao.xml b/src/main/java/com/nis/web/dao/specific/ConfigGroupInfoDao.xml index c182b566f..210559517 100644 --- a/src/main/java/com/nis/web/dao/specific/ConfigGroupInfoDao.xml +++ b/src/main/java/com/nis/web/dao/specific/ConfigGroupInfoDao.xml @@ -130,4 +130,21 @@ + + UPDATE config_group_info + + update_time=now(), + + group_name =#{groupName}, + + + + + and group_type =#{groupType} + + + and group_id =#{groupId} + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 9542abb44..3395276b9 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -547,25 +547,11 @@ public abstract class BaseService { dstList.add(cfg); } } else if (cfgType == 7) { //ASN关键字配置 - /*//TODO 下发之前是否需要增加asn号的有效性校验,创建配置和下发配置不是在同一时间 - //TODO 考虑增加配置id、表名和ASN组织,以及ASN NO的关系。 - //TODO 如果ASNO 和组织关系没有了,数据需要清理,asn组织和配置id关系没有了,也需要清理 - int regionNum=0; - //多个ASNNO存在一个ASN关键字配置中, - for (int i = 0; i < srcList.size(); i++) { - AsnKeywordCfg asnKeywordCfg=(AsnKeywordCfg)srcList.get(i); - regionNum+=asnKeywordCfg.getCfgKeywords().split(",").length; - - } - - //List groupIdList = ConfigServiceUtil.getId(2, srcList.size()); - List regionIdList = ConfigServiceUtil.getId(3, regionNum); - Integer regionIndex=0;*/ List listGroupId=new ArrayList<>(); for (int i = 0; i < srcList.size(); i++) { AsnKeywordCfg asnKeywordCfg = (AsnKeywordCfg)srcList.get(i); GroupCfg group = new GroupCfg(); - group.setGroupId(Integer.parseInt(asnKeywordCfg.getUserRegion1())); + group.setGroupId(asnKeywordCfg.getGroupId()); group.setCompileId(baseCfg.getCompileId()); group.setAuditTime(baseCfg.getAuditTime()); group.setIsValid(baseCfg.getIsValid()); @@ -580,7 +566,6 @@ public abstract class BaseService { StringCfg cfg = new StringCfg(); BeanUtils.copyProperties(asnKeywordCfg, cfg); cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(Integer.parseInt(asnKeywordCfg.getUserRegion2())); cfg.setAuditTime(baseCfg.getAuditTime()); cfg.setIsValid(baseCfg.getIsValid()); // 处理配置关键字转译 @@ -3010,14 +2995,9 @@ public abstract class BaseService { if(!StringUtil.isEmpty(asnList)){ AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class); ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class); - - //1、修改域配置为下发状态 - AsnKeywordCfg asnCfg=new AsnKeywordCfg(); - BeanUtils.copyProperties(entity, asnCfg); - asnCfg.setTableName(AsnKeywordCfg.getTablename()); - IpCfgDao ipCfgDao=SpringContextHolder.getBean(IpCfgDao.class); - ipCfgDao.auditCfg(asnCfg); - + StringCfgDao stringCfgDao=SpringContextHolder.getBean(StringCfgDao.class); + //域和分组的关系 + Map groupWithRegion=new HashMap<>(); //需要标记为下发全部域的groupId集合 List signAuditAllGroupList=new ArrayList<>(); //需要标记下发的groupId @@ -3026,59 +3006,56 @@ public abstract class BaseService { List auditRegionList=new ArrayList<>(); //所有未被策略过的域 List notAuditRegionList=new ArrayList<>(); - //域和分组的关系 - Map groupWithRegion=new HashMap<>(); //所有策略所选asn No - List asnNoList=new ArrayList<>(); + List asnGroupIdList=new ArrayList<>(); //所有未下发过的asnNo - List notAuditAsnNoList=new ArrayList<>(); + List notAuditGroupIdList=new ArrayList<>(); //最新的asn域集合 List newAsnList=new ArrayList<>(); //2、记录标记为下发all的groupId|存储组和asnno的关系|记录需要标记为已下发的group for (AsnKeywordCfg asnKeywordCfg : asnList) { - asnKeywordCfg.setUserRegion2(StringUtil.isEmpty(asnKeywordCfg.getUserRegion2()) ? "1":"0"); - if("1".equals(asnKeywordCfg.getUserRegion2())){ //是否标记为下发ALL - signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1())); + // + asnKeywordCfg.setUserRegion4(StringUtil.isEmpty(asnKeywordCfg.getUserRegion4()) ? "1":"0"); + if("1".equals(asnKeywordCfg.getUserRegion4())){ //是否标记为下发ALL + signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion4())); } - for (String asnstr: asnKeywordCfg.getCfgKeywords().split(",")) { - groupWithRegion.put(asnstr, asnKeywordCfg.getUserRegion1()); + groupWithRegion.put(asnKeywordCfg.getUserRegion2(), asnKeywordCfg.getUserRegion3()); + //需要标记为is_used=1的组织 + if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion3()))){ + isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion3())); } - if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion1()))){ - isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1())); - } - List list=Arrays.asList(asnKeywordCfg.getCfgKeywords().split(",")); - asnNoList.addAll(list); + //需要标记为is_used=1的asn no,根据groupId + asnGroupIdList.add(asnKeywordCfg.getUserRegion2()); + + AsnKeywordCfg asnCfg=new AsnKeywordCfg(); + BeanUtils.copyProperties(entity, asnCfg,new String[]{"cfgId","userReigon1","userReigon2","userReigon3","userReigon4","userReigon5"}); + asnCfg.setTableName(AsnKeywordCfg.getTablename()); + stringCfgDao.updateAsnKeyword(asnCfg); } - - //3、//根据asnNoList查询所有下发过的ASN NO - if(!StringUtil.isEmpty(asnNoList)){ - auditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 1); + //3、//根据asnGroupIdList查询所有下发过的ASN NO + if(!StringUtil.isEmpty(asnGroupIdList)){ + auditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 1); } - //已下发过的ASN NO只需要下发组 + //已下发过的asn groupId只需要下发组 if(!StringUtil.isEmpty(auditRegionList)){ for (AsnGroupInfo asnGroupInfo : auditRegionList) { AsnKeywordCfg cfg = new AsnKeywordCfg(); - cfg.initDefaultValue(); - cfg.setTableName(AsnKeywordCfg.getTablename()); - cfg.setCfgType(asnList.get(0).getCfgType()); cfg.setCompileId(entity.getCompileId()); - cfg.setCfgKeywords(asnGroupInfo.getGroupId().toString());//关键字 - cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //组号 - cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid + cfg.setRegionId(asnGroupInfo.getRegionId()); + cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //组号 cfg.setUserRegion3("0"); //是否下发域 cfg.setIsAudit(entity.getIsAudit()); cfg.setIsValid(entity.getIsValid()); cfg.setAuditorId(entity.getAuditorId()); cfg.setAuditTime(entity.getAuditTime()); - cfg.setFunctionId(entity.getFunctionId()); newAsnList.add(cfg); } } //4、查询所有未下发过的 ASN NO - if(!StringUtil.isEmpty(asnNoList)){ - notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 0); + if(!StringUtil.isEmpty(asnGroupIdList)){ + notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(asnGroupIdList, 0); } if(!StringUtil.isEmpty(notAuditRegionList)){ @@ -3089,8 +3066,8 @@ public abstract class BaseService { cfg.setCompileId(entity.getCompileId()); cfg.setCfgType(asnList.get(0).getCfgType()); cfg.setCfgKeywords(asnGroupInfo.getAsnId().toString());//关键字 - cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //groupId - cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid + cfg.setGroupId(Integer.parseInt(groupWithRegion.get(asnGroupInfo.getGroupId().toString()))); //groupId + cfg.setRegionId(asnGroupInfo.getRegionId());//regionid cfg.setUserRegion3("1"); //是否下发域 cfg.setIsAudit(entity.getIsAudit()); cfg.setIsValid(entity.getIsValid()); @@ -3098,3363 +3075,12 @@ public abstract class BaseService { cfg.setAuditTime(entity.getAuditTime()); cfg.setFunctionId(entity.getFunctionId()); newAsnList.add(cfg); - notAuditAsnNoList.add(asnGroupInfo.getAsnId().toString()); + notAuditGroupIdList.add(asnGroupInfo.getGroupId().toString()); } } - //5、修改所有下发的asn no为已下发 - if(!StringUtil.isEmpty(notAuditAsnNoList)){ - asnGroupInfoDao.updateIsUsedAndIsValid(notAuditAsnNoList,1,null); - } - //6、标记组已被策略标记为全部下发 - configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList ); - //7、标记组已被策略引用 - configGroupInfoDao.updateIsUsed(4, 1, isUsedGroupIdList); - //8、maat配置转换 - if(!StringUtil.isEmpty(newAsnList)){ - Map map = cfgConvert(strRegionList,newAsnList,7,entity,groupRelationList); - } - } - - - /*if(asnList!=null && asnList.size()>0){ - - for (AsnKeywordCfg asnKeywordCfg : asnList) { - asnNoStr+=asnKeywordCfg.getCfgKeywords()+","; - } - - AsnKeywordCfg cfg = new AsnKeywordCfg(); - cfg.setTableName(AsnKeywordCfg.getTablename()); - cfg.setCompileId(entity.getCompileId()); - cfg.setIsAudit(entity.getIsAudit()); - cfg.setIsValid(entity.getIsValid()); - cfg.setAuditorId(entity.getAuditorId()); - cfg.setAuditTime(entity.getAuditTime()); - cfg.setFunctionId(entity.getFunctionId()); - ipCfgDao.auditCfg(cfg); - Map map = cfgConvert(strRegionList,asnList,7,entity,groupRelationList); - groupRelationList=map.get("groupList"); - strRegionList=map.get("dstList"); - } - //修改配置选中的ASN NO 和 asn orga是否被策略引用过 - if(!StringUtil.isEmpty(asnNoStr)){ - asnNoStr=asnNoStr.substring(0, asnNoStr.length()-1); - if(!StringUtil.isEmpty(asnNoStr)){ - //如果asnGroup由is_use=0,修改为is_use=1;查询asn no下所有未下发的asn ip,并进行下发,走POST接口【暂时不考虑】 - AsnIpCfgDao asnIpCfgDao=SpringContextHolder.getBean(AsnIpCfgDao.class); - AsnIpCfg asnIp=new AsnIpCfg(); - asnIp.setIsAudit(0); - asnIp.setIsValid(0); - List asnIpList=asnIpCfgDao.findAllListByAsnGroup(asnIp, null, asnNoStr); - - //下发asn IP和修改asn ip的状态必须在一个事物中 - //重新修改下发时间,下发人员信息 - AsnIpCfg auditAsnIpCfg=new AsnIpCfg(); - auditAsnIpCfg.setIsAudit(1); - auditAsnIpCfg.setAuditTime(new Date()); - auditAsnIpCfg.setAuditorId(UserUtils.getUser().getId()); - auditAsnIpCfg.setIsValid(1); - auditAllAsnRegionCfg(auditAsnIpCfg, null, asnNoStr); - - AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class); - asnGroupInfoDao.updateIsUsed(asnNoStr, 1); - } - }*/ - - } - - /** - * 配置取消时,需要将公共组id发送至服务端 - * @param maatCfg - * @param entity - * @return - */ - public MaatCfg addKeepGroupList(MaatCfg maatCfg,BaseCfg entity){ - if(!StringUtil.isEmpty(entity.getCommonGroupIds())){ - List keepGroupList = new ArrayList(); - String[] orgGroupIds=entity.getCommonGroupIds().split(","); - for (int i = 0; i < orgGroupIds.length; i++) { - if(!StringUtil.isEmpty(orgGroupIds[i])){ - GroupCfg groupCfg=new GroupCfg(); - groupCfg.setGroupId(Integer.parseInt(orgGroupIds[i])); - keepGroupList.add(groupCfg); - } - } - if(!StringUtil.isEmpty(keepGroupList)){ - maatCfg.setKeepGroupList(keepGroupList); - } - } - return maatCfg; - } - - /** - * 公共组新增域 - * @param srcMap - * @param isValid - * @param cfgType - * @param commonType 公共组类型 4 ASN - * @return - */ - public static List convertCommonRegion(Map> srcMap,List commonGroupList,Integer isValid,Integer cfgType,Integer commonType) { - for (Integer groupId : srcMap.keySet()) { - GroupReuseCfg groupCfg=new GroupReuseCfg(); - List strRegionList=new ArrayList<>(); - List ipRegionList=new ArrayList<>(); - List numRegionList=new ArrayList<>(); - - for (int i = 0; i < srcMap.get(groupId).size(); i++) { - if (cfgType == 1) { - IpCfg cfg = new IpCfg(); - BaseIpCfg baseIpCfg = (BaseIpCfg)srcMap.get(groupId).get(i); - // 区域IP配置,多条IP配置属于同一个分组,其他业务配置IP,一条配置一个分组 - cfg.setGroupId(groupId); - List cfgs = ipConvert(cfg, baseIpCfg); - ipRegionList.addAll(cfgs); - - } - if(cfgType==4){ - // 一条业务配置创建一个分组 - NumBoundaryCfg cfg = new NumBoundaryCfg(); - BeanUtils.copyProperties(srcMap.get(groupId).get(i), cfg); - cfg.setGroupId(groupId); - numRegionList.add(cfg); - } - if(cfgType==2 || cfgType==3){ - // 一条业务配置创建一个分组 - StringCfg cfg = new StringCfg(); - BaseStringCfg strCfg=(BaseStringCfg)srcMap.get(groupId).get(i); - BeanUtils.copyProperties(srcMap.get(groupId).get(i), cfg); - cfg.setGroupId(groupId); - cfg.setCfgType(strCfg.getCfgType()); - cfg.setRegionId(cfg.getRegionId()); - cfg.setAuditTime(strCfg.getAuditTime()); - cfg.setMatchMethod(strCfg.getMatchMethod()); - cfg.setIsValid(isValid); - cfg.setIsHexbin(strCfg.getIsHexbin()); - cfg.setExprType(strCfg.getExprType()); - // 处理配置关键字转译 - if(commonType == 4){ - cfg.setCfgKeywords(Constants.ASN_KEY+keywordsEscape(cfg.getCfgKeywords())); - }else{ - cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords())); - } - - // 增强字符串转换 - cfg.setDistrict(keywordsEscape(cfg.getDistrict())); - strRegionList.add(cfg); - } - - } - - groupCfg.setStrRegionList(strRegionList); - groupCfg.setIpRegionList(ipRegionList); - groupCfg.setNumRegionList(numRegionList); - commonGroupList.add(groupCfg); - } - return commonGroupList; - } - - /** - * 处理IpSpoofing配置导入 - * @param list - * @param cfgIndexInfos - * @param send - */ - public void saveAndSendSpoofingIpPool(List list, List cfgIndexInfos, boolean send) { - List ipCfgList = (List)list; - List spoofingPoolIds=Lists.newArrayList(); - List spoofingPools = new ArrayList(); - PxyObjSpoofingIpPoolDao pxyObjSpoofingIpPoolDao = SpringContextHolder.getBean(PxyObjSpoofingIpPoolDao.class); - - try { - spoofingPoolIds = ConfigServiceUtil.getId(1,ipCfgList.size()); - } catch (Exception e) { - e.printStackTrace(); - logger.info("获取编译ID出错"); - throw new MaatConvertException(":"+e.getMessage()); - } - int index = 0; - for (BaseIpCfg cfg : ipCfgList) { - // 保存IP仿冒池 - PxyObjSpoofingIpPool spoofingPool = new PxyObjSpoofingIpPool(); - spoofingPool.setIpType(4);//ipv4 - spoofingPool.setIpAddress(cfg.getUserRegion2());//仿冒IP - spoofingPool.setProtocol(0); - if("dnat".equals(cfg.getUserRegion1().toLowerCase())){//spoofing server ip->dnat - spoofingPool.setDirection(1); - }else{ - spoofingPool.setDirection(2);//spoofing client ip->snat - } - spoofingPool.setPort("0"); - spoofingPool.setUserRegion("0"); - spoofingPool.setLocation(0); - spoofingPool.setServiceId(642); - spoofingPool.setAreaEffectiveIds("0"); - spoofingPool.setIsAreaEffective(0); - spoofingPool.setCreateTime(cfg.getCreateTime()); - spoofingPool.setCreatorId(UserUtils.getUser().getId()); - if(spoofingPoolIds.size() == ipCfgList.size()) { - spoofingPool.setCompileId(spoofingPoolIds.get(index)); - } - spoofingPool.setAction(1); - spoofingPool.setFunctionId(666); - spoofingPool.setRequestId(0); - if(send) { - spoofingPool.setIsAudit(Constants.AUDIT_YES); - spoofingPool.setIsValid(Constants.VALID_YES); - spoofingPool.setAuditorId(UserUtils.getUser().getId()); - spoofingPool.setAuditTime(cfg.getAuditTime()); - - }else { - spoofingPool.setIsValid(Constants.VALID_NO); - spoofingPool.setIsAudit(Constants.AUDIT_NOT_YET); - - } - pxyObjSpoofingIpPoolDao.insert(spoofingPool);//保存仿冒IP池配置 - cfg.setUserRegion3(String.valueOf(spoofingPool.getCfgId()));//将仿冒IP池配置ID作为策略组ID - - if(send) { - PxyObjSpoofingIpPool pool=new PxyObjSpoofingIpPool(); - pool.setCfgId(Long.valueOf(cfg.getUserRegion3())); - pool.setIsValid(cfg.getIsValid()); - pool.setIsAudit(cfg.getIsAudit()); - pool.setAuditorId(UserUtils.getUser().getId()); - pool.setAuditTime(cfg.getAuditTime()); - pxyObjSpoofingIpPoolDao.update(pool); - - spoofingPool.setAreaEffectiveIds("0"); - spoofingPool.setGroupId(spoofingPool.getCfgId().intValue()); - spoofingPools.add(spoofingPool); - } - - CfgIndexInfo cfgIndexInfo = new CfgIndexInfo(); - BeanUtils.copyProperties(cfg, cfgIndexInfo,new String[] {"cfgId"}); - cfgIndexInfos.add(cfgIndexInfo); - - index ++; - } - - if(send && spoofingPools.size()>0) { - //调用服务接口下发配置数据 - String json=gsonToJson(spoofingPools); - if(spoofingPools.size()>10) { - logger.info("欺骗IP池配置下发配置条数:" + spoofingPools.size()); - }else { - logger.info("欺骗IP池配置下发配置参数:" + json); - } - //调用服务接口下发配置 - try { - ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json); - if(result!=null){ - logger.info("欺骗IP池配置下发响应信息:"+result.getMsg()); - } - } catch (Exception e) { - logger.error("欺骗IP池配置配置下发失败",e); - throw e;package com.nis.web.service; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.nio.charset.Charset; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.transaction.annotation.Transactional; - -import com.beust.jcommander.internal.Maps; -import com.google.common.collect.Lists; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.TypeAdapter; -import com.google.gson.internal.LinkedTreeMap; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; -import com.googlecode.ipv6.IPv6Address; -import com.googlecode.ipv6.IPv6Network; -import com.nis.domain.FunctionRegionDict; -import com.nis.domain.FunctionServiceDict; -import com.nis.domain.SysRole; -import com.nis.domain.SysUser; -import com.nis.domain.basics.AsnGroupInfo; -import com.nis.domain.basics.AsnIpCfg; -import com.nis.domain.callback.InlineIp; -import com.nis.domain.callback.NtcDnsResStrategy; -import com.nis.domain.callback.ProxyObjKeyring; -import com.nis.domain.callback.ProxyObjTrustedCa; -import com.nis.domain.configuration.AppComplexFeatureCfg; -import com.nis.domain.configuration.AppDomainCfg; -import com.nis.domain.configuration.AppFeatureIndex; -import com.nis.domain.configuration.AppHttpCfg; -import com.nis.domain.configuration.AppIpCfg; -import com.nis.domain.configuration.AppPolicyCfg; -import com.nis.domain.configuration.AppTopicDomainCfg; -import com.nis.domain.configuration.AreaBean; -import com.nis.domain.configuration.AreaIpCfg; -import com.nis.domain.configuration.AsnKeywordCfg; -import com.nis.domain.configuration.BaseCfg; -import com.nis.domain.configuration.BaseIpCfg; -import com.nis.domain.configuration.BaseStringCfg; -import com.nis.domain.configuration.CfgIndexInfo; -import com.nis.domain.configuration.ComplexkeywordCfg; -import com.nis.domain.configuration.DdosIpCfg; -import com.nis.domain.configuration.DnsIpCfg; -import com.nis.domain.configuration.DnsResStrategy; -import com.nis.domain.configuration.FileDigestCfg; -import com.nis.domain.configuration.IpReusePolicyCfg; -import com.nis.domain.configuration.NtcSubscribeIdCfg; -import com.nis.domain.configuration.PxyObjKeyring; -import com.nis.domain.configuration.PxyObjSpoofingIpPool; -import com.nis.domain.configuration.PxyObjTrustedCaCert; -import com.nis.domain.configuration.PxyObjTrustedCaCrl; -import com.nis.domain.configuration.WebsiteDomainTopic; -import com.nis.domain.maat.GroupReuseAddBean; -import com.nis.domain.maat.GroupReuseCfg; -import com.nis.domain.maat.MaatCfg; -import com.nis.domain.maat.MaatCfg.DigestCfg; -import com.nis.domain.maat.MaatCfg.GroupCfg; -import com.nis.domain.maat.MaatCfg.IpCfg; -import com.nis.domain.maat.MaatCfg.NumBoundaryCfg; -import com.nis.domain.maat.MaatCfg.StringCfg; -import com.nis.domain.maat.ToMaatBean; -import com.nis.domain.maat.ToMaatResult; -import com.nis.domain.specific.ConfigGroupInfo; -import com.nis.domain.specific.SpecificServiceCfg; -import com.nis.exceptions.MaatConvertException; -//import com.nis.util.AsnCacheUtils; -import com.nis.util.ConfigServiceUtil; -import com.nis.util.Configurations; -import com.nis.util.Constants; -import com.nis.util.DictUtils; -import com.nis.util.IpUtil; -import com.nis.util.Reflections; -import com.nis.util.StringUtil; -import com.nis.util.StringUtils; -import com.nis.web.dao.basics.AsnGroupInfoDao; -import com.nis.web.dao.basics.AsnIpCfgDao; -import com.nis.web.dao.configuration.AppCfgDao; -import com.nis.web.dao.configuration.AppMultiFeatureCfgDao; -import com.nis.web.dao.configuration.DdosCfgDao; -import com.nis.web.dao.configuration.DnsIpCfgDao; -import com.nis.web.dao.configuration.DnsResStrategyDao; -import com.nis.web.dao.configuration.IpCfgDao; -import com.nis.web.dao.configuration.PxyObjSpoofingIpPoolDao; -import com.nis.web.dao.configuration.StringCfgDao; -import com.nis.web.dao.specific.ConfigGroupInfoDao; -import com.nis.web.dao.specific.SpecificServiceCfgDao; -import com.nis.web.security.UserUtils; -import com.nis.web.service.basics.AsnGroupInfoService; -import com.nis.web.service.basics.SysDictInfoService; - -/** - * Service基类 - * - * @author ThinkGem - * @version 2014-05-16 - */ -public abstract class BaseService { - - /** - * 日志对象 - */ - protected Logger logger = LoggerFactory.getLogger(getClass()); - - /** - * 数据范围过滤 - * - * @param user - * 当前用户对象,通过“entity.getCurrentUser()”获取 - * @param officeAlias - * 机构表别名,多个用“,”逗号隔开。 - * @param userAlias - * 用户表别名,多个用“,”逗号隔开,传递空,忽略此参数 - * @return 标准连接条件对象 - */ - public static String dataScopeFilter(SysUser user, String officeAlias, String userAlias) { - - StringBuilder sqlString = new StringBuilder(); - - // 进行权限过滤,多个角色权限范围之间为或者关系。 - List dataScope = Lists.newArrayList(); - - if (StringUtils.isBlank(user.getLoginId())) { - return ""; - } - - // 超级管理员,跳过权限过滤 - if (user.isAdmin()) { - boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList()); - - for (SysRole r : user.getUserRoleList()) { - for (String oa : StringUtils.split(officeAlias, ",")) { - if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(oa)) { - - sqlString.append(createScopeSql(r.getDataScope(), oa, user, null)); - dataScope.add(r.getDataScope()); - } - } - } - // 如果没有全部数据权限,并设置了用户别名,则当前权限为本人;如果未设置别名,当前无权限为已植入权限 - if (!isDataScopeAll) { - if (StringUtils.isNotBlank(userAlias)) { - for (String ua : StringUtils.split(userAlias, ",")) { - sqlString.append(" OR " + ua + ".id = '" + user.getId() + "'"); - } - } else { - for (String oa : StringUtils.split(officeAlias, ",")) { - // sqlString.append(" OR " + oa + ".id = " + user.getOffice().getId()); - sqlString.append(" OR " + oa + ".id IS NULL"); - } - } - } else { - // 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。 - sqlString = new StringBuilder(); - } - } - if (StringUtils.isNotBlank(sqlString.toString())) { - return " AND (" + sqlString.substring(4) + ")"; - } - return ""; - } - - /** - * 数据范围过滤 - * - * @param user - * 当前用户对象,通过“entity.getCurrentUser()”获取 - * @param configAlias - * 配置表别名,多个用","逗号隔开,传递空,忽略此参数 - * @return 标准连接条件对象 - */ - public static String configScopeFilter(SysUser user, String configAlias) { - - StringBuilder sqlString = new StringBuilder(); - - // 进行权限过滤,多个角色权限范围之间为或者关系。 - List dataScope = Lists.newArrayList(); - - if (StringUtils.isBlank(user.getLoginId())) { - return ""; - } - - // 超级管理员,跳过权限过滤 - if (!user.isAdmin()) { - boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList()); - // 如果没有全部数据权限 - if (!isDataScopeAll) { - for (SysRole r : user.getUserRoleList()) { - for (String c : StringUtils.split(configAlias, ",")) { - if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(c)) { - sqlString.append(createScopeSql(r.getDataScope(), "", user, c)); - dataScope.add(r.getDataScope()); - } - } - } - - } else { - // 如果包含全部权限,则去掉之前添加的所有条件但增加配置审核取消以及删除的配置,并跳出循环。 - sqlString = new StringBuilder(); -// sqlString.append(" OR " + configAlias + ".is_audit !=3"); - sqlString.append(" OR " + configAlias + ".creator_id <> 1"); - } - } - if (StringUtils.isNotBlank(sqlString.toString())) { - return " AND (" + sqlString.substring(4) + ")"; - } - return ""; - } - - /** - * 测试数据是否包含全集 - * - * @return - */ - private static boolean isContainsDataScopeAll(List roleList) { - boolean isDataScopeAll = false; - - for (SysRole role : roleList) { - if (SysRole.DATA_SCOPE_ALL.equals(role.getDataScope())) { - isDataScopeAll = true; - break; - } - } - - return isDataScopeAll; - - } - - /** - * 过滤机构信息 - * - * @param dataScope - * 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据; - * 4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据; - * 8:操作员数据;9:审核员数据,10:审计员数据) - * @return - */ - private static String createScopeSql(int dataScope, String officeAlias, SysUser user, String configAlias) { - StringBuilder scopeSql = new StringBuilder(1024); - - if (SysRole.DATA_SCOPE_COMPANY_AND_CHILD.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId()); - scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getCompany().getParentIds() - + user.getCompany().getId() + ",%'"); - } else if (SysRole.DATA_SCOPE_COMPANY.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId()); - // 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门) - scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getCompany().getId() + "' AND " - + officeAlias + ".type>1)"); - } else if (SysRole.DATA_SCOPE_OFFICE_AND_CHILD.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId()); - scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getOffice().getParentIds() - + user.getOffice().getId() + ",%'"); - } else if (SysRole.DATA_SCOPE_OFFICE.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId()); - } else if (SysRole.DATA_SCOPE_ENTITY_AND_CHILD.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId()); - scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getEntity().getParentIds() - + user.getEntity().getId() + ",%'"); - - } else if (SysRole.DATA_SCOPE_ENTITY.equals(dataScope)) { - scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId()); - // 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门) - scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getEntity().getId() + "' AND " + officeAlias - + ".type>1)"); - - } else if (SysRole.DATA_SCOPE_CREATOR.equals(dataScope)) { -// scopeSql.append(" OR " + configAlias + ".is_audit !=3"); - scopeSql.append(" OR " + configAlias + ".creator_id <>1 "); - } else if (SysRole.DATA_SCOPE_AUDITOR.equals(dataScope)) { - scopeSql.append(" OR " + configAlias + ".is_audit = 0 or " + configAlias + ".is_audit = 1"); - scopeSql.append(" OR " + configAlias + ".creator_id <>1 "); - } else if (SysRole.DATA_SCOPE_SHOWER.equals(dataScope)) { - scopeSql.append(" OR " + configAlias + ".is_audit = 1"); - scopeSql.append(" OR " + configAlias + ".creator_id <>1 "); - } - - return scopeSql.toString(); - } - - /** - * - * getTableName(获取表名对应的Class) (这里描述这个方法适用条件 – 可选) - * - * @param clazz - * @return String - * @exception @since - * 1.0.0 - */ - public String getClassName(String tableName) { - return Configurations.getStringProperty(tableName, null); - } - - public static class MapTypeAdapter extends TypeAdapter { - @Override - public Object read(JsonReader in) throws IOException { - JsonToken token = in.peek(); - switch (token) { - case BEGIN_ARRAY: - List list = new ArrayList(); - in.beginArray(); - while (in.hasNext()) { - list.add(read(in)); - } - in.endArray(); - return list; - - case BEGIN_OBJECT: - Map map = new LinkedTreeMap(); - in.beginObject(); - while (in.hasNext()) { - map.put(in.nextName(), read(in)); - } - in.endObject(); - return map; - - case STRING: - return in.nextString(); - - case NUMBER: - String temp = in.nextString(); - BigDecimal dbNum = new BigDecimal(temp); - BigDecimal maxLong = new BigDecimal(Long.MAX_VALUE); - BigDecimal maxInteger = new BigDecimal(Integer.MAX_VALUE); - // 数字超过long的最大值,返回BigDecimal类型 - if (dbNum.compareTo(maxLong) == 1) { - return dbNum; - } else if (dbNum.compareTo(maxInteger) == 1) { - long lngNum = Long.parseLong(temp); - return lngNum; - } else { - int lngNum = Integer.parseInt(temp); - return lngNum; - } - - case BOOLEAN: - return in.nextBoolean(); - - case NULL: - in.nextNull(); - return null; - - default: - throw new IllegalStateException(); - } - } - - @Override - public void write(JsonWriter out, Object value) throws IOException { - // 序列化无需实现 - } - - } - - /** - * 转换成字符串 - * - * @param obj - * @return - */ - public static String gsonToJson(T obj) { - Gson gson = new GsonBuilder().disableHtmlEscaping().excludeFieldsWithoutExposeAnnotation() - .registerTypeAdapter(Date.class, new JsonSerializer() { - @Override - public JsonElement serialize(Date src, Type type, JsonSerializationContext context) { - String format = "yyyy-MM-dd HH:mm:ss"; - long time = ((Date) src).getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - return new JsonPrimitive(sdf.format(time)); - } - }).create(); - return gson.toJson(obj); - } - - /** - * 字符串转成对象 - * - * @param jsonString - * @param cls - * @return - */ - public static T gsonFromJson(String jsonString, Class cls) { - Gson gson = new GsonBuilder().registerTypeAdapter(new TypeToken() { - }.getType(), new MapTypeAdapter()).registerTypeAdapter(new TypeToken() { - }.getType(), new MapTypeAdapter()).create(); - return gson.fromJson(jsonString, cls); - } - - /** - * 界面配置list转换为服务接口端的list - * - * @param - * @param - * @param dstList - * @param srcList - * @param cfgType,1为IP类型,2为字符串类型,3为增强字符串,4数值类型,5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList] - * @param baseCfg,配置基本信息 - * @param groupRelationList - * 配置分组列表 - * @return - */ - public static Map cfgConvert(List dstList, List srcList, Integer cfgType, BaseCfg baseCfg, - List groupRelationList) { - Map map = new HashMap(); - if (cfgType == 1) { - List numRegionList = new ArrayList(); - Integer groupId = 0; - Integer numGroupId = 0; - List regionIdList = ConfigServiceUtil.getId(3, srcList.size()); - for (int i = 0; i < srcList.size(); i++) { - T srcCfg = srcList.get(i); - BaseIpCfg baseIpCfg = new BaseIpCfg(); - BeanUtils.copyProperties(srcCfg, baseIpCfg); - IpCfg cfg = new IpCfg(); - BeanUtils.copyProperties(baseIpCfg, cfg); - // 区域IP配置,多条IP配置属于同一个分组,其他业务配置IP,一条配置一个分组 - // if(groupId==0 || !cfg.getCfgType().equals(Constants.AREA_REGION)){ - if (groupId == 0) { - GroupCfg group = new GroupCfg(); - groupId = ConfigServiceUtil.getId(2, 1).get(0); - group.setGroupId(groupId); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - } - cfg.setGroupId(groupId); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - List cfgs = ipConvert(cfg, baseIpCfg); - if (cfgs.size() > 1) { - List ids = ConfigServiceUtil.getId(3, cfgs.size() - 1); - regionIdList.addAll(ids); - } - for (int j = i; j < cfgs.size() + i; j++) { - cfgs.get(j - i).setRegionId(regionIdList.get(j)); - } - dstList.addAll(cfgs); - - // 如果protocolId非空非零,需要构造数值型域配置,多条相同协议的IP只需要一条数值域配置(目前没有不同协议IP&情况) - if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) { - if (numGroupId == 0) { - GroupCfg group1 = new GroupCfg(); - group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0)); - group1.setCompileId(baseIpCfg.getCompileId()); - group1.setAuditTime(baseCfg.getAuditTime()); - group1.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group1); - NumBoundaryCfg numCfg = new NumBoundaryCfg(); - numCfg.initDefaultValue(); - numCfg.setLowBoundary(baseIpCfg.getProtocolId()); - numCfg.setUpBoundary(baseIpCfg.getProtocolId()); - numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0)); - numCfg.setAuditTime(baseCfg.getAuditTime()); - numCfg.setGroupId(group1.getGroupId()); - numCfg.setIsValid(baseCfg.getIsValid()); - numRegionList.add(numCfg); - map.put("numRegionList", numRegionList); - numGroupId++; - } - } - } - - } else if (cfgType == 2 || cfgType == 3) { - List groupIdList = ConfigServiceUtil.getId(2, srcList.size()); - List regionIdList = ConfigServiceUtil.getId(3, srcList.size()); - for (int i = 0; i < srcList.size(); i++) { - // 一条业务配置创建一个分组 - GroupCfg group = new GroupCfg(); - StringCfg cfg = new StringCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg); - group.setGroupId(groupIdList.get(i)); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(regionIdList.get(i)); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - // 处理配置关键字转译 - cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords())); - // 增强字符串转换 - cfg.setDistrict(keywordsEscape(cfg.getDistrict())); - dstList.add(cfg); - } - } else if (cfgType == 4) { - List groupIdList = ConfigServiceUtil.getId(2, srcList.size()); - List regionIdList = ConfigServiceUtil.getId(3, srcList.size()); - for (int i = 0; i < srcList.size(); i++) { - // 一条业务配置创建一个分组 - com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(groupIdList.get(i)); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(regionIdList.get(i)); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - dstList.add(cfg); - } - } else if (cfgType == 5) { - List groupIdList = ConfigServiceUtil.getId(2, srcList.size()); - List regionIdList = ConfigServiceUtil.getId(3, srcList.size()); - for (int i = 0; i < srcList.size(); i++) { - // 一条业务配置创建一个分组 - com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(groupIdList.get(i)); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(regionIdList.get(i)); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - dstList.add(cfg); - } - } else if (cfgType == 7) { //ASN关键字配置 - /*//TODO 下发之前是否需要增加asn号的有效性校验,创建配置和下发配置不是在同一时间 - //TODO 考虑增加配置id、表名和ASN组织,以及ASN NO的关系。 - //TODO 如果ASNO 和组织关系没有了,数据需要清理,asn组织和配置id关系没有了,也需要清理 - int regionNum=0; - //多个ASNNO存在一个ASN关键字配置中, - for (int i = 0; i < srcList.size(); i++) { - AsnKeywordCfg asnKeywordCfg=(AsnKeywordCfg)srcList.get(i); - regionNum+=asnKeywordCfg.getCfgKeywords().split(",").length; - - } - - //List groupIdList = ConfigServiceUtil.getId(2, srcList.size()); - List regionIdList = ConfigServiceUtil.getId(3, regionNum); - Integer regionIndex=0;*/ - List listGroupId=new ArrayList<>(); - for (int i = 0; i < srcList.size(); i++) { - AsnKeywordCfg asnKeywordCfg = (AsnKeywordCfg)srcList.get(i); - GroupCfg group = new GroupCfg(); - group.setGroupId(Integer.parseInt(asnKeywordCfg.getUserRegion1())); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - group.setIsCommonGroup(1);//标识为公共组 //TODO 已下发过的组是否还需标记为公共组 - if(!listGroupId.contains(group.getGroupId())){ - groupRelationList.add(group); - listGroupId.add(group.getGroupId()); - } - - //****************是否下发域信息******* - if("1".equals(asnKeywordCfg.getUserRegion3())){ - StringCfg cfg = new StringCfg(); - BeanUtils.copyProperties(asnKeywordCfg, cfg); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(Integer.parseInt(asnKeywordCfg.getUserRegion2())); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - // 处理配置关键字转译 - cfg.setCfgKeywords(Constants.ASN_KEY+keywordsEscape(asnKeywordCfg.getCfgKeywords())); - dstList.add(cfg); - } - } - } else { - dstList.addAll(srcList); - } - map.put("groupList", groupRelationList); - map.put("dstList", dstList); - return map; - } - /** - * maatCfg转换,不支持callback,注意除了ip类型的range转换完成之后需要额外获取region id之外,其他需要在src中设置 compileId,regionId,regoup id - * 如果ip类型协议id不为空,需要设置numberRegionGroupId,numberRegionRegionId。 - * @param src - * @param cfgType,1为IP类型,2为字符串类型,3为增强字符串,4数值类型,5摘要类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList] - * @return Map - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - public static Map cfgConvert(BaseCfg src, Integer cfgType) { - Map map=Maps.newHashMap(); - List groupRelationList=Lists.newArrayList(); - Field compileIdF= Reflections.getAccessibleField(src, "compileId"); - Field groupIdF= Reflections.getAccessibleField(src, "groupId"); - Field regionIdF= Reflections.getAccessibleField(src, "regionId"); - try { - if(compileIdF==null||compileIdF.get(src)==null) { - throw new RuntimeException("Please set compileId first"); - } - if(groupIdF==null||groupIdF.get(src)==null) { - throw new RuntimeException("Please set groupId first"); - } - if(regionIdF==null||regionIdF.get(src)==null) { - throw new RuntimeException("Please set regionId first"); - } - } catch (IllegalArgumentException | IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - if (cfgType == 1) { - List ipcfgs=Lists.newArrayList(); - List numRegionList = new ArrayList(); - BaseIpCfg baseIpCfg = new BaseIpCfg(); - BeanUtils.copyProperties(src, baseIpCfg); - Integer groupId = baseIpCfg.getGroupId(); - Integer numGroupId = 0; - IpCfg cfg = new IpCfg(); - BeanUtils.copyProperties(baseIpCfg, cfg); - // 区域IP配置,多条IP配置属于同一个分组,其他业务配置IP,一条配置一个分组 - // if(groupId==0 || !cfg.getCfgType().equals(Constants.AREA_REGION)){ - GroupCfg group = new GroupCfg(); - if (groupId == 0) { - groupId = ConfigServiceUtil.getId(2, 1).get(0); - } - group.setGroupId(groupId); - group.setCompileId(baseIpCfg.getCompileId()); - group.setAuditTime(baseIpCfg.getAuditTime()); - group.setIsValid(baseIpCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(groupId); - cfg.setAuditTime(baseIpCfg.getAuditTime()); - cfg.setIsValid(baseIpCfg.getIsValid()); - List cfgs = ipConvert(cfg, baseIpCfg); - List regionIdList=Lists.newArrayListWithCapacity(cfgs.size() - 1); - if (cfgs.size() > 1) { - List ids = ConfigServiceUtil.getId(3, cfgs.size() - 1); - regionIdList.addAll(ids); - } - for (int i = 1; i < cfgs.size(); i++) { - cfgs.get(i).setRegionId(regionIdList.get(i-1)); - } - ipcfgs.addAll(cfgs); - map.put("ipRegionList", ipcfgs); - // 如果protocolId非空非零,需要构造数值型域配置,多条相同协议的IP只需要一条数值域配置(目前没有不同协议IP&情况) - if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) { - if (numGroupId == 0) { - GroupCfg group1 = new GroupCfg(); - //group1.setGroupId(groupId); - if(baseIpCfg.getNumberRegionGroupId()!=null) { - group1.setGroupId(baseIpCfg.getNumberRegionGroupId()); - }else { - group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0)); - } - group1.setCompileId(baseIpCfg.getCompileId()); - group1.setAuditTime(baseIpCfg.getAuditTime()); - group1.setIsValid(baseIpCfg.getIsValid()); - groupRelationList.add(group1); - NumBoundaryCfg numCfg = new NumBoundaryCfg(); - numCfg.initDefaultValue(); - numCfg.setLowBoundary(baseIpCfg.getProtocolId()); - numCfg.setUpBoundary(baseIpCfg.getProtocolId()); - if(baseIpCfg.getNumberRegionRegionId()!=null) { - numCfg.setRegionId(baseIpCfg.getNumberRegionRegionId()); - }else { - numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0)); - } - numCfg.setAuditTime(baseIpCfg.getAuditTime()); - numCfg.setGroupId(group1.getGroupId()); - numCfg.setIsValid(baseIpCfg.getIsValid()); - numRegionList.add(numCfg); - map.put("numRegionList", numRegionList); - numGroupId++; - } - } - } else if (cfgType == 2 || cfgType == 3) { - List stringcfgs=Lists.newArrayList(); - // 一条业务配置创建一个分组 - BaseCfg baseCfg=(BaseCfg)src; - GroupCfg group = new GroupCfg(); - StringCfg cfg = new StringCfg(); - BeanUtils.copyProperties(src, cfg); - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - // 处理配置关键字转译 - cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords())); - // 增强字符串转换 - cfg.setDistrict(keywordsEscape(cfg.getDistrict())); - stringcfgs.add(cfg); - map.put("strRegionList", stringcfgs); - } else if (cfgType == 4) { - List numCfgs=Lists.newArrayList(); - // 一条业务配置创建一个分组 - BaseCfg baseCfg=(BaseCfg)src; - com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg(); - BeanUtils.copyProperties(src, cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - numCfgs.add(cfg); - map.put("numRegionList", numCfgs); - } else if (cfgType == 5) { - List digestCfgs=Lists.newArrayList(); - BaseCfg baseCfg=(BaseCfg)src; - // 一条业务配置创建一个分组 - com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg(); - BeanUtils.copyProperties(src, cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - digestCfgs.add(cfg); - map.put("digestRegionList", digestCfgs); - } else { - throw new RuntimeException("unknown cfgType "+cfgType); - } - map.put("groupRelationList", groupRelationList); - return map; - } - - /** - * 界面配置list转换为服务接口端的list,用于批量下发时,regionId,groupId已在该方法前被批量获取 - * - * @param - * @param - * @param dstList - * @param srcList - * @param cfgType,1为IP类型,2为字符串类型,3为增强字符串,4数值类型,5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList] - * @param baseCfg,配置基本信息 - * @param groupRelationList - * 配置分组列表 - * @return - */ - public static Map cfgToMaatConvert(List dstList, List srcList, Integer cfgType,List groupRelationList) { - Map map = new HashMap(); - if (cfgType == 1) { - List numRegionList = new ArrayList(); - Integer groupId = 0; - Integer numGroupId = 0; - for (int i = 0; i < srcList.size(); i++) { - List regionIdList = Lists.newArrayList(); - T srcCfg = srcList.get(i); - BaseIpCfg baseIpCfg = new BaseIpCfg(); - BeanUtils.copyProperties(srcCfg, baseIpCfg); - regionIdList.add(baseIpCfg.getRegionId()); - IpCfg cfg = new IpCfg(); - BeanUtils.copyProperties(baseIpCfg, cfg); - //多条IP配置属于同一个分组 - if (groupId == 0) { - GroupCfg group = new GroupCfg(); - groupId = baseIpCfg.getGroupId(); - group.setGroupId(groupId); - group.setCompileId(baseIpCfg.getCompileId()); - group.setAuditTime(baseIpCfg.getAuditTime()); - group.setIsValid(baseIpCfg.getIsValid()); - groupRelationList.add(group); - } - cfg.setGroupId(groupId); - cfg.setAuditTime(baseIpCfg.getAuditTime()); - cfg.setIsValid(baseIpCfg.getIsValid()); - List cfgs = ipConvert(cfg, baseIpCfg); - if (cfgs.size() > 1) { - List ids = ConfigServiceUtil.getId(3, cfgs.size() - 1); - regionIdList.addAll(ids); - } - for (int j = i; j < cfgs.size() + i; j++) { - cfgs.get(j - i).setRegionId(regionIdList.get(j)); - } - dstList.addAll(cfgs); - - // 如果protocolId非空非零,需要构造数值型域配置,多条相同协议的IP只需要一条数值域配置(目前没有不同协议IP&情况) - if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) { - if (numGroupId == 0) { - GroupCfg group1 = new GroupCfg(); - group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0)); - group1.setCompileId(baseIpCfg.getCompileId()); - group1.setAuditTime(baseIpCfg.getAuditTime()); - group1.setIsValid(baseIpCfg.getIsValid()); - groupRelationList.add(group1); - NumBoundaryCfg numCfg = new NumBoundaryCfg(); - numCfg.initDefaultValue(); - numCfg.setLowBoundary(baseIpCfg.getProtocolId()); - numCfg.setUpBoundary(baseIpCfg.getProtocolId()); - numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0)); - numCfg.setAuditTime(baseIpCfg.getAuditTime()); - numCfg.setGroupId(group1.getGroupId()); - numCfg.setIsValid(baseIpCfg.getIsValid()); - numRegionList.add(numCfg); - map.put("numRegionList", numRegionList); - numGroupId++; - } - } - } - - } else if (cfgType == 2 || cfgType == 3) { - for (int i = 0; i < srcList.size(); i++) { - // 一条业务配置创建一个分组 - BaseCfg baseCfg = new BaseCfg(); - BeanUtils.copyProperties(srcList.get(i), baseCfg);//拷贝公共属性 - GroupCfg group = new GroupCfg(); - StringCfg cfg = new StringCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg);//拷贝公共属性以及私有属性 - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - // 处理配置关键字转译 - cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords())); - // 增强字符串转换 - cfg.setDistrict(keywordsEscape(cfg.getDistrict())); - dstList.add(cfg); - } - } else if (cfgType == 4) { - for (int i = 0; i < srcList.size(); i++) { - BaseCfg baseCfg = new BaseCfg(); - BeanUtils.copyProperties(srcList.get(i), baseCfg);//拷贝公共属性 - // 一条业务配置创建一个分组 - com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - dstList.add(cfg); - } - } else if (cfgType == 5) { - for (int i = 0; i < srcList.size(); i++) { - BaseCfg baseCfg = new BaseCfg(); - BeanUtils.copyProperties(srcList.get(i), baseCfg);//拷贝公共属性 - // 一条业务配置创建一个分组 - com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg(); - BeanUtils.copyProperties(srcList.get(i), cfg); - GroupCfg group = new GroupCfg(); - group.setGroupId(baseCfg.getGroupId()); - group.setCompileId(baseCfg.getCompileId()); - group.setAuditTime(baseCfg.getAuditTime()); - group.setIsValid(baseCfg.getIsValid()); - groupRelationList.add(group); - cfg.setGroupId(group.getGroupId()); - cfg.setRegionId(baseCfg.getRegionId()); - cfg.setAuditTime(baseCfg.getAuditTime()); - cfg.setIsValid(baseCfg.getIsValid()); - dstList.add(cfg); - } - } else { - dstList.addAll(srcList); - } - map.put("groupList", groupRelationList); - map.put("dstList", dstList); - return map; - } - /** - * 界面IP配置转换为MAAT类或者回调类IP配置 - * - * @param dstIp - * @param srcIp - * @return - */ - /* - * public static IpCfg ipConvert(IpCfg dstIp,BaseIpCfg srcIp){ - * if(srcIp.getSrcIpAddress()!=null){ - * if(srcIp.getSrcIpAddress().indexOf("/")!=-1){ if(srcIp.getIpType()==4 || - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 Integer srcMaskNum = - * Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){ - * dstIp.setSrcIpMask("0.0.0.0"); }else{ - * dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); } - * - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else - * if(srcIp.getIpType()==6|| srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress()); - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); - * dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { Pattern patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); - * Pattern patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); - * Matcher matchernV4Subnet=patternV4Subnet.matcher(srcIp.getSrcIpAddress()); - * Matcher matcherV6Subnet=patternV6Subnet.matcher(srcIp.getSrcIpAddress()); - * if(matchernV4Subnet.matches()) { Integer srcMaskNum = - * Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){ - * dstIp.setSrcIpMask("0.0.0.0"); }else{ - * dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); } - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else - * if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork = - * IPv6Network.fromString(srcIp.getSrcIpAddress()); - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); - * dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { throw new RuntimeException("Invalid IP/subnet mask format"); } } - * - * }else if(srcIp.getSrcIpAddress().indexOf("-")!=-1){ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("-")[0]); - * dstIp.setSrcIpMask(IpUtil.getMask(srcIp.getSrcIpAddress().split("-")[0], - * srcIp.getSrcIpAddress().split("-")[1])); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 IPv6Address address1 = - * IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]); IPv6Address - * address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]); - * IPv6Network network = IPv6Network.fromTwoAddresses(address1,address2); - * dstIp.setSrcIp(address1.toString()); - * dstIp.setSrcIpMask(network.getNetmask().asAddress().toString()); }else { - * Pattern patternV4Range=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP); - * Pattern patternV6Range=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP); - * Matcher matcherV4Range=patternV4Range.matcher(srcIp.getSrcIpAddress()); - * Matcher matcherV6Range=patternV6Range.matcher(srcIp.getSrcIpAddress()); - * if(matcherV4Range.matches()) { - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("-")[0]); - * dstIp.setSrcIpMask(IpUtil.getMask(srcIp.getSrcIpAddress().split("-")[0], - * srcIp.getSrcIpAddress().split("-")[1])); }else if(matcherV6Range.matches()) { - * IPv6Address address1 = - * IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]); IPv6Address - * address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]); - * IPv6Network network = IPv6Network.fromTwoAddresses(address1,address2); - * dstIp.setSrcIp(address1.toString()); - * dstIp.setSrcIpMask(network.getNetmask().asAddress().toString()); }else { - * throw new RuntimeException("Invalid IP range format"); } } - * - * }else{ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else {//all - * Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP); Pattern - * patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher - * matcherV4=patternV4.matcher(srcIp.getSrcIpAddress()); Matcher - * matcherV6=patternV6.matcher(srcIp.getSrcIpAddress()); if(matcherV4.matches()) - * { dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); }else if(matcherV6.matches()) { - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw - * new RuntimeException("Invalid IP format"); } } - * - * } }else{ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else {//all - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); } } - * if(srcIp.getDestIpAddress()!=null){ - * if(srcIp.getDestIpAddress().indexOf("/")!=-1){ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 Integer dstMaskNum = - * Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){ - * dstIp.setDstIpMask("0.0.0.0"); }else{ - * dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; } - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else - * if(srcIp.getIpType()==6|| srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * IPv6Network strangeNetwork = - * IPv6Network.fromString(srcIp.getDestIpAddress()); - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); - * dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { Pattern patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); - * Pattern patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); - * Matcher matchernV4Subnet=patternV4Subnet.matcher(srcIp.getDestIpAddress()); - * Matcher matcherV6Subnet=patternV6Subnet.matcher(srcIp.getDestIpAddress()); - * if(matchernV4Subnet.matches()) { Integer dstMaskNum = - * Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){ - * dstIp.setDstIpMask("0.0.0.0"); }else{ - * dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; } - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else - * if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork = - * IPv6Network.fromString(srcIp.getDestIpAddress()); - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); - * dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { throw new RuntimeException("Invalid IP/subnet mask format"); } } - * - * }else if(srcIp.getDestIpAddress().indexOf("-")!=-1){ - * if(srcIp.getIpType()==4|| srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * dstIp.setDstIp(srcIp.getDestIpAddress().split("-")[0]); - * dstIp.setDstIpMask(IpUtil.getMask(srcIp.getDestIpAddress().split("-")[0], - * srcIp.getDestIpAddress().split("-")[1])); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 IPv6Address address1 = - * IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]); IPv6Address - * address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]); - * IPv6Network network = IPv6Network.fromTwoAddresses(address1,address2); - * dstIp.setDstIp(address1.toString()); - * dstIp.setDstIpMask(network.getNetmask().asAddress().toString()); }else { - * Pattern patternV4Range=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP); - * Pattern patternV6Range=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP); - * Matcher matcherV4Range=patternV4Range.matcher(srcIp.getDestIpAddress()); - * Matcher matcherV6Range=patternV6Range.matcher(srcIp.getDestIpAddress()); - * if(matcherV4Range.matches()) { - * dstIp.setDstIp(srcIp.getDestIpAddress().split("-")[0]); - * dstIp.setDstIpMask(IpUtil.getMask(srcIp.getDestIpAddress().split("-")[0], - * srcIp.getDestIpAddress().split("-")[1])); }else if(matcherV6Range.matches()) - * { IPv6Address address1 = - * IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]); IPv6Address - * address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]); - * IPv6Network network = IPv6Network.fromTwoAddresses(address1,address2); - * dstIp.setDstIp(address1.toString()); - * dstIp.setDstIpMask(network.getNetmask().asAddress().toString()); }else { - * throw new RuntimeException("Invalid IP range format"); } } - * - * }else{ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else {//all - * Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP); Pattern - * patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher - * matcherV4=patternV4.matcher(srcIp.getDestIpAddress()); Matcher - * matcherV6=patternV6.matcher(srcIp.getDestIpAddress()); - * if(matcherV4.matches()) { dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); }else if(matcherV6.matches()) { - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw - * new RuntimeException("invalid ip format"); } } - * - * } }else{ if(srcIp.getIpType()==4|| - * srcIp.getIpType()==64){//64表示源ip为ipv6,目的ip为ipv4 - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); }else if(srcIp.getIpType()==6|| - * srcIp.getIpType()==46){//46表示源ip为ipv4,目的ip为ipv6 - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else {//all - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); } } if(srcIp.getSrcPort()!=null){ - * if(srcIp.getSrcPort().indexOf("/")!=-1){ String srcMaskNum = - * srcIp.getSrcPort().split("/")[1]; dstIp.setSrcPortMask(srcMaskNum); - * dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]); }else{ - * dstIp.setSrcPort(srcIp.getSrcPort()); dstIp.setSrcPortMask("65535"); } }else{ - * dstIp.setSrcPort("0"); dstIp.setSrcPortMask("65535"); } - * if(srcIp.getDestPort()!=null){ if(srcIp.getDestPort().indexOf("/")!=-1){ - * String dstMaskNum = srcIp.getDestPort().split("/")[1]; - * dstIp.setDstPortMask(dstMaskNum); - * dstIp.setDstPort(srcIp.getDestPort().split("/")[0]); }else{ - * dstIp.setDstPort(srcIp.getDestPort()); dstIp.setDstPortMask("65535"); } - * }else{ dstIp.setDstPort("0"); dstIp.setDstPortMask("65535"); } return dstIp; - * } - */ - /** - * 界面IP配置转换为MAAT类或者回调类IP配置 - * - * @param dstIp - * @param srcIp - * @return - */ - public static List ipConvert(IpCfg dstIp, BaseIpCfg srcIp) { - List ipConvertList = Lists.newArrayList(); - boolean isRange = ((srcIp.getIpPattern() != null && srcIp.getIpPattern() == 2) - || (srcIp.getSrcIpAddress() != null && srcIp.getSrcIpAddress().indexOf("-") > -1) - || (srcIp.getDestIpAddress() != null && srcIp.getDestIpAddress().indexOf("-") > -1)); - if (isRange) { - List tempList = Lists.newArrayList(); - List tempList1 = Lists.newArrayList(); - if (srcIp.getIpType().intValue() == 4) { - if (srcIp.getSrcIpAddress() != null) { - String startIpPart = srcIp.getSrcIpAddress().split("-")[0]; - String endIpPart = srcIp.getSrcIpAddress().split("-")[1]; - Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]); - Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]); - for (int i = startNum; i <= endNum; i++) { - IpCfg tempIp = new IpCfg(); - BeanUtils.copyProperties(dstIp, tempIp); - tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i); - tempIp.setSrcIpMask("255.255.255.255"); - tempList.add(tempIp); - } - } else { - dstIp.setSrcIp("0.0.0.0"); - dstIp.setSrcIpMask("255.255.255.255"); - tempList.add(dstIp); - } - if (srcIp.getDestIpAddress() != null) { - String startIpPart = srcIp.getDestIpAddress().split("-")[0]; - String endIpPart = srcIp.getDestIpAddress().split("-")[1]; - Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]); - Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]); - for (IpCfg _cfg : tempList) { - for (int i = startNum; i <= endNum; i++) { - IpCfg tempIp = new IpCfg(); - BeanUtils.copyProperties(_cfg, tempIp); - tempIp.setDstIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i); - tempIp.setDstIpMask("255.255.255.255"); - // 处理 - convertPortValues(tempIp, srcIp); - if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) { - tempList1.add(tempIp); - } - - } - } - tempList.clear(); - } else { - for (IpCfg _cfg : tempList) { - _cfg.setDstIp("0.0.0.0"); - _cfg.setSrcIpMask("255.255.255.255"); - convertPortValues(_cfg, srcIp); - } - } - if (tempList1.size() > 0) { - ipConvertList.addAll(tempList1); - } else { - ipConvertList.addAll(tempList); - } - } else if (srcIp.getIpType().intValue() == 6) { - if (srcIp.getSrcIpAddress() != null) { - IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]); - IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]); - IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2); - dstIp.setSrcIp(address1.toString()); - dstIp.setSrcIpMask(network.getNetmask().asAddress().toString()); - } else { - dstIp.setSrcIp("::"); - dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } - if (srcIp.getDestIpAddress() != null) { - IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]); - IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]); - IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2); - dstIp.setDstIp(address1.toString()); - dstIp.setDstIpMask(network.getNetmask().asAddress().toString()); - } else { - dstIp.setDstIp("::"); - dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } - - ipConvertList.add(dstIp); - } else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } else { - if (srcIp.getSrcIpAddress() != null) { - if (srcIp.getSrcIpAddress().indexOf("/") != -1) { - if (srcIp.getIpType() == 4 /* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); - if (srcMaskNum == 0) { - dstIp.setSrcIpMask("0.0.0.0"); - } else { - dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); - } - - dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress()); - dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); - dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); - } /* - * else { Pattern - * patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern - * patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher - * matchernV4Subnet=patternV4Subnet.matcher(srcIp.getSrcIpAddress()); Matcher - * matcherV6Subnet=patternV6Subnet.matcher(srcIp.getSrcIpAddress()); - * if(matchernV4Subnet.matches()) { Integer srcMaskNum = - * Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]); if(srcMaskNum==0){ - * dstIp.setSrcIpMask("0.0.0.0"); }else{ - * dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum)); } - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); }else - * if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork = - * IPv6Network.fromString(srcIp.getSrcIpAddress()); - * dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]); - * dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { throw new RuntimeException("Invalid IP/subnet mask format"); } } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } else { - if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - dstIp.setSrcIp(srcIp.getSrcIpAddress()); - dstIp.setSrcIpMask("255.255.255.255"); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - dstIp.setSrcIp(srcIp.getSrcIpAddress()); - dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } /* - * else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP); - * Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher - * matcherV4=patternV4.matcher(srcIp.getSrcIpAddress()); Matcher - * matcherV6=patternV6.matcher(srcIp.getSrcIpAddress()); if(matcherV4.matches()) - * { dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); }else if(matcherV6.matches()) { - * dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw - * new RuntimeException("Invalid IP format"); } } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } - } else { - if (srcIp.getIpType() == 4/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - dstIp.setSrcIp(srcIp.getSrcIpAddress()); - dstIp.setSrcIpMask("255.255.255.255"); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - dstIp.setSrcIp(srcIp.getSrcIpAddress()); - dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } /* - * else {//all dstIp.setSrcIp(srcIp.getSrcIpAddress()); - * dstIp.setSrcIpMask("255.255.255.255"); } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } - if (srcIp.getDestIpAddress() != null) { - if (srcIp.getDestIpAddress().indexOf("/") != -1) { - if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); - if (dstMaskNum == 0) { - dstIp.setDstIpMask("0.0.0.0"); - } else { - dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum)); - ; - } - dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress()); - dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); - dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); - } /* - * else { Pattern - * patternV4Subnet=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP); Pattern - * patternV6Subnet=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP); Matcher - * matchernV4Subnet=patternV4Subnet.matcher(srcIp.getDestIpAddress()); Matcher - * matcherV6Subnet=patternV6Subnet.matcher(srcIp.getDestIpAddress()); - * if(matchernV4Subnet.matches()) { Integer dstMaskNum = - * Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]); if(dstMaskNum==0){ - * dstIp.setDstIpMask("0.0.0.0"); }else{ - * dstIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));; } - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); }else - * if(matcherV6Subnet.matches()){ IPv6Network strangeNetwork = - * IPv6Network.fromString(srcIp.getDestIpAddress()); - * dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]); - * dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString()); }else - * { throw new RuntimeException("Invalid IP/subnet mask format"); } } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - - } else { - if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - dstIp.setDstIp(srcIp.getDestIpAddress()); - dstIp.setDstIpMask("255.255.255.255"); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - dstIp.setDstIp(srcIp.getDestIpAddress()); - dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } /* - * else {//all Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP); - * Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP); Matcher - * matcherV4=patternV4.matcher(srcIp.getDestIpAddress()); Matcher - * matcherV6=patternV6.matcher(srcIp.getDestIpAddress()); - * if(matcherV4.matches()) { dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); }else if(matcherV6.matches()) { - * dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); }else { throw - * new RuntimeException("invalid ip format"); } } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } - } else { - if (srcIp.getIpType() == 4/* || srcIp.getIpType()==64 */) {// 64表示源ip为ipv6,目的ip为ipv4 - dstIp.setDstIp(srcIp.getDestIpAddress()); - dstIp.setDstIpMask("255.255.255.255"); - } else if (srcIp.getIpType() == 6/* || srcIp.getIpType()==46 */) {// 46表示源ip为ipv4,目的ip为ipv6 - dstIp.setDstIp(srcIp.getDestIpAddress()); - dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"); - } /* - * else {//all dstIp.setDstIp(srcIp.getDestIpAddress()); - * dstIp.setDstIpMask("255.255.255.255"); } - */ - else { - throw new RuntimeException("Unsupported IP type " + srcIp.getIpType()); - } - } - if (srcIp.getSrcPort() != null) { - if (srcIp.getSrcPort().indexOf("/") != -1) { - String srcMaskNum = srcIp.getSrcPort().split("/")[1]; - dstIp.setSrcPortMask(srcMaskNum); - dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]); - } else { - dstIp.setSrcPort(srcIp.getSrcPort()); - dstIp.setSrcPortMask("65535"); - } - } else { - dstIp.setSrcPort("0"); - dstIp.setSrcPortMask("65535"); - } - if (srcIp.getDestPort() != null) { - if (srcIp.getDestPort().indexOf("/") != -1) { - String dstMaskNum = srcIp.getDestPort().split("/")[1]; - dstIp.setDstPortMask(dstMaskNum); - dstIp.setDstPort(srcIp.getDestPort().split("/")[0]); - } else { - dstIp.setDstPort(srcIp.getDestPort()); - dstIp.setDstPortMask("65535"); - } - } else { - dstIp.setDstPort("0"); - dstIp.setDstPortMask("65535"); - } - ipConvertList.add(dstIp); - } - return ipConvertList; - } - - /** - * 设置端口值 - * - * @param dstIp - * @param srcIp - */ - public static void convertPortValues(IpCfg dstIp, BaseIpCfg srcIp) { - if (srcIp.getSrcPort() != null) { - if (srcIp.getSrcPort().indexOf("/") != -1) { - String srcMaskNum = srcIp.getSrcPort().split("/")[1]; - dstIp.setSrcPortMask(srcMaskNum); - dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]); - } else { - dstIp.setSrcPort(srcIp.getSrcPort()); - dstIp.setSrcPortMask("65535"); - } - } else { - dstIp.setSrcPort("0"); - dstIp.setSrcPortMask("65535"); - } - if (srcIp.getDestPort() != null) { - if (srcIp.getDestPort().indexOf("/") != -1) { - String dstMaskNum = srcIp.getDestPort().split("/")[1]; - dstIp.setDstPortMask(dstMaskNum); - dstIp.setDstPort(srcIp.getDestPort().split("/")[0]); - } else { - dstIp.setDstPort(srcIp.getDestPort()); - dstIp.setDstPortMask("65535"); - } - } else { - dstIp.setDstPort("0"); - dstIp.setDstPortMask("65535"); - } - } - - // 拦截策略 - public static ProxyObjKeyring convertCallBackProxyObjKeyring(PxyObjKeyring cfg) { - ProxyObjKeyring proxyObjKeyring = new ProxyObjKeyring(); - proxyObjKeyring.setId(Long.valueOf(cfg.getCompileId())); - proxyObjKeyring.setCfgId(cfg.getCompileId()); - proxyObjKeyring.setCrl(cfg.getCrl()); - proxyObjKeyring.setExpireAfter(cfg.getExpireAfter()); - proxyObjKeyring.setKeyringId(cfg.getCompileId()); - proxyObjKeyring.setKeyringName(keywordsEscape(cfg.getCfgDesc())); - proxyObjKeyring.setKeyringType(cfg.getKeyringType()); - proxyObjKeyring.setPrivateKeyFile(cfg.getPrivateKeyFile()); - proxyObjKeyring.setPublicKeyAlgo(cfg.getPublicKeyAlgo()); - proxyObjKeyring.setPublicKeyFile(cfg.getPublicKeyFile()); - proxyObjKeyring.setService(cfg.getServiceId()); - proxyObjKeyring.setIsValid(cfg.getIsValid()); - proxyObjKeyring.setOpTime(cfg.getAuditTime()); - return proxyObjKeyring; - } - // 拦截策略 - public static IpReusePolicyCfg convertCallBackSnatPolicy(IpReusePolicyCfg cfg) { - if(cfg != null) { - String areaEffectiveIds=cfg.getAreaEffectiveIds(); - if(StringUtils.isEmpty(areaEffectiveIds)){ - areaEffectiveIds="0"; - }else { - // 组织区域、运营商配置下发格式 - SysDictInfoService service = SpringContextHolder.getBean(SysDictInfoService.class); - areaEffectiveIds = service.setEffectiveRange(areaEffectiveIds); - } - cfg.setAreaEffectiveIds(areaEffectiveIds); - cfg.setUserName(keywordsEscape(cfg.getUserName())); - } - return cfg; - } - - // 可信证书 - public static List convertCallBackProxyObjTrustedCa(PxyObjTrustedCaCert cfgCert, - PxyObjTrustedCaCrl cfgCrl) { - List proxyObjTrustedCas = new ArrayList<>(); - if (cfgCert != null && !StringUtil.isEmpty(cfgCert.getCompileId())) { - ProxyObjTrustedCa proxyObjTrustedCaCert = new ProxyObjTrustedCa(); - proxyObjTrustedCaCert.setId(Long.valueOf(cfgCert.getCompileId())); - proxyObjTrustedCaCert.setCfgId(cfgCert.getCompileId()); - proxyObjTrustedCaCert.setCertId(cfgCert.getCompileId()); - proxyObjTrustedCaCert.setCertName(keywordsEscape(cfgCert.getCfgDesc())); - proxyObjTrustedCaCert.setCertFile(cfgCert.getCertFile()); - proxyObjTrustedCaCert.setService(cfgCert.getServiceId()); - proxyObjTrustedCaCert.setIsValid(cfgCert.getIsValid()); - proxyObjTrustedCaCert.setOpTime(cfgCert.getAuditTime()); - proxyObjTrustedCas.add(proxyObjTrustedCaCert); - } - if (cfgCrl != null && !StringUtil.isEmpty(cfgCrl.getCompileId())) { - ProxyObjTrustedCa proxyObjTrustedCaCert = new ProxyObjTrustedCa(); - proxyObjTrustedCaCert.setId(Long.valueOf(cfgCrl.getCompileId())); - proxyObjTrustedCaCert.setCfgId(cfgCrl.getCompileId()); - proxyObjTrustedCaCert.setCertId(cfgCrl.getCertId()); - proxyObjTrustedCaCert.setService(cfgCrl.getServiceId()); - proxyObjTrustedCaCert.setIsValid(cfgCrl.getIsValid()); - proxyObjTrustedCaCert.setOpTime(cfgCrl.getAuditTime()); - proxyObjTrustedCaCert.setCrlId(cfgCrl.getCompileId()); - proxyObjTrustedCaCert.setCrlFile(cfgCrl.getCrlFile()); - proxyObjTrustedCas.add(proxyObjTrustedCaCert); - } - - return proxyObjTrustedCas; - } - - // ip转换为callback用ip - public static NtcDnsResStrategy convertCallBackDnsResStrategy(DnsResStrategy cfg) { - NtcDnsResStrategy resStrategy = new NtcDnsResStrategy(); - resStrategy.init(); - resStrategy.setId(Long.valueOf(cfg.getCompileId())); - resStrategy.setCfgId(cfg.getCompileId()); - resStrategy.setReqStrateId(cfg.getCfgId()); - resStrategy.setStrateName(keywordsEscape(cfg.getCfgDesc())); - resStrategy.setAction(cfg.getAction()); - resStrategy.setService(cfg.getServiceId()); - resStrategy.setResGroup1Id(cfg.getResGroup1Id()); - resStrategy.setResGroup1Num(cfg.getResGroup1Num()); - resStrategy.setMinTtl(cfg.getMinTtl()); - resStrategy.setMaxTtl(cfg.getMaxTtl()); - resStrategy.setIsValid(cfg.getIsValid()); - resStrategy.setOpTime(cfg.getAuditTime()); - return resStrategy; - } - - // ip转换为callback用ip - public static InlineIp convertCallBackIp(BaseIpCfg cfg, Integer policyGroup) { - List cfgs = ipConvert(new IpCfg(), cfg); - if (cfgs.size() > 1) { - throw new RuntimeException("CallBack IP did not support IP range!"); - } - IpCfg c = cfgs.get(0); - InlineIp ip = new InlineIp(); - ip.setId(cfg.getCompileId()); - ip.setCfgId(cfg.getCompileId()); - ip.setAction(cfg.getAction()); - ip.setService(cfg.getServiceId()); - ip.setAddrType(cfg.getIpType()); - ip.setSrcIp(c.getSrcIp()); - ip.setMaskSrcIp(c.getSrcIpMask()); - ip.setDstIp(c.getDstIp()); - ip.setMaskDstIp(c.getDstIpMask()); - ip.setSrcPort(c.getSrcPort()); - ip.setMaskSrcPort(c.getSrcPortMask()); - ip.setDstPort(c.getDstPort()); - ip.setMaskDstPort(c.getDstPortMask()); - ip.setProtocol(cfg.getProtocol()); - ip.setDirection(cfg.getDirection()); - ip.setIsValid(cfg.getIsValid()); - ip.setOpTime(cfg.getAuditTime()); - ip.setPolicyGroup(policyGroup); - ip.setAreaEffectiveIds(cfg.getAreaEffectiveIds());//添加区域管控 - return ip; - } - - // 区域IPsetAreaEffectiveIds设置 - public void setAreaEffectiveIds(BaseCfg entity) { - List areaCfg = entity.getAreaCfg(); - List areaIsps = entity.getAreaIsp(); - if (Constants.IS_AREA_EFFECTIVE_NO == entity.getIsAreaEffective()) { - entity.setAreaEffectiveIds(""); - entity.setAreaType(null); - } else if (Constants.IS_AREA_EFFECTIVE_YES == entity.getIsAreaEffective()) { - if (Constants.AREA_EFFECTIVE_TYPE_AREA_ISP == entity.getAreaType() && areaIsps != null - && areaIsps.size() > 0) { - StringBuffer areaEffectiveIds = new StringBuffer(); - for (int i = 0; i < areaIsps.size(); i++) { - if (StringUtils.isBlank(areaIsps.get(i).getArea())) { - areaEffectiveIds.append(areaIsps.get(i).getIsp()); - } else if (StringUtils.isBlank(areaIsps.get(i).getIsp())) { - areaEffectiveIds.append(areaIsps.get(i).getArea()); - } else { - areaEffectiveIds.append(areaIsps.get(i).getArea() + ":" + areaIsps.get(i).getIsp()); - } - if (i != areaIsps.size() - 1) { - areaEffectiveIds.append(","); - } - } - entity.setAreaEffectiveIds(areaEffectiveIds.toString()); - } else if (Constants.AREA_EFFECTIVE_TYPE_AREA_IP == entity.getAreaType() && areaCfg != null - && areaCfg.size() > 0) { - entity.setAreaEffectiveIds(""); - } - } - } - - public static String keywordsEscape(String cfgKeywords) { - if (StringUtils.isNotEmpty(cfgKeywords)) { - // 不转译特殊字符 - cfgKeywords = cfgKeywords.trim();// 首先去掉首尾空格 - cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords); - cfgKeywords = cfgKeywords.replace("\\", "\\\\"); - cfgKeywords = cfgKeywords.replace("&", "\\&"); - cfgKeywords = cfgKeywords.replace(" ", "\\b"); - // ***and***在界面表示多个关键字的与表达式,此特殊字符串在common.js中使用定义,maat端以&表示 - cfgKeywords = cfgKeywords.replace(Constants.KEYWORD_EXPR, "&"); - - } - return cfgKeywords; - } - - public static String replaceContentEscape(String replaceContent) { - if (StringUtils.isNotEmpty(replaceContent)) { - // 不转译特殊字符 - replaceContent = replaceContent.trim();// 首先去掉首尾空格 - replaceContent = replaceContent.replace("/", "\\/");// 首先转意斜杠“/” - } - return replaceContent; - } - - // asn IP 复用转换 - public List groupReuseCfgAddRemoveConvert(List> ipCfgList, Integer isValid, - Integer groupId) { - logger.warn("convert data start"); - long start = System.currentTimeMillis(); - Date opTime = new Date(); - List maatIpList = new ArrayList<>(); - if (ipCfgList.size() > 0) { - // 只用一次instanceof,取代循环中每次都用一次instanceof - if (ipCfgList.get(0) instanceof AsnIpCfg) { - for (BaseCfg _cfg : ipCfgList) { - IpCfg cfg = new IpCfg(); - BaseIpCfg baseIpCfg = new BaseIpCfg(); - AsnIpCfg asnIpCfg = (AsnIpCfg) _cfg; - BeanUtils.copyProperties(asnIpCfg, baseIpCfg); - BeanUtils.copyProperties(baseIpCfg, cfg); - cfg.setGroupId(asnIpCfg.getAsnIpGroup()); - cfg.setRegionId(asnIpCfg.getRegionId()); - String userRegion = "ASN_ID=" + asnIpCfg.getUserRegion1(); - cfg.setUserRegion(userRegion); - cfg.setIsValid(isValid); - cfg.setAuditTime(opTime); - List cfgs = ipConvert(cfg, baseIpCfg); - maatIpList.addAll(cfgs); - } - } else if (ipCfgList.get(0) instanceof AppIpCfg) { - for (BaseCfg _cfg : ipCfgList) { - IpCfg cfg = new IpCfg(); - BaseIpCfg baseIpCfg = new BaseIpCfg(); - AppIpCfg appIpCfg = (AppIpCfg) _cfg; - BeanUtils.copyProperties(appIpCfg, baseIpCfg); - BeanUtils.copyProperties(baseIpCfg, cfg); - cfg.setGroupId(groupId); - cfg.setRegionId(Integer.parseInt(appIpCfg.getUserRegion1())); - String userRegion = "APP_ID=" + appIpCfg.getAppCode(); - cfg.setUserRegion(userRegion); - cfg.setIsValid(isValid); - cfg.setAuditTime(opTime); - List cfgs = ipConvert(cfg, baseIpCfg); - maatIpList.addAll(cfgs); - } - } - } - long end = System.currentTimeMillis(); - logger.warn("convert data finish,cost:" + (end - start)); - return maatIpList; - } - public MaatCfg convertMaatCfg(BaseCfg _cfg,Integer cfgType) { - MaatCfg maatCfg = new MaatCfg(); - maatCfg.initDefaultValue(); - BeanUtils.copyProperties(_cfg, maatCfg); - maatCfg.setAction(_cfg.getAction()); - maatCfg.setAuditTime(_cfg.getAuditTime()); - Map regions=cfgConvert(_cfg, cfgType); - if(regions.get("ipRegionList")!=null) { - maatCfg.setIpRegionList(regions.get("ipRegionList")); - }else { - maatCfg.setIpRegionList(new ArrayList()); - } - if(regions.get("strRegionList")!=null) { - maatCfg.setStrRegionList(regions.get("strRegionList")); - }else { - maatCfg.setStrRegionList(new ArrayList()); - } - if(regions.get("numRegionList")!=null) { - maatCfg.setNumRegionList(regions.get("numRegionList")); - }else { - maatCfg.setNumRegionList(new ArrayList()); - } - if(regions.get("digestRegionList")!=null) { - maatCfg.setDigestRegionList(regions.get("digestRegionList")); - }else { - maatCfg.setDigestRegionList(new ArrayList()); - } - if(regions.get("groupRelationList")!=null) { - maatCfg.setGroupRelationList(regions.get("groupRelationList")); - maatCfg.setGroupNum(regions.get("groupRelationList").size()); - }else { - maatCfg.setGroupRelationList(new ArrayList()); - maatCfg.setGroupNum(0); - } - - maatCfg.setAreaIpRegionList(new ArrayList()); - maatCfg.setIsValid(_cfg.getIsValid()); - return maatCfg; - } - /** - * MaatCfg 追加region - */ - public MaatCfg maatCfgAppendRegion(MaatCfg maatCfg,BaseCfg _cfg,Integer cfgType) { - if(maatCfg==null) return maatCfg; - Map regions=cfgConvert(_cfg, cfgType); - if(regions.get("ipRegionList")!=null) { - maatCfg.getIpRegionList().addAll(regions.get("ipRegionList")); - } - if(regions.get("strRegionList")!=null) { - maatCfg.getStrRegionList().addAll(regions.get("strRegionList")); - } - if(regions.get("numRegionList")!=null) { - maatCfg.getNumRegionList().addAll(regions.get("numRegionList")); - } - if(regions.get("digestRegionList")!=null) { - maatCfg.getDigestRegionList().addAll(regions.get("digestRegionList")); - } - if(regions.get("groupRelationList")!=null) { - maatCfg.getGroupRelationList().addAll(regions.get("groupRelationList")); - maatCfg.setGroupNum(maatCfg.getGroupNum()+regions.get("groupRelationList").size()); - } - return maatCfg; - } - /** - * 分割并保存 - * @param regionDict - * @param serviceDict - * @param specificServiceCfg - * @param asnNoMap - * @param list - * @param cfgIndexInfos - * @param appPolicyCfgs - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAndSend(FunctionRegionDict regionDict,FunctionServiceDict serviceDict, - SpecificServiceCfg specificServiceCfg, - List list,List cfgIndexInfos, - List appPolicyCfgs, - List appFeatureCfgs, - List> asnNoMaps, - boolean send){ - if(list!=null&&list.size()>0) { - String type=null; - if (list.get(0) instanceof BaseIpCfg) { - type="BaseIpCfg"; - }else if(list.get(0) instanceof BaseStringCfg) { - type="BaseStringCfg"; - }else if(list.get(0) instanceof ComplexkeywordCfg) { - type="ComplexkeywordCfg"; - }else if(list.get(0) instanceof DnsResStrategy) { - type="DnsResStrategy"; - }else if(list.get(0) instanceof AsnIpCfg) { - type="AsnIpCfg"; - }else if(list.get(0) instanceof AppComplexFeatureCfg) { - type="AppComplexFeature"; - }else if(list.get(0) instanceof AppTopicDomainCfg) { - type="AppTopicDomain"; - } - - if(regionDict.getFunctionId().equals(214)) { // 处理IpSpoofing配置导入 - this.saveAndSendSpoofingIpPool(list,cfgIndexInfos,send); - } - if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) { - this.saveCfgIndexOf(cfgIndexInfos); - } - if (appPolicyCfgs != null && appPolicyCfgs.size() > 0) { - this.savePolicyList(regionDict,serviceDict,appPolicyCfgs,list,send); - } - if (appFeatureCfgs != null && appFeatureCfgs.size() > 0) { - this.saveAppFeatureList(appFeatureCfgs); - } - - if("BaseIpCfg".equals(type)) { - List listPage = (List) list; - if (specificServiceCfg!=null&®ionDict.getFunctionId().equals(405)) { - this.saveAppIpCfg((List)listPage,specificServiceCfg,send); - }else if(appPolicyCfgs==null||appPolicyCfgs.isEmpty()){ - this.saveIpBatch(regionDict,serviceDict,(List)listPage,send); - } - }else if("AsnIpCfg".equals(type)) { - List listPage = (List) list; - this.saveAsnIpBatch(listPage,asnNoMaps,send); - }else if("AppComplexFeature".equals(type)) {// APP Payload - List listPage = (List) list; - this.saveAppComplexFeatureBatch(regionDict,serviceDict,listPage,send); - }else if("AppTopicDomain".equals(type)) {// 主题网站 - List listPage = (List) list; - this.saveTopicDomainCfgBatch(regionDict,serviceDict,listPage,send); - }else if("BaseStringCfg".equals(type)) { - List> listPage = (List>) list; - // 调用对应配置的service - // ip_payload - if (regionDict.getDictId().intValue() == 167) { - // interceptCfgService.saveInterceptCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "intercept_pkt_bin",send); - }else - // http url - if (regionDict.getDictId().intValue() == 9||regionDict.getDictId().intValue() == 15 || regionDict.getDictId().intValue() == 596) { - // websiteCfgService.saveHttpUrlCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "http_url_cfg",send); - }else - // FTP url/content - if (regionDict.getDictId().intValue() == 36||regionDict.getDictId().intValue() == 37) { - // fileTransferCfgService.saveFtpCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "ftp_keyword_cfg",send); - }else - // P2P eMule Keyword - if(regionDict.getDictId().intValue() == 158){ - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "p2p_keyword_cfg",send); - }else - // P2P File Marking - if(regionDict.getDictId().intValue() == 159){ - // fileTransferCfgService.saveP2pCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "p2p_hash_cfg",send); - }else - // BGP AS - if (regionDict.getFunctionId().equals(61)) { - // bgpCfgService.saveBgpAsCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "ntc_bgp_as_cfg",send); - }else - // SSL SNI/SAN/CN - if (regionDict.getFunctionId().intValue() == 34) { - // websiteCfgService.saveSslCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "ssl_keyword_cfg",send); - }else - // HTTP 请求/应答内容 - if(regionDict.getDictId().intValue()==12||regionDict.getDictId().intValue()==13||regionDict.getDictId().intValue()==601||regionDict.getDictId().intValue()==602) { - // websiteCfgService.saveHttpBodyCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "http_body_cfg",send); - }else - // 流媒体协议 - if(regionDict.getDictId().intValue()==25){ - // avContentCfgService.saveContUrlCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "av_cont_url_cfg",send); - }else - // Voip Account - if(regionDict.getDictId().intValue()==16){ - // avContentCfgService.saveVoIpAccountCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "av_voip_account_cfg",send); - }else - // APP域名特征 - if(regionDict.getDictId().intValue()==64){ - // appCfgService.saveAppDomainCfg(listPage); - this.saveStringCfgBatch(regionDict,serviceDict,listPage, AppDomainCfg.getTablename(),send); - }else - // 域名拦截 - if(regionDict.getDictId().intValue()==56){ - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "http_url_cfg",send); - } - //账号 - else if("subscribe_id".equals(regionDict.getConfigServiceType())&&(appPolicyCfgs==null||appPolicyCfgs.isEmpty())){ - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "ntc_subscribe_id_cfg",send); - } - // HTTP(s) URL - else if(regionDict.getDictId().intValue()==97 || regionDict.getDictId().intValue()==79 || - regionDict.getDictId().intValue()==85 || regionDict.getDictId().intValue()==91 || - regionDict.getDictId().intValue()==99){ - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "http_url_cfg",send); - } - // HTTP(s) 请求/应答内容 - else if(regionDict.getDictId().intValue()==94 || regionDict.getDictId().intValue()==95 || - regionDict.getDictId().intValue()==88 || regionDict.getDictId().intValue()==89 || - regionDict.getDictId().intValue()==82 || regionDict.getDictId().intValue()==83 || - regionDict.getDictId().intValue()==103 || regionDict.getDictId().intValue()==104){ - this.saveStringCfgBatch(regionDict,serviceDict,listPage, "http_body_cfg",send); - } - }else if("ComplexkeywordCfg".equals(type)) { - List listPage = (List) list; - // DNS - if (regionDict.getDictId().intValue() == 28) { - // websiteCfgService.saveDnsCfg(listPage); - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "dns_domain_cfg",send); - }else - // Mail - if (regionDict.getDictId().intValue() == 30 || regionDict.getDictId().intValue() == 31||regionDict.getDictId().intValue() == 599) { - // mailCfgService.saveMailCfg(listPage); - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "mail_keyword_cfg",send); - }else - // HTTP请求头域 - if(regionDict.getDictId().intValue()==10) { - // websiteCfgService.saveHttpReqHeadCfg(listPage); - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "http_req_head_cfg",send); - }else - // HTTP响应头域 - if(regionDict.getDictId().intValue()==11) { - // websiteCfgService.saveHttpResHeadCfg(listPage); - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "http_res_head_cfg",send); - }else - // APP http特征 - if(regionDict.getDictId().intValue()==63) { - // appCfgService.saveAppHttpCfg(listPage); - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, AppHttpCfg.getTablename(),send); - }else - //app Http特征 - if(regionDict.getDictId().intValue()==220 || regionDict.getDictId().intValue()==216 || regionDict.getDictId().intValue()==224){ - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage,"app_complex_feature_cfg",send); - } - // HTTP(s)请求头域 - if(regionDict.getDictId().intValue()==98 || regionDict.getDictId().intValue()==80 || - regionDict.getDictId().intValue()==86 || regionDict.getDictId().intValue()==92 || - regionDict.getDictId().intValue()==100) { - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "http_req_head_cfg",send); - }else - // HTTP(s)响应头域 - if(regionDict.getDictId().intValue()==102 || regionDict.getDictId().intValue()==81 || - regionDict.getDictId().intValue()==87 || regionDict.getDictId().intValue()==93) { - this.saveComplexkeywordCfgBatch(regionDict,serviceDict,listPage, "http_res_head_cfg",send); - } - }else if("DnsResStrategy".equals(type)) { - List listPage = (List) list; - // dnsResStrategyService.saveDnsResStrategies(listPage); - this.saveDnsResStrategyCfgBatch(listPage); - } - } - } - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAsnIpBatch(List cfgs,List> asnNoMaps,boolean send){ - logger.warn("Start to save IP,size:"+cfgs.size()); - long start=System.currentTimeMillis(); - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - //需要通过新增域接口新增的ip集合 - List toAddRegionAsnIpCfgs=Lists.newArrayList(); - Map> toSendFirstAsnIpCfgs=Maps.newHashMap(); - Map asnGroupAddRegions=Maps.newHashMap(); -// AsnCacheUtils.init(true); - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(AsnIpCfg cfg:cfgs) { - ((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg); - if(send) { - AsnGroupInfo group=asnNoMaps.get(0).get(Long.parseLong(cfg.getUserRegion1())); - if(group==null) { - group=asnNoMaps.get(1).get(Long.parseLong(cfg.getUserRegion1())); - } - //AsnGroupInfo group=AsnCacheUtils.get(Long.parseLong(cfg.getUserRegion1())); - if(group!=null&&group.getIsValid().intValue()==1) { - if(asnGroupAddRegions.containsKey(group.getAsnId())) { - int count=asnGroupAddRegions.get(group.getAsnId()); - asnGroupAddRegions.put(group.getAsnId(), count+1); - }else { - asnGroupAddRegions.put(group.getAsnId(), 1); - } - toAddRegionAsnIpCfgs.add(cfg); - }else if(group!=null) { - if(toSendFirstAsnIpCfgs.containsKey(group.getAsnId())) { - toSendFirstAsnIpCfgs.get(group.getAsnId()).add(cfg); - }else { - toSendFirstAsnIpCfgs.put(group.getAsnId(), Lists.newArrayList()); - toSendFirstAsnIpCfgs.get(group.getAsnId()).add(cfg); - } - - - } - } - - } - if(send) { - if(toAddRegionAsnIpCfgs.size()>0) { - for(Entry asnGroupAddRegion:asnGroupAddRegions.entrySet()) { - AsnGroupInfo group=new AsnGroupInfo(); - group.setAsnId(asnGroupAddRegion.getKey()); - group.setIssuedIPs(asnGroupAddRegion.getValue()+0l); - ((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).modifyIssuedIp(group);; - } - asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES,Constants.OPACTION_POST); - } - if(toSendFirstAsnIpCfgs.size()>0) { - List configCompileList = new ArrayList(); - ToMaatBean maatBean = new ToMaatBean(); - for(Entry> info:toSendFirstAsnIpCfgs.entrySet()) { - AsnGroupInfo group=asnNoMaps.get(0).get(info.getKey()); - if(group==null) { - group=asnNoMaps.get(1).get(info.getKey()); - } - //AsnGroupInfo group=AsnCacheUtils.get(info.getKey()); - List groupRelationList = new ArrayList(); - List ipRegionList = new ArrayList(); - List strRegionList = new ArrayList(); - List numRegionList = new ArrayList(); - List digestRegionList = new ArrayList(); - List areaIpRegionList = new ArrayList(); - MaatCfg maatCfg = new MaatCfg(); - maatCfg.initDefaultValue(); - //group - GroupCfg groupCfg=new GroupCfg(); - groupCfg.setCompileId(group.getCompileId()); - groupCfg.setGroupId(group.getGroupId()); - groupCfg.setIsValid(Constants.VALID_YES); - groupCfg.setAuditTime(info.getValue().get(0).getAuditTime()); - groupRelationList.add(groupCfg); - BeanUtils.copyProperties(info.getValue().get(0), maatCfg); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(info.getValue(),Constants.VALID_YES,group.getGroupId())); - maatCfg.setCompileId(group.getCompileId()); - maatCfg.setAction(info.getValue().get(0).getAction()); - maatCfg.setAuditTime(info.getValue().get(0).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(info.getValue().get(0).getIsValid()); - // 设置自定义域 - String userRegion = "ASN_ID=" + info.getKey(); - maatCfg.setUserRegion(userRegion); - configCompileList.add(maatCfg); - - group.setIsValid(1); - group.setIssuedIPs(info.getValue().size()+0L); - ((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).updateValid(group); - } - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(cfgs.get(0).getAuditTime()); - maatBean.setCreatorName(cfgs.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = gsonToJson(maatBean); - if(configCompileList.size()<=100) { - logger.info("asn IP配置下发配置参数:" + json); - }else { - logger.info("asn IP配置下发配置数量:" + configCompileList.size()); - } - - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("asn IP配置下发响应信息:" + result.getMsg()); - } - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - long end=System.currentTimeMillis(); - logger.warn("Save IP finish,cost:"+(end-start)); - cfgs.clear(); - toAddRegionAsnIpCfgs.clear(); - cfgs=null; - toAddRegionAsnIpCfgs=null; - } - /** - * 导入配置时数据批量入库 - * @param data - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveDnsResStrategyCfgBatch(List data) { - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < data.size();index++){ - DnsResStrategy cfg = data.get(index); - ((DnsResStrategyDao) batchSqlSession.getMapper(DnsResStrategyDao.class)).insert(cfg); - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - - } - - /** - * 导入配置时数据批量入库 - * @param serviceDict - * @param regionDict - * @param data - * @param send - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveTopicDomainCfgBatch(FunctionRegionDict regionDict, FunctionServiceDict serviceDict, List data, boolean send) { - if (regionDict != null) { - Integer regionType = regionDict.getRegionType(); - if (2 == regionType.intValue()) { - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - AppCfgDao appCfgDao = SpringContextHolder.getBean(AppCfgDao.class); - List configCompileList = new ArrayList(); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < data.size();index++){ - AppTopicDomainCfg cfg = data.get(index); - ((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppTopicDomainCfgBatch(cfg); - if (send) { - if(regionDict.getIsMaat().intValue()==1) { - MaatCfg maatCfg=convertMaatCfg(cfg,2); - //userRegion处理 - WebsiteDomainTopic websiteDomainTopic = new WebsiteDomainTopic(); - websiteDomainTopic.setDomain(cfg.getCfgKeywords()); - List domainDict = appCfgDao.getDomainDict(websiteDomainTopic); - Long domainId = domainDict.get(0).getId(); - maatCfg.setUserRegion("WEB_ID=" + domainId); - configCompileList.add(maatCfg); - } - } - - } - if (send && configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("APP主题网站配置下发配置参数:" + configCompileList.size()); - }else { - logger.info("APP主题网站配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("APP主题网站配置下发响应信息:" + result.getMsg()); - - } - batchSqlSession.commit(); - - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - - } - } - } - - } - - /** - * APP Payload导入配置时数据批量入库 - * @param serviceDict - * @param regionDict - * @param data - * @param send - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAppComplexFeatureBatch(FunctionRegionDict regionDict, FunctionServiceDict serviceDict, List data, boolean send) { - if (regionDict != null) { - Integer regionType = regionDict.getRegionType(); - if (3 == regionType.intValue()) { - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - List configCompileList = new ArrayList(); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < data.size();index++){ - AppComplexFeatureCfg cfg = data.get(index); - ((AppMultiFeatureCfgDao) batchSqlSession.getMapper(AppMultiFeatureCfgDao.class)).insertAppComplexFeatureCfgBatch(cfg); - if (send) { - if(regionDict.getIsMaat().intValue()==1) { - MaatCfg maatCfg=convertMaatCfg(cfg,3); - //userRegion处理 - if(regionDict.getFunctionId()==563) { - maatCfg.setUserRegion(Constants.APP_ID_REGION+"="+cfg.getAppCode()); - } - configCompileList.add(maatCfg); - } - } - - } - if (send && configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("APP Feature增强字符串配置下发配置条数:" + configCompileList.size()); - }else { - logger.info("APP Feature增强字符串配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("APP Feature增强字符串配置下发响应信息:" + result.getMsg()); - - } - batchSqlSession.commit(); - - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - - } - } - } - - } - - /** - * 同一个app下的ip批量保存 - * @param cfgs - * @param specificServiceCfg - * @throws Exception - */ - @Transactional(readOnly = false, rollbackFor = RuntimeException.class) - public void saveAppIpCfg(List cfgs,SpecificServiceCfg specificServiceCfg,boolean send){ - logger.warn("Start to save IP"); - ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class); - SpecificServiceCfgDao specificServiceCfgDao=SpringContextHolder.getBean(SpecificServiceCfgDao.class); - AppCfgDao appCfgDao=SpringContextHolder.getBean(AppCfgDao.class); - long start=System.currentTimeMillis(); - ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId()); - if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。 - Integer groupId = ConfigServiceUtil.getId(2, 1).get(0); - Integer compileId=ConfigServiceUtil.getId(1, 1).get(0); - specificServiceCfg.setGroupId(groupId); - configGroupInfo = new ConfigGroupInfo(); - configGroupInfo.setGroupId(specificServiceCfg.getGroupId()); - configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName()); - configGroupInfo.setIsIssued(0); - configGroupInfo.setGroupType(1); - configGroupInfo.setCompileId(compileId); - configGroupInfoDao.insertConfigGroupInfo(configGroupInfo); - //更新group_id - specificServiceCfg.setOpTime(new Date()); - specificServiceCfgDao.update(specificServiceCfg); - } - Integer compileId = configGroupInfo.getCompileId(); -// Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet"); - List tempList=Lists.newArrayList(); - - int len=0; - int index=0; - for(BaseIpCfg cfg:cfgs) { - AppIpCfg entity=new AppIpCfg(); - BeanUtils.copyProperties(cfg, entity); - entity.setCompileId(compileId); - cfg.setCompileId(compileId); - cfg.setGroupId(specificServiceCfg.getGroupId()); - int tempLen=entity.toString().getBytes(Charset.forName("UTF-8")).length; - if((len+tempLen) configCompileList = new ArrayList(); - List groupRelationList = new ArrayList(); - List ipRegionList = new ArrayList(); - List strRegionList = new ArrayList(); - List numRegionList = new ArrayList(); - List digestRegionList = new ArrayList(); - List areaIpRegionList = new ArrayList(); - if(configGroupInfo.getIsIssued()==0) {//未下发,下发region compile,group. - MaatCfg maatCfg = new MaatCfg(); - ToMaatBean maatBean = new ToMaatBean(); - maatCfg.initDefaultValue(); - //group - GroupCfg groupCfg=new GroupCfg(); - groupCfg.setCompileId(compileId); - groupCfg.setGroupId(configGroupInfo.getGroupId()); - groupCfg.setIsValid(Constants.VALID_YES); - groupCfg.setAuditTime(tempList.get(0).getAuditTime()); - groupRelationList.add(groupCfg); - BeanUtils.copyProperties(cfgs.get(0), maatCfg); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId())); - maatCfg.setAction(tempList.get(0).getAction()); - maatCfg.setAuditTime(tempList.get(0).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(tempList.get(0).getIsValid()); - // 设置APP自定义域 - String userRegion = "APP_ID=" + tempList.get(0).getAppCode()/*+Constants.USER_REGION_SPLIT+"ASEV_ID="+businessType*/; - maatCfg.setUserRegion(userRegion); - configCompileList.add(maatCfg); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(tempList.get(0).getAuditTime()); - maatBean.setCreatorName(tempList.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = gsonToJson(maatBean); - logger.info("app协议IP配置下发配置参数:" + json); - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("app协议IP配置下发响应信息:" + result.getMsg()); - configGroupInfo.setIsIssued(1); - configGroupInfo.setUpdateTime(new Date()); - configGroupInfoDao.updateConfigGroupInfobyGroupId(configGroupInfo); - }else if(configGroupInfo.getIsIssued()==1) {//已经下发,分组复用下发 - GroupReuseAddBean maatBean = new GroupReuseAddBean(); - List groupReuseList=new ArrayList<>(); - GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); - /*groupReuseCfg.setUserRegion(userRegion);*/ - /*groupReuseCfg.setServiceId(tempList.get(0).getServiceId());*/ - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId())); - groupReuseCfg.setIpRegionList(ipRegionList); - groupReuseCfg.setStrRegionList(strRegionList); - groupReuseCfg.setNumRegionList(numRegionList); - groupReuseList.add(groupReuseCfg); - maatBean.setGroupReuseCfgList(groupReuseList); - maatBean.setAuditTime(tempList.get(0).getAuditTime()); - maatBean.setCreatorName(tempList.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - logger.info("app协议IP域新增配置下发配置参数:"+json); - //调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1); - logger.info("app协议IP域新增配置响应信息:"+result.getMsg()); - }else { - throw new RuntimeException("Unknown configGroupInfo isIssued value"); - } - } - tempList.clear(); - tempList.add(entity); - len=tempLen; - } - index ++; - } - if(tempList.size()>0) { - logger.warn("save ip size:"+tempList.size()); - appCfgDao.insertAppIpCfgBatch(tempList); - if(send) { - if(send) { - List configCompileList = new ArrayList(); - List groupRelationList = new ArrayList(); - List ipRegionList = new ArrayList(); - List strRegionList = new ArrayList(); - List numRegionList = new ArrayList(); - List digestRegionList = new ArrayList(); - List areaIpRegionList = new ArrayList(); - if(configGroupInfo.getIsIssued()==0) {//未下发,下发region compile,group. - MaatCfg maatCfg = new MaatCfg(); - ToMaatBean maatBean = new ToMaatBean(); - maatCfg.initDefaultValue(); - //group - GroupCfg groupCfg=new GroupCfg(); - groupCfg.setCompileId(compileId); - groupCfg.setGroupId(configGroupInfo.getGroupId()); - groupCfg.setIsValid(Constants.VALID_YES); - groupCfg.setAuditTime(tempList.get(0).getAuditTime()); - groupRelationList.add(groupCfg); - BeanUtils.copyProperties(cfgs.get(0), maatCfg); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId())); - maatCfg.setAction(tempList.get(0).getAction()); - maatCfg.setAuditTime(tempList.get(0).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(tempList.get(0).getIsValid()); - // 设置APP自定义域 - String userRegion = "APP_ID=" + tempList.get(0).getAppCode()/*+Constants.USER_REGION_SPLIT+"ASEV_ID="+businessType*/; - maatCfg.setUserRegion(userRegion); - configCompileList.add(maatCfg); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(tempList.get(0).getAuditTime()); - maatBean.setCreatorName(tempList.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = gsonToJson(maatBean); - logger.info("app协议IP配置下发配置参数:" + json); - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("app协议IP配置下发响应信息:" + result.getMsg()); - configGroupInfo.setIsIssued(1); - configGroupInfo.setUpdateTime(new Date()); - configGroupInfoDao.updateConfigGroupInfobyGroupId(configGroupInfo); - }else if(configGroupInfo.getIsIssued()==1) {//已经下发,分组复用下发 - GroupReuseAddBean maatBean = new GroupReuseAddBean(); - List groupReuseList=new ArrayList<>(); - GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); - /*groupReuseCfg.setUserRegion(userRegion);*/ - /*groupReuseCfg.setServiceId(tempList.get(0).getServiceId());*/ - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId())); - groupReuseCfg.setIpRegionList(ipRegionList); - groupReuseCfg.setStrRegionList(strRegionList); - groupReuseCfg.setNumRegionList(numRegionList); - groupReuseList.add(groupReuseCfg); - maatBean.setGroupReuseCfgList(groupReuseList); - maatBean.setAuditTime(tempList.get(0).getAuditTime()); - maatBean.setCreatorName(tempList.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - logger.info("app协议IP域新增配置下发配置参数:"+json); - //调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1); - logger.info("app协议IP域新增配置响应信息:"+result.getMsg()); - }else { - throw new RuntimeException("Unknown configGroupInfo isIssued value"); - } - } - } - tempList.clear(); - } - long end=System.currentTimeMillis(); - logger.warn("Save IP finish,cost:"+(end-start)); - } - - /** - * 导入配置保存CfgIndex - * @param cfgIndexInfos - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveCfgIndexOf(List cfgIndexInfos){ - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < cfgIndexInfos.size();index++){ - CfgIndexInfo cfgIndexInfo = cfgIndexInfos.get(index); - ((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).saveCfgIndexForBatch(cfgIndexInfo); - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - } - /** - * 导入配置保存App策略 - * @param appPolicyCfgs - * @throws CloneNotSupportedException - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void savePolicyList(FunctionRegionDict regionDict,FunctionServiceDict serviceDict,List appPolicyCfgs,List list,boolean send){ - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - List configCompileList = new ArrayList(); - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < appPolicyCfgs.size();index++){ - AppPolicyCfg _cfg = appPolicyCfgs.get(index); - ((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppPolicyCfgForBatch(_cfg); - - } - if(send) { - StringBuffer cfgKeywords = new StringBuffer(); - if (appPolicyCfgs.get(0).getBehavCode() != null) { - if (regionDict.getFunctionId().equals(63)) { - cfgKeywords.append(Constants.APP_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()); - } else if (regionDict.getFunctionId().equals(407) - || regionDict.getFunctionId().equals(408)) { - cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()); - } - cfgKeywords.append(Constants.KEYWORD_EXPR); - cfgKeywords.append(Constants.BEHAV_ID_REGION + "=" + appPolicyCfgs.get(0).getBehavCode()); - // appPolicyCfgs.get(0.setCfgKeywords(appPolicyCfgs.get(0.getAppCode()+Constants.KEYWORD_EXPR+appPolicyCfgs.get(0.getBehavCode()); - } else { - if (regionDict.getFunctionId().equals(63)) { - cfgKeywords.append(Constants.APP_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()); - } else if (regionDict.getFunctionId().equals(407) - || regionDict.getFunctionId().equals(408)) { - cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()); - } - // entity.setCfgKeywords(entity.getAppCode()+""); - } - appPolicyCfgs.get(0).setCfgKeywords(cfgKeywords.toString()); - } - List groupIds=Lists.newArrayList(); - List regionIds=Lists.newArrayList(); - if(send) { - groupIds=ConfigServiceUtil.getId(2, list.size()); - regionIds=ConfigServiceUtil.getId(3, list.size()); - } - for(int index = 0; index < list.size();index++){ - MaatCfg maatCfg=null; - if(send) { - if(regionDict.getIsMaat().intValue()==1) { - AppPolicyCfg cfg=(AppPolicyCfg) appPolicyCfgs.get(0); - cfg.setCompileId(list.get(index).getCompileId()); - cfg.setRegionId(regionIds.get(index)); - cfg.setGroupId(groupIds.get(index)); - maatCfg=convertMaatCfg(cfg,2); - if(regionDict.getFunctionId()==407) {// Protocol Identify - //PROTOCOL IDENTITY USER_REGION PROTOCOL_ID=ProtocolId - maatCfg.setUserRegion(Constants.PROTO_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()); - - // 限速业务需要设置 USER_REGION Droprate=userregion3 - if (Constants.RATELIMIT_ACTION.equals(appPolicyCfgs.get(0).getAction())) { - appPolicyCfgs.get(0).setUserRegion1(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion1()) ? "0":appPolicyCfgs.get(0).getUserRegion1()); - //限速 需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps - if(appPolicyCfgs.get(0).getUserRegion1().equals("0")){//丢包率 - appPolicyCfgs.get(0).setUserRegion2(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion2()) ? "":appPolicyCfgs.get(0).getUserRegion2()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion2()); - }else if(appPolicyCfgs.get(0).getUserRegion1().equals("1")){//带宽 - appPolicyCfgs.get(0).setUserRegion3(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion3()) ? "":appPolicyCfgs.get(0).getUserRegion3()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion3()); - } - } - //DKC=8 USER_REGION DKC=userregion4 - if(!StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion4()) && Constants.REJECT_ACTION.equals(appPolicyCfgs.get(0).getAction())){ - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.APP_VIGNORE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion4()); - } - // USER_REGION config_id=compileId - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT+"config_id="+maatCfg.getCompileId()); - }else if(regionDict.getFunctionId()==63) {// APP Policy - //APP IDENTITY USER_REGION包含APP_ID=AppCode;BEHAV_ID=ProtocolId - maatCfg.setUserRegion(Constants.APP_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()+Constants.USER_REGION_SPLIT+ Constants.BEHAV_ID_REGION + "=" + appPolicyCfgs.get(0).getBehavCode()); - // 限速业务需要设置 - if (Constants.RATELIMIT_ACTION.equals(appPolicyCfgs.get(0).getAction())) { - appPolicyCfgs.get(0).setUserRegion1(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion1()) ? "0":appPolicyCfgs.get(0).getUserRegion1()); - //限速 需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps - if(appPolicyCfgs.get(0).getUserRegion1().equals("0")){//丢包率 - appPolicyCfgs.get(0).setUserRegion2(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion2()) ? "":appPolicyCfgs.get(0).getUserRegion2()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion2()); - }else if(appPolicyCfgs.get(0).getUserRegion1().equals("1")){//带宽 - appPolicyCfgs.get(0).setUserRegion3(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion3()) ? "":appPolicyCfgs.get(0).getUserRegion3()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion3()); - } - } - //DKC=8 - if(!StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion4()) && Constants.REJECT_ACTION.equals(appPolicyCfgs.get(0).getAction())){ - maatCfg.setUserRegion(Constants.USER_REGION_SPLIT +Constants.APP_VIGNORE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion4()); - } - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT+"config_id="+appPolicyCfgs.get(0).getCompileId()); - }else if(regionDict.getFunctionId()==408) {// Behavior Identify - //BEHAVIOR IDENTITY USER_REGION包含APP_ID=AppCode;BEHAV_ID=ProtocolId - maatCfg.setUserRegion(Constants.PROTO_ID_REGION + "=" + appPolicyCfgs.get(0).getAppCode()+Constants.USER_REGION_SPLIT+ Constants.BEHAV_ID_REGION + "=" + appPolicyCfgs.get(0).getBehavCode()); - // 限速业务需要设置 - if (Constants.RATELIMIT_ACTION.equals(appPolicyCfgs.get(0).getAction())) { - appPolicyCfgs.get(0).setUserRegion1(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion1()) ? "0":appPolicyCfgs.get(0).getUserRegion1()); - //限速 需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps - if(appPolicyCfgs.get(0).getUserRegion1().equals("0")){//丢包率 - appPolicyCfgs.get(0).setUserRegion2(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion2()) ? "":appPolicyCfgs.get(0).getUserRegion2()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion2()); - }else if(appPolicyCfgs.get(0).getUserRegion1().equals("1")){//带宽 - appPolicyCfgs.get(0).setUserRegion3(StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion3()) ? "":appPolicyCfgs.get(0).getUserRegion3()); - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT +Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion3()); - } - } - //DKC=8 - if(!StringUtil.isEmpty(appPolicyCfgs.get(0).getUserRegion4()) && Constants.REJECT_ACTION.equals(appPolicyCfgs.get(0).getAction())){ - maatCfg.setUserRegion(Constants.USER_REGION_SPLIT +Constants.APP_VIGNORE_USER_REGION_KEY+"="+appPolicyCfgs.get(0).getUserRegion4()); - } - maatCfg.setUserRegion(maatCfg.getUserRegion()+Constants.USER_REGION_SPLIT+"config_id="+appPolicyCfgs.get(0).getCompileId()); - } - } - - } - if(list.get(0) instanceof BaseIpCfg) { - BaseIpCfg _cfg=(BaseIpCfg)list.get(index); - batchSqlSession.getMapper(IpCfgDao.class).insertForBatch(_cfg); - if(send) { - maatCfg=maatCfgAppendRegion(maatCfg,_cfg,1); - //是否需要处理字符串域and表达式 - configCompileList.add(maatCfg); - } - - }else if(list.get(0) instanceof BaseStringCfg) { - BaseStringCfg _cfg=(BaseStringCfg)list.get(index); - if("subscribe_id".equals(regionDict.getConfigServiceType())) { - _cfg.setTableName("ntc_subscribe_id_cfg"); - } - ((StringCfgDao) batchSqlSession.getMapper(StringCfgDao.class)).saveStringCfgBatch(_cfg); - if(send) { - maatCfg=maatCfgAppendRegion(maatCfg,_cfg,2); - //是否需要处理字符串域and表达式 - configCompileList.add(maatCfg); - } - } - } - if (send) { - if(configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("APP策略 配置下发配置条数:" + configCompileList.size()); - }else { - logger.info("APP策略 配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("APP策略 配置下发响应信息:" + result.getMsg()); - } - } - - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - } - - - /** - * 导入配置保存App特征 - * @param appPolicyCfgs - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAppFeatureList(List appFeatures){ - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < appFeatures.size();index++){ - AppFeatureIndex _cfg = appFeatures.get(index); - ((AppMultiFeatureCfgDao) batchSqlSession.getMapper(AppMultiFeatureCfgDao.class)).insertAppFeatureIndex(_cfg); - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - } - - - /** - * 导入配置时数据批量入库(IP配置) - * - * @param data - * @param tableName - */ - @Transactional(readOnly = false, rollbackFor = RuntimeException.class) - public void saveIpBatch(FunctionRegionDict regionDict, FunctionServiceDict serviceDict,List cfgs, boolean send) { - if (regionDict != null) { - Integer regionType = regionDict.getRegionType(); - if (1 == regionType.intValue()) { - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - SqlSession batchSqlSession = null; - List configCompileList = new ArrayList(); - List callbackIpList = new ArrayList(); - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < cfgs.size();index++){ - BaseIpCfg _cfg = cfgs.get(index); - if (regionDict.getFunctionId().equals(301)) { - DdosIpCfg ddosIpCfg=new DdosIpCfg(); - BeanUtils.copyProperties(_cfg, ddosIpCfg); - //如果insert加入了select last_insert_id,会拖慢6~7倍以上的效率 - ((DdosCfgDao) batchSqlSession.getMapper(DdosCfgDao.class)).insert(ddosIpCfg); - }else if (regionDict.getFunctionId().equals(401)) { - DnsIpCfg dnsIpCfg=new DnsIpCfg(); - BeanUtils.copyProperties(_cfg, dnsIpCfg); - //如果insert加入了select last_insert_id,会拖慢6~7倍以上的效率 - ((DnsIpCfgDao) batchSqlSession.getMapper(DnsIpCfgDao.class)).insert(dnsIpCfg); - } else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(566) || regionDict.getFunctionId().equals(563)){ - AppIpCfg app =new AppIpCfg(); - BeanUtils.copyProperties(_cfg, app); - ((AppMultiFeatureCfgDao) batchSqlSession.getMapper(AppMultiFeatureCfgDao.class)).insertAppIpRangeCfg(app); - } - else { - batchSqlSession.getMapper(IpCfgDao.class).insertForBatch(_cfg); - } - - if(send) { - if(regionDict.getIsMaat().intValue()==1) { - MaatCfg maatCfg=convertMaatCfg(_cfg,1); - //userregion处理 - //限速需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps - if(_cfg.getAction().equals(Constants.RATELIMIT_ACTION)){ - if(_cfg.getUserRegion1().equals("0")){//丢包率 - _cfg.setUserRegion2(StringUtil.isEmpty(_cfg.getUserRegion2()) ? "":_cfg.getUserRegion2()); - maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+_cfg.getUserRegion2()); - }else if(_cfg.getUserRegion1().equals("1")){//带宽 - _cfg.setUserRegion3(StringUtil.isEmpty(_cfg.getUserRegion3()) ? "":_cfg.getUserRegion3()); - maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+_cfg.getUserRegion3()); - } - }else if(regionDict.getFunctionId()==510) { - maatCfg.setUserRegion(Constants.P2P_IP_TYPE_USER_REGION_KEY+"="+_cfg.getUserRegion2()); - }else if(regionDict.getFunctionId()==7) { - if(!StringUtil.isEmpty(_cfg.getDnsStrategyId())){ -// maatCfg.setUserRegion(Constants.USER_REGION_SPLIT+entity.getDnsStrategyId()+Constants.USER_REGION_SPLIT); - maatCfg.setUserRegion(Constants.DNS_STRATEGY_USER_REGION_KEY+"="+_cfg.getDnsStrategyId()); - } - }else if(regionDict.getFunctionId()==301) {// Anti DDOS - Map umap= new HashMap(); - umap.put("protocol", _cfg.getAntiddosProtocol()); - umap.put("bps_threadshold", _cfg.getBpsThreadshold()); - umap.put("pps_threadshold", _cfg.getPpsThreadshold()); - maatCfg.setUserRegion(new Gson().toJson(umap)); - }else if(regionDict.getFunctionId()==200) {// IP Intercept - /*maatCfg.setUserRegion(Constants.USER_REGION_PLACEHOLDER); - if(_cfg.getAction().equals(Constants.MONIT_ACTION)) { - maatCfg.setUserRegion(Constants.INTERCEPT_IP_MONIT_USER_REGION_KEY+"="+Constants.USER_REGION_PLACEHOLDER); - }*/ - maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+_cfg.getUserRegion2()); - }else if(regionDict.getFunctionId()==207 || regionDict.getFunctionId()==208 || regionDict.getFunctionId()==209) {// HTTP(s)阻断、重定向、替换 - String userRegion = Constants.USER_REGION_PLACEHOLDER; - if(_cfg.getAction().equals(Constants.REJECT_ACTION)) {// 阻断 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REDIRECT_CONTENT_KEY+"="+_cfg.getUserRegion2(); - }else if(_cfg.getAction().equals(48)) {// 重定向 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REDIRECT_URL_KEY+"="+_cfg.getUserRegion2();; - }else if(_cfg.getAction().equals(Constants.REPLACE_ACTION)) {// 替换 - String substitute = "/"+_cfg.getUserRegion2()+"/"+_cfg.getUserRegion3(); - userRegion = Constants.REPLACE_ZONE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute; - } - maatCfg.setUserRegion(userRegion); - }else if(regionDict.getFunctionId()==563 || regionDict.getFunctionId()==565 || regionDict.getFunctionId()==566) {// APP Payload、HTTP、SSL Admin - maatCfg.setUserRegion(Constants.APP_ID_REGION+"="+_cfg.getAppCode()); - }else if(regionDict.getFunctionId()==214) { - String userRegion="nat_type="+_cfg.getUserRegion1()+";spoofing_ip_pool="+_cfg.getUserRegion3(); - maatCfg.setUserRegion(userRegion); - }else if(regionDict.getFunctionId()==212) { - String userRegion=Constants.REPLACE_ZONE_KEY+"="+_cfg.getUserRegion1(); - String substitute=""; - String userRegion2=StringUtil.isEmpty(_cfg.getUserRegion2()) ? "":_cfg.getUserRegion2(); - substitute="/"; - userRegion2 = BaseService.replaceContentEscape(userRegion2); - substitute=substitute+userRegion2; - - String userRegion3=StringUtil.isEmpty(_cfg.getUserRegion3()) ? "":_cfg.getUserRegion3(); - userRegion3 = BaseService.replaceContentEscape(userRegion3); - substitute=substitute+"/"+userRegion3; - - userRegion=userRegion+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute; - maatCfg.setUserRegion(userRegion); - } - - configCompileList.add(maatCfg); - }else { - //根据具体情况判断 - callbackIpList.add(this.convertCallBackIp(_cfg,_cfg.getDnsStrategyId())); - } - } - } - if (send) { - if(configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("IP 配置下发配置条数:" + configCompileList.size()); - }else { - logger.info("IP 配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("IP 配置下发响应信息:" + result.getMsg()); - }else { - //调用服务接口下发配置数据 - String json=gsonToJson(callbackIpList); - logger.info("IP配置下发配置参数:"+json); - //调用服务接口下发配置 - try { - ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json); - if(result!=null){ - logger.info("IP配置配置下发响应信息:"+result.getMsg()); - } - } catch (Exception e) { - logger.error("IP配置配置下发失败",e); - throw e; - } - } - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - } - } - - } - /** - * 导入配置时数据批量入库(字符串配置) - * - * @param data - * @param tableName - */ - @Transactional(readOnly = false, rollbackFor = RuntimeException.class) - public void saveStringCfgBatch(FunctionRegionDict regionDict, FunctionServiceDict serviceDict, - List> data, String tableName, boolean send) { - if (regionDict != null) { - Integer regionType = regionDict.getRegionType(); - if (2 == regionType.intValue()) { - SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class); - List configCompileList = new ArrayList(); - SqlSession batchSqlSession = null; - try { - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for (int index = 0; index < data.size(); index++) { - BaseStringCfg _cfg = data.get(index); - _cfg.setTableName(tableName); - if(regionDict.getDictId().intValue()==64){ - AppDomainCfg cfg=new AppDomainCfg(); - BeanUtils.copyProperties(_cfg, cfg); - ((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppDomainCfgBatch(cfg); - }else { - ((StringCfgDao) batchSqlSession.getMapper(StringCfgDao.class)).saveStringCfgBatch(_cfg); - } - if (send) { - if(regionDict.getIsMaat().intValue()==1) { - MaatCfg maatCfg=convertMaatCfg(_cfg,2); - //userregion处理 - if(regionDict.getFunctionId()==7) { - if(!StringUtil.isEmpty(_cfg.getDnsStrategyId())){ - // maatCfg.setUserRegion(Constants.USER_REGION_SPLIT+entity.getDnsStrategyId()+Constants.USER_REGION_SPLIT); - maatCfg.setUserRegion(Constants.DNS_STRATEGY_USER_REGION_KEY+"="+_cfg.getDnsStrategyId()); - } - }else if(regionDict.getDictId()==159) { - maatCfg.setUserRegion(Constants.P2P_HASH_TYPE_USER_REGION_KEY+"="+_cfg.getUserRegion1()); - }else if(regionDict.getFunctionId()==200) {// Domain Intercept - String userRegion = Constants.USERREGION_DOMAIN_ID+"="+_cfg.getCompileId()+";"+Constants.USERREGION_DOMAIN_STR+"="+_cfg.getCfgKeywords(); - if(_cfg.getAction().equals(Constants.MONIT_ACTION)) {// 监测 需要发keyring_id、拦截强度 - userRegion = Constants.INTERCEPT_IP_MONIT_USER_REGION_KEY+"=0"+";"+Constants.INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY+"="+_cfg.getUserRegion5()+";" + userRegion; - }else if(_cfg.getAction().equals(Constants.RATELIMIT_ACTION)) {// 限速 需要发Droprate - userRegion = Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+_cfg.getUserRegion2()+";" + userRegion; - } - maatCfg.setUserRegion(userRegion); - }else if(regionDict.getFunctionId()==207 || regionDict.getFunctionId()==208 || regionDict.getFunctionId()==209) {// HTTP(s)阻断、重定向、替换 - String userRegion = Constants.USER_REGION_PLACEHOLDER; - if(_cfg.getAction().equals(Constants.REJECT_ACTION)) {// 阻断 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REDIRECT_CONTENT_KEY+"="+_cfg.getUserRegion2(); - }else if(_cfg.getAction().equals(48)) {// 重定向 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REDIRECT_URL_KEY+"="+_cfg.getUserRegion2();; - }else if(_cfg.getAction().equals(Constants.REPLACE_ACTION)) {// 替换 - String substitute = "/"+_cfg.getUserRegion2()+"/"+_cfg.getUserRegion3(); - userRegion = Constants.REPLACE_ZONE_KEY+"="+_cfg.getUserRegion1()+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute; - } - maatCfg.setUserRegion(userRegion); - } - configCompileList.add(maatCfg); - } - - } - } - if (send && configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("字符串配置下发配置条数:" + configCompileList.size()); - }else { - logger.info("字符串配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("字符串配置下发响应信息:" + result.getMsg()); - - } - batchSqlSession.commit(); - } finally { - if (batchSqlSession != null) { - batchSqlSession.close(); - } - } - } else { - throw new RuntimeException("Region type must be 2!"); - } - } - } - /** - * 导入配置时数据批量入库(增强字符串配置) - * @param data - * @param tableName - */ - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveComplexkeywordCfgBatch(FunctionRegionDict regionDict, FunctionServiceDict serviceDict,List data, String tableName,boolean send) { - if (regionDict != null) { - Integer regionType = regionDict.getRegionType(); - if (3 == regionType.intValue()) { - SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); - List configCompileList = new ArrayList(); - SqlSession batchSqlSession = null; - try{ - batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); - for(int index = 0; index < data.size();index++){ - ComplexkeywordCfg cfg = data.get(index); - cfg.setTableName(tableName); - if(regionDict.getDictId().intValue()==63) { - AppHttpCfg _cfg=new AppHttpCfg(); - BeanUtils.copyProperties(cfg, _cfg); - ((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppHttpCfgBatch(_cfg); - }else if(regionDict.getDictId().intValue()==220 || regionDict.getDictId().intValue()==216 || regionDict.getDictId().intValue()==224){ - AppComplexFeatureCfg appCfg=new AppComplexFeatureCfg(); - BeanUtils.copyProperties(cfg, appCfg); - ((AppMultiFeatureCfgDao) batchSqlSession.getMapper(AppMultiFeatureCfgDao.class)).insertAppComplexFeatureCfg(appCfg); - } - else { - ((StringCfgDao) batchSqlSession.getMapper(StringCfgDao.class)).saveComplexkeywordCfgBatch(cfg); - } - if (send) { - if(regionDict.getIsMaat().intValue()==1) { - MaatCfg maatCfg=convertMaatCfg(cfg,3); - //userregion处理 - if(regionDict.getFunctionId()==7) { - if(!StringUtil.isEmpty(cfg.getDnsStrategyId())){ - // maatCfg.setUserRegion(Constants.USER_REGION_SPLIT+entity.getDnsStrategyId()+Constants.USER_REGION_SPLIT); - maatCfg.setUserRegion(Constants.DNS_STRATEGY_USER_REGION_KEY+"="+cfg.getDnsStrategyId()); - } - }else if(regionDict.getDictId()==10) { - String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, cfg.getDistrict()); - if(StringUtil.isEmpty(dictValue) || dictValue.equals("默认")){ - maatCfg.setUserRegion(Constants.HTTP_HEADER_USER_REGION_KEY+"="+cfg.getDistrict()); - } - }else if(regionDict.getDictId()==11) { - String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, cfg.getDistrict()); - if(StringUtil.isEmpty(dictValue) || dictValue.equals("默认")){ - maatCfg.setUserRegion(Constants.HTTP_HEADER_USER_REGION_KEY+"="+cfg.getDistrict()); - } - }else if(regionDict.getFunctionId()==207 || regionDict.getFunctionId()==208 || regionDict.getFunctionId()==209) {// HTTP(s)阻断、重定向、替换 - String userRegion = Constants.USER_REGION_PLACEHOLDER; - if(cfg.getAction().equals(Constants.REJECT_ACTION)) {// 阻断 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+";"+Constants.REDIRECT_CONTENT_KEY+"="+cfg.getUserRegion2(); - }else if(cfg.getAction().equals(48)) {// 重定向 - userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+";"+Constants.REDIRECT_URL_KEY+"="+cfg.getUserRegion2();; - }else if(cfg.getAction().equals(Constants.REPLACE_ACTION)) {// 替换 - String substitute = "/"+cfg.getUserRegion2()+"/"+cfg.getUserRegion3(); - userRegion = Constants.REPLACE_ZONE_KEY+"="+cfg.getUserRegion1()+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute; - } - maatCfg.setUserRegion(userRegion); - }else if(regionDict.getFunctionId()==564 || regionDict.getFunctionId()==565 || regionDict.getFunctionId()==566) {// APP HTTP、DNS、SSL Admin - maatCfg.setUserRegion(Constants.APP_ID_REGION+"="+cfg.getAppCode()); - } - configCompileList.add(maatCfg); - } - } - - } - if (send && configCompileList.size() > 0) { - ToMaatBean maatBean = new ToMaatBean(); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = BaseService.gsonToJson(maatBean); - if(configCompileList.size()>10) { - logger.info("增强字符串配置下发配置条数:" + configCompileList.size()); - }else { - logger.info("增强字符串配置下发配置参数:" + json); - } - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("增强字符串配置下发响应信息:" + result.getMsg()); - - } - batchSqlSession.commit(); - }finally { - if(batchSqlSession != null){ - batchSqlSession.close(); - } - } - } - - } - - } - /** - * asn ip分组复用新增[POST],修改[PUT],删除[PUT] - * 首次下发直接走maat,公共组第二次下发直接走addCommonRegion,updateCommonRegion,delCommonRegion - * @param asnIpCfgs - */ - public void asnIPRegionSendToMaat(List asnIpCfgs,Integer valid,Integer action) { - logger.warn("asnIPRegionSendToMaat start"); - long start=System.currentTimeMillis(); - GroupReuseAddBean maatBean = new GroupReuseAddBean(); - List groupReuseList=new ArrayList<>(); - GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); - List ipRegionList = groupReuseCfgAddRemoveConvert(asnIpCfgs,valid,null); - List strRegionList = new ArrayList<>(); - List numRegionList = new ArrayList<>(); - groupReuseCfg.setIpRegionList(ipRegionList); - groupReuseCfg.setStrRegionList(strRegionList); - groupReuseCfg.setNumRegionList(numRegionList); - groupReuseList.add(groupReuseCfg); - maatBean.setGroupReuseCfgList(groupReuseList); - maatBean.setAuditTime(new Date()); - maatBean.setCreatorName(UserUtils.getUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - if(valid==Constants.VALID_YES) { - maatBean.setOpAction(action); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - if(asnIpCfgs.size()<=100) { - logger.info("asn ip复用域 "+action+"下发配置参数:"+json); - }else { - logger.info("asn ip复用域 "+action+" 配置下发region条数:"+asnIpCfgs.size()); - } - //调用服务接口下发配置 - ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action); - logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg()); - }else { - maatBean.setOpAction(action); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - if(asnIpCfgs.size()<=100) { - logger.info("asn ip复用域删除配置下发配置参数:"+json); - }else { - logger.info("asn ip复用域删除配置下发region条数:"+asnIpCfgs.size()); - - } - //调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3); - logger.info("asn ip复用域删除配置响应信息:"+result.getMsg()); - } - long end=System.currentTimeMillis(); - logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start)); - } - - /** - * ASN关键字配置处理 - * @param asnList - * @param entity - */ - public void handleAsn(List asnList,BaseCfg entity) { - //无效子配置后,再新增子配置 - StringCfgDao stringCfgDao=SpringContextHolder.getBean(StringCfgDao.class); - stringCfgDao.deleteAsnKeyword(entity); - String commonGroupIds="";//公共表存储组织GroupIds - if(asnList != null && asnList.size()>0){ - for (AsnKeywordCfg asnKeywordCfg : asnList) { - BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"}); - asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename()); - asnKeywordCfg.setIsAudit(entity.getIsAudit()); - asnKeywordCfg.setIsValid(entity.getIsValid()); - asnKeywordCfg.setEditTime(entity.getEditTime()); - asnKeywordCfg.setEditorId(entity.getEditorId()); - asnKeywordCfg.setExprType(0); - asnKeywordCfg.setMatchMethod(3); - asnKeywordCfg.setExType("0"); - asnKeywordCfg.setIsHexbin(0); - asnKeywordCfg.setCreateTime(new Date()); - asnKeywordCfg.setCreatorId(UserUtils.getUser().getId()); - stringCfgDao.saveStringCfgBatch(asnKeywordCfg); - - commonGroupIds+=asnKeywordCfg.getUserRegion1()+",";//组织GroupId - } - } - if(!StringUtil.isEmpty(commonGroupIds)){ - commonGroupIds=commonGroupIds.substring(0, commonGroupIds.length()-1); - } - entity.setCommonGroupIds(commonGroupIds); - //return entity; - } - /** - * ASN关键字配置处理 - * @param asnList - * @param entity - */ - public void auditAsnCfg(List groupRelationList,List strRegionList,BaseCfg entity,List asnList){ - //注意:一条配置是一个分组,keywords=asnNos|userRegion1=groupId|userRegion2=isAuditAll 0 1 - if(!StringUtil.isEmpty(asnList)){ - AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class); - ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class); - - //1、修改域配置为下发状态 - AsnKeywordCfg asnCfg=new AsnKeywordCfg(); - BeanUtils.copyProperties(entity, asnCfg); - asnCfg.setTableName(AsnKeywordCfg.getTablename()); - IpCfgDao ipCfgDao=SpringContextHolder.getBean(IpCfgDao.class); - ipCfgDao.auditCfg(asnCfg); - - //需要标记为下发全部域的groupId集合 - List signAuditAllGroupList=new ArrayList<>(); - //需要标记下发的groupId - List isUsedGroupIdList=new ArrayList<>(); - //所有已被策略引用过的域 - List auditRegionList=new ArrayList<>(); - //所有未被策略过的域 - List notAuditRegionList=new ArrayList<>(); - //域和分组的关系 - Map groupWithRegion=new HashMap<>(); - //所有策略所选asn No - List asnNoList=new ArrayList<>(); - //所有未下发过的asnNo - List notAuditAsnNoList=new ArrayList<>(); - //最新的asn域集合 - List newAsnList=new ArrayList<>(); - - //2、记录标记为下发all的groupId|存储组和asnno的关系|记录需要标记为已下发的group - for (AsnKeywordCfg asnKeywordCfg : asnList) { - asnKeywordCfg.setUserRegion2(StringUtil.isEmpty(asnKeywordCfg.getUserRegion2()) ? "1":"0"); - if("1".equals(asnKeywordCfg.getUserRegion2())){ //是否标记为下发ALL - signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1())); - } - for (String asnstr: asnKeywordCfg.getCfgKeywords().split(",")) { - groupWithRegion.put(asnstr, asnKeywordCfg.getUserRegion1()); - } - if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion1()))){ - isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1())); - } - List list=Arrays.asList(asnKeywordCfg.getCfgKeywords().split(",")); - asnNoList.addAll(list); - } - - //3、//根据asnNoList查询所有下发过的ASN NO - if(!StringUtil.isEmpty(asnNoList)){ - auditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 1); - } - //已下发过的ASN NO只需要下发组 - if(!StringUtil.isEmpty(auditRegionList)){ - for (AsnGroupInfo asnGroupInfo : auditRegionList) { - AsnKeywordCfg cfg = new AsnKeywordCfg(); - cfg.initDefaultValue(); - cfg.setTableName(AsnKeywordCfg.getTablename()); - cfg.setCfgType(asnList.get(0).getCfgType()); - cfg.setCompileId(entity.getCompileId()); - cfg.setCfgKeywords(asnGroupInfo.getGroupId().toString());//关键字 - cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //组号 - cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid - cfg.setUserRegion3("0"); //是否下发域 - cfg.setIsAudit(entity.getIsAudit()); - cfg.setIsValid(entity.getIsValid()); - cfg.setAuditorId(entity.getAuditorId()); - cfg.setAuditTime(entity.getAuditTime()); - cfg.setFunctionId(entity.getFunctionId()); - newAsnList.add(cfg); - } - } - - //4、查询所有未下发过的 ASN NO - if(!StringUtil.isEmpty(asnNoList)){ - notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 0); - } - - if(!StringUtil.isEmpty(notAuditRegionList)){ - for (AsnGroupInfo asnGroupInfo : notAuditRegionList) { - AsnKeywordCfg cfg = new AsnKeywordCfg(); - cfg.initDefaultValue(); - cfg.setTableName(AsnKeywordCfg.getTablename()); - cfg.setCompileId(entity.getCompileId()); - cfg.setCfgType(asnList.get(0).getCfgType()); - cfg.setCfgKeywords(asnGroupInfo.getAsnId().toString());//关键字 - cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //groupId - cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid - cfg.setUserRegion3("1"); //是否下发域 - cfg.setIsAudit(entity.getIsAudit()); - cfg.setIsValid(entity.getIsValid()); - cfg.setAuditorId(entity.getAuditorId()); - cfg.setAuditTime(entity.getAuditTime()); - cfg.setFunctionId(entity.getFunctionId()); - newAsnList.add(cfg); - notAuditAsnNoList.add(asnGroupInfo.getAsnId().toString()); - } - } - //5、修改所有下发的asn no为已下发 - if(!StringUtil.isEmpty(notAuditAsnNoList)){ - asnGroupInfoDao.updateIsUsedAndIsValid(notAuditAsnNoList,1,null); + //5、修改所有下发的asn为已下发 + if(!StringUtil.isEmpty(notAuditGroupIdList)){ + asnGroupInfoDao.updateIsUsedAndIsValid(notAuditGroupIdList,1,null); } //6、标记组已被策略标记为全部下发 configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList ); @@ -6705,12 +3331,5 @@ public abstract class BaseService { } } -} - - - } - } - } - } diff --git a/src/main/java/com/nis/web/service/basics/AsnGroupInfoService.java b/src/main/java/com/nis/web/service/basics/AsnGroupInfoService.java index c8535f342..bbe5602c3 100644 --- a/src/main/java/com/nis/web/service/basics/AsnGroupInfoService.java +++ b/src/main/java/com/nis/web/service/basics/AsnGroupInfoService.java @@ -74,41 +74,43 @@ public class AsnGroupInfoService extends BaseService{ String country=entity.getCountry().trim().toUpperCase(); entity.setOrganization(org); entity.setCountry(country); - int groupId=0; - //获取组织 - ConfigGroupInfo configGroupInfo=configGroupInfoDao.getAsnGroupByName(org); - if(configGroupInfo==null) { - List groupIds= ConfigServiceUtil.getId(2,2); - if(groupIds.size()>0) { - groupId=groupIds.get(0).intValue(); - }else { - throw new MaatConvertException("Get asn group id failed"); + int groupId=0; + //新增 + if(entity.getGroupId()==null){ + + //1、根据信的组织名称,获取组织config_group_info + ConfigGroupInfo configGroupInfo=configGroupInfoDao.getAsnGroupByName(entity.getOrganization()); + if(configGroupInfo ==null){ + //新增组织 + List groupIds= ConfigServiceUtil.getId(2,1); + if(groupIds.size()>0) { + groupId=groupIds.get(0).intValue(); + }else { + throw new MaatConvertException("Get asn group id failed"); + } + configGroupInfo=new ConfigGroupInfo(); + configGroupInfo.setGroupName(entity.getOrganization()); + configGroupInfo.setIsIssued(0); + configGroupInfo.setGroupType(4); + configGroupInfo.setIsAuditAll(0); + configGroupInfo.setIsUsed(0); + configGroupInfo.setGroupId(groupIds.get(0)); + configGroupInfo.setInsertTime(new Date()); + configGroupInfoDao.insertConfigGroupInfo(configGroupInfo); } - configGroupInfo=new ConfigGroupInfo(); - configGroupInfo.setGroupName(org.toUpperCase()); - configGroupInfo.setIsIssued(0); - configGroupInfo.setGroupType(4); - configGroupInfo.setIsAuditAll(0); - configGroupInfo.setIsUsed(0); - configGroupInfo.setGroupId(groupIds.get(1)); - configGroupInfo.setInsertTime(new Date()); - configGroupInfoDao.insertConfigGroupInfo(configGroupInfo); - }else { + List groupIds= ConfigServiceUtil.getId(2,1); if(groupIds.size()>0) { groupId=groupIds.get(0).intValue(); }else { throw new MaatConvertException("Get asn group id failed"); } - - } - //新增 - if(entity.getGroupId()==null){ Date createTime=new Date(); entity.setCreatorId(UserUtils.getUser().getId()); entity.setCreateTime(createTime); entity.setGroupId(groupId); + entity.setOrgGroupId(configGroupInfo.getGroupId()); entity.setIsValid(0); //分组已被策略设定为下发全部域,则需要自动下发新增的asno if(configGroupInfo.getIsAuditAll() != null && configGroupInfo.getIsAuditAll().equals(1)){ @@ -139,41 +141,43 @@ public class AsnGroupInfoService extends BaseService{ } //修改 }else{ - long id=entity.getId(); - AsnGroupInfo group=asnGroupInfoDao.getById(id); - int count=asnGroupInfoDao.getCountGroupInfoByName(group.getOrganization()); - if(count==1&&!group.getOrganization().equalsIgnoreCase(entity.getOrganization())) { - configGroupInfoDao.delAsnGroup(group.getOrganization()); - } - ConfigGroupInfo configGroupInfo1=configGroupInfoDao.getAsnGroupByName(entity.getOrganization()); - if(configGroupInfo1==null) { - List groupIds= ConfigServiceUtil.getId(2,2); - if(groupIds.size()>0) { - groupId=groupIds.get(0).intValue(); - }else { - throw new MaatConvertException("Get asn group id failed"); - } - configGroupInfo1=new ConfigGroupInfo(); - configGroupInfo1.setGroupName(entity.getOrganization().toUpperCase()); - configGroupInfo1.setIsIssued(0); - configGroupInfo1.setGroupType(4); - configGroupInfo1.setIsUsed(0); - configGroupInfo1.setIsAuditAll(0); - configGroupInfo1.setGroupId(groupIds.get(1)); - configGroupInfo1.setInsertTime(new Date()); - configGroupInfoDao.insertConfigGroupInfo(configGroupInfo1); + //查询旧的asn group + AsnGroupInfo oldGroup=asnGroupInfoDao.getById(entity.getId()); + //根据旧的组织名称查询config group info + ConfigGroupInfo oldConfigGroupInfo=configGroupInfoDao.getAsnGroupByName(oldGroup.getOrganization()); + if(oldConfigGroupInfo ==null){ + //新增组织 + List groupIds= ConfigServiceUtil.getId(2,1); + if(groupIds.size()>0) { + groupId=groupIds.get(0).intValue(); + }else { + throw new MaatConvertException("Get asn group id failed"); + } + oldConfigGroupInfo=new ConfigGroupInfo(); + oldConfigGroupInfo.setGroupName(entity.getOrganization()); + oldConfigGroupInfo.setIsIssued(0); + oldConfigGroupInfo.setGroupType(4); + oldConfigGroupInfo.setIsAuditAll(0); + oldConfigGroupInfo.setIsUsed(0); + oldConfigGroupInfo.setGroupId(groupIds.get(0)); + oldConfigGroupInfo.setInsertTime(new Date()); + configGroupInfoDao.insert(oldConfigGroupInfo); + }else{ + ConfigGroupInfo newConfigGroupInfo=new ConfigGroupInfo(); + newConfigGroupInfo.setGroupId(oldConfigGroupInfo.getGroupId()); + newConfigGroupInfo.setId(oldConfigGroupInfo.getId()); + newConfigGroupInfo.setGroupName(entity.getOrganization()); + configGroupInfoDao.update(newConfigGroupInfo); } + Date editTime=new Date(); entity.setEditorId(UserUtils.getUser().getId()); entity.setEditTime(editTime); - entity.setGroupId(groupId); asnGroupInfoDao.update(entity); - asnIpCfgDao.updateAsn(String.valueOf(entity.getAsnId()),entity.getOrganization(),entity.getCountry(),entity.getDetail()); - if(configGroupInfo1.getIsUsed()!= null - && configGroupInfo1.getIsUsed().equals(1)){ - group.setGroupId(groupId); - group.setAsnId(entity.getAsnId()); - auditAsn(group,configGroupInfo1,Constants.OPACTION_PUT); + asnIpCfgDao.updateAsn(String.valueOf(entity.getAsnId()),entity.getOrganization(),entity.getCountry(),entity.getDetail(),String.valueOf(entity.getGroupId())); + if(oldConfigGroupInfo.getIsUsed()!= null + && oldConfigGroupInfo.getIsUsed().equals(1)){ + auditAsn(entity,oldConfigGroupInfo,Constants.OPACTION_PUT); } } @@ -216,14 +220,14 @@ public class AsnGroupInfoService extends BaseService{ } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void delete(String ids,String asnIds){ + public void delete(String ids,String asnIds,String groupIds){ if(!StringUtil.isEmpty(ids)){ List commonGroupList=new ArrayList<>(); //查询已经被策略引用的asn - List asnList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(Arrays.asList(asnIds.split(",")), 1); + List asnList=asnGroupInfoDao.findAsnGroupInfoByGroupIds(Arrays.asList(groupIds.split(",")), 1); //修改asn为无效,且解除引用 - asnGroupInfoDao.updateIsUsedAndIsValid(Arrays.asList(asnIds.split(",")), 0, -1); + asnGroupInfoDao.updateIsUsedAndIsValid(Arrays.asList(groupIds.split(",")), 0, -1); //删除asn下的所有asn IP asnIpCfgDao.deleteByAsnId(asnIds); @@ -364,9 +368,5 @@ public class AsnGroupInfoService extends BaseService{ List list=asnGroupInfoDao.findAsnGroupInfoByAsnGroup(asnGroupInfo); return list; } - public List findAsnGroupList(List asnNos,Integer isUsed){ - List list=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNos,null ); - return list; - } } diff --git a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java index d1016a55f..60db7f240 100644 --- a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java +++ b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java @@ -510,114 +510,138 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { List auditAsnGroupList=new ArrayList<>(); SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); final SqlSession batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); + Integer serviceId=0; try{ - int issuedNum=asnIpCfgs.size(); - for(int index = 0; index < asnIpCfgs.size();index++){ - AsnIpCfg t = asnIpCfgs.get(index); - BaseIpCfg ipCfg=new BaseIpCfg(); - BeanUtils.copyProperties(t, ipCfg); - ipCfg.setTableName(AsnIpCfg.getTablename()); - ((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).audit(ipCfg); - } - batchSqlSession.commit(); - AsnGroupInfo asnGroupInfo=new AsnGroupInfo(); - asnGroupInfo.setAsnId(asn); - asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo); - Integer groupId=asnGroupInfo.getGroupId(); - - MaatCfg maatCfg = new MaatCfg(); - List configCompileList = new ArrayList(); - List groupRelationList = new ArrayList(); - List ipRegionList = new ArrayList(); - List strRegionList = new ArrayList(); - List numRegionList = new ArrayList(); - List digestRegionList = new ArrayList(); - List areaIpRegionList = new ArrayList(); - - if(isValid==Constants.VALID_YES) {//审核通过 - if(asnGroupInfo.getIsValid()==0) {//ans组未下发过,下发编译配置 - asnGroupInfo.setIsValid(1); - asnGroupInfo.setEditorId(UserUtils.getUser().getId()); - asnGroupInfo.setEditTime(new Date()); - asnGroupInfo.setIssuedIPs(issuedNum+0L); - asnGroupInfoDao.updateValid(asnGroupInfo); - maatCfg.initDefaultValue(); - ToMaatBean maatBean = new ToMaatBean(); - //group - GroupCfg groupCfg=new GroupCfg(); - groupCfg.setCompileId(asnGroupInfo.getCompileId()); - groupCfg.setGroupId(groupId); - groupCfg.setIsValid(Constants.VALID_YES); - //asnGroupId标记为公共组 - groupCfg.setIsCommonGroup(1); - groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime()); - groupRelationList.add(groupCfg); - BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_YES,groupId)); - maatCfg.setCompileId(asnGroupInfo.getCompileId()); - maatCfg.setAction(asnIpCfgs.get(0).getAction()); - maatCfg.setAuditTime(asnIpCfgs.get(0).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(isValid); - // 设置ASN自定义域 - String userRegion = "ASN_ID=" + asnIpCfgs.get(0).getUserRegion1(); - maatCfg.setUserRegion(userRegion); - configCompileList.add(maatCfg); - maatBean.setConfigCompileList(configCompileList); - maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime()); - maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.INSERT_ACTION); - // 调用服务接口下发配置数据 - String json = gsonToJson(maatBean); - logger.info("ASN IP配置下发配置参数:" + json); - // 调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); - logger.info("ASN IP配置下发响应信息:" + result.getMsg()); - }else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用 - asnGroupInfo.setIssuedIPs(issuedNum+0l); - asnGroupInfoDao.update(asnGroupInfo); - asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST); - }else { - throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid()); - } - }else if(isValid==Constants.VALID_NO) {//取消审核通过 - asnGroupInfo.setIssuedIPs(0L-issuedNum); - asnGroupInfoDao.update(asnGroupInfo); - //已经下发过的,调用分组复用配置删除接口 - GroupReuseAddBean maatBean = new GroupReuseAddBean(); - List groupReuseList=new ArrayList<>(); - GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId)); - groupReuseCfg.setIpRegionList(ipRegionList); - groupReuseCfg.setStrRegionList(strRegionList); - groupReuseCfg.setNumRegionList(numRegionList); - groupReuseList.add(groupReuseCfg); - maatBean.setGroupReuseCfgList(groupReuseList); - maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime()); - maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.UPDATE_ACTION); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - logger.info("ASN IP域删除配置下发配置参数:"+json); - //调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3); - logger.info("ASN IP域删除配置响应信息:"+result.getMsg()); - //如果一个asn组下没有IP了,修改有效状态 - if(hasValidAsnIp(asn)) { - asnGroupInfo.setIsValid(0); - asnGroupInfo.setEditorId(UserUtils.getUser().getId()); - asnGroupInfo.setEditTime(new Date()); - asnGroupInfoDao.updateValid(asnGroupInfo); + if(!StringUtil.isEmpty(asnIpCfgs)){ + serviceId=asnIpCfgs.get(0).getServiceId(); + int issuedNum=asnIpCfgs.size(); + for(int index = 0; index < asnIpCfgs.size();index++){ + AsnIpCfg t = asnIpCfgs.get(index); + BaseIpCfg ipCfg=new BaseIpCfg(); + BeanUtils.copyProperties(t, ipCfg); + ipCfg.setTableName(AsnIpCfg.getTablename()); + ((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).audit(ipCfg); } + batchSqlSession.commit(); + AsnGroupInfo asnGroupInfo=new AsnGroupInfo(); + asnGroupInfo.setAsnId(asn); + asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo); + Integer groupId=asnGroupInfo.getGroupId(); + MaatCfg maatCfg = new MaatCfg(); + List configCompileList = new ArrayList(); + List groupRelationList = new ArrayList(); + List ipRegionList = new ArrayList(); + List strRegionList = new ArrayList(); + List numRegionList = new ArrayList(); + List digestRegionList = new ArrayList(); + List areaIpRegionList = new ArrayList(); + + if(isValid==Constants.VALID_YES) {//审核通过 + if(asnGroupInfo.getIsValid()==0) {//ans组未下发过,下发编译配置 + asnGroupInfo.setIsValid(1); + asnGroupInfo.setEditorId(UserUtils.getUser().getId()); + asnGroupInfo.setEditTime(new Date()); + asnGroupInfo.setIssuedIPs(issuedNum+0L); + asnGroupInfoDao.updateValid(asnGroupInfo); + maatCfg.initDefaultValue(); + ToMaatBean maatBean = new ToMaatBean(); + //group + GroupCfg groupCfg=new GroupCfg(); + groupCfg.setCompileId(asnGroupInfo.getCompileId()); + groupCfg.setGroupId(groupId); + groupCfg.setIsValid(Constants.VALID_YES); + //asnGroupId标记为公共组 + groupCfg.setIsCommonGroup(1); + groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime()); + groupRelationList.add(groupCfg); + BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg); + ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_YES,groupId)); + maatCfg.setCompileId(asnGroupInfo.getCompileId()); + maatCfg.setAction(asnIpCfgs.get(0).getAction()); + maatCfg.setAuditTime(asnIpCfgs.get(0).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(isValid); + // 设置ASN自定义域 + String userRegion = "ASN_ID=" + asnIpCfgs.get(0).getUserRegion1(); + maatCfg.setUserRegion(userRegion); + configCompileList.add(maatCfg); + maatBean.setConfigCompileList(configCompileList); + maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime()); + maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.INSERT_ACTION); + // 调用服务接口下发配置数据 + String json = gsonToJson(maatBean); + logger.info("ASN IP配置下发配置参数:" + json); + // 调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); + logger.info("ASN IP配置下发响应信息:" + result.getMsg()); + }else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用 + asnGroupInfo.setIssuedIPs(issuedNum+0l); + asnGroupInfoDao.update(asnGroupInfo); + asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST); + }else { + throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid()); + } + }else if(isValid==Constants.VALID_NO) {//取消审核通过 + asnGroupInfo.setIssuedIPs(0L-issuedNum); + asnGroupInfoDao.update(asnGroupInfo); + + //如果一个asn组下没有IP了,修改有效状态,并且删除 + if(hasValidAsnIp(asn)) { + //已经下发过的,调用分组复用配置删除接口 + GroupReuseAddBean maatBean = new GroupReuseAddBean(); + List groupReuseList=new ArrayList<>(); + GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); + ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId)); + groupReuseCfg.setIpRegionList(ipRegionList); + groupReuseCfg.setStrRegionList(strRegionList); + groupReuseCfg.setNumRegionList(numRegionList); + groupReuseList.add(groupReuseCfg); + maatBean.setGroupReuseCfgList(groupReuseList); + maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime()); + maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.UPDATE_ACTION); + //调用服务接口下发配置数据 + String json=gsonToJson(maatBean); + logger.info("ASN IP域删除配置下发配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3); + logger.info("ASN IP域删除配置响应信息:"+result.getMsg()); + }else{ + asnGroupInfo.setIsValid(0); + asnGroupInfo.setEditorId(UserUtils.getUser().getId()); + asnGroupInfo.setEditTime(new Date()); + asnGroupInfoDao.updateValid(asnGroupInfo); + //asn group下没有asn ip之后,需要失效整个compileId,并且不保留公共组信息 + ToMaatBean maatBean = new ToMaatBean(); + maatCfg.setCompileId(asnGroupInfo.getCompileId()); + maatCfg.setServiceId(serviceId); + maatCfg.setIsValid(0);//无效 + //configCompileList.add(addKeepGroupList(maatCfg,entity)); + configCompileList.add(maatCfg); + maatBean.setConfigCompileList(configCompileList); + maatBean.setAuditTime(new Date()); + maatBean.setCreatorName(UserUtils.getUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.UPDATE_ACTION); + //调用服务接口取消配置 + String json=gsonToJson(maatBean); + logger.info("asn ip配置下发配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.put(json,1); + logger.info("asn ip配置取消配置响应信息:"+result.getMsg()); + + } + } } }finally { if(batchSqlSession != null){ diff --git a/src/main/java/com/nis/web/service/configuration/AppCfgService.java b/src/main/java/com/nis/web/service/configuration/AppCfgService.java index b23100e79..85f839a6b 100644 --- a/src/main/java/com/nis/web/service/configuration/AppCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AppCfgService.java @@ -1168,7 +1168,9 @@ public class AppCfgService extends BaseService { List numRegionList = new ArrayList(); List digestRegionList = new ArrayList(); List areaIpRegionList = new ArrayList(); + Integer serviceId=0; this.auditAppIpCfg(entitys); + serviceId=entitys.get(0).getServiceId(); // for(AppIpCfg entity:entitys) { // // 保存区域IP信息 // List areaIpCfgList = areaIpCfgDao.getByCompileId(entitys.get(0).getCompileId()); @@ -1272,26 +1274,54 @@ public class AppCfgService extends BaseService { throw new RuntimeException("Unknown configGroupInfo isIssued value"); } } else if (isAudit == 3) { - //已经下发过的,调用分组复用配置删除接口 - GroupReuseAddBean maatBean = new GroupReuseAddBean(); - List groupReuseList=new ArrayList<>(); - GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); - ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_NO,groupId)); - groupReuseCfg.setIpRegionList(ipRegionList); - groupReuseCfg.setStrRegionList(strRegionList); - groupReuseCfg.setNumRegionList(numRegionList); - groupReuseList.add(groupReuseCfg); - maatBean.setGroupReuseCfgList(groupReuseList); - maatBean.setAuditTime(entitys.get(0).getAuditTime()); - maatBean.setCreatorName(entitys.get(0).getCurrentUser().getName()); - maatBean.setVersion(Constants.MAAT_VERSION); - maatBean.setOpAction(Constants.UPDATE_ACTION); - //调用服务接口下发配置数据 - String json=gsonToJson(maatBean); - logger.info("app协议IP域删除配置下发配置参数:"+json); - //调用服务接口下发配置 - ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3); - logger.info("app协议IP域删除配置响应信息:"+result.getMsg()); + //判断配置取消之后,是否还有有效的配置 + if(hasValidAppIp(configGroupInfo.getCompileId())){ + //已经下发过的,调用分组复用配置删除接口 + GroupReuseAddBean maatBean = new GroupReuseAddBean(); + List groupReuseList=new ArrayList<>(); + GroupReuseCfg groupReuseCfg=new GroupReuseCfg(); + ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_NO,groupId)); + groupReuseCfg.setIpRegionList(ipRegionList); + groupReuseCfg.setStrRegionList(strRegionList); + groupReuseCfg.setNumRegionList(numRegionList); + groupReuseList.add(groupReuseCfg); + maatBean.setGroupReuseCfgList(groupReuseList); + maatBean.setAuditTime(entitys.get(0).getAuditTime()); + maatBean.setCreatorName(entitys.get(0).getCurrentUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.UPDATE_ACTION); + //调用服务接口下发配置数据 + String json=gsonToJson(maatBean); + logger.info("app协议IP域删除配置下发配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3); + logger.info("app协议IP域删除配置响应信息:"+result.getMsg()); + }else{ + //修改组的有效状态为无效。并发送compileid 配置取消 此后组的app ip不再自动下发。 + ConfigGroupInfo appConfigGroup=new ConfigGroupInfo(); + appConfigGroup.setIsIssued(0); + appConfigGroup.setUpdateTime(new Date()); + appConfigGroup.setGroupId(configGroupInfo.getGroupId()); + configGroupInfoDao.updateConfigGroupInfobyGroupId(appConfigGroup); + //asn group下没有asn ip之后,需要失效整个compileId,并且不保留公共组信息 + ToMaatBean maatBean = new ToMaatBean(); + maatCfg.setCompileId(configGroupInfo.getCompileId()); + maatCfg.setServiceId(serviceId); + maatCfg.setIsValid(0);//无效 + //configCompileList.add(addKeepGroupList(maatCfg,entity)); + configCompileList.add(maatCfg); + maatBean.setConfigCompileList(configCompileList); + maatBean.setAuditTime(new Date()); + maatBean.setCreatorName(UserUtils.getUser().getName()); + maatBean.setVersion(Constants.MAAT_VERSION); + maatBean.setOpAction(Constants.UPDATE_ACTION); + //调用服务接口取消配置 + String json=gsonToJson(maatBean); + logger.info("app Ip 取消配置参数:"+json); + //调用服务接口下发配置 + ToMaatResult result = ConfigServiceUtil.put(json,1); + logger.info("app Ip 取消配置响应信息:"+result.getMsg()); + } } } @@ -2116,4 +2146,13 @@ public class AppCfgService extends BaseService { } + public boolean hasValidAppIp(Integer compileId){ + List appIps=appCfgDao.findAppIpByCompileId(compileId); + if(!StringUtil.isEmpty(appIps)){ + return true; + }else{ + return false; + } + } + } diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index ccfe707da..0facf3654 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -863,19 +863,15 @@ public class IpCfgService extends CrudService { List subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity); entity.setIpPortList(ipPortList); entity.setNtcSubscribeIdCfgList(subscribeIdList); - if(StringUtils.isNotBlank(entity.getCommonGroupIds())) { - List asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity); - entity.setAsnKeywords(asnKeywordCfgs); - } + List asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity); + entity.setAsnKeywords(asnKeywordCfgs); return entity; } public CfgIndexInfo exportIpInfo(CfgIndexInfo entity){ List ipPortList = ipCfgDao.getIpPortList(entity); entity.setIpPortList(ipPortList); - if(StringUtils.isNotBlank(entity.getUserRegion4())) { - List asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity); - entity.setAsnKeywords(asnKeywordCfgs); - } + List asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity); + entity.setAsnKeywords(asnKeywordCfgs); return entity; } public BaseIpCfg getIpCfgById(String tableName,long id){ diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index 58f6bb21a..7fa96f445 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1361,7 +1361,7 @@ nas_ip=NAS IP Address framed_ip=Framed IP Address log_user_name=User Name av_tips=The system does not support the index information of audio and video coding in the tail of the audio and video files. The system does not support video with resolution greater than 1080P. -asn_ip_group_delete=\uFF08IP configuration under this ASN group will also be deleted.) +asn_ip_group_delete=\uff08IP configuration under this ASN group will also be deleted.) keyword_log_tips=Deduplicate http body keywords log,for the control status of http body keywords is not ideal, configure the http url of the hit keyword as URL control configuration. conn_record=Connection Records bps=Gbps @@ -1474,4 +1474,6 @@ framework_log=Meta Log block_drop=Block(Drop) mail_record=Mail Records ssl_record=SSL Records -http_record=HTTP Records \ No newline at end of file +http_record=HTTP Records +second_bps=bps +GBps=GBps \ No newline at end of file diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index 63a8e577e..86980082f 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -44,6 +44,7 @@ domain_control=\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043 dns_control=DNS basic_configuration=\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Request_from=\u041f\u0438\u0441\u044c\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0444\u0438\u0441 +second_bps=bps classification_manage=\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f area_manage=\u0420\u0435\u0433\u0438\u043e\u043d feature_scope_manage=\u041e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 @@ -342,10 +343,10 @@ expression_type=\u0422\u0438\u043f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0 null_expression=\u041d\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f and_expression=& match_method=\u041c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 -substring_match=\u0421\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u0438\u0435 \u041F\u043E\u0434\u0441\u0442\u0440\u043E\u043A\u043E\u0439 -right_match= \u0421\u0443\u0444\u0444\u0438\u043A\u0441 \u0421\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u0438\u0435 -left_match=\u041F\u0440\u0435\u0444\u0438\u043A\u0441 \u0421\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u0438\u0435 -exactly_match=\u0422\u043E\u0447\u043D\u043E\u0441\u0442\u044C\u044E \u0421\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u0438\u0435 +substring_match=\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 +right_match= \u0421\u0443\u0444\u0444\u0438\u043a\u0441 \u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 +left_match=\u041f\u0440\u0435\u0444\u0438\u043a\u0441 \u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 +exactly_match=\u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 whether_hexbinary=\u041d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443 \u0438\u043b\u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 HEX hex_binary=HEX \u0444\u043e\u0440\u043c\u0430\u0442 case_insensitive_nohex=\u041d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443, \u0438 \u043d\u0435 HEX @@ -1018,7 +1019,7 @@ domain_intercepter_ratelimit=\u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u app_built_in_features_config=\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f PXY_INTERCEPT_PKT_BIN=\u041f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 certificate=\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 -do_log=\u041D\u0430\u0434\u043E \u043B\u0438 \u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C \u0436\u0443\u0440\u043D\u0430\u043B +do_log=\u041d\u0430\u0434\u043e \u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b file_strategy=\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 file_desc=\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 content_type=\u0422\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f @@ -1045,7 +1046,7 @@ keyring_name=\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440 keyring_type=\u0422\u0438\u043f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 private_key_file=\u0424\u0430\u0439\u043b \u0441 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u043c \u043a\u043b\u044e\u0447\u043e\u043c public_key_file=\u0424\u0430\u0439\u043b \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u043a\u043b\u044e\u0447\u043e\u043c -expire_after=\u0418\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435(\u0414\u043D\u0438) +expire_after=\u0418\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435(\u0414\u043d\u0438) issuer=\u042d\u043c\u0438\u0442\u0435\u043d\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 certificate_subject=\u041f\u0440\u0435\u0434\u043c\u0435\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 not_before_time=\u0412\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 @@ -1406,11 +1407,11 @@ APP_TCP_SESSION_BYTE=\u0421\u0435\u0430\u043d\u0441 ip_count=Uniq-IP counnection_count=\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 asn=ASN -Unique_num=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u041A\u043B\u0438\u0435\u043D\u0442\u0430 IP +Unique_num=\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u041a\u043b\u0438\u0435\u043d\u0442\u0430 IP ip=IP country=\u0421\u0442\u0440\u0430\u043d\u0430 desc=Desc -unique_num=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u041A\u043B\u0438\u0435\u043D\u0442\u0430 IP +unique_num=\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u041a\u043b\u0438\u0435\u043d\u0442\u0430 IP import_limit_is=The maximum import size is upload_limit_is=The limitation of file uplaod is count=Count @@ -1472,10 +1473,11 @@ not_exist=not exist real_time=Real Time history=History all_columns_hidden=All columns are hidden! -no_log=\u041D\u0435\u0442 \u0416\u0443\u0440\u043D\u0430\u043B\u043E\u0432 -all_log=\u0421\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0416\u0443\u0440\u043D\u0430\u043B \u0438 \u0416\u0443\u0440\u043D\u0430\u043B-\u0444\u0430\u0439\u043B -framework_log=\u0421\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0416\u0443\u0440\u043D\u0430\u043B +no_log=\u041d\u0435\u0442 \u0416\u0443\u0440\u043d\u0430\u043b\u043e\u0432 +all_log=\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0416\u0443\u0440\u043d\u0430\u043b \u0438 \u0416\u0443\u0440\u043d\u0430\u043b-\u0444\u0430\u0439\u043b +framework_log=\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0416\u0443\u0440\u043d\u0430\u043b block_drop=\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435(\u041f\u0430\u0434\u0435\u043d\u0438\u0435) -mail_record=\u0417\u0430\u043F\u0438\u0441\u0438 \u041F\u043E\u0447\u0442\u044B -ssl_record=SSL \u0417\u0430\u043F\u0438\u0441\u0438 -http_record=HTTP \u0417\u0430\u043F\u0438\u0441\u0438 \ No newline at end of file +mail_record=\u0417\u0430\u043f\u0438\u0441\u0438 \u041f\u043e\u0447\u0442\u044b +ssl_record=SSL \u0417\u0430\u043f\u0438\u0441\u0438 +http_record=HTTP \u0417\u0430\u043f\u0438\u0441\u0438 +GBps=GBps \ No newline at end of file diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index fd0b9b7d8..7ef037d10 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1017,7 +1017,7 @@ domain_intercepter_ratelimit=\u57df\u540d\u62e6\u622a\u9650\u901f app_built_in_features_config=APP\u5185\u7f6e\u7279\u5f81\u7ef4\u62a4 PXY_INTERCEPT_PKT_BIN=\u5305\u8f7d\u8377 certificate=\u8bc1\u4e66 -do_log=\u662F\u5426\u8BB0\u5F55\u65E5\u5FD7 +do_log=\u662f\u5426\u8bb0\u5f55\u65e5\u5fd7 file_strategy=\u6587\u4ef6\u7b56\u7565 file_desc=\u6587\u4ef6\u63cf\u8ff0\t content_type=\u5185\u5bb9\u7c7b\u578b @@ -1468,10 +1468,12 @@ not_exist=\u4e0d\u5b58\u5728 real_time=\u5b9e\u65f6 history=\u5386\u53f2 all_columns_hidden=\u6240\u6709\u7684\u5217\u90fd\u9690\u85cf\u4e86\uff01 -no_log=\u4E0D\u8BB0\u5F55 -all_log=\u8BB0\u5F55\u6240\u6709\u65E5\u5FD7 -framework_log=\u53EA\u8BB0\u5F55\u7ED3\u6784\u5316\u65E5\u5FD7 -block_drop=\u5C01\u5835(\u4E22\u5F03) -mail_record=\u90AE\u4EF6\u6CDB\u6536 -ssl_record=SSL\u6CDB\u6536 -http_record=HTTP\u6CDB\u6536 \ No newline at end of file +no_log=\u4e0d\u8bb0\u5f55 +all_log=\u8bb0\u5f55\u6240\u6709\u65e5\u5fd7 +framework_log=\u53ea\u8bb0\u5f55\u7ed3\u6784\u5316\u65e5\u5fd7 +block_drop=\u5c01\u5835(\u4e22\u5f03) +mail_record=\u90ae\u4ef6\u6cdb\u6536 +ssl_record=SSL\u6cdb\u6536 +http_record=HTTP\u6cdb\u6536 +second_bps=bps +GBps=GBps \ No newline at end of file diff --git a/src/main/resources/sql/20190117/add_sys_menu.sql b/src/main/resources/sql/20190117/add_sys_menu.sql new file mode 100644 index 000000000..dc036d817 --- /dev/null +++ b/src/main/resources/sql/20190117/add_sys_menu.sql @@ -0,0 +1,3 @@ +--新增日志检索->白名单->IP白名单 +INSERT INTO `sys_menu` (`id`, `parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('1240', '152', '0,1,152,', 'whitelist', 'White List', '1', '', '', '', '1', '', '1', '2019-01-16 14:51:10', '1', '2019-01-16 15:31:46', '', '1', NULL, '0', '0', NULL); +INSERT INTO `sys_menu` (`id`, `parent_id`, `parent_ids`, `code`, `name`, `sort`, `href`, `target`, `icon`, `is_show`, `permission`, `create_by`, `create_date`, `update_by`, `update_date`, `remarks`, `del_flag`, `menu_bg`, `quick_action`, `is_top`, `function_id`) VALUES ('1241', '1240', '0,1,152,1240,', 'ip_whitelist', 'IP White List', '1', '/log/ntc/ipWhiteList', '', '', '1', '', '1', '2019-01-16 14:52:55', '1', '2019-01-16 17:27:31', '', '1', NULL, '0', '0', '3'); \ No newline at end of file diff --git a/src/main/resources/sql/20190117/alter_asn_function_table.sql b/src/main/resources/sql/20190117/alter_asn_function_table.sql new file mode 100644 index 000000000..8ca806d00 --- /dev/null +++ b/src/main/resources/sql/20190117/alter_asn_function_table.sql @@ -0,0 +1,2 @@ +#asn和组织之间的关系属性 +ALTER TABLE asn_group_info ADD org_group_id int(20) DEFAULT 0 COMMENT '与config_group_info的group_id关联'; \ No newline at end of file diff --git a/src/main/resources/sql/truncate_tables.sql b/src/main/resources/sql/truncate_tables.sql index 32537395e..3e7935cdc 100644 --- a/src/main/resources/sql/truncate_tables.sql +++ b/src/main/resources/sql/truncate_tables.sql @@ -1,6 +1,7 @@ DELETE FROM app_byte_cfg; DELETE FROM app_domain_cfg; DELETE FROM app_features_index; +DELETE FROM app_feature_index; DELETE FROM app_http_cfg; DELETE FROM app_id_cfg; DELETE FROM app_ip_cfg; @@ -65,4 +66,8 @@ DELETE FROM ip_reuse_ip_cfg; DELETE FROM ip_reuse_policy_cfg; DELETE FROM user_manage; #clear vpn -DELETE FROM service_dict_info where item_type='5'; \ No newline at end of file +DELETE FROM service_dict_info where item_type='5'; +-- DNSҲҪ100ԲԷ101ʼ +ALTER TABLE policy_group_info auto_increment = 101; +-- asnŷ +DELETE FROM asn_group_info; \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/tags/sys/delRow.tag b/src/main/webapp/WEB-INF/tags/sys/delRow.tag index ca12d1145..ce2363ace 100644 --- a/src/main/webapp/WEB-INF/tags/sys/delRow.tag +++ b/src/main/webapp/WEB-INF/tags/sys/delRow.tag @@ -393,18 +393,7 @@ function cancelPassOpt(url){ }); return flag; } - //验证是否可删除 - function validateIsDelete(checkboxes){ - var flag = false; - $(checkboxes).filter(":checked").each(function(){ - //alert($(this).val()); - if($(this).val()!=0 && $(this).val()!=3){//状态为3的配置为取消审核的配置,可删除 - flag = true; - return; - } - }); - return flag; - } + //验证选择的配置,是否有审核通过的 function validatePass(checkboxes){ var flag = false; diff --git a/src/main/webapp/WEB-INF/views/basics/asnGroupForm.jsp b/src/main/webapp/WEB-INF/views/basics/asnGroupForm.jsp index add96f316..3344ea492 100644 --- a/src/main/webapp/WEB-INF/views/basics/asnGroupForm.jsp +++ b/src/main/webapp/WEB-INF/views/basics/asnGroupForm.jsp @@ -65,13 +65,14 @@ $(function(){ +
- +
diff --git a/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp b/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp index 35addb20b..04e2fe0fe 100644 --- a/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp @@ -282,10 +282,10 @@ <%-- - --%> - + --%> <%-- --%> + @@ -388,12 +388,7 @@ ${fns:abbr(lableInfo,20)} --%> - <%-- ${cfg.areaEffectiveIds } --%> - - - - - + <%-- ${cfg.areaEffectiveIds } --%> @@ -412,6 +407,11 @@ --%> <%--
--%> + + + + + ${cfg.creatorName } ${cfg.editorName } diff --git a/src/main/webapp/WEB-INF/views/cfg/asnForm.jsp b/src/main/webapp/WEB-INF/views/cfg/asnForm.jsp index cccdbb00e..8e5dbd1d8 100644 --- a/src/main/webapp/WEB-INF/views/cfg/asnForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/asnForm.jsp @@ -20,15 +20,21 @@ + + + + + + - - + +<%-- - + --%>
-
+ <%--
@@ -38,13 +44,14 @@
-
+
--%>
- + + <%-- --%>
diff --git a/src/main/webapp/WEB-INF/views/cfg/av/switchSignSample.jsp b/src/main/webapp/WEB-INF/views/cfg/av/switchSignSample.jsp index f75be364f..ea71cab8f 100644 --- a/src/main/webapp/WEB-INF/views/cfg/av/switchSignSample.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/av/switchSignSample.jsp @@ -26,6 +26,13 @@ $(function(){ $(".level").find("select[name$='level']").val("0"); $(".level").find("select[name$='level']").selectpicker("refresh"); } + if($("span").hasClass("label-success")){ + $("input[name='action']").not(":checked").attr("disabled","disabled"); + $("#save").attr("disabled","disabled"); + }else{ + $("input[name='action']").removeAttr("disabled"); + $("#save").removeAttr("disabled"); + } $("input[name~=action]").on("change",function(){ $("#serviceId").val($(this).attr("serviceId")); if($(".action:checked").val()==1){ @@ -64,6 +71,10 @@ $(function(){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); }, submitHandler: function(form){ + if($("span").hasClass("label-success")){ + top.$.jBox.tip("", ""); + return; + } loading('onloading...'); form.submit(); }, @@ -96,7 +107,7 @@ $(function(){ - + diff --git a/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgList.jsp index 76718c95a..192f6643f 100644 --- a/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgList.jsp @@ -331,13 +331,13 @@ - - - + + + <%-- --%> + <%-- --%> - @@ -370,13 +370,20 @@ + + + + + + + + - - ${fns:abbr(cfg.destIpAddress, 42)} + <%-- ${cfg.destPort } --%> @@ -388,14 +395,7 @@ --%> - - - - - - - - + ${fns:abbr(cfg.destIpAddress, 42)} ${cfg.requestName } diff --git a/src/main/webapp/WEB-INF/views/cfg/intercept/interceptList.jsp b/src/main/webapp/WEB-INF/views/cfg/intercept/interceptList.jsp index 3a3657956..199b383d6 100644 --- a/src/main/webapp/WEB-INF/views/cfg/intercept/interceptList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/intercept/interceptList.jsp @@ -409,14 +409,14 @@ --%> + + - - - + @@ -552,6 +552,14 @@ + + + + + + + +
@@ -623,15 +631,7 @@ - - - - - - - - -
+ ${indexCfg.creatorName } ${indexCfg.editorName } diff --git a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp index 9dde0f0ae..cd18f3091 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp @@ -312,6 +312,10 @@ var processAction=function(configType,obj){ }) $(".ratelimitAction").addClass("hidden"); $(".ratelimitAction").find("input[name^='userRegion'],select[name^='userRegion']").attr("disabled",true); + $(".subscribeId").find(".glyphicon-remove").click(); + $(".subscribeId").prev("h4").addClass("hidden"); + $(".asnRegionV").find(".glyphicon-remove").click(); + $(".asnRegionV").prev("h4").addClass("hidden"); }else if(action==16){ //先清空,再添加 o.find("select[name$='protocol']").empty(); @@ -322,6 +326,8 @@ var processAction=function(configType,obj){ }) $(".ratelimitAction").addClass("hidden"); $(".ratelimitAction").find("input[name^='userRegion'],select[name^='userRegion']").attr("disabled",true); + $(".subscribeId").prev("h4").removeClass("hidden"); + $(".asnRegionV").prev("h4").removeClass("hidden"); }else if(action==64){ //先清空,再添加 o.find("select[name$='protocol']").empty(); @@ -342,6 +348,8 @@ var processAction=function(configType,obj){ $(".droprate").find("select[name='userRegion2']").attr("disabled",true); $(".droprate").find("select[name='userRegion2']").selectpicker("refresh"); } + $(".subscribeId").prev("h4").removeClass("hidden"); + $(".asnRegionV").prev("h4").removeClass("hidden"); }else if(action==1){ //先清空,再添加 o.find("select[name$='protocol']").empty(); @@ -352,6 +360,8 @@ var processAction=function(configType,obj){ }) $(".ratelimitAction").addClass("hidden"); $(".ratelimitAction").find("input[name^='userRegion'],select[name^='userRegion']").attr("disabled",true); + $(".subscribeId").prev("h4").removeClass("hidden"); + $(".asnRegionV").prev("h4").removeClass("hidden"); } o.find("select[name$='protocol']").selectpicker("refresh"); //切换后如果没找到选项,选任意协议 @@ -419,6 +429,7 @@ var showHideIPSECProtocol=function(obj){ + diff --git a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipSubList.jsp b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipSubList.jsp index b6d41324f..2c583a79f 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipSubList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipSubList.jsp @@ -221,7 +221,7 @@
-
+ <%--
@@ -230,7 +230,7 @@
-
+
--%>
diff --git a/src/main/webapp/WEB-INF/views/cfg/maintenance/ipMultiplexPool/snatlist2.jsp b/src/main/webapp/WEB-INF/views/cfg/maintenance/ipMultiplexPool/snatlist2.jsp index e21c08cc8..383896ddf 100644 --- a/src/main/webapp/WEB-INF/views/cfg/maintenance/ipMultiplexPool/snatlist2.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/maintenance/ipMultiplexPool/snatlist2.jsp @@ -401,8 +401,7 @@ - <%-- --%> - + <%-- --%> <%-- --%> @@ -410,6 +409,7 @@ + @@ -438,12 +438,7 @@ - --%> - - - - - + --%> @@ -524,6 +519,11 @@ ${fns:abbr(lableInfo,20)} + + + + + ${cfg.creatorName } ${cfg.editorName } diff --git a/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/dnatPolicyList2.jsp b/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/dnatPolicyList2.jsp index f15562e2f..41a00dace 100644 --- a/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/dnatPolicyList2.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/dnatPolicyList2.jsp @@ -353,18 +353,17 @@ - - - - + <%-- --%> + + <%-- --%> <%-- --%> - <%-- --%> + @@ -417,16 +416,14 @@ - -
- + <%-- - --%> + --%> <%-- @@ -434,12 +431,7 @@ - --%> - - - - - + --%> @@ -448,6 +440,8 @@ +
+ <%--
--%> ${indexCfg.requestName } @@ -507,7 +501,11 @@ ${fns:abbr(lableInfo,20)} - <%--
--%> + + + + + ${indexCfg.creatorName } ${indexCfg.editorName } diff --git a/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/snatPolicyForm2.jsp b/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/snatPolicyForm2.jsp index 58a6bfb0c..1162ccb47 100644 --- a/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/snatPolicyForm2.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/manipulation/ipmulitiplex/snatPolicyForm2.jsp @@ -213,15 +213,15 @@ var switchUserType = function(obj){
-
+ diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficAppTrendList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficAppTrendList.jsp index 1618849f2..b6f81469e 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficAppTrendList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficAppTrendList.jsp @@ -162,6 +162,8 @@ () () + + @@ -317,6 +319,8 @@ html += "" + data.pktPercent + " %"; html += "" + Math.round(data.byteNum*100)/100 + ""; html += "" + data.bytePercent + " %"; + html += "" + data.pps + ""; + html += "" + data.bps + ""; html += "" if(index==fileDataS.length-1){ html+="" @@ -327,7 +331,9 @@ html+= ""+"--"+""; html+= ""+totalbyte+""; html+= ""+"--"+""; - html+="" + html+= ""+"--"+""; + html+= ""+"--"+""; + html+="" } } $("#tableData").append(html); diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficAppTypeList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficAppTypeList.jsp index dd4b361ec..390483cc6 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficAppTypeList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficAppTypeList.jsp @@ -120,6 +120,8 @@ () () + + @@ -353,6 +355,8 @@ function htmlData(fileDataS){ html+= ""+packper+"%"+""; html+= ""+Math.round(data.GByte*100)/100+""; html+= ""+gbytper+"%"+""; + html+= ""+data.pps+""; + html+= ""+data.bps+""; html+="" if(index==fileDataS.length-1){ html+="" @@ -364,6 +368,8 @@ function htmlData(fileDataS){ html+= ""+"100%"+""; html+= ""+Math.round(totalGByte*100)/100+""; html+= ""+"100%"+""; + html+= ""+"--"+""; + html+= ""+"--"+""; html+="" } } diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficHttpStatisticList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficHttpStatisticList.jsp index c2a569e15..cc8d9505f 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficHttpStatisticList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficHttpStatisticList.jsp @@ -82,6 +82,8 @@ () () + + @@ -298,6 +300,8 @@ function htmlData(fileDataS){ html+= ""+(data.packets/data.allPackets*100).toFixed(2)+"%"+""; html+= ""+(data.count/1073741824).toFixed(2)+""; html+= ""+(data.count/data.allGByte*100).toFixed(2)+"%"+""; + html+= ""+data.pps+""; + html+= ""+data.bps+""; html+="" if(index==fileDataS.length-1){ html+="" @@ -308,6 +312,8 @@ function htmlData(fileDataS){ html+= ""+"100%"+""; html+= ""+(data.allGByte/1073741824).toFixed(2)+""; html+= ""+"100%"+""; + html+= ""+"--"+""; + html+= ""+"--"+""; html+="" } } diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficIpActiveList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficIpActiveList.jsp index fa791acf9..8e70efb56 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficIpActiveList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficIpActiveList.jsp @@ -100,6 +100,8 @@ + + @@ -422,6 +424,8 @@ function showIpActiveChart(xData,series){ html+= ""+rs.s2cPktNum+""; html+= ""+packetNum+""; html+= ""+rs.statTime+""; + html+= ""+rs.avgPacket+""; + html+= ""+rs.avgByte+""; html+="" if(i==data.length-1){ @@ -435,6 +439,8 @@ function showIpActiveChart(xData,series){ html+= ""+totalc2sPkt+""; html+= ""+totals2cPkt+""; html+= ""+totalpacket+""; + html+= ""+"--"+""; + html+= ""+"--"+""; html+= ""+"--"+""; html+="" } diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficProtocolTypeList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficProtocolTypeList.jsp index 4311e068f..184c8e438 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficProtocolTypeList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficProtocolTypeList.jsp @@ -107,6 +107,8 @@ () () + + @@ -343,6 +345,8 @@ function htmlData(fileDataS){ html+= ""+packper+"%"+""; html+= ""+Math.round(data.GByte*100)/100+""; html+= ""+gbytper+"%"+""; + html+= ""+data.pps+""; + html+= ""+data.bps+""; html+="" if(index==fileDataS.length-1){ html+="" @@ -353,6 +357,8 @@ function htmlData(fileDataS){ html+= ""+"100%"+""; html+= ""+Math.round(totalGByte*100)/100+""; html+= ""+"100%"+""; + html+= ""+"——"+""; + html+= ""+"——"+""; html+="" } } diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficUserBehavior.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficUserBehavior.jsp index b207a3362..a2d38a1ae 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficUserBehavior.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficUserBehavior.jsp @@ -130,7 +130,6 @@ } $("#pageNo").val(n); $("#pageSize").val(s); -// $("#searchForm").attr("action","${ctx}/traffic/userBehavior"); $("#searchForm").submit(); return false; } @@ -244,7 +243,7 @@
+ value="${log.searchFoundStartTime}" onclick="WdatePicker({onpicked:function(){this.onchange()},dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'#F{\'new Date()\'}'});" onchange="setEndTimeByFormat('#searchFoundStartTime','#searchFoundEndTime',1,'d','yyyy-MM-dd hh:mm:ss',false,'yyyy-MM-dd hh')"/>
@@ -253,14 +252,14 @@
+ value="${log.searchFoundEndTime}" onclick="WdatePicker({onpicked:function(){this.onchange()},dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'#F{\'new Date()\'}'});" onchange="setEndTimeByFormat('#searchFoundStartTime','#searchFoundEndTime',1,'d','yyyy-MM-dd hh:mm:ss',false,'yyyy-MM-dd hh')"/>
- +
- +
diff --git a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp index ffe66034f..be277e753 100644 --- a/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp +++ b/src/main/webapp/WEB-INF/views/dashboard/trafficWebTypeList.jsp @@ -150,6 +150,8 @@ () () + + @@ -398,6 +400,8 @@ html += "" + packper + " %"; html += "" + Math.round(data.Gbyte*100)/100 + ""; html += "" + gbytper + " %"; + html += "" + data.pps + ""; + html += "" + data.bps + ""; html += "" if(index==fileDataS.length-1){ html+="" @@ -409,6 +413,8 @@ html+= ""+"100%"+""; html+= ""+parseInt(totalGbyte).toFixed(2)+""; html+= ""+"100%"+""; + html+= ""+"--"+""; + html+= ""+"--"+""; html+="" } } diff --git a/src/main/webapp/WEB-INF/views/log/ntc/connRecordLogList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/connRecordLogList.jsp index f639f7549..bce69e6a9 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/connRecordLogList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/connRecordLogList.jsp @@ -44,6 +44,16 @@ $('#appSelect').selectpicker('render'); } + $('#ispSelect').selectpicker(); + var app = $("#isps").val(); //回选的数据 + if (app !=null && app !='') { + var seasonlist = app.split(","); + $('#ispSelect').selectpicker('val',seasonlist); + $('#ispSelect').selectpicker('render'); + } + + + $('#protoSelect').selectpicker(); var proto = $("#protos").val(); //回选的数据 if (proto !=null && proto !='') { @@ -127,6 +137,7 @@ + +
+
+ + +
+
+ +
" class="selectpicker form-control " data-max-options="10" data-selected-text-format="count > 3" multiple data-live-search="true" data-live-search-placeholder=""> - @@ -290,7 +311,6 @@
- -
-
diff --git a/src/main/webapp/WEB-INF/views/log/ntc/httpRecordList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/httpRecordList.jsp index da562a1d3..4d9e3d91a 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/httpRecordList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/httpRecordList.jsp @@ -353,9 +353,9 @@ - -<%-- <%-- --%> -<%-- --%> --%> + +<%-- --%> + <%-- ${log.cfgId } --%> diff --git a/src/main/webapp/WEB-INF/views/log/ntc/ipWhiteList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/ipWhiteList.jsp index 82517330d..6b5b1b892 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/ipWhiteList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/ipWhiteList.jsp @@ -265,7 +265,7 @@ <%-- --%> - + ${log.cfgId } diff --git a/src/main/webapp/WEB-INF/views/log/ntc/mailRecordList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/mailRecordList.jsp index 43b625b04..e931b1451 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/mailRecordList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/mailRecordList.jsp @@ -237,8 +237,8 @@ - - +<%-- --%> +<%-- --%> @@ -284,16 +284,16 @@ <%-- --%> - ${log.cfgId } - - ${log.action } - - - ${dict.itemValue} - - - - +<%-- ${log.cfgId } --%> + +<%-- ${log.action } --%> +<%-- --%> +<%-- --%> +<%-- ${dict.itemValue} --%> +<%-- --%> +<%-- --%> +<%-- --%> + ${log.foundTime } ${log.recvTime } diff --git a/src/main/webapp/WEB-INF/views/log/ntc/sslRecordLogList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/sslRecordLogList.jsp index c9d19e33b..90cdd01e4 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/sslRecordLogList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/sslRecordLogList.jsp @@ -244,8 +244,8 @@ - - +<%-- --%> +<%-- --%> @@ -290,16 +290,16 @@ <%-- --%> - ${log.cfgId } - - ${log.action } - - - ${dict.itemValue} - - - - +<%-- ${log.cfgId } --%> + +<%-- ${log.action } --%> +<%-- --%> +<%-- --%> +<%-- ${dict.itemValue} --%> +<%-- --%> +<%-- --%> +<%-- --%> + ${log.foundTime } ${log.recvTime } diff --git a/src/main/webapp/WEB-INF/views/login.jsp b/src/main/webapp/WEB-INF/views/login.jsp index 49acd702c..b203598b3 100644 --- a/src/main/webapp/WEB-INF/views/login.jsp +++ b/src/main/webapp/WEB-INF/views/login.jsp @@ -79,7 +79,7 @@ } .main_right{ - background-image: url("${pageContext.request.contextPath}/static/login/assets/images/login/login_06.png"); + background-image: url("${pageContext.request.contextPath}/static/login/assets/images/login/login_06-K.png"); background-repeat:no-repeat; background-size: 100% 100%; max-height: 501px; diff --git a/src/main/webapp/WEB-INF/views/report/asnRecordList.jsp b/src/main/webapp/WEB-INF/views/report/asnRecordList.jsp index bdd37d706..8ba476c4a 100644 --- a/src/main/webapp/WEB-INF/views/report/asnRecordList.jsp +++ b/src/main/webapp/WEB-INF/views/report/asnRecordList.jsp @@ -230,7 +230,7 @@ --%> - + diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js index b4c892e78..74cd634d0 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js @@ -953,8 +953,24 @@ jQuery.validator.addMethod("asnNoUnique",function(value, element) { async:false, url: url, data:{"id":id,"asnId":value}, - success:function(data){ - result = data; + success:function(data,textStatus){ + if(textStatus=="success"){ + if(data == null || data.id==null || data.id == 'undefined'){ + result=true; + }else{ + /*if($(element).attr("name") + && $(element).attr("name") != ''){ + var name=$(element).attr("name").split("."); + console.log(name[0]); + if(name[1] == 'cfgKeywords'){ + $("input[name='"+name[0]+".userRegion1']").val(data.regionId); + $("input[name='"+name[0]+".userRegion2']").val(data.groupId); + } + }*/ + result=false; + } + } + } }); return result; @@ -963,18 +979,40 @@ jQuery.validator.addMethod("asnMustExists",function(value, element) { var ctx=$(element).attr("ctx"); //var id= $("[name='id']").val(); var url = ctx+"/basics/asnGroup/checkAsnNo"; - var result = true; + var result = false; $.ajax({ type:'post', async:false, url: url, data:{"asnId":value}, - success:function(data){ - if(data==true){ - result=false; - }else{ - result=true; + success:function(data,textStatus){ + if(textStatus=="success"){ + if(data == null || data.id==null || data.id == 'undefined'){ + result=false; + }else{ + if($(element).attr("name") + && $(element).attr("name") != ''){ + var name=$(element).attr("name").split("."); + console.log(name[0]); + if(name[1] == 'cfgKeywords'){ + //校验成功的同时 + $("input[name='"+name[0]+".userRegion1']").val(data.regionId); + $("input[name='"+name[0]+".userRegion2']").val(data.groupId); + $("input[name='"+name[0]+".userRegion3']").val(data.commonGroupIds); + var commonGroupIds=$("input[name='commonGroupIds']").val(); + if(commonGroupIds !=null + && commonGroupIds != '' + && (","+commonGroupIds+",").indexOf(","+data.commonGroupIds+",") < 0){ + $("input[name='commonGroupIds']").val(commonGroupIds+","+data.commonGroupIds) + }else{ + $("input[name='commonGroupIds']").val(data.commonGroupIds) + } + } + } + result=true; + } } + } }); return result; diff --git a/src/main/webapp/static/global/scripts/asnRegion.js b/src/main/webapp/static/global/scripts/asnRegion.js index 8e19d46d3..8961a7770 100644 --- a/src/main/webapp/static/global/scripts/asnRegion.js +++ b/src/main/webapp/static/global/scripts/asnRegion.js @@ -1,4 +1,4 @@ -$(function(){ +/*$(function(){ $('.asnNo').selectpicker({ deselectAllText: $("#deselectAll").text(), selectAllText: $("#selectAll").text() @@ -11,9 +11,9 @@ $(function(){ $(this).change(); }); }); -/** +*//** * 异步获取ASN组织 - */ + *//* var initAsnOrganazation=function(){ var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.lastIndexOf("/nis")+4); $.ajax({ @@ -34,7 +34,7 @@ var initAsnOrganazation=function(){ } } }); - /***设定数据库值***/ + *//***设定数据库值***//* $(".organization").each(function(){ if($(this).attr("name") != null && $(this).attr("name") != 'undefined'){ var asnObjName = ($(this).attr("name")).split("userRegion1")[0]+"organizationGroupId"; @@ -45,9 +45,9 @@ var initAsnOrganazation=function(){ }); } -/** +*//** * ASN组织级联获取ASN NO - */ + *//* var getASNNo=function(obj,orgGroupId,orgName){ if($(obj).attr("name") != null && $(obj).attr("name") != 'undefined'){ var asnObjName = ($(obj).attr("name")).split("userRegion1")[0]+"cfgKeywords"; @@ -71,7 +71,7 @@ var getASNNo=function(obj,orgGroupId,orgName){ }); } - /***设定数据库值***/ + *//***设定数据库值***//* $("select[name='"+asnObjName+"']").selectpicker('refresh'); var asnNoObjName = ($(obj).attr("name")).split("userRegion1")[0]+"asnNo"; if($("input[name='"+asnNoObjName+"']").val() == '' @@ -88,3 +88,4 @@ var getASNNo=function(obj,orgGroupId,orgName){ } } +*/ \ No newline at end of file