|
|
@@ -17,9 +17,7 @@ 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.SupplierBusinessInfo;
|
|
|
-import org.dromara.customer.domain.SupplierProcurement;
|
|
|
-import org.dromara.customer.domain.SupplyArea;
|
|
|
+import org.dromara.customer.domain.*;
|
|
|
import org.dromara.customer.domain.bo.EnterpriseScaleBo;
|
|
|
import org.dromara.customer.domain.bo.SupplierAuthorizeBo;
|
|
|
import org.dromara.customer.domain.vo.EnterpriseScaleVo;
|
|
|
@@ -39,7 +37,6 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.customer.domain.bo.SupplierInfoBo;
|
|
|
import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
-import org.dromara.customer.domain.SupplierInfo;
|
|
|
import org.dromara.customer.mapper.SupplierInfoMapper;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -55,7 +52,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
|
|
|
+public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
|
|
|
|
|
|
private final SupplierInfoMapper baseMapper;
|
|
|
|
|
|
@@ -82,8 +79,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
private final RemoteSupplierTypeService remoteSupplierTypeService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 新增供应商信息
|
|
|
*
|
|
|
@@ -98,7 +93,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
.orderByDesc(SupplierInfo::getSupplierNo)
|
|
|
.last("LIMIT 1");
|
|
|
SupplierInfo maxSupplier = baseMapper.selectOne(lambdaQueryWrapper);
|
|
|
- long l = Long.parseLong(maxSupplier.getSupplierNo())+1;
|
|
|
+ long l = Long.parseLong(maxSupplier.getSupplierNo()) + 1;
|
|
|
String supplierNo = String.valueOf(l);
|
|
|
SupplierInfo add = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
add.setSupplierNo(supplierNo);
|
|
|
@@ -113,11 +108,12 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 从JSON字符串解析工商信息并保存
|
|
|
*
|
|
|
* @param otherCustomersJson JSON格式的工商信息
|
|
|
- * @param supplierId 供应商ID
|
|
|
+ * @param supplierId 供应商ID
|
|
|
*/
|
|
|
private void saveSupplierBusinessInfoFromJson(String otherCustomersJson, Long supplierId) {
|
|
|
if (StringUtils.isBlank(otherCustomersJson)) {
|
|
|
@@ -149,7 +145,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 修改供应商信息
|
|
|
*
|
|
|
@@ -180,7 +175,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// 审核不通过->待审核
|
|
|
- if (supplierInfoVo.getSupplyStatus()==SupplierStatusEnum.REVIEW_FAILED.getCode() && supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode()) {
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode() && supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
update.setCooperative(0l);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
@@ -202,7 +197,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
@@ -230,7 +225,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 分页查询供应商信息列表
|
|
|
*
|
|
|
@@ -249,20 +243,19 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
public TableDataInfo<SupplierInfoVo> getSupplierInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
// 1. 基础分页查询
|
|
|
- if (bo.getSupplyStatus() == null){
|
|
|
+ if (bo.getSupplyStatus() == null) {
|
|
|
//正式供应商
|
|
|
lqw.eq(SupplierInfo::getSupplyStatus, 1L);
|
|
|
- }else {
|
|
|
- lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
+ } else {
|
|
|
+ lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
// 2. 添加品牌条件
|
|
|
- if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -315,15 +308,15 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
if (bo.getSupplyStatus() == null) {
|
|
|
List<Long> status = Arrays.asList(0L, 4L);
|
|
|
lqw.in(SupplierInfo::getSupplyStatus, status);
|
|
|
- }else {
|
|
|
- lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
+ } else {
|
|
|
+ lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
|
|
|
}
|
|
|
|
|
|
// 2.添加品牌条件
|
|
|
- if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -376,9 +369,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSupplierName()), SupplierInfo::getEnterpriseName, bo.getSupplierName());
|
|
|
|
|
|
//可供应品牌
|
|
|
- if (StringUtils.isNotBlank(bo.getSupplyBrand())){
|
|
|
+ if (StringUtils.isNotBlank(bo.getSupplyBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getSupplyBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -386,10 +379,10 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
// 查询符合条件的供应商ID列表
|
|
|
List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
- if (supplierIds != null &&!supplierIds.isEmpty()) {
|
|
|
+ if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
|
}
|
|
|
@@ -399,9 +392,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
if (StringUtils.isNotBlank(bo.getBrandName())) {
|
|
|
// 通过SupplierAuthorizeService查询符合条件的供应商ID
|
|
|
List<Long> supplierIdsByBrand = commonSupplierAuthorizeMapper.getSupplierIdsByBrandName(bo.getBrandName());
|
|
|
- if (supplierIdsByBrand!=null &&!supplierIdsByBrand.isEmpty()) {
|
|
|
+ if (supplierIdsByBrand != null && !supplierIdsByBrand.isEmpty()) {
|
|
|
lqw.in(SupplierInfo::getId, supplierIdsByBrand);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
|
}
|
|
|
@@ -434,6 +427,32 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<Long, String> selectSupplierNameByIds(Set<Long> ids) {
|
|
|
+ if (ids == null || ids.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 限制批量大小
|
|
|
+ if (ids.size() > 1000) {
|
|
|
+ throw new IllegalArgumentException("Batch size exceeds limit: " + ids.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SupplierInfo> supplierInfoList = baseMapper.selectByIds(ids);
|
|
|
+ Map<Long, String> resultMap = new HashMap<>(ids.size());
|
|
|
+
|
|
|
+ // 初始化所有请求的 ID 为 null
|
|
|
+ ids.forEach(id -> resultMap.put(id, null));
|
|
|
+
|
|
|
+ if (supplierInfoList != null) {
|
|
|
+ supplierInfoList.stream()
|
|
|
+ .filter(supplier -> supplier.getId() != null && supplier.getSupplierName() != null)
|
|
|
+ .forEach(supplier -> resultMap.put(supplier.getId(), supplier.getSupplierName()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 将工商信息复制到供应商信息VO中
|
|
|
*
|
|
|
@@ -455,6 +474,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// ========== 3. 数据转换 - 映射构建方法 ==========
|
|
|
+
|
|
|
/**
|
|
|
* 构建品牌ID→名称映射表
|
|
|
*/
|
|
|
@@ -536,6 +556,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
Collectors.mapping(SupplyArea::getAreaName, Collectors.toList())
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 构建企业规模ID→名称映射表
|
|
|
*/
|
|
|
@@ -558,6 +579,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
return scaleMap;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 构建供应商品类ID→名称映射表
|
|
|
*/
|
|
|
@@ -873,6 +895,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// ========== 5. 工具方法 ==========
|
|
|
+
|
|
|
/**
|
|
|
* 收集供应商列表中的所有品牌ID
|
|
|
*/
|
|
|
@@ -932,33 +955,32 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private SupplierInfoVo handleProcurementInfo(SupplierInfoVo records) {
|
|
|
|
|
|
- // 查询管理人员和采购人员
|
|
|
- Long id = records.getId();
|
|
|
- //查询供应地区
|
|
|
- LambdaQueryWrapper<SupplyArea> supplyProvinceAreaLqw = Wrappers.lambdaQuery();
|
|
|
- supplyProvinceAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
- .eq(SupplyArea::getLevel,"1");
|
|
|
- List<SupplyArea> supplyProvinceArealist = supplyAreaService.list(supplyProvinceAreaLqw);
|
|
|
-
|
|
|
- LambdaQueryWrapper<SupplyArea> supplyCityAreaLqw = Wrappers.lambdaQuery();
|
|
|
- supplyCityAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
- .eq(SupplyArea::getLevel,"2");
|
|
|
- List<SupplyArea> supplyCityArealist = supplyAreaService.list(supplyCityAreaLqw);
|
|
|
-
|
|
|
- // 拼接省份名称
|
|
|
- String provinceNames = supplyProvinceArealist.stream()
|
|
|
- .map(SupplyArea::getAreaName)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.joining(","));
|
|
|
+ // 查询管理人员和采购人员
|
|
|
+ Long id = records.getId();
|
|
|
+ //查询供应地区
|
|
|
+ LambdaQueryWrapper<SupplyArea> supplyProvinceAreaLqw = Wrappers.lambdaQuery();
|
|
|
+ supplyProvinceAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
+ .eq(SupplyArea::getLevel, "1");
|
|
|
+ List<SupplyArea> supplyProvinceArealist = supplyAreaService.list(supplyProvinceAreaLqw);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SupplyArea> supplyCityAreaLqw = Wrappers.lambdaQuery();
|
|
|
+ supplyCityAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
+ .eq(SupplyArea::getLevel, "2");
|
|
|
+ List<SupplyArea> supplyCityArealist = supplyAreaService.list(supplyCityAreaLqw);
|
|
|
+
|
|
|
+ // 拼接省份名称
|
|
|
+ String provinceNames = supplyProvinceArealist.stream()
|
|
|
+ .map(SupplyArea::getAreaName)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
|
|
- // 拼接城市名称
|
|
|
- String cityNames = supplyCityArealist.stream()
|
|
|
- .map(SupplyArea::getAreaName)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.joining(","));
|
|
|
+ // 拼接城市名称
|
|
|
+ String cityNames = supplyCityArealist.stream()
|
|
|
+ .map(SupplyArea::getAreaName)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
|
|
records.setProvince(provinceNames);
|
|
|
records.setCity(cityNames);
|
|
|
@@ -1076,7 +1098,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 处理采购员和产品经理信息和品牌和供应商类型
|
|
|
*/
|
|
|
@@ -1163,12 +1184,12 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 2. 查询供应地区(原有逻辑)
|
|
|
LambdaQueryWrapper<SupplyArea> supplyProvinceAreaLqw = Wrappers.lambdaQuery();
|
|
|
supplyProvinceAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
- .eq(SupplyArea::getLevel,"1");
|
|
|
+ .eq(SupplyArea::getLevel, "1");
|
|
|
List<SupplyArea> supplyProvinceArealist = supplyAreaService.list(supplyProvinceAreaLqw);
|
|
|
|
|
|
LambdaQueryWrapper<SupplyArea> supplyCityAreaLqw = Wrappers.lambdaQuery();
|
|
|
supplyCityAreaLqw.eq(SupplyArea::getSupplierId, id)
|
|
|
- .eq(SupplyArea::getLevel,"2");
|
|
|
+ .eq(SupplyArea::getLevel, "2");
|
|
|
List<SupplyArea> supplyCityArealist = supplyAreaService.list(supplyCityAreaLqw);
|
|
|
|
|
|
if (!supplyProvinceArealist.isEmpty()) {
|
|
|
@@ -1372,8 +1393,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
/**
|
|
|
* 复制分页结果(保持原分页的总数/页码/页大小,仅替换数据列表)
|
|
|
+ *
|
|
|
* @param originalPage 原分页对象(包含总数、页码等元数据)
|
|
|
- * @param newRecords 新的数据集
|
|
|
+ * @param newRecords 新的数据集
|
|
|
* @return 新的分页对象
|
|
|
*/
|
|
|
private Page<SupplierInfoVo> copyPageResult(Page<SupplierInfoVo> originalPage, List<SupplierInfoVo> newRecords) {
|
|
|
@@ -1391,6 +1413,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
return newPage;
|
|
|
}
|
|
|
+
|
|
|
private LambdaQueryWrapper<SupplierInfo> buildQueryWrapper(SupplierInfoBo bo) {
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<SupplierInfo> lqw = Wrappers.lambdaQuery();
|