| | |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct); |
| | | if(!CollectionUtils.isEmpty(salesLedgerProducts)){ |
| | | salesLedgerProducts.forEach(item -> { |
| | | // 发货信息 |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | // 发货信息(取最新一条) |
| | | ShippingInfo latestShippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, item.getId()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | .last("limit 1")); |
| | | if(shippingInfo != null){ |
| | | item.setShippingDate(shippingInfo.getShippingDate()); |
| | | item.setShippingCarNumber(shippingInfo.getShippingCarNumber()); |
| | | item.setExpressCompany(shippingInfo.getExpressCompany()); |
| | | item.setExpressNumber(shippingInfo.getExpressNumber()); |
| | | if(latestShippingInfo != null){ |
| | | item.setShippingDate(latestShippingInfo.getShippingDate()); |
| | | item.setExpressCompany(latestShippingInfo.getExpressCompany()); |
| | | item.setExpressNumber(latestShippingInfo.getExpressNumber()); |
| | | } |
| | | // 车牌号:取所有发货记录的车牌号,逗号拼接 |
| | | List<ShippingInfo> allShippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, item.getId()) |
| | | .orderByAsc(ShippingInfo::getCreateTime)); |
| | | if(!CollectionUtils.isEmpty(allShippingInfos)){ |
| | | String carNumbers = allShippingInfos.stream() |
| | | .map(ShippingInfo::getShippingCarNumber) |
| | | .filter(carNo -> carNo != null && !carNo.trim().isEmpty()) |
| | | .distinct() |
| | | .collect(Collectors.joining(",")); |
| | | item.setShippingCarNumber(carNumbers); |
| | | } |
| | | }); |
| | | } |
| | |
| | | ProductionPlan productionPlan = new ProductionPlan(); |
| | | productionPlan.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId()); |
| | | productionPlan.setSalesLedgerProductId(salesLedgerProduct.getId()); |
| | | productionPlan.setMpsNo(generateNextPlanNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")))); |
| | | productionPlan.setMpsNo(generateNextPlanNo(com.ruoyi.common.utils.DateUtils.toLocalDate(salesLedger.getEntryDate()) |
| | | .format(DateTimeFormatter.ofPattern("yyyyMMdd")))); |
| | | productionPlan.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | | productionPlan.setQtyRequired(salesLedgerProduct.getQuantity()); |
| | | productionPlan.setSource("销售"); |