| | |
| | | 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(); |
| | | // 需求数量 |