24282 2 lat temu
rodzic
commit
e6f99ee643

+ 10 - 0
src/main/java/com/fjhx/email/entity/dto/MailSyncInfo.java

@@ -35,6 +35,11 @@ public class MailSyncInfo {
     public static Integer mailType;
 
     /**
+     * 调用主服务url前缀
+     */
+    public static String urlPrefix;
+
+    /**
      * 需要同步的邮箱账号
      */
     public static List<MailboxInfo> mailboxInfoList;
@@ -64,4 +69,9 @@ public class MailSyncInfo {
         MailSyncInfo.mailType = mailType;
     }
 
+    @Value("${mail.urlPrefix}")
+    public static void setUrlPrefix(String urlPrefix) {
+        MailSyncInfo.urlPrefix = urlPrefix;
+    }
+
 }

+ 12 - 4
src/main/java/com/fjhx/email/service/impl/CoreServiceImpl.java

@@ -162,7 +162,8 @@ public class CoreServiceImpl implements ApplicationRunner {
         // 处理时间
         long handleTime = end - start;
 
-        log.info("第 {} 伦邮件同步完成,共同步 {} 个邮箱,{} 封邮件,总耗时 {}", num, mailboxSize, mailCount, DateUtil.formatBetween(handleTime));
+        log.info("第 {} 伦邮件同步完成,共同步 {} 个邮箱,{} 封邮件,总耗时 {}",
+                num, mailboxSize, mailCount, DateUtil.formatBetween(handleTime));
 
         // 处理时间是否小于最小处理时间
         if (MailSyncInfo.minWaitingTime > handleTime) {
@@ -329,8 +330,9 @@ public class CoreServiceImpl implements ApplicationRunner {
                     break;
                 }
             }
+
             // 收件时间在上次收件时间之前,不继续找之前的邮件了
-            if (receivedDate.before(lastReceivedDate) || receivedDate.equals(lastReceivedDate)) {
+            if (receivedDate.before(lastReceivedDate)) {
                 break;
             }
 
@@ -380,7 +382,10 @@ public class CoreServiceImpl implements ApplicationRunner {
 
                 // 邮箱是否同步
                 if (mailboxInfo.getSkip()) {
-                    personalMailboxService.update(q -> q.eq(BaseEntity::getId, mailboxInfo.getId()).set(PersonalMailbox::getSyncStatus, mailboxInfo.getSkip() ? 0 : 1).set(BaseEntity::getUpdateTime, new Date()));
+                    personalMailboxService.update(q -> q
+                            .eq(BaseEntity::getId, mailboxInfo.getId())
+                            .set(PersonalMailbox::getSyncStatus, mailboxInfo.getSkip() ? 0 : 1)
+                            .set(BaseEntity::getUpdateTime, new Date()));
                 }
 
                 PersonalFolder personalFolder = new PersonalFolder();
@@ -418,7 +423,10 @@ public class CoreServiceImpl implements ApplicationRunner {
 
                 // 邮箱是否同步
                 if (mailboxInfo.getSkip()) {
-                    enterpriseMailboxService.update(q -> q.eq(BaseEntity::getId, mailboxInfo.getId()).set(EnterpriseMailbox::getSyncStatus, mailboxInfo.getSkip() ? 0 : 1).set(BaseEntity::getUpdateTime, new Date()));
+                    enterpriseMailboxService.update(q -> q.
+                            eq(BaseEntity::getId, mailboxInfo.getId())
+                            .set(EnterpriseMailbox::getSyncStatus, mailboxInfo.getSkip() ? 0 : 1)
+                            .set(BaseEntity::getUpdateTime, new Date()));
                 }
 
                 EnterpriseFolder enterpriseFolder = new EnterpriseFolder();

+ 3 - 1
src/main/resources/application-dev.yml

@@ -15,4 +15,6 @@ mail:
   # 超过多少次后将不再同步此邮箱
   errorNumber: 5
   # 获取邮箱类型 1国内邮箱 2国外邮箱
-  mailType: 1
+  mailType: 1
+  # 调用主服务url前缀
+  urlPrefix: http://localhost:9898/