#
Junjie
14 小时以前 fefdabbcd1504a55d8ad10ecf6cfc36cc7b1b1b6
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -36,7 +36,7 @@
@Component
public class StationOperateProcessUtils {
    private static final int LOOP_LOAD_RESERVE_EXPIRE_SECONDS = 120;
    private static final int OUT_ORDER_DISPATCH_LIMIT_SECONDS = 10;
    private static final int OUT_ORDER_DISPATCH_LIMIT_SECONDS = 2;
    private static final int STATION_IDLE_RECOVER_SECONDS = 10;
    private static final int STATION_IDLE_RECOVER_LIMIT_SECONDS = 10;
    private static final int STATION_IDLE_TRACK_EXPIRE_SECONDS = 60 * 60;
@@ -312,39 +312,45 @@
            for (WrkMast wrkMast : wrkMasts) {
                Integer wrkNo = wrkMast.getWrkNo();
                Integer targetStaNo = wrkMast.getStaNo();
                if (wrkNo == null || targetStaNo == null) {
                    continue;
                }
                boolean complete = false;
                Integer targetDeviceNo = null;
                BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>().eq("station_id", targetStaNo));
                if (basStation == null) {
                    continue;
                }
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
                if (stationThread == null) {
                    continue;
                }
                Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                StationProtocol stationProtocol = statusMap.get(basStation.getStationId());
                if (stationProtocol == null) {
                    continue;
                }
                if (stationProtocol.getTaskNo().equals(wrkNo)) {
                    complete = true;
                if (basStation != null) {
                    targetDeviceNo = basStation.getDeviceNo();
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
                    if (stationThread != null) {
                        Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                        StationProtocol stationProtocol = statusMap.get(basStation.getStationId());
                        if (stationProtocol != null && wrkNo.equals(stationProtocol.getTaskNo())) {
                            complete = true;
                        }
                    }
                }
                if (complete) {
                    wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
                    wrkMast.setIoTime(new Date());
                    wrkMastService.updateById(wrkMast);
                    notifyUtils.notify(String.valueOf(SlaveType.Devp), basStation.getDeviceNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN_COMPLETE, null);
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
                    completeStationRunTask(wrkMast, targetDeviceNo);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void completeStationRunTask(WrkMast wrkMast, Integer deviceNo) {
        if (wrkMast == null || wrkMast.getWrkNo() == null) {
            return;
        }
        wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
        wrkMast.setIoTime(new Date());
        wrkMastService.updateById(wrkMast);
        if (deviceNo != null) {
            notifyUtils.notify(String.valueOf(SlaveType.Devp), deviceNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN_COMPLETE, null);
        }
        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
    }
    // 检测任务转完成
@@ -753,11 +759,7 @@
        if (!Objects.equals(dispatchStationId, wrkMast.getStaNo())
                && isCurrentOutOrderStation(currentStationId, outOrderStationIds)
                && isWatchingCircleArrival(wrkMast.getWrkNo(), currentStationId)) {
            Integer circleTarget = resolveNextCircleOrderTarget(currentStationId, outOrderStationIds);
            if (circleTarget == null) {
                return null;
            }
            return new OutOrderDispatchDecision(circleTarget, true);
            return new OutOrderDispatchDecision(dispatchStationId, true);
        }
        return new OutOrderDispatchDecision(dispatchStationId, false);
    }
@@ -802,8 +804,7 @@
        if (seq == null) {
            toTarget = currentBatchSeq.equals(wrkMast.getBatchSeq());
        } else {
            toTarget = Integer.valueOf(seq + 1).equals(wrkMast.getBatchSeq())
                    && currentBatchSeq.equals(wrkMast.getBatchSeq());
            toTarget = Integer.valueOf(seq + 1).equals(wrkMast.getBatchSeq());
        }
        if (toTarget) {
            if (hasReachableOutReleaseSlot(currentStationId, wrkMast.getStaNo())) {