From 06249d0408e9bcff181e9045385d478e0247eb32 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Mon, 21 Feb 2022 18:07:39 +0800 Subject: [PATCH] =?UTF-8?q?[manager,common]=E9=82=AE=E4=BB=B6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BC=98=E5=8C=96=EF=BC=8Cfix=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E6=9C=AA=E8=BD=AC=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/usthe/common/util/CommonUtil.java | 15 + .../manager/service/impl/MailServiceImpl.java | 9 +- .../main/resources/templates/mailAlarm.html | 1190 ++++++++++++----- 3 files changed, 896 insertions(+), 318 deletions(-) diff --git a/common/src/main/java/com/usthe/common/util/CommonUtil.java b/common/src/main/java/com/usthe/common/util/CommonUtil.java index 7b25c28..298a359 100644 --- a/common/src/main/java/com/usthe/common/util/CommonUtil.java +++ b/common/src/main/java/com/usthe/common/util/CommonUtil.java @@ -62,4 +62,19 @@ public class CommonUtil { return m.find(); } + /** + * 告警级别文字转换 + * @param priority 告警级别 + * @return 告警级别文字 + */ + public static String transferAlertPriority(byte priority) { + String priorityMsg = "警告告警"; + switch (priority) { + case 0: priorityMsg = "紧急告警"; break; + case 1: priorityMsg = "严重告警"; break; + case 2: priorityMsg = "警告告警"; break; + default: break; + } + return priorityMsg; + } } diff --git a/manager/src/main/java/com/usthe/manager/service/impl/MailServiceImpl.java b/manager/src/main/java/com/usthe/manager/service/impl/MailServiceImpl.java index 6beceab..640c491 100644 --- a/manager/src/main/java/com/usthe/manager/service/impl/MailServiceImpl.java +++ b/manager/src/main/java/com/usthe/manager/service/impl/MailServiceImpl.java @@ -1,9 +1,9 @@ package com.usthe.manager.service.impl; import com.usthe.common.entity.alerter.Alert; +import com.usthe.common.util.CommonUtil; import com.usthe.manager.service.MailService; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.thymeleaf.TemplateEngine; import org.thymeleaf.context.Context; @@ -16,7 +16,6 @@ import javax.annotation.Resource; * @author 花城 * @version 1.0 * @date 2022/2/19 6:13 下午 - * @Description */ @Slf4j @Service @@ -30,9 +29,9 @@ public class MailServiceImpl implements MailService { // 引入thymeleaf上下文参数渲染页面 Context context = new Context(); context.setVariable("target",alert.getTarget()); - context.setVariable("ID",alert.getMonitorId()); - context.setVariable("name",alert.getMonitorName()); - context.setVariable("priority",alert.getPriority()); + context.setVariable("monitorId",alert.getMonitorId()); + context.setVariable("monitorName",alert.getMonitorName()); + context.setVariable("priority", CommonUtil.transferAlertPriority(alert.getPriority())); context.setVariable("content",alert.getContent()); return templateEngine.process("mailAlarm", context); } diff --git a/manager/src/main/resources/templates/mailAlarm.html b/manager/src/main/resources/templates/mailAlarm.html index 0fd375b..fa994c3 100644 --- a/manager/src/main/resources/templates/mailAlarm.html +++ b/manager/src/main/resources/templates/mailAlarm.html @@ -1,323 +1,887 @@ - - - - + + - - - - + - -
-
-


-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- TanCloud探云-监控告警 -

-
-
-

- 告警通知 -

-
-
-

- Alarm notification -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- TanCloud探云 -

-
-
-
- -
-
-
-
-


-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- 告警目标对象:
-     所属监控ID:
-     所属监控名称:
-     告警级别:
-     告警详情:
-
-

-

-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

TanCloud探云 

-


+ + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + +
+
+ + + + + + +
+ + + + + + +
+
+ TANCLOUD +
+
+
+
+
+ + + + + + + + + + + + +
+
+
+ + + + + + +
+ + + + + + +
+ + + + + + +
+
+ 告警通知 +
+
+
+
+
+ +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+ 告警目标对象: + +
+ 所属监控ID: + + +
+ 所属监控名称: + + +
+ 告警级别: + +
+
+
+
+
+
+
+
+ + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + +
+ 登入控制台 +
+
+
+
+
+
+ + + + + + +
+ + + + + + +
+
+
+
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + +
+ +
+ 探云 + tancloud.cn +
+
+ + + + + + + +
+ +
+ 赫兹跳动 + hertzbeat.com +
+
+
+
+
+
+
+
+
+ + + + + + +
+ + + + + + +
+
如果您不想再接收TanCloud的「告警通知」邮件,或者需要设置其他人接收,点此设置订阅。 If you do not wish to receive any more emails, you can unsubscribe here.
+
+
+
+
+
+
\ No newline at end of file