Browse Source

feat:邮件解析-修复循环方向为其他时解析错误的问题

mozuwen 7 months ago
parent
commit
ff4c39db6c

+ 2 - 2
service-base/src/main/java/com/simuwang/base/common/conts/EmailDataDirectionConst.java

@@ -15,11 +15,11 @@ public class EmailDataDirectionConst {
     /**
      * 其他方向
      */
-    public static final Integer OTHER_DIRECTION_TYPE = 3;
+    public static final Integer OTHER_DIRECTION_TYPE = -1;
 
     /**
      * 最大行数或最大列数
      */
-    public static final Integer MAX_ROW_COLUMN = 2;
+    public static final Integer MAX_ROW_COLUMN = 20;
 
 }

+ 2 - 2
service-daq/src/main/java/com/simuwang/daq/service/EmailTemplateService.java

@@ -126,7 +126,7 @@ public class EmailTemplateService {
 
         for (TemplateDataRuleDTO templateDataRuleDTO : dataRuleDetailList) {
             Integer fieldName = templateDataRuleDTO.getFieldName();
-            Integer position = templateDataRuleDTO.getPosition();
+            Integer position = templateDataRuleDTO.getPosition() == null ? 2 : templateDataRuleDTO.getPosition();
             // 提取位置-正文
             if (position == 1) {
                 String valueByPattern = getValueByPattern(textContent, templateDataRuleDTO.getFieldRule());
@@ -135,7 +135,7 @@ public class EmailTemplateService {
             // 提取位置-正文表格或附件表格(表格数据提取一次后不再提取)
             if (position == 2 && !hasParsedTableData) {
                 hasParsedTableData = true;
-                List<TemplateDataRuleDTO> dataRuleDTOS = dataRuleDetailList.stream().filter(e -> e.getPosition() == 2).toList();
+                List<TemplateDataRuleDTO> dataRuleDTOS = dataRuleDetailList.stream().filter(e -> e.getPosition() == null || e.getPosition() == 2).toList();
                 fieldValueMapList = parsedTableData(filePath, direction, dataRuleDTOS);
             }
         }

+ 2 - 5
service-deploy/src/test/java/com/simuwang/ApplicationTest.java

@@ -26,9 +26,6 @@ public class ApplicationTest {
     @Test
     public void test() {
         MailboxInfoDTO emailInfoDTO = new MailboxInfoDTO();
-//        emailInfoDTO.setUserId(2374315);
-//        emailInfoDTO.setAccount("wangzaijun@simuwang.com");
-//        emailInfoDTO.setPassword("WZJ2twy1314");
         emailInfoDTO.setUserId(2395446);
         emailInfoDTO.setAccount("mozuwen@simuwang.com");
         emailInfoDTO.setPassword("Mzw@0306");
@@ -42,8 +39,8 @@ public class ApplicationTest {
 //        emailInfoDTO.setPort("993");
 //        emailInfoDTO.setProtocol("imap");
 
-        Date startDate = DateUtil.parse("2024-09-26 10:20:00", DateConst.YYYY_MM_DD_HH_MM_SS);
-        Date endDate = DateUtil.parse("2024-09-26 19:00:00", DateConst.YYYY_MM_DD_HH_MM_SS);
+        Date startDate = DateUtil.parse("2024-09-27 16:25:00", DateConst.YYYY_MM_DD_HH_MM_SS);
+        Date endDate = DateUtil.parse("2024-09-27 16:40:00", DateConst.YYYY_MM_DD_HH_MM_SS);
         try {
             emailParseService.parseEmail(emailInfoDTO, startDate, endDate);
         } catch (Exception e) {