| | |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.SortTheExecutionOfTheCarUtil; |
| | | import com.zy.asrs.utils.TimeCalculatorUtils; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.*; |
| | |
| | | import com.zy.core.thread.RgvThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private BasCircularShuttleService basCircularShuttleService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Value("${constant-parameters.perimeter}") |
| | | private Long perimeter; |
| | | /** |
| | | * 站点任务检测 更新小车位置信息 |
| | | */ |
| | |
| | | if (wrkMasts.isEmpty()){ |
| | | return; |
| | | } |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",false)); |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",true)); |
| | | if (basDevpPositions.isEmpty()){ |
| | | log.error("获取所有站点信息异常"); |
| | | return; |
| | |
| | | rgvPosition.add(rgvProtocol.getRgvPos()); |
| | | rgvPositionList.add(rgvPosition); |
| | | } |
| | | Integer rgvNo = SortTheExecutionOfTheCarUtil.LatelyAndGreaterThan(rgvPositionList, sitePosition); |
| | | |
| | | Integer rgvNo = SortTheExecutionOfTheCarUtil.LatelyAndGreaterThan(rgvPositionList, sitePosition,perimeter); |
| | | if (rgvNo == -1){ |
| | | log.info("更新小车排序信息异常={}",rgvNo); |
| | | return; |
| | | } |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); |
| | | if (basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)){ |
| | | return; |
| | | } |
| | | |
| | | int[][] ints = new int[basCircularShuttleList.size()][2]; |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList){ |
| | |
| | | */ |
| | | public synchronized void DevpTaskNoRun() { |
| | | try{ |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time",true)); |
| | | if (wrkMasts.isEmpty()){ |
| | | return; |
| | | } |
| | | long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(wrkMasts.get(0).getModiTime(), new Date()); |
| | | if (differenceInSeconds<=100){ |
| | | return; |
| | | } |
| | | |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1)); |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | return; |
| | | } |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",false)); |
| | | Integer devNo = SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPositions, rgvProtocol.getRgvPos()); |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",true)); |
| | | Integer devNo = SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPositions, rgvProtocol.getRgvPos(),perimeter); |
| | | BasDevpPosition[] basDevpPositionsList = SortTheExecutionOfTheCarUtil.devpNoSort(basDevpPositions, devNo); |
| | | BasDevpPosition[] basDevpPositionsListUN = SortTheExecutionOfTheCarUtil.devpNoSortUN(basDevpPositionsList); |
| | | List<List<WrkMast>> wrkMastLists = getWrkMastLists(basDevpPositionsListUN); |
| | |
| | | List<WrkMast> wrkMastlistA = new ArrayList<>(); |
| | | List<WrkMast> wrkMastlistB = new ArrayList<>(); |
| | | for (BasDevpPosition basDevpPosition : basDevpPositionsListUN){ |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("wrk_sts",1L)); |
| | | if (!Cools.isEmpty(wrkMast)){ |
| | | if (SortTheExecutionOfTheCarUtil.devpNoSortbj(basDevpPositionsListUN,wrkMast.getSourceStaNo(),wrkMast.getStaNo())){ |
| | | wrkMastlistA.add(wrkMast); |
| | | } else { |
| | | wrkMastlistB.add(wrkMast); |
| | | List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("wrk_sts", 1L).orderBy("modi_time",true)); |
| | | for (WrkMast wrkMast:wrkMastList){ |
| | | if (!Cools.isEmpty(wrkMast)){ |
| | | if (SortTheExecutionOfTheCarUtil.devpNoSortbj(basDevpPositionsListUN,wrkMast.getSourceStaNo(),wrkMast.getStaNo())){ |
| | | wrkMastlistA.add(wrkMast); |
| | | } else { |
| | | wrkMastlistB.add(wrkMast); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | runRgv: |
| | | for (List<WrkMast> wrkMastList : wrkMastLists){ |
| | | for (WrkMast wrkMast: wrkMastList){ |
| | | |
| | | log.error("存在任务,RGV号={},任务数据={}", rgvId, JSON.toJSON(wrkMast)); |
| | | |
| | | rgvId++; |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1L)); |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", rgvId)); |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null){ |
| | | continue ; |
| | | } |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", rgvProtocol.getRgvNo()).eq("wrk_sts", 2L)); |
| | | if (!wrkMasts.isEmpty()){ |
| | | continue ; |
| | | } |
| | | if (rgvProtocol != null |
| | | && rgvProtocol.modeType == RgvModeType.AUTO |
| | | && (rgvProtocol.getStatusType() == RgvStatusType.IDLE || rgvProtocol.getStatusType() == RgvStatusType.ROAM) |
| | |
| | | break runRgv; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |