From c69370aabe8709543bcae504900bda3b4990ff71 Mon Sep 17 00:00:00 2001 From: duandongmei Date: Fri, 2 Nov 2018 11:21:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=B1=9E=E6=80=A7=E8=A7=84?= =?UTF-8?q?=E5=88=99=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E7=BB=99=E5=87=BA=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nis/util/excel/ExportExcel.java | 461 +++++++++++++++--- 1 file changed, 381 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/nis/util/excel/ExportExcel.java b/src/main/java/com/nis/util/excel/ExportExcel.java index 51d93d27c..c9f9f7834 100644 --- a/src/main/java/com/nis/util/excel/ExportExcel.java +++ b/src/main/java/com/nis/util/excel/ExportExcel.java @@ -49,6 +49,7 @@ import com.nis.domain.FunctionServiceDict; import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.basics.PolicyGroupInfo; import com.nis.domain.basics.ServiceDictInfo; +import com.nis.domain.basics.SysDictInfo; import com.nis.domain.configuration.DnsResStrategy; import com.nis.util.Constants; import com.nis.util.DictUtils; @@ -57,6 +58,7 @@ import com.nis.util.Reflections; import com.nis.util.StringUtil; import com.nis.web.dao.FunctionServiceDictDao; import com.nis.web.dao.basics.PolicyGroupInfoDao; +import com.nis.web.dao.basics.SysDictInfoDao; import com.nis.web.dao.configuration.DnsResStrategyDao; import com.nis.web.service.SpringContextHolder; import com.nis.web.service.configuration.DnsResStrategyService; @@ -74,6 +76,8 @@ public class ExportExcel { private static Logger log = LoggerFactory.getLogger(ExportExcel.class); private static DnsResStrategyDao dnsResStrategyDao = SpringContextHolder.getBean(DnsResStrategyDao.class); + private static PolicyGroupInfoDao policyGroupInfoDao = SpringContextHolder.getBean(PolicyGroupInfoDao.class); + private static SysDictInfoDao sysDictInfoDao = SpringContextHolder.getBean(SysDictInfoDao.class); /** * 工作薄对象 @@ -174,7 +178,7 @@ public class ExportExcel { commentStr=commentStr+sysDataDictionaryItem.getItemCode()+"("+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+")\n"; index++; } - defaultValue=p2pIpType.get(0).getItemCode()+"("+msgProp.getProperty(p2pIpType.get(0).getItemValue(),p2pIpType.get(0).getItemValue())+")"; + defaultValue=p2pIpType.get(0).getItemCode(); } commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; @@ -182,7 +186,7 @@ public class ExportExcel { commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n"; index++; if(!StringUtil.isEmpty(defaultValue)){ - //2、默认值说明 + //1、默认值说明 commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; index++; } @@ -204,12 +208,28 @@ public class ExportExcel { commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n"; index++; if(!StringUtil.isEmpty(defaultValue)){ - //2、默认值说明 + //1、默认值说明 commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; index++; index++; } } + /***发现内容***/ + if("replaced_content".equals(headerStr)){ + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + } + /***替换内容***/ + if("replace_content".equals(headerStr)){ + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + } //intercept replace replace_zone if("replace_zone".equals(headerStr)){ commentStr=""; @@ -219,7 +239,7 @@ public class ExportExcel { commentStr=commentStr+sysDataDictionaryItem.getItemCode()+"("+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+")\n"; index++; } - defaultValue=interceptReplaceZone.get(0).getItemCode()+"("+msgProp.getProperty(interceptReplaceZone.get(0).getItemValue(),interceptReplaceZone.get(0).getItemValue())+")"; + defaultValue=interceptReplaceZone.get(0).getItemCode(); } commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; @@ -227,7 +247,7 @@ public class ExportExcel { commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n"; index++; if(!StringUtil.isEmpty(defaultValue)){ - //2、默认值说明 + //1、默认值说明 commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; index++; index++; @@ -250,7 +270,7 @@ public class ExportExcel { List resStrategys=dnsResStrategyDao.findList(null, 1,1); commentStr=commentStr+"0"+"("+msgProp.getProperty("no_strategy")+")\n"; index++; - defaultValue="0"+"("+msgProp.getProperty("no_strategy")+")"; + defaultValue="0"; if(!StringUtil.isEmpty(resStrategys)){ for (DnsResStrategy dnsResStrategy : resStrategys) { commentStr=commentStr+dnsResStrategy.getCfgId()+"("+dnsResStrategy.getCfgDesc()+")\n"; @@ -292,11 +312,44 @@ public class ExportExcel { index++; } if("bps_threadshold".equals(headerStr)){ - commentStr=msgProp.getProperty("input_integer")+":\n"+commentStr; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + commentStr=commentStr+msgProp.getProperty("input_integer")+"\n"; index++; } if("pps_threadshold".equals(headerStr)){ - commentStr=msgProp.getProperty("input_integer")+":\n"+commentStr; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + commentStr=commentStr+msgProp.getProperty("input_integer")+"\n"; + index++; + } + if("group".equals(headerStr)) { + commentStr=""; + //查询ip复用地址池配置的policyGroup列表 + List list=policyGroupInfoDao.findPolicyGroupInfosByType(2); + if(!StringUtil.isEmpty(list)){ + for (PolicyGroupInfo policyGroupInfo : list) { + commentStr=commentStr+policyGroupInfo.getGroupId()+"("+policyGroupInfo.getGroupName()+")\n"; + index++; + } + } + commentStr=msgProp.getProperty("select")+":\n"+commentStr; + index++; + } + if("isp".equals(headerStr)) { + commentStr=""; + List itTypeList = new ArrayList(); + itTypeList.add(Constants.ITEM_TYPE_ISP); + SysDictInfo sysDictInfo=new SysDictInfo(); + sysDictInfo.setConditionType(itTypeList); + List isps=sysDictInfoDao.findAllSysDictInfo(sysDictInfo,null); + if(!StringUtil.isEmpty(isps)){ + for (SysDictInfo _sysDictInfo : isps) { + commentStr=commentStr+_sysDictInfo.getItemCode()+"("+_sysDictInfo.getItemValue()+")\n"; + index++; + } + } + commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; } if(region.getRegionType().equals(1)){//IP配置 @@ -318,28 +371,46 @@ public class ExportExcel { if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"(IPv4)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_VALUE; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv4_range_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv4_subnet_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE; + } index++; } } if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"(IPv6)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_VALUE; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv6_range_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv6_subnet_tip")+")"+"\n\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE; + } index++; } } @@ -372,32 +443,46 @@ public class ExportExcel { index++; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; index++; - //1、源IP和目的IP不能相同 - commentStr=commentStr+"▶"+String.format(msgProp.getProperty("are_the_same") - , msgProp.getProperty("clientip") - ,msgProp.getProperty("serverip"))+"\n"; - index++; - index++; - //2、源IP和目的IP IP类型和IP格式必须一致 - commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n"; - index++; - index++; - //3、IP Range 开始IP和结束IP必须在同一网段 - commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; - index++; - index++; - //4、IP Range 开始IP必须小于结束IP - commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_smaller")+"\n"; - index++; - index++; - //5、IPv4 Mask 掩码范围16-32 - commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; - index++; - index++; - //6、IPv6 Mask 掩码范围2-128 - commentStr=commentStr+"▶"+msgProp.getProperty("ipv6_subnet_tip")+","+msgProp.getProperty("ipv6_mask_range_tip")+"\n"; - index++; - index++; + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } + //2、源IP和目的IP不能相同 + if(((","+region.getConfigIpPortShow()+",").indexOf(",1,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1)){ + commentStr=commentStr+"▶"+String.format(msgProp.getProperty("are_the_same") + , msgProp.getProperty("clientip") + ,msgProp.getProperty("serverip"))+"\n"; + index++; + index++; + commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n"; + index++; + index++; + } + //4、IP Range 开始IP和结束IP必须在同一网段 + if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; + index++; + index++; + //5、IP Range 开始IP必须小于结束IP + commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_smaller")+"\n"; + index++; + index++; + } + + //6、IPv4 Mask 掩码范围16-32 + if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){ + if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; + index++; + index++; + } + if(((","+region.getConfigIpType()+",").indexOf(",6,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ipv6_subnet_tip")+","+msgProp.getProperty("ipv6_mask_range_tip")+"\n"; + index++; + index++; + } + } } } @@ -407,28 +492,46 @@ public class ExportExcel { if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"(IPv4)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_VALUE+"(IPv4)"; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv4_range_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv4_range_tip"); + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv4_subnet_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv4_subnet_tip")+")"; + } index++; } } if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"(IPv6)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_VALUE+"(IPv6)"; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv6_range_tip")+")"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv6_range_tip")+")"; + } index++; } if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv6_subnet_tip")+")"+"\n\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv6_subnet_tip")+")"; + } index++; } } @@ -445,43 +548,75 @@ public class ExportExcel { index++; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; index++; - //1、源IP和目的IP不能相同 - commentStr=commentStr+"▶"+String.format(msgProp.getProperty("are_the_same") - , msgProp.getProperty("clientip") - ,msgProp.getProperty("serverip"))+"\n"; - index++; - index++; - //2、源IP和目的IP IP类型和IP格式必须一致 - commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n"; - index++; - index++; - //3、IP Range 开始IP和结束IP必须在同一网段 - commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; - index++; - index++; - //4、IP Range 开始IP必须小于结束IP - commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_smaller")+"\n"; - index++; - index++; - //5、IPv4 Mask 掩码范围16-32 - commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; - index++; - index++; - //6、IPv6 Mask 掩码范围2-128 - commentStr=commentStr+"▶"+msgProp.getProperty("ipv6_subnet_tip")+","+msgProp.getProperty("ipv6_mask_range_tip")+"\n"; - index++; - index++; + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } + //2、源IP和目的IP不能相同 + if(((","+region.getConfigIpPortShow()+",").indexOf(",1,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1)){ + commentStr=commentStr+"▶"+String.format(msgProp.getProperty("are_the_same") + , msgProp.getProperty("clientip") + ,msgProp.getProperty("serverip"))+"\n"; + index++; + index++; + commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n"; + index++; + index++; + } + //4、IP Range 开始IP和结束IP必须在同一网段 + if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n"; + index++; + index++; + //5、IP Range 开始IP必须小于结束IP + commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_smaller")+"\n"; + index++; + index++; + } + + //6、IPv4 Mask 掩码范围16-32 + if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){ + if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n"; + index++; + index++; + } + if(((","+region.getConfigIpType()+",").indexOf(",6,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("ipv6_subnet_tip")+","+msgProp.getProperty("ipv6_mask_range_tip")+"\n"; + index++; + index++; + } + } } } + //4、协议 + String protocol=region.getConfigProtocol(); + if(region.getFunctionId().equals(5) ){ + //ip block tcp + if(service.getAction().equals(16) ){ + protocol="6"; + }else{ + protocol=region.getConfigProtocol(); + } + }else{ + protocol=region.getConfigProtocol(); + } if("client_port".equals(headerStr)){ if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){ commentStr=""; if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){ - commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n"; + commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.PORT_DEFAULT; + } index++; } if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"(Port/"+msgProp.getProperty("port_mask")+")"+"\n\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.PORT_MASK_DEFAULT; + } index++; } }else{ @@ -497,29 +632,65 @@ public class ExportExcel { index++; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; index++; - //1、源端口、目的端口格式必须一致 - commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; - index++; - index++; - //2、端口和端口掩码范围0-65535 + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } + //2、源端口、目的端口格式必须一致 + if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; + index++; + index++; + } + //3、端口和端口掩码范围0-65535 commentStr=commentStr+"▶"+msgProp.getProperty("port_mask_comment_tip")+"\n"; index++; index++; - //2、端口和端口掩码范围0-65535 - commentStr=commentStr+"▶"+msgProp.getProperty("protocol_and_port")+"\n"; - index++; - index++; + //protocol 非tcp 和 udp必须为o + //协议大于1个,excel不会隐藏,需提示协议和端口的关系 + if(protocol.split(",").length > 1){ + if(((","+protocol+",").indexOf(",6,")>-1) ||((","+protocol+",").indexOf(",17,")>-1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("port_comment_tip")+"\n"; + index++; + index++; + commentStr=commentStr+"▶"+msgProp.getProperty("protocol_and_port")+"\n"; + index++; + index++; + }else{ + commentStr=commentStr+"▶"+msgProp.getProperty("no_tc_udp_port_comment_tip")+"\n"; + index++; + index++; + } + }else{ + if(((","+protocol+",").indexOf(",6,")>-1) ||((","+protocol+",").indexOf(",17,")>-1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("port_comment_tip")+"\n"; + index++; + index++; + }else{ + commentStr=commentStr+"▶"+msgProp.getProperty("no_tc_udp_port_comment_tip")+"\n"; + index++; + index++; + } + } + } } if("server_port".equals(headerStr)){ if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){ commentStr=""; if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){ - commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n"; + commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.PORT_DEFAULT; + } index++; } if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){ commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"(Port/"+msgProp.getProperty("port_mask")+")"+"\n\n"; + if(StringUtil.isEmpty(defaultValue)){ + defaultValue=Constants.PORT_MASK_DEFAULT; + } index++; } }else{ @@ -535,15 +706,47 @@ public class ExportExcel { index++; commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; index++; - commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; - index++; - index++; + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } + //2、源端口、目的端口格式必须一致 + if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n"; + index++; + index++; + } + //3、端口和端口掩码范围0-65535 commentStr=commentStr+"▶"+msgProp.getProperty("port_mask_comment_tip")+"\n"; index++; index++; - commentStr=commentStr+"▶"+msgProp.getProperty("protocol_and_port")+"\n"; - index++; - index++; + //protocol 非tcp 和 udp必须为o + //协议大于1个,excel不会隐藏,需提示协议和端口的关系 + if(protocol.split(",").length > 1){ + if(((","+protocol+",").indexOf(",6,")>-1) ||((","+protocol+",").indexOf(",17,")>-1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("port_comment_tip")+"\n"; + index++; + index++; + commentStr=commentStr+"▶"+msgProp.getProperty("protocol_and_port")+"\n"; + index++; + index++; + }else{ + commentStr=commentStr+"▶"+msgProp.getProperty("no_tc_udp_port_comment_tip")+"\n"; + index++; + index++; + } + }else{ + if(((","+protocol+",").indexOf(",6,")>-1) ||((","+protocol+",").indexOf(",17,")>-1)){ + commentStr=commentStr+"▶"+msgProp.getProperty("port_comment_tip")+"\n"; + index++; + index++; + }else{ + commentStr=commentStr+"▶"+msgProp.getProperty("no_tc_udp_port_comment_tip")+"\n"; + index++; + index++; + } + } } } } @@ -567,6 +770,9 @@ public class ExportExcel { } } }*/ + if(StringUtil.isEmpty(defaultValue)){ + defaultValue="6"; + } }else{ commentStr=""; List protocol=DictUtils.getDictList("PROTOCOL"); @@ -583,6 +789,19 @@ public class ExportExcel { } } + if(StringUtil.isEmpty(defaultValue)){ + if((","+region.getConfigProtocol()+",").indexOf("0") > -1){ + defaultValue="0"; + }else if((","+region.getConfigProtocol()+",").indexOf("6") > -1){ + defaultValue="6"; + }else if((","+region.getConfigProtocol()+",").indexOf("17") > -1){ + defaultValue="17"; + }else if((","+region.getConfigProtocol()+",").indexOf("17") > -1){ + defaultValue=region.getConfigProtocol().split(",")[0]; + } + + + } } } }else{ @@ -606,6 +825,19 @@ public class ExportExcel { } } } + if(StringUtil.isEmpty(defaultValue)){ + if((","+region.getConfigProtocol()+",").indexOf("0") > -1){ + defaultValue="0"; + }else if((","+region.getConfigProtocol()+",").indexOf("6") > -1){ + defaultValue="6"; + }else if((","+region.getConfigProtocol()+",").indexOf("17") > -1){ + defaultValue="17"; + }else if((","+region.getConfigProtocol()+",").indexOf("17") > -1){ + defaultValue=region.getConfigProtocol().split(",")[0]; + } + + + } } } if(StringUtil.isEmpty(commentStr) @@ -615,6 +847,14 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } } } @@ -642,6 +882,9 @@ public class ExportExcel { headerStr=""; commentStr=""; } + if(StringUtil.isEmpty(defaultValue)){ + defaultValue="0"; + } } } if(StringUtil.isEmpty(commentStr)){ @@ -650,6 +893,14 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } } } @@ -666,7 +917,7 @@ public class ExportExcel { commentStr=commentStr+districtStr+"\n"; index++; } - + defaultValue=region.getConfigDistrict().split(",")[0]; } if(StringUtil.isEmpty(commentStr)){ headerStr=""; @@ -674,6 +925,17 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空说明 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + //2、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } } } } @@ -708,7 +970,7 @@ public class ExportExcel { } //expr type - if("expression_type".equals(headerStr)){ + /*if("expression_type".equals(headerStr)){ if(StringUtil.isEmpty(region.getConfigExprType()) ||(region.getConfigExprType().split(",").length==1)){ headerStr=""; @@ -727,6 +989,7 @@ public class ExportExcel { index++; } } + defaultValue=region.getConfigExprType().split(",")[0]; } } if(StringUtil.isEmpty(commentStr)){ @@ -735,8 +998,19 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //1、非空说明 + commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n"; + index++; + //2、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } } - } + }*/ //match method if("match_method".equals(headerStr)){ if(StringUtil.isEmpty(region.getConfigMatchMethod()) @@ -757,6 +1031,13 @@ public class ExportExcel { index++; } } + if(StringUtil.isEmpty(defaultValue)){ + if((","+region.getConfigMatchMethod()+",").indexOf("0") > -1){ + defaultValue="0"; + }else{ + defaultValue=region.getConfigMatchMethod().split(",")[0]; + } + } } if(StringUtil.isEmpty(commentStr)){ headerStr=""; @@ -764,6 +1045,14 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //2、默认值说明 + if(!StringUtil.isEmpty(defaultValue)){ + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; + index++; + } } } } @@ -810,6 +1099,12 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //2、默认值说明 + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":0\n"; + index++; } } if("is_case_insenstive".equals(headerStr)){ @@ -854,6 +1149,12 @@ public class ExportExcel { }else{ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; + index++; + commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n"; + index++; + //2、默认值说明 + commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":0\n"; + index++; } } }