gongchunyi
3 天以前 566058f4f874741adfbef92868afa05386c457fa
fix: 报工不合格数量不能大于本次报工数量
已修改1个文件
6 ■■■■ 文件已修改
src/main/java/com/ruoyi/production/service/impl/ProductionRecordServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionRecordServiceImpl.java
@@ -206,10 +206,14 @@
        BigDecimal totalQty = productOrder.getQuantity() == null ? BigDecimal.ZERO : productOrder.getQuantity();
        //  剩余可报工数量
        BigDecimal remainQty = totalQty.subtract(completeQty);
        //  本次报工合格数量不能超过剩余数量(校验必须在累加前执行)
        //  本次报工合格数量不能超过剩余数量
        if (qualifiedQty.compareTo(remainQty) > 0) {
            throw new ServiceException("报工失败,本次报工数量不能大于剩余可报工数量,剩余报工数量:[" + remainQty + "]");
        }
        //  本次报工不合格数量不能超过本次报工数量
        if (dto.getUnqualifiedQuantity() != null && dto.getUnqualifiedQuantity().compareTo(dto.getQuantity()) > 0) {
            throw new ServiceException("报工失败,本次报工不合格数量不能大于报工数量,报工数量:[" + dto.getQuantity() + "]");
        }
        //  历史已完成 + 本次合格数量
        BigDecimal newCompleteQty = completeQty.add(qualifiedQty);
        productOrder.setCompleteQuantity(newCompleteQty);