| | |
| | | package com.zy.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.WrkCharge; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.mapper.WrkChargeMapper; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | |
| | | * 调度车辆 |
| | | */ |
| | | public boolean dispatchShuttle(Integer wrkNo, String locNo) { |
| | | //检测目标库位组是否存在小车,如存在小车则直接指定该车 |
| | | WrkMast wrkMast = wrkMastMapper.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<NyShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车 |
| | | ArrayList<NyShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车 |
| | | |
| | |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo(); |
| | | //当前穿梭车线程到目标地点距离 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)));//搜索空闲穿梭车,使用正常通道地图 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图 |
| | | if (currentShuttlePath == null) { |
| | | continue; |
| | | } |
| | |
| | | WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo); |
| | | |
| | | if (wrkMast1 != null) { |
| | | int lev = Utils.getLev(wrkMast1.getLocNo());//目标楼层 |
| | | String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo(); |
| | | int lev = Utils.getLev(targetLoc);//目标楼层 |
| | | |
| | | //检测目标楼层车数量是否小于允许的最大数量 |
| | | boolean checkDispatchMaxNum = checkDispatchMaxNum(lev); |
| | |
| | | if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) { |
| | | //目标库位和小车库位处于不同一楼层,需要通过提升机调度 |
| | | //获取穿梭车最近且空闲的提升机输送站点 |
| | | LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo); |
| | | LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo)); |
| | | if (liftSta == null) { |
| | | return false;//没有可用且空闲的输送站点 |
| | | } |
| | |
| | | * true: 小于最大数量 false: 大于或等于最大数量 |
| | | */ |
| | | public boolean checkDispatchMaxNum(Integer lev) { |
| | | BasShuttleService basShuttleService = SpringUtils.getBean(BasShuttleService.class); |
| | | ConfigService configService = SpringUtils.getBean(ConfigService.class); |
| | | EntityWrapper<Config> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("code", "dispatchShuttleMaxNum"); |
| | |
| | | continue; |
| | | } |
| | | |
| | | NyShuttleProtocol.NyShuttlePointClass point = null; |
| | | if (shuttleProtocol.getPoint() == null) { |
| | | continue; |
| | | BasShuttle basShuttle = basShuttleService.selectById(shuttle.getId());//小车如果没有数据,从数据库取数据 |
| | | if (basShuttle == null || basShuttle.getPoint() == null) { |
| | | continue; |
| | | } |
| | | point = JSON.parseObject(basShuttle.getPoint(), NyShuttleProtocol.NyShuttlePointClass.class); |
| | | }else { |
| | | point = shuttleProtocol.getPoint(); |
| | | } |
| | | |
| | | if (shuttleProtocol.getPoint().getZ().equals(lev)) { |
| | | if (point.getZ().equals(lev)) { |
| | | levCount++;//目标楼层有车,数量增加 |
| | | } |
| | | } |
| | | |
| | | //搜索是否存在前往目标楼层的小车移动工作档 |
| | | for (WrkMast wrkMast : wrkMastMapper.selectShuttleMoveWrk()) { |
| | | if (wrkMast.getSourceLocNo() == null || wrkMast.getLocNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | | int sourceLev = Utils.getLev(wrkMast.getSourceLocNo());//工作档源楼层 |
| | | int targetLev = Utils.getLev(wrkMast.getLocNo());//工作档目标楼层 |
| | | if (sourceLev == lev) { |
| | | continue;//工作档楼层和目标楼层相同,跳过 |
| | | } |
| | | |
| | | if (targetLev == lev) { |
| | | levCount++;//工作档目标楼层和实际楼层相同,数量增加 |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | return levCount < Integer.parseInt(config.getValue()); |
| | | } |
| | |
| | | /** |
| | | * 获取穿梭车最近且空闲的提升机输送站点 |
| | | */ |
| | | public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) { |
| | | public LiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) { |
| | | //获取四向穿梭车线程 |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | if (shuttleThread == null) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | //判断目标楼层站点是否无托盘 |
| | | LiftStaProtocol targetLiftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), targetLev); |
| | | if (targetLiftStaProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (targetLiftStaProtocol.getHasTray()) { |
| | | continue;//有托盘跳过 |
| | | } |
| | | |
| | | list.add(liftStaProtocol); |
| | | } |
| | | |
| | |
| | | String locNo = liftStaProtocol.getLocNo();//站点库位号 |
| | | |
| | | //当前穿梭车线程到目标地点距离 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)));//使用正常通道地图 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//使用正常通道地图 |
| | | if (currentShuttlePath == null) { |
| | | continue; |
| | | } |