|
|
@@ -1,5 +1,6 @@
|
|
|
package org.dromara.customer.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
@@ -10,6 +11,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.customer.domain.SupplierInfo;
|
|
|
+import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
+import org.dromara.customer.mapper.SupplierInfoMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.customer.domain.bo.SupplierAddressBo;
|
|
|
import org.dromara.customer.domain.vo.SupplierAddressVo;
|
|
|
@@ -17,9 +21,8 @@ import org.dromara.customer.domain.SupplierAddress;
|
|
|
import org.dromara.customer.mapper.SupplierAddressMapper;
|
|
|
import org.dromara.customer.service.ISupplierAddressService;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 供应商地址Service业务层处理
|
|
|
@@ -34,6 +37,8 @@ public class SupplierAddressServiceImpl extends ServiceImpl<SupplierAddressMapp
|
|
|
|
|
|
private final SupplierAddressMapper baseMapper;
|
|
|
|
|
|
+ private final SupplierInfoMapper supplierInfoMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询供应商地址
|
|
|
*
|
|
|
@@ -56,6 +61,35 @@ public class SupplierAddressServiceImpl extends ServiceImpl<SupplierAddressMapp
|
|
|
public TableDataInfo<SupplierAddressVo> queryPageList(SupplierAddressBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<SupplierAddress> lqw = buildQueryWrapper(bo);
|
|
|
Page<SupplierAddressVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<SupplierAddressVo> records = result.getRecords();
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
+
|
|
|
+ // 1️⃣ 收集 supplierId 集合
|
|
|
+ Set<Long> supplierIds = records.stream()
|
|
|
+ .map(SupplierAddressVo::getSupplierId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(supplierIds)) {
|
|
|
+
|
|
|
+ // 2️⃣ 批量查询企业信息
|
|
|
+ List<SupplierInfoVo> enterprises = supplierInfoMapper.selectVoByIds(supplierIds);
|
|
|
+
|
|
|
+ // 3️⃣ 转成 Map<id, enterpriseName>
|
|
|
+ Map<Long, String> enterpriseMap = enterprises.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ SupplierInfoVo::getId,
|
|
|
+ SupplierInfoVo::getEnterpriseName
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 4️⃣ 回填 enterpriseName
|
|
|
+ records.forEach(vo -> {
|
|
|
+ vo.setEnterpriseName(
|
|
|
+ enterpriseMap.get(vo.getSupplierId())
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|