Commit 42f44a17 by 徐高华

好办加好友统计

parent a68f12e7
...@@ -85,17 +85,20 @@ public class TabQywxErrorLogServiceImpl implements QywxErrorLogService { ...@@ -85,17 +85,20 @@ public class TabQywxErrorLogServiceImpl implements QywxErrorLogService {
@Override @Override
public void doFriendTimer(String params) { public void doFriendTimer(String params) {
log.info("加好友异常重试"); log.info("加好友异常重试");
Date start = DateUtil.getStartTimeOfDay() ; Date yesterday = DateUtil.addDay(new Date() , -1) ;
Date end = DateUtil.getEndTimeOfDay() ; Date start = DateUtil.getStartTimeOfDay(yesterday) ;
Date end = DateUtil.getEndTimeOfDay(yesterday) ;
List<TabQywxErrorLog> list = this.tabQywxErrorLogMapper.listErrorFriend(null,4, start, end) ; List<TabQywxErrorLog> list = this.tabQywxErrorLogMapper.listErrorFriend(null,4, start, end) ;
if(CollectionUtils.isNotEmpty(list)) { if(CollectionUtils.isNotEmpty(list)) {
String mqName = "dealQywxExternalUserMq2"; String mqName = "dealQywxExternalUserMq2";
for(TabQywxErrorLog tab : list) { for(TabQywxErrorLog tab : list) {
DealQywxExternalUserPojo dealQywxExternalUserPojo = new DealQywxExternalUserPojo();
dealQywxExternalUserPojo.setType(DealQywxExternalUserPojo.DealType.add.getType());
dealQywxExternalUserPojo.setData(JSONObject.parseObject(tab.getErrorContent(), QwFrientNoticeDTO.class));
try { try {
clientInstance.sendMessage(mqName, JSONObject.toJSONString(dealQywxExternalUserPojo)); DealQywxExternalUserPojo dealQywxExternalUserPojo = new DealQywxExternalUserPojo();
dealQywxExternalUserPojo.setType(DealQywxExternalUserPojo.DealType.add.getType());
if(StringUtils.isNotBlank(tab.getErrorContent())) {
dealQywxExternalUserPojo.setData(JSONObject.parseObject(tab.getErrorContent(), QwFrientNoticeDTO.class));
clientInstance.sendMessage(mqName, JSONObject.toJSONString(dealQywxExternalUserPojo));
}
} catch (Exception e) { } catch (Exception e) {
log.info("异步处理异常:{}", e); log.info("异步处理异常:{}", e);
} }
......
package com.gic.haoban.manage.service.util; package com.gic.haoban.manage.service.util;
import com.gic.commons.util.IPUtil;
import com.gic.dubbo.util.DubboInvokeUtil;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.service.pojo.HBQwMonitorBO; import com.gic.haoban.manage.service.pojo.HBQwMonitorBO;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -17,16 +20,17 @@ public class HBQwMonitorUtils { ...@@ -17,16 +20,17 @@ public class HBQwMonitorUtils {
private static Logger logger = LogManager.getLogger(HBQwMonitorUtils.class); private static Logger logger = LogManager.getLogger(HBQwMonitorUtils.class);
private static final List<String> keyList = Arrays.asList("hbDatakey:qwFriendNotice","hbDataKey:addFriendFail") ; private static final List<String> keyList = Arrays.asList("hbmonitor:friendNotice","hbmonitor:friendFail") ;
/** /**
* @param index 0加好友企微通知数量 1加好友查询企微接口限制数量 * @param index 0加好友企微通知数量 1加好友查询企微接口限制数量
*/ */
public static void addForFriend(int index) { public static void addForFriend(int index) {
logger.info("addForFriend"); String ip = IPUtil.getLocalIP();
String key = keyList.get(index) ; logger.info("addForFriend={}",ip);
String key = keyList.get(index)+ip ;
RAtomicLong cache = RedisUtil.getRedisClient().getAtomicLong(key); RAtomicLong cache = RedisUtil.getRedisClient().getAtomicLong(key);
long val = cache.addAndGet(1); cache.addAndGet(1);
} }
...@@ -35,21 +39,24 @@ public class HBQwMonitorUtils { ...@@ -35,21 +39,24 @@ public class HBQwMonitorUtils {
} }
public static void addByTimer() { public static void addByTimer() {
List<String> ipList = DubboInvokeUtil.getServiceHostList(MemberUnionidRelatedApiService.class) ;
logger.info("add timer"); logger.info("add timer");
for(int i=0;i<keyList.size();i++) { for(int i=0;i<keyList.size();i++) {
String key = keyList.get(i) ; for(String ip : ipList) {
int count = 0 ; String key = keyList.get(i)+ip ;
Object countObj = RedisUtil.getCache(key) ; int count = 0 ;
if(null != countObj) { Object countObj = RedisUtil.getCache(key) ;
count = Integer.valueOf(countObj.toString()) ; if(null != countObj) {
count = Integer.valueOf(countObj.toString()) ;
}
RAtomicLong cache = RedisUtil.getRedisClient().getAtomicLong(key);
cache.addAndGet(-count) ;
HBQwMonitorBO bo = new HBQwMonitorBO() ;
bo.setHost(ip);
bo.setType(""+i);
bo.setNum(count);
InfluxDbMonitorUtils.getInstance().friendAdd(bo);
} }
RAtomicLong cache = RedisUtil.getRedisClient().getAtomicLong(key);
cache.addAndGet(-count) ;
HBQwMonitorBO bo = new HBQwMonitorBO() ;
bo.setHost("127.0.0.1");
bo.setType(""+i);
bo.setNum(count);
InfluxDbMonitorUtils.getInstance().friendAdd(bo);
} }
} }
......
...@@ -58,6 +58,7 @@ public class InfluxDbMonitorUtils { ...@@ -58,6 +58,7 @@ public class InfluxDbMonitorUtils {
influxDB.write(Point.measurement("hb_qw_friend_monitor") influxDB.write(Point.measurement("hb_qw_friend_monitor")
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS) .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.addField("num", bo.getNum()) .addField("num", bo.getNum())
.tag("application","haoban-manage3")
.tag("host", bo.getHost()) .tag("host", bo.getHost())
.tag("type", bo.getType()) .tag("type", bo.getType())
.build()); .build());
......
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