Просмотр исходного кода

[招商]adjust

release_toaliyun_real
Burce 6 лет назад
Родитель
Сommit
aa7123b76b
1 измененных файлов: 31 добавлений и 27 удалений
  1. +31
    -27
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java

+ 31
- 27
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java Просмотреть файл

@@ -60,12 +60,11 @@ public class InvestBizServiceImpl implements InvestBizService {


InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>(); InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>();


LambdaQueryWrapper<InvestDemandEntity> queryWrapperDemand = null;
LambdaQueryWrapper<InvestDemandEntity> queryWrapperDemand = new LambdaQueryWrapper<>(demandParams);
InvestPageResult<InvestCustomerEntity> customers = customerService.queryPage(buildPageQuery(params, customerParams)); InvestPageResult<InvestCustomerEntity> customers = customerService.queryPage(buildPageQuery(params, customerParams));
if (CollectionUtils.isEmpty(customers.getRecords())) { if (CollectionUtils.isEmpty(customers.getRecords())) {
return investPage; return investPage;
} }
queryWrapperDemand = new LambdaQueryWrapper<>(demandParams);
queryWrapperDemand.in(InvestDemandEntity::getCustomerId, getIds(customers.getRecords(), InvestCustomerEntity::getId)); queryWrapperDemand.in(InvestDemandEntity::getCustomerId, getIds(customers.getRecords(), InvestCustomerEntity::getId));


List<InvestDemandEntity> demandList = demandService.list(queryWrapperDemand); List<InvestDemandEntity> demandList = demandService.list(queryWrapperDemand);
@@ -91,7 +90,6 @@ public class InvestBizServiceImpl implements InvestBizService {
demandEntity.setOwner(params.getDemandOwner()); demandEntity.setOwner(params.getDemandOwner());
} }



InvestDemandDto demandDto = new InvestDemandDto(); InvestDemandDto demandDto = new InvestDemandDto();
demandDto.setCustomer(customerEntity); demandDto.setCustomer(customerEntity);
demandDto.setDemand(demandEntity); demandDto.setDemand(demandEntity);
@@ -130,9 +128,9 @@ public class InvestBizServiceImpl implements InvestBizService {
Collection<InvestTaskEntity> taskList = taskPage.getRecords(); Collection<InvestTaskEntity> taskList = taskPage.getRecords();
//2、目标信息 //2、目标信息
Collection<WxShop> shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId)); Collection<WxShop> shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId));
Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId);
HashMap<Long, WxShop> shopsMap = getMap(shops, WxShop::getId);
//3、用户信息 //3、用户信息
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
List<InvestTaskVo> resultList = new ArrayList<>(); List<InvestTaskVo> resultList = new ArrayList<>();
for (InvestTaskEntity item : taskList) { for (InvestTaskEntity item : taskList) {
WxShop shop = shopsMap.get(item.getTargetId()); WxShop shop = shopsMap.get(item.getTargetId());
@@ -184,13 +182,13 @@ public class InvestBizServiceImpl implements InvestBizService {
Collection<InvestFollowRecordEntity> recordList = recordPage.getRecords(); Collection<InvestFollowRecordEntity> recordList = recordPage.getRecords();


//2、用户信息 //2、用户信息
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);


//3、客户 //3、客户
Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId)); Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId));
Map<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId);
HashMap<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId);
//4、 品牌 //4、 品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
HashMap<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);


List<InvestFollowRecordVo> resultList = new ArrayList<>(); List<InvestFollowRecordVo> resultList = new ArrayList<>();
for (InvestFollowRecordEntity item : recordList) { for (InvestFollowRecordEntity item : recordList) {
@@ -219,13 +217,13 @@ public class InvestBizServiceImpl implements InvestBizService {
} }


//2、用户信息 //2、用户信息
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestRemindEntity::getOwner)), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestRemindEntity::getOwner)), MallUserInfo::getId);


//3、客户 //3、客户
Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(resultList, InvestRemindVo::getCustomerId)); Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(resultList, InvestRemindVo::getCustomerId));
Map<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId);
HashMap<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId);
//4、 品牌 //4、 品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
HashMap<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);


