maven
7 天以前 5e79bce73b2cf6a65081082a10f6f4be06413aa3
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -119,7 +119,8 @@
        procurementRecordMapper.deleteBatchIds(procurementRecordStorageById.stream().map(ProcurementRecordStorage::getId).collect(Collectors.toList()));
        // 删除所有对应的出库记录
        LambdaQueryWrapper<ProcurementRecordOut> procurementRecordOutLambdaQueryWrapper = new LambdaQueryWrapper<>();
        procurementRecordOutLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, procurementDto.getIds());
        procurementRecordOutLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, procurementDto.getIds())
                .eq(ProcurementRecordOut::getType,procurementDto.getType());
        List<ProcurementRecordOut> procurementRecordOuts = procurementRecordOutMapper.selectList(procurementRecordOutLambdaQueryWrapper);
        if(!CollectionUtils.isEmpty(procurementRecordOuts)){
            procurementRecordOutMapper.deleteBatchIds(procurementRecordOuts.stream().map(ProcurementRecordOut::getId).collect(Collectors.toList()));
@@ -467,8 +468,11 @@
            if(customStorage.getTimeStr() != null){
                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getTimeStr());
            }
            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
            }
        }
        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getCreateTime);
        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
        IPage<CustomStorage> procurementPageDtoIPage = customStorageMapper.selectPage(page, customStorageLambdaQueryWrapper);
        procurementPageDtoIPage.getRecords().forEach(item -> item.setInboundNum0(item.getInboundNum()));
        List<CustomStorage> procurementPageDtos = procurementPageDtoIPage.getRecords();
@@ -534,6 +538,7 @@
            // 如果没有相关的出库记录,跳过该条数据
            if(CollectionUtils.isEmpty(collect1)){
                dto.setInboundNum0(dto.getInboundNum());
                dto.setTotalInboundNum(BigDecimal.ZERO);
                continue;
            }
@@ -545,25 +550,33 @@
            dto.setTotalInboundNum(totalInboundNum);
            // 待出库数量 = 总数量 - 已出库数量
            dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
            // 库存价值
            if(dto.getUnitPrice() != null){
                dto.setTotalPrice(dto.getTotalInboundNum().multiply(dto.getUnitPrice()));
            }
        }
        return procurementPageDtoCopyIPage;
    }
    @Override
    public IPage<CustomStorage> listPageCopyByCustom(Page page, CustomStorage customStorage) {
        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
        customStorageLambdaQueryWrapper.groupBy(CustomStorage::getProductCategory, CustomStorage::getSpecificationModel);
        if(customStorage != null){
            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
            }
            // 筛选入库时间
            if(customStorage.getInboundDate() != null){
                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getInboundDate());
            }
        }
        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getCreateTime);
        IPage<CustomStorage> pageList = customStorageMapper.selectPage(page, customStorageLambdaQueryWrapper);
//        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
//        customStorageLambdaQueryWrapper.groupBy(CustomStorage::getProductCategory, CustomStorage::getSpecificationModel,CustomStorage::getTaxInclusiveUnitPrice);
//        if(customStorage != null){
//            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
//                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
//            }
//            // 筛选入库时间
//            if(customStorage.getInboundDate() != null){
//                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getInboundDate());
//            }
//            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
//                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
//            }
//        }
//        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
        IPage<CustomStorage> pageList = customStorageMapper.listPageCopyByCustom(page, customStorage);
        List<CustomStorage> procurementPageDtoCopyList = pageList.getRecords();
        // 计算待入库数量
        // 查询采购记录已入库数量
@@ -587,6 +600,7 @@
            // 如果没有相关的出库记录,跳过该条数据
            if(CollectionUtils.isEmpty(collect1)){
                dto.setInboundNum0(dto.getInboundNum());
                dto.setTotalInboundNum(BigDecimal.ZERO);
                continue;
            }
@@ -598,6 +612,10 @@
            dto.setTotalInboundNum(totalInboundNum);
            // 待出库数量 = 总数量 - 已出库数量
            dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
            // 库存价值
            if(dto.getTaxInclusiveUnitPrice() != null){
                dto.setTaxInclusiveTotalPrice(dto.getInboundNum0().multiply(dto.getTaxInclusiveUnitPrice()));
            }
        }
        pageList.setRecords(procurementPageDtoCopyList);
        return pageList;
@@ -630,6 +648,8 @@
                    .inboundNum(detail.getInboundQuantity())
                    .type(procurementDto.getType())
                    .warnNum(detail.getWarnNum())
                    .unitPrice(detail.getUnitPrice())
                    .totalPrice(detail.getInboundQuantity().multiply(detail.getUnitPrice()))
                    .createTime(LocalDateTime.now())
                    .createUser(loginUser.getUserId())
                    .updateTime(LocalDateTime.now())
@@ -709,12 +729,13 @@
        for (ProcurementPageDtoCopy dto : procurementPageDtoCopyList) {
            // 根据采购台账ID筛选对应的出库记录
            List<ProcurementRecordOut> collect1 = procurementRecords.stream()
                    .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()))
                    .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()) && ProcurementRecordOut.getType().equals(1))
                    .collect(Collectors.toList());
            // 如果没有相关的出库记录,跳过该条数据
            if(CollectionUtils.isEmpty(collect1)){
                dto.setInboundNum0(dto.getInboundNum());
                dto.setTotalInboundNum(BigDecimal.ZERO);
                continue;
            }
@@ -726,6 +747,10 @@
            dto.setTotalInboundNum(totalInboundNum);
            // 待出库数量 = 总数量 - 已出库数量
            dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
            // 库存价值
            if(dto.getUnitPrice() != null){
                dto.setTotalPrice(dto.getInboundNum0().multiply(dto.getUnitPrice()));
            }
        }
        return procurementPageDtoCopyIPage;
    }