提交 ba1bd79f 作者: 洪东保

每次发送邮件发送一个额外使用手册文件

父级 a7776cce
......@@ -35,6 +35,7 @@ import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -263,6 +264,12 @@ public class MeetingInfoController {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMdd");
EmailPush.Attachment attachment = EmailPush.Attachment.builder().name(meetingInfo.getSubject() + "会议纪要_" + fmt.format(meetingInfo.getStartTime())).bytes(meetingMinutesBytes).build();
attachments.add(attachment);
org.springframework.core.io.Resource resource = new ClassPathResource("static/Cmeeting会议助手使用手册.pdf");
byte[] meetingMinutesBytes2 = IOUtils.toByteArray(resource.getInputStream());
EmailPush.Attachment attachment2 = EmailPush.Attachment.builder().name("Cmeeting会议助手使用手册.pdf").bytes(meetingMinutesBytes2).build();
attachments.add(attachment2);
String hostUid = meetingInfo.getHostUid();
String userCode = userIdMapper.getWidByTid(hostUid);
EmailPush emailPushBuilder = EmailPush.builder()
......
......@@ -172,9 +172,14 @@ public class EmailSender {
LinkedList<Attachment> attachmentsList = new LinkedList<>();
for (EmailPush.Attachment attachment : emailPushBuilder.getAttachments()) {
FileAttachment attachments = new FileAttachment();
attachments.name = attachment.getName() + ".docx";
if (attachment.getName().endsWith(".pdf")) {
attachments.name = attachment.getName();
attachments.contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
} else {
attachments.name = attachment.getName() + ".docx";
attachments.contentType = "application/pdf";
}
attachments.oDataType = "#microsoft.graph.fileAttachment";
attachments.contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
attachments.contentBytes = attachment.getBytes();
attachmentsList.add(attachments);
}
......
......@@ -21,6 +21,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import java.io.*;
......@@ -120,6 +122,11 @@ public class EmailPushTask {
FileUtil.del(dataNetworkMinutesPath);
}
Resource resource = new ClassPathResource("static/Cmeeting会议助手使用手册.pdf");
byte[] meetingMinutesBytes = IOUtils.toByteArray(resource.getInputStream());
EmailPush.Attachment attachment = EmailPush.Attachment.builder().name("Cmeeting会议助手使用手册.pdf").bytes(meetingMinutesBytes).build();
attachments.add(attachment);
String userCode = tidWidRelations.get(hostUid);
EmailPush emailPushBuilder = EmailPush.builder()
.toEmail(meetingInfo.getEmail())
......
......@@ -49,6 +49,8 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
......@@ -200,6 +202,12 @@ public class FileProcessTask {
isSuccess = false;
continue;
}
Resource resource = new ClassPathResource("static/Cmeeting会议助手使用手册.pdf");
byte[] meetingMinutesBytes = IOUtils.toByteArray(resource.getInputStream());
EmailPush.Attachment attachment = EmailPush.Attachment.builder().name("Cmeeting会议助手使用手册.pdf").bytes(meetingMinutesBytes).build();
attachments.add(attachment);
if (!tidWidRelations.containsKey(meetingInfo.getHostUid())) {
log.error("邮件推送重试失败: 主持人对应关系未配置。meetingRecordId {}", meetingRecordId);
processLogService.log(meetingId, subMeetingId, "邮件推送重试失败: 主持人对应关系未配置。meetingRecordId:"+meetingRecordId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论