| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | BigDecimal reportQty = dto.getQuantity(); |
| | | BigDecimal scrapQty = dto.getScrapQty() == null ? BigDecimal.ZERO : dto.getScrapQty(); |
| | | BigDecimal bomInputQty = dto.getBomInputQty(); |
| | | if (reportQty == null || reportQty.compareTo(BigDecimal.ZERO) <= 0) { |
| | | throw new ServiceException("报工数量必须大于0"); |
| | | } |
| | |
| | | } |
| | | if (scrapQty.compareTo(reportQty) > 0) { |
| | | throw new ServiceException("报废数量不能大于报工数量"); |
| | | } |
| | | if (bomInputQty == null || bomInputQty.compareTo(BigDecimal.ZERO) < 0) { |
| | | throw new ServiceException("产品结构投入数量不能小于0"); |
| | | } |
| | | |
| | | // 第二步:加载当前工序、工单、工艺路线和订单数据,并校验基础关联关系 |
| | |
| | | .collect(Collectors.toMap(ProductStructureDto::getId, Function.identity(), (a, b) -> a)); |
| | | } |
| | | |
| | | // 第七步-1:投入数量强制取前端传入的 bomInputQty |
| | | BigDecimal inputBaseQty = bomInputQty; |
| | | |
| | | for (ProductStructureDto productStructureDto : productStructureDtos) { |
| | | if (productStructureDto.getProductModelId() == null) { |
| | | throw new ServiceException("投入物料产品型号不能为空"); |
| | |
| | | throw new ServiceException("父级物料用量必须大于0"); |
| | | } |
| | | |
| | | BigDecimal needQty = childQty |
| | | .divide(parentQty, 6, RoundingMode.HALF_UP) |
| | | .multiply(reportQty); |
| | | BigDecimal needQty = inputBaseQty; |
| | | |
| | | ProductionProductInput productionProductInput = new ProductionProductInput(); |
| | | productionProductInput.setProductModelId(productStructureDto.getProductModelId()); |
| | |
| | | needQty, |
| | | StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), |
| | | productionProductMain.getId(), |
| | | null, |
| | | null |
| | | ); |
| | | } |