| | |
| | | /** |
| | | * 调度车辆 |
| | | */ |
| | | public boolean dispatchShuttle(Integer wrkNo, String locNo) { |
| | | public boolean searchDispatchShuttle(Integer wrkNo, String sourceLocNo, String locNo, String flag) { |
| | | ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车 |
| | | ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | if (currentLocNo.equals(locNo)) { |
| | | sameShuttles.put(-1, shuttleThread); |
| | | continue; |
| | | } |
| | | |
| | | //当前穿梭车线程到目标地点距离 |
| | | List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图 |
| | | if (currentShuttlePath == null) { |
| | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //尝试调度小车 |
| | | boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo); |
| | | boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); |
| | | if (result) { |
| | | return true;//调度成功 |
| | | } |
| | |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | int currentLev = Utils.getLev(currentLocNo); |
| | | List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车 |
| | | int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量 |
| | | if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { |
| | | //存在其他任务且可用小车数量小于等于1,跳过这辆车 |
| | | continue; |
| | | } |
| | | // List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车 |
| | | // int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量 |
| | | // if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { |
| | | // //存在其他任务且可用小车数量小于等于1,跳过这辆车 |
| | | // continue; |
| | | // } |
| | | |
| | | //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值 |
| | | int currentValue = Math.abs(lev - currentLev); |
| | | diffShuttles.put(currentValue, shuttleThread); |
| | | if (diffShuttles.get(currentValue) != null) { |
| | | diffShuttles.put(currentValue + 1, shuttleThread); |
| | | } else { |
| | | diffShuttles.put(currentValue, shuttleThread); |
| | | } |
| | | } |
| | | |
| | | //尝试调度跨楼层小车 |
| | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //尝试调度小车 |
| | | boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo); |
| | | boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); |
| | | if (result) { |
| | | return true;//调度成功 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //News.info("{}目标库位没有搜索到可用穿梭车", locNo); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 调度车辆 |
| | | */ |
| | | public boolean searchDispatchShuttleS(Integer wrkNo, String sourceLocNo, String locNo, String flag) { |
| | | ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车 |
| | | ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | | for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (checkChargeWrk(shuttle.getId())) { |
| | | continue;//存在充电任务,过滤小车 |
| | | } |
| | | |
| | | 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());//小车当前层高 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo();//小车当前库位号 |
| | | |
| | | if (currentLocNo.equals(locNo) || currentLocNo.equals(sourceLocNo)) { |
| | | //车辆当前位置已经是目标库位,调度该车 |
| | | //给工作档绑定小车号 |
| | | WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkMast1 != null) { |
| | | wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo()); |
| | | wrkMastService.updateById(wrkMast1); |
| | | sameLev.add(0,shuttleThread); |
| | | //return true; |
| | | } |
| | | break; |
| | | } |
| | | if (currentLev == Utils.getLev(sourceLocNo)) { |
| | | //工作档楼层相同的穿梭车 |
| | | sameLev.add(shuttleThread); |
| | | } else { |
| | | //工作档不同楼层的穿梭车 |
| | | diffLev.add(shuttleThread); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //优先调度同楼层小车,寻找离任务最近的穿梭车 |
| | | if (!sameLev.isEmpty()) { |
| | | Map<Integer, ShuttleThread> sameShuttles = new TreeMap<>();//自然排序小车Map |
| | | for (ShuttleThread shuttleThread : sameLev) { |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | if (currentLocNo.equals(sourceLocNo)) { |
| | | sameShuttles.put(-1, shuttleThread); |
| | | continue; |
| | | } |
| | | |
| | | //当前穿梭车线程到目标地点距离 |
| | | List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图 |
| | | if (currentShuttlePath == null) { |
| | | continue; |
| | | } |
| | | |
| | | Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离 |
| | | sameShuttles.put(currentAllDistance, shuttleThread); |
| | | } |
| | | |
| | | //尝试调度同楼层小车 |
| | | for (Map.Entry<Integer, ShuttleThread> entry : sameShuttles.entrySet()) { |
| | | ShuttleThread shuttleThread = entry.getValue(); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //尝试调度小车 |
| | | boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); |
| | | if (result) { |
| | | return true;//调度成功 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //执行到此处,同楼层无调度成功小车。需要进行跨楼层调度小车 |
| | | //寻找离任务楼层最近的穿梭车(不考虑跨楼层小车移动距离) |
| | | if (!diffLev.isEmpty()) { |
| | | Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//自然排序小车Map |
| | | //获取任务 |
| | | WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkMast1 != null) { |
| | | String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo(); |
| | | int lev = Utils.getLev(targetLoc);//目标楼层 |
| | | |
| | | //检测目标楼层车数量是否小于允许的最大数量 |
| | | boolean checkDispatchMaxNum = checkDispatchMaxNum(lev); |
| | | if (!checkDispatchMaxNum) { |
| | | News.info("{}任务,{}层,已经达到当前楼层调度车辆最大值", wrkMast1.getWrkNo(), lev); |
| | | return false; |
| | | } |
| | | |
| | | for (ShuttleThread shuttleThread : diffLev) { |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | int currentLev = Utils.getLev(currentLocNo); |
| | | // List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车 |
| | | // int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量 |
| | | // if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { |
| | | // //存在其他任务且可用小车数量小于等于1,跳过这辆车 |
| | | // continue; |
| | | // } |
| | | |
| | | //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值 |
| | | int currentValue = Math.abs(lev - currentLev); |
| | | if (diffShuttles.get(currentValue) != null) { |
| | | diffShuttles.put(currentValue + 1, shuttleThread); |
| | | } else { |
| | | diffShuttles.put(currentValue, shuttleThread); |
| | | } |
| | | } |
| | | |
| | | //尝试调度跨楼层小车 |
| | | for (Map.Entry<Integer, ShuttleThread> entry : diffShuttles.entrySet()) { |
| | | ShuttleThread shuttleThread = entry.getValue(); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //尝试调度小车 |
| | | boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); |
| | | if (result) { |
| | | return true;//调度成功 |
| | | } |
| | |
| | | News.info("{}目标库位没有搜索到可用穿梭车", locNo); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 调度车辆 |
| | | */ |
| | | public boolean searchDispatchShuttleNoLift(Integer wrkNo, String sourceLocNo, String locNo, String flag) { |
| | | ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | | for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (checkChargeWrk(shuttle.getId())) { |
| | | continue;//存在充电任务,过滤小车 |
| | | } |
| | | |
| | | if (!shuttleThread.isIdle()) { |
| | | continue;//小车忙碌中 |
| | | } |
| | | |
| | | BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getId())); |
| | | if (basShuttle != null) { |
| | | if (basShuttle.getStatus() == 0) { |
| | | continue;//小车被禁用 |
| | | } |
| | | } |
| | | diffLev.add(shuttleThread); |
| | | } |
| | | |
| | | //寻找离任务楼层最近的穿梭车(不考虑跨楼层小车移动距离) |
| | | if (!diffLev.isEmpty()) { |
| | | Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//自然排序小车Map |
| | | //获取任务 |
| | | WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkMast1 != null) { |
| | | int lev = 1; |
| | | boolean b = wrkMast1.getIoType() < 100; |
| | | if (b) { |
| | | //ruku |
| | | if (wrkMast1.getStaNo() == 1015) { |
| | | lev = 1; |
| | | } else { |
| | | lev = 5; |
| | | } |
| | | } else { |
| | | lev = Utils.getLev(wrkMast1.getSourceLocNo());//目标楼层 |
| | | } |
| | | |
| | | |
| | | //检测目标楼层车数量是否小于允许的最大数量 |
| | | boolean checkDispatchMaxNum = checkDispatchMaxNum(lev); |
| | | if (!checkDispatchMaxNum) { |
| | | News.info("{}任务,{}层,已经达到当前楼层调度车辆最大值", wrkMast1.getWrkNo(), lev); |
| | | return false; |
| | | } |
| | | |
| | | for (ShuttleThread shuttleThread : diffLev) { |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | int currentLev = Utils.getLev(currentLocNo); |
| | | |
| | | if (wrkMast1.getIoType() == 101 && currentLocNo.equals(locNo)) { |
| | | //车辆当前位置已经是目标库位,调度该车 |
| | | //给工作档绑定小车号 |
| | | diffShuttles.put(-1, shuttleThread); |
| | | } else { |
| | | //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值 |
| | | int currentValue = Math.abs(lev - currentLev); |
| | | if (diffShuttles.get(currentValue) != null) { |
| | | diffShuttles.put(currentValue + 1, shuttleThread); |
| | | } else { |
| | | diffShuttles.put(currentValue, shuttleThread); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //尝试调度跨楼层小车 |
| | | for (Map.Entry<Integer, ShuttleThread> entry : diffShuttles.entrySet()) { |
| | | ShuttleThread shuttleThread = entry.getValue(); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //尝试调度小车 |
| | | boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false); |
| | | if (result) { |
| | | return true;//调度成功 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | News.info("{}目标库位没有搜索到可用穿梭车", locNo); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 小车迁移任务生成 |
| | |
| | | News.info("{}号小车,存在移动任务,等待执行完成后再生成新的任务", shuttleNo); |
| | | return false; |
| | | } |
| | | |
| | | WrkMast mainWrkMast = null; |
| | | //获取主工作档信息 |
| | | WrkMast mainWrkMast = wrkMastService.selectByWorkNo(wrkNo); |
| | | if (wrkNo != null) { |
| | | mainWrkMast = wrkMastService.selectByWorkNo(wrkNo); |
| | | } |
| | | |
| | | //判断是否有其他任务正在使用穿梭车 |
| | | WrkMast wrkMast2 = wrkMastService.selectShuttleWorking(shuttleNo); |
| | | WrkMast wrkMast2 = wrkMastService.selectShuttleWorking2(shuttleNo, wrkNo, mainWrkMast != null ? mainWrkMast.getMainWrkNo() : null); |
| | | if (wrkMast2 != null && !disableCheck) {//小车存在其他工作档任务,等待执行完成后再生成新的任务 |
| | | if (mainWrkMast == null) { |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | } else { |
| | | if (!mainWrkMast.getShuttleNo().equals(shuttleNo)) { |
| | | if (mainWrkMast.getShuttleNo() != null && !mainWrkMast.getShuttleNo().equals(shuttleNo)) { |
| | | News.info("{}号小车,存在其他工作档任务,等待执行完成再生成新的任务", shuttleNo); |
| | | return false; |
| | | } |
| | |
| | | wrkMast.setLocNo(locNo); // 目标库位 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setMainWrkNo(mainWrkMast.getWrkNo()); |
| | | |
| | | if ("TRANSPORT_LIFT".equalsIgnoreCase(flag) || "TRANSPORT_DEVP".equalsIgnoreCase(flag)) { |
| | | wrkMast.setMainWrkNo(wrkNo); |
| | | } |
| | | |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | News.error("小车迁移 --- 保存工作档失败! 穿梭车号:" + shuttleNo); |