| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | final BigDecimal finalStockInNum; |
| | | if (item.getStockInNum() != null && item.getStockInNum().compareTo(BigDecimal.ZERO) > 0) { |
| | | finalStockInNum = item.getStockInNum(); |
| | | adjustPurchaseInboundAuditFields(stockInRecord, finalStockInNum); |
| | | // 更新入库记录的入库数量 |
| | | stockInRecord.setStockInNum(finalStockInNum); |
| | | } else { |
| | |
| | | return items.size(); |
| | | } |
| | | |
| | | private void adjustPurchaseInboundAuditFields(StockInRecord stockInRecord, BigDecimal finalStockInNum) { |
| | | if (stockInRecord == null || finalStockInNum == null) { |
| | | return; |
| | | } |
| | | if (!StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | return; |
| | | } |
| | | BigDecimal theoryStockInNum = stockInRecord.getTheoryStockInNum(); |
| | | if (theoryStockInNum == null || theoryStockInNum.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return; |
| | | } |
| | | if (finalStockInNum.compareTo(theoryStockInNum) > 0) { |
| | | throw new BaseException("采购入库审核时,实际入库数量不能大于理论入库数量"); |
| | | } |
| | | if (Boolean.TRUE.equals(stockInRecord.getIsContainsWater())) { |
| | | BigDecimal waterContent = theoryStockInNum.subtract(finalStockInNum) |
| | | .multiply(new BigDecimal("100")) |
| | | .divide(theoryStockInNum, 4, RoundingMode.HALF_UP); |
| | | stockInRecord.setWaterContent(waterContent); |
| | | } |
| | | } |
| | | |
| | | private static @NonNull StockInventoryDto getStockInventoryDto(StockInRecord stockInRecord) { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setProductModelId(stockInRecord.getProductModelId()); |