gongchunyi
3 天以前 f0bcc6b51f4a272321710650800486d7d2f019fd
fix:报工数量负数判断
已修改1个文件
12 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/service/impl/ProductionRecordServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionRecordServiceImpl.java
@@ -202,8 +202,18 @@
            throw new ServiceException("报工失败,生产订单不存在");
        }
        //  当前报工合格数量(前端已保证 = 投入数量 - 不合格数量,直接使用)
        //  当前报工合格数量
        BigDecimal qualifiedQty = dto.getQualifiedQuantity() == null ? BigDecimal.ZERO : dto.getQualifiedQuantity();
        BigDecimal unqualifiedQty = dto.getUnqualifiedQuantity() == null ? BigDecimal.ZERO : dto.getUnqualifiedQuantity();
        BigDecimal totalReportQty = dto.getQuantity() == null ? BigDecimal.ZERO : dto.getQuantity();
        if (qualifiedQty.compareTo(BigDecimal.ZERO) < 0 || unqualifiedQty.compareTo(BigDecimal.ZERO) < 0 || totalReportQty.compareTo(BigDecimal.ZERO) < 0) {
            throw new ServiceException("报工失败:合格数量、不合格数量或总数量不能为负数");
        }
        if (qualifiedQty.add(unqualifiedQty).compareTo(totalReportQty) != 0) {
            throw new ServiceException("报工失败:合格数量与不合格数量之和必须等于总报工数量");
        }
        //  订单已完成数量(历史累计)
        BigDecimal completeQty = productOrder.getCompleteQuantity() == null ? BigDecimal.ZERO : productOrder.getCompleteQuantity();
        //  需求数量