Эх сурвалжийг харах

王子文 专项培养
1) 导师邀请其他导师参会,其他导师收到邮件通知

wangggziwen 3 жил өмнө
parent
commit
5fbe0624d8

+ 85 - 0
master/src/main/java/com/ruoyi/common/thread/Trainning/MeetingInvitationMailThread.java

@@ -0,0 +1,85 @@
+package com.ruoyi.common.thread.Trainning;
+
+import com.ruoyi.common.sendEmail.IMailService;
+
+import java.util.Date;
+
+/**
+ * @author Wang Zi Wen
+ * @email wangggziwen@163.com
+ * @date 2022/05/25 14:30:52
+ */
+public class MeetingInvitationMailThread implements Runnable {
+
+    private IMailService mailService;
+    private String email;   // 邮箱
+    private String successorName;    // 学员用户名(中)
+    private String successorNameEN;  // 学员用户名(英)
+    private String mentorName;    // 导师用户名(中)
+    private String mentorNameEN;  // 导师用户名(英)
+    private String feedbackYear;    // 年
+    private String feedbackSeason;  // 季度
+    private String meetingDate; // 会议日期
+
+    public MeetingInvitationMailThread() {
+    }
+
+    public MeetingInvitationMailThread(IMailService mailService, String email, String successorName, String successorNameEN, String mentorName, String mentorNameEN, String feedbackYear, String feedbackSeason,String meetingDate) {
+        this.mailService = mailService;
+        this.email = email;
+        this.successorName = successorName;
+        this.successorNameEN = successorNameEN;
+        this.mentorName = mentorName;
+        this.mentorNameEN = mentorNameEN;
+        this.feedbackYear = feedbackYear;
+        this.feedbackSeason = feedbackSeason;
+        this.meetingDate = meetingDate;
+    }
+
+    @Override
+    public void run() {
+        this.sendMail();
+    }
+
+    private void sendMail() {
+        String jumpUrl = "/training/spec/monthlyfeedback";
+        //写html开始内容
+        String start = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title></head><body><div style=\"background-color:#ECECEC; padding: 35px;\">" +
+                "<table cellpadding=\"0\" align=\"center\"" +
+                "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;\">" +
+                "<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;\">" +
+                "<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>";
+        //表html中间内容
+        String prime = "";
+        String center = "<tr><td><div style=\"padding:25px 35px 40px; background-color:#fff;\"><h2 style=\"margin: 5px 0px; \">" +
+                "<font color=\"#333333\" style=\"line-height: 20px; \"><font style=\"line-height: 22px; \" size=\"4\">" +
+                "亲爱的mentorName</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
+                "Dear mentorNameEN</font></font></h2>" +
+                "<p>您已受邀参加季度汇报,详情如下:<br>" +
+                "You have a new to-do task:<br>" +
+                "学员:<b>successorName</b><br>" +
+                "汇报内容:<b>feedbackYear年第feedbackSeason季度汇报</b><br>" +
+                "会议日期:<b>meetingDate</b><br>" +
+                "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS管理系统</a>查看。<br>" +
+                "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#jumpUrl\">CPMS</a> to handle it.</p>" +
+                "<p align=\"right\">date</p>" +
+                "<div style=\"width:700px;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>此为系统邮件,请勿回复<br>This e-Mail is an automatic reminder sent by CPMS, please do not reply</p>" +
+                "</div></div></div></td></tr>";
+        String one = center.replaceFirst("mentorName", mentorName);
+        String two = one.replaceFirst("mentorNameEN", mentorNameEN);
+        String three = two.replaceFirst("successorName", successorName);
+        String four = three.replaceFirst("feedbackYear",feedbackYear);
+        String five = four.replaceFirst("feedbackSeason",feedbackSeason);
+        String six = five.replaceFirst("meetingDate",meetingDate);
+        String result = six.replaceFirst("date", String.valueOf(new Date())).replaceFirst("jumpUrl",jumpUrl).replaceFirst("jumpUrl",jumpUrl);
+        prime = prime + result;
+        //写html结尾内容
+        String end = "</tbody></table></div></body></html>";
+        //拼接html
+        String html = start + prime + end;
+        mailService.sendHtmlMail(email, "CPMS:您已受邀参加学员" + successorName + "的季度汇报 (" + feedbackYear + "年第" + feedbackSeason + "季度)", html);
+    }
+
+}

+ 2 - 2
master/src/main/java/com/ruoyi/common/thread/Trainning/MonthlyFeedbackMailThread.java

