monitorMessages2 = new LinkedBlockingQueue<>(2<<20);\n" +
+ " private static final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);\n" +
+ //TODO Parem
+ "%s\n" +
+ //TODO Static
+ "static{%s}\n" +
+ " static {\n" +
+ " String fileName = \"pod-scale-alarm.html\";\n" +
+ " InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);\n" +
+ " if(inputStream==null){\n" +
+ " System.err.println(\"文件读取失败\"+fileName);\n" +
+ " }else {\n" +
+ " BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream));\n" +
+ " StringBuilder buffers = new StringBuilder();\n" +
+ " String line = \"\";\n" +
+ " try {\n" +
+ " while ((line = fileReader.readLine()) != null) {\n" +
+ " buffers.append(line);\n" +
+ " }\n" +
+ " buffer = buffers.toString();\n" +
+ " } catch (Exception e) {\n" +
+ " System.err.println(\"读取文件失败,fileName:\"+fileName+ e.toString());\n" +
+ " } finally {\n" +
+ " try {\n" +
+ " inputStream.close();\n" +
+ " fileReader.close();\n" +
+ " } catch (IOException e) {\n" +
+ " e.printStackTrace();\n" +
+ " }\n" +
+ " }\n" +
+ " }" +
+ " for (int i = 0; i < 10; i++) {\n" +
+ " scheduledExecutorService.scheduleWithFixedDelay(()->{\n" +
+ " //弹出队顶元素,队列为空时返回null\n" +
+ " MonitorMessage monitorMessage = monitorMessages.poll();\n" +
+ " if(monitorMessage!=null){\n" +
+ " send(monitorMessage.getTitle(),\n" +
+ " monitorMessage.getPloy(),\n" +
+ " monitorMessage.getLinkInfo(),\n" +
+ " monitorMessage.getMessageType());\n" +
+ " }\n" +
+ " },0,1000, TimeUnit.MILLISECONDS);\n" +
+ " }\n" +
+ " scheduledExecutorService.scheduleWithFixedDelay(()->{\n" +
+ " //弹出队顶元素,队列为空时返回null\n" +
+ " MonitorMessage monitorMessage = monitorMessages2.poll();\n" +
+ " if(monitorMessage!=null){\n" +
+ " send(monitorMessage.getTitle(),\n" +
+ " monitorMessage.getPloy(),\n" +
+ " monitorMessage.getLinkInfo(),\n" +
+ " monitorMessage.getMessageType());\n" +
+ " }\n" +
+ " },0,10, TimeUnit.SECONDS);\n" +
+ " }" +
+ " @Override\n" +
+ " public void sendEmail(MonitorMessage monitorMessage) {\n" +
+ " try {\n" +
+ " monitorMessages.add(monitorMessage);\n" +
+ " }catch (IllegalStateException e){\n" +
+ " monitorMessages2.offer(monitorMessage);\n" +
+ " }" +
+ " }\n" +
+ //TODO 下面是要添加的方法 MethodContent
+ " public static void send(String title, String content, String linkInfo, int type) {\n" +
+ "System.err.println(\"send begin\");\n" +
+ " %s\n" +
+ "System.err.println(\"send ok\");\n" +
+ " }\n" +
+ "private static String buildContent(String title,String body,int isDanger) throws IOException {\n" +
+ " String contentText = body+\"以下是物联网设备详细信息, 敬请查看.
below is the information of service instance scale, please check. \";\n" +
+ " String header = \"分区(Namespace) | 服务(Service) | 伸缩结果(Scale Result) | 伸缩原因(Scale Reason) | 当前实例数(Pod instance number) | \";\n" +
+ " String emailHeadColor;\n" +
+ " switch (isDanger){\n" +
+ " case MessageType.ERROR:\n" +
+ " emailHeadColor = \"#cc1d0c\";\n" +
+ " break;\n" +
+ " case MessageType.SUCCESS:\n" +
+ " emailHeadColor = \"#10fa81\";\n" +
+ " break;\n" +
+ " case MessageType.WANNER:\n" +
+ " emailHeadColor = \"yellow\";\n" +
+ " break;\n" +
+ " default:\n" +
+ " emailHeadColor = \"#aaa\";\n" +
+ " }\n" +
+ " String date = DateFormatUtils.format(new Date(), \"yyyy/MM/dd HH:mm:ss\");\n" +
+ " String linesBuffer = \"湖南分区 | 集群服务 | 服务暂停 | 异常 | 2 |
\";\n" +
+ " String htmlText = MessageFormat.format(buffer, title,emailHeadColor, contentText, date, header, linesBuffer);\n" +
+ " htmlText = htmlText.replaceAll(\"\", \" | \");\n" +
+ " htmlText = htmlText.replaceAll(\" | \", \"
\");" +
+ " return htmlText;\n" +
+ " }" +
+ "}";
+
+ @Override
+ public T createStub(String imports ,String className,String parem,String statics , String methodContent) throws Exception{
+ className = className + "Stub";
+ String source = String.format(STUB_SOURCE_TEMPLATE, imports, className, parem,statics, methodContent);
+ String stubFullName = "cn.ljobin.bibi.utils.email.impl." + className;
+ //编译源代码
+ JavaStringCompiler compiler = new JavaStringCompiler();
+ try {
+ Map results = compiler.compile(className + ".java", source);
+ // 加载编译好的类
+ Class> clazz = compiler.loadClass(stubFullName, results);
+ // 把实例化
+ BaseMailSend stubInstance = (BaseMailSend) clazz.newInstance();
+ log.info(stubInstance.toString());
+ // 返回这个桩
+ return (T) stubInstance;
+ } catch (IOException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/AnnotationUtils.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/AnnotationUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..9412d1f8cc13d95492db0f1fbf89889df5b38554
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/AnnotationUtils.java
@@ -0,0 +1,158 @@
+package cn.ljobin.bibi.utils;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * @program: IoT-Plat
+ * @description: 包装验证类
+ * @author: Mr.Liu
+ * @create: 2020-04-11 16:25
+ **/
+public class AnnotationUtils {
+ /**
+ * 反射包装QueryWrapper,自动将简单的条件查询 映射好
+ * 构建where后面的条件
+ */
+ public QueryWrapper wapperData (QueryWrapper queryWrapper,T o){
+ Class clazz = o.getClass();
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field f : fields) {
+ TableField tableField = f.getAnnotation(TableField.class);
+ //没有注解表示肯定存在这个字段在数据库
+ if(tableField==null){
+ TableId tableId = f.getAnnotation(TableId.class);
+ String name = "";
+ if(tableId != null){
+ String n = tableId.value();
+ if("".equals(n)){
+ name = f.getName();
+ }else {
+ name = n;
+ }
+ }else {
+ name = f.getName();
+ }
+ Object value = getValue(o,f);
+ if(value!=null && value != ""){
+ //System.out.println(name+"---"+value);
+ queryWrapper.eq(name,value);
+ }
+ continue;
+ }
+ //如果注解明确说明是不存在的,就不管了
+ if(!tableField.exist()){
+ continue;
+ }
+ //获取注解中的value值,及数据库中字段名称
+ String name = tableField.value();
+ if(!"".equals(name)){
+ Object value = getValue(o,f);
+ if(Objects.nonNull(value)){
+ //System.out.println(name+"---"+value);
+ queryWrapper.eq(name,value);
+ }
+ }
+ }
+ return queryWrapper;
+ }
+ private Object getValue(T model,Field f){
+ f.setAccessible(true);
+ // 获取属性的类型
+ String type = f.getGenericType().toString();
+ try {
+ // 如果type是类类型,则前面包含"class ",后面跟类名
+ if ("class java.lang.String".equals(type)) {
+ //获取属性值
+ String value = (String) f.get(model);
+ if("".equals(value)){
+ return null;
+ }
+ return value;
+ }
+ if ("class java.lang.Integer".equals(type)) {
+ //获取属性值
+ return (Integer) f.get(model);
+ }
+ if ("class java.lang.Long".equals(type)) {
+ //获取属性值
+ return (Long) f.get(model);
+ }
+ if ("class java.lang.Double".equals(type)) {
+ return (Double) f.get(model);
+ }
+ if ("class java.lang.Float".equals(type)) {
+ return (Float) f.get(model);
+ }
+ if ("class java.lang.Boolean".equals(type)) {
+ return (Boolean) f.get(model);
+ }
+ if ("class java.util.Date".equals(type)) {
+ return (Date) f.get(model);
+ }
+ // 如果有需要,可以仿照上面继续进行扩充,再增加对其它类型的判断
+ } catch (SecurityException | IllegalAccessException | IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ return null;
+ //下面是通过getXXX()方法获取的,不太灵活
+// // 获取属性的名字
+// String name = f.getName();
+// // 将属性的首字符大写,方便构造get,set方法
+// name = name.substring(0, 1).toUpperCase() + name.substring(1);
+// // 获取属性的类型
+// String type = f.getGenericType().toString();
+// try {
+// // 如果type是类类型,则前面包含"class ",后面跟类名
+// if ("class java.lang.String".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// System.out.println((String) m.invoke(model));
+// return (String) m.invoke(model);
+// }
+// if ("class java.lang.Integer".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// return (Integer) m.invoke(model);
+// }
+// if ("class java.lang.Long".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// System.out.println((Long) m.invoke(model));
+// return (Long) m.invoke(model);
+// }
+// if ("class java.lang.Double".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// return (Double) m.invoke(model);
+// }
+// if ("class java.lang.Float".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// return (Float) m.invoke(model);
+// }
+// if ("class java.lang.Boolean".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// return (Boolean) m.invoke(model);
+// }
+// if ("class java.util.Date".equals(type)) {
+// Method m = model.getClass().getMethod("get" + name);
+// return (Date) m.invoke(model);
+// }
+// // 如果有需要,可以仿照上面继续进行扩充,再增加对其它类型的判断
+// }catch (NoSuchMethodException e) {
+// e.printStackTrace();
+// } catch (SecurityException e) {
+// e.printStackTrace();
+// } catch (IllegalAccessException e) {
+// e.printStackTrace();
+// } catch (IllegalArgumentException e) {
+// e.printStackTrace();
+// } catch (InvocationTargetException e) {
+// e.printStackTrace();
+// }
+// return null;
+ }
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/Log4JavaMail.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/Log4JavaMail.java
new file mode 100644
index 0000000000000000000000000000000000000000..8b1adc0564938e6c8bed7169a9bdc28ece92b41e
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/Log4JavaMail.java
@@ -0,0 +1,88 @@
+package cn.ljobin.bibi.utils;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.slf4j.Logger;
+import java.io.PrintStream;
+
+/**
+ * @program: Iot-Monitor
+ * @description:
+ * @author: Mr.Liu
+ * @create: 2020-06-02 21:02
+ **/
+public class Log4JavaMail extends PrintStream {
+ private static byte[] CRLF = new byte[] { 13, 10 };
+ private ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ private Logger actualLog;
+ private String charset;
+ private boolean hitData;
+
+ public String getCharset() {
+ return charset;
+ }
+
+ public void setCharset(String charset) {
+ this.charset = charset;
+ }
+
+ public Log4JavaMail(Logger log) {
+ super(System.out);
+ this.actualLog = log;
+ }
+
+ public Log4JavaMail(Logger log, String charset) {
+ super(System.out);
+ this.actualLog = log;
+ this.charset = charset;
+ }
+
+ @Override
+ public void write(byte buf[], int off, int len) {
+ bos.write(buf, off, len);
+ //到过一行末尾,输出日志
+ if (len > 1) {
+ if (buf[off + len - 2] == CRLF[0]
+ && buf[off + len - 1] == CRLF[1]) {
+ flush();
+ }
+ }
+ }
+
+ @Override
+ public void flush() {
+ if (charset == null) {
+ charset = "utf-8";
+ }
+ try {
+ String msg = new String(bos.toByteArray(), charset);
+ //debug输出会加上换行符,所以去掉javamail加上的换行符。
+ if (msg.endsWith("\r\n")) {
+ msg = msg.substring(0, msg.length() - 2);
+ }
+
+ if (msg.equals("DATA")) {
+ hitData = true;
+ } else if (msg.equals(".\r\n")) {
+ hitData = false;
+ }
+
+ if (hitData) {
+ //data阶段输出邮件内容,设置为trace级别.
+ actualLog.trace(msg);
+ } else {
+ actualLog.debug(msg);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ bos.reset();
+ }
+
+ @Override
+ public void println(String x) {
+ actualLog.debug(x);
+ }
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/BaseMailSend.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/BaseMailSend.java
new file mode 100644
index 0000000000000000000000000000000000000000..617acb48f46dd7dddddb258c5189e10caadcc24f
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/BaseMailSend.java
@@ -0,0 +1,18 @@
+package cn.ljobin.bibi.utils.email;
+
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+
+/**
+ * @program: Iot-Monitor
+ * @description:
+ * @author: Mr.Liu
+ * @create: 2020-06-02 15:34
+ **/
+
+public interface BaseMailSend {
+ /**
+ * 发送邮件
+ * @param monitorMessage 邮件标题
+ */
+ public void sendEmail(MonitorMessage monitorMessage);
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..4cdf9b74b9e97c7ade916ba6a6584eeda7488717
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.java
@@ -0,0 +1,104 @@
+package cn.ljobin.bibi.utils.email.impl;
+
+/**
+ * @program: guns
+ * @description:
+ * @author: Mr.Liu
+ * @create: 2019-09-12 18:02
+ **/
+
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import cn.ljobin.bibi.utils.Log4JavaMail;
+import cn.ljobin.bibi.utils.email.BaseMailSend;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
+
+@Service("sendQqMailUtil")
+@Slf4j
+public class SendQqMailUtil implements BaseMailSend {
+ private String sendUserEmail = "2018214546@qq.com";
+ private String qqPassword = "ujpiarknosuybadb";
+ private static volatile Properties properties;
+ private static Properties getPropertiesInstance(){
+ if(properties==null){
+ synchronized (Properties.class){
+ if(properties==null){
+ Properties properties2 = new Properties();
+ // 连接协议
+ properties2.put("mail.transport.protocol", "smtp");
+ // 主机名
+ properties2.put("mail.smtp.host", "smtp.qq.com");
+ // 端口号
+ properties2.put("mail.smtp.port", 465);
+ properties2.put("mail.smtp.auth", "true");
+ // 设置是否使用ssl安全连接 ---一般都使用
+ properties2.put("mail.smtp.ssl.enable", "true");
+ // 设置是否显示debug信息 true 会在控制台显示相关信息
+ properties2.put("mail.debug", "false");
+ properties = properties2;
+ }
+ }
+ }
+ return properties;
+ }
+ private ExecutorService executorService = Executors.newFixedThreadPool(15);
+
+ /**
+ * TODO 这里应该对相同标题和内容的邮箱进行整合,一起发送
+ * @param title 邮件标题
+ * @param content 邮件类容
+ * @param linkInfo 邮件接收端地址
+ */
+ @Override
+ public void sendEmail(MonitorMessage monitorMessage){
+ executorService.submit(()->{
+ Transport transport=null;
+ Session session=null;
+ try {
+ // 得到回话对象
+ session = Session.getInstance(getPropertiesInstance());
+ session.setDebug(false);
+ session.setDebugOut(new Log4JavaMail(log,"utf-8"));
+ // 获取邮件对象
+ Message message = new MimeMessage(session);
+ // 设置发件人邮箱地址
+ message.setFrom(new InternetAddress(sendUserEmail));
+ // 设置收件人邮箱地址
+ message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress(monitorMessage.getLinkInfo())});
+ //message.setRecipient(Message.RecipientType.TO, new InternetAddress("xxx@qq.com"));//一个收件人
+ // 设置邮件标题
+ message.setSubject(monitorMessage.getTitle());
+ // 设置邮件内容
+ message.setText(monitorMessage.getPloy());
+ // 得到邮差对象
+ transport = session.getTransport();
+ // 连接自己的邮箱账户
+ // 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
+ //授权码申请参考:https://baijiahao.baidu.com/s?id=1552315463915496&wfr=spider&for=pc
+ transport.connect(sendUserEmail, qqPassword);
+ // 发送邮件
+ transport.sendMessage(message, message.getAllRecipients());
+ }catch (MessagingException e){
+ log.error(e.toString());
+ }finally {
+ if(transport!=null){
+ try {
+ transport.close();
+ } catch (MessagingException e) {
+ log.error(e.toString());
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8d740c87d7f12600b6f32cd11bcf877f9ac0edb
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.java
@@ -0,0 +1,179 @@
+package cn.ljobin.bibi.utils.email.impl;
+
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import cn.ljobin.bibi.enums.MessageType;
+import cn.ljobin.bibi.utils.email.BaseMailSend;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Objects;
+import java.util.Properties;
+import java.io.IOException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+/**
+ * @program: Iot-Monitor
+ * @description:
+ * @author: Mr.Liu
+ * @create: 2020-06-02 21:23
+ **/
+@Service("sprBooEmailUtil")
+@Slf4j
+public class SprBooEmailUtil implements BaseMailSend {
+ private static String sendUserEmail = "2018214546@qq.com";
+ private static String qqPassword = "ujpiarknosuybadb";
+ private static JavaMailSenderImpl javaMailSender;
+ private static String buffer;
+ /**保存从activemq获取的消息*1024*1024 = 1048576*/
+ public static final LinkedBlockingQueue monitorMessages = new LinkedBlockingQueue<>(2<<20);
+ /**上面那个满了就保存到下面这个**/
+ public static final LinkedBlockingQueue monitorMessages2 = new LinkedBlockingQueue<>(2<<20);
+ public static final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
+ static {
+ //加载邮件html模板
+ String fileName = "pod-scale-alarm.html";
+ InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
+ if(inputStream==null){
+ log.error("{}文件读取失败",fileName);
+ }else {
+ BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream));
+ StringBuilder buffers = new StringBuilder();
+ String line = "";
+ try {
+ while ((line = fileReader.readLine()) != null) {
+ buffers.append(line);
+ }
+ buffer = buffers.toString();
+ } catch (Exception e) {
+ log.error("读取文件失败,fileName:{}", fileName, e);
+ } finally {
+ try {
+ inputStream.close();
+ fileReader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ static {
+ javaMailSender = new JavaMailSenderImpl();
+ javaMailSender.setUsername(sendUserEmail);
+ javaMailSender.setPassword(qqPassword);
+ javaMailSender.setHost("smtp.qq.com");
+ javaMailSender.setPort(587);
+ javaMailSender.setDefaultEncoding("UTF-8");
+ Properties props = new Properties();
+ props.setProperty("mail.smtp.host", "smtp.qq.com");
+ props.setProperty("mail.transport.protocol", "smtp");
+ props.setProperty("mail.smtp.auth", "true");
+ props.setProperty("mail.smtp.connectiontimeout", "20000");
+ props.setProperty("mail.smtp.timeout", "20000");
+ javaMailSender.setJavaMailProperties(props);
+ }
+ static {
+ for (int i = 0; i < 10; i++) {
+ scheduledExecutorService.scheduleWithFixedDelay(()->{
+ //弹出队顶元素,队列为空时返回null
+ MonitorMessage monitorMessage = monitorMessages.poll();
+ if(monitorMessage!=null){
+ send(monitorMessage.getTitle(),
+ monitorMessage.getPloy(),
+ monitorMessage.getLinkInfo(),
+ monitorMessage.getMessageType());
+ }
+ },0,100, TimeUnit.MILLISECONDS);
+ }
+ scheduledExecutorService.scheduleWithFixedDelay(()->{
+ //弹出队顶元素,队列为空时返回null
+ MonitorMessage monitorMessage = monitorMessages2.poll();
+ if(monitorMessage!=null){
+ send(monitorMessage.getTitle(),
+ monitorMessage.getPloy(),
+ monitorMessage.getLinkInfo(),
+ monitorMessage.getMessageType());
+ }
+ },0,10, TimeUnit.SECONDS);
+ }
+ @Override
+ public void sendEmail(MonitorMessage monitorMessage) {
+ //send(monitorMessage.getTitle(), monitorMessage.getPloy(), monitorMessage.getLinkInfo(),monitorMessage.getMessageType());
+ try {
+ monitorMessages.add(monitorMessage);
+ }catch (IllegalStateException e){
+ monitorMessages2.offer(monitorMessage);
+ }
+ }
+ public static void send(String title, String content, String linkInfo, int type){
+ MimeMessage message = javaMailSender.createMimeMessage();
+ MimeMessageHelper helper = null;
+ try {
+ helper = new MimeMessageHelper(message, true, "UTF-8");
+ helper.setTo(new String[]{linkInfo});
+// helper.setCc("抄送人邮箱");
+ helper.setFrom(sendUserEmail);
+ helper.setSubject(title);
+ helper.setText(buildContent(title,content,type), true);
+ String alarmIconName = "success-alarm.png";
+ ClassPathResource img = new ClassPathResource(alarmIconName);
+ //设置图标
+ helper.addInline("icon-alarm", img);
+ /**邮件发送时间较久**/
+ long st1 = System.currentTimeMillis();
+ javaMailSender.send(message);
+ long st2 = System.currentTimeMillis();
+ log.info("发送耗时:{}",(st2-st1));
+ } catch (MessagingException | IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String buildContent(String title,String body,int isDanger) throws IOException {
+
+ String contentText = body+"以下是物联网设备详细信息, 敬请查看.
below is the information of service instance scale, please check. ";
+ //邮件表格header
+ String header = "分区(Namespace) | 服务(Service) | 伸缩结果(Scale Result) | 伸缩原因(Scale Reason) | 当前实例数(Pod instance number) | ";
+ //绿色
+ String emailHeadColor;
+ switch (isDanger){
+ case MessageType.ERROR:
+ emailHeadColor = "#cc1d0c";
+ break;
+ case MessageType.SUCCESS:
+ emailHeadColor = "#10fa81";
+ break;
+ case MessageType.WANNER:
+ emailHeadColor = "yellow";
+ break;
+ default:
+ emailHeadColor = "#aaa";
+ }
+ String date = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss");
+ //填充html模板中的五个参数
+ String linesBuffer = "" + "湖南分区" + " | " + "集群服务" + " | " + "服务暂停" + " | " +
+ "" + "异常" + " | " + "2" + " |
";
+ String htmlText = MessageFormat.format(buffer, title,emailHeadColor, contentText, date, header, linesBuffer);
+
+ //改变表格样式
+ htmlText = htmlText.replaceAll("", " | ");
+ htmlText = htmlText.replaceAll(" | ", "
");
+ return htmlText;
+ }
+
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..b0f61b9bd071b02d6552a0f04c2bb2fd388e270e
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.java
@@ -0,0 +1,22 @@
+package cn.ljobin.bibi.utils.kafkaconfig;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import static cn.stylefeng.roses.kernel.model.constants.ConfigPrefixConstants.LOG_PREFIX;
+
+/**
+ * @program: IoT-Plat
+ * @description: kafka消费者监听器
+ * @author: Mr.Liu
+ * @create: 2020-04-14 17:06
+ **/
+@Configuration
+@ConditionalOnProperty(prefix = LOG_PREFIX, value = "kafka", havingValue = "true")
+public class ComsumerConfig {
+ @Bean
+ public Listener listener() {
+ return new Listener();
+ }
+}
diff --git a/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/Listener.java b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/Listener.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b6230f1e06a2e99b7e30a9a0f59fd0e3a64ebb9
--- /dev/null
+++ b/saltice-monitor-common/src/main/java/cn/ljobin/bibi/utils/kafkaconfig/Listener.java
@@ -0,0 +1,61 @@
+package cn.ljobin.bibi.utils.kafkaconfig;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.kafka.annotation.TopicPartition;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+import static cn.stylefeng.roses.kernel.logger.constants.KafkaConstants.*;
+import static cn.stylefeng.roses.kernel.model.constants.ConfigPrefixConstants.LOG_PREFIX;
+
+/**
+ * @program: IoT-Plat
+ * @description:
+ * @author: Mr.Liu
+ * @create: 2020-04-14 11:07
+ **/
+@Service
+@Slf4j
+public class Listener {
+// /**
+// * LOG_TOPIC 消息接收
+// * @param recordList
+// */
+// @KafkaListener(id=LOG_TOPIC,
+// topicPartitions ={@TopicPartition(topic = LOG_TOPIC, partitions = { "0"})})
+// public void listen(List> recordList) {
+// recordList.forEach((record)->{
+// log.info("kafka的key: " + record.key());
+// log.info("kafka的value: " + new String(record.value()));
+// });
+// }
+//
+// /**
+// * TRACE_LOG_TOPIC 消息接收
+// * @param recordList
+// */
+// @KafkaListener(id=TRACE_LOG_TOPIC,
+// topicPartitions ={@TopicPartition(topic = TRACE_LOG_TOPIC, partitions = { "0"})})
+// public void listen2(List> recordList) {
+// recordList.forEach((record)->{
+// log.info("kafka的key: " + record.key());
+// log.info("kafka的value: " + new String(record.value()));
+// });
+// }
+//
+// /**
+// * TC_LOG_TOPIC 消息接收
+// * @param recordList
+// */
+// @KafkaListener(id=TC_LOG_TOPIC,
+// topicPartitions ={@TopicPartition(topic = TC_LOG_TOPIC, partitions = { "0"})})
+// public void listen3(List> recordList) {
+// recordList.forEach((record)->{
+// log.info("kafka的key: " + record.key());
+// log.info("kafka的value: " + new String(record.value()));
+// });
+// }
+}
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/constant/Status.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/constant/Status.class
new file mode 100644
index 0000000000000000000000000000000000000000..b8756e2e8a988f9e5327981ef867304d432f1d8c
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/constant/Status.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/AnnotationUtils.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/AnnotationUtils.class
new file mode 100644
index 0000000000000000000000000000000000000000..5016c084c88db19752c47870b0ee181e2c7da353
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/AnnotationUtils.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/Log4JavaMail.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/Log4JavaMail.class
new file mode 100644
index 0000000000000000000000000000000000000000..8e2ef7a1ae3bfc1501b53cd722996cba9d4fb614
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/Log4JavaMail.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/BaseMailSend.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/BaseMailSend.class
new file mode 100644
index 0000000000000000000000000000000000000000..97519594124014c3e9b9ff9935e462062cb37525
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/BaseMailSend.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.class
new file mode 100644
index 0000000000000000000000000000000000000000..5408c8bc970cbd81ccf1fee147645d5690593384
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SendQqMailUtil.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.class
new file mode 100644
index 0000000000000000000000000000000000000000..0baa0f9b55980ab68b4f7d022ff716a77d7a4121
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/email/impl/SprBooEmailUtil.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.class
new file mode 100644
index 0000000000000000000000000000000000000000..2c79d75135f02d79dc9ecde7c9ef6be8c2e4f314
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/ComsumerConfig.class differ
diff --git a/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/Listener.class b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/Listener.class
new file mode 100644
index 0000000000000000000000000000000000000000..a2fcc7be945413a8bdfc185c5351da3853c0a800
Binary files /dev/null and b/saltice-monitor-common/target/classes/cn/ljobin/bibi/utils/kafkaconfig/Listener.class differ
diff --git a/saltice-monitor-feign/pom.xml b/saltice-monitor-feign/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c7b3fe76692556685f9f8400cf3298c4c81a3e7d
--- /dev/null
+++ b/saltice-monitor-feign/pom.xml
@@ -0,0 +1,107 @@
+
+
+
+ 4.0.0
+
+ cn.ljobin.bibi
+ saltice-monitor-feign
+ 1.0-SNAPSHOT
+
+
+ cn.ljobin.bibi
+ IoT-monitor
+ 1.0-SNAPSHOT
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ cn.stylefeng.roses
+ kernel-model
+
+
+ cn.stylefeng.roses
+ kernel-core
+ provided
+
+
+
+
+
+
+
+ cn.stylefeng.roses
+ roses-system-api
+ 1.1.6
+
+
+ cn.stylefeng.roses
+ kernel-logger
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-hystrix
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/AuthUserComsumer.java b/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/AuthUserComsumer.java
new file mode 100644
index 0000000000000000000000000000000000000000..f61ff2fabd9ae003f656860e2f39cb8a33797d20
--- /dev/null
+++ b/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/AuthUserComsumer.java
@@ -0,0 +1,15 @@
+package cn.ljobin.bibi.feign;
+
+import cn.ljobin.bibi.feign.fallback.AuthUserComsumeuFallback;
+import cn.stylefeng.roses.kernel.model.api.AuthService;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * @program: IoT-Plat
+ * @description: 获取用户信息的
+ * @author: Mr.Liu
+ * @create: 2020-04-12 16:23
+ **/
+@FeignClient(value = "roses-system" , fallback = AuthUserComsumeuFallback.class)
+public interface AuthUserComsumer extends AuthService {
+}
diff --git a/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.java b/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..baa615824796b8693bdb04809979d489d13633f7
--- /dev/null
+++ b/saltice-monitor-feign/src/main/java/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.java
@@ -0,0 +1,88 @@
+package cn.ljobin.bibi.feign.fallback;
+
+import cn.ljobin.bibi.feign.AuthUserComsumer;
+import cn.stylefeng.roses.core.reqres.response.ResponseData;
+import cn.stylefeng.roses.kernel.logger.api.common.annotion.IotLog;
+import cn.stylefeng.roses.kernel.logger.api.common.state.LogType;
+import cn.stylefeng.roses.kernel.model.api.AuthService;
+import cn.stylefeng.roses.kernel.model.api.base.AppUserWarpper;
+import cn.stylefeng.roses.kernel.model.api.base.RpcBaseResponse;
+import cn.stylefeng.roses.kernel.model.auth.AbstractLoginUser;
+import cn.stylefeng.roses.kernel.model.auth.SysUser;
+import cn.stylefeng.roses.kernel.model.enums.SystemMenu;
+import cn.stylefeng.roses.system.api.context.LoginUser;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * @program: IoT-Plat
+ * @description: 失败回调
+ * @author: Mr.Liu
+ * @create: 2020-04-12 16:31
+ **/
+@Component
+@RequestMapping("/fallback/auth/api")
+public class AuthUserComsumeuFallback implements AuthUserComsumer {
+
+ @Override
+ @IotLog(value = "注册失败",type = LogType.FEIGN_DEFEAT)
+ public RpcBaseResponse register(AppUserWarpper appUserWarpper) {
+ return RpcBaseResponse.error("请稍后再试");
+ }
+
+ @Override
+ @IotLog(value = "更新头像失败",type = LogType.FEIGN_DEFEAT)
+ public RpcBaseResponse updateAvatar(MultipartFile files, String token) {
+ return RpcBaseResponse.error("请稍后再试");
+ }
+
+ @Override
+ @IotLog(value = "登陆失败",type = LogType.FEIGN_DEFEAT)
+ public RpcBaseResponse login(String account, String password, SystemMenu systemMenu) {
+ return RpcBaseResponse.error("请稍后再试");
+ }
+
+ @Override
+ @IotLog(value = "校验失败",type = LogType.FEIGN_DEFEAT)
+ public boolean checkToken(String token) {
+ return false;
+ }
+
+ @Override
+ @IotLog(value = "退出失败",type = LogType.FEIGN_DEFEAT)
+ public void logout(String token) {
+
+ }
+
+ @Override
+ @IotLog(value = "获取用户信息失败",type = LogType.FEIGN_DEFEAT)
+ public RpcBaseResponse getLoginUserByToken(String token) {
+ return RpcBaseResponse.error("请稍后再试");
+ }
+
+ @Override
+ public SysUser getUserByToken(String token) {
+ return null;
+ }
+
+ @Override
+ @IotLog(value = "获取用户ID失败",type = LogType.FEIGN_DEFEAT)
+ public Long getLoginUserIdByToken(String token) {
+ return null;
+ }
+
+ @Override
+ @IotLog(value = "更新用户信息失败",type = LogType.FEIGN_DEFEAT)
+ public RpcBaseResponse updateLoginUserByToken(String token, AppUserWarpper userWarpper) {
+ return RpcBaseResponse.error("请稍后再试");
+ }
+
+ @Override
+ public RpcBaseResponse updatePasswordByToken(String token, String password) {
+ return null;
+ }
+}
diff --git a/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/AuthUserComsumer.class b/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/AuthUserComsumer.class
new file mode 100644
index 0000000000000000000000000000000000000000..08d2b06a015e86ff7989fc4b6fee81da4a585561
Binary files /dev/null and b/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/AuthUserComsumer.class differ
diff --git a/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.class b/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.class
new file mode 100644
index 0000000000000000000000000000000000000000..a85a1a80d62f65fac860eb6cb7217fece84eaedc
Binary files /dev/null and b/saltice-monitor-feign/target/classes/cn/ljobin/bibi/feign/fallback/AuthUserComsumeuFallback.class differ
diff --git a/saltice-monitor-iot/pom.xml b/saltice-monitor-iot/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..22292c838b09409aab939f719afd23cf5b74b834
--- /dev/null
+++ b/saltice-monitor-iot/pom.xml
@@ -0,0 +1,98 @@
+
+
+
+ 4.0.0
+
+ cn.ljobin.bibi
+ saltice-monitor-iot
+ 1.0-SNAPSHOT
+
+
+ cn.ljobin.bibi
+ IoT-monitor
+ 1.0-SNAPSHOT
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-activemq
+
+
+ cn.stylefeng.roses
+ kernel-model
+
+
+ cn.stylefeng.roses
+ kernel-core
+ provided
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ cn.ljobin.bibi
+ saltice-monitor-api
+ 1.0-SNAPSHOT
+
+
+ cn.ljobin.bibi
+ saltice-monitor-common
+ 1.0-SNAPSHOT
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailMapper.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2397993e81e9699c69ab756062b37f081ea5a1b
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailMapper.java
@@ -0,0 +1,18 @@
+package cn.ljobin.bibi.mapper;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.pot.TbIoterminal;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 盆栽信息Mapper接口
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Mapper
+public interface EmailMapper extends BaseMapper
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailRePushMapper.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailRePushMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..69c3e5184b32d216a351621a79498fcd99862700
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/EmailRePushMapper.java
@@ -0,0 +1,17 @@
+package cn.ljobin.bibi.mapper;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorEmailRepush;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 盆栽信息Mapper接口
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Mapper
+public interface EmailRePushMapper extends BaseMapper
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/MonitorMessageMapper.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/MonitorMessageMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..1b2887e75f34476b0eddefd6866c279ff67218e1
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/MonitorMessageMapper.java
@@ -0,0 +1,17 @@
+package cn.ljobin.bibi.mapper;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 盆栽信息Mapper接口
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Mapper
+public interface MonitorMessageMapper extends BaseMapper
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0a53df721c73c022f1afc39e530e8b669fb1a16
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, linkInfo, `type`, body, pushTime
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..62a2bd814ccd6594be67a8a8321e2e454cbea191
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, linkInfo, `type`, body, oldPushTime,num,already_dead
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2f2acd6e843bd477cd0ced4b979d07ebc95f8c5a
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id,clientId, linkInfo, `type`, ploy, insertTime,title,messageType
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailRePushService.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailRePushService.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f6a899d8080371e67cc3ecb4a010b36102c15b5
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailRePushService.java
@@ -0,0 +1,15 @@
+package cn.ljobin.bibi.service;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorEmailRepush;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 盆栽信息Service接口
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+public interface IEmailRePushService extends IService
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailService.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailService.java
new file mode 100644
index 0000000000000000000000000000000000000000..62eaf2416404c7b1cdd57c2d32ddb2a95f621fa9
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IEmailService.java
@@ -0,0 +1,20 @@
+package cn.ljobin.bibi.service;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import cn.ljobin.bibi.domain.pot.TbIoterminal;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * email发送服务
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+public interface IEmailService extends IService {
+ /**
+ * 消费消息
+ * @param monitorMessage
+ */
+ public void recodeMonitorMsg(MonitorMessage monitorMessage);
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IMonitorMessageService.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IMonitorMessageService.java
new file mode 100644
index 0000000000000000000000000000000000000000..fe73a2dbd8d10aecdd9a92c24dd9fccdeb16a565
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/IMonitorMessageService.java
@@ -0,0 +1,15 @@
+package cn.ljobin.bibi.service;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 盆栽信息Service接口
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+public interface IMonitorMessageService extends IService
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c6261bc54997ee7bdab2caabfbca6a970ac8b473
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.java
@@ -0,0 +1,18 @@
+package cn.ljobin.bibi.service.Impl;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmailRepush;
+import cn.ljobin.bibi.mapper.EmailRePushMapper;
+import cn.ljobin.bibi.service.IEmailRePushService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 盆栽信息Service业务层处理
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Service
+public class EmailRePushServiceImpl extends ServiceImpl implements IEmailRePushService
+{
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailServiceImpl.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..8a2506c30d211a332c84dd446d5cc74fca5fe434
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/EmailServiceImpl.java
@@ -0,0 +1,31 @@
+package cn.ljobin.bibi.service.Impl;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import cn.ljobin.bibi.mapper.EmailMapper;
+import cn.ljobin.bibi.service.IEmailService;
+import cn.ljobin.bibi.utils.email.BaseMailSend;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+
+/**
+ * 盆栽信息Service业务层处理
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Service
+public class EmailServiceImpl extends ServiceImpl implements IEmailService {
+ /**
+ * 发送邮件
+ */
+ //@Resource(name = "sendQqMailUtil")
+ @Resource(name = "sprBooEmailUtil")
+ private BaseMailSend sendQQMailUtil;
+
+ @Override
+ public void recodeMonitorMsg(MonitorMessage monitorMessage) {
+ sendQQMailUtil.sendEmail(monitorMessage);
+ }
+}
diff --git a/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.java b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..f9dd4a1891982ee9eee10eec7afe51543eaabe5e
--- /dev/null
+++ b/saltice-monitor-iot/src/main/java/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.java
@@ -0,0 +1,21 @@
+package cn.ljobin.bibi.service.Impl;
+
+import cn.ljobin.bibi.domain.monitor.MonitorEmail;
+import cn.ljobin.bibi.domain.monitor.MonitorMessage;
+import cn.ljobin.bibi.mapper.EmailMapper;
+import cn.ljobin.bibi.mapper.MonitorMessageMapper;
+import cn.ljobin.bibi.service.IEmailService;
+import cn.ljobin.bibi.service.IMonitorMessageService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 盆栽信息Service业务层处理
+ *
+ * @author lyb
+ * @date 2020-04-21
+ */
+@Service
+public class MonitorMessageServiceImpl extends ServiceImpl implements IMonitorMessageService
+{
+}
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailMapper.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailMapper.class
new file mode 100644
index 0000000000000000000000000000000000000000..01f284c8e9ffda7c5457ca009d2d7442a4bb732b
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailMapper.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailRePushMapper.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailRePushMapper.class
new file mode 100644
index 0000000000000000000000000000000000000000..739449d3dfa7dc32caf28c13159950be4f6a01f5
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/EmailRePushMapper.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/MonitorMessageMapper.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/MonitorMessageMapper.class
new file mode 100644
index 0000000000000000000000000000000000000000..e12154073bf0a7e2b2aab8746c7a5ffc7fbfdc86
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/MonitorMessageMapper.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0a53df721c73c022f1afc39e530e8b669fb1a16
--- /dev/null
+++ b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailMapper.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, linkInfo, `type`, body, pushTime
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..62a2bd814ccd6594be67a8a8321e2e454cbea191
--- /dev/null
+++ b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/EmailRePushMapper.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, linkInfo, `type`, body, oldPushTime,num,already_dead
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2f2acd6e843bd477cd0ced4b979d07ebc95f8c5a
--- /dev/null
+++ b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/mapper/mapping/MonitorMessageMapper.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id,clientId, linkInfo, `type`, ploy, insertTime,title,messageType
+
+
+
\ No newline at end of file
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailRePushService.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailRePushService.class
new file mode 100644
index 0000000000000000000000000000000000000000..10ef66cb10d01a85542b7fcbfac59b8c25146fa5
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailRePushService.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailService.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailService.class
new file mode 100644
index 0000000000000000000000000000000000000000..522cbcbb2f75d9bda11ed52ab3c8fd613a074c03
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IEmailService.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IMonitorMessageService.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IMonitorMessageService.class
new file mode 100644
index 0000000000000000000000000000000000000000..fcee397eb0a3cc88a70ca0ccd9c2888d2955a1aa
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/IMonitorMessageService.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.class
new file mode 100644
index 0000000000000000000000000000000000000000..461da0921a9e137a1e19cf57b165a1ee242128b1
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailRePushServiceImpl.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailServiceImpl.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailServiceImpl.class
new file mode 100644
index 0000000000000000000000000000000000000000..54e8d5e02877c633730a44ad7922cd33dbc64ffc
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/EmailServiceImpl.class differ
diff --git a/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.class b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.class
new file mode 100644
index 0000000000000000000000000000000000000000..50b6debf9d365788ca77646cfe383418d830fd4e
Binary files /dev/null and b/saltice-monitor-iot/target/classes/cn/ljobin/bibi/service/Impl/MonitorMessageServiceImpl.class differ