|
|
|
@ -285,13 +285,13 @@ public class WmsMessageServiceImpl implements WmsMessageService { |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
//3种业务类型 栈板入立库货架 栈板出立库货架 栈板到达出库口待取货 |
|
|
|
//4种业务类型:入库、出库、取货通知、取走栈板 - rqrq |
|
|
|
public String wcsWareHouse(PalletWareHouseData inData) { |
|
|
|
Long logId = null; |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
try { |
|
|
|
// 1. 记录接口调用日志 |
|
|
|
// 1. 记录接口调用日志 - rqrq |
|
|
|
String requestJson = JSONObject.toJSONString(inData); |
|
|
|
logId = interfaceCallLogService.logInterfaceCall( |
|
|
|
"WmsMessageService", |
|
|
|
@ -304,7 +304,56 @@ public class WmsMessageServiceImpl implements WmsMessageService { |
|
|
|
|
|
|
|
log.info("接收立库出入库请求:{}", requestJson); |
|
|
|
|
|
|
|
// 2. 参数验证 |
|
|
|
// 2. 参数验证 - rqrq |
|
|
|
validateWcsWareHouseParams(inData); |
|
|
|
|
|
|
|
// 3. 根据业务类型分别处理 - rqrq |
|
|
|
String result; |
|
|
|
switch (inData.getTransTypeDesc()) { |
|
|
|
case "入库": |
|
|
|
result = processInbound(inData); |
|
|
|
break; |
|
|
|
case "出库": |
|
|
|
result = processOutbound(inData); |
|
|
|
break; |
|
|
|
case "取货通知": |
|
|
|
result = processPickupNotification(inData); |
|
|
|
break; |
|
|
|
case "取走栈板": |
|
|
|
result = processPalletRemoval(inData); |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new RuntimeException("不支持的事务类型:" + inData.getTransTypeDesc()); |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 更新成功日志 - rqrq |
|
|
|
long executionTime = System.currentTimeMillis() - startTime; |
|
|
|
interfaceCallLogService.updateCallResult(logId, result, "SUCCESS", null, executionTime); |
|
|
|
|
|
|
|
log.info("立库出入库接收成功,托盘ID: {}, 类型: {}, 结果: {}", |
|
|
|
inData.getPalletId(), inData.getTransTypeDesc(), result); |
|
|
|
return result; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
// 更新失败日志 - rqrq |
|
|
|
long executionTime = System.currentTimeMillis() - startTime; |
|
|
|
interfaceCallLogService.updateCallResult(logId, null, "ERROR", e.getMessage(), executionTime); |
|
|
|
|
|
|
|
log.error("立库出入库接收失败,托盘ID: {}, 类型: {}, 错误: {}", |
|
|
|
inData != null ? inData.getPalletId() : "unknown", |
|
|
|
inData != null ? inData.getTransTypeDesc() : "unknown", |
|
|
|
e.getMessage(), e); |
|
|
|
throw new RuntimeException("立库出入库处理失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 参数验证 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private void validateWcsWareHouseParams(PalletWareHouseData inData) { |
|
|
|
if (inData == null || !StringUtils.hasText(inData.getPalletId()) || |
|
|
|
!StringUtils.hasText(inData.getTransTypeDesc())) { |
|
|
|
throw new RuntimeException("参数验证失败:托盘ID和事务类型不能为空"); |
|
|
|
@ -312,258 +361,172 @@ public class WmsMessageServiceImpl implements WmsMessageService { |
|
|
|
if (!StringUtils.hasText(inData.getSite())) { |
|
|
|
throw new RuntimeException("参数验证失败:工厂编码不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 确定目标仓库和库位 |
|
|
|
String toWarehouseId; |
|
|
|
String toLocationId; |
|
|
|
/** |
|
|
|
* @Description 处理入库回调 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @return 处理结果 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private String processInbound(PalletWareHouseData inData) { |
|
|
|
log.info("开始处理入库回调 - rqrq,palletId={}, toBarcode={}", |
|
|
|
inData.getPalletId(), inData.getToBarcode()); |
|
|
|
|
|
|
|
if ("入库".equals(inData.getTransTypeDesc())) { |
|
|
|
//入库要改 站点查询 |
|
|
|
// 入库时从入参中获取目标仓库和库位 |
|
|
|
String stationCode=inData.getToBarcode(); |
|
|
|
// 1. 参数验证 - rqrq |
|
|
|
if (!StringUtils.hasText(inData.getToBarcode())) { |
|
|
|
throw new RuntimeException("入库操作时目标货架不能为空"); |
|
|
|
} |
|
|
|
AgvStation station= wcsIntegrationMapper.getStationDataByCode(stationCode); |
|
|
|
|
|
|
|
// 2. 查询站点信息 - rqrq |
|
|
|
AgvStation station = wcsIntegrationMapper.getStationDataByCode(inData.getToBarcode()); |
|
|
|
if (station == null) { |
|
|
|
throw new RuntimeException("入参站点ToBarcode不存在"); |
|
|
|
throw new RuntimeException("入参站点ToBarcode不存在:" + inData.getToBarcode()); |
|
|
|
} |
|
|
|
toWarehouseId = station.getWarehouseCode(); |
|
|
|
toLocationId = station.getLocationCode(); |
|
|
|
|
|
|
|
} else if ("出库".equals(inData.getTransTypeDesc())) { |
|
|
|
// 出库时从缓冲区配置获取 |
|
|
|
toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
toLocationId = BufferZoneConfig.BUFFER_LOCATION_ID.getValue(); |
|
|
|
inData.setToBarcode(BufferZoneConfig.BUFFER_Station_ID.getValue()); |
|
|
|
}else if ("取货通知".equals(inData.getTransTypeDesc())) { |
|
|
|
// 出库时从缓冲区配置获取 |
|
|
|
switch (inData.getToBarcode()) { |
|
|
|
case "1099": |
|
|
|
inData.setToBarcode("D1"); |
|
|
|
break; |
|
|
|
case "1093": |
|
|
|
inData.setToBarcode("D2"); |
|
|
|
break; |
|
|
|
} |
|
|
|
toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
toLocationId = BufferZoneConfig.BUFFER_LOCATION_ID.getValue(); |
|
|
|
}else if ("取走栈板".equals(inData.getTransTypeDesc())) { |
|
|
|
// 出库时从缓冲区配置获取 |
|
|
|
switch (inData.getToBarcode()) { |
|
|
|
case "1099": |
|
|
|
inData.setToBarcode("D1"); |
|
|
|
break; |
|
|
|
case "1093": |
|
|
|
inData.setToBarcode("D2"); |
|
|
|
break; |
|
|
|
} |
|
|
|
if(!inData.getToBarcode().startsWith("D")){ |
|
|
|
throw new RuntimeException("目前只有滚筒对接区(D1/D2)可以执行这个操作!"); |
|
|
|
} |
|
|
|
toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
toLocationId = inData.getToBarcode(); |
|
|
|
wcsIntegrationMapper.updateAgvStationStatus(inData.getToBarcode(), 0, "空闲"); |
|
|
|
} else { |
|
|
|
throw new RuntimeException("不支持的事务类型:" + inData.getTransTypeDesc()); |
|
|
|
} |
|
|
|
// 所有类型都保存到日志表,由定时任务统一处理 - rqrq |
|
|
|
if ("取货通知".equals(inData.getTransTypeDesc()) || "取走栈板".equals(inData.getTransTypeDesc()) || |
|
|
|
"入库".equals(inData.getTransTypeDesc()) || "出库".equals(inData.getTransTypeDesc())) { |
|
|
|
// 4. 保存WCS回调数据到新表,等待定时任务处理 - rqrq |
|
|
|
WcsCallbackTask callbackTask = new WcsCallbackTask(); |
|
|
|
callbackTask.setSite(inData.getSite()); |
|
|
|
callbackTask.setPalletId(inData.getPalletId()); |
|
|
|
callbackTask.setTransTypeDesc(inData.getTransTypeDesc()); |
|
|
|
callbackTask.setToWarehouseId(toWarehouseId); |
|
|
|
callbackTask.setToLocationId(toLocationId); |
|
|
|
callbackTask.setStatus("已录入"); // 等待定时任务处理 |
|
|
|
callbackTask.setCreatedTime(new Date()); |
|
|
|
callbackTask.setRetryCount(0); |
|
|
|
callbackTask.setRemark("WCS立库" + inData.getTransTypeDesc() + "回调"); |
|
|
|
callbackTask.setTaskNo(inData.getTaskNo()); |
|
|
|
callbackTask.setItemNo(inData.getItemNo()); |
|
|
|
callbackTask.setToStation(inData.getToBarcode()); |
|
|
|
String toWarehouseId = station.getWarehouseCode(); |
|
|
|
String toLocationId = station.getLocationCode(); |
|
|
|
|
|
|
|
// 保存到WCS回调任务表 - rqrq |
|
|
|
wcsIntegrationMapper.insertWcsCallbackTask(callbackTask); |
|
|
|
// 3. 保存WCS回调任务到表,等待定时任务处理 - rqrq |
|
|
|
saveWcsCallbackTask(inData, toWarehouseId, toLocationId); |
|
|
|
|
|
|
|
log.info("WCS回调数据已保存:栈板={}, 任务类型={}, 目标位置={}-{}", |
|
|
|
inData.getPalletId(), inData.getTransTypeDesc(), toWarehouseId, toLocationId); |
|
|
|
} |
|
|
|
// 4. 立即更新部分状态(防止没有组盘直接入库的情况)- rqrq |
|
|
|
updateOrderTaskStatusForInboundCallback(inData); |
|
|
|
wcsIntegrationMapper.updatePalletDetailWcsFlag(inData.getSite(), inData.getPalletId()); |
|
|
|
|
|
|
|
// 以下是旧的同步处理逻辑,已移至定时任务处理,保留作为备份参考 - rqrq |
|
|
|
/* |
|
|
|
//单独call料栈板到达出库口 直接转移站点然后更新任务就行 |
|
|
|
if ("取货通知".equals(inData.getTransTypeDesc())) { |
|
|
|
updateOrderTaskStatusForQuHuo(inData); |
|
|
|
wcsIntegrationMapper.updatePalletCallingFlag(inData.getSite(), inData.getPalletId(), "N", "SYS_WMS"); |
|
|
|
wcsIntegrationMapper.updateAgvStationStatus(inData.getToBarcode(), 1, "有货"); |
|
|
|
// 2. 查询托盘当前位置信息 - rqrq(改用手写SQL避免锁表) |
|
|
|
Pallet pallet = palletMapper.selectPalletBySiteAndPalletId(inData.getSite(), inData.getPalletId()); |
|
|
|
log.info("入库回调处理完成 - rqrq,palletId={}, 已保存回调任务并更新pallet_detail的wcs_flag", |
|
|
|
inData.getPalletId()); |
|
|
|
|
|
|
|
if (pallet == null) { |
|
|
|
throw new RuntimeException("托盘不存在:" + inData.getPalletId()); |
|
|
|
return "入库回调数据已保存,等待定时任务处理"; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新托盘位置和调用标志 - rqrq |
|
|
|
log.info("取货通知-更新托盘信息前 - rqrq,托盘ID: {}, 主键ID: {}, 当前位置: {}, 当前调用标志: {}, 目标位置: {}", |
|
|
|
pallet.getPalletId(), pallet.getId(), pallet.getLocationCode(), pallet.getCallingFlag(), inData.getToBarcode()); |
|
|
|
/** |
|
|
|
* @Description 处理出库回调 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @return 处理结果 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private String processOutbound(PalletWareHouseData inData) { |
|
|
|
log.info("开始处理出库回调 - rqrq,palletId={}", inData.getPalletId()); |
|
|
|
|
|
|
|
pallet.setLocationCode(inData.getToBarcode()); |
|
|
|
pallet.setCallingFlag("N"); |
|
|
|
// boolean updateResult = palletService.updateById(pallet); |
|
|
|
palletMapper.updateLocationWithPalletId(pallet.getSite(),pallet.getPalletId(),pallet.getLocationCode(),null); |
|
|
|
// 1. 设置目标位置为缓冲区 - rqrq |
|
|
|
String toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
String toLocationId = BufferZoneConfig.BUFFER_LOCATION_ID.getValue(); |
|
|
|
inData.setToBarcode(BufferZoneConfig.BUFFER_Station_ID.getValue()); |
|
|
|
|
|
|
|
// log.info("取货通知-更新托盘信息完成 - rqrq,托盘ID: {}, 主键ID: {}, 更新结果: {}, 新位置: {}, 新调用标志: N", |
|
|
|
// pallet.getPalletId(), pallet.getId(), updateResult ? "成功" : "失败", inData.getToBarcode()); |
|
|
|
// |
|
|
|
// if (!updateResult) { |
|
|
|
// throw new RuntimeException("更新托盘信息失败,托盘ID: " + inData.getPalletId()); |
|
|
|
// } |
|
|
|
// 2. 保存WCS回调任务到表,等待定时任务处理 - rqrq |
|
|
|
saveWcsCallbackTask(inData, toWarehouseId, toLocationId); |
|
|
|
|
|
|
|
// 4. 保存WCS回调数据到新表,作为记录 后续根据order表去取货就行 |
|
|
|
WcsCallbackTask callbackTask = new WcsCallbackTask(); |
|
|
|
callbackTask.setSite(inData.getSite()); |
|
|
|
callbackTask.setPalletId(inData.getPalletId()); |
|
|
|
callbackTask.setTransTypeDesc(inData.getTransTypeDesc()); |
|
|
|
callbackTask.setToWarehouseId(toWarehouseId); |
|
|
|
callbackTask.setToLocationId(toLocationId); |
|
|
|
callbackTask.setStatus("已完成"); |
|
|
|
callbackTask.setCreatedTime(new Date()); |
|
|
|
callbackTask.setRetryCount(0); |
|
|
|
callbackTask.setRemark("WCS立库" + inData.getTransTypeDesc() + "回调"); |
|
|
|
callbackTask.setTaskNo(inData.getTaskNo()); |
|
|
|
callbackTask.setItemNo(inData.getItemNo()); |
|
|
|
callbackTask.setToStation(inData.getToBarcode()); |
|
|
|
// 3. 立即更新部分状态(可能是移库出库)- rqrq |
|
|
|
updateOrderTaskStatusForOutCallback(inData); |
|
|
|
wcsIntegrationMapper.reUpdatePalletDetailWcsFlag(inData.getSite(), inData.getPalletId()); |
|
|
|
|
|
|
|
// 保存到WCS回调任务表 |
|
|
|
wcsIntegrationMapper.insertWcsCallbackTask(callbackTask); |
|
|
|
//查询下 如果这个栈板没有预约任务取走,且栈板上有被预留的物料 那么直接去缓存区 |
|
|
|
WmsTransportTask checkIfHasNeedTask=wcsIntegrationMapper.checkIfHasNeedTask(inData.getSite(), inData.getPalletId()); |
|
|
|
if(checkIfHasNeedTask==null){ |
|
|
|
List<PalletDetail> palletDetailList=getPalletDetails(inData.getSite(), inData.getPalletId()); |
|
|
|
boolean hasReservePart=false; |
|
|
|
for(PalletDetail pd:palletDetailList){ |
|
|
|
List<HandlingUnit> huList=handlingUnitService.lambdaQuery() |
|
|
|
.eq(HandlingUnit::getSite, pd.getSite()) |
|
|
|
.eq(HandlingUnit::getUnitId, pd.getSerialNo()) |
|
|
|
.eq(HandlingUnit::getReserveFlag, "Y") |
|
|
|
.list(); |
|
|
|
if(huList.size()>0){ |
|
|
|
hasReservePart=true; |
|
|
|
break; |
|
|
|
} |
|
|
|
log.info("出库回调处理完成 - rqrq,palletId={}, 已保存回调任务并更新pallet_detail的wcs_flag", |
|
|
|
inData.getPalletId()); |
|
|
|
|
|
|
|
return "出库回调数据已保存,等待定时任务处理"; |
|
|
|
} |
|
|
|
if(hasReservePart){ |
|
|
|
ScheduleDeliveryTask scheduleDeliveryTask=new ScheduleDeliveryTask(); |
|
|
|
scheduleDeliveryTask.setSite(inData.getSite()); |
|
|
|
scheduleDeliveryTask.setPalletId(inData.getPalletId()); |
|
|
|
scheduleDeliveryTask.setFromLocation(inData.getToBarcode()); |
|
|
|
scheduleDeliveryTask.setToArea("Z104"); |
|
|
|
scheduleDeliveryTask.setUsername("SYS_WMS"); |
|
|
|
autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask); |
|
|
|
log.info("栈板{}没有预约任务且有预留物料,自动移库到缓存区",inData.getPalletId()); |
|
|
|
|
|
|
|
// 更新SOIssueNotifyOrderMaterialList_detail的out_wcs_flag以及wms_order_task_detail和wms_order_task状态 - rqrq |
|
|
|
try { |
|
|
|
log.info("开始更新栈板{}的申请单和任务状态 - rqrq", inData.getPalletId()); |
|
|
|
/** |
|
|
|
* @Description 处理取货通知回调 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @return 处理结果 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private String processPickupNotification(PalletWareHouseData inData) { |
|
|
|
log.info("开始处理取货通知回调 - rqrq,palletId={}, toBarcode={}", |
|
|
|
inData.getPalletId(), inData.getToBarcode()); |
|
|
|
|
|
|
|
// 1. 收集栈板上所有序列号 - rqrq |
|
|
|
List<String> serialNos = new ArrayList<>(); |
|
|
|
for(PalletDetail pd : palletDetailList){ |
|
|
|
serialNos.add(pd.getSerialNo()); |
|
|
|
} |
|
|
|
log.info("收集到序列号数量:{} - rqrq", serialNos.size()); |
|
|
|
// 1. 站点编码转换(WCS的1099/1093映射为D1/D2)- rqrq |
|
|
|
convertStationCode(inData); |
|
|
|
|
|
|
|
// 2. 根据序列号列表查询SOIssueNotifyOrderMaterialList_detail明细 - rqrq |
|
|
|
List<com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail> notifyDetails = |
|
|
|
wcsIntegrationMapper.getSOIssueNotifyDetailsBySerialNos(inData.getSite(), serialNos); |
|
|
|
log.info("查询到申请单明细数量:{} - rqrq", notifyDetails.size()); |
|
|
|
// 2. 设置目标位置为缓冲区 - rqrq |
|
|
|
String toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
String toLocationId = BufferZoneConfig.BUFFER_LOCATION_ID.getValue(); |
|
|
|
|
|
|
|
// 3. 逐条更新out_wcs_flag为Y - rqrq |
|
|
|
for (com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail notifyDetail : notifyDetails) { |
|
|
|
wcsIntegrationMapper.updateSOIssueNotifyOrderMaterialListDetailOutWcsFlag(inData.getSite(), notifyDetail.getSerialNo()); |
|
|
|
log.info("更新序列号{}的out_wcs_flag为Y - rqrq", notifyDetail.getSerialNo()); |
|
|
|
} |
|
|
|
// 3. 保存WCS回调任务到表,等待定时任务处理 - rqrq |
|
|
|
saveWcsCallbackTask(inData, toWarehouseId, toLocationId); |
|
|
|
|
|
|
|
// 4. 根据task_ref+task_item+task_seq组合去匹配wms_order_task_detail并更新状态 - rqrq |
|
|
|
// 按task_ref+task_item+task_seq分组去重 - rqrq |
|
|
|
Map<String, com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail> taskKeyMap = new HashMap<>(); |
|
|
|
for (com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail notifyDetail : notifyDetails) { |
|
|
|
// 跳过task_seq为0或null的记录 - rqrq |
|
|
|
if (notifyDetail.getTaskSeq() == null || notifyDetail.getTaskSeq() == 0) { |
|
|
|
log.info("跳过task_seq为0或null的记录,序列号={} - rqrq", notifyDetail.getSerialNo()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
log.info("取货通知回调处理完成 - rqrq,palletId={}, toStation={}, 已保存回调任务", |
|
|
|
inData.getPalletId(), inData.getToBarcode()); |
|
|
|
|
|
|
|
String taskKey = notifyDetail.getTaskRef() + "_" + notifyDetail.getTaskItem() + "_" + notifyDetail.getTaskSeq(); |
|
|
|
taskKeyMap.put(taskKey, notifyDetail); |
|
|
|
return "取货通知回调数据已保存,等待定时任务处理"; |
|
|
|
} |
|
|
|
log.info("去重后的任务明细数量:{} - rqrq", taskKeyMap.size()); |
|
|
|
|
|
|
|
// 5. 遍历更新wms_order_task_detail状态 - rqrq |
|
|
|
for (com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail notifyDetail : taskKeyMap.values()) { |
|
|
|
String taskNo = notifyDetail.getTaskRef(); |
|
|
|
Integer itemNo = notifyDetail.getTaskItem(); |
|
|
|
Integer seqNo = notifyDetail.getTaskSeq(); |
|
|
|
/** |
|
|
|
* @Description 处理取走栈板回调 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @return 处理结果 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private String processPalletRemoval(PalletWareHouseData inData) { |
|
|
|
log.info("开始处理取走栈板回调 - rqrq,palletId={}, toBarcode={}", |
|
|
|
inData.getPalletId(), inData.getToBarcode()); |
|
|
|
|
|
|
|
wcsIntegrationMapper.updateWmsOrderTaskDetailStatusForAllOuting(inData.getSite(), taskNo, itemNo, seqNo); |
|
|
|
log.info("更新wms_order_task_detail状态为已完成已分拣,taskNo={}, itemNo={}, seqNo={} - rqrq", |
|
|
|
taskNo, itemNo, seqNo); |
|
|
|
} |
|
|
|
// 1. 站点编码转换(WCS的1099/1093映射为D1/D2)- rqrq |
|
|
|
convertStationCode(inData); |
|
|
|
|
|
|
|
// 6. 检查每个任务的所有明细是否都已完成,如果是则更新主表状态为已完成 - rqrq |
|
|
|
// 收集所有涉及的taskNo+itemNo组合(去重)- rqrq |
|
|
|
Map<String, com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail> taskMainKeyMap = new HashMap<>(); |
|
|
|
for (com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail notifyDetail : taskKeyMap.values()) { |
|
|
|
String taskMainKey = notifyDetail.getTaskRef() + "_" + notifyDetail.getTaskItem(); |
|
|
|
taskMainKeyMap.put(taskMainKey, notifyDetail); |
|
|
|
// 2. 验证只能是滚筒对接区 - rqrq |
|
|
|
if (!inData.getToBarcode().startsWith("D")) { |
|
|
|
throw new RuntimeException("目前只有滚筒对接区(D1/D2)可以执行取走栈板操作,当前站点:" + inData.getToBarcode()); |
|
|
|
} |
|
|
|
log.info("去重后的任务主表数量:{} - rqrq", taskMainKeyMap.size()); |
|
|
|
|
|
|
|
// 遍历检查并更新主表状态 - rqrq |
|
|
|
for (com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail notifyDetail : taskMainKeyMap.values()) { |
|
|
|
String taskNo = notifyDetail.getTaskRef(); |
|
|
|
Integer itemNo = notifyDetail.getTaskItem(); |
|
|
|
// 3. 设置目标位置 - rqrq |
|
|
|
String toWarehouseId = BufferZoneConfig.BUFFER_WAREHOUSE_ID.getValue(); |
|
|
|
String toLocationId = inData.getToBarcode(); |
|
|
|
|
|
|
|
// 检查该任务的所有明细是否都已完成 - rqrq |
|
|
|
int unfinishedCount = wcsIntegrationMapper.checkAllTaskDetailCompleted(inData.getSite(), taskNo, itemNo); |
|
|
|
// 4. 立即更新站点状态为空闲 - rqrq |
|
|
|
wcsIntegrationMapper.updateAgvStationStatus(inData.getToBarcode(), 0, "空闲"); |
|
|
|
|
|
|
|
if (unfinishedCount == 0) { |
|
|
|
// 所有明细都已完成,更新主表状态为已完成 - rqrq |
|
|
|
wcsIntegrationMapper.updateWmsOrderTaskStatusCompleted(inData.getSite(), taskNo, itemNo); |
|
|
|
log.info("任务所有明细都已完成,更新wms_order_task主表状态为已完成,taskNo={}, itemNo={} - rqrq", |
|
|
|
taskNo, itemNo); |
|
|
|
} else { |
|
|
|
log.info("任务还有{}个明细未完成,暂不更新主表状态,taskNo={}, itemNo={} - rqrq", |
|
|
|
unfinishedCount, taskNo, itemNo); |
|
|
|
} |
|
|
|
} |
|
|
|
// 5. 保存WCS回调任务到表,等待定时任务处理 - rqrq |
|
|
|
saveWcsCallbackTask(inData, toWarehouseId, toLocationId); |
|
|
|
|
|
|
|
log.info("更新栈板{}的申请单和任务状态完成 - rqrq", inData.getPalletId()); |
|
|
|
log.info("取走栈板回调处理完成 - rqrq,palletId={}, toStation={}, 已更新站点状态并保存回调任务", |
|
|
|
inData.getPalletId(), inData.getToBarcode()); |
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
// 更新任务状态失败不影响主流程,只打印日志 - rqrq |
|
|
|
log.error("更新栈板{}的任务状态失败 - rqrq:{}", inData.getPalletId(), ex.getMessage()); |
|
|
|
ex.printStackTrace(); |
|
|
|
return "取走栈板回调数据已保存,站点已更新为空闲"; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 站点编码转换(WCS的1099/1093映射为D1/D2)- rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private void convertStationCode(PalletWareHouseData inData) { |
|
|
|
switch (inData.getToBarcode()) { |
|
|
|
case "1099": |
|
|
|
inData.setToBarcode("D1"); |
|
|
|
break; |
|
|
|
case "1093": |
|
|
|
inData.setToBarcode("D2"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
// 其他编码保持不变 - rqrq |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 旧的入库出库同步处理逻辑,已移至定时任务统一处理 - rqrq |
|
|
|
/* |
|
|
|
}else if ("入库".equals(inData.getTransTypeDesc())||"出库".equals(inData.getTransTypeDesc())) { |
|
|
|
// 4. 保存WCS回调数据到新表,等待定时任务处理 |
|
|
|
/** |
|
|
|
* @Description 保存WCS回调任务到表 - rqrq |
|
|
|
* @param inData 请求参数 |
|
|
|
* @param toWarehouseId 目标仓库 |
|
|
|
* @param toLocationId 目标库位 |
|
|
|
* @author rqrq |
|
|
|
* @date 2025/10/30 |
|
|
|
*/ |
|
|
|
private void saveWcsCallbackTask(PalletWareHouseData inData, String toWarehouseId, String toLocationId) { |
|
|
|
WcsCallbackTask callbackTask = new WcsCallbackTask(); |
|
|
|
callbackTask.setSite(inData.getSite()); |
|
|
|
callbackTask.setPalletId(inData.getPalletId()); |
|
|
|
callbackTask.setTransTypeDesc(inData.getTransTypeDesc()); |
|
|
|
callbackTask.setToWarehouseId(toWarehouseId); |
|
|
|
callbackTask.setToLocationId(toLocationId); |
|
|
|
callbackTask.setStatus("已录入"); // 等待定时任务处理 |
|
|
|
callbackTask.setStatus("已录入"); // 等待定时任务处理 - rqrq |
|
|
|
callbackTask.setCreatedTime(new Date()); |
|
|
|
callbackTask.setRetryCount(0); |
|
|
|
callbackTask.setRemark("WCS立库" + inData.getTransTypeDesc() + "回调"); |
|
|
|
@ -571,62 +534,11 @@ public class WmsMessageServiceImpl implements WmsMessageService { |
|
|
|
callbackTask.setItemNo(inData.getItemNo()); |
|
|
|
callbackTask.setToStation(inData.getToBarcode()); |
|
|
|
|
|
|
|
// 保存到WCS回调任务表 |
|
|
|
// 保存到WCS回调任务表 - rqrq |
|
|
|
wcsIntegrationMapper.insertWcsCallbackTask(callbackTask); |
|
|
|
} |
|
|
|
// 如果是入库,同时更新对应的wms_order_task状态 |
|
|
|
if ("入库".equals(inData.getTransTypeDesc())) { |
|
|
|
updateOrderTaskStatusForInboundCallback(inData); |
|
|
|
//防止没有组盘入库 |
|
|
|
wcsIntegrationMapper.updatePalletDetailWcsFlag(inData.getSite(),inData.getPalletId()); |
|
|
|
wcsIntegrationMapper.updatePalletCallingFlag(inData.getSite(), inData.getPalletId(), "N", "SYS_WMS"); |
|
|
|
} |
|
|
|
// 如果是入库,同时更新对应的wms_order_task状态 |
|
|
|
if ("出库".equals(inData.getTransTypeDesc())) { |
|
|
|
updateOrderTaskStatusForOutCallback(inData); |
|
|
|
//可能是移库出库 |
|
|
|
wcsIntegrationMapper.reUpdatePalletDetailWcsFlag(inData.getSite(),inData.getPalletId()); |
|
|
|
wcsIntegrationMapper.updatePalletCallingFlag(inData.getSite(), inData.getPalletId(), "Y", "SYS_WMS"); |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
// 如果是入库,需要立即更新一些状态(防止没有组盘入库的情况)- rqrq |
|
|
|
if ("入库".equals(inData.getTransTypeDesc())) { |
|
|
|
updateOrderTaskStatusForInboundCallback(inData); |
|
|
|
//防止没有组盘入库 - rqrq |
|
|
|
wcsIntegrationMapper.updatePalletDetailWcsFlag(inData.getSite(), inData.getPalletId()); |
|
|
|
log.info("入库回调:已更新pallet_detail的wcs_flag - rqrq,palletId={}", inData.getPalletId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果是出库,需要立即更新一些状态 - rqrq |
|
|
|
if ("出库".equals(inData.getTransTypeDesc())) { |
|
|
|
updateOrderTaskStatusForOutCallback(inData); |
|
|
|
//可能是移库出库 - rqrq |
|
|
|
wcsIntegrationMapper.reUpdatePalletDetailWcsFlag(inData.getSite(), inData.getPalletId()); |
|
|
|
log.info("出库回调:已更新pallet_detail的wcs_flag - rqrq,palletId={}", inData.getPalletId()); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("WCS回调数据已保存:栈板={}, 任务类型={}, 目标位置={}-{}", |
|
|
|
log.info("WCS回调任务已保存 - rqrq:栈板={}, 类型={}, 目标位置={}-{}", |
|
|
|
inData.getPalletId(), inData.getTransTypeDesc(), toWarehouseId, toLocationId); |
|
|
|
|
|
|
|
String result = "WCS回调数据已保存,等待定时任务处理"; |
|
|
|
|
|
|
|
// 6. 更新成功日志 |
|
|
|
long executionTime = System.currentTimeMillis() - startTime; |
|
|
|
interfaceCallLogService.updateCallResult(logId, result, "SUCCESS", null, executionTime); |
|
|
|
|
|
|
|
log.info("立库出入库接收成功,托盘ID: {}, 结果: {}", inData.getPalletId(), result); |
|
|
|
return result; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
// 更新失败日志 |
|
|
|
long executionTime = System.currentTimeMillis() - startTime; |
|
|
|
interfaceCallLogService.updateCallResult(logId, null, "ERROR", e.getMessage(), executionTime); |
|
|
|
|
|
|
|
log.error("立库出入库接收失败,托盘ID: {}, 错误: {}", |
|
|
|
inData != null ? inData.getPalletId() : "unknown", e.getMessage(), e); |
|
|
|
throw new RuntimeException("立库出入库处理失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|