Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop

This commit is contained in:
intraUser
2019-01-04 12:13:05 +08:00
26 changed files with 1225 additions and 356 deletions

View File

@@ -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++;
}
}
@@ -2611,5 +2616,60 @@ public class ExportExcel {
log.debug("Export success.");
*/
}
public <E> ExportExcel ajaxDataList(List<List<Object>>dataMap,String code){
for (int i = 0; i < dataMap.size(); i++) {
Row row = this.addRow(sheets.get(code),rownums.get(code),code);
int colunm = 0;
List<Object> list=dataMap.get(i);
for (int j = 0; j < list.size(); j++) {
this.addCell(row, colunm++,list.get(j), 0,null);
}
}
return this;
}
public ExportExcel(String titleName,String code,String titleTime,List<String> headerList){
this.wb = new SXSSFWorkbook(500);
int j=0;
sheets=new HashMap<>();
rownums=new HashMap<>();
Sheet sheet = wb.createSheet(titleName);
if(!StringUtils.isEmpty(titleTime)){
rownums.put(code, 1);
}else{
rownums.put(code, 0);
}
sheets.put(code, sheet);
this.styles = createStyles(wb);
if(!StringUtils.isEmpty(titleTime)){
//添加一行数据
CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,headerList.size()-1);
CellStyle style = styles.get("data");
Row timeRow = sheet.createRow(0);
timeRow.setHeightInPoints(16);
Cell cellt = timeRow.createCell(0);
cellt.setCellValue(titleTime);
sheet.addMergedRegion(callRangeAddress);
sheet.autoSizeColumn(0);
setBorderStyle(CellStyle.BORDER_THIN,callRangeAddress,sheet,wb);
}
Integer rownum=rownums.get(code);
Row headerRow = sheet.createRow(rownum++);
headerRow.setHeightInPoints(16);
for (int i = 0; i < headerList.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header"));
cell.setCellValue(headerList.get(i));
sheet.autoSizeColumn(i);
}
for (int i = 0; i < headerList.size(); i++) {
int colWidth = sheet.getColumnWidth(i)*2;
sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
}
j++;
}
}

View File

@@ -92,21 +92,63 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
StringBuffer errInfo = new StringBuffer();
AppComplexFeatureCfg baseStringCfg = new AppComplexFeatureCfg();
BeanUtils.copyProperties(list.get(i), baseStringCfg);
// 配置描述、关键字长度限制
// 配置描述长度限制
if(baseStringCfg.getCfgDesc().length() > 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<String> 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<String
String.format(prop.getProperty("can_not_be"), " 'others'")+ ";");
}
}
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<String> 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<String
}else{
appMultiFeatureCfgService.checkImportAppPayload(baseStringCfg, errInfo, prop);
}
appMultiFeatureCfgService.setL3HeaderKeyword(baseStringCfg);
if (errInfo.toString().length() == 0) {
appMultiFeatureCfgService.setL3HeaderKeyword(baseStringCfg);
}
baseStringCfg.setIsHexbin(1);
baseStringCfg.setIsCaseInsenstive(0);
baseStringCfg.setExprType(3);
baseStringCfg.setMatchMethod(0);
}else {
baseStringCfg.setHeaderType(null);
baseStringCfg.setVer(null);

View File

@@ -0,0 +1,29 @@
package com.nis.web.controller.report;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.web.controller.BaseController;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("${adminPath}/export")
public class ExportController extends BaseController {
@RequestMapping(value = "ajaxExport")
public void ajaxExport(String exports,HttpServletRequest request,HttpServletResponse response) throws Exception{
JSONObject jsonObject = JSONObject.fromObject(StringEscapeUtils.unescapeHtml(exports));
Map<String,Object> map=JSONObject.fromObject(jsonObject);
List<List<Object>> list=(List<List<Object>>) map.get("book");
List<String> heard=(List<String>) map.get("heard");
String titleTime=String.valueOf(map.get("titleTime"));
String titleCode=String.valueOf(map.get("titleCode"));
_ajaxExport(request,response,titleCode, titleTime, heard, list);
}
}

View File

@@ -581,7 +581,7 @@ public class AppMultiFeatureCfgService extends BaseService {
count++;
}
if((count >0 || count <5) && (!errorFlag) && (ipHeaderFlag)) {// 清空错误信息
if((0<count) && (count<5) && (!errorFlag) && (ipHeaderFlag)) {// 清空错误信息
errInfo.setLength(0);;
errInfo.append(errInfoCopy);
}