|
@@ -1,11 +1,19 @@
|
|
|
package com.example.demo.util;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.example.demo.domain.entity.SysDictItem;
|
|
|
+import com.example.demo.service.OutInterfaceService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.Serializable;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -18,20 +26,26 @@ import java.util.Map;
|
|
|
@Component
|
|
|
public class PatentStarEmail implements Serializable {
|
|
|
private final MessageUtils mailUtils;
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
|
|
|
/**
|
|
|
* 发送邮件通知
|
|
|
*/
|
|
|
- public void sendEmail(String jieKouName, String json) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("title", "专利之星接口调用异常通知");
|
|
|
- map.put("template", "mail/emailPatentStarException.html");
|
|
|
- map.put("value1", jieKouName + "接口异常获取到的信息为:" + json);
|
|
|
- map.put("img", "/logo.png");
|
|
|
- map.put("email", "chendayuya@163.com");
|
|
|
- map.put("value2", "陈宇");
|
|
|
-
|
|
|
- mailUtils.sendEmailMessage(map);
|
|
|
+ public void sendEmail(String jieKouName, String json) throws IOException {
|
|
|
+ //调用权限系统从字典表里获得配置联系人数
|
|
|
+ String res = outInterfaceService.getAdminEmailPersonsFromPCS();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<SysDictItem> sysDictItems = JSON.parseArray(jsonObject.get("data").toString(), SysDictItem.class);
|
|
|
+ sysDictItems.forEach(item -> {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("title", "专利之星接口调用异常通知");
|
|
|
+ map.put("template", "mail/emailPatentStarException.html");
|
|
|
+ map.put("value1", jieKouName + "接口异常获取到的信息为:" + json);
|
|
|
+ map.put("img", "/logo.png");
|
|
|
+ map.put("email", item.getDictChildValue());
|
|
|
+ map.put("value2", item.getDictChildLabel());
|
|
|
+ mailUtils.sendEmailMessage(map);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
}
|