| | |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.CustomerRegions; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.ICustomerRegionsService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.SaleEnum; |
| | |
| | | productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId()); |
| | | productWrapper.eq(SalesLedgerProduct::getType, 1); |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper); |
| | | Map<Long, ProductModel> productModelMap = Collections.emptyMap(); |
| | | if (CollectionUtils.isNotEmpty(products)) { |
| | | List<Long> productModelIds = products.stream() |
| | | .map(SalesLedgerProduct::getProductModelId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(productModelIds)) { |
| | | List<ProductModel> productModels = productModelMapper.selectBatchIds(productModelIds); |
| | | if (CollectionUtils.isNotEmpty(productModels)) { |
| | | productModelMap = productModels.stream().collect(Collectors.toMap(ProductModel::getId, Function.identity())); |
| | | } |
| | | } |
| | | } |
| | | for (SalesLedgerProduct product : products) { |
| | | product.setOriginalNoInvoiceNum(product.getNoInvoiceNum()); |
| | | // 提供临时未开票数,未开票金额供前段计算 |
| | |
| | | List<SalesLedgerProductProcess> processList = salesLedgerProductProcessService.listByIds(processIds); |
| | | processList.forEach(p -> p.setQuantity(processQuantityMap.get(p.getId()))); |
| | | product.setSalesProductProcessList(processList); |
| | | } |
| | | ProductModel productModel = productModelMap.get(product.getProductModelId()); |
| | | if (productModel != null) { |
| | | product.setThickness(productModel.getThickness()); |
| | | } |
| | | if (product.getWidth() != null && product.getHeight() != null) { |
| | | BigDecimal pieceArea = product.getWidth().multiply(product.getHeight()).divide(new BigDecimal(1000000), 2, RoundingMode.HALF_UP); |
| | | if (product.getActualPieceArea() == null) { |
| | | product.setActualPieceArea(pieceArea); |
| | | } |
| | | BigDecimal quantity = product.getQuantity() == null ? BigDecimal.ZERO : product.getQuantity(); |
| | | if (product.getActualTotalArea() == null) { |
| | | product.setActualTotalArea(pieceArea.multiply(quantity).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | salesLedger.setContractAmount(salesLedgerProductImportDtos.stream() |
| | | .map(SalesLedgerProductImportDto::getTaxInclusiveTotalPrice) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | // 发货状态 |
| | | salesLedger.setDeliveryStatus(0); |
| | | salesLedgerMapper.insert(salesLedger); |
| | | |
| | | for (SalesLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) { |
| | |
| | | if (salesLedger.getId() == null) { |
| | | String contractNo = generateSalesContractNo(); |
| | | salesLedger.setSalesContractNo(contractNo); |
| | | salesLedger.setDeliveryStatus(0); |
| | | salesLedgerMapper.insert(salesLedger); |
| | | } else { |
| | | if (salesLedger.getDeliveryStatus() == 1) { |
| | | throw new ServiceException("订单已发货,禁止编辑"); |
| | | } |
| | | salesLedgerMapper.updateById(salesLedger); |
| | | } |
| | | |
| | |
| | | // 清空销售产品绑定的加工 |
| | | salesLedgerProductProcessBindService.updateProductProcessBind(salesLedgerProduct.getSalesProductProcessList(), salesLedgerProduct.getId()); |
| | | // 添加生产数据 |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | // salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | } |
| | | } |
| | | } |