|
|
@@ -37,6 +37,7 @@ import org.dromara.system.api.domain.vo.RemoteSupplierTypeVo;
|
|
|
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.mapper.SupplierInfoMapper;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -81,8 +82,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
private final RemoteSupplierTypeService remoteSupplierTypeService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 新增供应商信息
|
|
|
*
|
|
|
@@ -97,7 +96,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);
|
|
|
@@ -328,74 +327,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public boolean srmUpdateByBo(SupplierInfoBo bo) {
|
|
|
- Long id = bo.getId();
|
|
|
- SupplierInfo supplierInfo = baseMapper.selectById(id);
|
|
|
- //如果是待审核 随便改
|
|
|
- if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode()){
|
|
|
- SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- return baseMapper.updateById(update) > 0;
|
|
|
- }
|
|
|
- //如果是启用状态,就变成待修改审核状态
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()){
|
|
|
- SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
- if (supplierInfoTemporary == null){
|
|
|
- BeanUtils.copyProperties(bo, supplierInfoTemporary,"id");
|
|
|
- supplierInfoTemporary.setSupplierId(id);
|
|
|
- supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
- boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
- if (save == false){
|
|
|
- throw new RuntimeException("保存供应商待审核数据失败");
|
|
|
- }
|
|
|
- }
|
|
|
- //一共三个地方
|
|
|
- boolean flag =false;
|
|
|
- //1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
- supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
- //2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
- //3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
- supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
-
|
|
|
- supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
- boolean update =baseMapper.updateById(supplierInfo) > 0;
|
|
|
- return update && flag;
|
|
|
- }
|
|
|
- //如果是待审核状态,就变成待修改审核状态
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()){
|
|
|
- SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
- //一共三个地方
|
|
|
- boolean flag =false;
|
|
|
- //1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
- supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
- //2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
- //3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
- supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
- flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
- }
|
|
|
- return flag;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 校验并批量删除供应商信息信息
|
|
|
*
|
|
|
@@ -405,7 +336,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;
|
|
|
@@ -436,6 +367,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 将工商信息复制到供应商信息对象中
|
|
|
copyBusinessInfoToSupplierInfoVo(supplierBusinessInfoVo, supplierInformationVo);
|
|
|
}
|
|
|
+
|
|
|
return supplierInformationVo;
|
|
|
}
|
|
|
|
|
|
@@ -459,18 +391,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);
|
|
|
}
|
|
|
}
|
|
|
@@ -680,14 +613,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);
|
|
|
}
|
|
|
}
|
|
|
@@ -704,6 +638,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//产品经理和采购人员
|
|
|
if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
// 查询符合条件的供应商ID列表
|
|
|
@@ -714,6 +649,8 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// 2. 基础分页查询
|
|
|
Page<SupplierInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
List<SupplierInfoVo> supplierVos = result.getRecords();
|
|
|
@@ -774,9 +711,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);
|
|
|
}
|
|
|
}
|
|
|
@@ -784,10 +721,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);
|
|
|
|
|
|
}
|
|
|
@@ -797,9 +734,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);
|
|
|
|
|
|
}
|
|
|
@@ -857,6 +794,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中
|
|
|
*
|
|
|
@@ -878,6 +841,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// ========== 3. 数据转换 - 映射构建方法 ==========
|
|
|
+
|
|
|
/**
|
|
|
* 构建品牌ID→名称映射表
|
|
|
*/
|
|
|
@@ -959,6 +923,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
Collectors.mapping(SupplyArea::getAreaName, Collectors.toList())
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 构建企业规模ID→名称映射表
|
|
|
*/
|
|
|
@@ -981,6 +946,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
return scaleMap;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 构建供应商品类ID→名称映射表
|
|
|
*/
|
|
|
@@ -1296,6 +1262,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// ========== 5. 工具方法 ==========
|
|
|
+
|
|
|
/**
|
|
|
* 收集供应商列表中的所有品牌ID
|
|
|
*/
|
|
|
@@ -1358,30 +1325,30 @@ 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);
|
|
|
@@ -1499,7 +1466,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 处理采购员和产品经理信息和品牌和供应商类型
|
|
|
*/
|
|
|
@@ -1586,12 +1552,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()) {
|
|
|
@@ -1795,8 +1761,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) {
|
|
|
@@ -1814,6 +1781,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();
|