|
@@ -3,16 +3,13 @@ package com.fire.dist.service.impl;
|
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.fire.dist.data.DataPool;
|
|
|
-import com.fire.dist.mapper.CustomerInfoMapper;
|
|
|
-import com.fire.dist.mapper.CustomerProductMapper;
|
|
|
-import com.fire.dist.mapper.FlowAppInfoMapper;
|
|
|
+import com.fire.dist.mapper.*;
|
|
|
import com.fire.dist.service.CacheService;
|
|
|
-import com.fire.dto.CustomerInfo;
|
|
|
-import com.fire.dto.CustomerProduct;
|
|
|
-import com.fire.dto.FlowAppInfo;
|
|
|
+import com.fire.dto.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -34,6 +31,18 @@ public class CacheServiceImpl implements CacheService {
|
|
|
@Resource
|
|
|
private CustomerProductMapper customerProductMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ChannelProductInfoMapper channelProductInfoMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ChannelInfoMapper channelInfoMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DistributeGroupMapper distributeGroupMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ChannelGroupMapper channelGroupMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 缓存客户信息
|
|
@@ -67,9 +76,35 @@ public class CacheServiceImpl implements CacheService {
|
|
|
//将接入信息list 转换为appId为key的map 如果存在重复key,以后出现的为准
|
|
|
DataPool.flowAppInfoMap = appInfos.stream().collect(Collectors.toMap(FlowAppInfo::getAppId, a -> a, (k1, k2) -> k2));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 缓存通道信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void cacheChannel() {
|
|
|
+ List<ChannelProductInfo> productInfos = channelProductInfoMapper.queryAll();
|
|
|
+ List<ChannelInfo> channelInfos = channelInfoMapper.queryAll();
|
|
|
+ List<DistributeGroup> distributeGroups = distributeGroupMapper.queryAll();
|
|
|
+ List<ChannelGroup> channelGroups = channelGroupMapper.queryAll();
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(productInfos) && CollectionUtils.isNotEmpty(channelInfos) && CollectionUtils.isNotEmpty(distributeGroups) && CollectionUtils.isNotEmpty(channelGroups)) {
|
|
|
+ //通道产品 根据 通道id第一层 区域第二层 面额分第三层 进行分组
|
|
|
+ Map<Long, Map<String, Map<Long, List<ChannelProductInfo>>>> productListMap = productInfos.stream().collect(Collectors.groupingBy(ChannelProductInfo::getChannelId, Collectors.groupingBy(ChannelProductInfo::getAreaNum, Collectors.groupingBy(ChannelProductInfo::getStandardPrice))));
|
|
|
+ //将产品挂载到通道上面
|
|
|
+ channelInfos.forEach(a -> a.setProductListMap(productListMap.get(a.getChannelId())));
|
|
|
+ //通道按分发组id进行分组
|
|
|
+ Map<Integer, List<ChannelInfo>> channelListMap = channelInfos.stream().collect(Collectors.groupingBy(ChannelInfo::getDistributeGroupId));
|
|
|
+ //将通道挂载到分发组上面
|
|
|
+ distributeGroups.forEach(a -> a.setChannelInfos(channelListMap.get(a.getDistributeGroupId())));
|
|
|
+ //分发组按 通道组id第一层 运营商第二层 进行分组
|
|
|
+ Map<Long, Map<Integer, List<DistributeGroup>>> distributeGroupListMap = distributeGroups.stream().collect(Collectors.groupingBy(DistributeGroup::getChannelGroupId, Collectors.groupingBy(DistributeGroup::getOperator)));
|
|
|
+ //将分发组进行排序
|
|
|
+ distributeGroupListMap.forEach((k1, v1) -> v1.forEach((k2, v2) -> v2.sort(Comparator.comparingInt(DistributeGroup::getWeight).reversed())));
|
|
|
+ //将分发组挂载到通道组上
|
|
|
+ channelGroups.forEach(a -> a.setDistributeGroupsMap(distributeGroupListMap.get(a.getChannelGroupId())));
|
|
|
+ //通道组转为map 以通道组id为key 存到内存常量中
|
|
|
+ DataPool.channelGroupMap = channelGroups.stream().collect(Collectors.toMap(ChannelGroup::getChannelGroupId, a -> a, (k1, k2) -> k2));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|