Commit 1f00cb80 by liuzz

针对处理'-'等未输入的值,插入数据库时直接显示为null值,便于统计

parent 727d3f9b
...@@ -105,6 +105,10 @@ public class DataImportUtils { ...@@ -105,6 +105,10 @@ public class DataImportUtils {
* @return * @return
*/ */
public static String getInsertContent(VerifyVO vo, int index) { public static String getInsertContent(VerifyVO vo, int index) {
// 没有值就插入null
if (vo.getValues().get(index) == null){
return "null";
}
if (StringUtils.containsIgnoreCase(vo.getFieldType(), "VARCHAR")) { if (StringUtils.containsIgnoreCase(vo.getFieldType(), "VARCHAR")) {
return "'" + vo.getValues().get(index) + "'"; return "'" + vo.getValues().get(index) + "'";
} else if (StringUtils.containsIgnoreCase(vo.getFieldType(), "NUMBER")) { } else if (StringUtils.containsIgnoreCase(vo.getFieldType(), "NUMBER")) {
...@@ -120,9 +124,9 @@ public class DataImportUtils { ...@@ -120,9 +124,9 @@ public class DataImportUtils {
return StrFormatter.format("to_date('{}','YYYY-MM-DD HH24:MI:SS')", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", date)); return StrFormatter.format("to_date('{}','YYYY-MM-DD HH24:MI:SS')", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", date));
} }
} catch (Exception ignore) { } catch (Exception ignore) {
}
return "null"; return "null";
} }
}
return "'" + vo.getValues().get(index) + "'"; return "'" + vo.getValues().get(index) + "'";
} }
......
...@@ -560,6 +560,12 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData ...@@ -560,6 +560,12 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
for (Integer column : columnList) { for (Integer column : columnList) {
final Cell cell = row.getCell(column, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); final Cell cell = row.getCell(column, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
String cellValue = DiConfig.getValue(cell); String cellValue = DiConfig.getValue(cell);
// 如果没有值一律转换为空值
if (StrUtil.isBlank(cellValue) || StrUtil.equalsAnyIgnoreCase(cellValue,"-","null")){
cellValue = null;
vo.addValue(cellValue);
continue;
}
if (StrUtil.containsIgnoreCase(vo.getFieldType(),"number")){ if (StrUtil.containsIgnoreCase(vo.getFieldType(),"number")){
// 如果是数字 // 如果是数字
// 计算整数长度in 小数长度de // 计算整数长度in 小数长度de
......
...@@ -47,7 +47,7 @@ spring: ...@@ -47,7 +47,7 @@ spring:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: druid active: zyy
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment