Junjie
6 小时以前 41aeff86351d1dd94fe2408175f96475f227c1b9
src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
@@ -77,52 +77,46 @@
        }
    }
    public void stationOutExecuteFinish() {
    public void stationOutExecuteFinish(StationObjModel stationObjModel) {
        try {
            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
            for (WrkMast wrkMast : wrkMasts) {
                stationOutExecuteFinish(wrkMast);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
            if (stationObjModel == null) {
                return;
    }
    public void stationOutExecuteFinish(WrkMast wrkMast) {
        try {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                return;
            }
            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                return;
            }
            if (stationProtocol.getTaskNo() <= 0) {
                return;
            }
            WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
            if (wrkMast == null) {
                return;
            }
            Integer wrkNo = wrkMast.getWrkNo();
            Integer targetStaNo = wrkMast.getStaNo();
            if (wrkNo == null || targetStaNo == null) {
            if (!wrkMast.getWrkSts().equals(WrkStsType.STATION_RUN.sts)) {
                return;
            }
            Integer wrkNo = wrkMast.getWrkNo();
            boolean complete = false;
            Integer targetDeviceNo = null;
            StationThread stationThread = null;
            BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>().eq("station_id", targetStaNo));
            if (basStation != null) {
                targetDeviceNo = basStation.getDeviceNo();
                stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
                if (stationThread != null) {
                    Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                    StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(basStation.getStationId());
                    boolean arrived = stationProtocol != null && wrkNo.equals(stationProtocol.getTaskNo());
                    if (arrived || stationThread.hasRecentArrival(basStation.getStationId(), wrkNo)) {
                        complete = true;
                        if (!arrived) {
                            News.info("输送站点出库到达判定使用最近到站补偿,工作号={},目标站={}", wrkNo, targetStaNo);
            if (stationMoveCoordinator != null) {
                stationMoveCoordinator.finishSession(wrkMast.getWrkNo());
                        }
                    }
                }
            }
            if (complete) {
            Date now = new Date();
            wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
            wrkMast.setIoTime(now);
            wrkMast.setModiTime(now);
            wrkMastService.updateById(wrkMast);
            wrkAnalysisService.markOutboundStationComplete(wrkMast, now);
            notifyUtils.notify(String.valueOf(SlaveType.Devp), stationObjModel.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);
                attemptClearTaskPath(stationThread, wrkNo);
                completeStationRunTask(wrkMast, targetDeviceNo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -193,25 +187,6 @@
        } catch (Exception e) {
            News.error("输送站点任务运行完成后清理残留路径异常,工作号={}", taskNo, e);
        }
    }
    private void completeStationRunTask(WrkMast wrkMast, Integer deviceNo) {
        if (wrkMast == null || wrkMast.getWrkNo() == null) {
            return;
        }
        if (stationMoveCoordinator != null) {
            stationMoveCoordinator.finishSession(wrkMast.getWrkNo());
        }
        Date now = new Date();
        wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
        wrkMast.setIoTime(now);
        wrkMast.setModiTime(now);
        wrkMastService.updateById(wrkMast);
        wrkAnalysisService.markOutboundStationComplete(wrkMast, now);
        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);
    }
    private boolean offerDevpCommandWithDedup(Integer deviceNo, StationCommand command, String scene) {