|
@@ -1,10 +1,19 @@
|
|
package cn.cslg.pas.service;
|
|
package cn.cslg.pas.service;
|
|
|
|
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
|
+import cn.cslg.pas.common.utils.DateUtils2;
|
|
import cn.cslg.pas.common.utils.RabbitMQUtils;
|
|
import cn.cslg.pas.common.utils.RabbitMQUtils;
|
|
|
|
+import cn.cslg.pas.domain.business.ImportTask;
|
|
|
|
+import cn.cslg.pas.domain.business.ImportTaskCondition;
|
|
|
|
+import cn.cslg.pas.domain.business.Project;
|
|
|
|
+import cn.cslg.pas.domain.business.SystemDict;
|
|
|
|
+import cn.cslg.pas.service.business.ImportTaskConditionService;
|
|
|
|
+import cn.cslg.pas.service.business.ProjectService;
|
|
|
|
+import cn.cslg.pas.service.business.SystemDictService;
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -21,6 +30,12 @@ public class MailSendService {
|
|
private String url;
|
|
private String url;
|
|
@Autowired
|
|
@Autowired
|
|
private RabbitMQUtils rabbitMQUtils;
|
|
private RabbitMQUtils rabbitMQUtils;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ImportTaskConditionService importTaskConditionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectService projectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SystemDictService systemDictService;
|
|
|
|
|
|
//发送协同邮件
|
|
//发送协同邮件
|
|
public String sendSynery(String personId, Boolean ifInner, Integer projectId, Integer taskId, Integer reportType, String code) {
|
|
public String sendSynery(String personId, Boolean ifInner, Integer projectId, Integer taskId, Integer reportType, String code) {
|
|
@@ -131,16 +146,89 @@ public class MailSendService {
|
|
if (!res.equals("")) {
|
|
if (!res.equals("")) {
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
List<Personnel> personnels = JSON.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
List<Personnel> personnels = JSON.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
- Personnel personnel =personnels.get(0);
|
|
|
|
|
|
+ Personnel personnel = personnels.get(0);
|
|
|
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
+ map.put("title", "任务通知");
|
|
|
|
+ map.put("template", "mail/eTaskDone.html");
|
|
|
|
+ map.put("value1", personnel.getPersonnelName());
|
|
|
|
+ map.put("img", "\\src\\main\\resources\\mail\\logo.png");
|
|
|
|
+ map.put("email", personnel.getPersonnelEmail());
|
|
|
|
+ map.put("value2", taskTypeName);
|
|
|
|
+ map.put("value3", taskName);
|
|
|
|
+ rabbitMQUtils.sendEmailMessage(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void sendCycleImportTaskDoneEmail(ImportTask importTask) {
|
|
|
|
+ ImportTaskCondition importTaskCondition = importTaskConditionService.getById(importTask.getImportTaskConditionId());
|
|
|
|
+ Integer projectId = importTaskCondition.getProjectId();
|
|
|
|
+ Project project = projectService.getById(projectId);
|
|
|
|
+ String personId = importTask.getCreateId();
|
|
|
|
+ String res = "";
|
|
|
|
+ try {
|
|
|
|
+ res = permissionService.getPersonnelByIdsFromPCS(Arrays.asList(personId));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ }
|
|
|
|
+ if (!res.equals("")) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ List<Personnel> personnels = JSON.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
|
+ Personnel personnel = personnels.get(0);
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
- map.put("title","任务通知");
|
|
|
|
- map.put("template","mail/eTaskDone.html");
|
|
|
|
- map.put("value1",personnel.getPersonnelName());
|
|
|
|
- map.put("img","\\src\\main\\resources\\mail\\logo.png");
|
|
|
|
- map.put("email",personnel.getPersonnelEmail());
|
|
|
|
- map.put("value2",taskTypeName);
|
|
|
|
- map.put("value3",taskName);
|
|
|
|
|
|
+ map.put("title", "监控通知");
|
|
|
|
+ map.put("template", "mail/cycleTaskDone.html");
|
|
|
|
+ map.put("value1", personnel.getPersonnelName());
|
|
|
|
+ map.put("img", "\\src\\main\\resources\\mail\\logo.png");
|
|
|
|
+ map.put("email", personnel.getPersonnelEmail());
|
|
|
|
+ map.put("value2", project.getName());
|
|
|
|
+ String dateRange = "";
|
|
|
|
+ if (importTask != null) {
|
|
|
|
+ if (importTask.getLastUpdateToDate() != null) {
|
|
|
|
+ if (importTask.getUpdateToDate() != null) {
|
|
|
|
+ String toDateStr = DateUtils2.dateTimeToPatentStr(importTask.getUpdateToDate());
|
|
|
|
+ String fromDateStr = DateUtils2.dateTimeToPatentStr(importTask.getLastUpdateToDate());
|
|
|
|
+ dateRange = toDateStr + "~" + fromDateStr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if (importTask.getUpdateToDate() != null) {
|
|
|
|
+ String toDateStr = DateUtils2.dateTimeToPatentStr(importTask.getUpdateToDate());
|
|
|
|
+
|
|
|
|
+ dateRange = "<" + toDateStr;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put("value3", dateRange);
|
|
|
|
+ map.put("value4", importTask.getAllNum());
|
|
rabbitMQUtils.sendEmailMessage(map);
|
|
rabbitMQUtils.sendEmailMessage(map);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void sendSysCycleStartEmail() {
|
|
|
|
+ LambdaQueryWrapper<SystemDict> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.in(SystemDict::getType, "ADMIN");
|
|
|
|
+ List<SystemDict> systemDictList = systemDictService.list(queryWrapper);
|
|
|
|
+ if(systemDictList.size()==0){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
+ map.put("title", "监控通知");
|
|
|
|
+ map.put("template", "mail/sysCycleStart.html");
|
|
|
|
+ map.put("img", "\\src\\main\\resources\\mail\\logo.png");
|
|
|
|
+ if (systemDictList != null && systemDictList.size() > 0) {
|
|
|
|
+ SystemDict systemDict = systemDictList.remove(0);
|
|
|
|
+ map.put("email", systemDict.getValue());
|
|
|
|
+ if (systemDictList.size() > 0) {
|
|
|
|
+ String[] ccs = new String[systemDictList.size()];
|
|
|
|
+ for (int i = 0; i < systemDictList.size(); i++) {
|
|
|
|
+ ccs[i] = systemDictList.get(i).getValue();
|
|
|
|
+ }
|
|
|
|
+ map.put("cc", ccs);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ rabbitMQUtils.sendEmailMessage(map);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|