| | |
| | | procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum()); |
| | | procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId()); |
| | | procurementRecordStorageById.setUpdateTime(LocalDateTime.now()); |
| | | procurementRecordStorageById.setUnitPrice(procurementDto.getUnitPrice()); |
| | | procurementRecordStorageById.setTotalPrice(procurementDto.getTotalPrice()); |
| | | return procurementRecordMapper.updateById(procurementRecordStorageById); |
| | | } |
| | | |
| | |
| | | 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())); |
| | |
| | | if(salesLedgerProduct == null){ |
| | | throw new RuntimeException("销售台账产品不存在"); |
| | | } |
| | | // 根据大类,规格查询所有产品id |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getProductCategory, salesLedgerProduct.getProductCategory()) |
| | | .eq(SalesLedgerProduct::getSpecificationModel, salesLedgerProduct.getSpecificationModel()) |
| | | .eq(SalesLedgerProduct::getType, 1); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(salesLedgerProductLambdaQueryWrapper); |
| | | if(CollectionUtils.isEmpty(salesLedgerProducts)){ |
| | | throw new RuntimeException("没有找到对应的产品"); |
| | | } |
| | | salesLedgerProduct.setMinStock(procurementDto.getMinStock()); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId()); |
| | | procurementRecordStorageById.setCreateBy(sysUser.getNickName()); |
| | | procurementRecordStorageById.setCreateUser(sysUser.getUserId()); |
| | | procurementRecordStorageById.setUpdateTime(LocalDateTime.parse(entryDateStr,df)); |
| | | procurementRecordStorageById.setUpdateUser(loginUser.getUserId()); |
| | | procurementRecordStorageById.setCreateTime(LocalDateTime.parse(createTimeStr,df)); |
| | | procurementRecordMapper.updateById(procurementRecordStorageById); |
| | | LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordStorageLambdaQueryWrapper.in(ProcurementRecordStorage::getSalesLedgerProductId, salesLedgerProducts.stream().map(SalesLedgerProduct::getId).collect(Collectors.toList())); |
| | | ProcurementRecordStorage procurementRecordStorage = ProcurementRecordStorage.builder().build(); |
| | | procurementRecordStorage.setUnitPrice(procurementDto.getUnitPrice()); |
| | | procurementRecordStorage.setTotalPrice(procurementDto.getTotalPrice()); |
| | | procurementRecordStorage.setCreateBy(sysUser.getNickName()); |
| | | procurementRecordStorage.setCreateUser(sysUser.getUserId()); |
| | | procurementRecordStorage.setUpdateTime(LocalDateTime.parse(entryDateStr,df)); |
| | | procurementRecordStorage.setUpdateUser(loginUser.getUserId()); |
| | | procurementRecordStorage.setCreateTime(LocalDateTime.parse(createTimeStr,df)); |
| | | procurementRecordMapper.update(procurementRecordStorage,procurementRecordStorageLambdaQueryWrapper); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | // 如果没有相关的出库记录,跳过该条数据 |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setInboundNum0(dto.getInboundNum()); |
| | | dto.setTotalInboundNum(BigDecimal.ZERO); |
| | | continue; |
| | | } |
| | | |
| | |
| | | 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()); |
| | | } |
| | | if(!StringUtils.isEmpty(customStorage.getProductCategory())){ |
| | | customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory()); |
| | | } |
| | | } |
| | | customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate); |
| | | 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(); |
| | | // 计算待入库数量 |
| | | // 查询采购记录已入库数量 |
| | |
| | | // 如果没有相关的出库记录,跳过该条数据 |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setInboundNum0(dto.getInboundNum()); |
| | | dto.setTotalInboundNum(BigDecimal.ZERO); |
| | | continue; |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | @Override |
| | | public AjaxResult deleteCustom(List<Long> ids) { |
| | | return AjaxResult.success(customStorageMapper.deleteBatchIds(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public int updateManagementByCustom(ProcurementManagementUpdateDto procurementDto) { |
| | | CustomStorage customStorage = customStorageMapper.selectById(procurementDto.getId()); |
| | | if(customStorage == null){ |
| | | throw new RuntimeException("材料库存不存在"); |
| | | } |
| | | LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | customStorageLambdaQueryWrapper.eq(CustomStorage::getProductCategory, customStorage.getProductCategory()) |
| | | .eq(CustomStorage::getSpecificationModel, customStorage.getSpecificationModel()); |
| | | CustomStorage one = new CustomStorage(); |
| | | one.setTaxInclusiveUnitPrice(procurementDto.getTaxInclusiveUnitPrice()); |
| | | one.setTaxInclusiveTotalPrice(procurementDto.getTaxInclusiveTotalPrice()); |
| | | return customStorageMapper.update(one,customStorageLambdaQueryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .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()) |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | dto.setTotalInboundNum(totalInboundNum); |
| | | // 待出库数量 = 总数量 - 已出库数量 |
| | | dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum)); |
| | | // 库存价值 |
| | | if(dto.getUnitPrice() != null){ |
| | | dto.setTotalPrice(dto.getInboundNum0().multiply(dto.getUnitPrice())); |
| | | } |
| | | } |
| | | return procurementPageDtoCopyIPage; |
| | | } |