huminmin
2026-04-08 f7b8a02843673c19e21b275d1c54e2a778bfedd4
src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -161,6 +161,15 @@
    @Override
    public Boolean addProductOrder(ProductOrder productOrder) {
        // 检查相同产品型号和批号是否已存在
        if (productOrder.getProductModelId() != null && productOrder.getBatchNo() != null) {
            LambdaQueryWrapper<ProductOrder> queryWrapper = Wrappers.<ProductOrder>lambdaQuery()
                    .eq(ProductOrder::getProductModelId, productOrder.getProductModelId())
                    .eq(ProductOrder::getBatchNo, productOrder.getBatchNo());
            if (this.count(queryWrapper) > 0) {
                throw new RuntimeException("相同产品型号和批号的生产订单已存在");
            }
        }
        String string = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
        productOrder.setNpsNo(string);
        productOrder.setCompleteQuantity(BigDecimal.ZERO);
@@ -281,7 +290,7 @@
            List<DrawMaterialDto> materialDtoList = JSON.parseArray(productOrder.getDrawMaterials(), DrawMaterialDto.class);
            for (DrawMaterialDto drawMaterialDto : materialDtoList) {
                stockUtils.addStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(), null, productOrderDto.getId(),
                        drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer()
                        drawMaterialDto.getBatchNo(), drawMaterialDto.getCustomer(),drawMaterialDto.getProductionDate()
                );
            }
        }
@@ -292,6 +301,10 @@
                if (drawMaterialDto.getProductModelId() == null) {
                    throw new RuntimeException("产品型号ID不能为空");
                }
                if (drawMaterialDto.getQualitity() == null  || drawMaterialDto.getQualitity().compareTo(BigDecimal.ZERO) == 0) {
                    throw new RuntimeException("产品" + drawMaterialDto.getProductName() + "型号" + drawMaterialDto.getModel()
                     + "批号" + drawMaterialDto.getBatchNo() + "库存不足!");
                }
                stockUtils.substractStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(),
                        StockOutQualifiedRecordTypeEnum.DRAW_MATERIALS_STOCK_OUT.getCode(), productOrderDto.getId(),
                        drawMaterialDto.getBatchNo(),drawMaterialDto.getCustomer());