| | |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private final StockUtils stockUtils; |
| | | private final ApprovalTemplateMapper approvalTemplateMapper; |
| | | private final SparePartsMapper sparePartsMapper; |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | @Override |
| | | public List<PurchaseLedger> selectPurchaseLedgerList(PurchaseLedger purchaseLedger) { |
| | |
| | | qualityInspect.setProductModelId(saleProduct.getProductModelId()); |
| | | qualityInspect.setUnit(saleProduct.getUnit()); |
| | | qualityInspect.setQuantity(saleProduct.getQuantity()); |
| | | qualityInspect.setWarehouse(saleProduct.getStorageLocation()); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0,null); |
| | | if (qualityTestStandard.size()>0){ |
| | |
| | | if (CollectionUtils.isEmpty(stockRecords) |
| | | && qualityInspect.getQualifiedQuantity() != null |
| | | && qualityInspect.getQualifiedQuantity().compareTo(BigDecimal.ZERO) > 0) { |
| | | // 优先使用质检单中的库位,如果没有则使用产品明细中的库位 |
| | | String warehouse = StringUtils.hasText(qualityInspect.getWarehouse()) |
| | | ? qualityInspect.getWarehouse() |
| | | : product.getStorageLocation(); |
| | | stockUtils.addStockWithBatchNo( |
| | | product.getProductModelId(), |
| | | qualityInspect.getQualifiedQuantity(), |
| | | StockInQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_OUT.getCode(), |
| | | qualityInspect.getId(), |
| | | null, |
| | | purchaseInspectTime == null ? null : purchaseInspectTime.plusDays(1) |
| | | purchaseInspectTime == null ? null : purchaseInspectTime.plusDays(1), |
| | | warehouse |
| | | ); |
| | | stockRecords = findQualityStockRecords(qualityInspect.getId(), product.getProductModelId()); |
| | | } |
| | |
| | | StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), |
| | | purchaseLedger.getId(), |
| | | purchaseLedger.getPurchaseContractNumber() + "-" + product.getId(), |
| | | stockCreateTime |
| | | stockCreateTime, |
| | | product.getStorageLocation() |
| | | ); |
| | | stockRecords = findDirectStockRecords(purchaseLedger.getId(), purchaseLedger.getPurchaseContractNumber(), product.getProductModelId(), product.getId()); |
| | | } |
| | |
| | | product.setProductCategory(spareParts.getName()); |
| | | } |
| | | } |
| | | |
| | | // 如果有设备ID但没有库位,从设备表自动填充库位 |
| | | if (product.getDeviceId() != null && StringUtils.isEmpty(product.getStorageLocation())) { |
| | | DeviceLedger device = deviceLedgerMapper.selectById(product.getDeviceId()); |
| | | if (device != null && StringUtils.isNotEmpty(device.getStorageLocation())) { |
| | | product.setStorageLocation(device.getStorageLocation()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 分组处理 |