提交 b450608b 作者: duanxincheng

纪要生成后清除磁盘的临时文件

父级 2089d7b6
package com.cmeeting.job;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -7,6 +8,7 @@ import com.cmeeting.email.EmailSender;
import com.cmeeting.mapper.primary.MeetingInfoMapper;
import com.cmeeting.mapper.primary.MeetingRecordTemplateMapper;
import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.pojo.MeetingRecordTemplate;
import com.cmeeting.util.MinioUtils;
import com.cmeeting.vo.EmailPush;
import com.deepoove.poi.XWPFTemplate;
......@@ -56,7 +58,6 @@ public class EmailPushTask {
.eq(subMeetingId != null, MeetingInfo::getSubMeetingId, subMeetingId));
while (retryCount.intValue() <= MAX_RETRY && !isSuccess) {
try {
String nowTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmmss"));
String targetFileName;
String meetingName;
String recordXmlPath = meetingId + "-recordXmlPath-" + IdUtil.fastSimpleUUID() + "xml";
......@@ -77,15 +78,14 @@ public class EmailPushTask {
participantsMap.put("meeting_participants", meetingInfo.getParticipantUsers());
participantsMap.put("meeting_host",meetingInfo.getHost());
dataModel.putAll(participantsMap);
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
ClassPathResource resource = new ClassPathResource("template/data_network.docx");
MeetingRecordTemplate meetingRecordTemplate = meetingRecordTemplateMapper.selectById(1);
meetingName = dataModel.get("meeting_name") != null ? String.valueOf(dataModel.get("meeting_name")) : "腾讯会议纪要";
targetFileName = meetingName + "_data_network";
try (InputStream inputStream = resource.getInputStream()) {
String dataNetworkMinutesPath = savePath + meetingName + "_" + meetingRecordTemplate.getName() + ".docx";
try (InputStream inputStream = minioUtils.getFile(meetingRecordTemplate.getTemplate())) {
XWPFTemplate template = XWPFTemplate.compile(inputStream).render(dataModel);
template.writeAndClose(new FileOutputStream(path + targetFileName + ".docx"));
byte[] recordXmlData = Files.readAllBytes(Paths.get(path + targetFileName + ".docx"));
template.writeAndClose(new FileOutputStream(dataNetworkMinutesPath));
byte[] recordXmlData = Files.readAllBytes(Paths.get(dataNetworkMinutesPath));
minioUtils.upload(recordXmlPath,recordXmlData);
} catch (IOException e) {
e.printStackTrace();
......@@ -93,12 +93,14 @@ public class EmailPushTask {
//邮件推送
List<EmailPush.Attachment> attachments = new ArrayList<>();
try(InputStream is = new FileInputStream(path + targetFileName + ".docx")){
try(InputStream is = new FileInputStream(dataNetworkMinutesPath)){
byte[] meetingMinutesBytes = IOUtils.toByteArray(is);
EmailPush.Attachment attachment = EmailPush.Attachment.builder().name(meetingInfo.getSubject()+"_数据网络中心").bytes(meetingMinutesBytes).build();
EmailPush.Attachment attachment = EmailPush.Attachment.builder().name(meetingInfo.getSubject()+"会议纪要_数据网络中心").bytes(meetingMinutesBytes).build();
attachments.add(attachment);
}catch (Exception e){
throw new RuntimeException(e);
}finally {
FileUtil.del(dataNetworkMinutesPath);
}
EmailPush emailPushBuilder = EmailPush.builder().toEmail(meetingInfo.getEmail()).meetingId(meetingId).attachments(attachments).subject(meetingInfo.getSubject()).build();
isSuccess = emailSender.sendEmailWithAttachment(emailPushBuilder);
......
......@@ -5,6 +5,7 @@ import cn.chatbot.openai.completion.chat.ChatMessage;
import cn.chatbot.openai.completion.chat.ChatMessageRole;
import cn.chatbot.openai.completion.chat.Message;
import cn.chatbot.openai.service.LLMService;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -187,6 +188,8 @@ public class FileProcessTask {
// emailPush(meetingMinutesBytes, meetingInfo.getSubject(), meetingInfo.getEmail(), meetingInfo.getEmailPushAccess());
}catch (Exception e){
throw new RuntimeException(e);
}finally {
FileUtil.del(dataNetworkMinutesPath);
}
String processedResult2 = processWithClaude(recordTextBuffer.toString(),meetingRecordTemplate2.getPrompt());
......@@ -198,6 +201,8 @@ public class FileProcessTask {
// emailPush(meetingMinutesBytes, meetingInfo.getSubject(), meetingInfo.getEmail(), meetingInfo.getEmailPushAccess());
}catch (Exception e){
throw new RuntimeException(e);
}finally {
FileUtil.del(groupOfficeMinutesPath);
}
EmailPush emailPushBuilder = EmailPush.builder().toEmail(meetingInfo.getEmail()).meetingId(meetingId).attachments(attachments).subject(meetingInfo.getSubject()).build();
emailPush(emailPushBuilder);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论