|
|
|
@ -708,13 +708,20 @@ public class NewIssureServiceImpl implements NewIssureService { |
|
|
|
(item.getOrderSatisfactionStatus() == 1 || item.getOrderSatisfactionStatus() == 2)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 2. 获取传入的原始订单总数(按生产订单分组统计)- rqrq |
|
|
|
int originalOrderCount = (int) data.getInventoryList().stream() |
|
|
|
.map(InventoryCheckResult::getProductionOrderNo) |
|
|
|
.distinct() |
|
|
|
.count(); |
|
|
|
System.out.println("前端传入的订单总数:" + originalOrderCount + " - rqrq"); |
|
|
|
|
|
|
|
System.out.println("筛选后满足库存要求的数据:" + validList.size() + "条 - rqrq"); |
|
|
|
|
|
|
|
if (validList.isEmpty()) { |
|
|
|
throw new RuntimeException("没有满足库存要求的订单数据"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 提取所有条码(序列号) - rqrq |
|
|
|
// 3. 提取所有条码(序列号) - rqrq |
|
|
|
List<String> allSerialNos = new ArrayList<>(); |
|
|
|
for (InventoryCheckResult item : validList) { |
|
|
|
String matchedBarcodes = item.getMatchedBarcodes(); |
|
|
|
@ -729,14 +736,14 @@ public class NewIssureServiceImpl implements NewIssureService { |
|
|
|
|
|
|
|
System.out.println("提取到条码总数:" + allSerialNos.size() + " - rqrq"); |
|
|
|
|
|
|
|
// 3. 前置校验:检查reserve_flag - rqrq |
|
|
|
// 4. 前置校验:检查reserve_flag - rqrq |
|
|
|
List<String> reservedUnits = newIssureMapper.checkReserveFlagBySerialNos(site, allSerialNos); |
|
|
|
if (reservedUnits != null && !reservedUnits.isEmpty()) { |
|
|
|
if (!reservedUnits.isEmpty()) { |
|
|
|
throw new RuntimeException("已经有物料被其他任务领走,请重新打开推送界面计算库存。"); |
|
|
|
} |
|
|
|
System.out.println("reserve_flag校验通过 - rqrq"); |
|
|
|
|
|
|
|
// 4. 前置校验:查询栈板并检查calling_flag - rqrq |
|
|
|
// 5. 前置校验:查询栈板并检查calling_flag - rqrq |
|
|
|
List<String> palletIds = newIssureMapper.getPalletIdsBySerialNos(site, allSerialNos); |
|
|
|
if (palletIds == null || palletIds.isEmpty()) { |
|
|
|
throw new RuntimeException("未找到条码对应的栈板信息"); |
|
|
|
@ -744,22 +751,22 @@ public class NewIssureServiceImpl implements NewIssureService { |
|
|
|
System.out.println("找到栈板数量:" + palletIds.size() + " - rqrq"); |
|
|
|
|
|
|
|
List<String> callingPallets = newIssureMapper.checkCallingFlagByPalletIds(site, palletIds); |
|
|
|
if (callingPallets != null && !callingPallets.isEmpty()) { |
|
|
|
throw new RuntimeException("已经有物料被其他任务领走,请重新打开推送界面计算库存。"); |
|
|
|
if ( !callingPallets.isEmpty()) { |
|
|
|
throw new RuntimeException("已经有栈板被其他任务领走,请重新打开推送界面计算库存。"); |
|
|
|
} |
|
|
|
System.out.println("calling_flag校验通过 - rqrq"); |
|
|
|
|
|
|
|
// 5. 按ProductionOrderNo分组 - rqrq |
|
|
|
// 6. 按ProductionOrderNo分组 - rqrq |
|
|
|
Map<String, List<InventoryCheckResult>> groupedByOrder = validList.stream() |
|
|
|
.collect(Collectors.groupingBy(InventoryCheckResult::getProductionOrderNo)); |
|
|
|
|
|
|
|
int totalOrdersToProcess = groupedByOrder.size(); |
|
|
|
System.out.println("按生产订单分组,本次要推送" + totalOrdersToProcess + "个订单 - rqrq"); |
|
|
|
int validOrderCount = groupedByOrder.size(); |
|
|
|
System.out.println("按生产订单分组,满足条件的订单数:" + validOrderCount + "个 - rqrq"); |
|
|
|
|
|
|
|
Date currentTime = new Date(); |
|
|
|
int successCount = 0; // 统计成功推送的订单数 - rqrq |
|
|
|
|
|
|
|
// 6. 遍历每个生产订单 - rqrq |
|
|
|
// 7. 遍历每个生产订单 - rqrq |
|
|
|
for (Map.Entry<String, List<InventoryCheckResult>> entry : groupedByOrder.entrySet()) { |
|
|
|
String productionOrderNo = entry.getKey(); |
|
|
|
List<InventoryCheckResult> orderItems = entry.getValue(); |
|
|
|
@ -1003,12 +1010,22 @@ public class NewIssureServiceImpl implements NewIssureService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 7. 判断推送状态并更新SOIssueNotifyHeader的push_wcs_flag - rqrq |
|
|
|
String pushWcsFlag = (successCount == totalOrdersToProcess) ? "推送完成" : "部分推送"; |
|
|
|
System.out.println("推送结果统计:本次要推送" + totalOrdersToProcess + "个订单,成功推送" + successCount + "个订单 - rqrq"); |
|
|
|
// 8. 判断推送状态并更新SOIssueNotifyHeader的push_wcs_flag - rqrq |
|
|
|
// 判断逻辑: |
|
|
|
// - 如果一条都没成功(successCount == 0):不改变状态 |
|
|
|
// - 如果全部推送成功(successCount == originalOrderCount):推送完成 |
|
|
|
// - 如果部分成功(0 < successCount < originalOrderCount):部分推送 |
|
|
|
if (successCount == 0) { |
|
|
|
// 一条都没成功,不改变push_wcs_flag状态 - rqrq |
|
|
|
System.out.println("推送结果:传入" + originalOrderCount + "个订单,成功0个,不改变推送状态 - rqrq"); |
|
|
|
} else { |
|
|
|
// 使用原始订单总数判断,而不是过滤后的订单数 - rqrq |
|
|
|
String pushWcsFlag = (successCount == originalOrderCount) ? "推送完成" : "部分推送"; |
|
|
|
System.out.println("推送结果统计:传入" + originalOrderCount + "个订单,满足条件" + validOrderCount + "个,成功推送" + successCount + "个,最终状态=" + pushWcsFlag + " - rqrq"); |
|
|
|
|
|
|
|
newIssureMapper.updateNotifyHeaderPushWcsFlag(site, notifyNo, pushWcsFlag); |
|
|
|
System.out.println("更新申请单push_wcs_flag=" + pushWcsFlag + " - rqrq"); |
|
|
|
newIssureMapper.updateNotifyHeaderPushWcsFlag(site, notifyNo, pushWcsFlag); |
|
|
|
System.out.println("更新申请单push_wcs_flag=" + pushWcsFlag + " - rqrq"); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("推送库存预览数据至WCS完成 - rqrq"); |
|
|
|
} |
|
|
|
|