#
Junjie
8 分钟以前 b2485b33216052f512d0a61d73dd856da0387cd7
src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
@@ -72,19 +72,6 @@
    @Value("${station.outbound.recent-dispatch-protect-seconds:60}")
    private long recentDispatchProtectSeconds;
    public void crnStationOutExecute() {
        try {
            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("crn_no"));
            for (WrkMast wrkMast : wrkMasts) {
                crnStationOutExecute(wrkMast);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void crnStationOutExecute(WrkMast wrkMast) {
        try {
            if (wrkMast == null || wrkMast.getWrkNo() == null) {
@@ -249,69 +236,67 @@
        }
    }
    public void dualCrnStationOutExecute() {
    public void dualCrnStationOutExecute(WrkMast wrkMast) {
        try {
            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("dual_crn_no"));
            for (WrkMast wrkMast : wrkMasts) {
                if (hasPendingDispatch(wrkMast.getWrkNo())) {
                    continue;
                }
                StationObjModel stationObjModel = getOutboundSourceStation(wrkMast);
                if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) {
                    continue;
                }
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                if (stationThread == null) {
                    continue;
            if (wrkMast == null || wrkMast.getWrkNo() == null) {
                return;
            }
            if (hasPendingDispatch(wrkMast.getWrkNo())) {
                return;
            }
            StationObjModel stationObjModel = getOutboundSourceStation(wrkMast);
            if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) {
                return;
            }
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                return;
            }
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                return;
            }
            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
            if (lock != null) {
                return;
            }
            if (stationProtocol.isAutoing()
                    && stationProtocol.isLoading()
                    && stationProtocol.getTaskNo() == 0) {
                Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
                StationCommand command = stationOutboundDecisionSupport.buildOutboundMoveCommand(
                        stationThread,
                        wrkMast,
                        stationProtocol.getStationId(),
                        wrkMast.getStaNo(),
                        pathLenFactor
                );
                if (command == null) {
                    News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                    return;
                }
                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
                if (stationProtocol == null) {
                    continue;
                boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
                if (!offered) {
                    return;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
                if (lock != null) {
                    continue;
                }
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0) {
                    Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
                    StationCommand command = stationOutboundDecisionSupport.buildOutboundMoveCommand(
                            stationThread,
                            wrkMast,
                if (stationMoveCoordinator != null) {
                    stationMoveCoordinator.recordDispatch(
                            wrkMast.getWrkNo(),
                            stationProtocol.getStationId(),
                            wrkMast.getStaNo(),
                            pathLenFactor
                            "dualCrnStationOutExecute",
                            command,
                            false
                    );
                    if (command == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                    }
                    boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
                    if (!offered) {
                        continue;
                    }
                    if (stationMoveCoordinator != null) {
                        stationMoveCoordinator.recordDispatch(
                                wrkMast.getWrkNo(),
                                stationProtocol.getStationId(),
                                "dualCrnStationOutExecute",
                                command,
                                false
                        );
                    }
                    markPendingDispatch(wrkMast.getWrkNo());
                    News.info("输送站点出库命令已入设备执行链路,等待源站接单。站点号={},工作号={},命令数据={}",
                            stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                }
                markPendingDispatch(wrkMast.getWrkNo());
                News.info("输送站点出库命令已入设备执行链路,等待源站接单。站点号={},工作号={},命令数据={}",
                        stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
            }
        } catch (Exception e) {
            e.printStackTrace();