for (InvestRemindVo remindVo : resultList) { for (InvestRemindVo remindVo : resultList) {
InvestCustomerEntity customerEntity = customerMap.get(remindVo.getCustomerId()); InvestCustomerEntity customerEntity = customerMap.get(remindVo.getCustomerId());
@@ -293,7 +291,7 @@ public class InvestBizServiceImpl implements InvestBizService {
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId());
WxBrand brand = brandService.getById(customerEntity.getBrandId()); WxBrand brand = brandService.getById(customerEntity.getBrandId());
WxShop shop = shopService.getById(demandEntity.getTargetId()); WxShop shop = shopService.getById(demandEntity.getTargetId());
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap); return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap);
} }


@@ -301,7 +299,7 @@ public class InvestBizServiceImpl implements InvestBizService {
public InvestTaskVo findTaskById(Long id) { public InvestTaskVo findTaskById(Long id) {
InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); InvestTaskEntity taskEntity = taskService.getByIdNotNull(id);
WxShop shop = shopService.getById(taskEntity.getTargetId()); WxShop shop = shopService.getById(taskEntity.getTargetId());
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
return buildTaskItem(taskEntity, shop, usersMap); return buildTaskItem(taskEntity, shop, usersMap);
} }


@@ -323,7 +321,7 @@ public class InvestBizServiceImpl implements InvestBizService {
@Override @Override
public InvestFollowRecordVo findFollowRecordById(Long id) { public InvestFollowRecordVo findFollowRecordById(Long id) {
InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id);
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId()); InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId());
WxBrand brand = brandService.getById(customerEntity.getBrandId()); WxBrand brand = brandService.getById(customerEntity.getBrandId());
return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand);
@@ -347,8 +345,10 @@ public class InvestBizServiceImpl implements InvestBizService {
resultItemVo.setBrand(brand); resultItemVo.setBrand(brand);
resultItemVo.setCustomer(customer); resultItemVo.setCustomer(customer);
resultItemVo.setTargetInfo(shop); resultItemVo.setTargetInfo(shop);
resultItemVo.setOwnerInfo(usersMap.get(item.getOwner()));
BeanUtils.copyProperties(item, resultItemVo);
if (Objects.nonNull(item)) {
resultItemVo.setOwnerInfo(usersMap.get(item.getOwner()));
BeanUtils.copyProperties(item, resultItemVo);
}
return resultItemVo; return resultItemVo;
} }


@@ -392,23 +392,26 @@ public class InvestBizServiceImpl implements InvestBizService {
} }


private List<InvestDemandVo> getTargeInfoList(List<InvestDemandEntity> demandList, Collection<InvestCustomerEntity> customers) { private List<InvestDemandVo> getTargeInfoList(List<InvestDemandEntity> demandList, Collection<InvestCustomerEntity> customers) {
Map<Long, InvestDemandEntity> demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId);
HashMap<Long, InvestDemandEntity> demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId);


//3、目标信息 //3、目标信息
Collection<WxShop> shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId)); Collection<WxShop> shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId));
Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId);
HashMap<Long, WxShop> shopsMap = getMap(shops, WxShop::getId);


//4、品牌 //4、品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
HashMap<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
//5、用户 //5、用户
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
HashMap<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);


List<InvestDemandVo> resultList = new ArrayList<>(); List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestCustomerEntity item : customers) {
InvestDemandEntity demandItem = demindsMap.get(item.getId());
WxShop shop = shopsMap.get(demandItem.getTargetId());
WxBrand brand = brandMap.get(item.getBrandId());
resultList.add(buildDemindItem(demandItem, item, brand, shop, usersMap));
for (InvestCustomerEntity costomerItem : customers) {
InvestDemandEntity demandItem = demindsMap.get(costomerItem.getId());
WxShop shop = null;
if (Objects.nonNull(demandItem)) {
shop = shopsMap.get(demandItem.getTargetId());
}
WxBrand brand = brandMap.get(costomerItem.getBrandId());
resultList.add(buildDemindItem(demandItem, costomerItem, brand, shop, usersMap));
} }
return resultList; return resultList;
} }
@@ -427,8 +430,9 @@ public class InvestBizServiceImpl implements InvestBizService {
return function.apply(params); return function.apply(params);
} }


private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) {
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity));
private <T, R> HashMap<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) {
Map<R, T> map = dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity));
return new HashMap<>(map);
} }


private <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) { private <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) {


Загрузка…
Отмена
Сохранить