@@ -12,7 +12,7 @@ import java.util.Date;
 public class MonthlyFeedbackMailThread implements Runnable {
 
     private IMailService mailService;
-    private String email;   // 学员邮箱
+    private String email;   // 邮箱
     private String successorName;    // 学员用户名(中)
     private String successorNameEN;  // 学员用户名(英)
     private String mentorName;    // 导师用户名(中)
@@ -75,7 +75,7 @@ public class MonthlyFeedbackMailThread implements Runnable {
         String end = "</tbody></table></div></body></html>";
         //拼接html
         String html = start + prime + end;
-        mailService.sendHtmlMail("wangggziwen@163.com", "CPMS:您的导师已提交月度反馈 (" + feedbackYear + "年" + feedbackMonth + "月)", html);
+        mailService.sendHtmlMail(email, "CPMS:您的导师已提交月度反馈 (" + feedbackYear + "年" + feedbackMonth + "月)", html);
     }
 
 }

+ 26 - 3
master/src/main/java/com/ruoyi/project/training/spec/controller/TStFeedbackController.java

@@ -2,12 +2,14 @@ package com.ruoyi.project.training.spec.controller;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import com.github.stuxuhai.jpinyin.PinyinException;
 import com.github.stuxuhai.jpinyin.PinyinFormat;
 import com.github.stuxuhai.jpinyin.PinyinHelper;
 import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.common.thread.Trainning.MeetingInvitationMailThread;
 import com.ruoyi.common.thread.Trainning.MonthlyFeedbackMailThread;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.service.ISysUserService;
@@ -513,8 +515,28 @@ public class TStFeedbackController extends BaseController
     @PreAuthorize("@ss.hasPermi('spec:feedback:add')")
     @Log(title = "专项培训反馈", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TStFeedback tStFeedback)
-    {
+    public AjaxResult add(@RequestBody TStFeedback tStFeedback) throws PinyinException {
+        // 新增受邀导师反馈记录
+        if (tStFeedback.getParentId() != null) {
+            // 根据学员staffId获取用户对象
+            SysUser successor = sysUserService.selectUserByStaffId(tStFeedback.getSuccessorId());
+            String successorName = successor.getNickName();
+            String successorNameEN = PinyinHelper.convertToPinyinString(successorName, " ", PinyinFormat.WITHOUT_TONE);
+            String feedbackYear = tStFeedback.getFeedbackYear();
+            String feedbackSeason = tStFeedback.getFeedbackSeason();
+            // 根据导师staffId获取用户对象
+            SysUser mentor = sysUserService.selectUserByStaffId(tStFeedback.getMentorId());
+            String email = mentor.getEmail();
+            String mentorName = mentor.getNickName();
+            String mentorNameEN = PinyinHelper.convertToPinyinString(mentorName, " ", PinyinFormat.WITHOUT_TONE);
+            Date meetingDate = tStFeedbackService.selectTStFeedbackById(tStFeedback.getParentId()).getMeetingDate();
+            String meetingDateString = "20" + (meetingDate.getYear() + "年" + (meetingDate.getMonth() + 1 + "月") + meetingDate.getDate() + "日").substring(1);
+            // TODO: 部署前开启
+            // 邮件通知导师
+//            MeetingInvitationMailThread meetingInvitationMailThread = new MeetingInvitationMailThread(mailService, email, successorName, successorNameEN, mentorName, mentorNameEN, feedbackYear, feedbackSeason, meetingDateString);
+//            Thread thread = new Thread(meetingInvitationMailThread);
+//            thread.start();
+        }
         return toAjax(tStFeedbackService.insertTStFeedback(tStFeedback));
     }
 
@@ -539,7 +561,8 @@ public class TStFeedbackController extends BaseController
             SysUser mentor = sysUserService.selectUserByStaffId(feedback.getMentorId());
             String mentorName = mentor.getNickName();
             String mentorNameEN = PinyinHelper.convertToPinyinString(mentorName, " ", PinyinFormat.WITHOUT_TONE);
-            // 邮件通知导师
+            // TODO: 部署前开启
+            // 邮件通知学员
 //            MonthlyFeedbackMailThread monthlyFeedbackMailThread = new MonthlyFeedbackMailThread(mailService, email, successorName, successorNameEN, mentorName, mentorNameEN, feedbackYear, feedbackMonth);
 //            Thread thread = new Thread(monthlyFeedbackMailThread);
 //            thread.start();

+ 1 - 0
master/src/main/java/com/ruoyi/project/training/spec/scheduler/TStFeedbackScheduler.java

@@ -42,6 +42,7 @@ public class TStFeedbackScheduler {
      * 会议时间一周后给学员发送邮件
      * 定时任务触发条件:每日8:00
      */
+    // TODO: 部署前开启
 //    @Scheduled(cron = "0 0 8 * * ?")
     private void mailSuccessorAfterMeeting() throws PinyinException {
         // 获取所有反馈记录