Browse Source

第三方导入,表头匹配改为大小写不敏感

欧阳劲驰 1 tháng trước cách đây
mục cha
commit
e64516687f

+ 5 - 2
src/main/java/com/shkpr/service/alambizplugin/commtools/ExcelUtils.java

@@ -5,6 +5,7 @@ import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.annotation.ExcelMapping;
 import com.shkpr.service.alambizplugin.constants.ExcelEnum;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import org.apache.commons.collections4.map.CaseInsensitiveMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.*;
@@ -141,7 +142,7 @@ public class ExcelUtils {
                     .mapToObj(row::getCell)
                     .allMatch(cell -> cell == null || cell.getCellTypeEnum() == CellType.BLANK)) continue;
             //数据
-            Map<String, String> data = new HashMap<>();
+            Map<String, String> data = new CaseInsensitiveMap<>();
             //遍历字段映射
             for (Map.Entry<Integer, String> entry : fieldMap.entrySet()) {
                 //获取单元格
@@ -252,7 +253,9 @@ public class ExcelUtils {
                                         //过滤相同的值
                                         .filter(index -> headerRow.getCell(index).getStringCellValue().equals(excelMappingValue))
                                         .findFirst().orElse(-1);
-                            }, Function.identity()
+                            }, Function.identity(),
+                            (it1, it2) -> it2,
+                            CaseInsensitiveMap::new
                     ));
             //遍历行
             for (Row row : sheet) {