|
@@ -3,17 +3,18 @@ package com.fdkankan.ucenter.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.ucenter.common.constants.ResultCode;
|
|
|
-import com.fdkankan.ucenter.entity.MailTemplate;
|
|
|
-import com.fdkankan.ucenter.entity.ScenePlus;
|
|
|
-import com.fdkankan.ucenter.entity.ScenePro;
|
|
|
+import com.fdkankan.ucenter.entity.*;
|
|
|
import com.fdkankan.ucenter.mapper.IMailTemplateMapper;
|
|
|
import com.fdkankan.ucenter.service.IMailTemplateService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.ucenter.service.IScenePlusExtService;
|
|
|
import com.fdkankan.ucenter.util.SendMailUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -28,6 +29,9 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
public class MailTemplateServiceImpl extends ServiceImpl<IMailTemplateMapper, MailTemplate> implements IMailTemplateService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IScenePlusExtService scenePlusExtService;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean sendMail(String email , MailTemplate mailTemplate, String file) {
|
|
|
if(mailTemplate == null){
|
|
@@ -90,35 +94,61 @@ public class MailTemplateServiceImpl extends ServiceImpl<IMailTemplateMapper, Ma
|
|
|
if(proList.size()<=0 && plusList.size() <=0){
|
|
|
return false;
|
|
|
}
|
|
|
- String sceneName = null;
|
|
|
+ StringBuilder webSites = new StringBuilder();
|
|
|
for (ScenePro scenePro : proList) {
|
|
|
- sceneName = scenePro.getSceneName();
|
|
|
+ webSites.append(scenePro.getWebSite()).append("\n");
|
|
|
}
|
|
|
for (ScenePlus scenePlus : plusList) {
|
|
|
- sceneName = scenePlus.getTitle();
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ if(scenePlusExt != null){
|
|
|
+ webSites.append(scenePlusExt.getWebSite()).append("\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(StringUtils.isBlank(sceneName)){
|
|
|
+ if(StringUtils.isBlank(webSites)){
|
|
|
return false;
|
|
|
}
|
|
|
MailTemplate mailTemplate = this.getTemplate(6,lang);
|
|
|
if(mailTemplate != null){
|
|
|
String msg = mailTemplate.getMsg();
|
|
|
- if(StringUtils.isNotBlank(sceneName)){
|
|
|
- msg = msg.replace("{sceneName}",sceneName);
|
|
|
+ if(StringUtils.isNotBlank(webSites)){
|
|
|
+ msg = msg.replace("{sceneWebSites}",webSites.toString());
|
|
|
}
|
|
|
+ mailTemplate.setMsg(msg);
|
|
|
+ }
|
|
|
+ return sendMail(username,mailTemplate,null);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("邮件发送失败,type:{},error:{}","协作场景邮件",e);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- String subject = mailTemplate.getSubject();
|
|
|
- if(StringUtils.isNotBlank(sceneName)){
|
|
|
- subject = subject.replace("{sceneName}",sceneName);
|
|
|
+ @Override
|
|
|
+ public Boolean sendCameraCooperation(HashMap<Long, Camera> cameraMap, String username, String lang) {
|
|
|
+ try {
|
|
|
+ if(cameraMap.size()<=0 ){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ StringBuilder snCodes = new StringBuilder();
|
|
|
+ for (Long cameraId : cameraMap.keySet()) {
|
|
|
+ if(cameraMap.get(cameraId) != null){
|
|
|
+ snCodes.append(cameraMap.get(cameraId).getSnCode()).append("\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(snCodes)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ MailTemplate mailTemplate = this.getTemplate(8,lang);
|
|
|
+ if(mailTemplate != null){
|
|
|
+ String msg = mailTemplate.getMsg();
|
|
|
+ if(StringUtils.isNotBlank(snCodes)){
|
|
|
+ msg = msg.replace("{snCodes}",snCodes.toString());
|
|
|
}
|
|
|
-
|
|
|
mailTemplate.setMsg(msg);
|
|
|
- mailTemplate.setSubject(subject);
|
|
|
}
|
|
|
return sendMail(username,mailTemplate,null);
|
|
|
}catch (Exception e){
|
|
|
log.error("邮件发送失败,type:{},error:{}","协作场景邮件",e);
|
|
|
}
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|