Browse Source

fix: 类型推断问题

upgrade
Zhenfei.Li 5 years ago
parent
commit
c7c2d59324
  1. 33
      src/main/java/com/fr/plugin/decision/core/DML.java
  2. 2
      src/main/java/com/fr/plugin/decision/core/action/CreateAction.java

33
src/main/java/com/fr/plugin/decision/core/DML.java

@ -122,8 +122,8 @@ public class DML {
return execInsertedPreparedStatementByItem(dialect, conn, table, ps, rowCount, tableColName, tableColType, tableValue);
}
for (int rownum=0; rownum<rowCount; rownum++) {
for (int index=0; index<tableColName.size(); index++) {
for (int rownum = 0; rownum < rowCount; rownum++) {
for (int index = 0; index < tableColName.size(); index++) {
int type = tableColType.get(index);
Object value = tableValue.get(tableColName.get(index)).get(rownum);
// excel 中读数 1 会识别为 1.0 , 列格式为[文本]时需要调整下
@ -131,21 +131,26 @@ public class DML {
value = value.toString().split("\\.")[0];
}
DBUtils.applyColumnTypeValue(
dialect,
conn,
table,
null,
null,
ps,
index + 1,
type,
value
);
try {
DBUtils.applyColumnTypeValue(
dialect,
conn,
table,
null,
null,
ps,
index + 1,
type,
value
);
} catch (Exception e) {
// 类型推断后,若遇到不符合该类型的值,直接catch错误
FineLoggerFactory.getLogger().warn("type is not match");
}
}
count ++ ;
ps.addBatch();
if(rownum!=0 && rownum%10000==0){
if(rownum != 0 && rownum % 10000 == 0){
ps.executeBatch();
ps.clearBatch();
}

2
src/main/java/com/fr/plugin/decision/core/action/CreateAction.java

@ -56,7 +56,7 @@ public class CreateAction extends ExcelDmlAction {
FineLoggerFactory.getLogger().error("HW_excel导入:dropTable failed !", e.getMessage());
}
e.printStackTrace();
result.put("status", "failed").put("errorText", "【" + excelDmlBean.getTable().getName() + "】" + "新增操作异常" + e.getLocalizedMessage());
result.put("status", "failed").put("errorText", "【" + excelDmlBean.getTable().getName() + "】" + "导入数据库异常:" + e.getLocalizedMessage());
} finally {
DBUtils.close(conn);
DBUtils.close(preparedStatement);

Loading…
Cancel
Save