Junjie
2026-04-16 39b95ef917ac3a01d8e1d315d25b4645b9df9692
src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java
@@ -33,6 +33,7 @@
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@@ -69,7 +70,7 @@
            }
            StoreInTaskContext earlyContext = buildContext(basDevp, stationObjModel);
            if (earlyContext == null || !handleErrorStationBack(earlyContext)) {
            if (earlyContext == null || !handleErrorStationBack(policy, earlyContext)) {
                return;
            }
@@ -188,7 +189,7 @@
        }
    }
    private boolean handleErrorStationBack(StoreInTaskContext context) {
    private boolean handleErrorStationBack(StoreInTaskPolicy policy, StoreInTaskContext context) {
        StationProtocol stationProtocol = context.getStationProtocol();
        if (stationProtocol == null) {
            return false;
@@ -255,6 +256,12 @@
            return false;
        }
        stationCommandDispatcher.dispatch(context.getBasDevp().getDevpNo(), command, "store-in-task", "station-back");
        String errorMsg = Cools.isEmpty(stationProtocol.getErrorMsg()) ? "未知异常" : stationProtocol.getErrorMsg();
        String warning = "条码站异常退回,报警信息:" + errorMsg;
        if (!Cools.isEmpty(stationProtocol.getSystemWarning())) {
            warning = stationProtocol.getSystemWarning() + ";" + warning;
        }
        policy.setSystemWarning(context, warning);
        News.info("{}扫码站异常,已退回至{},条码站状态:{}", stationProtocol.getTaskNo(),
                backStation.getStationId(), JSON.toJSONString(stationProtocol));
        redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(),
@@ -329,13 +336,13 @@
                request.getBarcode(), request.getSourceStaNo(), result.getResponse(), result.getMessage());
        redisUtil.set(policy.getGenerateLockKey(context), "lock", policy.getRetryLockSeconds(context));
        policy.onApplyFailed(context, result);
        triggerStationBackOnApplyFailed(context, request, result);
        triggerStationBackOnApplyFailed(policy, context, request, result);
    }
    /**
     * WMS 申请入库失败后,货物仍停留在扫码站,此时补发退回到入库站的输送命令,避免货物长期滞留。
     */
    private void triggerStationBackOnApplyFailed(StoreInTaskContext context,
    private void triggerStationBackOnApplyFailed(StoreInTaskPolicy policy, StoreInTaskContext context,
                                                 InTaskApplyRequest request,
                                                 InTaskApplyResult result) {
        if (context == null || context.getStationThread() == null || context.getStationObjModel() == null) {
@@ -406,6 +413,12 @@
        }
        redisUtil.set(lockKey, "lock", APPLY_FAIL_STATION_BACK_LOCK_SECONDS);
        String currentWarning = stationProtocol.getSystemWarning();
        String backWarning = "WMS入库失败,已退回入库站";
        if (!Cools.isEmpty(currentWarning)) {
            backWarning = currentWarning + ";" + backWarning;
        }
        policy.setSystemWarning(context, backWarning);
        News.warn("WMS入库失败,已触发货物退回入库站。barcode={},stationId={},backStationId={},warning={}",
                request == null ? null : request.getBarcode(),
                currentStationId,