|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.crypto.digest.BCrypt;
|
|
import cn.hutool.crypto.digest.BCrypt;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
@@ -141,6 +142,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
bo.setId(add.getId());
|
|
bo.setId(add.getId());
|
|
|
// 解析 otherCustomers JSON 并保存工商信息
|
|
// 解析 otherCustomers JSON 并保存工商信息
|
|
|
saveSupplierBusinessInfoFromJson(bo.getOtherCustomers(), add.getId());
|
|
saveSupplierBusinessInfoFromJson(bo.getOtherCustomers(), add.getId());
|
|
|
|
|
+ //
|
|
|
}
|
|
}
|
|
|
return flag;
|
|
return flag;
|
|
|
}
|
|
}
|
|
@@ -204,7 +206,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
//状态为修改待审核
|
|
//状态为修改待审核
|
|
|
supplierInfoVo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
supplierInfoVo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
//先copy到临时表
|
|
//先copy到临时表
|
|
|
- SupplierInfoTemporary supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
|
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.getOne(Wrappers.lambdaQuery(SupplierInfoTemporary.class)
|
|
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, bo.getId())
|
|
|
|
|
+ .last("limit 1")
|
|
|
|
|
+ );
|
|
|
|
|
+ if(supplierInfoTemporary == null){
|
|
|
|
|
+ supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
|
|
+ }
|
|
|
BeanUtils.copyProperties(bo, supplierInfoTemporary, "id");
|
|
BeanUtils.copyProperties(bo, supplierInfoTemporary, "id");
|
|
|
//修改待审核
|
|
//修改待审核
|
|
|
//ID一对一
|
|
//ID一对一
|
|
@@ -219,7 +227,8 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
String areaListJson = objectMapper.writeValueAsString(supplyAreaVoTableDataInfo);
|
|
String areaListJson = objectMapper.writeValueAsString(supplyAreaVoTableDataInfo);
|
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
|
- boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
|
|
|
|
+ supplierInfoTemporary.setSupplyStatus(bo.getSupplyStatus());
|
|
|
|
|
+ boolean save = supplierInfoTemporaryService.saveOrUpdate(supplierInfoTemporary);
|
|
|
return baseMapper.updateById(supplierInfoVo) > 0;
|
|
return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -302,9 +311,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
if (updateMain == false) {
|
|
if (updateMain == false) {
|
|
|
throw new RuntimeException("更新供应商信息失败");
|
|
throw new RuntimeException("更新供应商信息失败");
|
|
|
}
|
|
}
|
|
|
- boolean remove = supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>().eq(SupplierInfoTemporary::getSupplierId, id));
|
|
|
|
|
- // 6. 返回最终结果(地址批量插入 + 主表更新都成功才返回 true)
|
|
|
|
|
- return batchSave && updateMain && remove;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 不删除临时表数据,而是将临时表的supplyStatus改为和主表一样
|
|
|
|
|
+ supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode());
|
|
|
|
|
+ boolean updateTemp = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
|
|
+
|
|
|
|
|
+ // 7. 返回最终结果(地址批量插入 + 主表更新 + 临时表状态更新都成功才返回 true)
|
|
|
|
|
+ return batchSave && updateMain && updateTemp;
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
} catch (JsonProcessingException e) {
|
|
|
// JSON解析异常处理(可打印日志、抛出业务异常等)
|
|
// JSON解析异常处理(可打印日志、抛出业务异常等)
|
|
@@ -319,8 +332,10 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
update.setCooperative(0L);
|
|
update.setCooperative(0L);
|
|
|
// 补充:审核未通过,建议同时删除临时表的待审核数据,避免残留
|
|
// 补充:审核未通过,建议同时删除临时表的待审核数据,避免残留
|
|
|
- supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>()
|
|
|
|
|
- .eq(SupplierInfoTemporary::getSupplierId, update.getId()));
|
|
|
|
|
|
|
+ supplierInfoTemporaryService.update(new LambdaUpdateWrapper<SupplierInfoTemporary>()
|
|
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, update.getId())
|
|
|
|
|
+ .set(SupplierInfoTemporary::getSupplyStatus, bo.getSupplyStatus())
|
|
|
|
|
+ );
|
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -345,7 +360,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
BeanUtils.copyProperties(tempMain, tempSupplier, "id", "supplierId", "areaListJson");
|
|
BeanUtils.copyProperties(tempMain, tempSupplier, "id", "supplierId", "areaListJson");
|
|
|
// 忽略:主键、关联字段、区域JSON(区域JSON已由insertByBo处理完成)
|
|
// 忽略:主键、关联字段、区域JSON(区域JSON已由insertByBo处理完成)
|
|
|
// 3.2 保持临时表状态仍为「待修改审核」(兜底,避免意外修改)
|
|
// 3.2 保持临时表状态仍为「待修改审核」(兜底,避免意外修改)
|
|
|
- tempSupplier.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
|
|
|
|
+ tempSupplier.setSupplyStatus(bo.getSupplyStatus());
|
|
|
// 4. 更新临时表的基础信息(区域JSON已由insertByBo更新,此处仅更新基础信息)
|
|
// 4. 更新临时表的基础信息(区域JSON已由insertByBo更新,此处仅更新基础信息)
|
|
|
try {
|
|
try {
|
|
|
boolean operateResult = supplierInfoTemporaryService.saveOrUpdate(tempSupplier);
|
|
boolean operateResult = supplierInfoTemporaryService.saveOrUpdate(tempSupplier);
|
|
@@ -355,6 +370,15 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
throw new RuntimeException("更新供应商待审核基础数据失败,请联系管理员", e);
|
|
throw new RuntimeException("更新供应商待审核基础数据失败,请联系管理员", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.getOne(Wrappers.lambdaQuery(SupplierInfoTemporary.class)
|
|
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, bo.getId())
|
|
|
|
|
+ .last("limit 1")
|
|
|
|
|
+ );
|
|
|
|
|
+ if(supplierInfoTemporary == null){
|
|
|
|
|
+ supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
|
|
+ }
|
|
|
|
|
+ BeanUtils.copyProperties(bo, supplierInfoTemporary, "id");
|
|
|
|
|
+ supplierInfoTemporaryService.saveOrUpdate(supplierInfoTemporary);
|
|
|
|
|
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
@@ -452,13 +476,11 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
|
|
|
|
|
// 待审核
|
|
// 待审核
|
|
|
case PENDING_REVIEW:
|
|
case PENDING_REVIEW:
|
|
|
- return updateSupplier(bo);
|
|
|
|
|
|
|
+ return handleOfficialSupplierUpdate(bo, supplier);
|
|
|
|
|
|
|
|
// 审核失败 -> 重新待审核
|
|
// 审核失败 -> 重新待审核
|
|
|
case REVIEW_FAILED:
|
|
case REVIEW_FAILED:
|
|
|
- SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
|
|
- update.setSupplyStatus(SupplierStatusEnum.PENDING_REVIEW.getCode());
|
|
|
|
|
- return baseMapper.updateById(update) > 0;
|
|
|
|
|
|
|
+ return handleOfficialSupplierUpdate(bo, supplier);
|
|
|
|
|
|
|
|
// 正式供应商 -> 进入修改审核
|
|
// 正式供应商 -> 进入修改审核
|
|
|
case OFFICIAL_SUPPLIER:
|
|
case OFFICIAL_SUPPLIER:
|
|
@@ -607,13 +629,14 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
|
.eq(SupplierInfo::getId, id));
|
|
.eq(SupplierInfo::getId, id));
|
|
|
SupplierInfoVo supplierInfoVo = new SupplierInfoVo();
|
|
SupplierInfoVo supplierInfoVo = new SupplierInfoVo();
|
|
|
- if (supplierInfoVo1 != null && supplierInfoVo1.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
|
|
|
|
+// if (supplierInfoVo1 != null && supplierInfoVo1.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
|
|
+ if (supplierInfoVo1 != null ) {
|
|
|
SupplierInfoTemporaryVo supplierInfoTemporaryVo = supplierInfoTemporaryService.getVoOne(id);
|
|
SupplierInfoTemporaryVo supplierInfoTemporaryVo = supplierInfoTemporaryService.getVoOne(id);
|
|
|
if (supplierInfoTemporaryVo != null) {
|
|
if (supplierInfoTemporaryVo != null) {
|
|
|
BeanUtils.copyProperties(supplierInfoTemporaryVo, supplierInfoVo);
|
|
BeanUtils.copyProperties(supplierInfoTemporaryVo, supplierInfoVo);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
|
|
|
|
+ supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
}
|
|
}
|
|
|
SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
|
|
SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
|
|
|
//返回工商信息
|
|
//返回工商信息
|
|
@@ -706,162 +729,79 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public TableDataInfo<SupplierInfoVo> getSupplierApproveInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<SupplierInfoVo> getSupplierApproveInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
|
- if (bo.getSupplyStatus() == null) {
|
|
|
|
|
- // 步骤1:定义两个列表,存储主表(状态0)和临时表(状态4)的数据
|
|
|
|
|
- List<SupplierInfoVo> mainTableVoList = new ArrayList<>();
|
|
|
|
|
- List<SupplierInfoVo> tempTableVoList = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- // 步骤2:查询主表(info)状态为 0 的数据
|
|
|
|
|
- LambdaQueryWrapper<SupplierInfo> mainLqw = buildCommonQueryWrapper(bo);
|
|
|
|
|
- mainLqw.eq(SupplierInfo::getSupplyStatus, SupplierStatusEnum.PENDING_REVIEW.getCode()); // 状态0:待审核(可替换为 SupplierStatusEnum.PENDING_REVIEW.getCode())
|
|
|
|
|
- mainLqw.eq(StringUtils.isNotBlank(bo.getSupplierNo()), SupplierInfo::getSupplierNo, bo.getSupplierNo());
|
|
|
|
|
- mainLqw.like(StringUtils.isNotBlank(bo.getEnterpriseName()), SupplierInfo::getEnterpriseName, bo.getEnterpriseName());
|
|
|
|
|
- Page<SupplierInfoVo> mainPage = baseMapper.selectVoPage(new Page<>(1, Integer.MAX_VALUE), mainLqw); // 查询全部符合条件的数据,不做分页
|
|
|
|
|
- if (!CollectionUtils.isEmpty(mainPage.getRecords())) {
|
|
|
|
|
- mainTableVoList = mainPage.getRecords();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 步骤3:查询临时表(temporary)状态为 4 的数据
|
|
|
|
|
- LambdaQueryWrapper<SupplierInfoTemporary> tempLqw = new LambdaQueryWrapper<>();
|
|
|
|
|
- tempLqw.eq(SupplierInfoTemporary::getSupplyStatus, SupplierStatusEnum.REVIEW_UPDATED.getCode()); // 状态4:修改待审核(可替换为 SupplierStatusEnum.REVIEW_UPDATED.getCode())
|
|
|
|
|
- // 补充bo中的其他查询条件(如品牌,和主表查询保持一致)
|
|
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
|
|
- Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
|
|
- if (productBrandIdByName != null) {
|
|
|
|
|
- tempLqw.like(SupplierInfoTemporary::getOperatingBrand, productBrandIdByName);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 若有区域、产品经理/采购人员过滤,需同步对临时表执行相同过滤逻辑(此处复用你原有的过滤方法)
|
|
|
|
|
- List<Long> validSupplierIds = new ArrayList<>();
|
|
|
|
|
- // 3.1 区域过滤(同步主表逻辑)
|
|
|
|
|
- if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
|
|
- validSupplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
|
|
- if (CollectionUtils.isEmpty(validSupplierIds)) {
|
|
|
|
|
- validSupplierIds.add(-1L); // 无数据时添加无效ID,避免查询全部
|
|
|
|
|
- }
|
|
|
|
|
- tempLqw.in(SupplierInfoTemporary::getId, validSupplierIds);
|
|
|
|
|
- }
|
|
|
|
|
- // 3.2 产品经理/采购人员过滤(同步主表逻辑)
|
|
|
|
|
- if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
|
|
- validSupplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
|
|
|
- if (CollectionUtils.isEmpty(validSupplierIds)) {
|
|
|
|
|
- validSupplierIds.add(-1L);
|
|
|
|
|
- }
|
|
|
|
|
- tempLqw.in(SupplierInfoTemporary::getId, validSupplierIds);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 查询临时表全部符合条件数据,并转换为 SupplierInfoVo(保证和主表数据结构一致)
|
|
|
|
|
- List<SupplierInfoTemporary> tempTableList = supplierInfoTemporaryService.list(tempLqw);
|
|
|
|
|
- if (!CollectionUtils.isEmpty(tempTableList)) {
|
|
|
|
|
- // 转换:SupplierInfoTemporary -> SupplierInfoVo(可使用Mapstruct,此处用BeanUtils示例,需保证字段一致)
|
|
|
|
|
- tempTableVoList = tempTableList.stream().map(temp -> {
|
|
|
|
|
- SupplierInfoVo vo = new SupplierInfoVo();
|
|
|
|
|
- org.springframework.beans.BeanUtils.copyProperties(temp, vo);
|
|
|
|
|
- vo.setId(temp.getSupplierId());
|
|
|
|
|
- return vo;
|
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 步骤4:合并两个列表的数据
|
|
|
|
|
- List<SupplierInfoVo> totalVoList = new ArrayList<>();
|
|
|
|
|
- totalVoList.addAll(mainTableVoList);
|
|
|
|
|
- totalVoList.addAll(tempTableVoList);
|
|
|
|
|
-
|
|
|
|
|
- // 步骤5:按照 supplyNo 倒序排序(处理null值,避免排序异常)
|
|
|
|
|
- if (!CollectionUtils.isEmpty(totalVoList)) {
|
|
|
|
|
- totalVoList.sort((vo1, vo2) -> {
|
|
|
|
|
- // 优先处理null值,null值排后面
|
|
|
|
|
- if (vo1.getSupplierNo() == null && vo2.getSupplierNo() == null) {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (vo1.getSupplierNo() == null) {
|
|
|
|
|
- return 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (vo2.getSupplierNo() == null) {
|
|
|
|
|
- return -1;
|
|
|
|
|
- }
|
|
|
|
|
- // 倒序排序(compareTo反过来)
|
|
|
|
|
- return vo2.getSupplierNo().compareTo(vo1.getSupplierNo());
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // 批量处理扩展信息(复用你原有的逻辑)
|
|
|
|
|
- totalVoList = batchHandleBaseExtInfo(totalVoList);
|
|
|
|
|
- handleEnterpriseScaleName(totalVoList);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 步骤6:手动实现分页(关键:内存数据分页)
|
|
|
|
|
- int pageNum = pageQuery.getPageNum();
|
|
|
|
|
- int pageSize = pageQuery.getPageSize();
|
|
|
|
|
- int totalCount = totalVoList.size();
|
|
|
|
|
-
|
|
|
|
|
- // 计算分页参数
|
|
|
|
|
- int startIndex = (pageNum - 1) * pageSize;
|
|
|
|
|
- int endIndex = Math.min(startIndex + pageSize, totalCount);
|
|
|
|
|
- List<SupplierInfoVo> pageVoList = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- // 截取当前页数据
|
|
|
|
|
- if (startIndex < totalCount) {
|
|
|
|
|
- pageVoList = totalVoList.subList(startIndex, endIndex);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 步骤7:封装分页结果(构建Page对象,符合返回值要求)
|
|
|
|
|
- Page<SupplierInfoVo> resultPage = new Page<>(pageNum, pageSize, totalCount);
|
|
|
|
|
- resultPage.setRecords(pageVoList);
|
|
|
|
|
-
|
|
|
|
|
- // 步骤8:返回封装后的TableDataInfo
|
|
|
|
|
- return TableDataInfo.build(resultPage);
|
|
|
|
|
|
|
+ // 只查询临时表 supplier_info_temporary
|
|
|
|
|
+ LambdaQueryWrapper<SupplierInfoTemporary> lqw = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
+ // 如果未指定状态,默认查询状态为4(修改待审核)的数据
|
|
|
|
|
+ if (bo.getSupplyStatus() != null) {
|
|
|
|
|
+ lqw.eq(SupplierInfoTemporary::getSupplyStatus, bo.getSupplyStatus());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 1. 构建审批状态条件
|
|
|
|
|
- LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
|
|
- lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
|
|
|
|
|
|
|
+ // 添加供应商编号过滤
|
|
|
|
|
+ if (StringUtils.isNotBlank(bo.getSupplierNo())) {
|
|
|
|
|
+ lqw.eq(SupplierInfoTemporary::getSupplierNo, bo.getSupplierNo());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 添加企业名称模糊查询
|
|
|
|
|
+ if (StringUtils.isNotBlank(bo.getEnterpriseName())) {
|
|
|
|
|
+ lqw.like(SupplierInfoTemporary::getEnterpriseName, bo.getEnterpriseName());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 2.添加品牌条件
|
|
|
|
|
|
|
+ // 添加品牌条件
|
|
|
if (bo.getOperatingBrand() != null && 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) {
|
|
|
|
|
- lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
|
|
+ lqw.like(SupplierInfoTemporary::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //3.可供货区域省和市 - 添加供应区域过滤
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 可供货区域省和市 - 添加供应区域过滤
|
|
|
if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
- // 查询符合条件的供应商ID列表
|
|
|
|
|
List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
- if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
|
|
- lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(supplierIds)) {
|
|
|
|
|
+ lqw.in(SupplierInfoTemporary::getId, supplierIds);
|
|
|
} else {
|
|
} else {
|
|
|
- lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ lqw.in(SupplierInfoTemporary::getId, -1L);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //产品经理和采购人员
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 产品经理和采购人员过滤
|
|
|
if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
- // 查询符合条件的供应商ID列表
|
|
|
|
|
List<Long> supplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
List<Long> supplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
|
- if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
|
|
- lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(supplierIds)) {
|
|
|
|
|
+ lqw.in(SupplierInfoTemporary::getId, supplierIds);
|
|
|
} else {
|
|
} else {
|
|
|
- lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
|
|
+ lqw.in(SupplierInfoTemporary::getId, -1L);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 2. 基础分页查询
|
|
|
|
|
- Page<SupplierInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
- List<SupplierInfoVo> supplierVos = result.getRecords();
|
|
|
|
|
|
|
|
|
|
- // 3. 批量处理扩展信息
|
|
|
|
|
- if (!CollectionUtils.isEmpty(supplierVos)) {
|
|
|
|
|
|
|
+ // 分页查询临时表数据
|
|
|
|
|
+ Page<SupplierInfoTemporary> tempPage = supplierInfoTemporaryService.page(pageQuery.build(), lqw);
|
|
|
|
|
+ List<SupplierInfoTemporary> tempRecords = tempPage.getRecords();
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为 SupplierInfoVo
|
|
|
|
|
+ List<SupplierInfoVo> supplierVos = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(tempRecords)) {
|
|
|
|
|
+ supplierVos = tempRecords.stream().map(temp -> {
|
|
|
|
|
+ SupplierInfoVo supplierInfo = baseMapper.selectVoById(temp.getSupplierId());
|
|
|
|
|
+ SupplierInfoVo vo = new SupplierInfoVo();
|
|
|
|
|
+
|
|
|
|
|
+ BeanUtil.copyProperties(temp, vo);
|
|
|
|
|
+ vo.setId(temp.getSupplierId());
|
|
|
|
|
+ vo.setSupplierNo(supplierInfo.getSupplierNo());
|
|
|
|
|
+// vo.setSupplyStatus(supplierInfo.getSupplyStatus());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 批量处理扩展信息
|
|
|
supplierVos = batchHandleBaseExtInfo(supplierVos);
|
|
supplierVos = batchHandleBaseExtInfo(supplierVos);
|
|
|
handleEnterpriseScaleName(supplierVos);
|
|
handleEnterpriseScaleName(supplierVos);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 4. 封装分页结果
|
|
|
|
|
- Page<SupplierInfoVo> newPage = copyPageResult(result, supplierVos);
|
|
|
|
|
- return TableDataInfo.build(newPage);
|
|
|
|
|
|
|
+ // 封装分页结果
|
|
|
|
|
+ Page<SupplierInfoVo> resultPage = new Page<>(tempPage.getCurrent(), tempPage.getSize(), tempPage.getTotal());
|
|
|
|
|
+ resultPage.setRecords(supplierVos);
|
|
|
|
|
+
|
|
|
|
|
+ return TableDataInfo.build(resultPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2168,6 +2108,23 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
if (baseMapper.insert(supplierInfo) <= 0) {
|
|
if (baseMapper.insert(supplierInfo) <= 0) {
|
|
|
throw new ServiceException("供应商信息注册失败");
|
|
throw new ServiceException("供应商信息注册失败");
|
|
|
}
|
|
}
|
|
|
|
|
+ //先查询供应商是否做过修改,如果有则直接编辑
|
|
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.getOne(
|
|
|
|
|
+ new LambdaQueryWrapper<SupplierInfoTemporary>()
|
|
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, supplierInfo.getId())
|
|
|
|
|
+ );
|
|
|
|
|
+ if (supplierInfoTemporary != null) {
|
|
|
|
|
+ SupplierInfoTemporary add = BeanUtil.toBean(supplierInfo, SupplierInfoTemporary.class);
|
|
|
|
|
+ add.setId(supplierInfoTemporary.getId());
|
|
|
|
|
+ add.setSupplierId(supplierInfo.getId());
|
|
|
|
|
+ add.setSupplyStatus(0L);
|
|
|
|
|
+ supplierInfoTemporaryService.updateById(add);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ SupplierInfoTemporary add = BeanUtil.toBean(supplierInfo, SupplierInfoTemporary.class);
|
|
|
|
|
+ add.setSupplierId(supplierInfo.getId());
|
|
|
|
|
+ add.setSupplyStatus(0L);
|
|
|
|
|
+ supplierInfoTemporaryService.save(add);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Long supplierId = supplierInfo.getId();
|
|
Long supplierId = supplierInfo.getId();
|
|
|
|
|
|