Commit 351c6f6410177790cbf790e6a4a7237742c797ec
Merge branch 'master_chujiang_0805' into master_quotation
Showing
2 changed files
with
29 additions
and
16 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| @@ -960,6 +960,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -960,6 +960,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 960 | .collect(Collectors.toList()); | 960 | .collect(Collectors.toList()); |
| 961 | List<PurchaseOrderInfo> batchOrderInfoList = purchaseOrderInfoService.queryByIds(batchOrderIds); | 961 | List<PurchaseOrderInfo> batchOrderInfoList = purchaseOrderInfoService.queryByIds(batchOrderIds); |
| 962 | List<String> detailIds = new ArrayList<>(); | 962 | List<String> detailIds = new ArrayList<>(); |
| 963 | + List<ShipmentsPlanDetail> shipmentsPlanDetails = new ArrayList<>(); | ||
| 963 | String id = IdUtil.getId(); | 964 | String id = IdUtil.getId(); |
| 964 | String customerId = details.get(0).getCustomerId(); | 965 | String customerId = details.get(0).getCustomerId(); |
| 965 | StringBuilder deliveryTypeBuilder = new StringBuilder(); | 966 | StringBuilder deliveryTypeBuilder = new StringBuilder(); |
| @@ -974,6 +975,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -974,6 +975,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 974 | } | 975 | } |
| 975 | detail.setShipmentOrderId(id); | 976 | detail.setShipmentOrderId(id); |
| 976 | detailIds.add(detail.getId()); | 977 | detailIds.add(detail.getId()); |
| 978 | + shipmentsPlanDetails.add(detail); | ||
| 977 | 979 | ||
| 978 | PurchaseOrderInfo orderInfo = orderInfoMap.get(detail.getOrderId()); | 980 | PurchaseOrderInfo orderInfo = orderInfoMap.get(detail.getOrderId()); |
| 979 | if (orderInfo == null) { | 981 | if (orderInfo == null) { |
| @@ -1062,6 +1064,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -1062,6 +1064,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 1062 | // 更新明细数据 | 1064 | // 更新明细数据 |
| 1063 | if (allApproved) { | 1065 | if (allApproved) { |
| 1064 | shipmentsPlanDetailService.setShipmentsOrderId(detailIds, id); | 1066 | shipmentsPlanDetailService.setShipmentsOrderId(detailIds, id); |
| 1067 | + shipmentsOrderInfo.setDetailList(shipmentsPlanDetails); | ||
| 1065 | //生成要车单和要车计划 | 1068 | //生成要车单和要车计划 |
| 1066 | carRequestPlanService.generate(batchOrderInfoList, shipmentsOrderInfo); | 1069 | carRequestPlanService.generate(batchOrderInfoList, shipmentsOrderInfo); |
| 1067 | } | 1070 | } |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/car/CarRequestPlanServiceImpl.java
| @@ -18,6 +18,7 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog; | @@ -18,6 +18,7 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog; | ||
| 18 | import com.lframework.starter.web.core.utils.PageHelperUtil; | 18 | import com.lframework.starter.web.core.utils.PageHelperUtil; |
| 19 | import com.lframework.starter.common.utils.Assert; | 19 | import com.lframework.starter.common.utils.Assert; |
| 20 | import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | 20 | import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; |
| 21 | +import lombok.extern.slf4j.Slf4j; | ||
| 21 | import com.lframework.xingyun.sc.entity.*; | 22 | import com.lframework.xingyun.sc.entity.*; |
| 22 | import com.lframework.xingyun.sc.mappers.CarRequestPlanMapper; | 23 | import com.lframework.xingyun.sc.mappers.CarRequestPlanMapper; |
| 23 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; | 24 | import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService; |
| @@ -40,6 +41,7 @@ import java.util.function.Function; | @@ -40,6 +41,7 @@ import java.util.function.Function; | ||
| 40 | import java.util.stream.Collectors; | 41 | import java.util.stream.Collectors; |
| 41 | 42 | ||
| 42 | @Service | 43 | @Service |
| 44 | +@Slf4j | ||
| 43 | public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanMapper, CarRequestPlan> implements CarRequestPlanService { | 45 | public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanMapper, CarRequestPlan> implements CarRequestPlanService { |
| 44 | @Resource | 46 | @Resource |
| 45 | private RequestCarTicketService requestCarTicketService; | 47 | private RequestCarTicketService requestCarTicketService; |
| @@ -171,8 +173,10 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | @@ -171,8 +173,10 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | ||
| 171 | @Transactional(rollbackFor = Exception.class) | 173 | @Transactional(rollbackFor = Exception.class) |
| 172 | public void generate(List<PurchaseOrderInfo> orderInfoList, ShipmentsOrderInfo shipmentsOrderInfo) { | 174 | public void generate(List<PurchaseOrderInfo> orderInfoList, ShipmentsOrderInfo shipmentsOrderInfo) { |
| 173 | if (CollectionUtils.isEmpty(orderInfoList) || shipmentsOrderInfo == null) { | 175 | if (CollectionUtils.isEmpty(orderInfoList) || shipmentsOrderInfo == null) { |
| 176 | + log.warn("[CarRequestPlan.generate] 跳过生成:orderInfoList={}, shipmentsOrderInfo={}", CollectionUtils.isEmpty(orderInfoList), shipmentsOrderInfo); | ||
| 174 | return; | 177 | return; |
| 175 | } | 178 | } |
| 179 | + log.info("[CarRequestPlan.generate] 开始生成,发货单ID={},订单数={}", shipmentsOrderInfo.getId(), orderInfoList.size()); | ||
| 176 | List<String> orderIds = orderInfoList.stream().map(PurchaseOrderInfo::getId).collect(Collectors.toList()); | 180 | List<String> orderIds = orderInfoList.stream().map(PurchaseOrderInfo::getId).collect(Collectors.toList()); |
| 177 | // 根据订货单获取草稿要车单 | 181 | // 根据订货单获取草稿要车单 |
| 178 | List<DraftRequestCarTicket> draftTickets = draftRequestCarTicketService.listByOrderId(orderIds); | 182 | List<DraftRequestCarTicket> draftTickets = draftRequestCarTicketService.listByOrderId(orderIds); |
| @@ -183,6 +187,10 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | @@ -183,6 +187,10 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | ||
| 183 | if (StringUtil.isNotBlank(shipmentsOrderInfo.getPlanId())) { | 187 | if (StringUtil.isNotBlank(shipmentsOrderInfo.getPlanId())) { |
| 184 | shipmentsPlan = shipmentsPlanService.findById(shipmentsOrderInfo.getPlanId()); | 188 | shipmentsPlan = shipmentsPlanService.findById(shipmentsOrderInfo.getPlanId()); |
| 185 | } | 189 | } |
| 190 | + List<ShipmentsPlanDetail> detailList = shipmentsOrderInfo.getDetailList(); | ||
| 191 | + if (CollectionUtils.isEmpty(detailList)) { | ||
| 192 | + log.warn("[CarRequestPlan.generate] 发货单 {} 的detailList为空,无法计算吨位/装货时间,跳过生成要车单", shipmentsOrderInfo.getId()); | ||
| 193 | + } | ||
| 186 | for (PurchaseOrderInfo orderInfo : orderInfoList) { | 194 | for (PurchaseOrderInfo orderInfo : orderInfoList) { |
| 187 | // 生成要车计划 | 195 | // 生成要车计划 |
| 188 | LocalDate requestCarDate = shipmentsOrderInfo.getShipmentsDate(); | 196 | LocalDate requestCarDate = shipmentsOrderInfo.getShipmentsDate(); |
| @@ -193,9 +201,11 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | @@ -193,9 +201,11 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | ||
| 193 | planCreateVo.setRequestCarDate(requestCarDate); | 201 | planCreateVo.setRequestCarDate(requestCarDate); |
| 194 | planCreateVo.setWorkshopId(orderInfo.getWorkshopId()); | 202 | planCreateVo.setWorkshopId(orderInfo.getWorkshopId()); |
| 195 | String requestCarPlanId = create(planCreateVo); | 203 | String requestCarPlanId = create(planCreateVo); |
| 204 | + log.info("[CarRequestPlan.generate] 已生成/复用要车计划ID={},订单ID={}", requestCarPlanId, orderInfo.getId()); | ||
| 196 | // 生成要车单 | 205 | // 生成要车单 |
| 197 | DraftRequestCarTicket draftTicket = draftTicketMap.get(orderInfo.getId()); | 206 | DraftRequestCarTicket draftTicket = draftTicketMap.get(orderInfo.getId()); |
| 198 | if (draftTicket == null) { | 207 | if (draftTicket == null) { |
| 208 | + log.warn("[CarRequestPlan.generate] 订单ID={} 缺少草稿要车单,抛异常回滚", orderInfo.getId()); | ||
| 199 | throw new DefaultClientException("请先补充草稿要车单数据!"); | 209 | throw new DefaultClientException("请先补充草稿要车单数据!"); |
| 200 | } | 210 | } |
| 201 | CreateRequestCarTicketVo ticketVo = new CreateRequestCarTicketVo(); | 211 | CreateRequestCarTicketVo ticketVo = new CreateRequestCarTicketVo(); |
| @@ -219,31 +229,31 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | @@ -219,31 +229,31 @@ public class CarRequestPlanServiceImpl extends BaseMpServiceImpl<CarRequestPlanM | ||
| 219 | ticketVo.setReturnPlanArrangement(draftTicket.getReturnPlanArrangement()); | 229 | ticketVo.setReturnPlanArrangement(draftTicket.getReturnPlanArrangement()); |
| 220 | ticketVo.setOther(draftTicket.getOther()); | 230 | ticketVo.setOther(draftTicket.getOther()); |
| 221 | ticketVo.setSpecialLoadingRequirement(draftTicket.getSpecialLoadingRequirement()); | 231 | ticketVo.setSpecialLoadingRequirement(draftTicket.getSpecialLoadingRequirement()); |
| 222 | - List<ShipmentsPlanDetail> detailList = shipmentsOrderInfo.getDetailList(); | ||
| 223 | - if (CollectionUtil.isEmpty(detailList)) { | ||
| 224 | - continue; | ||
| 225 | - } | ||
| 226 | // 计划吨位 | 232 | // 计划吨位 |
| 227 | BigDecimal totalQuantity = BigDecimal.ZERO; | 233 | BigDecimal totalQuantity = BigDecimal.ZERO; |
| 228 | - for (ShipmentsPlanDetail detail : detailList) { | ||
| 229 | - BigDecimal quantity = detail.getQuantity(); | ||
| 230 | - if (quantity == null || !orderInfo.getId().equals(detail.getOrderId())) { | ||
| 231 | - continue; | 234 | + LocalTime minTime = null; |
| 235 | + if (CollectionUtils.isNotEmpty(detailList)) { | ||
| 236 | + for (ShipmentsPlanDetail detail : detailList) { | ||
| 237 | + BigDecimal quantity = detail.getQuantity(); | ||
| 238 | + if (orderInfo.getId().equals(detail.getOrderId()) && quantity != null) { | ||
| 239 | + totalQuantity = totalQuantity.add(quantity); | ||
| 240 | + } | ||
| 241 | + if (detail.getShipmentsTime() != null) { | ||
| 242 | + if (minTime == null || detail.getShipmentsTime().isBefore(minTime)) { | ||
| 243 | + minTime = detail.getShipmentsTime(); | ||
| 244 | + } | ||
| 245 | + } | ||
| 232 | } | 246 | } |
| 233 | - totalQuantity = totalQuantity.add(quantity); | ||
| 234 | } | 247 | } |
| 235 | ticketVo.setQuantity(totalQuantity); | 248 | ticketVo.setQuantity(totalQuantity); |
| 236 | // 装货时间处理 | 249 | // 装货时间处理 |
| 237 | - LocalTime minTime = shipmentsOrderInfo.getDetailList().stream() | ||
| 238 | - .map(ShipmentsPlanDetail::getShipmentsTime) | ||
| 239 | - .min(LocalTime::compareTo) | ||
| 240 | - .orElse(null); | ||
| 241 | - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | ||
| 242 | if (minTime != null) { | 250 | if (minTime != null) { |
| 243 | - String loadingTime = minTime.format(formatter); | 251 | + String loadingTime = minTime.format(DateTimeFormatter.ofPattern("HH:mm")); |
| 244 | ticketVo.setLoadingTime(loadingTime); | 252 | ticketVo.setLoadingTime(loadingTime); |
| 245 | } | 253 | } |
| 246 | - requestCarTicketService.create(ticketVo); | 254 | + log.info("=====开始创建要车单====" + ticketVo); |
| 255 | + String ticketId = requestCarTicketService.create(ticketVo); | ||
| 256 | + log.info("[CarRequestPlan.generate] 已生成要车单ID={},订单ID={},吨位={}", ticketId, orderInfo.getId(), totalQuantity); | ||
| 247 | } | 257 | } |
| 248 | } | 258 | } |
| 249 | 259 |