| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | |
| | | List<ProcurementRecordStorage> collect1 = procurementRecordStorages.stream() |
| | | .filter(procurementRecordStorage -> procurementRecordStorage.getSalesLedgerProductId().equals(dto.getId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | // 如果没有相关的入库记录,跳过该条数据 |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setQuantity0(dto.getQuantity()); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | // 计算已入库数量总和,并设置待入库数量 |
| | | BigDecimal totalInboundNum = collect1.stream() |
| | | .map(ProcurementRecordStorage::getInboundNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | |
| | | // 待入库数量 = 总数量 - 已入库数量 |
| | | dto.setQuantity0(dto.getQuantity().subtract(totalInboundNum)); |
| | | } |
| | |
| | | List<ProcurementRecordOut> recordOutList = procurementRecordOutMapper.selectList(queryWrapper); |
| | | |
| | | // 2. 按SalesLedgerProductId分组,统计每个id对应的已出库数量总和-已出库数量 |
| | | Map<Integer, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream() |
| | | Map<Long, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | ProcurementRecordOut::getSalesLedgerProductId, |
| | | Collectors.reducing( |
| | |
| | | procurementRecordLambdaQueryWrapper.eq(ProcurementRecordStorage::getSalesLedgerProductId, detail.getId()) |
| | | .eq(ProcurementRecordStorage::getType, procurementDto.getType()); |
| | | Long aLong = procurementRecordMapper.selectCount(procurementRecordLambdaQueryWrapper); |
| | | |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(detail.getId()); |
| | | if (ObjectUtils.isNull(detail.getProductModelId())){ |
| | | detail.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | } |
| | | ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder() |
| | | .salesLedgerProductId(detail.getId()) |
| | | .inboundBatches(aLong.equals(0L) ? "第1批次("+ procurementDto.getTypeName() +")" : "第"+ (aLong + 1) + "批次(" + procurementDto.getTypeName() + ")" ) |
| | |
| | | return iPage; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ProcurementPageDto> listPageByProductProduction(Page page, ProcurementPageDto procurementDto) { |
| | | IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordMapper.listPageByProductProduction(page, procurementDto); |
| | | return procurementPageDtoIPage; |
| | | } |
| | | |
| | | } |