‘linchangsheng’ il y a 4 mois
Parent
commit
0676e3dac5

+ 16 - 15
mall-server-api/src/main/java/com/gree/mall/manager/logic/policy/AgreementLogic.java

@@ -270,13 +270,16 @@ public class AgreementLogic {
 
             //发邮件
             try {
-                this.sendEmailFile(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
                 mailboxSendRecord1.setSendStatus("OK");
                 mailboxSendRecord1.setSendTime(new Date());
                 mailboxSendRecord1.updateById();
+
+                this.sendEmailFile(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
+
             } catch (Exception e) {
+                e.printStackTrace();
                 log.error("发送意外保险失败"+e.toString());
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
@@ -290,13 +293,15 @@ public class AgreementLogic {
 
             //发邮件
             try {
-                this.sendEmailFileEm(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
                 mailboxSendRecord1.setSendStatus("OK");
                 mailboxSendRecord1.setSendTime(new Date());
                 mailboxSendRecord1.updateById();
+                this.sendEmailFileEm(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
+
             } catch (Exception e) {
+                e.printStackTrace();
                 log.error("发送雇主保险失败"+e.toString());
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
@@ -311,13 +316,15 @@ public class AgreementLogic {
 
             //发邮件
             try {
-                this.sendEmailFileIn(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
                 mailboxSendRecord1.setSendStatus("OK");
                 mailboxSendRecord1.setSendTime(new Date());
                 mailboxSendRecord1.updateById();
+                this.sendEmailFileIn(mailboxSendRecordPolicies, mailboxSendRecord, mailbox,emailUtilsNew);
+
             } catch (Exception e) {
+                e.printStackTrace();
                 log.error("发送工伤保险失败"+e.toString());
                 MailboxSendRecord mailboxSendRecord1 = new MailboxSendRecord();
                 mailboxSendRecord1.setId(mailboxSendRecord.getId());
@@ -364,11 +371,9 @@ public class AgreementLogic {
 
         //分发邮件
         Session session = emailUtilsNew.loadMailSession();
-        for (String s : mailboxSendRecord.getReceiveMailbox().split(",|,")) {
 
-            emailUtilsNew.send(session,s, mailbox.getSendMailbox(), "工伤险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
+        emailUtilsNew.send(session,mailboxSendRecord.getReceiveMailbox(), mailbox.getSendMailbox(), "工伤险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
                     + mailbox.getSendName() + "保险人员名单详情见附件", filePath);
-        }
 
 
         //删除该文件
@@ -416,10 +421,9 @@ public class AgreementLogic {
 
         //分发邮件
         Session session = emailUtilsNew.loadMailSession();
-        for (String s : mailboxSendRecord.getReceiveMailbox().split(",|,")) {
-            emailUtilsNew.send(session,s, mailbox.getSendMailbox(), "雇主险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
-                    + mailbox.getSendName() + "保险人员名单详情见附件", filePath);
-        }
+
+        emailUtilsNew.send(session,mailboxSendRecord.getReceiveMailbox(), mailbox.getSendMailbox(), "雇主险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
+                + mailbox.getSendName() + "保险人员名单详情见附件", filePath);
 
 
         //删除该文件
@@ -469,12 +473,9 @@ public class AgreementLogic {
 
         //分发邮件
         Session session = emailUtilsNew.loadMailSession();
-        for (String s : mailboxSendRecord.getReceiveMailbox().split(",|,")) {
-            emailUtilsNew.send(session,s, mailbox.getSendMailbox(), "意外险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
-                    + mailbox.getSendName() + "保险人员名单详情见附件", filePath);
-        }
-
 
+        emailUtilsNew.send(session,mailboxSendRecord.getReceiveMailbox(), mailbox.getSendMailbox(), "意外险-" + mailboxSendRecord.getSendBatch() + "-" + mailbox.getSendName(), "你好,以下是" + DateUtil.format(new Date(), "yyyy-MM-dd")
+                + mailbox.getSendName() + "保险人员名单详情见附件", filePath);
 
         //删除该文件
         excel.delete();

+ 10 - 6
mall-server-api/src/main/java/com/gree/mall/manager/utils/email/EmailUtilsNew.java

@@ -2,6 +2,7 @@ package com.gree.mall.manager.utils.email;
 
 
 import cn.hutool.core.date.DateUtil;
+import com.gree.mall.manager.exception.RemoteServiceException;
 import com.sun.mail.imap.IMAPStore;
 import lombok.extern.slf4j.Slf4j;
 
@@ -14,9 +15,7 @@ import javax.mail.search.*;
 
 
 import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Properties;
+import java.util.*;
 
 @Slf4j
 public class EmailUtilsNew {
@@ -92,8 +91,12 @@ public class EmailUtilsNew {
             //mm.addHeader("Disposition-Notification-To", "448797381@qq.com");
             //发件人
             mm.setFrom(new InternetAddress(user));
+
+            InternetAddress[] internetAddresses =InternetAddress.parse(toEmail);
+
+
             //收件人
-            mm.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmail)); // 设置收件人
+            mm.setRecipients(Message.RecipientType.TO, internetAddresses); // 设置收件人
 
             Address[] a = new Address[1];
             a[0] = new InternetAddress(emailReceAccount);
@@ -119,9 +122,10 @@ public class EmailUtilsNew {
             mm.setContent(multipart);
             Transport.send(mm);
         } catch (Exception e) {
-
             // 在这里处理message内容, 格式是固定的
-            System.out.println(e.toString());
+            e.printStackTrace();
+            throw new RemoteServiceException(e.toString());
+
         }
 
     }

+ 1 - 1
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1619,7 +1619,7 @@
         </if>
         HAVING a.worker_number_yun != c.worker_number or c.worker_number is null
         <if test="ex.orderBy == null or ex.orderBy ==''">
-            ORDER BY a.create_time DESC
+            ORDER BY a.websit_id,a.worker_number DESC
         </if>
         ${ex.orderBy}
     </select>