| | |
| | | package com.zy.core.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasStation; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasStationService; |
| | | import com.zy.asrs.service.WrkAnalysisService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | |
| | | private MainProcessTaskSubmitter mainProcessTaskSubmitter; |
| | | @Autowired |
| | | private StationOutboundDecisionSupport stationOutboundDecisionSupport; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | |
| | | //执行输送站点入库任务 |
| | | public synchronized void stationInExecute() { |
| | |
| | | stationRegularDispatchProcessor.stationOutExecuteFinish(wrkMast); |
| | | } |
| | | |
| | | // 检测入库任务是否到达站台并转为站台运行完成 |
| | | public synchronized 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()); |
| | | boolean arrived = stationProtocol != null |
| | | && wrkMast.getWrkNo().equals(stationProtocol.getTaskNo()) |
| | | && stationProtocol.isLoading(); |
| | | if (!arrived && !stationThread.hasRecentArrival(basStation.getStationId(), wrkMast.getWrkNo())) { |
| | | continue; |
| | | } |
| | | boolean updated = wrkAnalysisService.completeInboundStationRun(wrkMast, new Date()); |
| | | if (updated) { |
| | | News.info("入库站点到达扫描命中,工作号={},目标站={}", wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 检测单个入库任务是否到达目标站台 |
| | | public void scanInboundStationArrival(WrkMast wrkMast) { |
| | | if (wrkMast == null || wrkMast.getWrkNo() == null || wrkMast.getStaNo() == null) { |
| | | public void scanInboundStationArrival(StationObjModel stationObjModel) { |
| | | if (stationObjModel == null) { |
| | | return; |
| | | } |
| | | BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>() |
| | | .eq("station_id", wrkMast.getStaNo()) |
| | | .last("limit 1")); |
| | | if (basStation == null || basStation.getDeviceNo() == null) { |
| | | return; |
| | | } |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo()); |
| | | 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(basStation.getStationId()); |
| | | boolean arrived = stationProtocol != null |
| | | && wrkMast.getWrkNo().equals(stationProtocol.getTaskNo()) |
| | | && stationProtocol.isLoading(); |
| | | if (!arrived && !stationThread.hasRecentArrival(basStation.getStationId(), wrkMast.getWrkNo())) { |
| | | 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; |
| | | } |
| | | boolean updated = wrkAnalysisService.completeInboundStationRun(wrkMast, new Date()); |
| | |
| | | } |
| | | |
| | | public void submitInboundStationArrivalTasks(MainProcessLane lane, long minIntervalMs) { |
| | | 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) { |
| | | mainProcessTaskSubmitter.submitKeyedSerialTask( |
| | | lane, |
| | | wrkMast.getStaNo(), |
| | | "scanInboundStationArrival", |
| | | minIntervalMs, |
| | | () -> scanInboundStationArrival(wrkMast) |
| | | ); |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | Integer crnNo = basCrnp == null ? null : basCrnp.getCrnNo(); |
| | | if (crnNo == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : basCrnp.getInStationList$()) { |
| | | mainProcessTaskSubmitter.submitKeyedSerialTask( |
| | | lane, |
| | | stationObjModel.getStationId(), |
| | | "scanInboundStationArrival", |
| | | minIntervalMs, |
| | | () -> scanInboundStationArrival(stationObjModel) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | |