| | |
| | | package com.zy.core.dispatcher; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.ShuttleGatherResult; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | |
| | | private NavigateUtils navigateUtils; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | |
| | | /** |
| | | * 调度车辆-调度指定穿梭车 |
| | |
| | | * 调度车辆 |
| | | */ |
| | | public boolean dispatchShuttle(Integer wrkNo, String locNo) { |
| | | //检测目标库位组是否存在小车,如存在小车则直接指定该车 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkMast != null) { |
| | | String targetLocNo = wrkMast.getIoType() < 100 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo(); |
| | | List<String> groupLoc = Utils.getGroupLoc(targetLocNo); |
| | | Integer groupShuttleNo = Utils.checkGroupLocHasShuttle(groupLoc); |
| | | if (groupShuttleNo != null) { |
| | | //存在小车,直接调度该车 |
| | | return shuttleMoveGenerate(wrkNo, locNo, groupShuttleNo); |
| | | } |
| | | } |
| | | |
| | | ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车 |
| | | ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | |
| | | |
| | | if (!shuttleThread.isIdle()) { |
| | | continue;//小车忙碌中 |
| | | } |
| | | |
| | | BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getId())); |
| | | if (basShuttle != null) { |
| | | if (basShuttle.getStatus() == 0) { |
| | | continue;//小车被禁用 |
| | | } |
| | | } |
| | | |
| | | int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//小车当前层高 |
| | |
| | | return false; |
| | | } |
| | | |
| | | //获取主工作档信息 |
| | | WrkMast mainWrkMast = wrkMastService.selectByWorkNo(wrkNo); |
| | | |
| | | //判断是否有其他任务正在使用穿梭车 |
| | | WrkMast wrkMast2 = wrkMastService.selectShuttleWorking(shuttleNo); |
| | | if (wrkMast2 != null) {//小车存在其他工作档任务,等待执行完成后再生成新的任务 |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | if (mainWrkMast == null) { |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | }else { |
| | | if (!mainWrkMast.getShuttleNo().equals(shuttleNo)) { |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Integer sourceStaNo = null;//小车换层源站点 |
| | |
| | | return false;//没有可用且空闲的输送站点 |
| | | } |
| | | sourceStaNo = liftSta.getStaNo();//源站点 |
| | | //提升机号*100+目标楼层=目标站点 |
| | | staNo = liftSta.getLiftNo() * 100 + Utils.getLev(locNo);//目标站 |
| | | |
| | | ForkLiftStaProtocol targetLiftSta = ForkLiftUtils.getLiftStaByLev(liftSta.getLiftNo(), Utils.getLev(locNo)); |
| | | if (targetLiftSta == null) { |
| | | News.info("{}号小车,{}目标库位,没有目标站点", shuttleNo, locNo); |
| | | return false;//没有找到目标站点 |
| | | } |
| | | //目标站点 |
| | | staNo = targetLiftSta.getStaNo();//目标站 |
| | | } |
| | | |
| | | // 获取工作号 |
| | |
| | | } |
| | | |
| | | //给工作档绑定小车号 |
| | | WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkMast1 != null) { |
| | | wrkMast1.setShuttleNo(shuttleNo); |
| | | wrkMastService.updateById(wrkMast1); |
| | | if (mainWrkMast != null) { |
| | | mainWrkMast.setShuttleNo(shuttleNo); |
| | | wrkMastService.updateById(mainWrkMast); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 小车集合 |
| | | */ |
| | | public List<ShuttleGatherResult> shuttleGather() { |
| | | List<BasShuttle> basShuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().eq("status", 1)); |
| | | List<ShuttleGatherResult> list = new ArrayList<>(); |
| | | for (BasShuttle basShuttle : basShuttles) { |
| | | String idleLoc = basShuttle.getIdleLoc(); |
| | | if(Cools.isEmpty(idleLoc)) { |
| | | continue; |
| | | } |
| | | |
| | | boolean result = shuttleMoveGenerate(null, idleLoc, basShuttle.getShuttleNo()); |
| | | |
| | | ShuttleGatherResult gatherResult = new ShuttleGatherResult(); |
| | | gatherResult.setShuttleNo(basShuttle.getShuttleNo()); |
| | | gatherResult.setIdleLoc(idleLoc); |
| | | gatherResult.setResult(result); |
| | | list.add(gatherResult); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | continue; |
| | | } |
| | | |
| | | //小车有充电任务 |
| | | if (shuttleThread.isCharging()) { |
| | | continue; |
| | | } |
| | | |
| | | //小车故障跳过 |
| | | if (shuttleThread.isFault()) { |
| | | continue; |
| | | } |
| | | |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | if (currentLocNo == null) { |
| | | continue; |