MeetingInvitationMailThread.java 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.ruoyi.common.thread.Trainning;
  2. import com.ruoyi.common.sendEmail.IMailService;
  3. import java.util.Date;
  4. /**
  5. * @author Wang Zi Wen
  6. * @email wangggziwen@163.com
  7. * @date 2022/05/25 14:30:52
  8. */
  9. public class MeetingInvitationMailThread implements Runnable {
  10. private IMailService mailService;
  11. private String email; // 邮箱
  12. private String successorName; // 学员用户名(中)
  13. private String successorNameEN; // 学员用户名(英)
  14. private String mentorName; // 导师用户名(中)
  15. private String mentorNameEN; // 导师用户名(英)
  16. private String feedbackYear; // 年
  17. private String feedbackSeason; // 季度
  18. private String meetingDate; // 会议日期
  19. public MeetingInvitationMailThread() {
  20. }
  21. public MeetingInvitationMailThread(IMailService mailService, String email, String successorName, String successorNameEN, String mentorName, String mentorNameEN, String feedbackYear, String feedbackSeason,String meetingDate) {
  22. this.mailService = mailService;
  23. this.email = email;
  24. this.successorName = successorName;
  25. this.successorNameEN = successorNameEN;
  26. this.mentorName = mentorName;
  27. this.mentorNameEN = mentorNameEN;
  28. this.feedbackYear = feedbackYear;
  29. this.feedbackSeason = feedbackSeason;
  30. this.meetingDate = meetingDate;
  31. }
  32. @Override
  33. public void run() {
  34. this.sendMail();
  35. }
  36. private void sendMail() {
  37. String jumpUrl = "/training/spec/monthlyfeedback";
  38. //写html开始内容
  39. String start = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title></head><body><div style=\"background-color:#ECECEC; padding: 35px;\">" +
  40. "<table cellpadding=\"0\" align=\"center\"" +
  41. "style=\"width: 600px; margin: 0px auto; text-align: left; position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; font-size: 14px; font-family:微软雅黑, 黑体; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0px 0px 5px; border-collapse: collapse; background-position: initial initial; background-repeat: initial initial;background:#fff;\">" +
  42. "<tbody><tr><th valign=\"middle\" style=\"height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #42a3d3; background-color: #49bcff; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;\">" +
  43. "<font face=\"微软雅黑\" size=\"5\" style=\"color: rgb(255, 255, 255); \">CPMS管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">CPMS System</font></th></tr>";
  44. //表html中间内容
  45. String prime = "";
  46. String center = "<tr><td><div style=\"padding:25px 35px 40px; background-color:#fff;\"><h2 style=\"margin: 5px 0px; \">" +
  47. "<font color=\"#333333\" style=\"line-height: 20px; \"><font style=\"line-height: 22px; \" size=\"4\">" +
  48. "亲爱的mentorName</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
  49. "Dear mentorNameEN</font></font></h2>" +
  50. "<p>您已受邀参加季度汇报,详情如下:<br>" +
  51. "You have a new to-do task:<br>" +
  52. "学员:<b>successorName</b><br>" +
  53. "汇报内容:<b>feedbackYear年第feedbackSeason季度汇报</b><br>" +
  54. "会议日期:<b>meetingDate</b><br>" +
  55. "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS管理系统</a>查看。<br>" +
  56. "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS</a> to handle it.</p>" +
  57. "<p align=\"right\">date</p>" +
  58. "<div style=\"width:700px;margin:0 auto;\">" +
  59. "<div style=\"padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;\">" +
  60. "<p>此为系统邮件,请勿回复<br>This e-Mail is an automatic reminder sent by CPMS, please do not reply</p>" +
  61. "</div></div></div></td></tr>";
  62. String one = center.replaceFirst("mentorName", mentorName);
  63. String two = one.replaceFirst("mentorNameEN", mentorNameEN);
  64. String three = two.replaceFirst("successorName", successorName);
  65. String four = three.replaceFirst("feedbackYear",feedbackYear);
  66. String five = four.replaceFirst("feedbackSeason",feedbackSeason);
  67. String six = five.replaceFirst("meetingDate",meetingDate);
  68. String result = six.replaceFirst("date", String.valueOf(new Date())).replaceFirst("jumpUrl",jumpUrl).replaceFirst("jumpUrl",jumpUrl);
  69. prime = prime + result;
  70. //写html结尾内容
  71. String end = "</tbody></table></div></body></html>";
  72. //拼接html
  73. String html = start + prime + end;
  74. mailService.sendHtmlMail(email, "CPMS:您已受邀参加学员" + successorName + "的季度汇报 (" + feedbackYear + "年第" + feedbackSeason + "季度)", html);
  75. }
  76. }