zss
2 天以前 d15462274ecea7f7fe3dfc4b81278bc647e8cd26
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -65,18 +65,18 @@
            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));
        }
@@ -103,8 +103,11 @@
    public int updatePro(ProcurementUpdateDto procurementDto) {
        ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
        procurementRecordStorageById.setInboundNum(procurementDto.getQuantityStock());
        procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
        procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
        procurementRecordStorageById.setUpdateTime(LocalDateTime.now());
        procurementRecordStorageById.setOutStockQuantity(procurementDto.getOutStockQuantity());
        procurementRecordStorageById.setShortageDescription(procurementDto.getShortageDescription());
        return procurementRecordMapper.updateById(procurementRecordStorageById);
    }
@@ -346,8 +349,12 @@
            ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder()
                    .salesLedgerProductId(detail.getId())
                    .productModelId(detail.getProductModelId())
                    .inboundBatches(aLong.equals(0L) ? "第1批次" : "第"+ (aLong + 1) + "批次")
                    .inboundNum(detail.getInboundQuantity())
                    .warnNum(detail.getWarnNum())
                    .outStockQuantity(detail.getOutStockQuantity())
                    .shortageDescription(detail.getShortageDescription())
                    .createTime(LocalDateTime.now())
                    .createUser(loginUser.getUserId())
                    .updateTime(LocalDateTime.now())