导出注解行数根据内容动态设置

This commit is contained in:
duandongmei
2018-10-22 09:15:30 +08:00
parent b5f199acbc
commit 600a41be37
6 changed files with 244 additions and 67 deletions

View File

@@ -194,6 +194,8 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
public static List<BaseStringCfg> replaceBaseKeyList(List<BaseStringCfg> list){ public static List<BaseStringCfg> replaceBaseKeyList(List<BaseStringCfg> list){
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
BaseStringCfg base=(BaseStringCfg)list.get(i); BaseStringCfg base=(BaseStringCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," ")); base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
} }
return list; return list;

View File

@@ -178,6 +178,8 @@ public class ComplexkeywordCfg extends BaseCfg<ComplexkeywordCfg>{
public static List<ComplexkeywordCfg> replaceComplexKeyList(List<ComplexkeywordCfg> list){ public static List<ComplexkeywordCfg> replaceComplexKeyList(List<ComplexkeywordCfg> list){
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
ComplexkeywordCfg base=(ComplexkeywordCfg)list.get(i); ComplexkeywordCfg base=(ComplexkeywordCfg)list.get(i);
base.setIsHex(base.getIsHexbin());
base.setIsCaseInsenstive(base.getIsHexbin());
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," ")); base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
} }
return list; return list;

View File

