|
@@ -2,16 +2,20 @@ package cn.cslg.pas.service.report;
|
|
|
|
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.SystemFile;
|
|
|
+import cn.cslg.pas.common.model.report.ExtraEmailDTO;
|
|
|
import cn.cslg.pas.common.model.report.MailMessageDTO;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
import cn.cslg.pas.domain.business.Project;
|
|
|
+import cn.cslg.pas.domain.business.ReportProject;
|
|
|
import cn.cslg.pas.domain.report.AssoIprReportType;
|
|
|
import cn.cslg.pas.domain.report.IprPerson;
|
|
|
import cn.cslg.pas.domain.report.MatchCasePerson;
|
|
|
import cn.cslg.pas.exception.ExceptionEnum;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
+import cn.cslg.pas.service.MailSendService;
|
|
|
import cn.cslg.pas.service.business.ProjectService;
|
|
|
+import cn.cslg.pas.service.business.ReportProjectService;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -37,9 +41,11 @@ public class SendReportMailService {
|
|
|
private final FileManagerService fileManagerService;
|
|
|
private final LoginUtils loginUtils;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
+ private final ReportProjectService reportProjectService;
|
|
|
+ private final MailSendService mailSendService;
|
|
|
|
|
|
//装载所需要的数据
|
|
|
- public MailMessageDTO loadingData(Integer reportType, Integer projectId, List<String> fileGuids) {
|
|
|
+ public MailMessageDTO loadingData(Integer projectId, List<String> fileGuids) {
|
|
|
MailMessageDTO mailMessageDTO = new MailMessageDTO();
|
|
|
List<String> names = new ArrayList<>();
|
|
|
List<String> emails = new ArrayList<>();
|
|
@@ -63,11 +69,18 @@ public class SendReportMailService {
|
|
|
}
|
|
|
IprPerson iprPerson = iprPersonService.getById(matchCasePerson.getIprPersonId());
|
|
|
names.add(iprPerson.getName());
|
|
|
- emails.add(iprPerson.getEmail());
|
|
|
+ emails.add(this.loadEmail(iprPerson.getName(), iprPerson.getEmail()));
|
|
|
}
|
|
|
|
|
|
|
|
|
// 根据报告类型查询默认邮箱发送人员
|
|
|
+ LambdaQueryWrapper<ReportProject> reportWrapper = new LambdaQueryWrapper<>();
|
|
|
+ reportWrapper.eq(ReportProject::getProjectId, projectId);
|
|
|
+ ReportProject reportProject = reportProjectService.getOne(reportWrapper, false);
|
|
|
+ if (reportProject == null) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "报告查询错误");
|
|
|
+ }
|
|
|
+ Integer reportType = reportProject.getReportType();
|
|
|
LambdaQueryWrapper<AssoIprReportType> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
queryWrapper2.eq(AssoIprReportType::getReportType, reportType);
|
|
|
List<AssoIprReportType> assoIprReportTypes = assoIprReportTypeService.list(queryWrapper2);
|
|
@@ -78,11 +91,13 @@ public class SendReportMailService {
|
|
|
iprPersonIds.addAll(defaultIprPersonIds);
|
|
|
LambdaQueryWrapper<IprPerson> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
queryWrapper3.in(IprPerson::getId, iprPersonIds)
|
|
|
- .eq(IprPerson::getIfDefault, 1);
|
|
|
+ .eq(IprPerson::getIfDefault, true);
|
|
|
List<IprPerson> iprPersonList = iprPersonService.list(queryWrapper3);
|
|
|
if (iprPersonList != null && !iprPersonList.isEmpty()) {
|
|
|
- names.addAll(iprPersonList.stream().map(IprPerson::getName).collect(Collectors.toList()));
|
|
|
- emails.addAll(iprPersonList.stream().map(IprPerson::getEmail).collect(Collectors.toList()));
|
|
|
+ for (IprPerson iprPerson : iprPersonList) {
|
|
|
+ names.add(iprPerson.getName());
|
|
|
+ emails.add(this.loadEmail(iprPerson.getName(), iprPerson.getEmail()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
names = names.stream().distinct().collect(Collectors.toList());
|
|
@@ -101,6 +116,7 @@ public class SendReportMailService {
|
|
|
List<String> fileNames = systemFiles.stream().map(SystemFile::getOriginalName).collect(Collectors.toList());
|
|
|
String fileName = this.appendStr(fileNames);
|
|
|
mailMessageDTO.setFileName(fileName);
|
|
|
+ mailMessageDTO.setFileGuids(fileGuids);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "文件查询错误");
|
|
@@ -133,4 +149,25 @@ public class SendReportMailService {
|
|
|
}
|
|
|
return result.toString();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public String loadEmail(String name, String email) {
|
|
|
+ return name + " <" + email + ">";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void finalSendEmail(Integer projectId, List<String> fileGuids, List<ExtraEmailDTO> extraEmailDTOS) {
|
|
|
+ MailMessageDTO mailMessageDTO = this.loadingData(projectId, fileGuids);
|
|
|
+ if (mailMessageDTO != null) {
|
|
|
+ mailSendService.sendReportEmail(mailMessageDTO);
|
|
|
+ if (extraEmailDTOS != null && !extraEmailDTOS.isEmpty()) {
|
|
|
+ List<String> emails = new ArrayList<>();
|
|
|
+ for (ExtraEmailDTO extraEmailDTO : extraEmailDTOS) {
|
|
|
+ emails.add(this.loadEmail(extraEmailDTO.getName(), extraEmailDTO.getEmail()));
|
|
|
+ }
|
|
|
+ mailMessageDTO.setEmails(emails);
|
|
|
+ mailSendService.sendReportEmail(mailMessageDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|