Showing
5 changed files
with
73 additions
and
39 deletions
| ... | ... | @@ -33,6 +33,7 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; |
| 33 | 33 | import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; |
| 34 | 34 | import com.lframework.xingyun.sc.service.shipments.ShipmentsOrderInfoService; |
| 35 | 35 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; |
| 36 | +import com.lframework.xingyun.sc.service.shipments.car.CarRequestPlanService; | |
| 36 | 37 | import com.lframework.xingyun.sc.service.shipments.car.DraftRequestCarTicketService; |
| 37 | 38 | import com.lframework.xingyun.sc.service.statistics.ShipmentDetailStatisticsService; |
| 38 | 39 | import com.lframework.xingyun.sc.utils.CommonUtil; |
| ... | ... | @@ -91,6 +92,8 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
| 91 | 92 | private FundOrderingUnitDetailService fundOrderingUnitDetailService; |
| 92 | 93 | @Resource |
| 93 | 94 | private ShipmentDetailStatisticsService shipmentDetailStatisticsService; |
| 95 | + @Resource | |
| 96 | + private CarRequestPlanService carRequestPlanService; | |
| 94 | 97 | |
| 95 | 98 | |
| 96 | 99 | // 定义状态优先级顺序(从高到低) |
| ... | ... | @@ -793,6 +796,8 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
| 793 | 796 | generateLedgerInfo(shipmentsOrderInfos); |
| 794 | 797 | // 生成发货明细报表数据 |
| 795 | 798 | shipmentDetailStatisticsService.generateStatisticsData(detailIds); |
| 799 | + // 生成要车计划、要车单 | |
| 800 | + generateCarPlanAndTicket(shipmentsOrderInfos); | |
| 796 | 801 | } |
| 797 | 802 | |
| 798 | 803 | @Override |
| ... | ... | @@ -1308,4 +1313,25 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
| 1308 | 1313 | } |
| 1309 | 1314 | dataList.add(data); |
| 1310 | 1315 | } |
| 1316 | + | |
| 1317 | + | |
| 1318 | + /** | |
| 1319 | + * 生成要车计划、要车单 | |
| 1320 | + * | |
| 1321 | + * @param shipmentsOrderInfoList 发货单数据 | |
| 1322 | + */ | |
| 1323 | + private void generateCarPlanAndTicket(List<ShipmentsOrderInfo> shipmentsOrderInfoList) { | |
| 1324 | + if (CollectionUtils.isEmpty(shipmentsOrderInfoList)) { | |
| 1325 | + return; | |
| 1326 | + } | |
| 1327 | + for (ShipmentsOrderInfo shipmentsOrderInfo : shipmentsOrderInfoList) { | |
| 1328 | + List<ShipmentsPlanDetail> detailList = shipmentsOrderInfo.getDetailList(); | |
| 1329 | + if (CollectionUtils.isEmpty(detailList)) { | |
| 1330 | + continue; | |
| 1331 | + } | |
| 1332 | + List<String> orderIds = detailList.stream().map(ShipmentsPlanDetail::getOrderId).distinct().collect(Collectors.toList()); | |
| 1333 | + List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds); | |
| 1334 | + carRequestPlanService.generate(orderInfoList, shipmentsOrderInfo); | |
| 1335 | + } | |
| 1336 | + } | |
| 1311 | 1337 | } | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| ... | ... | @@ -48,6 +48,7 @@ import org.apache.commons.collections4.CollectionUtils; |
| 48 | 48 | import org.apache.commons.collections4.MapUtils; |
| 49 | 49 | import org.apache.commons.lang3.BooleanUtils; |
| 50 | 50 | import org.apache.commons.lang3.StringUtils; |
| 51 | +import org.springframework.data.redis.core.RedisTemplate; | |
| 51 | 52 | import org.springframework.transaction.annotation.Transactional; |
| 52 | 53 | import com.lframework.xingyun.sc.mappers.ShipmentsOrderInfoMapper; |
| 53 | 54 | import com.lframework.xingyun.sc.service.shipments.ShipmentsOrderInfoService; |
| ... | ... | @@ -55,11 +56,14 @@ import org.springframework.stereotype.Service; |
| 55 | 56 | |
| 56 | 57 | import javax.annotation.Resource; |
| 57 | 58 | import java.math.BigDecimal; |
| 59 | +import java.time.Duration; | |
| 58 | 60 | import java.time.LocalDate; |
| 59 | 61 | import java.time.LocalDateTime; |
| 60 | 62 | import java.time.LocalTime; |
| 63 | +import java.time.format.DateTimeFormatter; | |
| 61 | 64 | import java.time.temporal.TemporalAdjusters; |
| 62 | 65 | import java.util.*; |
| 66 | +import java.util.concurrent.TimeUnit; | |
| 63 | 67 | import java.util.function.Function; |
| 64 | 68 | import java.util.stream.Collectors; |
| 65 | 69 | |
| ... | ... | @@ -103,6 +107,8 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 103 | 107 | private SampleResultFeedbackService sampleResultFeedbackService; |
| 104 | 108 | @Resource |
| 105 | 109 | private ShipmentDetailStatisticsService shipmentDetailStatisticsService; |
| 110 | + @Resource | |
| 111 | + private RedisTemplate redisTemplate; | |
| 106 | 112 | |
| 107 | 113 | |
| 108 | 114 | @Override |
| ... | ... | @@ -681,6 +687,29 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 681 | 687 | return shipmentsOrderInfos; |
| 682 | 688 | } |
| 683 | 689 | |
| 690 | + @Override | |
| 691 | + public String generateSerialNumber(String pre, String key, String format, LocalDateTime startTime, LocalDateTime endTime) { | |
| 692 | + // 获取当前时间,并做格式化处理 | |
| 693 | + String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern(format)); | |
| 694 | + // Redis自增序列 | |
| 695 | + Long id = redisTemplate.opsForValue().increment(key, 1); | |
| 696 | + if (id != null && id == 1) { | |
| 697 | + // 计算时间差(秒) | |
| 698 | + long secondsUntilMidnight = Duration.between(startTime, endTime).getSeconds(); | |
| 699 | + redisTemplate.expire(key, secondsUntilMidnight, TimeUnit.SECONDS); | |
| 700 | + } | |
| 701 | + // 补零到4位 | |
| 702 | + String incrPart = String.format("%04d", id); | |
| 703 | + // 拼接最终结果 | |
| 704 | + String result = ""; | |
| 705 | + if (StringUtils.isBlank(pre)) { | |
| 706 | + result = datePart + incrPart; | |
| 707 | + } else { | |
| 708 | + result = pre + datePart + incrPart; | |
| 709 | + } | |
| 710 | + return result; | |
| 711 | + } | |
| 712 | + | |
| 684 | 713 | |
| 685 | 714 | /** |
| 686 | 715 | * 处理批次数据 |
| ... | ... | @@ -795,7 +824,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 795 | 824 | .withHour(23) |
| 796 | 825 | .withMinute(59) |
| 797 | 826 | .withSecond(59); |
| 798 | - String serialNumber = CommonUtil.generateSerialNumber(null, "", "yyMM", LocalDateTime.now(), monthEnd); | |
| 827 | + String serialNumber = generateSerialNumber(null, "", "yyMM", LocalDateTime.now(), monthEnd); | |
| 799 | 828 | shipmentsOrderInfo.setCode(serialNumber); |
| 800 | 829 | shipmentsOrderInfo.setPlanId(planId); |
| 801 | 830 | shipmentsOrderInfo.setCustomerId(customerId); | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/car/CarRequestPlanServiceImpl.java
| ... | ... | @@ -196,6 +196,10 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM |
| 196 | 196 | ticketVo.setReturnPlanArrangement(draftTicket.getReturnPlanArrangement()); |
| 197 | 197 | ticketVo.setOther(draftTicket.getOther()); |
| 198 | 198 | ticketVo.setSpecialLoadingRequirement(draftTicket.getSpecialLoadingRequirement()); |
| 199 | + List<ShipmentsPlanDetail> detailList = shipmentsOrderInfo.getDetailList(); | |
| 200 | + if (CollectionUtil.isEmpty(detailList)) { | |
| 201 | + continue; | |
| 202 | + } | |
| 199 | 203 | // 装货时间处理 |
| 200 | 204 | LocalTime minTime = shipmentsOrderInfo.getDetailList().stream() |
| 201 | 205 | .map(ShipmentsPlanDetail::getShipmentsTime) | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ import com.lframework.starter.web.core.service.BaseMpService; |
| 6 | 6 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 7 | 7 | |
| 8 | 8 | import java.time.LocalDate; |
| 9 | +import java.time.LocalDateTime; | |
| 9 | 10 | import java.util.List; |
| 10 | 11 | import java.util.Map; |
| 11 | 12 | |
| ... | ... | @@ -126,4 +127,16 @@ public interface ShipmentsOrderInfoService extends BaseMpService<ShipmentsOrderI |
| 126 | 127 | * @return List<ShipmentsOrderInfo> |
| 127 | 128 | */ |
| 128 | 129 | List<ShipmentsOrderInfo> queryByShipmentDate(LocalDate shipmentDate); |
| 130 | + | |
| 131 | + /** | |
| 132 | + * 生成流水号 | |
| 133 | + * | |
| 134 | + * @param pre 流水号前缀 | |
| 135 | + * @param key 缓存key | |
| 136 | + * @param format 时间格式 | |
| 137 | + * @param startTime 缓存开始时间 | |
| 138 | + * @param endTime 缓存到期时间 | |
| 139 | + * @return String | |
| 140 | + */ | |
| 141 | + String generateSerialNumber(String pre, String key, String format, LocalDateTime startTime, LocalDateTime endTime); | |
| 129 | 142 | } | ... | ... |
| 1 | 1 | package com.lframework.xingyun.sc.utils; |
| 2 | 2 | |
| 3 | 3 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 4 | -import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 5 | 4 | import lombok.extern.slf4j.Slf4j; |
| 6 | 5 | import org.apache.commons.collections4.CollectionUtils; |
| 7 | -import org.apache.commons.lang3.StringUtils; | |
| 8 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 9 | 6 | |
| 10 | 7 | import java.io.*; |
| 11 | 8 | import java.math.BigDecimal; |
| ... | ... | @@ -15,7 +12,6 @@ import java.time.format.DateTimeFormatter; |
| 15 | 12 | import java.util.ArrayList; |
| 16 | 13 | import java.util.Collections; |
| 17 | 14 | import java.util.List; |
| 18 | -import java.util.concurrent.TimeUnit; | |
| 19 | 15 | |
| 20 | 16 | @Slf4j |
| 21 | 17 | public class CommonUtil { |
| ... | ... | @@ -170,38 +166,4 @@ public class CommonUtil { |
| 170 | 166 | } |
| 171 | 167 | return String.valueOf(num); |
| 172 | 168 | } |
| 173 | - | |
| 174 | - | |
| 175 | - /** | |
| 176 | - * 生成流水号 | |
| 177 | - * | |
| 178 | - * @param pre 流水号前缀 | |
| 179 | - * @param key 缓存key | |
| 180 | - * @param format 时间格式 | |
| 181 | - * @param startTime 缓存开始时间 | |
| 182 | - * @param endTime 缓存到期时间 | |
| 183 | - * @return String | |
| 184 | - */ | |
| 185 | - public static String generateSerialNumber(String pre, String key, String format, LocalDateTime startTime, LocalDateTime endTime) { | |
| 186 | - // 1. 获取当前时间,并做格式化处理 | |
| 187 | - String datePart = LocalDate.now().format(DateTimeFormatter.ofPattern(format)); | |
| 188 | - // 2. Redis自增序列 | |
| 189 | - RedisTemplate redisTemplate = ApplicationUtil.getBean(RedisTemplate.class); | |
| 190 | - Long id = redisTemplate.opsForValue().increment(key, 1); | |
| 191 | - if (id != null && id == 1) { | |
| 192 | - // 计算时间差(秒) | |
| 193 | - long secondsUntilMidnight = Duration.between(startTime, endTime).getSeconds(); | |
| 194 | - redisTemplate.expire(key, secondsUntilMidnight, TimeUnit.SECONDS); | |
| 195 | - } | |
| 196 | - // 3. 补零到4位 | |
| 197 | - String incrPart = String.format("%04d", id); | |
| 198 | - // 4. 拼接最终结果 | |
| 199 | - String result = ""; | |
| 200 | - if (StringUtils.isBlank(pre)) { | |
| 201 | - result = datePart + incrPart; | |
| 202 | - } else { | |
| 203 | - result = pre + datePart + incrPart; | |
| 204 | - } | |
| 205 | - return result; | |
| 206 | - } | |
| 207 | 169 | } | ... | ... |