Commit b9114eb7 by fudahua

会员标签同步-告警

parent 8589e46e
......@@ -4,15 +4,25 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2021/8/2.
*/
public enum AlertTypeEnum {
QYWX_TAG_SYNC(1, "企微标签同步"),
QUNFA_MESSAGE(2, "企微群发"),
FRIEND_ADD(3, "企微好友添加"),;
QYWX_TAG_SYNC(1, "企微标签同步", null),
QUNFA_MESSAGE(2, "企微群发", null),
FRIEND_ADD(3, "企微好友添加", null),;
private Integer type;
private String name;
private String dingUrl;
AlertTypeEnum(Integer type, String name) {
AlertTypeEnum(Integer type, String name, String dingUrl) {
this.type = type;
this.name = name;
this.dingUrl = dingUrl;
}
public String getDingUrl() {
return dingUrl;
}
public void setDingUrl(String dingUrl) {
this.dingUrl = dingUrl;
}
public Integer getType() {
......@@ -30,4 +40,14 @@ public enum AlertTypeEnum {
public void setName(String name) {
this.name = name;
}
public static AlertTypeEnum getEnum(int type) {
AlertTypeEnum[] values = AlertTypeEnum.values();
for (AlertTypeEnum value : values) {
if (value.getType() == type) {
return value;
}
}
return null;
}
}
......@@ -149,13 +149,19 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
dingMap.put("markdown", markdownMap);
String text = "";
//企业微信标签同步
if (messageDTO.getAlertType().equals(AlertTypeEnum.QYWX_TAG_SYNC.getType())) {
markdownMap.put("title", AlertTypeEnum.QYWX_TAG_SYNC.getName() + "-" + messageDTO.getAlertTitle());
text += "标题:" + AlertTypeEnum.QYWX_TAG_SYNC.getName() + "-" + messageDTO.getAlertTitle() + "\n\r";
String dingUrl = ALERT_URL;
AlertTypeEnum anEnum = AlertTypeEnum.getEnum(messageDTO.getAlertType());
if (anEnum != null) {
markdownMap.put("title", anEnum.getName() + "-" + messageDTO.getAlertTitle());
text += "标题:" + anEnum.getName() + "-" + messageDTO.getAlertTitle() + "\n\r";
if (anEnum.getDingUrl() != null) {
dingUrl = anEnum.getDingUrl();
}
} else {
markdownMap.put("title", messageDTO.getAlertTitle());
text += "标题:" + messageDTO.getAlertTitle() + "\n\r";
}
//企业信息
if (StringUtils.isNotBlank(messageDTO.getWxEnterpriseId())) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(messageDTO.getWxEnterpriseId());
......@@ -180,7 +186,7 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
text += "链路:[" + messageDTO.getTraceId() + "](" + traceUrl + ")";
}
markdownMap.put("text", text);
String post = HttpUtil.post(ALERT_URL, JSONObject.toJSONString(dingMap));
String post = HttpUtil.post(dingUrl, JSONObject.toJSONString(dingMap));
logger.info("alert:{}", post);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment