| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.zy.asrs.entity.BasStation; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasStationService; |
| | | import com.zy.asrs.service.WrkAnalysisService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.core.utils.StationOperateProcessUtils; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class WrkAnalysisStationArrivalScanner { |
| | | |
| | | private final WrkMastService wrkMastService; |
| | | private final BasStationService basStationService; |
| | | private final WrkAnalysisService wrkAnalysisService; |
| | | private final StationOperateProcessUtils stationOperateProcessUtils; |
| | | |
| | | public WrkAnalysisStationArrivalScanner(WrkMastService wrkMastService, |
| | | BasStationService basStationService, |
| | | WrkAnalysisService wrkAnalysisService, |
| | | StationOperateProcessUtils stationOperateProcessUtils) { |
| | | this.wrkMastService = wrkMastService; |
| | | this.basStationService = basStationService; |
| | | this.wrkAnalysisService = wrkAnalysisService; |
| | | public WrkAnalysisStationArrivalScanner(StationOperateProcessUtils stationOperateProcessUtils) { |
| | | this.stationOperateProcessUtils = stationOperateProcessUtils; |
| | | } |
| | | |
| | |
| | | public void scanOutboundStationFlow() { |
| | | stationOperateProcessUtils.stationOutExecuteFinish(); |
| | | stationOperateProcessUtils.checkTaskToComplete(); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000L) |
| | | public void scanInboundStationArrival() { |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>() |
| | | .eq("io_type", 1) |
| | | .eq("wrk_sts", WrkStsType.INBOUND_STATION_RUN.sts) |
| | | .isNotNull("sta_no")); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if (wrkMast == null || wrkMast.getWrkNo() == null || wrkMast.getStaNo() == null) { |
| | | continue; |
| | | } |
| | | BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>() |
| | | .eq("station_id", wrkMast.getStaNo()) |
| | | .last("limit 1")); |
| | | if (basStation == null || basStation.getDeviceNo() == null) { |
| | | continue; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(basStation.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | if (!wrkMast.getWrkNo().equals(stationProtocol.getTaskNo()) || !stationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | boolean updated = wrkAnalysisService.completeInboundStationRun(wrkMast, new Date()); |
| | | if (updated) { |
| | | News.info("入库站点到达扫描命中,工作号={},目标站={}", wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | } |
| | | } |
| | | } |
| | | } |