瀏覽代碼

原始代码 2022/10/8

lwhhszx 2 年之前
父節點
當前提交
f99164c569

+ 1 - 0
pom.xml

@@ -50,6 +50,7 @@
     </dependencies>
 
     <build>
+        <finalName>MMS_PROD</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 3 - 2
src/main/java/com/example/common/Service/EmailService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
 import com.example.common.Util.MailUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
@@ -21,9 +22,9 @@ import java.util.Map;
 public class EmailService {
     private final MailUtils mailUtils;
 
-
-    @RabbitListener(queues = "mail.queue")
+    @RabbitListener(queues = "${queueName}")
     public void sendEmailMessage(Map<String,Object> map ){
+        System.out.println(map.get("email"));
         mailUtils.sendEmailMessage(map);
     }
 

+ 12 - 10
src/main/java/com/example/common/Util/MailUtils.java

@@ -57,8 +57,9 @@ public class MailUtils {
 
         String[] arr = values.toArray(new String[values.size()]);
         //替换html模板中的参数
-        return MessageFormat.format(buffer.toString(),arr);
+        return MessageFormat.format(buffer.toString(), arr);
     }
+
     @Autowired
     private JavaMailSender javaMailSender;
 
@@ -67,25 +68,26 @@ public class MailUtils {
      *
      * @param map 收件人邮箱
      */
-    public void sendEmailMessage(Map<String,Object> map) {
+    public void sendEmailMessage(Map<String, Object> map) {
         MimeMessage message = javaMailSender.createMimeMessage();
         try {
             //邮箱发送内容组成
-           FileSystemResource img = new FileSystemResource(new File(System.getProperty("user.dir") + map.get("img")));
+            FileSystemResource img = new FileSystemResource(new File(System.getProperty("user.dir") + map.get("img")));
             MimeMessageHelper helper = new MimeMessageHelper(message, true);
             helper.setSubject(map.get("title").toString());
             Set<String> keys = map.keySet();
-           List<String> values = new ArrayList<>();
-            for(String key:keys){
-                if(key.contains("value")){
-                 values.add(map.get(key).toString());
+            List<String> values = new ArrayList<>();
+            for (String key : keys) {
+                if (key.contains("value")) {
+                    if (map.get(key) == null) {
+                        map.put(key, "");
+                    }
+                    values.add(map.get(key).toString());
                 }
             }
-
-
             helper.setText(buildContent(map.get("template").toString(), values), true);
             helper.setTo(map.get("email").toString());
-          helper.addInline("logo", img);
+            helper.addInline("logo", img);
             helper.setFrom(sendEmail);
             javaMailSender.send(message);
         } catch (MessagingException | javax.mail.MessagingException e) {

+ 11 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,11 @@
+
+spring: # rabbitmq
+  rabbitmq:
+    host: 192.168.1.24
+    port: 5672
+    username: admin
+    password: 123456
+    listener:
+      simple:
+        acknowledge-mode: none
+queueName: emailProd.queue

+ 10 - 0
src/main/resources/application-prodNetIn.yml

@@ -0,0 +1,10 @@
+spring: # rabbitmq
+  rabbitmq:
+    host: 172.27.247.174
+    port: 5672
+    username: admin
+    password: 123456
+    listener:
+      simple:
+        acknowledge-mode: none
+queueName: emailProd.queue

+ 13 - 0
src/main/resources/application-prodNetOut.yml

@@ -0,0 +1,13 @@
+spring: # rabbitmq
+  rabbitmq:
+    host: 47.101.137.223
+    port: 5672
+    username: admin
+    password: 123456
+    listener:
+      simple:
+        acknowledge-mode: none
+queueName: emailProd.queue
+# 设置手动确认(ack) Queue -> C
+#  rabbitmq.listener.simple.acknowledge-mode: manual
+#  rabbitmq.listener.simple.prefetch: 100

+ 7 - 0
src/main/resources/application-testNetIn.yml

@@ -0,0 +1,7 @@
+spring: # rabbitmq
+  rabbitmq:
+    host: 172.27.247.174
+    port: 5672
+    username: admin
+    password: 123456
+queueName: emailTest.queue

+ 7 - 0
src/main/resources/application-testNetOut.yml

@@ -0,0 +1,7 @@
+spring: # rabbitmq
+  rabbitmq:
+    host: 47.101.137.223
+    port: 5672
+    username: admin
+    password: 123456
+queueName: emailTest.queue

+ 17 - 16
src/main/resources/application.yml

@@ -6,30 +6,31 @@ spring:
   thymeleaf:
     cache: false
     mode: HTML5
+  profiles:
+    active: dev
     # 使用 smtp 协议
   mail.protocol: smtp
-  mail.host: smtp.qq.com
-  mail.port: 587
-  mail.username: 2232623707@qq.com
+  mail.host: smtp.exmail.qq.com
+  mail.port: 465
+  mail.username: xiaoshikeji@china-wispro.com
   # 授权码
-  mail.password: tcofjmtemsmedibf
+  mail.password: XS202211ever
   mail.test-connection: false
-  mail.properties.mail.smtp.auth: false
+  mail.properties.mail.smtp.auth: true
   mail.properties.mail.debug: false
   mail.properties.mail.mime.splitlongparameters: false
   mail.default-encoding: UTF-8
-# rabbitmq
-  rabbitmq.host: 47.101.137.223
-  rabbitmq.port: 5672
-  rabbitmq.username: admin
-  rabbitmq.password: 123456
-  # 开启confirms回调 P -> Exchange
-  rabbitmq.prabbitmq.publisher-confirms: true
-  # 开启returnedMessage回调 Exchange -> Queue
-  rabbitmq.publisher-returns: true
+  mail.properties:
+       mail:
+         smtp:
+           auth: true
+           socketFactory:
+             class: javax.net.ssl.SSLSocketFactory
+           starttls:
+             enable: true
   # 设置手动确认(ack) Queue -> C
-  rabbitmq.listener.simple.acknowledge-mode: manual
-  rabbitmq.listener.simple.prefetch: 100
+#  rabbitmq.listener.simple.acknowledge-mode: manual
+#  rabbitmq.listener.simple.prefetch: 100
 
 authorUrl: http://192.168.0.56:8880
 

+ 66 - 0
src/main/resources/mail/Synery.html

@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="description" content="email code">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>邮件</title>
+</head>
+<!--邮箱验证码模板-->
+<body>
+<div style="background-color:#ECECEC; padding: 35px;">
+    <table style="width: 800px;height: 100%; margin: 0 auto; text-align: left; position: relative; border-radius: 5px;font-size: 14px; font-family:微软雅黑, 黑体,serif; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0 0 5px; border-collapse: collapse; background: #fff initial initial initial initial;">
+        <tbody>
+        <tr>
+            <th style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: RGB(148,0,211); background-color: RGB(148,0,211); border-radius: 5px 5px 0 0;">
+                <img src="cid:logo" alt="logo" style="width: 110px; height: 35px;">
+            </th>
+        </tr>
+        <tr>
+            <td style="word-break:break-all">
+                <div style="padding:25px 35px 40px; background-color:#fff;opacity:0.8;">
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px; font-size: medium; ">
+                                尊敬的用户 {0}:
+                            </span>
+                        </span>
+                    </h2>
+                    <!-- 中文 -->
+                    <p>您好! 请确认您根据识别码,点击下方链接修改并确认您的专利报告信息</p>
+                    <p><span style="font-size:18px;font-weight:800">识别码:</span><span style="color: #ff8c00; ">{1}</span>
+                    </p>
+<a href={2} target="_blank" rel="noopener">{2}</a>
+<p>如果以上链接无法点击,请将链接地址复制到浏览器中打开</p>
+                    <br>
+                    <!-- 英文 -->
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px;  font-size: medium; ">
+                                Dear user :
+                            </span>
+                        </span>
+                    </h2>
+                    <p>Hello! Please confirm that you have amended and confirmed your patent report information according to the identification code, clicking on the link below
+                    </p>
+<p><span style="font-size:18px;font-weight:800">Identification number:</span><span style="color: #ff8c00; ">{1}</span>
+<p><a href={2} target="_blank" rel="noopener">{2}</a></p>
+<p>If the above link cannot be clicked, copy the link address to your browser to open it</p>
+                    <div style="width:100%;margin:0 auto;">
+                        <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;">
+                            <p>威世博团队</p>
+                            <p>如果您有其他使用上的问题,请联系我们:********</p>
+                            <br>
+                            <p>此为系统邮件,请勿回复<br>Please do not reply to this system email
+                            </p>
+                        </div>
+                    </div>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+</body>
+</html>

+ 67 - 0
src/main/resources/mail/SyneryInside.html

@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="description" content="email code">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>邮件</title>
+</head>
+<!--邮箱验证码模板-->
+<!-- 协同(有账号)邮件模板 -->
+<body>
+<div style="background-color:#ECECEC; padding: 35px;">
+    <table style="width: 800px;height: 100%; margin: 0 auto; text-align: left; position: relative; border-radius: 5px;font-size: 14px; font-family:微软雅黑, 黑体,serif; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0 0 5px; border-collapse: collapse; background: #fff initial initial initial initial;">
+        <tbody>
+        <tr>
+            <th style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: RGB(148,0,211); background-color: RGB(148,0,211); border-radius: 5px 5px 0 0;">
+                <img src="cid:logo" alt="logo" style="width: 110px; height: 35px;">
+            </th>
+        </tr>
+        <tr>
+            <td style="word-break:break-all">
+                <div style="padding:25px 35px 40px; background-color:#fff;opacity:0.8;">
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px; font-size: medium; ">
+                                尊敬的用户 {0}:
+                            </span>
+                        </span>
+                    </h2>
+                    <!-- 中文 -->
+                    <p>您好! 请点击下方链接或直接登录报告系统修改并确认您的专利报告信息</p>
+                    <!-- <p><span style="font-size:18px;font-weight:800">识别码:</span><span style="color: #ff8c00; ">{1}</span> -->
+                    </p>
+<a href="http://192.168.0.55:8085/customer_review" target="_blank" rel="noopener">{1}</a>
+<p>如果以上链接无法点击,请将链接地址复制到浏览器中打开,也可直接登录报告系统->任务管理->我处理页面进行查看处理</p>
+                    <br>
+                    <!-- 英文 -->
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px;  font-size: medium; ">
+                                Dear user :
+                            </span>
+                        </span>
+                    </h2>
+                    <p>Hello! Please click the link below or directly log in to the report system to modify and confirm your patent report information
+                    </p>
+<!-- <p><span style="font-size:18px;font-weight:800">Identification number:</span><span style="color: #ff8c00; ">{1}</span> -->
+<p><a href="http://192.168.0.55:8085/customer_review" target="_blank" rel="noopener"></a></p>
+<p>If the above link cannot be clicked, please copy the link address to the browser to open it, or directly log in to the report system ->task management ->My processing page to view and process</p>
+                    <div style="width:100%;margin:0 auto;">
+                        <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;">
+                            <p>威世博团队</p>
+                            <p>如果您有其他使用上的问题,请联系我们:********</p>
+                            <br>
+                            <p>此为系统邮件,请勿回复<br>Please do not reply to this system email
+                            </p>
+                        </div>
+                    </div>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+</body>
+</html>

+ 65 - 0
src/main/resources/mail/SyneryTo.html

@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="description" content="email code">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>邮件</title>
+</head>
+<!--邮箱验证码模板-->
+<!-- 协同抄送人邮箱模板 -->
+<body>
+<div style="background-color:#ECECEC; padding: 35px;">
+    <table style="width: 800px;height: 100%; margin: 0 auto; text-align: left; position: relative; border-radius: 5px;font-size: 14px; font-family:微软雅黑, 黑体,serif; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0 0 5px; border-collapse: collapse; background: #fff initial initial initial initial;">
+        <tbody>
+        <tr>
+            <th style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: RGB(148,0,211); background-color: RGB(148,0,211); border-radius: 5px 5px 0 0;">
+                <img src="cid:logo" alt="logo" style="width: 110px; height: 35px;">
+            </th>
+        </tr>
+        <tr>
+            <td style="word-break:break-all">
+                <div style="padding:25px 35px 40px; background-color:#fff;opacity:0.8;">
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px; font-size: medium; ">
+                                尊敬的用户 {0}:
+                            </span>
+                        </span>
+                    </h2>
+                    <!-- 中文 -->
+                    <p>{1}<span>发起了协同任务,</span>由协同人{2}<span></span>进行处理</p>
+                    <p>主题:</p>
+                    <p>期待完成时间:</p>
+                    <p>备注:</p>
+                    <br>
+                    <!-- 英文 -->
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px;  font-size: medium; ">
+                                Dear user :
+                            </span>
+                        </span>
+                    </h2>
+                    <p>某某<span>Initiated a collaborative task,</span>By the collaborator某某<span></span>Processing</p>
+                    <p>Theme:</p>
+                    <p>Expected completion time:</p>
+                    <p>Remarks:</p>
+                    <div style="width:100%;margin:0 auto;">
+                        <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;">
+                            <p>威世博团队</p>
+                            <p>如果您有其他使用上的问题,请联系我们:********</p>
+                            <br>
+                            <p>此为系统邮件,请勿回复<br>Please do not reply to this system email
+                            </p>
+                        </div>
+                    </div>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+</body>
+</html>

+ 54 - 0
src/main/resources/mail/eTask.html

@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="description" content="email code">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>邮件</title>
+</head>
+<!--邮箱验证码模板-->
+<body>
+<div style="background-color:#ECECEC; padding: 35px;">
+    <table style="width: 800px;height: 100%; margin: 0 auto; text-align: left; position: relative; border-radius: 5px;font-size: 14px; font-family:微软雅黑, 黑体,serif; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0 0 5px; border-collapse: collapse; background: #fff initial initial initial initial;">
+        <tbody>
+        <tr>
+            <th style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: RGB(148,0,211); background-color: RGB(148,0,211); border-radius: 5px 5px 0 0;">
+                <img src="cid:logo" alt="logo" style="width: 110px; height: 35px;">
+            </th>
+        </tr>
+        <tr>
+            <td style="word-break:break-all">
+                <div style="padding:25px 35px 40px; background-color:#fff;opacity:0.8;">
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px; font-size: medium; ">
+                                尊敬的用户 {0}:
+                            </span>
+                        </span>
+                    </h2>
+                    <!-- 中文 -->
+                    <p>您好! 用户{1}给您添加了一个{2}任务,截止时间为{3}</p>
+                    <p><span style="font-size:18px;font-weight:800">请打开地址:</span><span style="color: #ff8c00; ">{4}</span>
+                    </p>
+                    <br>
+                  
+    
+                    <div style="width:100%;margin:0 auto;">
+                        <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;">
+                            <p>威世博团队</p>
+                            <p>如果您有其他使用上的问题,请联系我们:********</p>
+                            <br>
+                            <p>此为系统邮件,请勿回复<br>Please do not reply to this system email
+                            </p>
+                        </div>
+                    </div>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+</body>
+</html>
+

+ 53 - 0
src/main/resources/mail/eTaskConfirm.html

@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="description" content="email code">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>邮件</title>
+</head>
+<!--邮箱验证码模板-->
+<body>
+<div style="background-color:#ECECEC; padding: 35px;">
+    <table style="width: 800px;height: 100%; margin: 0 auto; text-align: left; position: relative; border-radius: 5px;font-size: 14px; font-family:微软雅黑, 黑体,serif; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0 0 5px; border-collapse: collapse; background: #fff initial initial initial initial;">
+        <tbody>
+        <tr>
+            <th style="height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: RGB(148,0,211); background-color: RGB(148,0,211); border-radius: 5px 5px 0 0;">
+                <img src="cid:logo" alt="logo" style="width: 110px; height: 35px;">
+            </th>
+        </tr>
+        <tr>
+            <td style="word-break:break-all">
+                <div style="padding:25px 35px 40px; background-color:#fff;opacity:0.8;">
+                    <h2 style="margin: 5px 0; ">
+                        <span style="line-height: 20px;  color: #333333; ">
+                            <span style="line-height: 22px; font-size: medium; ">
+                                尊敬的用户 {0}:
+                            </span>
+                        </span>
+                    </h2>
+                    <!-- 中文 -->
+                    <p>您好! 协同任务{1},协同人已经完成!请在任务管理-我处理的中确认结果</p>
+                    </p>
+                    <br>
+                  
+    
+                    <div style="width:100%;margin:0 auto;">
+                        <div style="padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;">
+                            <p>威世博团队</p>
+                            <p>如果您有其他使用上的问题,请联系我们:********</p>
+                            <br>
+                            <p>此为系统邮件,请勿回复<br>Please do not reply to this system email
+                            </p>
+                        </div>
+                    </div>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+</body>
+</html>
+