Junjie
23 小时以前 03c3ae747f82ad22c761c79e7b1c0e0031c57d41
src/main/java/com/zy/core/plugin/GslProcess.java
@@ -86,38 +86,6 @@
    }
    @Override
    public boolean matchCandidate(StoreInTaskContext context) {
        return canRequestStoreIn(context.getStationProtocol());
    }
    @Override
    public boolean beforeApply(StoreInTaskContext context) {
        StationProtocol stationProtocol = context.getStationProtocol();
        if (stationProtocol.getError() <= 0) {
            return true;
        }
        Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId());
        if (lock != null) {
            return false;
        }
        StationObjModel backStation = context.getStationObjModel().getBackStation();
        StationCommand command = context.getStationThread().getCommand(StationCommandType.MOVE,
                commonService.getWorkNo(WrkIoType.STATION_BACK.id),
                context.getStationObjModel().getStationId(),
                backStation.getStationId(), 0);
        if (command == null) {
            News.taskInfo(stationProtocol.getTaskNo(), "{}工作,获取输送线命令失败", stationProtocol.getTaskNo());
            return false;
        }
        stationCommandDispatcher.dispatch(context.getBasDevp().getDevpNo(), command, "gsl-process", "station-back");
        News.taskInfo(stationProtocol.getTaskNo(), "{}扫码异常,已退回至{}", backStation.getStationId());
        redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 10);
        return true;
    }
    @Override
    public InTaskApplyRequest buildApplyRequest(StoreInTaskContext context) {
        InTaskApplyRequest request = StoreInTaskPolicy.super.buildApplyRequest(context);
        request.getExtraParams().put("weight", context.getStationProtocol().getWeight());
@@ -192,6 +160,9 @@
                if (!stationMap.containsKey(stationId)) {
                    continue;
                }
                if (!handleErrorStationBack(basDevp, stationThread, stationObjModel, stationMap.get(stationId))) {
                    continue;
                }
                if (!canRequestStoreIn(stationMap.get(stationId))) {
                    continue;
                }
@@ -203,6 +174,7 @@
    private boolean canRequestStoreIn(StationProtocol stationProtocol) {
        return stationProtocol != null
                && stationProtocol.getError() <= 0
                && stationProtocol.isAutoing()
                && stationProtocol.isLoading()
                && stationProtocol.isInEnable()
@@ -210,4 +182,32 @@
                && !Cools.isEmpty(stationProtocol.getBarcode());
    }
    private boolean handleErrorStationBack(BasDevp basDevp,
                                           StationThread stationThread,
                                           StationObjModel stationObjModel,
                                           StationProtocol stationProtocol) {
        if (stationProtocol.getError() <= 0) {
            return true;
        }
        Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId());
        if (lock != null) {
            return false;
        }
        StationObjModel backStation = stationObjModel.getBackStation();
        StationCommand command = stationThread.getCommand(StationCommandType.MOVE,
                commonService.getWorkNo(WrkIoType.STATION_BACK.id),
                stationObjModel.getStationId(),
                backStation.getStationId(), 0);
        if (command == null) {
            News.taskInfo(stationProtocol.getTaskNo(), "{}工作,获取输送线命令失败", stationProtocol.getTaskNo());
            return false;
        }
        stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "station-back");
        News.taskInfo(stationProtocol.getTaskNo(), "{}扫码异常,已退回至{}", backStation.getStationId());
        redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 10);
        return false;
    }
}