|
@@ -15,9 +15,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
|
|
|
@Service("zzzgTaskCreateListener")
|
|
|
public class ZzzgTaskCreateListener implements Serializable, TaskListener {
|
|
@@ -30,58 +28,55 @@ public class ZzzgTaskCreateListener implements Serializable, TaskListener {
|
|
|
ITApproveReserveInvoiceService tApproveReserveInvoiceService = (ITApproveReserveInvoiceService) SpringContextUtils.getBean("tApproveReserveInvoiceService");
|
|
|
ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
|
|
|
IMailService mailService = (IMailService) SpringContextUtils.getBean("mailService");
|
|
|
- TApproveReserveInvoice approveEntity = tApproveReserveInvoiceService.selectTApproveReserveInvoiceById(Long.parseLong(id)) ;
|
|
|
+ TApproveReserveInvoice approveEntity = tApproveReserveInvoiceService.selectTApproveReserveInvoiceById(Long.parseLong(id));
|
|
|
logger.info("approveEntity:" + approveEntity);
|
|
|
//发送邮件
|
|
|
try {
|
|
|
- List<String> emails = new ArrayList<>();
|
|
|
for (String zzzguser : zzzgusers.split(",")) {
|
|
|
- emails.add(sysUserService.selectUserById(Long.parseLong(zzzguser)).getEmail());
|
|
|
+ String email = sysUserService.selectUserById(Long.parseLong(zzzguser)).getEmail();
|
|
|
+ String apNo = approveEntity.getApNo();
|
|
|
+ logger.info("apNo:" + apNo);
|
|
|
+ String username = sysUserService.selectUserById(Long.parseLong(zzzguser)).getNickName();
|
|
|
+ String usernameEN = PinyinHelper.convertToPinyinString(username, " ", PinyinFormat.WITHOUT_TONE);
|
|
|
+ logger.info("email:" + email);
|
|
|
+ logger.info("username:" + username);
|
|
|
+ //写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); \">预约开票管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">Reserve Invoice</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\">" +
|
|
|
+ "亲爱的 username</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
+ "Dear usernameEN</font></font></h2>" +
|
|
|
+ "<p>您有一个新的待办任务:<br>" +
|
|
|
+ "You have a new to-do task:<br>" +
|
|
|
+ "任务编号:<b>apNo</b><br>" +
|
|
|
+ "Task Number: <b>apNoEN</b><br>" +
|
|
|
+ "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">预约开票申请流程</a>查看。<br>" +
|
|
|
+ "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">InvoiceApprove</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 SEMS, please do not reply</p>" +
|
|
|
+ "</div></div></div></td></tr>";
|
|
|
+ String one = center.replaceFirst("username", username);
|
|
|
+ String two = one.replaceFirst("usernameEN", usernameEN);
|
|
|
+ String four = two.replaceFirst("apNo", apNo);
|
|
|
+ String five = four.replaceFirst("apNoEN", apNo);
|
|
|
+ String result = five.replaceFirst("date", String.valueOf(new Date()));
|
|
|
+ prime = prime + result;
|
|
|
+ //写html结尾内容
|
|
|
+ String end = "</tbody></table></div></body></html>";
|
|
|
+ //拼接html
|
|
|
+ String html = start + prime + end;
|
|
|
+ logger.info("html:" + html);
|
|
|
+// mailService.sendHtmlMail(email, "预约开票:您有一个新的待办任务 Reserve Invoice:You have a new to-do task (" + apNo + ")", html);
|
|
|
}
|
|
|
- String apNo = approveEntity.getApNo();
|
|
|
- logger.info("apNo:" + apNo);
|
|
|
- String username = sysUserService.selectUserById(Long.parseLong(zzzgusers)).getNickName();
|
|
|
- String usernameEN = PinyinHelper.convertToPinyinString(username, " ", PinyinFormat.WITHOUT_TONE);
|
|
|
- logger.info("email:" + JSON.toJSONString(emails));
|
|
|
- logger.info("username:" + username);
|
|
|
- //写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); \">预约开票管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">Reserve Invoice</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\">" +
|
|
|
- "亲爱的 username</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
- "Dear usernameEN</font></font></h2>" +
|
|
|
- "<p>您有一个新的待办任务:<br>" +
|
|
|
- "You have a new to-do task:<br>" +
|
|
|
- "任务编号:<b>apNo</b><br>" +
|
|
|
- "Task Number: <b>apNoEN</b><br>" +
|
|
|
- "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">预约开票申请流程</a>查看。<br>" +
|
|
|
- "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">InvoiceApprove</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 SEMS, please do not reply</p>" +
|
|
|
- "</div></div></div></td></tr>";
|
|
|
- String one = center.replaceFirst("username", username);
|
|
|
- String two = one.replaceFirst("usernameEN", usernameEN);
|
|
|
- String four = two.replaceFirst("apNo", apNo);
|
|
|
- String five = four.replaceFirst("apNoEN", apNo);
|
|
|
- String result = five.replaceFirst("date", String.valueOf(new Date()));
|
|
|
- prime = prime + result;
|
|
|
- //写html结尾内容
|
|
|
- String end = "</tbody></table></div></body></html>";
|
|
|
- //拼接html
|
|
|
- String html = start + prime + end;
|
|
|
- logger.info("html:" + html);
|
|
|
- for (String email : emails) {
|
|
|
- //mailService.sendHtmlMail(email, "预约开票:您有一个新的待办任务 Reserve Invoice:You have a new to-do task (" + apNo + ")", html);
|
|
|
- }
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
logger.error("邮件发送失败" + JSON.toJSONString(e));
|
|
|
}
|
|
|
}
|