diff --git a/src/main/java/com/nis/domain/configuration/AppFeatureIndex.java b/src/main/java/com/nis/domain/configuration/AppFeatureIndex.java index 45ef53501..897304222 100644 --- a/src/main/java/com/nis/domain/configuration/AppFeatureIndex.java +++ b/src/main/java/com/nis/domain/configuration/AppFeatureIndex.java @@ -133,5 +133,23 @@ public class AppFeatureIndex extends BaseCfg { public void setNumCfgList(List numCfgList) { this.numCfgList = numCfgList; } + public Integer getExprType() { + return exprType; + } + public void setExprType(Integer exprType) { + this.exprType = exprType; + } + public Integer getMatchMethod() { + return matchMethod; + } + public void setMatchMethod(Integer matchMethod) { + this.matchMethod = matchMethod; + } + public Integer getIsHexbin() { + return isHexbin; + } + public void setIsHexbin(Integer isHexbin) { + this.isHexbin = isHexbin; + } } diff --git a/src/main/java/com/nis/util/excel/ExportExcel.java b/src/main/java/com/nis/util/excel/ExportExcel.java index ad4edaaff..4976e264c 100644 --- a/src/main/java/com/nis/util/excel/ExportExcel.java +++ b/src/main/java/com/nis/util/excel/ExportExcel.java @@ -1038,7 +1038,12 @@ public class ExportExcel { } // APP Payload if(region.getFunctionId().equals(563)) { - commentStr=commentStr+"▶"+"L3_header:"+msgProp.getProperty("need_input")+"'headerType'"+"\n"; + commentStr=commentStr+"▶"+"L3_header:"+msgProp.getProperty("need_input")+"'headerType', "+ + msgProp.getProperty("no_need_input")+"'"+ + msgProp.getProperty("key_word")+"'、'"+ + msgProp.getProperty("match_method")+"'、'"+ + msgProp.getProperty("is_hex")+"'、'"+ + msgProp.getProperty("is_case_insenstive")+"'"+"\n"; index++; } } diff --git a/src/main/java/com/nis/util/excel/thread/CheckAppFeatureComplexStringFormatThread.java b/src/main/java/com/nis/util/excel/thread/CheckAppFeatureComplexStringFormatThread.java index 106d24e7e..8d5080f0e 100644 --- a/src/main/java/com/nis/util/excel/thread/CheckAppFeatureComplexStringFormatThread.java +++ b/src/main/java/com/nis/util/excel/thread/CheckAppFeatureComplexStringFormatThread.java @@ -92,21 +92,63 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable 128) { errInfo.append(prop.getProperty("config_describe")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":128") + ";"); } - if(baseStringCfg.getCfgKeywords().length() < 4 || baseStringCfg.getCfgKeywords().length() > 1024){ - errInfo.append(prop.getProperty("key_word")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";"); - } if (regionDict.getRegionType().equals(3)) { String keyword = baseStringCfg.getCfgKeywords(); String district = baseStringCfg.getDistrict(); - if (StringUtils.isBlank(keyword)) { - errInfo.append( - String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";"); + if(!district.equals("L3_header")) {// district="L3_header"时 不校验keyword + + if (StringUtils.isBlank(keyword)) { + errInfo.append( + String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";"); + }else if(keyword.length() < 4 || keyword.length() > 1024){// 关键字长度限制 + errInfo.append(prop.getProperty("key_word")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";"); + } + + if (mulityKeywordsP.equals("0")) { + if (keyword.indexOf("\n") > -1) { + errInfo.append( + String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";"); + } + Matcher m = pattern.matcher(keyword); + if (m.find()) { + errInfo.append(String.format(prop.getProperty("has_invisible_char"), + prop.getProperty("key_word") + " '" + keyword + "'") + ";"); + } + } else { + boolean has = false; + Set keywordSet=Sets.newHashSet(); + + for (String key : keyword.split("\n")) { + Matcher m = pattern.matcher(key); + if (m.find()) { + has = true; + errInfo.append(String.format(prop.getProperty("has_invisible_char"), + prop.getProperty("key_word") + " '" + key + "'") + ";"); + break; + } + if(!keywordSet.contains(key)) { + keywordSet.add(key); + }else { + errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";"); + } + } + if (!has) { + if(keyword.replaceAll("\n","").length()>1024) { + errInfo.append(String.format(prop.getProperty("most_keywords"), + prop.getProperty("key_word")) + ";"); + }else { + String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR); + baseStringCfg.setCfgKeywords(reWord); + } + } + } } + if (StringUtils.isNotBlank(dirtrictP)) { if (StringUtils.isBlank(district)) { if (dirtrictP.indexOf(",") == -1) { @@ -127,185 +169,149 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable -1) { - errInfo.append( - String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word")) + ";"); - } - Matcher m = pattern.matcher(keyword); - if (m.find()) { - errInfo.append(String.format(prop.getProperty("has_invisible_char"), - prop.getProperty("key_word") + " '" + keyword + "'") + ";"); - } - } else { - boolean has = false; - Set keywordSet=Sets.newHashSet(); - - for (String key : keyword.split("\n")) { - Matcher m = pattern.matcher(key); - if (m.find()) { - has = true; - errInfo.append(String.format(prop.getProperty("has_invisible_char"), - prop.getProperty("key_word") + " '" + key + "'") + ";"); - break; - } - if(!keywordSet.contains(key)) { - keywordSet.add(key); - }else { - errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";"); - } - } - if (!has) { - if(keyword.replaceAll("\n","").length()>1024) { - errInfo.append(String.format(prop.getProperty("most_keywords"), - prop.getProperty("key_word")) + ";"); - }else { - String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR); - baseStringCfg.setCfgKeywords(reWord); - } - } - } - Integer exprType = baseStringCfg.getExprType(); - boolean has = false; - if (exprType == null) { - if (exprTypeP.indexOf(",") == -1) { - if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) { - throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); - } - baseStringCfg.setExprType(Integer.parseInt(exprTypeP)); - } else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) { - baseStringCfg.setExprType(0); - } else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1") - && keyword.indexOf("\n") > -1) { - baseStringCfg.setExprType(1); - } else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1") - && keyword.indexOf("\n") == -1) { - baseStringCfg.setExprType(0); - } else { - baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0])); - } - // errInfo.append(String.format(prop.getProperty("can_not_null"), - // prop.getProperty("expression_type"))+";"); - } else { - for (String exp : exprTypeP.split(",")) { - if (exp.equals(exprType.toString())) { - has = true; - break; - } - } - if (!has) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type")) - + ";"); - } - has = false; - } - exprType = baseStringCfg.getExprType(); - Integer matchMethod = baseStringCfg.getMatchMethod(); - if (matchMethod == null) { - if (matchMethodP.indexOf(",") == -1) { - if (exprTypeP.equals("1") && !matchMethodP.equals("0")) { - throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); - } - baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP)); - } else if (exprType != null && exprType.intValue() == 1) { - if (matchMethodP.indexOf("0") > -1) { - baseStringCfg.setMatchMethod(0); - } else { - throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); - } - - } else { - baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0])); - } - // errInfo.append(String.format(prop.getProperty("can_not_null"), - // prop.getProperty("match_method"))+";"); - } else { - for (String exp : matchMethodP.split(",")) { - if (exp.equals(matchMethod.toString())) { - has = true; - break; - } - } - if (!has) { - errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method")) - + ";"); - } - } - Integer isHex = baseStringCfg.getIsHex(); - Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive(); - if (isHex == null || isCaseInsenstive == null) { - if (isHex == null) { - if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) { - baseStringCfg.setIsHex(0); - } else if (hexP.indexOf("1")>-1) { - baseStringCfg.setIsHex(1); - } else { - errInfo.append( - String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";"); - } - } - if (isCaseInsenstive == null) { - if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) { - baseStringCfg.setIsCaseInsenstive(0); - } else if (hexP.indexOf("2")>-1) { - baseStringCfg.setIsCaseInsenstive(1); - } else { - errInfo.append(String.format(prop.getProperty("can_not_null"), - prop.getProperty("is_case_insenstive")) + ";"); - } - } - } else { - if (isHex.intValue() != 0 && isHex.intValue() != 1) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); - } - if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) - + ";"); - } - if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); - } - if (hexP.equals("1") && isHex.intValue() == 0) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); - } - if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) - + ";"); - } - if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) { - errInfo.append( - String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) - + ";"); - } - // 关键字十六进制校验 - if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) { - boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches(); - if(!bl) { - errInfo.append( - prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";"); - } - } - } - isHex = baseStringCfg.getIsHex(); - isCaseInsenstive = baseStringCfg.getIsCaseInsenstive(); - if (isHex != null && isCaseInsenstive != null) { - if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) { - baseStringCfg.setIsHexbin(0); - } else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) { - baseStringCfg.setIsHexbin(1); - } else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) { - baseStringCfg.setIsHexbin(2); - } else if (hexP.indexOf("1") != -1 && isHex.intValue() == 1 && isCaseInsenstive.intValue() == 1) {// 只有是十六进制且取值正确的时候, 才进行(十六进制)与(大小写敏感)的校验 - errInfo.append(prop.getProperty("hex_case_insensitive")+ ";"); - } - } + if(!district.equals("L3_header")) {// district="L3_header"时 不校验exprType、matchMethod、isHex、isCaseInsenstive,为固定值 + Integer exprType = baseStringCfg.getExprType(); + boolean has = false; + if (exprType == null) { + if (exprTypeP.indexOf(",") == -1) { + if (mulityKeywordsP.equals("0") && exprTypeP.equals("1")) { + throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); + } + baseStringCfg.setExprType(Integer.parseInt(exprTypeP)); + } else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("0")) { + baseStringCfg.setExprType(0); + } else if (exprTypeP.indexOf("1") > -1 && mulityKeywordsP.equals("1") + && keyword.indexOf("\n") > -1) { + baseStringCfg.setExprType(1); + } else if (exprTypeP.indexOf("0") > -1 && mulityKeywordsP.equals("1") + && keyword.indexOf("\n") == -1) { + baseStringCfg.setExprType(0); + } else { + baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0])); + } + // errInfo.append(String.format(prop.getProperty("can_not_null"), + // prop.getProperty("expression_type"))+";"); + } else { + for (String exp : exprTypeP.split(",")) { + if (exp.equals(exprType.toString())) { + has = true; + break; + } + } + if (!has) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type")) + + ";"); + } + has = false; + } + exprType = baseStringCfg.getExprType(); + Integer matchMethod = baseStringCfg.getMatchMethod(); + if (matchMethod == null) { + if (matchMethodP.indexOf(",") == -1) { + if (exprTypeP.equals("1") && !matchMethodP.equals("0")) { + throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); + } + baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP)); + } else if (exprType != null && exprType.intValue() == 1) { + if (matchMethodP.indexOf("0") > -1) { + baseStringCfg.setMatchMethod(0); + } else { + throw new RuntimeException("region dict config error,dict id is " + regionDict.getDictId()); + } + + } else { + baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0])); + } + // errInfo.append(String.format(prop.getProperty("can_not_null"), + // prop.getProperty("match_method"))+";"); + } else { + for (String exp : matchMethodP.split(",")) { + if (exp.equals(matchMethod.toString())) { + has = true; + break; + } + } + if (!has) { + errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method")) + + ";"); + } + } + Integer isHex = baseStringCfg.getIsHex(); + Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive(); + if (isHex == null || isCaseInsenstive == null) { + if (isHex == null) { + if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) { + baseStringCfg.setIsHex(0); + } else if (hexP.indexOf("1")>-1) { + baseStringCfg.setIsHex(1); + } else { + errInfo.append( + String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";"); + } + } + if (isCaseInsenstive == null) { + if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) { + baseStringCfg.setIsCaseInsenstive(0); + } else if (hexP.indexOf("2")>-1) { + baseStringCfg.setIsCaseInsenstive(1); + } else { + errInfo.append(String.format(prop.getProperty("can_not_null"), + prop.getProperty("is_case_insenstive")) + ";"); + } + } + } else { + if (isHex.intValue() != 0 && isHex.intValue() != 1) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); + } + if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) + + ";"); + } + if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); + } + if (hexP.equals("1") && isHex.intValue() == 0) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";"); + } + if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) + + ";"); + } + if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) { + errInfo.append( + String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive")) + + ";"); + } + // 关键字十六进制校验 + if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) { + boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches(); + if(!bl) { + errInfo.append( + prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";"); + } + } + } + isHex = baseStringCfg.getIsHex(); + isCaseInsenstive = baseStringCfg.getIsCaseInsenstive(); + if (isHex != null && isCaseInsenstive != null) { + if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) { + baseStringCfg.setIsHexbin(0); + } else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) { + baseStringCfg.setIsHexbin(1); + } else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) { + baseStringCfg.setIsHexbin(2); + } else if (hexP.indexOf("1") != -1 && isHex.intValue() == 1 && isCaseInsenstive.intValue() == 1) {// 只有是十六进制且取值正确的时候, 才进行(十六进制)与(大小写敏感)的校验 + errInfo.append(prop.getProperty("hex_case_insensitive")+ ";"); + } + } + } // APP Payload L3_HEADER的特殊属性限制 if(baseStringCfg.getDistrict().equals("L3_header")) { String headerType = baseStringCfg.getHeaderType(); @@ -318,7 +324,13 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable