解析 空字符串校验
This commit is contained in:
@@ -955,28 +955,32 @@ public class DataResolveThread implements Runnable{
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String fileType = field.getFiledType().toUpperCase();
|
String fileType = field.getFiledType().toUpperCase();
|
||||||
|
String col = detailsArr0[index];
|
||||||
if("DATE".equals(fileType)){
|
if("DATE".equals(fileType)){
|
||||||
if(StringUtils.isNumeric(detailsArr0[index])){//如果为数字型时间,转换
|
if(StringUtils.isBlank(col)){
|
||||||
detail.put(field.getFiledName(), format.format(new Date(Long.parseLong(detailsArr0[index].trim()))));
|
detail.put(field.getFiledName(), null);
|
||||||
|
}else if(StringUtils.isNumeric(col)){//如果为数字型时间,转换
|
||||||
|
detail.put(field.getFiledName(), format.format(new Date(Long.parseLong(col.trim()))));
|
||||||
}else{//eg:2016-03-06 12:12:12
|
}else{//eg:2016-03-06 12:12:12
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
detail.put(field.getFiledName(), col.trim());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if("NUMBER".equals(fileType)){
|
if("NUMBER".equals(fileType)){
|
||||||
if (StringUtils.isBlank(detailsArr0[index])
|
if(StringUtils.isBlank(col)){
|
||||||
|| StringUtil.isRationalNumber(detailsArr0[index])) {
|
detail.put(field.getFiledName(), null);
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
} else if (StringUtil.isRationalNumber(col)) {
|
||||||
} else if (detailsArr0[index].trim().contains(" days, ")) {
|
detail.put(field.getFiledName(), col.trim());
|
||||||
detail.put(field.getFiledName(), CommonService.getLongTimeStr(detailsArr0[index].trim()));
|
} else if (col.trim().contains(" days, ")) {
|
||||||
|
detail.put(field.getFiledName(), CommonService.getLongTimeStr(col.trim()));
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("NUMBER数据格式错误!");
|
throw new Exception("NUMBER数据格式错误!");
|
||||||
}
|
}
|
||||||
}else{ // VARCHAR2(x)
|
}else{ // VARCHAR2(x)
|
||||||
String length = fileType.replaceAll("VARCHAR2\\((\\d+)\\)", "$1");
|
String length = fileType.replaceAll("VARCHAR2\\((\\d+)\\)", "$1");
|
||||||
if(Integer.parseInt(length) < detailsArr0[index].trim().length()) {
|
if(Integer.parseInt(length) < col.trim().length()) {
|
||||||
throw new Exception("VARCHAR2数据格式错误!");
|
throw new Exception("VARCHAR2数据格式错误!");
|
||||||
}
|
}
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
detail.put(field.getFiledName(), col.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -988,7 +992,7 @@ public class DataResolveThread implements Runnable{
|
|||||||
}
|
}
|
||||||
errorInfo.deleteCharAt(errorInfo.length()-1);
|
errorInfo.deleteCharAt(errorInfo.length()-1);
|
||||||
//监测数据的详细信息如果和指定的字段类型不匹配,则抛弃此条监测数据,避免影响批量入库
|
//监测数据的详细信息如果和指定的字段类型不匹配,则抛弃此条监测数据,避免影响批量入库
|
||||||
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo);
|
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo,e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
Reference in New Issue
Block a user