Browse Source

导入时如果是数字类型默认值为0

guq 7 years ago
parent
commit
9506a0b3c0

+ 12 - 1
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ExcelServiceImpl.java

@@ -196,6 +196,10 @@ public class ExcelServiceImpl implements ExcelService{
                                    break;
                                    break;
                                }
                                }
                            }
                            }
+                           //如果为数字类型且为空默认赋值0
+                           if ("number".equals(set.getType()) && StringUtils.isEmpty(value)) {
+                                value = "0";
+                           }
                            //插入主表数据
                            //插入主表数据
                            if (null != mainData) {
                            if (null != mainData) {
                                mainData.put(set.getField(), value);
                                mainData.put(set.getField(), value);
@@ -230,6 +234,10 @@ public class ExcelServiceImpl implements ExcelService{
                                    break;
                                    break;
                                }
                                }
                            }
                            }
+                           //如果为数字类型且为空默认赋值0
+                           if ("number".equals(set.getType()) && StringUtils.isEmpty(value)) {
+                               value = "0";
+                           }
                            //拼从表数据
                            //拼从表数据
                            detailData.put(set.getField(), value);
                            detailData.put(set.getField(), value);
                        }
                        }
@@ -239,7 +247,10 @@ public class ExcelServiceImpl implements ExcelService{
                        }
                        }
                    }
                    }
                 }
                 }
-                dataImportDetailMapper.insertSelective(dd);
+                //排除编号未填写但是其他字段填写的情况
+                if (StringUtils.hasText(codeValue)) {
+                    dataImportDetailMapper.insertSelective(dd);
+                }
             }
             }
             //重复编号检测
             //重复编号检测
             List<String> samecode = getDuplicateElements(validateCode);
             List<String> samecode = getDuplicateElements(validateCode);