Commit b481fedb authored by hongguangwu's avatar hongguangwu

MVP1.6.2-工资原表识别-优化

parent dac28f7c
...@@ -194,6 +194,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -194,6 +194,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
String idCardValue = null; String idCardValue = null;
// 数据行是否被确认,true否 // 数据行是否被确认,true否
boolean dataRowFlag; boolean dataRowFlag;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean nullFlag = true;
// 极限空白表头列,超过阈值,将不继续循环列
int maxTitleNullColumNum = 50;
HSSFCell cell; HSSFCell cell;
// 循环每个sheet // 循环每个sheet
for (int i = 0; i < sheetNum; i++) { for (int i = 0; i < sheetNum; i++) {
...@@ -213,6 +217,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -213,6 +217,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
nullColumn = -1; nullColumn = -1;
preNullColumn = -1; preNullColumn = -1;
nullColumnNum = 0; nullColumnNum = 0;
nullFlag = true;
idCardValue = null; idCardValue = null;
contentMap = new HashMap<>(); contentMap = new HashMap<>();
...@@ -267,6 +272,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -267,6 +272,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (Common.isNotNull(cellValue)) { if (Common.isNotNull(cellValue)) {
titleMap.put(String.valueOf(cellNum), cellValue); titleMap.put(String.valueOf(cellNum), cellValue);
} }
if (nullFlag) {
contentMap.put(String.valueOf(cellNum), cellValue); contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) { if (dataRowFlag) {
if (Common.isEmpty(cellValue)) { if (Common.isEmpty(cellValue)) {
...@@ -310,11 +316,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -310,11 +316,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
contentMap.remove(String.valueOf(nullColumn + num)); contentMap.remove(String.valueOf(nullColumn + num));
} }
break; nullFlag = false;
} }
if (idCardColumn != -1 && cellNum == idCardColumn) { if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue; idCardValue = cellValue;
} }
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
// 表头Map超过50,跳出当前行的列循环
if (nullColumnNum >= maxTitleNullColumNum) {
break;
}
}
} }
if (!dataRowFlag) { if (!dataRowFlag) {
contentList.add(contentMap); contentList.add(contentMap);
...@@ -404,6 +429,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -404,6 +429,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
String idCardValue = null; String idCardValue = null;
// 数据行是否被确认,true否 // 数据行是否被确认,true否
boolean dataRowFlag; boolean dataRowFlag;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean nullFlag = true;
// 极限空白表头列,超过阈值,将不继续循环列
int maxTitleNullColumNum = 50;
XSSFCell cell; XSSFCell cell;
// 循环每个sheet // 循环每个sheet
for (int i = 0; i < sheetNum; i++) { for (int i = 0; i < sheetNum; i++) {
...@@ -423,6 +452,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -423,6 +452,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
nullColumn = -1; nullColumn = -1;
preNullColumn = -1; preNullColumn = -1;
nullColumnNum = 0; nullColumnNum = 0;
nullFlag = true;
idCardValue = null; idCardValue = null;
contentMap = new HashMap<>(); contentMap = new HashMap<>();
...@@ -477,6 +507,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -477,6 +507,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (Common.isNotNull(cellValue)) { if (Common.isNotNull(cellValue)) {
titleMap.put(String.valueOf(cellNum), cellValue); titleMap.put(String.valueOf(cellNum), cellValue);
} }
if (nullFlag) {
contentMap.put(String.valueOf(cellNum), cellValue); contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) { if (dataRowFlag) {
if (Common.isEmpty(cellValue)) { if (Common.isEmpty(cellValue)) {
...@@ -520,11 +551,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -520,11 +551,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
contentMap.remove(String.valueOf(nullColumn + num)); contentMap.remove(String.valueOf(nullColumn + num));
} }
break; nullFlag = false;
} }
if (idCardColumn != -1 && cellNum == idCardColumn) { if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue; idCardValue = cellValue;
} }
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
// 表头Map超过50,跳出当前行的列循环
if (nullColumnNum >= maxTitleNullColumNum) {
break;
}
}
} }
if (!dataRowFlag) { if (!dataRowFlag) {
contentList.add(contentMap); contentList.add(contentMap);
...@@ -686,7 +736,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -686,7 +736,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
&& !"银行卡号".equals(title.getContent()) && !"银行卡号".equals(title.getContent())
&& !"手机号码".equals(title.getContent()) && !"手机号码".equals(title.getContent())
&& !"计税月份".equals(title.getContent())) { && !"计税月份".equals(title.getContent())) {
return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!");
//return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
} }
} else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName()) } else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())
&& (!"是否新员工(默认否)".equals(title.getContent()) && (!"是否新员工(默认否)".equals(title.getContent())
...@@ -698,10 +750,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -698,10 +750,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
|| !"手机号码".equals(title.getContent()) || !"手机号码".equals(title.getContent())
|| !"计税月份".equals(title.getContent())) || !"计税月份".equals(title.getContent()))
) { ) {
return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为【" + title.getContent() + "】"); return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!");
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为【" + title.getContent() + "】");
} }
} else if (detailMap.get(String.valueOf(title.getLineNum())) != null && Common.isNotNull(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())) { } else if (detailMap.get(String.valueOf(title.getLineNum())) != null && Common.isNotNull(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())) {
return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为空!"); return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!!");
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为空!");
} }
} }
} else { } else {
......
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