@@ -47,6 +47,7 @@ import com.nis.domain.FunctionServiceDict;
import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.configuration.DnsResStrategy; import com.nis.domain.configuration.DnsResStrategy;
import com.nis.util.Constants;
import com.nis.util.DictUtils; import com.nis.util.DictUtils;
import com.nis.util.Encodes; import com.nis.util.Encodes;
import com.nis.util.Reflections; import com.nis.util.Reflections;
@@ -139,7 +140,8 @@ public class ExportExcel {
} }
} }
public String[] validRegionFieldAndSetComment(String headerStr,String commentStr,FunctionRegionDict region,FunctionServiceDict service,Properties msgProp){ public String[] validRegionFieldAndSetComment(String headerStr,String commentStr,FunctionRegionDict region,FunctionServiceDict service,Properties msgProp){
String[] titleInfo=new String[2]; int index=0;
String[] titleInfo=new String[3];
//ratelimit //ratelimit
if("ratelimit".equals(headerStr)){ if("ratelimit".equals(headerStr)){
commentStr=""; commentStr="";
@@ -147,15 +149,20 @@ public class ExportExcel {
if(ratelimit !=null && ratelimit.size()>0){ if(ratelimit !=null && ratelimit.size()>0){
for (SysDataDictionaryItem sysDataDictionaryItem : ratelimit) { for (SysDataDictionaryItem sysDataDictionaryItem : ratelimit) {
if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+"\n";
index++;
}else{ }else{
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){ if(StringUtil.isEmpty(commentStr)){
headerStr=""; headerStr="";
commentStr=""; commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
} }
} }
//replace_zone //replace_zone
@@ -166,14 +173,19 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : interceptReplaceZone) { for (SysDataDictionaryItem sysDataDictionaryItem : interceptReplaceZone) {
if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n";
index++;
}else{ }else{
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){ if(StringUtil.isEmpty(commentStr)){
headerStr=""; headerStr="";
commentStr=""; commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
} }
} }
@@ -190,12 +202,16 @@ public class ExportExcel {
}else{ }else{
for (DnsResStrategy dnsResStrategy : resStrategys) { for (DnsResStrategy dnsResStrategy : resStrategys) {
commentStr=commentStr+dnsResStrategy.getCfgId()+":"+dnsResStrategy.getCfgDesc()+"\n"; commentStr=commentStr+dnsResStrategy.getCfgId()+":"+dnsResStrategy.getCfgDesc()+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){ if(StringUtil.isEmpty(commentStr)){
headerStr=""; headerStr="";
commentStr=""; commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
} }
} }
@@ -217,88 +233,178 @@ public class ExportExcel {
commentStr=""; commentStr="";
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+"0.0.0.0"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"0.0.0.0-1"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range")+""+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"0.0.0.0/16"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_mask")+""+"\n";
index++;
} }
} }
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+"::"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"::-::"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range")+""+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"::/128"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_mask")+""+"\n";
index++;
} }
} }
}else{ }else{
headerStr=""; headerStr="";
commentStr=""; commentStr="";
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("example")+":\n"+commentStr;
index++;
/**TODO
规则:
index++;
1、源ip和目的ip不能相等
index++;
2、源ip和目的ip格式必须一致
index++;
3、IPv4 Range 必须是C段IP
index++;
4、IPv4 Mask 掩码范围16-32
index++;
5、IPv6 Mask 掩码范围2-128
index++;
*/
}
} }
if("server_ip".equals(headerStr)){ if("server_ip".equals(headerStr)){
if((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1){
commentStr=""; commentStr="";
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+"0.0.0.0"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"IPv4"+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"0.0.0.0-1"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv4_range")+""+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"0.0.0.0/16"+"\n"; commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv4_mask")+""+"\n";
index++;
} }
} }
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){ if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
commentStr=commentStr+"::"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"IPv6"+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"::-::"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+""+msgProp.getProperty("ipv6_range")+""+"\n";
index++;
} }
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"::/128"+"\n"; commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+""+msgProp.getProperty("ipv6_mask")+""+"\n";
index++;
} }
} }
}else{ }else{
headerStr=""; headerStr="";
commentStr=""; commentStr="";
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("example")+":\n"+commentStr;
index++;
/**TODO
规则:
index++;
1、源ip和目的ip不能相等
index++;
2、源ip和目的ip格式必须一致
index++;
3、IPv4 Range 必须是C段IP
index++;
4、IPv4 Mask 掩码范围16-32
index++;
5、IPv6 Mask 掩码范围2-128
index++;
*/
}
} }
if("client_port".equals(headerStr)){ if("client_port".equals(headerStr)){
if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){ if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){
commentStr=""; commentStr="";
if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"0["+msgProp.getProperty("val_src_port")+"]"+"\n"; commentStr=commentStr+Constants.PORT_DEFAULT+"Port)"+"\n";
index++;
} }
if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"0/65535["+msgProp.getProperty("val_src_port_mask")+"]"+"\n"; commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n";
index++;
} }
}else{ }else{
headerStr=""; headerStr="";
commentStr=""; commentStr="";
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("example")+":\n"+commentStr;
index++;
/**TODO
规则:
index++;
1、源端口和目的端口格式必须一致
index++;
2、端口范围0-65535
index++;
3、端口掩码范围0-65535
index++;
4、非TCP、UDP、ALL协议端口必须为0
index++;
*/
}
} }
if("server_port".equals(headerStr)){ if("server_port".equals(headerStr)){
if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){ if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){
commentStr=""; commentStr="";
if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
commentStr=commentStr+"0["+msgProp.getProperty("val_src_port")+"]"+"\n"; commentStr=commentStr+Constants.PORT_DEFAULT+"Port)"+"\n";
index++;
} }
if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){ if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
commentStr=commentStr+"0/65535["+msgProp.getProperty("val_src_port_mask")+"]"+"\n"; commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"Port/"+msgProp.getProperty("port_mask")+""+"\n";
index++;
} }
}else{ }else{
headerStr=""; headerStr="";
commentStr=""; commentStr="";
} }
/**TODO
规则:
index++;
1、源端口和目的端口格式必须一致
index++;
2、端口范围0-65535
index++;
3、端口掩码范围0-65535
index++;
4、非TCP、UDP、ALL协议端口必须为0
index++;
*/
} }
} }
//导入的Protocol //导入的Protocol
@@ -311,7 +417,8 @@ public class ExportExcel {
if(protocol !=null && protocol.size()>0){ if(protocol !=null && protocol.size()>0){
for (SysDataDictionaryItem sysDataDictionaryItem : protocol) { for (SysDataDictionaryItem sysDataDictionaryItem : protocol) {
if(sysDataDictionaryItem.getItemCode().equals(6)){ if(sysDataDictionaryItem.getItemCode().equals(6)){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
} }
} }
} }
@@ -322,9 +429,11 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : protocol) { for (SysDataDictionaryItem sysDataDictionaryItem : protocol) {
if((","+region.getConfigProtocol()+",").indexOf(","+sysDataDictionaryItem.getItemCode()+",") >-1){ if((","+region.getConfigProtocol()+",").indexOf(","+sysDataDictionaryItem.getItemCode()+",") >-1){
if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
}else{ }else{
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+""+"\n";
index++;
} }
} }
@@ -342,20 +451,25 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : protocol) { for (SysDataDictionaryItem sysDataDictionaryItem : protocol) {
if((","+region.getConfigProtocol()+",").indexOf(","+sysDataDictionaryItem.getItemCode()+",") >-1){ if((","+region.getConfigProtocol()+",").indexOf(","+sysDataDictionaryItem.getItemCode()+",") >-1){
if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ if(StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
}else{ }else{
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+""+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
//Direction //Direction
@@ -370,9 +484,11 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : direction) { for (SysDataDictionaryItem sysDataDictionaryItem : direction) {
if(((","+region.getConfigDirection()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1) if(((","+region.getConfigDirection()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1)
&& StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ && StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
}else if((","+region.getConfigDirection()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){ }else if((","+region.getConfigDirection()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+""+"\n";
index++;
} }
} }
if(StringUtil.isEmpty(commentStr)){ if(StringUtil.isEmpty(commentStr)){
@@ -381,6 +497,13 @@ public class ExportExcel {
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
//字符串或摘要字符串 //字符串或摘要字符串
@@ -392,9 +515,16 @@ public class ExportExcel {
commentStr=""; commentStr="";
}else{ }else{
commentStr=region.getConfigDistrict(); commentStr=region.getConfigDistrict();
index++;
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
//expr type //expr type
if("expression_type".equals(headerStr)){ if("expression_type".equals(headerStr)){
@@ -408,17 +538,22 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : exprType) { for (SysDataDictionaryItem sysDataDictionaryItem : exprType) {
if(((","+region.getConfigExprType()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1) if(((","+region.getConfigExprType()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1)
&& StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ && StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
}else if((","+region.getConfigExprType()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){ }else if((","+region.getConfigExprType()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+""+"\n";
index++;
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
//match method //match method
if("match_method".equals(headerStr)){ if("match_method".equals(headerStr)){
@@ -432,15 +567,20 @@ public class ExportExcel {
for (SysDataDictionaryItem sysDataDictionaryItem : matchMethod) { for (SysDataDictionaryItem sysDataDictionaryItem : matchMethod) {
if(((","+region.getConfigMatchMethod()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1) if(((","+region.getConfigMatchMethod()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1)
&& StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){ && StringUtil.isEmpty(msgProp.getProperty(sysDataDictionaryItem.getItemValue()))){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
}else if((","+region.getConfigMatchMethod()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){ }else if((","+region.getConfigMatchMethod()+",").indexOf(sysDataDictionaryItem.getItemCode()) >-1){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue())+""+"\n";
index++;
} }
} }
if(StringUtil.isEmpty(commentStr)){ }
headerStr=""; if(StringUtil.isEmpty(commentStr)){
commentStr=""; headerStr="";
} commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
} }
} }
} }
@@ -456,24 +596,29 @@ public class ExportExcel {
if(((","+region.getConfigHex()+",").indexOf(",1,") >-1)){ if(((","+region.getConfigHex()+",").indexOf(",1,") >-1)){
for (SysDataDictionaryItem sysDataDictionaryItem : isHex) { for (SysDataDictionaryItem sysDataDictionaryItem : isHex) {
if(sysDataDictionaryItem.getItemCode().equals("1")){ if(sysDataDictionaryItem.getItemCode().equals("1")){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
} }
} }
} }
if(!((","+region.getConfigHex()+",").indexOf(",1,") >-1)){ if(!((","+region.getConfigHex()+",").indexOf(",1,") >-1)){
for (SysDataDictionaryItem sysDataDictionaryItem : isHex) { for (SysDataDictionaryItem sysDataDictionaryItem : isHex) {
if(sysDataDictionaryItem.getItemCode().equals("0")){ if(sysDataDictionaryItem.getItemCode().equals("0")){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
if("is_case_insenstive".equals(headerStr)){ if("is_case_insenstive".equals(headerStr)){
if(StringUtil.isEmpty(region.getConfigHex())){ if(StringUtil.isEmpty(region.getConfigHex())){
@@ -486,28 +631,34 @@ public class ExportExcel {
if(((","+region.getConfigHex()+",").indexOf(",2,") >-1)){ if(((","+region.getConfigHex()+",").indexOf(",2,") >-1)){
for (SysDataDictionaryItem sysDataDictionaryItem : isCaseSenstive) { for (SysDataDictionaryItem sysDataDictionaryItem : isCaseSenstive) {
if(sysDataDictionaryItem.getItemCode().equals("1")){ if(sysDataDictionaryItem.getItemCode().equals("1")){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
} }
} }
} }
if(!((","+region.getConfigHex()+",").indexOf(",2,") >-1)){ if(!((","+region.getConfigHex()+",").indexOf(",2,") >-1)){
for (SysDataDictionaryItem sysDataDictionaryItem : isCaseSenstive) { for (SysDataDictionaryItem sysDataDictionaryItem : isCaseSenstive) {
if(sysDataDictionaryItem.getItemCode().equals("0")){ if(sysDataDictionaryItem.getItemCode().equals("0")){
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+":"+sysDataDictionaryItem.getItemValue()+"\n"; commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+sysDataDictionaryItem.getItemValue()+""+"\n";
index++;
} }
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}
} }
} }
if(StringUtil.isEmpty(commentStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
} }
} }
titleInfo[0]=headerStr; titleInfo[0]=headerStr;
titleInfo[1]=commentStr; titleInfo[1]=commentStr;
titleInfo[2]=index+"";
return titleInfo; return titleInfo;
} }
/** /**
@@ -635,7 +786,7 @@ public class ExportExcel {
headerList.add(titleStr); headerList.add(titleStr);
commentList.add(commentStr); commentList.add(commentStr);
} }
initialize(title, headerList,commentList); initialize(title, headerList,commentList,null);
} }
/** /**
* 构造函数 * 构造函数
@@ -714,9 +865,11 @@ public class ExportExcel {
// Initialize // Initialize
List<String> headerList = Lists.newArrayList(); List<String> headerList = Lists.newArrayList();
List<String> commentList = Lists.newArrayList(); List<String> commentList = Lists.newArrayList();
List<Integer> commentRowList = Lists.newArrayList();
for (Object[] os : annotationList){ for (Object[] os : annotationList){
String titleStr = ((ExcelField)os[0]).title(); String titleStr = ((ExcelField)os[0]).title();
String commentStr = ((ExcelField)os[0]).comment(); String commentStr = ((ExcelField)os[0]).comment();
Integer commentRow = 0;
// 如果是导出,则去掉注释 // 如果是导出,则去掉注释
if (type==1){ if (type==1){
@@ -726,14 +879,16 @@ public class ExportExcel {
String[] titleInfo=validRegionFieldAndSetComment(titleStr,commentStr,region,service,msgProp); String[] titleInfo=validRegionFieldAndSetComment(titleStr,commentStr,region,service,msgProp);
titleStr=titleInfo[0]; titleStr=titleInfo[0];
commentStr=titleInfo[1]; commentStr=titleInfo[1];
commentRow=StringUtil.isEmpty(titleInfo[2]) ? 0:Integer.parseInt(titleInfo[2]);
} }
if(!StringUtil.isEmpty(titleStr)){ if(!StringUtil.isEmpty(titleStr)){
headerList.add(msgProp.getProperty(titleStr)==null?titleStr:msgProp.getProperty(titleStr)); headerList.add(msgProp.getProperty(titleStr)==null?titleStr:msgProp.getProperty(titleStr));
commentList.add(commentStr); commentList.add(commentStr);
commentRowList.add(commentRow);
} }
} }
initialize(title, headerList,commentList); initialize(title, headerList,commentList,commentRowList);
} }
/** /**
* 构造函数 * 构造函数
@@ -825,7 +980,7 @@ public class ExportExcel {
} }
} }
initialize(title, headerList,commentList); initialize(title, headerList,commentList,null);
} }
/** /**
* 构造函数 * 构造函数
@@ -937,7 +1092,7 @@ public class ExportExcel {
headerList.add(msgProp.getProperty(titleStr)==null?titleStr:msgProp.getProperty(titleStr)); headerList.add(msgProp.getProperty(titleStr)==null?titleStr:msgProp.getProperty(titleStr));
commentList.add(commentStr); commentList.add(commentStr);
} }
initialize(title, headerList,commentList); initialize(title, headerList,commentList,null);
} }
/** /**
@@ -946,7 +1101,7 @@ public class ExportExcel {
* @param headers 表头数组 * @param headers 表头数组
*/ */
public ExportExcel(String title, String[] headers, String[] comments) { public ExportExcel(String title, String[] headers, String[] comments) {
initialize(title, Lists.newArrayList(headers), Lists.newArrayList(comments)); initialize(title, Lists.newArrayList(headers), Lists.newArrayList(comments),null);
} }
/** /**
@@ -955,8 +1110,8 @@ public class ExportExcel {
* @param headerList 表头列表 * @param headerList 表头列表
* @param commentList 注释列表 * @param commentList 注释列表
*/ */
public ExportExcel(String title, List<String> headerList, List<String> commentList) { public ExportExcel(String title, List<String> headerList, List<String> commentList,List<Integer> commentRowList) {
initialize(title, headerList,commentList); initialize(title, headerList,commentList,commentRowList);
} }
@@ -965,7 +1120,7 @@ public class ExportExcel {
* @param title 表格标题,传“空值”,表示无标题 * @param title 表格标题,传“空值”,表示无标题
* @param headerList 表头列表 * @param headerList 表头列表
*/ */
private void initialize(String title, List<String> headerList, List<String> commentList) { private void initialize(String title, List<String> headerList, List<String> commentList,List<Integer> commentRowList) {
this.wb = new SXSSFWorkbook(500); this.wb = new SXSSFWorkbook(500);
this.sheet = wb.createSheet("Export"); this.sheet = wb.createSheet("Export");
this.styles = createStyles(wb); this.styles = createStyles(wb);
@@ -989,10 +1144,16 @@ public class ExportExcel {
Cell cell = headerRow.createCell(i); Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header")); cell.setCellStyle(styles.get("header"));
String commentStr = commentList.get(i); String commentStr = commentList.get(i);
Integer commentRow =3;
if(!StringUtil.isEmpty(commentRowList)
&& !StringUtil.isEmpty(commentRowList.get(i))
&& commentRowList.get(i) > 0){
commentRow=commentRowList.get(i);
}
if (!StringUtil.isEmpty(commentStr)){ if (!StringUtil.isEmpty(commentStr)){
cell.setCellValue(headerList.get(i)); cell.setCellValue(headerList.get(i));
Comment comment = this.sheet.createDrawingPatriarch().createCellComment( Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
new XSSFClientAnchor(0, 0, 0, 0, (short) i, 0, (short) i+4, i+5)); new XSSFClientAnchor(0, 0, 0, 0, (short) i, 0, (short) i+3, commentRow));
comment.setString(new XSSFRichTextString(commentStr)); comment.setString(new XSSFRichTextString(commentStr));
cell.setCellComment(comment); cell.setCellComment(comment);
}else{ }else{

View File

@@ -1267,4 +1267,8 @@ alternative_values= Alternative values can be %s
certificate_error=Wrong format of public key file and private key file certificate_error=Wrong format of public key file and private key file
public_file_error=Wrong format of public key file public_file_error=Wrong format of public key file
private_file_error=Wrong format of private key file private_file_error=Wrong format of private key file
keyframe_pic_required=No keyframe pictures have been selected. keyframe_pic_required=No keyframe pictures have been selected.
ipv4_range=IPv4 Range
ipv4_subnet=IPv4/Subnet mask
ipv6_range=IPv6 Range
ipv6_subnet=IPv6/Subnet mask

View File

@@ -1287,4 +1287,8 @@ alternative_values= Alternative values can be %s
certificate_error=Wrong format of public key file and private key file certificate_error=Wrong format of public key file and private key file
public_file_error=Wrong format of public key file public_file_error=Wrong format of public key file
private_file_error=Wrong format of private key file private_file_error=Wrong format of private key file
keyframe_pic_required=No keyframe pictures have been selected. keyframe_pic_required=No keyframe pictures have been selected.
ipv4_range=IPv4 Range
ipv4_subnet=IPv4/Subnet mask
ipv6_range=IPv6 Range
ipv6_subnet=IPv6/Subnet mask

View File

@@ -1262,4 +1262,8 @@ certificate_error=\u516C\u94A5\u3001\u79C1\u94A5\u6587\u4EF6\u683C\u5F0F\u9519\u
public_file_error=\u516C\u94A5\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF public_file_error=\u516C\u94A5\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF
keyframe_pic_required=\u5C1A\u672A\u9009\u62E9\u5173\u952E\u5E27\u56FE\u7247 keyframe_pic_required=\u5C1A\u672A\u9009\u62E9\u5173\u952E\u5E27\u56FE\u7247
private_file_error=\u79C1\u94A5\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF private_file_error=\u79C1\u94A5\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF
keyframe_pic_required=\u5C1A\u672A\u9009\u62E9\u5173\u952E\u5E27\u56FE\u7247 keyframe_pic_required=\u5C1A\u672A\u9009\u62E9\u5173\u952E\u5E27\u56FE\u7247
ipv4_range=IPv4 Range
ipv4_subnet=IPv4/Subnet mask
ipv6_range=IPv6 Range
ipv6_subnet=IPv6/Subnet mask