Browse Source

[fix] 采购管理

按照万材调整;在选择供应商之后第二步选择物料之需要看见此供应商可以提供的物料信息,其余信息不展示
已经采购的供应商以及物料不需要再展示,除非后续未采购的物料,有不同的供应商再次报价
dev
liuxiaoxu 2 months ago
parent
commit
5e022e2e6a
  1. 66
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

66
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

@ -128,7 +128,6 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
* */ * */
@Override @Override
public List<PurchasePlanSelectSupplierVo> selectSupplierOneList(PurchasePlan purchasePlan) { public List<PurchasePlanSelectSupplierVo> selectSupplierOneList(PurchasePlan purchasePlan) {
String purchasePlanCode = purchasePlan.getPurchasePlanCode(); String purchasePlanCode = purchasePlan.getPurchasePlanCode();
List<String> purchasePlanCodeList = new ArrayList<>(); List<String> purchasePlanCodeList = new ArrayList<>();
@ -136,58 +135,55 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
String[] splitSalesOrderCode = purchasePlanCode.split(","); String[] splitSalesOrderCode = purchasePlanCode.split(",");
purchasePlanCodeList = Arrays.asList(splitSalesOrderCode); purchasePlanCodeList = Arrays.asList(splitSalesOrderCode);
} }
List<PurchasePlan> purchasePlanList = purchasePlanMapper.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList);
//采购计划子表数据 // 获取采购计划子表数据并过滤掉已完成采购的项
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(purchasePlanCodeList); List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(purchasePlanCodeList)
.stream()
.filter(item -> Objects.nonNull(item.getPurchasePlanStatus()) && !"2".equals(item.getPurchasePlanStatus()))
.collect(Collectors.toList());
//查找采购报价的数据 // 获取采购计划中的物料编号
List<PurchaseQuote> purchaseQuoteList = purchaseQuoteMapper.selectPurchaseQuoteAllList(); Set<String> planMaterialNos = purchasePlanChildList.stream().map(PurchasePlanChild::getMaterialNo).collect(Collectors.toSet());
// 查找采购报价的数据,并获取报价子表的数据
List<PurchaseQuote> purchaseQuoteList = purchaseQuoteMapper.selectPurchaseQuoteAllList();
List<String> purchaseQuoteCodes = purchaseQuoteList.stream().map(PurchaseQuote::getPurchaseQuoteCode).collect(Collectors.toList()); List<String> purchaseQuoteCodes = purchaseQuoteList.stream().map(PurchaseQuote::getPurchaseQuoteCode).collect(Collectors.toList());
//查找采购报价子表的数据
List<PurchaseQuoteChild> purchaseQuoteChildList = purchaseQuoteChildMapper.selectPurchaseQuoteChildListByQuoteCodeList(purchaseQuoteCodes); List<PurchaseQuoteChild> purchaseQuoteChildList = purchaseQuoteChildMapper.selectPurchaseQuoteChildListByQuoteCodeList(purchaseQuoteCodes);
// 根据供应商编号对采购报价子表进行分组
//获取采购计划中的物料编号 Map<String, List<PurchaseQuoteChild>> quoteChildBySupplier = purchaseQuoteChildList.stream()
Set<String> planMaterialNos = purchasePlanChildList.stream().map(PurchasePlanChild::getMaterialNo).collect(Collectors.toSet()); .collect(Collectors.groupingBy(PurchaseQuoteChild::getSupplierCode));
//根据供应商编号对采购报价子表进行分组
Map<String, List<PurchaseQuoteChild>> quoteChildBySupplier = purchaseQuoteChildList.stream().collect(Collectors.groupingBy(PurchaseQuoteChild::getSupplierCode));
//提取采购报价中的所有supplierCode
List<String> supplierCodes = purchaseQuoteList.stream().map(PurchaseQuote::getSupplierQuoteCode).distinct().collect(Collectors.toList());
// 创建结果列表 // 创建结果列表
List<PurchasePlanSelectSupplierVo> result = new ArrayList<>(); List<PurchasePlanSelectSupplierVo> result = new ArrayList<>();
// 遍历每个 supplierCode // 遍历每个供应商
for (Map.Entry<String, List<PurchaseQuoteChild>> entry : quoteChildBySupplier.entrySet()) { for (Map.Entry<String, List<PurchaseQuoteChild>> entry : quoteChildBySupplier.entrySet()) {
String supplierCode = entry.getKey(); String supplierCode = entry.getKey();
List<PurchaseQuoteChild> supplierQuoteChildren = entry.getValue(); List<PurchaseQuoteChild> supplierQuoteChildren = entry.getValue();
SysSupplier sysSupplier = sysSupplierMapper.selectSysSupplierByCode(supplierCode); SysSupplier sysSupplier = sysSupplierMapper.selectSysSupplierByCode(supplierCode);
// 提取这些 purchaseQuoteChild 中的所有 materialCode
Set<String> supplierMaterialCodes = supplierQuoteChildren.stream() // 提取这些 purchaseQuoteChild 中与采购计划关联且未完成采购的物料
Set<String> availableMaterials = supplierQuoteChildren.stream()
.map(PurchaseQuoteChild::getMaterialCode) .map(PurchaseQuoteChild::getMaterialCode)
.filter(planMaterialNos::contains) .filter(materialCode -> planMaterialNos.contains(materialCode))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
// 创建 PurchasePlanSelectSupplierVo 对象 // 创建 PurchasePlanSelectSupplierVo 对象
PurchasePlanSelectSupplierVo vo = new PurchasePlanSelectSupplierVo(); PurchasePlanSelectSupplierVo vo = new PurchasePlanSelectSupplierVo();
vo.setSupplierCode(supplierCode); vo.setSupplierCode(supplierCode);
vo.setSupplierName(sysSupplier.getSupplierName()); vo.setSupplierName(sysSupplier.getSupplierName());
vo.setAvailableMaterialNum(supplierMaterialCodes.size()); vo.setAvailableMaterialNum(availableMaterials.size());
// 将结果添加到结果列表中 // 将结果添加到结果列表中
result.add(vo); result.add(vo);
} }
//去掉没有可供应物料数的供应商 // 去掉没有可供应物料数的供应商,并对结果进行排序,按可用物料数量降序
result = result.stream().filter(item->item.getAvailableMaterialNum() > 0).collect(Collectors.toList()); return result.stream()
//对结果进行排序,按可用物料数量降序 .filter(item -> item.getAvailableMaterialNum() > 0)
result.sort(Comparator.comparingInt(PurchasePlanSelectSupplierVo::getAvailableMaterialNum).reversed()); .sorted(Comparator.comparingInt(PurchasePlanSelectSupplierVo::getAvailableMaterialNum).reversed())
return result; .collect(Collectors.toList());
} }
/** /**
@ -285,9 +281,14 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
mergedList.forEach(item -> { mergedList.forEach(item -> {
// 获取库存查询信息 // 获取库存查询信息
WarehouseInventoryInquiry warehouseInventoryInquiry = warehouseInventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(item.getMaterialNo()); WarehouseInventoryInquiry warehouseInventoryInquiry = warehouseInventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(item.getMaterialNo());
Integer sharedAvailableStockNum = 0;
if (warehouseInventoryInquiry != null){
// 设置共享可用库存数,默认为0 // 设置共享可用库存数,默认为0
Integer sharedAvailableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getSharedAvailableStockNum()).orElse(0); sharedAvailableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getSharedAvailableStockNum()).orElse(0);
}else {
sharedAvailableStockNum = 0;
}
item.setSharedAvailableInventoryNum(sharedAvailableStockNum); item.setSharedAvailableInventoryNum(sharedAvailableStockNum);
// 计划采购数、实际采购数、作废数 // 计划采购数、实际采购数、作废数
@ -321,8 +322,11 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
// mergedList = mergedList.stream().filter(item->item.getPurchaseNum() > 0).collect(Collectors.toList()); // mergedList = mergedList.stream().filter(item->item.getPurchaseNum() > 0).collect(Collectors.toList());
//过滤掉采购计划状态为全部申请和全部作废的数据 2为全部申请、3为全部作废 //过滤掉采购计划状态为全部申请和全部作废的数据 2为全部申请、3为全部作废
mergedList = mergedList.stream().filter(item->!item.getPurchasePlanStatus().equals("2") || !item.getPurchasePlanStatus().equals("3")).collect(Collectors.toList()); mergedList = mergedList.stream()
.filter(item -> !"2".equals(item.getPurchasePlanStatus()) && !"3".equals(item.getPurchasePlanStatus()))
.collect(Collectors.toList());
//过滤掉 不含税总价和含税总价为null或者0的数据
mergedList = mergedList.stream().filter(item->item.getMaterialNoRmbSum() != null && item.getMaterialNoRmbSum().compareTo(BigDecimal.ZERO) > 0 && item.getMaterialRmbSum() != null && item.getMaterialRmbSum().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
return mergedList; return mergedList;
} }

Loading…
Cancel
Save