Commit 3942d87c by 李传峰

feat:[none] 处理超时,4千多个批量调用改单个单个调用

parent 0f0cb089
package com.pcloud.book.advertising.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.book.advertising.biz.LinkRevertBiz;
import com.pcloud.book.advertising.dao.AdvertisingBrandDao;
import com.pcloud.book.advertising.dao.AdvertisingGroupTagDao;
......@@ -27,6 +28,8 @@ import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.message.dto.LinkGroupParamDTO;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -48,6 +51,8 @@ import java.util.stream.Collectors;
@Component("linkRevertBiz")
public class LinkRevertBizImpl implements LinkRevertBiz {
private Logger logger = LoggerFactory.getLogger(getClass());
@Value("${wechat.group.link.prefix}")
private String wechatGroupLinkPrefix;
@Autowired
......@@ -171,6 +176,7 @@ public class LinkRevertBizImpl implements LinkRevertBiz {
new Thread() {
@Override
public void run() {
long start = System.currentTimeMillis();
List<AdvertisingLinkRevert> list = advertisingLinkRevertDao.getAll();
if (ListUtils.isEmpty(list)) {
return;
......@@ -181,15 +187,20 @@ public class LinkRevertBizImpl implements LinkRevertBiz {
List<String> groupIds = advertisingGroupTagDao.getTagWxGroupIdsByBrandId(brandId);
groupMap.put(brandId, groupIds);
}
List<LinkGroupParamDTO> paramDTOS = new ArrayList<>();
long s2 = System.currentTimeMillis();
Map<String, Integer> sendCountMap = new HashMap<>();
for (AdvertisingLinkRevert linkRevert : list) {
LinkGroupParamDTO paramDTO = new LinkGroupParamDTO();
paramDTO.setLink(linkRevert.getShortLink());
paramDTO.setWxGroupIds(groupMap.get(linkRevert.getBrandId()));
paramDTO.setDate(DateUtils.getYesterday());
paramDTOS.add(paramDTO);
Map<String, Integer> scMap = wechatGroupConsr.getLinkSendCount(Lists.newArrayList(paramDTO));
sendCountMap.putAll(scMap);
}
Map<String, Integer> sendCountMap = wechatGroupConsr.getLinkSendCount(paramDTOS);
long s3 = System.currentTimeMillis();
List<AdvertisingLinkSend> sendList = new ArrayList<>();
for (AdvertisingLinkRevert linkRevert : list) {
AdvertisingLinkSend linkSend = new AdvertisingLinkSend();
......@@ -204,6 +215,9 @@ public class LinkRevertBizImpl implements LinkRevertBiz {
sendList.add(linkSend);
}
advertisingLinkSendDao.insert(sendList);
long s4 = System.currentTimeMillis();
logger.warn("统计昨日链接发送次数,总耗时={},查询数据耗时={},wechatGroup耗时={},写数据耗时={}", s4 - start, s2 - start, s3 - s2, s4 - s3);
}
}.start();
}
......
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