package com.ruoyi.common.thread;
import com.ruoyi.common.sendEmail.IMailService;
import com.ruoyi.project.sems.domain.TApprove;
import java.util.Date;
public class SendEmailThead implements Runnable {
private IMailService mailService;
private String email;
private String apNo;
private String username;
private String usernameEN;
private TApprove tApprove;
private String sendType;
public SendEmailThead(String email, String apNo, String username, String usernameEN, IMailService mailService, TApprove tApprove, String sendType) {
this.email = email;
this.apNo = apNo;
this.username = username;
this.usernameEN = usernameEN;
this.mailService = mailService;
this.tApprove = tApprove;
this.sendType = sendType;
}
/*
* 发送邮件
*/
@Override
public void run() {
if (sendType.equals("year")) {
year();
}else if (sendType.equals("month")) {
month();
}
}
/*
* 发送年度邮件
*/
public void year() {
String devType = null;
String devTypeEN = null;
switch (tApprove.getDevType().toString()) {
case "1":
devType = "压力容器";
devTypeEN = "Pressure Vessel";
break;
case "2":
devType = "压力管道";
devTypeEN = "Pressure Pipeline";
break;
}
String approveType = "生成" + devType + "年度检查报告";
String approveTypeEN = "Generate annual inspection report of " + devTypeEN;
//写html开始内容
String start = "
" +
"
" +
"| " +
"特种设备信息管理系统 Special Equipment Management System (SEMS) |
";
//表html中间内容
String prime = "";
String center = "" +
"" +
"亲爱的 username " +
"Dear usernameEN" +
" 您有一个新的待办任务: " +
"You have a new to-do task: " +
"任务编号:apNo " +
"Task Number: apNoEN " +
"申请设备类型:devType " +
"Equipment Type: devTypeEN " +
"审批类型:approveType " +
"Application Category: approveTypeEN " +
"请登录特种设备信息管理系统查看。 " +
"Please log in the SEMS to handle it. " +
" date " +
" " +
" " +
" 此为系统邮件,请勿回复 This e-Mail is an automatic reminder sent by SEMS, please do not reply " +
" |
";
String one = center.replaceFirst("username", username);
String two = one.replaceFirst("usernameEN", usernameEN);
String three = two.replaceFirst("devType", devType);
String four = three.replaceFirst("apNo", apNo);
String five = four.replaceFirst("apNoEN", apNo);
String six = five.replaceFirst("devTypeEN", devTypeEN);
String seven = six.replaceFirst("approveType", approveType);
String eight = seven.replaceFirst("approveTypeEN", approveTypeEN);
String result = eight.replaceFirst("date", String.valueOf(new Date()));
prime = prime + result;
//写html结尾内容
String end = "
";
//拼接html
String html = start + prime + end;
mailService.sendHtmlMail(email, "特种设备:您有一个新的待办任务 SEMS:You have a new to-do task (" + apNo + ")", html);
}
/*
* 发送月度邮件
*/
public void month() {
String approveType = "生成月度检查报告";
String approveTypeEN = "Generate monthly inspection report";
//写html开始内容
String start = "" +
"
" +
"| " +
"特种设备信息管理系统 Special Equipment Management System (SEMS) |
";
//表html中间内容
String prime = "";
String center = "" +
"" +
"亲爱的 username " +
"Dear usernameEN" +
" 您有一个新的待办任务: " +
"You have a new to-do task: " +
"任务编号:apNo " +
"Task Number: apNoEN " +
"审批类型:approveType " +
"Application Category: approveTypeEN " +
"请登录特种设备信息管理系统查看。 " +
"Please log in the SEMS to handle it. " +
" date " +
" " +
" " +
" 此为系统邮件,请勿回复 This e-Mail is an automatic reminder sent by SEMS, please do not reply " +
" |
";
String one = center.replaceFirst("username", username);
String two = one.replaceFirst("usernameEN", usernameEN);
String three = two.replaceFirst("apNo", apNo);
String four = three.replaceFirst("apNoEN", apNo);
String five = four.replaceFirst("approveType", approveType);
String six = five.replaceFirst("approveTypeEN", approveTypeEN);
String result = six.replaceFirst("date", String.valueOf(new Date()));
prime = prime + result;
//写html结尾内容
String end = "
";
//拼接html
String html = start + prime + end;
mailService.sendHtmlMail(email, "特种设备:您有一个新的待办任务 SEMS:You have a new to-do task (" + apNo + ")", html);
}
}