Browse Source

fix:邮件解析-修复日期[xxxx年xx月xx日]解析不正确的问题

mozuwen 7 months ago
parent
commit
ee8c8aa2d6

+ 0 - 1
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -294,7 +294,6 @@ public class EmailParseService {
         if (CollUtil.isEmpty(fundIdList)) {
             fundNavDTO.setParseStatus(NavParseStatusConst.NOT_MATCH);
         }
-        log.info("判断数据的解析状态 -> 邮件主题:{},邮件日期:{},数据解析状态:{}", emailTitle, emailDate, fundNavDTO.getParseStatus());
         fundNavDTO.setFundIdList(fundIdList);
     }
 

+ 5 - 3
service-daq/src/main/java/com/simuwang/daq/service/NavEmailParser.java

@@ -260,7 +260,7 @@ public class NavEmailParser extends AbstractEmailParser {
                     if (cell == null) {
                         continue;
                     }
-                    fieldValueMap.put(fieldRowMap.get(rowNum), cell.getStringCellValue());
+                    fieldValueMap.put(fieldRowMap.get(rowNum), ExcelUtil.getCellValue(cell));
                 }
                 Optional.ofNullable(buildEmailFundNavDTO(fieldValueMap)).ifPresent(fundNavDTOList::add);
             }
@@ -290,7 +290,7 @@ public class NavEmailParser extends AbstractEmailParser {
                 if (cell == null) {
                     continue;
                 }
-                String cellValue = cell.getStringCellValue();
+                String cellValue = ExcelUtil.getCellValue(cell);
                 if (StrUtil.isNotBlank(cellValue) && cellValue.contains("截至")) {
                     int index = cellValue.indexOf("截至");
                     String date = cellValue.substring(index + 2, index + 2 + 10);
@@ -359,6 +359,7 @@ public class NavEmailParser extends AbstractEmailParser {
         // 正常净值文件格式
         if (StrUtil.isNotBlank(priceDate) && !priceDate.contains("-")) {
             // 处理日期yyyyMMdd格式 -> 转成yyyy-MM-dd
+            priceDate = priceDate.replace("年","").replace("月","").replace("日","");
             priceDate = DateUtil.format(DateUtil.parse(priceDate, DateConst.YYYYMMDD), DateConst.YYYY_MM_DD);
         }
         emailFundNavDTO.setPriceDate(priceDate);
@@ -410,6 +411,7 @@ public class NavEmailParser extends AbstractEmailParser {
         }
         if (StrUtil.isNotBlank(priceDate) && !priceDate.contains("-")) {
             // 处理日期yyyyMMdd格式 -> 转成yyyy-MM-dd
+            priceDate = priceDate.replace("年","").replace("月","").replace("日","");
             priceDate = DateUtil.format(DateUtil.parse(priceDate, DateConst.YYYYMMDD), DateConst.YYYY_MM_DD);
         }
         emailFundNavDTO.setPriceDate(priceDate);
@@ -483,7 +485,7 @@ public class NavEmailParser extends AbstractEmailParser {
     private Map<String, Pair<Integer, Integer>> getFieldPosition(Sheet sheet, Map<String, List<String>> emailFieldMap) {
         Map<String, List<Pair<Integer, Integer>>> tempFieldPositionMap = MapUtil.newHashMap();
         int lastRowNum = sheet.getLastRowNum();
-        for (int rowNum = 0; rowNum < lastRowNum; rowNum++) {
+        for (int rowNum = 0; rowNum <= lastRowNum; rowNum++) {
             Row sheetRow = sheet.getRow(rowNum);
             if (sheetRow == null) {
                 continue;