|
@@ -293,12 +293,12 @@ public class EmailTemplateService {
|
|
}
|
|
}
|
|
Map<Integer, EmailTemplateInfoDO> templateIdDirectionMap = emailTemplateInfoDOList.stream()
|
|
Map<Integer, EmailTemplateInfoDO> templateIdDirectionMap = emailTemplateInfoDOList.stream()
|
|
.collect(Collectors.toMap(EmailTemplateInfoDO::getId, v -> v, (oldValue, newValue) -> newValue));
|
|
.collect(Collectors.toMap(EmailTemplateInfoDO::getId, v -> v, (oldValue, newValue) -> newValue));
|
|
- // 查询模版适用性规则 -> 判断邮件是否满足模板适用性规则
|
|
|
|
|
|
+ // 查询模版适用性规则 -> 判断邮件是否满足模板适用性规则(模板的适应性规则允许为空 -> 这种情况下满足模板的适用条件)
|
|
List<EmailTemplateApplicationRuleDO> templateApplicationRuleDOList = emailTemplateApplicationRuleMapper.queryByTemplateId(templateIdList);
|
|
List<EmailTemplateApplicationRuleDO> templateApplicationRuleDOList = emailTemplateApplicationRuleMapper.queryByTemplateId(templateIdList);
|
|
- if (CollUtil.isEmpty(templateApplicationRuleDOList)) {
|
|
|
|
- return templateDetailDTOList;
|
|
|
|
|
|
+ Map<Integer, List<EmailTemplateApplicationRuleDO>> templateIdApplicationRuleMap = MapUtil.newHashMap();
|
|
|
|
+ if (CollUtil.isNotEmpty(templateApplicationRuleDOList)) {
|
|
|
|
+ templateIdApplicationRuleMap = templateApplicationRuleDOList.stream().collect(Collectors.groupingBy(EmailTemplateApplicationRuleDO::getTemplateId));
|
|
}
|
|
}
|
|
- Map<Integer, List<EmailTemplateApplicationRuleDO>> templateIdApplicationRuleMap = templateApplicationRuleDOList.stream().collect(Collectors.groupingBy(EmailTemplateApplicationRuleDO::getTemplateId));
|
|
|
|
// 查询模版数据规则
|
|
// 查询模版数据规则
|
|
List<EmailTemplateDataRuleDO> templateDataRuleDOList = emailTemplateDataRuleMapper.queryByTemplateId(templateIdList);
|
|
List<EmailTemplateDataRuleDO> templateDataRuleDOList = emailTemplateDataRuleMapper.queryByTemplateId(templateIdList);
|
|
if (CollUtil.isEmpty(templateDataRuleDOList)) {
|
|
if (CollUtil.isEmpty(templateDataRuleDOList)) {
|
|
@@ -309,9 +309,8 @@ public class EmailTemplateService {
|
|
.filter(e -> (e.getRow() != null && StrUtil.isNotBlank(e.getColumn())) || StrUtil.isNotBlank(e.getFieldRule()))
|
|
.filter(e -> (e.getRow() != null && StrUtil.isNotBlank(e.getColumn())) || StrUtil.isNotBlank(e.getFieldRule()))
|
|
.collect(Collectors.groupingBy(EmailTemplateDataRuleDO::getTemplateId));
|
|
.collect(Collectors.groupingBy(EmailTemplateDataRuleDO::getTemplateId));
|
|
|
|
|
|
- for (Map.Entry<Integer, List<EmailTemplateApplicationRuleDO>> templateIdApplicationRule : templateIdApplicationRuleMap.entrySet()) {
|
|
|
|
- Integer templateId = templateIdApplicationRule.getKey();
|
|
|
|
- List<EmailTemplateApplicationRuleDO> applicationRuleDOList = templateIdApplicationRule.getValue();
|
|
|
|
|
|
+ for (Integer templateId : templateIdList) {
|
|
|
|
+ List<EmailTemplateApplicationRuleDO> applicationRuleDOList = templateIdApplicationRuleMap.get(templateId);
|
|
// 判断是否满足模板适用性规则
|
|
// 判断是否满足模板适用性规则
|
|
boolean isMatchTemplate = isMatchTemplate(textContent, emailContentInfoDTO.getEmailTitle(), emailContentInfoDTO.getFileName(), filePath, applicationRuleDOList);
|
|
boolean isMatchTemplate = isMatchTemplate(textContent, emailContentInfoDTO.getEmailTitle(), emailContentInfoDTO.getFileName(), filePath, applicationRuleDOList);
|
|
if (!isMatchTemplate) {
|
|
if (!isMatchTemplate) {
|
|
@@ -340,11 +339,14 @@ public class EmailTemplateService {
|
|
* @param emailTitle 邮件主题
|
|
* @param emailTitle 邮件主题
|
|
* @param fileName 附件名称
|
|
* @param fileName 附件名称
|
|
* @param filePath 文件路径(邮件正文html转成)
|
|
* @param filePath 文件路径(邮件正文html转成)
|
|
- * @param applicationRuleDOList 模板配置的适用性规则列表
|
|
|
|
|
|
+ * @param applicationRuleDOList 模板配置的适用性规则列表(为空时 -> 返回true)
|
|
* @return true or false
|
|
* @return true or false
|
|
*/
|
|
*/
|
|
private boolean isMatchTemplate(String emailContent, String emailTitle, String fileName,
|
|
private boolean isMatchTemplate(String emailContent, String emailTitle, String fileName,
|
|
String filePath, List<EmailTemplateApplicationRuleDO> applicationRuleDOList) {
|
|
String filePath, List<EmailTemplateApplicationRuleDO> applicationRuleDOList) {
|
|
|
|
+ if (CollUtil.isEmpty(applicationRuleDOList)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
return applicationRuleDOList.stream()
|
|
return applicationRuleDOList.stream()
|
|
.allMatch(e -> isMathApplicationRule(e, emailContent, emailTitle, fileName, filePath));
|
|
.allMatch(e -> isMathApplicationRule(e, emailContent, emailTitle, fileName, filePath));
|
|
}
|
|
}
|