| | |
| | | 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); |