mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
[DAT] 修复时间错误的问题;尝试修复发邮件
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.assistance.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
@@ -51,26 +52,28 @@ public class SmtpEmailServiceImpl implements ISmtpEmailService {
|
||||
|
||||
if ("ssl".equalsIgnoreCase(SMTP_ENCRYPTION)) {
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
props.put("mail.smtp.ssl.protocols", "TLSv1.2");
|
||||
props.put("mail.smtp.ssl.trust", SMTP_HOST);
|
||||
// props.put("mail.smtp.ssl.protocols", "TLSv1.2");
|
||||
} else if ("tls".equalsIgnoreCase(SMTP_ENCRYPTION)) {
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
}
|
||||
|
||||
// 创建会话
|
||||
Session session = Session.getInstance(props, new Authenticator() {
|
||||
Authenticator authenticator = new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(SMTP_USERNAME, SMTP_PASSWORD);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 创建会话
|
||||
Session session = Session.getInstance(props, authenticator);
|
||||
session.setDebug(true); // 查看调试信息
|
||||
|
||||
try {
|
||||
// 创建邮件消息
|
||||
Message message = new MimeMessage(session);
|
||||
|
||||
// 设置发件人
|
||||
String fromAddress = StringUtils.isNotBlank(from) ? from : SMTP_USERNAME + "@boe.com.cn";
|
||||
message.setFrom(new InternetAddress(fromAddress));
|
||||
message.setFrom(new InternetAddress(SMTP_USERNAME));
|
||||
|
||||
// 设置收件人
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
|
||||
@@ -80,9 +83,12 @@ public class SmtpEmailServiceImpl implements ISmtpEmailService {
|
||||
|
||||
// 设置邮件内容
|
||||
message.setContent(htmlMsg, "text/html;charset=UTF-8");
|
||||
|
||||
// 发送日期
|
||||
message.setSentDate(new Date());
|
||||
|
||||
// 发送邮件
|
||||
log.info("发送邮件. 发件人: {}, 收件人: {}, 标题: {}", fromAddress, to, subject);
|
||||
log.info("发送邮件. 发件人: {}, 收件人: {}, 标题: {}", SMTP_USERNAME, to, subject);
|
||||
Transport.send(message);
|
||||
|
||||
} catch (MessagingException e) {
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -405,6 +406,10 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
caseReferObj.put("authorName", caseRefer.getAuthorName());
|
||||
caseReferObj.put("keywords", caseRefer.getKeywords());
|
||||
caseReferObj.put("content", caseRefer.getContent());
|
||||
// 使用指定的时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
caseReferObj.put("uploadTime", caseRefer.getUploadTime() != null ? caseRefer.getUploadTime().format(formatter) : null);
|
||||
|
||||
caseReferArray.add(caseReferObj);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user