|
@@ -2,9 +2,11 @@ package com.fire.order.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.fire.dto.CustomerInfo;
|
|
import com.fire.dto.CustomerInfo;
|
|
|
|
+import com.fire.dto.CustomerProduct;
|
|
import com.fire.dto.FlowAppInfo;
|
|
import com.fire.dto.FlowAppInfo;
|
|
import com.fire.order.data.DataPool;
|
|
import com.fire.order.data.DataPool;
|
|
import com.fire.order.mapper.CustomerInfoMapper;
|
|
import com.fire.order.mapper.CustomerInfoMapper;
|
|
|
|
+import com.fire.order.mapper.CustomerProductMapper;
|
|
import com.fire.order.mapper.FlowAppInfoMapper;
|
|
import com.fire.order.mapper.FlowAppInfoMapper;
|
|
import com.fire.order.service.CustomerService;
|
|
import com.fire.order.service.CustomerService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,6 +30,9 @@ public class CustomerServiceImpl implements CustomerService {
|
|
@Resource
|
|
@Resource
|
|
private CustomerInfoMapper customerInfoMapper;
|
|
private CustomerInfoMapper customerInfoMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private CustomerProductMapper customerProductMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 缓存客户信息
|
|
* 缓存客户信息
|
|
*/
|
|
*/
|
|
@@ -36,14 +41,24 @@ public class CustomerServiceImpl implements CustomerService {
|
|
//查询所有的客户信息和所有的接入信息
|
|
//查询所有的客户信息和所有的接入信息
|
|
List<FlowAppInfo> appInfos = flowAppInfoMapper.queryAll();
|
|
List<FlowAppInfo> appInfos = flowAppInfoMapper.queryAll();
|
|
List<CustomerInfo> customerInfos = customerInfoMapper.queryAll();
|
|
List<CustomerInfo> customerInfos = customerInfoMapper.queryAll();
|
|
- if (appInfos != null && customerInfos != null) {
|
|
|
|
|
|
+ List<CustomerProduct> products = customerProductMapper.queryAll();
|
|
|
|
+ if (appInfos != null && customerInfos != null && products != null) {
|
|
//将客户信息List 转换为客户id为key的map 如果存在重复key,以后出现的为准
|
|
//将客户信息List 转换为客户id为key的map 如果存在重复key,以后出现的为准
|
|
Map<Long, CustomerInfo> customerInfoMap = customerInfos.stream().collect(Collectors.toMap(CustomerInfo::getCustomerId, a -> a, (k1, k2) -> k2));
|
|
Map<Long, CustomerInfo> customerInfoMap = customerInfos.stream().collect(Collectors.toMap(CustomerInfo::getCustomerId, a -> a, (k1, k2) -> k2));
|
|
- //遍历接入信息,将对应客户信息放入接入信息中
|
|
|
|
|
|
+ //根据客户id进行分组
|
|
|
|
+ Map<Long, List<CustomerProduct>> longListMap = products.stream().collect(Collectors.groupingBy(CustomerProduct::getCustomerId));
|
|
|
|
+ //遍历接入信息
|
|
for (FlowAppInfo appInfo : appInfos) {
|
|
for (FlowAppInfo appInfo : appInfos) {
|
|
if (appInfo != null && appInfo.getCustomerId() != null) {
|
|
if (appInfo != null && appInfo.getCustomerId() != null) {
|
|
CustomerInfo customerInfo = customerInfoMap.get(appInfo.getCustomerId());
|
|
CustomerInfo customerInfo = customerInfoMap.get(appInfo.getCustomerId());
|
|
|
|
+ //将对应客户信息放入接入信息中
|
|
appInfo.setCustomerInfo(customerInfo);
|
|
appInfo.setCustomerInfo(customerInfo);
|
|
|
|
+ List<CustomerProduct> customerProducts = longListMap.get(appInfo.getCustomerId());
|
|
|
|
+ if (customerProducts != null) {
|
|
|
|
+ //将客户产品放入接入信息中
|
|
|
|
+ Map<String, CustomerProduct> productMap = customerProducts.stream().collect(Collectors.toMap(CustomerProduct::getPackageId, a -> a, (k1, k2) -> k2));
|
|
|
|
+ appInfo.setProductMap(productMap);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//将接入信息list 转换为appId为key的map 如果存在重复key,以后出现的为准
|
|
//将接入信息list 转换为appId为key的map 如果存在重复key,以后出现的为准
|