Commit c8eca3c0bd684f70b117cadbc7872700afbde0a5
Merge branch 'master_chujiang_0805' into master_quotation
Showing
1 changed file
with
23 additions
and
12 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| @@ -481,11 +481,20 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -481,11 +481,20 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 481 | if (MapUtils.isEmpty(detailMap)) { | 481 | if (MapUtils.isEmpty(detailMap)) { |
| 482 | throw new DefaultClientException("不存在可以自动发货的数据!"); | 482 | throw new DefaultClientException("不存在可以自动发货的数据!"); |
| 483 | } | 483 | } |
| 484 | + // 汇总:所有客户、所有批次处理完后再统一判断是否提示补充草稿 | ||
| 485 | + boolean overallNeedDraft = false; | ||
| 484 | // todo 如果客户很多,则此处需要优化 | 486 | // todo 如果客户很多,则此处需要优化 |
| 485 | for (Map.Entry<String, List<ShipmentsPlanDetail>> entry : detailMap.entrySet()) { | 487 | for (Map.Entry<String, List<ShipmentsPlanDetail>> entry : detailMap.entrySet()) { |
| 486 | List<ShipmentsPlanDetail> value = entry.getValue(); | 488 | List<ShipmentsPlanDetail> value = entry.getValue(); |
| 487 | List<List<ShipmentsPlanDetail>> batchList = CommonUtil.partition(value, 8); | 489 | List<List<ShipmentsPlanDetail>> batchList = CommonUtil.partition(value, 8); |
| 488 | - handleBatchData(batchList, planId); | 490 | + boolean needDraft = handleBatchData(batchList, planId); |
| 491 | + if (needDraft) { | ||
| 492 | + overallNeedDraft = true; | ||
| 493 | + } | ||
| 494 | + } | ||
| 495 | + // 统一抛出:保证所有客户的草稿都先被创建后再提示补充 | ||
| 496 | + if (overallNeedDraft) { | ||
| 497 | + throw new DefaultClientException("请先补充草稿要车单数据!"); | ||
| 489 | } | 498 | } |
| 490 | } else { | 499 | } else { |
| 491 | List<String> planDetailIds = vo.getPlanDetailIds(); | 500 | List<String> planDetailIds = vo.getPlanDetailIds(); |
| @@ -506,7 +515,10 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -506,7 +515,10 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 506 | } | 515 | } |
| 507 | } | 516 | } |
| 508 | List<List<ShipmentsPlanDetail>> batchList = CommonUtil.partition(detailList, 8); | 517 | List<List<ShipmentsPlanDetail>> batchList = CommonUtil.partition(detailList, 8); |
| 509 | - handleBatchData(batchList, planId); | 518 | + boolean needDraft = handleBatchData(batchList, planId); |
| 519 | + if (needDraft) { | ||
| 520 | + throw new DefaultClientException("请先补充草稿要车单数据!"); | ||
| 521 | + } | ||
| 510 | } | 522 | } |
| 511 | ShipmentsPlan plan = shipmentsPlanService.findById(planId); | 523 | ShipmentsPlan plan = shipmentsPlanService.findById(planId); |
| 512 | if ("IN_PROGRESS".equals(plan.getStatus())) { | 524 | if ("IN_PROGRESS".equals(plan.getStatus())) { |
| @@ -911,10 +923,11 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -911,10 +923,11 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 911 | * 处理批次数据 | 923 | * 处理批次数据 |
| 912 | * | 924 | * |
| 913 | * @param batchList 数据批次 | 925 | * @param batchList 数据批次 |
| 926 | + * @return 是否存在需要补充的草稿(新建或未审核通过) | ||
| 914 | */ | 927 | */ |
| 915 | - private void handleBatchData(List<List<ShipmentsPlanDetail>> batchList, String planId) { | 928 | + private boolean handleBatchData(List<List<ShipmentsPlanDetail>> batchList, String planId) { |
| 916 | if (CollectionUtils.isEmpty(batchList)) { | 929 | if (CollectionUtils.isEmpty(batchList)) { |
| 917 | - return; | 930 | + return false; |
| 918 | } | 931 | } |
| 919 | // 获取发货计划数据 | 932 | // 获取发货计划数据 |
| 920 | ShipmentsPlan plan = shipmentsPlanService.findById(planId); | 933 | ShipmentsPlan plan = shipmentsPlanService.findById(planId); |
| @@ -1068,7 +1081,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -1068,7 +1081,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 1068 | } | 1081 | } |
| 1069 | } | 1082 | } |
| 1070 | // 先检查是否都有审核通过的草稿,再批量新增发货单,否则只生成草稿要车单 | 1083 | // 先检查是否都有审核通过的草稿,再批量新增发货单,否则只生成草稿要车单 |
| 1071 | - generateRequestCarData(orderInfoList, orderIds, plan, quantityMap); | 1084 | + boolean needDraft = generateRequestCarData(orderInfoList, orderIds, plan, quantityMap); |
| 1072 | // todo 后续如果数据量过大,则此处需要优化 | 1085 | // todo 后续如果数据量过大,则此处需要优化 |
| 1073 | batchAdd(shipmentsOrderInfoList); | 1086 | batchAdd(shipmentsOrderInfoList); |
| 1074 | // 生成发货单编号 | 1087 | // 生成发货单编号 |
| @@ -1084,6 +1097,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -1084,6 +1097,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 1084 | shipmentsOrderInfo.setCode(serialNumber); | 1097 | shipmentsOrderInfo.setCode(serialNumber); |
| 1085 | } | 1098 | } |
| 1086 | getBaseMapper().setShipmentOrderCode(shipmentsOrderInfoList); | 1099 | getBaseMapper().setShipmentOrderCode(shipmentsOrderInfoList); |
| 1100 | + return needDraft; | ||
| 1087 | } | 1101 | } |
| 1088 | 1102 | ||
| 1089 | /** | 1103 | /** |
| @@ -1119,8 +1133,9 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -1119,8 +1133,9 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 1119 | * @param orderInfoList 订货单数据集合 | 1133 | * @param orderInfoList 订货单数据集合 |
| 1120 | * @param orderIds 订货单ID集合 | 1134 | * @param orderIds 订货单ID集合 |
| 1121 | * @param plan 发货计划 | 1135 | * @param plan 发货计划 |
| 1136 | + * @return 是否存在需要补充的草稿(新建或未审核通过) | ||
| 1122 | */ | 1137 | */ |
| 1123 | - private void generateRequestCarData(List<PurchaseOrderInfo> orderInfoList, List<String> orderIds, ShipmentsPlan plan | 1138 | + private boolean generateRequestCarData(List<PurchaseOrderInfo> orderInfoList, List<String> orderIds, ShipmentsPlan plan |
| 1124 | , Map<String, BigDecimal> quantityMap) { | 1139 | , Map<String, BigDecimal> quantityMap) { |
| 1125 | // 1. 批量获取已有的草稿要车单 | 1140 | // 1. 批量获取已有的草稿要车单 |
| 1126 | Map<String, DraftRequestCarTicket> draftTicketMap = new HashMap<>(); | 1141 | Map<String, DraftRequestCarTicket> draftTicketMap = new HashMap<>(); |
| @@ -1152,12 +1167,8 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | @@ -1152,12 +1167,8 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr | ||
| 1152 | } | 1167 | } |
| 1153 | } | 1168 | } |
| 1154 | 1169 | ||
| 1155 | - // 【第二阶段:统一校验并返回提示】 | ||
| 1156 | - // 循环结束后,只要生成了新的草稿或有未通过的草稿,就统一抛出异常 | ||
| 1157 | - // 这样既保证了所有草稿都被创建,又实现了已创建数据不回退的效果 | ||
| 1158 | - if (hasNewDraftCreated) { | ||
| 1159 | - throw new DefaultClientException("请先补充草稿要车单数据!"); | ||
| 1160 | - } | 1170 | + // 返回给上层统一处理抛出:避免按客户循环时中途抛出导致后续客户无法生成草稿 |
| 1171 | + return hasNewDraftCreated; | ||
| 1161 | } | 1172 | } |
| 1162 | 1173 | ||
| 1163 | 1174 |