Commit 5c4ab7ba by 墨竹

fix:dingding告警修改

parent a9db0e32
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
......@@ -9,6 +10,7 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.AlertTypeEnum;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -109,23 +111,28 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
RBucket<Object> bucket = RedisUtil.getRedisClient().getBucket(key);
boolean b = bucket.trySet(1, 2L, TimeUnit.HOURS);
if (!b) {
logger.info("同一个企业加好友2小时内重复无需提醒");
return;
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
String traceId = providerLocalTag.traceId;
String traceUrl = "http://10.105.8.172:8780/damo-stats/mongodb/getLogMessagesView?trace_id=" + traceId;
String title = wxEnterpriseDTO.getCorpName() + ": " + titleSub;
AlertMessageDTO messageDTO = new AlertMessageDTO();
messageDTO.setAlertTitle(titleSub);
messageDTO.setEnterpriseId(dto.getEnterpriseId());
messageDTO.setAlertType(AlertTypeEnum.QYWX_TAG_SYNC.getType());
messageDTO.setWxEnterpriseId(wxEnterpriseId);
Map<String, Object> map = new HashMap<>();
Map<String, Object> link = new HashMap<>();
map.put("msgtype", "link");
link.put("title", title);
link.put("text", JSONObject.toJSONString(dto));
link.put("messageUrl", traceUrl);
map.put("link", link);
String post = HttpUtil.post(ALERT_URL, JSONObject.toJSONString(map));
logger.info("alert:{}", post);
map.put("员工userid", dto.getWxUserId());
map.put("企业id", dto.getEnterpriseId());
messageDTO.setContentMap(map);
messageDTO.setTraceId(traceId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("haobanAlertMq", JSONObject.toJSONString(messageDTO));
} catch (Exception e) {
logger.info("异常:{}", e.getMessage(),e);
}
}
@Override
......@@ -203,7 +210,7 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
}
markdownMap.put("text", text.toString());
String post = HttpUtil.post(dingUrl, JSONObject.toJSONString(dingMap));
logger.info("alert:{}", post);
logger.info("dingding推送alert:{}", post);
}
}
......@@ -6,13 +6,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.ToolUtil;
import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.haoban.app.customer.enums.QywxTaskStatusEnum;
import com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.AlertTypeEnum;
import com.gic.haoban.manage.api.enums.QywxTagRelationSyncFlagEnum;
import com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum;
import com.gic.haoban.manage.api.service.QywxTagApiService;
......@@ -787,10 +785,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
@Override
public void checkQywxSync(String params) {
List<TabHaobanWxEnterprise> wxEnterprises = wxEnterpriseService.listAll();
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
String traceIdMid = providerLocalTag.traceId;
wxEnterprises.forEach(wxEnterprise -> {
String traceId = providerLocalTag.traceId = traceIdMid + "_" + wxEnterprise.getWxEnterpriseId();
logger.info("企业:{}", wxEnterprise.getWxEnterpriseId());
try {
List<TabQywxTagRelation> tagRelations = qywxTagService.listAllQywxRelation(wxEnterprise.getWxEnterpriseId());
......@@ -804,21 +799,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
for (TabQywxTagRelation qywxTagRelation : qywxTagRelations) {
Map<String, Object> map = checkQywxSyncByQywxTag(qywxTagRelation, wxEnterprise, pojo);
if (MapUtils.isNotEmpty(map)) {
AlertMessageDTO messageDTO = new AlertMessageDTO();
messageDTO.setAlertTitle("企微与好办同步标签不相同");
messageDTO.setEnterpriseId(qywxTagRelation.getEnterpriseId());
messageDTO.setAlertType(AlertTypeEnum.QYWX_TAG_SYNC.getType());
messageDTO.setWxEnterpriseId(wxEnterprise.getWxEnterpriseId());
messageDTO.setContentMap(map);
messageDTO.setTraceId(traceId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("haobanAlertMq", JSONObject.toJSONString(messageDTO));
} catch (Exception e) {
e.printStackTrace();
logger.info("异常:{}", e);
}
logger.error("企微与好办同步标签不相同:{}",JSON.toJSONString(map));
}
}
} catch (Exception e) {
......
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