diff --git a/src/main/java/com/nis/util/excel/ExportExcel.java b/src/main/java/com/nis/util/excel/ExportExcel.java index a5da629d2..51015b452 100644 --- a/src/main/java/com/nis/util/excel/ExportExcel.java +++ b/src/main/java/com/nis/util/excel/ExportExcel.java @@ -773,9 +773,9 @@ public class ExportExcel { /** *block 只有TCP不需要导入 * */ - headerStr=""; - commentStr=""; - /*List protocol=DictUtils.getDictList("PROTOCOL"); + /*headerStr=""; + commentStr="";*/ + List protocol=DictUtils.getDictList("PROTOCOL"); if(protocol !=null && protocol.size()>0){ for (SysDataDictionaryItem sysDataDictionaryItem : protocol) { if(sysDataDictionaryItem.getItemCode().equals("6")){ @@ -783,7 +783,7 @@ public class ExportExcel { index++; } } - }*/ + } if(StringUtil.isEmpty(defaultValue)){ defaultValue="6"; } @@ -819,10 +819,10 @@ public class ExportExcel { } } }else{ - if(StringUtil.isEmpty(region.getConfigProtocol())){ + /*if(StringUtil.isEmpty(region.getConfigProtocol())){ headerStr=""; commentStr=""; - }else{ + }else{*/ commentStr=""; List protocol=DictUtils.getDictList("PROTOCOL"); if(protocol !=null && protocol.size()>0){ @@ -856,13 +856,13 @@ public class ExportExcel { } - } + /*}*/ } - if(StringUtil.isEmpty(commentStr) + /*if(StringUtil.isEmpty(commentStr) ||(region.getConfigProtocol().split(",").length==1)){ headerStr=""; commentStr=""; - }else{ + }else{*/ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; index++; @@ -873,16 +873,16 @@ public class ExportExcel { commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; index++; } - } + /*}*/ } //Direction if("direction".equals(headerStr)){ - if(StringUtil.isEmpty(region.getConfigDirection()) + /*if(StringUtil.isEmpty(region.getConfigDirection()) ||(region.getConfigDirection().split(",").length==1)){ headerStr=""; commentStr=""; - }else{ + }else{*/ commentStr=""; List direction=DictUtils.getDictList("DIRECTION"); if(direction !=null && direction.size()>0){ @@ -904,11 +904,11 @@ public class ExportExcel { defaultValue="0"; } } - } - if(StringUtil.isEmpty(commentStr)){ + /*}*/ + /*if(StringUtil.isEmpty(commentStr)){ headerStr=""; commentStr=""; - }else{ + }else{*/ commentStr=msgProp.getProperty("select")+":\n"+commentStr; index++; index++; @@ -919,7 +919,7 @@ public class ExportExcel { commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; index++; } - } + /*}*/ } //字符串或摘要字符串 @@ -927,7 +927,7 @@ public class ExportExcel { if(region.getRegionType().equals(3)){ if("district".equals(headerStr)){ if(StringUtil.isEmpty(region.getConfigDistrict()) - ||(region.getConfigDistrict().split(",").length==1)){ + /*||(region.getConfigDistrict().split(",").length==1)*/){ headerStr=""; commentStr=""; }else{ @@ -1032,7 +1032,7 @@ public class ExportExcel { //match method if("match_method".equals(headerStr)){ if(StringUtil.isEmpty(region.getConfigMatchMethod()) - ||(region.getConfigMatchMethod().split(",").length==1)){ + /*||(region.getConfigMatchMethod().split(",").length==1)*/){ headerStr=""; commentStr=""; }else{ @@ -1111,7 +1111,7 @@ public class ExportExcel { } } - if(StringUtil.isEmpty(commentStr) || (!StringUtil.isEmpty(list) && list.size()==1)){ + if(StringUtil.isEmpty(commentStr) /*|| (!StringUtil.isEmpty(list) && list.size()==1)*/){ headerStr=""; commentStr=""; }else{ @@ -1161,7 +1161,7 @@ public class ExportExcel { } } - if(StringUtil.isEmpty(commentStr) || (!StringUtil.isEmpty(list) && list.size()==1)){ + if(StringUtil.isEmpty(commentStr) /*|| (!StringUtil.isEmpty(list) && list.size()==1)*/){ headerStr=""; commentStr=""; }else{ diff --git a/src/main/java/com/nis/util/excel/ImportBigExcel.java b/src/main/java/com/nis/util/excel/ImportBigExcel.java index 046c144bb..801229e45 100644 --- a/src/main/java/com/nis/util/excel/ImportBigExcel.java +++ b/src/main/java/com/nis/util/excel/ImportBigExcel.java @@ -244,7 +244,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ continue; } } - if(!directionShow) { + /*if(!directionShow) { if(f.getName().equalsIgnoreCase("direction")) { continue; } @@ -273,7 +273,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ if(f.getName().equalsIgnoreCase("district")) { continue; } - } + }*/ ExcelField ef = f.getAnnotation(ExcelField.class); if (ef != null && (ef.type()==0 || ef.type()==2)){ if (groups!=null && groups.length>0){ @@ -323,7 +323,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ continue; } } - if(!directionShow) { + /*if(!directionShow) { if(m.getName().equalsIgnoreCase("get"+"direction")||m.getName().equalsIgnoreCase("set"+"direction")) { continue; } @@ -352,7 +352,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ if(m.getName().equalsIgnoreCase("get"+"district")||m.getName().equalsIgnoreCase("set"+"district")) { continue; } - } + }*/ ExcelField ef = m.getAnnotation(ExcelField.class); if (ef != null && (ef.type()==0 || ef.type()==2)){ if (groups!=null && groups.length>0){ @@ -451,29 +451,29 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ //log.debug("Import value type: ["+i+","+column+"] " + valType); try { if (valType == String.class){ - String s = String.valueOf(val.toString()); + String s = String.valueOf(val.toString().trim()); //0.0.0.0表示任意IP的含义 if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){ val = StringUtils.substringBefore(s, ".0"); }else{ - val = String.valueOf(val.toString()); + val = String.valueOf(val.toString().trim()); } }else if (valType == Integer.class){ - val = Double.valueOf(val.toString()).intValue(); + val = Double.valueOf(val.toString().trim()).intValue(); }else if (valType == Long.class){ - val = Double.valueOf(val.toString()).longValue(); + val = Double.valueOf(val.toString().trim()).longValue(); }else if (valType == Double.class){ - val = Double.valueOf(val.toString()); + val = Double.valueOf(val.toString().trim()); }else if (valType == Float.class){ - val = Float.valueOf(val.toString()); + val = Float.valueOf(val.toString().trim()); }else if (valType == Date.class){ val = DateUtil.getJavaDate((Double)val); }else{ if (ef.fieldType() != Class.class){ - val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString()); + val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString().trim()); }else{ val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(), - "fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString()); + "fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString().trim()); } } } catch (Exception ex) { diff --git a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java index 96de8e21a..e27076410 100644 --- a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java +++ b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java @@ -609,6 +609,17 @@ public class CheckIpFormatThread implements Callable{ } } // TODO 判断Protocol的值 + if(baseIpCfg.getProtocol()==null) { + if(protocol.indexOf("0")>-1) { + baseIpCfg.setProtocol(0); + }else if(protocol.indexOf("6")>-1) { + baseIpCfg.setProtocol(6); + }else if(protocol.indexOf("17")>-1) { + baseIpCfg.setProtocol(17); + }else if(StringUtils.isNotBlank(protocol)) { + baseIpCfg.setProtocol(Integer.parseInt(protocol.split(",")[0])); + } + } boolean validProtocol = this.validProtocol(errInfo, baseIpCfg.getProtocol(), protocol); // 验证protocol与port是否符合逻辑 if (validProtocol && validPort) { @@ -624,7 +635,13 @@ public class CheckIpFormatThread implements Callable{ } else { baseIpCfg.setDirection(baseIpCfg.getDirection()); } - + if(baseIpCfg.getDirection()==null) { + if(direction.indexOf("0")>-1) { + baseIpCfg.setDirection(0); + }else if(StringUtils.isNotBlank(direction)) { + baseIpCfg.setDirection(Integer.parseInt(direction.split(",")[0])); + } + } // TODO 判断Direction的值 this.validDirection(errInfo, baseIpCfg.getDirection(), direction); } @@ -706,10 +723,10 @@ public class CheckIpFormatThread implements Callable{ */ public boolean validProtocol(StringBuffer errInfo, Integer protocol, String protocolPattern) throws ServiceException { - if (protocol == null) { + /*if (protocol == null) { errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("protocol")) + ";"); return false; - } + }*/ boolean has = false; for (String p : protocolPattern.split(",")) { if (p.equals(protocol.toString())) {