From 6f0df10fdd0e55e5ed3e31b1720efd25e2bf02fb Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期三, 16 九月 2026 18:51:12 +0800
Subject: [PATCH] fix: 添加条件过滤以确保查询结果中合格数量大于零
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index 28ce78a..4dae74c 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -308,29 +308,30 @@
}
int count = 0;
StringBuilder stringBuffer = new StringBuilder();
+ // 鎵佸钩BOM鍙淮鎶も�滅墿鏂欒鏍� + 娑堣�楀伐搴忊�濓紝涓嶉厤缃敤閲忥紝
+ // 鍥犳杩欓噷鍙牎楠屾瘡涓墿鏂欐槸鍚︽湁鍙敤搴撳瓨锛屼笉鍐嶆寜鍗曚綅鐢ㄩ噺鏍哥畻闇�姹傛暟閲忋��
for (TechnologyBomStructureVo structure : structureList) {
- if (structure.getParentId() == null) {
+ if (structure == null || structure.getProductModelId() == null) {
continue;
}
- StockInventory stockInventory = stockInventoryMapper.selectOne(
- new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, structure.getProductModelId()));
- if (stockInventory == null) {
- count++;
- stringBuffer.append(structure.getProductName()).append("-").append(structure.getModel()).append("搴撳瓨涓嶈冻").append(System.lineSeparator());
- continue;
+ List<StockInventory> stockList = stockInventoryMapper.selectList(
+ new QueryWrapper<StockInventory>().lambda()
+ .eq(StockInventory::getProductModelId, structure.getProductModelId()));
+ BigDecimal available = BigDecimal.ZERO;
+ for (StockInventory stockInventory : stockList) {
+ if (stockInventory == null) {
+ continue;
+ }
+ BigDecimal quantity = stockInventory.getQualitity() == null ? BigDecimal.ZERO : stockInventory.getQualitity();
+ BigDecimal locked = stockInventory.getLockedQuantity() == null ? BigDecimal.ZERO : stockInventory.getLockedQuantity();
+ available = available.add(quantity.subtract(locked));
}
- BigDecimal required = salesLedgerProduct.getQuantity().multiply(structure.getUnitQuantity() == null ? BigDecimal.ZERO : structure.getUnitQuantity());
- BigDecimal remain = stockInventory.getQualitity()
- .subtract(stockInventory.getLockedQuantity())
- .subtract(required)
- .divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
- if (remain.compareTo(BigDecimal.ZERO) < 0) {
+ if (available.compareTo(BigDecimal.ZERO) <= 0) {
count++;
stringBuffer.append(structure.getProductName())
.append("-")
.append(structure.getModel())
- .append("搴撳瓨涓嶈冻锛屽皯")
- .append(remain.abs())
+ .append("鏃犲彲鐢ㄥ簱瀛�")
.append(System.lineSeparator());
}
}
--
Gitblit v1.9.3