| | |
| | | // 计算待入库数量 |
| | | // 查询采购记录已入库数量 |
| | | List<Integer> collect = procurementDtos.stream().map(ProcurementDto::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | if(CollectionUtils.isEmpty( collect)){ |
| | | return procurementDtos; |
| | | } |
| | | LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordLambdaQueryWrapper.in(ProcurementRecordStorage::getSalesLedgerProductId, collect); |
| | | List<ProcurementRecordStorage> procurementRecordStorages = procurementRecordMapper.selectList(procurementRecordLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(procurementRecordStorages)) { |
| | | if(CollectionUtils.isEmpty(procurementRecordStorages)){ |
| | | return procurementDtos; |
| | | } |
| | | for (ProcurementDto dto : procurementDtos) { |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 如果没有相关的入库记录,跳过该条数据 |
| | | if (CollectionUtils.isEmpty(collect1)) { |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setQuantity0(dto.getQuantity()); |
| | | continue; |
| | | } |
| | |
| | | // 删除所有对应的出库记录 |
| | | LambdaQueryWrapper<ProcurementRecordOut> procurementRecordOutLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordOutLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, procurementDto.getIds()) |
| | | .eq(ProcurementRecordOut::getType, procurementDto.getType()); |
| | | .eq(ProcurementRecordOut::getType,procurementDto.getType()); |
| | | List<ProcurementRecordOut> procurementRecordOuts = procurementRecordOutMapper.selectList(procurementRecordOutLambdaQueryWrapper); |
| | | if (!CollectionUtils.isEmpty(procurementRecordOuts)) { |
| | | if(!CollectionUtils.isEmpty(procurementRecordOuts)){ |
| | | procurementRecordOutMapper.deleteBatchIds(procurementRecordOuts.stream().map(ProcurementRecordOut::getId).collect(Collectors.toList())); |
| | | } |
| | | return 0; |
| | |
| | | currentStock += dto.getInboundNum().intValue() - totalInboundNum.intValue(); |
| | | values.add(currentStock); |
| | | // 计算周转率 |
| | | if (totalIn > 0) { |
| | | if(totalIn > 0){ |
| | | turnoverRate = totalOut * 100 / totalIn; |
| | | } |
| | | } |
| | |
| | | .eq(ProcurementRecordStorage::getType, procurementDto.getType()); |
| | | Long aLong = procurementRecordMapper.selectCount(procurementRecordLambdaQueryWrapper); |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(detail.getId()); |
| | | if (ObjectUtils.isNull(detail.getProductModelId())) { |
| | | if (ObjectUtils.isNull(detail.getProductModelId())){ |
| | | detail.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | } |
| | | ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder() |
| | |
| | | .updateUser(loginUser.getUserId()) |
| | | .createBy(procurementDto.getNickName()) |
| | | .productModelId(detail.getProductModelId()) |
| | | .qualityInspectId(ObjectUtils.isNotNull(procurementDto.getQualityInspectId()) ? procurementDto.getQualityInspectId() : 0L); |
| | | .qualityInspectId(ObjectUtils.isNotNull(procurementDto.getQualityInspectId())?procurementDto.getQualityInspectId():0L); |
| | | this.save(procurementRecordBuilder.build()); |
| | | // 入库成功减掉采购数量 |
| | | // LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | // 计算待入库数量 |
| | | // 查询采购记录已入库数量 |
| | | List<Integer> collect = procurementPageDtos.stream().map(ProcurementPageDto::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | if(CollectionUtils.isEmpty( collect)){ |
| | | return procurementPageDtoIPage; |
| | | } |
| | | LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect) |
| | | .eq(ProcurementRecordOut::getType, 1); |
| | | List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(procurementRecords)) { |
| | | if(CollectionUtils.isEmpty( procurementRecords)){ |
| | | return procurementPageDtoIPage; |
| | | } |
| | | for (ProcurementPageDto dto : procurementPageDtos) { |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 如果没有相关的出库记录,跳过该条数据 |
| | | if (CollectionUtils.isEmpty(collect1)) { |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setInboundNum0(dto.getInboundNum()); |
| | | continue; |
| | | } |
| | |
| | | // 计算待入库数量 |
| | | // 查询采购记录已入库数量 |
| | | List<Integer> collect = procurementPageDtoCopyList.stream().map(ProcurementPageDtoCopy::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | if(CollectionUtils.isEmpty( collect)){ |
| | | return procurementPageDtoCopyIPage; |
| | | } |
| | | LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect); |
| | | procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType, 1); |
| | | procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType,1); |
| | | List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(procurementRecords)) { |
| | | if(CollectionUtils.isEmpty( procurementRecords)){ |
| | | return procurementPageDtoCopyIPage; |
| | | } |
| | | for (ProcurementPageDtoCopy dto : procurementPageDtoCopyList) { |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 如果没有相关的出库记录,跳过该条数据 |
| | | if (CollectionUtils.isEmpty(collect1)) { |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setInboundNum0(dto.getInboundNum()); |
| | | dto.setTotalInboundNum(BigDecimal.ZERO); |
| | | continue; |
| | |
| | | // 待出库数量 = 总数量 - 已出库数量 |
| | | dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum)); |
| | | // 库存价值 |
| | | if (dto.getUnitPrice() != null) { |
| | | if(dto.getUnitPrice() != null){ |
| | | dto.setTotalPrice(dto.getInboundNum0().multiply(dto.getUnitPrice())); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ProductModel> listPageProductionStock(Page page) { |
| | | ProductModel productModel = new ProductModel(); |
| | | IPage<ProductModel> iPage = productModelMapper.listPageProductModel(page, productModel); |
| | | iPage.getRecords().forEach(item -> { |
| | | item.setInboundNum(stockUtils.getStockQuantity(item.getId()).get("inboundNum")); |
| | | item.setOutboundNum(stockUtils.getStockQuantity(item.getId()).get("outboundNum")); |
| | | item.setStockQuantity(stockUtils.getStockQuantity(item.getId()).get("stockQuantity")); |
| | | }); |
| | | return iPage; |
| | | public IPage<ProductModel> listPageProductionStock(Page page, ProcurementPageDto dto) { |
| | | return productModelMapper.listPageProductionStock(page, dto); |
| | | } |
| | | |
| | | |
| | |
| | | // 计算待入库数量 |
| | | // 查询采购记录已入库数量 |
| | | List<Integer> collect = procurementPageDtos.stream().map(ProcurementPageDto::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | if(CollectionUtils.isEmpty( collect)){ |
| | | return procurementPageDtoIPage; |
| | | } |
| | | LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect) |
| | | .eq(ProcurementRecordOut::getType, 4); |
| | | List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(procurementRecords)) { |
| | | if(CollectionUtils.isEmpty( procurementRecords)){ |
| | | return procurementPageDtoIPage; |
| | | } |
| | | for (ProcurementPageDto dto : procurementPageDtos) { |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 如果没有相关的出库记录,跳过该条数据 |
| | | if (CollectionUtils.isEmpty(collect1)) { |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setInboundNum0(dto.getInboundNum()); |
| | | continue; |
| | | } |