Junjie
昨天 9b8ff50b66361c4b56074b7586b2d5951ecf2091
src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
@@ -53,45 +53,58 @@
    public void crnStationOutExecute() {
        try {
            DispatchLimitConfig baseLimitConfig =
                    stationDispatchLoadSupport.getDispatchLimitConfig(null, null);
            int[] currentStationTaskCountRef = new int[]{stationDispatchLoadSupport.countCurrentStationTask()};
            LoadGuardState loadGuardState =
                    stationDispatchLoadSupport.buildLoadGuardState(baseLimitConfig);
            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("crn_no"));
            List<Integer> outOrderList = stationOutboundDecisionSupport.getAllOutOrderList();
            for (WrkMast wrkMast : wrkMasts) {
                crnStationOutExecute(wrkMast);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void crnStationOutExecute(WrkMast wrkMast) {
        try {
            if (wrkMast == null || wrkMast.getWrkNo() == null) {
                return;
            }
                Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                if (infoObj == null) {
                    News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
                    continue;
                return;
                }
                StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
            if (stationObjModel == null || stationObjModel.getDeviceNo() == null || stationObjModel.getStationId() == null) {
                return;
            }
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                if (stationThread == null) {
                    continue;
                return;
                }
                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
            StationProtocol stationProtocol = stationMap == null ? null : stationMap.get(stationObjModel.getStationId());
                if (stationProtocol == null) {
                    continue;
                return;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
                if (lock != null) {
                    continue;
                return;
                }
                if (stationProtocol.isAutoing()
            if (!(stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0) {
                    && stationProtocol.getTaskNo() == 0)) {
                return;
            }
                    Double pathLenFactor = stationOutboundDecisionSupport.resolveOutboundPathLenFactor(wrkMast);
            List<Integer> outOrderList = stationOutboundDecisionSupport.getAllOutOrderList();
                    OutOrderDispatchDecision dispatchDecision =
                            stationOutboundDecisionSupport.resolveOutboundDispatchDecision(
                                    stationProtocol.getStationId(),
@@ -101,11 +114,13 @@
                            );
                    Integer moveStaNo = dispatchDecision == null ? null : dispatchDecision.getTargetStationId();
                    if (moveStaNo == null) {
                        continue;
                return;
                    }
                    DispatchLimitConfig limitConfig =
                            stationDispatchLoadSupport.getDispatchLimitConfig(stationProtocol.getStationId(), moveStaNo);
            int currentStationTaskCount = stationDispatchLoadSupport.countCurrentStationTask();
            LoadGuardState loadGuardState = stationDispatchLoadSupport.buildLoadGuardState(limitConfig);
                    LoopHitResult loopHitResult =
                            stationDispatchLoadSupport.findPathLoopHit(
                                    limitConfig,
@@ -117,7 +132,7 @@
                            );
                    if (stationDispatchLoadSupport.isDispatchBlocked(
                            limitConfig,
                            currentStationTaskCountRef[0],
                    currentStationTaskCount,
                            loadGuardState,
                            loopHitResult.isThroughLoop())) {
                        return;
@@ -132,7 +147,7 @@
                    );
                    if (command == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                return;
                    }
                    Date now = new Date();
@@ -156,11 +171,8 @@
                                stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                        redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                        currentStationTaskCountRef[0]++;
                        loadGuardState.reserveLoopTask(loopHitResult.getLoopNo());
                        stationDispatchLoadSupport.saveLoopLoadReserve(wrkMast.getWrkNo(), loopHitResult);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();