src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -55,7 +55,7 @@
    private static final String PROCESS_VOLTAGE_SORT = "电压分选";
    private static final String PROCESS_OPTICAL_INSPECTION = "光检外观";
    private static final String PROCESS_PACKAGING = "包装";
    private static final String INPUT_WEIGHT_PARAMETER = "投入重量";
    private static final String INPUT_WEIGHT_PARAMETER = "投入重量/数量";
    private static final String INPUT_WEIGHT_FIELD = "inputWeight";
    private static final Object PRODUCT_MAIN_NO_LOCK = new Object();
@@ -204,9 +204,9 @@
            BigDecimal previousCompleteQty =
                    previousWorkOrder.getCompleteQuantity() == null ? BigDecimal.ZERO : previousWorkOrder.getCompleteQuantity();
            if (currentReportedQty.add(reportQty).compareTo(previousCompleteQty) > 0) {
                throw new ServiceException("本次报工数量超过上道工序可流转数量");
            }
//            if (currentReportedQty.add(reportQty).compareTo(previousCompleteQty) > 0) {
//                throw new ServiceException("本次报工数量超过上道工序可流转数量");
//            }
            List<ProductProcessRouteItem> previousItems = productProcessRouteItemMapper.selectList(
                    Wrappers.<ProductProcessRouteItem>lambdaQuery()
@@ -250,10 +250,10 @@
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
        }
        if (productWorkOrder.getPlanQuantity() != null
                && currentWorkOrderReportedQty.add(reportQty).compareTo(productWorkOrder.getPlanQuantity()) > 0) {
            throw new ServiceException("本次报工数量超过工单可报数量");
        }
//        if (productWorkOrder.getPlanQuantity() != null
//                && currentWorkOrderReportedQty.add(reportQty).compareTo(productWorkOrder.getPlanQuantity()) > 0) {
//            throw new ServiceException("本次报工数量超过工单可报数量");
//        }
        // 第五步:生成报工单号并确定报工人信息
        String productNo;
@@ -327,6 +327,11 @@
        // 第七步-1:投入数量强制取前端传入的 bomInputQty
        BigDecimal inputBaseQty = bomInputQty;
        // 第七步-2:光检外观和包装工序不扣减库存
        String currentProcessName = productProcess.getName() == null ? "" : productProcess.getName().trim();
        boolean shouldSkipStockDeduction = PROCESS_OPTICAL_INSPECTION.equals(currentProcessName)
                || PROCESS_PACKAGING.equals(currentProcessName);
        for (ProductStructureDto productStructureDto : productStructureDtos) {
            if (productStructureDto.getProductModelId() == null) {
                throw new ServiceException("投入物料产品型号不能为空");
@@ -357,14 +362,16 @@
            productionProductInput.setProductMainId(productionProductMain.getId());
            productionProductInputMapper.insert(productionProductInput);
            stockUtils.substractStock(
                    productStructureDto.getProductModelId(),
                    needQty,
                    StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(),
                    productionProductMain.getId(),
                    null,
                    null
            );
            if (!shouldSkipStockDeduction) {
                stockUtils.substractStock(
                        productStructureDto.getProductModelId(),
                        needQty,
                        StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(),
                        productionProductMain.getId(),
                        null,
                        null
                );
            }
        }
        // 第八步:写产出记录并计算本次合格数量
@@ -778,7 +785,7 @@
        try {
            parsed = JSON.parse(otherData);
        } catch (Exception ex) {
            throw new ServiceException("报工参数格式错误,无法解析投入重量");
            throw new ServiceException("报工参数格式错误,无法解析投入重量/数量");
        }
        String inputWeight = StringUtils.trim(findParameterValue(parsed, INPUT_WEIGHT_PARAMETER));
        if (StringUtils.isBlank(inputWeight)) {
@@ -790,7 +797,7 @@
        try {
            return new BigDecimal(inputWeight);
        } catch (NumberFormatException ex) {
            throw new ServiceException("报工参数中的投入重量格式错误");
            throw new ServiceException("报工参数中的投入重量/数量格式错误");
        }
    }
@@ -852,4 +859,4 @@
        }
        return null;
    }
}
}