| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.framework.web.domain.R; |
| | |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.impl.ProductOrderServiceImpl; |
| | | import com.ruoyi.purchase.dto.SimpleReturnOrderGroupDto; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | private PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private PurchaseReturnOrderProductsMapper purchaseReturnOrderProductsMapper; |
| | | |
| | | private ProductOrderMapper productOrderMapper; |
| | | |
| | |
| | | |
| | | private ProcessRouteMapper processRouteMapper; |
| | | private ProductProcessRouteMapper productProcessRouteMapper; |
| | | private ProductModelMapper productModelMapper; |
| | | |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | private ProductionProductMainMapper productionProductMainMapper; |
| | |
| | | // queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerProduct.getSalesLedgerId()) |
| | | // .eq(SalesLedgerProduct::getType, salesLedgerProduct.getType()); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct); |
| | | if (!CollectionUtils.isEmpty(salesLedgerProducts)) { |
| | | if (CollectionUtils.isEmpty(salesLedgerProducts)) { |
| | | return salesLedgerProducts; |
| | | } |
| | | |
| | | salesLedgerProducts.forEach(item -> { |
| | | // 发货信息 |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, item.getId()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | |
| | | item.setExpressNumber(shippingInfo.getExpressNumber()); |
| | | } |
| | | }); |
| | | // 开票 |
| | | |
| | | if (salesLedgerProduct.getSalesLedgerId() != null) { |
| | | InvoiceRegistrationProductDto invoiceRegistrationProductDto = new InvoiceRegistrationProductDto(); |
| | | invoiceRegistrationProductDto.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId().intValue()); |
| | | List<InvoiceRegistrationProductDto> invoiceRegistrationProductDtoList = invoiceRegistrationProductMapper.invoiceRegistrationProductList(invoiceRegistrationProductDto); |
| | | // 统计开票登记产品的已开票数/已开票金额 |
| | | if (!CollectionUtils.isEmpty(invoiceRegistrationProductDtoList)) { |
| | | for (SalesLedgerProduct ledgerProduct : salesLedgerProducts) { |
| | | BigDecimal invoiceNum = BigDecimal.ZERO; |
| | | BigDecimal invoiceAmount = BigDecimal.ZERO; |
| | | BigDecimal noInvoiceNum = BigDecimal.ZERO; |
| | | BigDecimal noInvoiceAmount = BigDecimal.ZERO; |
| | | for (InvoiceRegistrationProductDto registrationProductDto : invoiceRegistrationProductDtoList) { |
| | | if (ledgerProduct.getId().intValue() == registrationProductDto.getSalesLedgerProductId()) { |
| | | invoiceNum = invoiceNum.add(registrationProductDto.getInvoiceNum()); |
| | | invoiceAmount = invoiceAmount.add(registrationProductDto.getInvoiceAmount()); |
| | | } |
| | | } |
| | | noInvoiceNum = ledgerProduct.getQuantity().subtract(invoiceNum); |
| | | noInvoiceAmount = ledgerProduct.getTaxInclusiveTotalPrice().subtract(invoiceAmount); |
| | | BigDecimal ledgerQuantity = ledgerProduct.getQuantity() == null ? BigDecimal.ZERO : ledgerProduct.getQuantity(); |
| | | BigDecimal ledgerTotalPrice = ledgerProduct.getTaxInclusiveTotalPrice() == null ? BigDecimal.ZERO : ledgerProduct.getTaxInclusiveTotalPrice(); |
| | | ledgerProduct.setInvoiceNum(invoiceNum); |
| | | ledgerProduct.setInvoiceAmount(invoiceAmount); |
| | | ledgerProduct.setNoInvoiceNum(noInvoiceNum); |
| | | ledgerProduct.setNoInvoiceAmount(noInvoiceAmount); |
| | | |
| | | |
| | | ledgerProduct.setNoInvoiceNum(ledgerQuantity.subtract(invoiceNum)); |
| | | ledgerProduct.setNoInvoiceAmount(ledgerTotalPrice.subtract(invoiceAmount)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<Long> productIds = salesLedgerProducts.stream() |
| | | .map(SalesLedgerProduct::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | Map<Long, BigDecimal> returnOrderGroupDtoMap = Collections.emptyMap(); |
| | | if (!CollectionUtils.isEmpty(productIds)) { |
| | | List<SimpleReturnOrderGroupDto> groupListByProductIds = purchaseReturnOrderProductsMapper.getReturnOrderGroupListByProductIds(productIds); |
| | | if (!CollectionUtils.isEmpty(groupListByProductIds)) { |
| | | returnOrderGroupDtoMap = groupListByProductIds.stream() |
| | | .collect(Collectors.toMap(SimpleReturnOrderGroupDto::getSalesLedgerProductId, |
| | | SimpleReturnOrderGroupDto::getSumReturnQuantity, |
| | | BigDecimal::add)); |
| | | } |
| | | } |
| | | |
| | | List<Long> productModelIds = salesLedgerProducts.stream() |
| | | .map(SalesLedgerProduct::getProductModelId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | Map<Long, ProductModel> productModelMap = Collections.emptyMap(); |
| | | if (!CollectionUtils.isEmpty(productModelIds)) { |
| | | List<ProductModel> productModels = productModelMapper.selectBatchIds(productModelIds); |
| | | if (!CollectionUtils.isEmpty(productModels)) { |
| | | productModelMap = productModels.stream() |
| | | .collect(Collectors.toMap(ProductModel::getId, Function.identity())); |
| | | } |
| | | } |
| | | |
| | | Map<Long, BigDecimal> finalReturnOrderGroupDtoMap = returnOrderGroupDtoMap; |
| | | Map<Long, ProductModel> finalProductModelMap = productModelMap; |
| | | salesLedgerProducts.forEach(item -> { |
| | | if (item.getFutureTickets() == null || item.getFutureTickets().compareTo(BigDecimal.ZERO) == 0) { |
| | | item.setFutureTickets(BigDecimal.ZERO); |
| | | } |
| | | if (item.getFutureTicketsAmount() == null || item.getFutureTicketsAmount().compareTo(BigDecimal.ZERO) == 0) { |
| | | item.setFutureTicketsAmount(BigDecimal.ZERO); |
| | | } |
| | | if (item.getApproveStatus() == null || item.getApproveStatus() != 2) { |
| | | Integer hasSufficientStock = item.getHasSufficientStock(); |
| | | if (hasSufficientStock != null && hasSufficientStock == 0) { |
| | | item.setApproveStatus(0); |
| | | } else { |
| | | item.setApproveStatus(1); |
| | | } |
| | | } |
| | | BigDecimal returnQuality = finalReturnOrderGroupDtoMap.getOrDefault(item.getId(), BigDecimal.ZERO); |
| | | item.setReturnQuality(returnQuality); |
| | | BigDecimal quantity = item.getQuantity() == null ? BigDecimal.ZERO : item.getQuantity(); |
| | | item.setAvailableQuality(quantity.subtract(returnQuality)); |
| | | ProductModel productModel = finalProductModelMap.get(item.getProductModelId()); |
| | | if (productModel != null) { |
| | | item.setThickness(productModel.getThickness()); |
| | | } |
| | | }); |
| | | return salesLedgerProducts; |
| | | } |
| | | |