src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/utils/NyLiftUtils.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/LiftSlave.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/LiftThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1247,7 +1247,7 @@ //查询库位移转工作档 List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); for (WrkMast wrkMast : wrkMasts1) { if (wrkMast.getSourceLocNo().equals(wrkMast.getLocNo())) { if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { boolean step1 = this.locToLocExecuteStep1(wrkMast);//同楼层库位移转 if (!step1) { continue; @@ -1366,10 +1366,14 @@ } //获取穿梭车最近且空闲的提升机输送站点 BasDevp liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId()); LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId()); if (liftSta == null) { return false;//没有可用且空闲的输送站点 } //源站 Integer sourceStaNo = liftSta.getStaNo(); //提升机号*100+目标楼层=目标站点 Integer staNo = liftSta.getLiftNo() * 100 + Utils.getLev(wrkMast.getLocNo());//目标站 //小车已抵达源库位,将货物搬运到输送站点 NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo()); @@ -1387,7 +1391,8 @@ assignCommand.setNodes(result.getNodes());//路径节点 wrkMast.setWrkSts(22L);//21.生成出库任务 => 22.小车搬运中 wrkMast.setLiftNo(liftSta.getLiftNo());//设置提升机号 wrkMast.setSourceStaNo(sourceStaNo);//源站 wrkMast.setStaNo(staNo);//目标站 wrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(wrkMast) > 0) { //下发任务 @@ -1427,16 +1432,16 @@ return false; } //获取源站对应的输送站点 BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue()); //获取目标站对应的输送站点 BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue()); if (sourceBasDevp == null || targetBasDevp == null) { return false;//缺少站点信息 //源站 Integer sourceStaNo = wrkMast.getSourceStaNo(); //目标站 Integer staNo = wrkMast.getStaNo(); if (sourceStaNo == null || staNo == null) { return false;//源站或目标站为空 } //获取提升机命令 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo()); NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceStaNo, staNo, wrkMast.getWrkNo()); ArrayList<NyLiftCommand> commands = new ArrayList<>(); commands.add(liftCommand); @@ -1515,6 +1520,7 @@ assignCommand.setNodes(result.getNodes());//路径节点 wrkMast.setWrkSts(5L);//4.提升机搬运完成 => 5.小车搬运中 wrkMast.setLiftNo(null);//释放提升机 wrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(wrkMast) > 0) { //下发任务 @@ -2217,14 +2223,14 @@ return false; } //获取目标输送站 BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo()); if (basDevp == null) { return false;//找不到输送站点 //获取源输送站 LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); if (liftSta == null) { return false;//找不到站点 } //获取小车到输送站点行走命令 NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), basDevp.getLocNo()); NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo()); List<NyShuttleHttpCommand> commands = result.getCommands(); ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); @@ -2259,14 +2265,20 @@ //小车移动到提升机中 103.小车移动至站点完成 ==> 104.小车迁入提升机中 if (wrkMast.getWrkSts() == 103) { //获取源站 LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); if (sourceLiftSta == null) { return false;//找不到站点 } //获取目标输送站 BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo()); if (basDevp == null) { return false;//找不到输送站点 LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (liftSta == null) { return false;//找不到站点 } //获取提升机数据 BasLift basLift = basLiftService.selectById(basDevp.getLiftNo()); BasLift basLift = basLiftService.selectById(liftSta.getLiftNo()); if (basLift == null) { return false;//没有提升机数据 } @@ -2281,7 +2293,7 @@ return false;//当前提升机存在未完成任务,等待下一次轮询 } LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo()); LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSta.getLiftNo()); if (liftThread == null) { return false; } @@ -2313,10 +2325,8 @@ //提升机不在小车楼层 //调度提升机 //获取源站对应的输送站点 BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(liftProtocol.getLev().intValue(), liftProtocol.getLiftNo().intValue()); //获取提升机命令 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceBasDevp.getDevNo(), basDevp.getDevNo(), wrkMast.getWrkNo()); //获取提升机命令,调度提升机到源站位置 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo()); ArrayList<NyLiftCommand> commands = new ArrayList<>(); commands.add(liftCommand); @@ -2349,7 +2359,7 @@ } //站点节点 NavigateNode staNode = NavigatePositionConvert.locNoToNode(basDevp.getLocNo()); NavigateNode staNode = NavigatePositionConvert.locNoToNode(sourceLiftSta.getLocNo()); //提升机节点 NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); @@ -2414,6 +2424,11 @@ return false;//提升机令牌和当前小车不一致,禁止派发 } //判断提升机内是否有小车 if (!liftProtocol.getHasCar()) { return false;//提升机内无小车 } //获取四向穿梭车线程 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); if (shuttleThread == null) { @@ -2434,16 +2449,16 @@ return false; } //获取源站对应的输送站点 BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue()); //获取目标站对应的输送站点 BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue()); if (sourceBasDevp == null || targetBasDevp == null) { //获取源站 LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); //获取目标站 LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (sourceLiftSta == null || liftSta == null) { return false;//缺少站点信息 } //获取提升机命令 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo()); NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), liftSta.getStaNo(), wrkMast.getWrkNo()); ArrayList<NyLiftCommand> commands = new ArrayList<>(); commands.add(liftCommand); @@ -2515,10 +2530,10 @@ return false; } //获取目标站对应的输送站点 BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue()); if (targetBasDevp == null) { return false;//缺少站点信息 //获取目标站 LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (liftSta == null) { return false;//找不到站点 } //获取提升机数据 @@ -2534,7 +2549,7 @@ List<NyShuttleHttpCommand> commands = new ArrayList<>(); //获取小车出提升机行走命令 NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), liftNode, NavigatePositionConvert.locNoToNode(targetBasDevp.getLocNo()), false); NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), liftNode, NavigatePositionConvert.locNoToNode(liftSta.getLocNo()), false); commands.add(moveCommand);//添加小车迁出提升机命令 ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); src/main/java/com/zy/common/utils/NyLiftUtils.java
@@ -1,6 +1,15 @@ package com.zy.common.utils; import com.core.common.SpringUtils; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.SlaveType; import com.zy.core.model.LiftSlave; import com.zy.core.model.command.NyLiftCommand; import com.zy.core.model.protocol.LiftStaProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.LiftThread; import javax.swing.*; /** * 牛眼提升机工具类 @@ -20,4 +29,55 @@ return command; } //获取提升机站点 public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) { SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); for (LiftSlave liftSlave : slaveProperties.getLift()) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getStaNo() == staNo) { return liftStaProtocol; } } } return null; } //获取提升机站点 public static LiftStaProtocol getLiftStaByStaNo(Integer liftNo, Integer staNo) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getStaNo() == staNo) { return liftStaProtocol; } } return null; } //获取提升机站点 public static LiftStaProtocol getLiftStaByLev(Integer liftNo, Integer lev) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); if (liftThread == null) { return null; } for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { if (liftStaProtocol.getLev() == lev) { return liftStaProtocol; } } return null; } } src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
@@ -18,6 +18,7 @@ import com.zy.core.model.LiftSlave; import com.zy.core.model.ShuttleSlave; import com.zy.core.model.protocol.LiftProtocol; import com.zy.core.model.protocol.LiftStaProtocol; import com.zy.core.model.protocol.NyShuttleProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.LiftThread; @@ -111,6 +112,7 @@ if (currentAllDistance < recentAllDistance) { //如果当前楼层的车路径更小,则更新最近穿梭车 recentShuttle = shuttleThread; recentAllDistance = currentAllDistance; } } }else { @@ -137,6 +139,7 @@ if (currentAllDistance < recentAllDistance) { //如果当前楼层的车路径更小,则更新最近穿梭车 recentShuttle = shuttleThread; recentAllDistance = currentAllDistance; } } } @@ -188,15 +191,18 @@ return false; } Integer staNo = null; Integer sourceStaNo = null;//小车换层源站点 Integer staNo = null;//小车换层目标站点 if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) { //目标库位和小车库位处于不同一楼层,需要通过提升机调度 //获取穿梭车最近且空闲的提升机输送站点 BasDevp liftSta = this.getRecentLiftSta(shuttleNo); LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo); if (liftSta == null) { return false;//没有可用且空闲的输送站点 } staNo = liftSta.getDevNo(); sourceStaNo = liftSta.getStaNo();//源站点 //提升机号*100+目标楼层=目标站点 staNo = liftSta.getLiftNo() * 100 + Utils.getLev(locNo);//目标站 } // 获取工作号 @@ -211,6 +217,7 @@ wrkMast.setShuttleNo(shuttleNo);//穿梭车号 wrkMast.setSourceLocNo(shuttleProtocol.getCurrentLocNo()); // 源库位 => 小车当前库位号 wrkMast.setLocNo(locNo); // 目标库位 wrkMast.setSourceStaNo(sourceStaNo);//源站 wrkMast.setStaNo(staNo);//目标站 wrkMast.setPicking("N"); // 拣料 wrkMast.setExitMk("N"); // 退出 @@ -236,7 +243,7 @@ /** * 获取穿梭车最近且空闲的提升机输送站点 */ public BasDevp getRecentLiftSta(Integer shuttleNo) { public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) { //获取四向穿梭车线程 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); if (shuttleThread == null) { @@ -247,6 +254,9 @@ return null; } //获取小车同一楼层的站点 ArrayList<LiftStaProtocol> list = new ArrayList<>(); int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//小车楼层 for (LiftSlave slave : slaveProperties.getLift()) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); if (liftThread == null) { @@ -260,14 +270,40 @@ continue; } BasDevp basDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(shuttleProtocol.getCurrentLocNo()), slave.getId()); if (basDevp == null) { LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), lev); if (liftStaProtocol == null) { continue; } return basDevp; list.add(liftStaProtocol); } return null; if (list.isEmpty()) { return null; } String currentLocNo = shuttleProtocol.getCurrentLocNo();//小车位置 Integer recentAllDistance = 9999999; LiftStaProtocol recentSta = null;//最近站点 //搜索距离小车最近的站点 for (LiftStaProtocol liftStaProtocol : list) { Integer staNo = liftStaProtocol.getStaNo();//站点号 String locNo = liftStaProtocol.getLocNo();//站点库位号 //当前穿梭车线程到目标地点距离 List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)));//使用正常通道地图 if (currentShuttlePath == null) { continue; } Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离 if (currentAllDistance < recentAllDistance) { //如果当前楼层的车路径更小,则更新最近站点 recentSta = liftStaProtocol; recentAllDistance = currentAllDistance; } } return recentSta; } } src/main/java/com/zy/core/model/LiftSlave.java
@@ -14,6 +14,12 @@ //提升机站点 private List<Sta> sta = new ArrayList<>(); //输送站点排 private Integer staRow; //输送站点列 private Integer staBay; @Data public static class Sta { @@ -23,6 +29,9 @@ // 层 private Integer lev; // 提升机号 private Integer liftNo; } } src/main/java/com/zy/core/model/protocol/LiftStaProtocol.java
@@ -84,4 +84,14 @@ */ private Integer lev; /** * 站点库位号 */ private String locNo; /** * 提升机号 */ private Integer liftNo; } src/main/java/com/zy/core/thread/LiftThread.java
@@ -13,6 +13,7 @@ import com.zy.asrs.mapper.WrkMastMapper; import com.zy.asrs.service.BasLiftOptService; import com.zy.asrs.service.BasLiftService; import com.zy.asrs.utils.Utils; import com.zy.common.utils.RedisUtil; import com.zy.core.News; import com.zy.core.ThreadHandler; @@ -55,6 +56,9 @@ LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); liftStaProtocol.setStaNo(sta.getStaNo());//站点号 liftStaProtocol.setLev(sta.getLev());//站点楼层 String locNo = Utils.getLocNo(this.slave.getStaRow(), this.slave.getStaBay(), sta.getLev()); liftStaProtocol.setLocNo(locNo);//站点库位号 liftStaProtocol.setLiftNo(sta.getLiftNo());//提升机号 liftStaProtocols.add(liftStaProtocol); }