认证-参数项收集清单-变更:导出时发送消息

This commit is contained in:
liyawei
2022-07-21 17:52:20 +08:00
parent 9070368004
commit c9601c4abb
@@ -68,15 +68,18 @@ import org.aspectj.util.FileUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@@ -2108,6 +2111,40 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
os.write(len);
}
// 将导出文件上传到cos上
String uploadFileName = fileOriName + ".zip";
InputStream uploadFileio = new FileInputStream(new File(fileNowPath+".zip"));
MultipartFile mFile = new MockMultipartFile(uploadFileName, uploadFileName, "text/plain", uploadFileio); // 用于上传
OSSFile ossFile = ossFileService.uploadLocalOfCos(mFile, "/manifest", "", CutEnum.CN.getValue()); // 上传导出的压缩包
// 系统向用户发消息
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录人
String msgTitle = "您导出的" + paramsCollectManifestVO.getExportName() + "已经生成完毕";
String content = "您导出的" + paramsCollectManifestVO.getExportName() + "已经生成完毕,请点击下载。";
String href = "<a href='/jero-boot/sys/common/downLoadFile?id=" + ossFile.getId() + "'" + " target='_blank'>下载</a>。";
String contentInfo = "您导出的" + paramsCollectManifestVO.getExportName() + "已经生成完毕,请点击" + href;
SysAnnouncement sysAnnouncement = new SysAnnouncement();
sysAnnouncement.setDelFlag("0");
sysAnnouncement.setSendStatus("0");
sysAnnouncement.setSendTime(new Date());
sysAnnouncement.setMsgCategory(MessageTypeEnum.PUSH.getValue()); //消息类型:转发推送
sysAnnouncement.setInitiator(MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName()); // 发起人:系统
sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR);//指定用户
sysAnnouncement.setTitile(msgTitle);
sysAnnouncement.setMsgContent(content);
sysAnnouncement.setMsgContentInfo(contentInfo);
sysAnnouncement.setUserIds(currentUser.getId()); // 发送给当前导出人
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
JSONObject obj = new JSONObject();
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, currentUser.getId());
obj.put(WebsocketConst.MSG_TXT, contentInfo);
webSocket.sendMessage(obj.toJSONString());
uploadFileio.close();
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关