Junjie
13 小时以前 44e258e4f5370a14e92e3c15bccd32e1e4d7280c
src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -3,16 +3,18 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.entity.BasStation;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkAnalysisService;
import com.zy.asrs.service.WrkMastLogService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.LocStsType;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkIoType;
import com.zy.core.enums.WrkStsType;
import com.zy.core.thread.StationThread;
import com.zy.core.utils.StationOperateProcessUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -31,17 +33,24 @@
    private final WrkAnalysisService wrkAnalysisService;
    private final LocMastService locMastService;
    private final NotifyUtils notifyUtils;
    private final StationOperateProcessUtils stationOperateProcessUtils;
    private final BasStationService basStationService;
    public WrkMastScheduler(WrkMastService wrkMastService,
                            WrkMastLogService wrkMastLogService,
                            WrkAnalysisService wrkAnalysisService,
                            LocMastService locMastService,
                            NotifyUtils notifyUtils) {
                            NotifyUtils notifyUtils,
                            StationOperateProcessUtils stationOperateProcessUtils,
                            BasStationService basStationService
    ) {
        this.wrkMastService = wrkMastService;
        this.wrkMastLogService = wrkMastLogService;
        this.wrkAnalysisService = wrkAnalysisService;
        this.locMastService = locMastService;
        this.notifyUtils = notifyUtils;
        this.stationOperateProcessUtils = stationOperateProcessUtils;
        this.basStationService = basStationService;
    }
    @Scheduled(cron = "0/1 * * * * ? ")
@@ -53,6 +62,10 @@
        }
        for (WrkMast wrkMast : wrkMasts) {
            Integer taskNo = wrkMast.getWrkNo();
            Integer sourceStaNo = wrkMast.getSourceStaNo();
            Integer staNo = wrkMast.getStaNo();
            String locNo = wrkMast.getLocNo();
            LocMast locMast = locMastService.queryByLoc(locNo);
            if (locMast == null) {
@@ -87,6 +100,17 @@
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
            //清理路径
            List<BasStation> basStations = basStationService.list(new QueryWrapper<BasStation>().in("station_id", sourceStaNo, staNo));
            if (!basStations.isEmpty()) {
                for (BasStation basStation : basStations) {
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
                    if (stationThread != null) {
                        stationOperateProcessUtils.attemptClearTaskPath(stationThread, taskNo);
                    }
                }
            }
        }
    }
@@ -99,6 +123,10 @@
        }
        for (WrkMast wrkMast : wrkMasts) {
            Integer taskNo = wrkMast.getWrkNo();
            Integer sourceStaNo = wrkMast.getSourceStaNo();
            Integer staNo = wrkMast.getStaNo();
            String locNo = wrkMast.getSourceLocNo();
            LocMast locMast = locMastService.queryByLoc(locNo);
            if (locMast == null) {
@@ -133,6 +161,17 @@
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
            //清理路径
            List<BasStation> basStations = basStationService.list(new QueryWrapper<BasStation>().in("station_id", sourceStaNo, staNo));
            if (!basStations.isEmpty()) {
                for (BasStation basStation : basStations) {
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
                    if (stationThread != null) {
                        stationOperateProcessUtils.attemptClearTaskPath(stationThread, taskNo);
                    }
                }
            }
        }
    }