Commit ca386fa9 by 18356073052

增加客户列表保存到redis,查询从redis中读取

1 parent 111a3877
......@@ -380,4 +380,6 @@ public class WeConstans {
* 第三方应用ID,参数标实
*/
public static final String THIRD_APP_PARAM_TIP = "agentId";
public static final String WECUSTOMERS_KEY="weCustomer";
}
......@@ -7,11 +7,14 @@ import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.elasticsearch.ElasticSearch;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.service.IWeChatContactMappingService;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeSensitiveActHitService;
import com.linkwechat.wecom.service.IWeSensitiveService;
import com.tencent.wework.FinanceUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
......@@ -43,6 +46,8 @@ public class RyTask {
private IWeSensitiveService weSensitiveService;
@Autowired
private IWeSensitiveActHitService weSensitiveActHitService;
@Autowired
private IWeCustomerService weCustomerService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
......@@ -90,6 +95,21 @@ public class RyTask {
}
}
public void WeCustomers(){
//查询系统所有客户
List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if(CollectionUtils.isEmpty(cacheList)){
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY,customers);
}else {
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
List<WeCustomer> weCustomers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if(CollectionUtils.isNotEmpty(weCustomers) && weCustomers.size()<customers.size()){
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY,customers);
}
}
}
private void setRedisCacheSeqValue(AtomicLong index) {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
SortBuilder<?> sortBuilderPrice = SortBuilders.fieldSort(WeConstans.CONTACT_SEQ_KEY).order(SortOrder.DESC);
......
......@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.enums.ChatType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils;
......@@ -61,6 +62,9 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Autowired
private IWeCustomerMessgaeResultService weCustomerMessgaeResultService;
@Autowired
private RedisCache redisCache;
@Override
@Transactional
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException {
......@@ -384,8 +388,8 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
*/
public List<WeCustomer> externalUserIds(String pushRange, String staffId, String department, String tag) {
if (pushRange.equals("0")) {
//查询系统所有客户
return weCustomerService.selectWeCustomerList(null);
//从redis中读取数据
return redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
} else {
//按条件查询客户
//通过部门id查询所有的员工
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!