feat: There is no way the MQ conf
This commit is contained in:
@@ -29,6 +29,10 @@
|
|||||||
<artifactId>fk-util</artifactId>
|
<artifactId>fk-util</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- Eureka -->
|
<!-- Eureka -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.ydw.bat.wkflow.business_mq.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
|
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.ResponseMessage;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.UserVO;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.utils.EmailUtils;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||||
@@ -21,6 +25,7 @@ import org.springframework.messaging.Message;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,12 +37,18 @@ public class SendDoneMQService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CreateMQService convertMq;
|
private CreateMQService convertMq;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebServiceOAService webServiceOAService;
|
private WebServiceOAService webServiceOAService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendTodoLogMapper sendTodoLogMapper;
|
private SendTodoLogMapper sendTodoLogMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LawsUserInfoService lawsUserInfoService;
|
||||||
|
|
||||||
@RabbitListener(bindings = @QueueBinding(
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
value = @Queue(value = "createMQDone_SQ_GSAR", durable = "true"),
|
value = @Queue(value = "createMQDone_SQ_GSAR", durable = "true"),
|
||||||
exchange = @Exchange(value = "sendDone-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
exchange = @Exchange(value = "sendDone-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||||
@@ -106,6 +117,15 @@ public class SendDoneMQService {
|
|||||||
if(againNumNew >= 6){
|
if(againNumNew >= 6){
|
||||||
// 发送待办 或 发送给管理员邮箱
|
// 发送待办 或 发送给管理员邮箱
|
||||||
logger.info("发送失败6次,发送给管理员邮箱");
|
logger.info("发送失败6次,发送给管理员邮箱");
|
||||||
|
List<String> emailList = new ArrayList<>();
|
||||||
|
ResponseMessage<UserVO> byId = lawsUserInfoService.getById("WY8J26MH23");
|
||||||
|
// 占时指定admin用户邮箱
|
||||||
|
emailList.add(byId == null ? "" : (byId.getData().getEmail() != null ? byId.getData().getEmail() : ""));
|
||||||
|
String[] arr = emailList.toArray(new String[emailList.size()]);
|
||||||
|
String title = "OA请求发送失败6次";
|
||||||
|
String countText = "<div style=\"font-size:16px\" ><div><p>您好:</p></div>" +
|
||||||
|
"<span style=\"color:blue;\" >"+"OA请求发送失败6次,请线下协调处理"+"</span></div>";
|
||||||
|
emailUtils.sendMsgFeign(arr,title,countText);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
restSendDoneTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
restSendDoneTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package com.ydw.bat.wkflow.business_mq.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
|
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.ResponseMessage;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.UserVO;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.utils.EmailUtils;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
@@ -21,6 +25,7 @@ import org.springframework.messaging.Message;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,12 +37,18 @@ public class SendMQService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CreateMQService convertMq;
|
private CreateMQService convertMq;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailUtils emailUtils;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebServiceOAService webServiceOAService;
|
private WebServiceOAService webServiceOAService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendTodoLogMapper sendTodoLogMapper;
|
private SendTodoLogMapper sendTodoLogMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LawsUserInfoService lawsUserInfoService;
|
||||||
|
|
||||||
@RabbitListener(bindings = @QueueBinding(
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
value = @Queue(value = "createMQ_SQ_GSAR", durable = "true"),
|
value = @Queue(value = "createMQ_SQ_GSAR", durable = "true"),
|
||||||
exchange = @Exchange(value = "send-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
exchange = @Exchange(value = "send-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||||
@@ -103,7 +114,16 @@ public class SendMQService {
|
|||||||
SendTodoLog sendTodoLog = list.get(0);
|
SendTodoLog sendTodoLog = list.get(0);
|
||||||
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
||||||
if(againNumNew >= 6){
|
if(againNumNew >= 6){
|
||||||
|
ResponseMessage<UserVO> byId = lawsUserInfoService.getById("WY8J26MH23");
|
||||||
// 发送待办 或 发送给管理员邮箱
|
// 发送待办 或 发送给管理员邮箱
|
||||||
|
List<String> emailList = new ArrayList<>();
|
||||||
|
// 占时指定admin用户邮箱
|
||||||
|
emailList.add(byId == null ? "" : (byId.getData().getEmail() == null ? "" : byId.getData().getEmail()));
|
||||||
|
String[] arr = emailList.toArray(new String[emailList.size()]);
|
||||||
|
String title = "OA请求发送失败6次";
|
||||||
|
String countText = "<div style=\"font-size:16px\" ><div><p>您好:</p></div>" +
|
||||||
|
"<span style=\"color:blue;\" >"+"OA请求发送失败6次,请线下协调处理"+"</span></div>";
|
||||||
|
emailUtils.sendMsgFeign(arr,title,countText);
|
||||||
logger.info("发送失败6次,发送给管理员邮箱");
|
logger.info("发送失败6次,发送给管理员邮箱");
|
||||||
}else {
|
}else {
|
||||||
restSendTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
restSendTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
||||||
|
|||||||
@@ -0,0 +1,342 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_oa.utils;
|
||||||
|
|
||||||
|
import org.apache.avalon.framework.service.ServiceException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.MailException;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EmailUtils {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
/**
|
||||||
|
* The Mail sender.
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
JavaMailSenderImpl mailSender;
|
||||||
|
|
||||||
|
@Value("${mail.valid}")
|
||||||
|
private boolean mailValid;
|
||||||
|
|
||||||
|
@Value("${spring.mail.username}")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Value("${spring.mail.password}")
|
||||||
|
private String mailPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send simple email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendSimpleEmail(String deliver,String personName, String receiver, String subject, String content) throws ServiceException {
|
||||||
|
if(mailValid){
|
||||||
|
String[] receivers = {receiver};
|
||||||
|
sendSimpleEmail(deliver,personName, receivers, null, subject, content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send simple email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param carbonCopy the carbon copy
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendSimpleEmail(String deliver,String personName, String[] receiver, String[] carbonCopy, String subject, String content) throws ServiceException {
|
||||||
|
|
||||||
|
long startTimestamp = System.currentTimeMillis();
|
||||||
|
logger.info("Start send mail ... ");
|
||||||
|
|
||||||
|
try {
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
personName=javax.mail.internet.MimeUtility.encodeText(personName);
|
||||||
|
message.setFrom(personName + "<"+deliver+">");
|
||||||
|
message.setTo(receiver);
|
||||||
|
if(carbonCopy!=null && carbonCopy.length>0){
|
||||||
|
message.setCc(carbonCopy);
|
||||||
|
}
|
||||||
|
message.setSubject(subject);
|
||||||
|
message.setText(content);
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
logger.info("Send mail success, cost {} million seconds", System.currentTimeMillis() - startTimestamp);
|
||||||
|
} catch (MailException e) {
|
||||||
|
logger.error("Send mail failed, error message is : {} \n", e.getMessage());
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
logger.error("Send mail failed, error message is : {} \n", e.getMessage());
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send html email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendHtmlEmail(String deliver, String receiver, String subject, String content) throws ServiceException {
|
||||||
|
String[] receivers = {receiver};
|
||||||
|
sendHtmlEmail(deliver, receivers, null, subject, content, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send html email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param carbonCopy the carbon copy
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @param isHtml the is html
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendHtmlEmail(String deliver, String[] receiver, String[] carbonCopy, String subject, String content, boolean isHtml) throws ServiceException {
|
||||||
|
long startTimestamp = System.currentTimeMillis();
|
||||||
|
logger.info("Start send email ...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper messageHelper = new MimeMessageHelper(message);
|
||||||
|
|
||||||
|
messageHelper.setFrom(deliver);
|
||||||
|
messageHelper.setTo(receiver);
|
||||||
|
if (null != carbonCopy) {
|
||||||
|
messageHelper.setCc(carbonCopy);
|
||||||
|
}
|
||||||
|
messageHelper.setSubject(subject);
|
||||||
|
messageHelper.setText(content, isHtml);
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
logger.info("Send email success, cost {} million seconds", System.currentTimeMillis() - startTimestamp);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
logger.error("Send email failed, error message is {} \n", e.getMessage());
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send attachment file email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @param fileName the file name
|
||||||
|
* @param file the file
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendAttachmentFileEmail(String deliver, String receiver, String subject, String content, String fileName, File file) throws ServiceException {
|
||||||
|
String[] receivers = {receiver};
|
||||||
|
sendAttachmentFileEmail(deliver, receivers, null, subject, content, true, fileName, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send attachment file mail.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param carbonCopy the carbon copy
|
||||||
|
* @param subject the subject
|
||||||
|
* @param content the content
|
||||||
|
* @param isHtml the is html
|
||||||
|
* @param fileName the file name
|
||||||
|
* @param file the file
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*/
|
||||||
|
public void sendAttachmentFileEmail(String deliver, String[] receiver, String[] carbonCopy, String subject, String content, boolean isHtml, String fileName, File file) throws ServiceException {
|
||||||
|
long startTimestamp = System.currentTimeMillis();
|
||||||
|
logger.info("Start send mail ...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper messageHelper = new MimeMessageHelper(message, true);
|
||||||
|
|
||||||
|
messageHelper.setFrom(deliver);
|
||||||
|
messageHelper.setTo(receiver);
|
||||||
|
messageHelper.setCc(carbonCopy);
|
||||||
|
messageHelper.setSubject(subject);
|
||||||
|
messageHelper.setText(content, isHtml);
|
||||||
|
messageHelper.addAttachment(fileName, file);
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
logger.info("Send mail success, cost {} million seconds", System.currentTimeMillis() - startTimestamp);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
logger.error("Send mail failed, error message is {}\n", e.getMessage());
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *//**
|
||||||
|
* Send template email.
|
||||||
|
*
|
||||||
|
* @param deliver the deliver
|
||||||
|
* @param receiver the receiver
|
||||||
|
* @param subject the subject
|
||||||
|
* @param template the template
|
||||||
|
* @param context the context
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*//*
|
||||||
|
public void sendTemplateEmail(String deliver, String receiver, String subject, String template, Context context) throws ServiceException {
|
||||||
|
String[] receivers = {receiver};
|
||||||
|
sendTemplateEmail(deliver, receivers, null, subject, template, context);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/* *//**
|
||||||
|
* Send template mail.
|
||||||
|
* @throws ServiceException the service exception
|
||||||
|
*//*
|
||||||
|
public void sendTemplateEmail(String deliver, String[] receiver, String[] carbonCopy, String subject, String template, Context context) throws ServiceException {
|
||||||
|
long startTimestamp = System.currentTimeMillis();
|
||||||
|
logger.info("Start send mail ...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper messageHelper = new MimeMessageHelper(message);
|
||||||
|
|
||||||
|
String content = templateEngine.process(template, context);
|
||||||
|
messageHelper.setFrom(deliver);
|
||||||
|
messageHelper.setTo(receiver);
|
||||||
|
messageHelper.setCc(carbonCopy);
|
||||||
|
messageHelper.setSubject(subject);
|
||||||
|
messageHelper.setText(content, true);
|
||||||
|
|
||||||
|
mailSender.send(message);
|
||||||
|
logger.info("Send mail success, cost {} million seconds", System.currentTimeMillis() - startTimestamp);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
logger.error("Send mail failed, error message is {} \n", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendMsg(String[] tos,String msg){
|
||||||
|
//创建简单邮件消息
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//谁发的
|
||||||
|
message.setFrom(userName);
|
||||||
|
//谁要接收
|
||||||
|
message.setTo(tos);
|
||||||
|
//邮件标题
|
||||||
|
message.setSubject(msg);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(msg);
|
||||||
|
try {
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
} catch (MailException e) {
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendMsgNew(String[] tos,String msg,String title){
|
||||||
|
//创建简单邮件消息
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//谁发的
|
||||||
|
message.setFrom(userName);
|
||||||
|
//谁要接收
|
||||||
|
message.setTo(tos);
|
||||||
|
//邮件标题
|
||||||
|
message.setSubject(title);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(msg);
|
||||||
|
try {
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
} catch (MailException e) {
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendMsgFeign(String[] tos,String title, String msg){
|
||||||
|
//创建简单邮件消息
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//谁发的
|
||||||
|
message.setFrom(userName);
|
||||||
|
//谁要接收
|
||||||
|
message.setTo(tos);
|
||||||
|
//邮件标题
|
||||||
|
message.setSubject(title);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(msg);
|
||||||
|
try {
|
||||||
|
if (null != tos){
|
||||||
|
for (String to :tos){
|
||||||
|
sendHtmlEmail( userName, to, title, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendMsgWithCC(String[] tos,String[] cc,String msg){
|
||||||
|
//创建简单邮件消息
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//谁发的
|
||||||
|
message.setFrom(userName);
|
||||||
|
//谁要接收
|
||||||
|
message.setTo(tos);
|
||||||
|
//抄送
|
||||||
|
message.setCc(cc);
|
||||||
|
//邮件标题
|
||||||
|
message.setSubject(msg);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(msg);
|
||||||
|
try {
|
||||||
|
if(StringUtils.isBlank(mailPwd)){
|
||||||
|
mailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
} catch (MailException e) {
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,32 @@ spring:
|
|||||||
enabled: true
|
enabled: true
|
||||||
#最大重试9次
|
#最大重试9次
|
||||||
max-attempts: 6
|
max-attempts: 6
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# 邮箱配置-1
|
||||||
|
# =============================================================================
|
||||||
|
mail:
|
||||||
|
host: smtp.163.com
|
||||||
|
protocol: smtp
|
||||||
|
username: foton_admin@163.com
|
||||||
|
password: QDQMXXMCKFARNDEI
|
||||||
|
properties:
|
||||||
|
smtp:
|
||||||
|
auth: true
|
||||||
|
starttls:
|
||||||
|
enable: true
|
||||||
|
required: true
|
||||||
|
mail:
|
||||||
|
smtp:
|
||||||
|
ssl:
|
||||||
|
enable: true
|
||||||
|
port: 465
|
||||||
|
# =============================================================================
|
||||||
|
# 邮箱配置-2
|
||||||
|
# =============================================================================
|
||||||
|
mail:
|
||||||
|
valid: true
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|||||||
Reference in New Issue
Block a user