7 天以前 901e3c96c76f168ddbeaa10562a4d2d6f4d3ba8c
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -168,6 +168,11 @@
        int result;
        Long salesLedgerId = salesLedgerProduct.getSalesLedgerId();
        salesLedgerProduct.setSingleQuantity(normalizeSingleQuantity(salesLedgerProduct.getSingleQuantity()));
        salesLedgerProduct.setTotalQuantity(normalizeTotalQuantity(
                salesLedgerProduct.getTotalQuantity(),
                salesLedgerProduct.getQuantity(),
                salesLedgerProduct.getSingleQuantity()
        ));
        if (salesLedgerProduct.getId() == null) {
            salesLedgerProduct.setRegisterDate(LocalDateTime.now());
            result = salesLedgerProductMapper.insert(salesLedgerProduct);
@@ -225,7 +230,11 @@
        productionPlan.setSalesLedgerProductId(salesLedgerProduct.getId());
        productionPlan.setMpsNo(generateNextPlanNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))));
        productionPlan.setProductModelId(salesLedgerProduct.getProductModelId());
        productionPlan.setQtyRequired(salesLedgerProduct.getQuantity());
        productionPlan.setQtyRequired(normalizeTotalQuantity(
                salesLedgerProduct.getTotalQuantity(),
                salesLedgerProduct.getQuantity(),
                salesLedgerProduct.getSingleQuantity()
        ));
        productionPlan.setSource("销售");
        productionPlan.setStatus(0);
        productionPlan.setRequiredDate(salesLedger.getDeliveryDate());//需求日期=交货日期
@@ -344,6 +353,16 @@
        return singleQuantity;
    }
    private BigDecimal normalizeTotalQuantity(BigDecimal totalQuantity, BigDecimal quantity, BigDecimal singleQuantity) {
        if (totalQuantity != null && totalQuantity.compareTo(BigDecimal.ZERO) > 0) {
            return totalQuantity;
        }
        if (quantity == null || quantity.compareTo(BigDecimal.ZERO) <= 0) {
            return BigDecimal.ZERO;
        }
        return quantity.multiply(normalizeSingleQuantity(singleQuantity));
    }
    private String generateNextPlanNo(String datePrefix) {
        QueryWrapper<ProductionPlan> queryWrapper = new QueryWrapper<>();
        queryWrapper.likeRight("mps_no", "JH" + datePrefix);