|
@@ -2,34 +2,50 @@ package com.fdkankan.contro.mq.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.contro.entity.*;
|
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
|
|
|
import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.contro.mq.service.ICommonService;
|
|
|
+import com.fdkankan.contro.service.*;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
-import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.FloorPlanUserUtil;
|
|
|
-import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import com.fdkankan.sms.SendMailAcceUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class CommonServiceImpl implements ICommonService {
|
|
|
|
|
|
+ @Value("${main.url}")
|
|
|
+ private String mainUrl;
|
|
|
+
|
|
|
+ @Value("${env:gn}")
|
|
|
+ private String env;
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private IMailTemplateService mailTemplateService;
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -149,4 +165,44 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
String hourseTypeJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan.json";
|
|
|
fYunFileServiceInterface.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendEmail(String num) {
|
|
|
+ try {
|
|
|
+ Long userId = null;
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(num);
|
|
|
+ if(Objects.isNull(scenePro)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ userId = scenePro.getUserId();
|
|
|
+ }else{
|
|
|
+ userId = scenePlus.getUserId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Objects.isNull(userId)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ User user = userService.getById(scenePlus.getUserId());
|
|
|
+ if(Objects.isNull(user) || StrUtil.isEmpty(user.getUserName())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String toEmail = user.getUserName();
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String sceneLink = scenePlusExt.getWebSite();
|
|
|
+ String helpLink = mainUrl + "/#/service/use/help ";
|
|
|
+ String lang = "en";
|
|
|
+ if("gn".equals(env)){
|
|
|
+ lang = "zh";
|
|
|
+ }
|
|
|
+ sceneLink += "&lang=" + lang;
|
|
|
+
|
|
|
+ MailTemplate mailTemplate = mailTemplateService.getOne(new LambdaQueryWrapper<MailTemplate>().eq(MailTemplate::getRemark, "计算完成").eq(MailTemplate::getLang, lang));
|
|
|
+ String content = mailTemplate.getMsg().replaceAll("scene_link", sceneLink).replaceAll("help_link", helpLink);
|
|
|
+ SendMailAcceUtils.sendMail(mailTemplate.getSendMail(), mailTemplate.getSendPassword(), mailTemplate.getSendHost(), toEmail, mailTemplate.getSubject(), content, null);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.warn("发送邮件失败,num:{}", num);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|