src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -37,7 +37,6 @@
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;
@@ -99,6 +98,7 @@
        BigDecimal reportQty = dto.getQuantity();
        BigDecimal scrapQty = dto.getScrapQty() == null ? BigDecimal.ZERO : dto.getScrapQty();
        BigDecimal bomInputQty = dto.getBomInputQty();
        if (reportQty == null || reportQty.compareTo(BigDecimal.ZERO) <= 0) {
            throw new ServiceException("报工数量必须大于0");
        }
@@ -107,6 +107,9 @@
        }
        if (scrapQty.compareTo(reportQty) > 0) {
            throw new ServiceException("报废数量不能大于报工数量");
        }
        if (bomInputQty == null || bomInputQty.compareTo(BigDecimal.ZERO) < 0) {
            throw new ServiceException("产品结构投入数量不能小于0");
        }
        // 第二步:加载当前工序、工单、工艺路线和订单数据,并校验基础关联关系
@@ -313,6 +316,9 @@
                    .collect(Collectors.toMap(ProductStructureDto::getId, Function.identity(), (a, b) -> a));
        }
        // 第七步-1:投入数量强制取前端传入的 bomInputQty
        BigDecimal inputBaseQty = bomInputQty;
        for (ProductStructureDto productStructureDto : productStructureDtos) {
            if (productStructureDto.getProductModelId() == null) {
                throw new ServiceException("投入物料产品型号不能为空");
@@ -335,9 +341,7 @@
                throw new ServiceException("父级物料用量必须大于0");
            }
            BigDecimal needQty = childQty
                    .divide(parentQty, 6, RoundingMode.HALF_UP)
                    .multiply(reportQty);
            BigDecimal needQty = inputBaseQty;
            ProductionProductInput productionProductInput = new ProductionProductInput();
            productionProductInput.setProductModelId(productStructureDto.getProductModelId());
@@ -350,6 +354,7 @@
                    needQty,
                    StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(),
                    productionProductMain.getId(),
                    null,
                    null
            );
        }