From cea4e4e9c6dad4d4f1b04b750ffca73cc252b22f Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期六, 25 四月 2026 10:23:00 +0800
Subject: [PATCH] 生产工单流转卡去掉logo,增加产品单位
---
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java | 39 ++++++++++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index ec3d367..d22f0f4 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -34,12 +34,12 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.function.Function;
import java.util.stream.Collectors;
@Service
@@ -184,14 +184,39 @@
productStructureDto.setUnitQuantity(BigDecimal.ONE);
productStructureDtos.add(productStructureDto);
}
+ Set<Long> parentIds = productStructureDtos.stream()
+ .map(ProductStructureDto::getParentId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ Map<Long, ProductStructureDto> parentMap =
+ productStructureMapper.selectByIds(parentIds)
+ .stream()
+ .collect(Collectors.toMap(
+ ProductStructureDto::getId,
+ Function.identity()
+ ));
for (ProductStructureDto productStructureDto : productStructureDtos) {
- System.out.println(productStructureDto.getProductModelId());
ProductionProductInput productionProductInput = new ProductionProductInput();
productionProductInput.setProductModelId(productStructureDto.getProductModelId());
- productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity()));
+// productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity()));
+ BigDecimal childQty = productStructureDto.getUnitQuantity();
+ BigDecimal parentQty = BigDecimal.ONE;
+ if (productStructureDto.getParentId() != null) {
+ ProductStructureDto parent = parentMap.get(productStructureDto.getParentId());
+ if (parent != null) {
+ parentQty = parent.getUnitQuantity();
+ }
+ }
+
+ // 鏍稿績璁$畻
+ BigDecimal needQty = childQty.divide(parentQty, 6, RoundingMode.HALF_UP).multiply(dto.getQuantity());
+
+
+ productionProductInput.setQuantity(needQty);
+
productionProductInput.setProductMainId(productionProductMain.getId());
productionProductInputMapper.insert(productionProductInput);
- stockUtils.substractStock(productStructureDto.getProductModelId(), productionProductInput.getQuantity(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), productionProductMain.getId(),dto.getBatchNo());
+ stockUtils.substractStock(productStructureDto.getProductModelId(), productionProductInput.getQuantity(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), productionProductMain.getId(), null);
}
/*鏂板鎶ュ伐浜у嚭琛�*/
ProductionProductOutput productionProductOutput = new ProductionProductOutput();
@@ -449,4 +474,4 @@
return productionProductMainDtos;
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3