|
|
@@ -165,17 +165,13 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
for (TempletSet set : main) {
|
|
|
//取excel值
|
|
|
value = data.get(set.getDescription());
|
|
|
- /* if ("true".equals(set.getNecessary())) {
|
|
|
- value = data.get("*" + set.getDescription());
|
|
|
- } else {
|
|
|
- value = data.get(set.getDescription());
|
|
|
- }*/
|
|
|
//取编号字段
|
|
|
if (set.isCodefield() && !"".equals(value)) {
|
|
|
mainData = new JSONObject();
|
|
|
codeValue = value;
|
|
|
difference = true;
|
|
|
validateCode.add(codeValue);
|
|
|
+ dd.setDd_codevalue(codeValue);
|
|
|
}
|
|
|
//检查是否是同一单
|
|
|
if (set.isCodefield() && "".equals(value)) {
|
|
|
@@ -184,7 +180,6 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
}
|
|
|
//检查主表必填字段是否完整
|
|
|
if (difference) {
|
|
|
- dd.setDd_codevalue(codeValue);
|
|
|
if ("true".equals(set.getNecessary()) && "".equals(value)) {
|
|
|
err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
|
|
|
break;
|
|
|
@@ -227,11 +222,6 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
for (TempletSet set : detail) {
|
|
|
//取excel值
|
|
|
value = data.get(set.getDescription());
|
|
|
- /* if ("true".equals(set.getNecessary())) {
|
|
|
- value = data.get("*" + set.getDescription());
|
|
|
- } else {
|
|
|
- value = data.get(set.getDescription());
|
|
|
- }*/
|
|
|
if ("true".equals(set.getNecessary()) && value.equals("")) {
|
|
|
detailData = null;
|
|
|
//err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
|
|
|
@@ -245,9 +235,17 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- //如果为数字类型且为空默认赋值0
|
|
|
- if ("number".equals(set.getType()) && StringUtils.isEmpty(value)) {
|
|
|
- value = "0";
|
|
|
+ //如果为数字类型且为空默认赋值0,检测是否为数字类型
|
|
|
+ if ("number".equals(set.getType())) {
|
|
|
+ if (StringUtils.isEmpty(value)) {
|
|
|
+ value = "0";
|
|
|
+ } else {
|
|
|
+ Boolean numner = isNumner(value);
|
|
|
+ if (!numner) {
|
|
|
+ err.append("第" + (i + 3) + "行 " + set.getDescription() + " 数字格式不正确!<br/> ");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//拼从表数据
|
|
|
detailData.put(set.getField(), value);
|
|
|
@@ -258,8 +256,8 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //排除编号未填写但是其他字段填写的情况
|
|
|
- if (StringUtils.hasText(codeValue)) {
|
|
|
+ //排除编号未填写但是其他字段填写的情况 主表不为空且从表也不为空
|
|
|
+ if (StringUtils.hasText(codeValue) && StringUtils.hasText(dd.getDd_codevalue())) {
|
|
|
dataImportDetailMapper.insertSelective(dd);
|
|
|
}
|
|
|
}
|
|
|
@@ -315,8 +313,8 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
if (StringUtils.isEmpty(date)) {
|
|
|
return false;
|
|
|
}
|
|
|
- String regEx1 = "[0-9]{4}/[0-9]{2}/[0-9]{2}";
|
|
|
- String regEX2 = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
|
|
|
+ String regEx1 = "[0-9]{4}/[0-1][0-9]/[0-3][0-9]";
|
|
|
+ String regEX2 = "[0-9]{4}-[0-1][0-9]-[0-3][0-9]";
|
|
|
// 编译正则表达式
|
|
|
Pattern pattern1 = Pattern.compile(regEx1);
|
|
|
Pattern pattern2 = Pattern.compile(regEX2);
|
|
|
@@ -334,7 +332,7 @@ public class ExcelServiceImpl implements ExcelService{
|
|
|
Integer days = Integer.valueOf(num);
|
|
|
return DateUtils.plusDay(days, "1899-12-30");
|
|
|
}catch (Exception e) {
|
|
|
- return null;
|
|
|
+ return validateDateFormat(num) ? num : null;
|
|
|
}
|
|
|
}
|
|
|
|