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 b6cc50d21..7aae6eac0 100644 --- a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java +++ b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java @@ -29,6 +29,7 @@ import com.nis.domain.specific.ConfigGroupInfo; //import com.nis.util.AsnCacheUtils; import com.nis.util.Constants; import com.nis.util.DictUtils; +import com.nis.util.StringUtil; public class CheckIpFormatThread implements Callable{ private Logger logger=Logger.getLogger(CheckIpFormatThread.class); @@ -269,11 +270,7 @@ public class CheckIpFormatThread implements Callable{ if (regionDict.getFunctionId().equals(600)) {//asn //组织的非空和长度校验 String organization=baseIpCfg.getOrganization(); - if(StringUtils.isBlank(organization)) { - errInfo.append( - String.format(prop.getProperty("can_not_null"), prop.getProperty("organization","Organization")) - + ";"); - }else { + if(!StringUtils.isBlank(organization)) { if(organization.length() > 1024){ errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";"); }else { @@ -282,7 +279,6 @@ public class CheckIpFormatThread implements Callable{ } baseIpCfg.setOrganization(organization.trim().toUpperCase()); } - } //国家的非空和长度校验 String country=baseIpCfg.getCountry(); @@ -293,18 +289,14 @@ public class CheckIpFormatThread implements Callable{ baseIpCfg.setCountry(country.trim().toUpperCase()); } //详情可以为空 - /*String detail=baseIpCfg.getDetail(); - if(StringUtils.isBlank(detail)) { - errInfo.append( - String.format(prop.getProperty("can_not_null"), prop.getProperty("detail")) - + ";"); - }else { + String detail=baseIpCfg.getDetail(); + if(!StringUtils.isBlank(detail)) { if(detail.length() > 1024||detail.length()<4){ errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";"); }else { baseIpCfg.setDetail(detail.trim()); } - }*/ + } //asn id 校验 String userRegion1 = baseIpCfg.getUserRegion1(); if(StringUtils.isBlank(userRegion1)) { @@ -319,21 +311,25 @@ public class CheckIpFormatThread implements Callable{ String.format(prop.getProperty("must_between"),"1","4294967295" ) + ";"); }else { + if(StringUtil.isEmpty(baseIpCfg.getOrganization())){ + baseIpCfg.setOrganization(asnNo.toString()); + baseIpCfg.setCfgDesc(asnNo.toString()); + } if(asnNos!=null) { //数据库中是否已经存在 AsnGroupInfo asnGroupInfo=asnNos.get(1)==null?null:asnNos.get(1).get(asnNo); if(asnGroupInfo==null) { synchronized (Constants.IMPORT_LOCK) { - if(StringUtils.isNotBlank(baseIpCfg.getOrganization())&&StringUtils.isNotBlank(baseIpCfg.getCountry())) { + if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) { AsnGroupInfo groupInfo=new AsnGroupInfo(); groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase()); - groupInfo.setCountry(baseIpCfg.getCountry()); - groupInfo.setDetail(baseIpCfg.getDetail().trim()); + groupInfo.setCountry(StringUtil.isEmpty(baseIpCfg.getCountry()) ? "":baseIpCfg.getCountry().trim().toUpperCase()); + groupInfo.setDetail(StringUtil.isEmpty(baseIpCfg.getDetail()) ? "":baseIpCfg.getDetail().trim().toUpperCase()); groupInfo.setIsUsed(0); groupInfo.setIsValid(0); groupInfo.setAsnId(asnNo); if(asnNos.get(2).containsKey(asnNo)) { - if(!asnNos.get(2).get(asnNo).getOrganization().equals(baseIpCfg.getOrganization().trim().toUpperCase())) { + if(!asnNos.get(2).get(asnNo).getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) { //一个asn号不能被两个组织拥有 logger.error("ASN "+asnNo+" Found two Organization "+asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()); errInfo.append(asnNos.get(2).get(asnNo).getOrganization()+" "+baseIpCfg.getOrganization().trim().toUpperCase()+" "+prop.getProperty("asn_no")+" "+asnNo+" "+prop.getProperty("repeat") @@ -357,14 +353,6 @@ public class CheckIpFormatThread implements Callable{ } } - }else { - if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) { - logger.error("ASN "+asnNo+" Organization is Null"); - } - /*if(StringUtils.isNotBlank(baseIpCfg.getCountry())) { - logger.error("ASN "+asnNo+" Country is Null"); - }*/ - } } @@ -372,12 +360,7 @@ public class CheckIpFormatThread implements Callable{ if(!asnGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) { errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch")); } - /*if(!asnGroupInfo.getCountry().equalsIgnoreCase(baseIpCfg.getCountry().trim())) { - errInfo.append(prop.getProperty("country","Country")+" "+prop.getProperty("mismatch","Mismatch")); - } - if(!asnGroupInfo.getDetail().equalsIgnoreCase(baseIpCfg.getDetail().trim())) { - errInfo.append(prop.getProperty("detail","Detail")+" "+prop.getProperty("mismatch","Mismatch")); - }*/ + if(StringUtils.isBlank(errInfo.toString())) { //已下发过的asn no if(asnGroupInfo.getIsValid() ==1){ @@ -386,6 +369,9 @@ public class CheckIpFormatThread implements Callable{ asnNos.get(1).put(asnNo,asnGroupInfo); asnGroupInfo.setIsValid(0); asnGroupInfo.setIssuedIPs(0l); + asnGroupInfo.setOrganization(organization); + asnGroupInfo.setCountry(baseIpCfg.getCountry()); + asnGroupInfo.setDetail(baseIpCfg.getDetail()); asnNos.get(2).put(asnNo,asnGroupInfo); } }