实现采购入库的供货商字段数据存放到数据库,并且系统在采购入库界面能读取对应的采购入库单的对应供货商名称显示

This commit is contained in:
2025-10-31 13:52:33 +08:00
parent 642c4a0941
commit 52cc5e3aae
3 changed files with 43 additions and 5 deletions

View File

@@ -161,6 +161,27 @@ public class PurchaseInventoryAppServiceImpl implements IPurchaseInventoryAppSer
if (receiptDetailList.isEmpty()) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00006, null));
}
// 获取所有供应商ID
Set<Long> supplierIds = receiptDetailList.stream()
.filter(dto -> dto.getSupplierId() != null)
.map(ReceiptDetailDto::getSupplierId)
.collect(Collectors.toSet());
// 查询供应商信息并设置供应商名称
if (!supplierIds.isEmpty()) {
List<Supplier> suppliers = supplierService.listByIds(supplierIds);
Map<Long, String> supplierNameMap = suppliers.stream()
.collect(Collectors.toMap(Supplier::getId, Supplier::getName));
// 设置供应商名称
receiptDetailList.forEach(dto -> {
if (dto.getSupplierId() != null) {
dto.setSupplierName(supplierNameMap.getOrDefault(dto.getSupplierId(), ""));
}
});
}
return R.ok(receiptDetailList);
}