Junjie
2023-06-17 928bc386bea03b9d3157e6d66dcb7afc843e9964
小车从提升机移动出去增强管控
6个文件已修改
450 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 318 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/Utils.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateUtils.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/LiftProtocol.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LiftThread.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/ShuttleThread.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -670,12 +670,40 @@
                        if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) {
                            ShuttleThread shuttleThread = null;
                            HashMap<String, Object> searchIdleShuttle = null;
                            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1);
                            LiftProtocol liftProtocol = liftThread.getLiftProtocol();
                            if (wrkMast.getWrkSts() == 4) {
                                //寻找最近且空闲的四向穿梭车
                                searchIdleShuttle = this.searchIdleShuttle(wrkMast);
                                shuttleThread = (ShuttleThread) searchIdleShuttle.get("result");
                            }else {
                                //状态8,四向穿梭车已在提升机口,等待命令进行入库搬运动作
                            }else if(wrkMast.getWrkSts() == 8){//状态8,需要向小车下发命令从提升机移动出去,需要判断提升机状是否空闲、提升机是否到达目标楼层、目标楼层站点是否存在、目标楼层站点是否给出提升机到位信号
                                //状态8,等待命令进行入库搬运动作
                                //判断提升机是否空闲
                                if (!liftProtocol.isIdle()) {
                                    continue;//提升机忙
                                }
                                //判断提升机楼层是否到位,判断站点是否给出提升机到位信号
                                String locNo = wrkMast.getLocNo();
                                int lev = Utils.getLev(locNo);//目标二维码所在楼层
                                int liftLev = liftProtocol.getLev().intValue();//提升机所在楼层
                                if (liftLev != lev) {
                                    continue;//提升机不在目标楼层跳过
                                }
                                Integer staNo = Utils.levToOutInStaNo(lev);
                                //获取目标站信息
                                StaProtocol staProtocol1 = devpThread.getStation().get(staNo);
                                if (staProtocol1 == null) {
                                    continue;//站点信息不存在
                                }
                                if (!staProtocol1.isLiftArrival()) {
                                    continue;//站点提升机到位信号false
                                }
                                Integer shuttleNo = wrkMast.getShuttleNo();//四向穿梭车号
                                shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
                            }
@@ -705,7 +733,7 @@
                            assignCommand.setSourceLocNo(currentLocNo);//源库位(小车当前位置)
                            String locNo = wrkMast.getLocNo();//当前工作档库位号
                            Integer currentLev = Utils.getLev(currentLocNo);//小车当前层高
                            Integer currentLev = wrkMast.getWrkSts() == 4 ? Utils.getLev(currentLocNo) : liftProtocol.getLev();//小车当前层高
                            //提升机口站点库位号
                            String liftSiteLocNo = Utils.levToOutInStaLocNo(currentLev);
@@ -713,15 +741,17 @@
                            if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) {
                                //同一层直接取货无需经过提升机
                                //直接计算车到提升机取货再到库位路径指令
                                List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftSiteLocNo, locNo, assignCommand,shuttleThread);
                                List<ShuttleCommand> commands = this.shuttleAssignCommand(wrkMast.getWrkSts() == 4 ? currentLocNo : liftSiteLocNo, liftSiteLocNo, locNo, assignCommand, shuttleThread);
                                if (wrkMast.getWrkSts() == 8) {
                                    //此时车在提升机内部,需要多下达一步指令让车移动到提升机口
                                    BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息
                                    short startCode = Short.parseShort(basDevp.getQrCodeValue());//提升机内部二维码
                                    Short distCode = commands.get(0).getStartCodeNum();//提升机口二维码
                                    Short runDirection = commands.get(0).getRunDirection();//运行方向
                                    //此时车在提升机内部,下达一步指令让车移动到提升机口
                                    Integer staNo = Utils.levToOutInStaNo(currentLev);//站点号
                                    BasDevp basDevp = basDevpService.selectById(staNo);
                                    short startCode = liftProtocol.getBarcode();//提升机内部二维码
                                    Short distCode = Short.parseShort(basDevp.getQrCodeValue());//提升机口站点二维码
                                    Short runDirection = ShuttleRunDirection.BOTTOM.id;//运行方向
                                    //获取命令
                                    ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1300, runDirection, (short) 1, 0);
                                    ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1400, runDirection, startCode, 1400, 1000);
                                    commands.add(0, moveCommand);//将该指令添加到队头
                                }
                                assignCommand.setCommands(commands);
@@ -735,6 +765,15 @@
                                //小车移动到提升机口,计算路径
                                List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftSiteLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread);
                                //获取当前小车所在楼层的站点信息
                                BasDevp basDevp = basDevpService.queryByLocNo(liftSiteLocNo);
                                Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码
                                //增加移动进提升机命令
                                ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 1000);
                                commands.add(moveCommand);
                                //分配目标库位
                                shuttleProtocol.setLocNo(liftSiteLocNo);
                                //目标库位
@@ -923,11 +962,43 @@
                        || wrkMast.getWrkSts() == 31) {
                    ShuttleThread shuttleThread = null;
                    HashMap<String, Object> searchIdleShuttle = null;
                    LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1);
                    LiftProtocol liftProtocol = liftThread.getLiftProtocol();
                    if (wrkMast.getWrkSts() == 21) {
                        //寻找最近且空闲的四向穿梭车
                        searchIdleShuttle = this.searchIdleShuttle(wrkMast);
                        shuttleThread = (ShuttleThread) searchIdleShuttle.get("result");
                    }else if(wrkMast.getWrkSts() == 31 || wrkMast.getWrkSts() == 25) {
                    }else if(wrkMast.getWrkSts() == 25) {//状态25,需要向小车下发命令从提升机移动出去,需要判断提升机状是否空闲、提升机是否到达目标楼层、目标楼层站点是否存在、目标楼层站点是否给出提升机到位信号
                        //判断提升机是否空闲
                        if (!liftProtocol.isIdle()) {
                            continue;//提升机忙
                        }
                        //判断提升机楼层是否到位,判断站点是否给出提升机到位信号
                        String locNo = wrkMast.getSourceLocNo();
                        int lev = Utils.getLev(locNo);//目标二维码所在楼层
                        int liftLev = liftProtocol.getLev().intValue();//提升机所在楼层
                        if (liftLev != lev) {
                            continue;//提升机不在目标楼层跳过
                        }
                        Integer staNo = Utils.levToOutInStaNo(lev);
                        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                        //获取目标站信息
                        StaProtocol staProtocol1 = devpThread.getStation().get(staNo);
                        if (staProtocol1 == null) {
                            continue;//站点信息不存在
                        }
                        if (!staProtocol1.isLiftArrival()) {
                            continue;//站点提升机到位信号false
                        }
                        //继续完成之前小车未完成的任务
                        shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
                    } else if (wrkMast.getWrkSts() == 31) {
                        //继续完成之前小车未完成的任务
                        shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
                    }
@@ -995,6 +1066,15 @@
                            //小车到提升机口指令
                            List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftSiteLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread);
                            shuttleProtocol.setLocNo(liftSiteLocNo);
                            //获取当前小车所在楼层的站点信息
                            BasDevp basDevp = basDevpService.queryByLocNo(liftSiteLocNo);
                            Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码
                            //增加移动进提升机命令
                            ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 1000);
                            commands.add(moveCommand);
                            //目标库位
                            assignCommand.setLocNo(liftSiteLocNo);
                            assignCommand.setCommands(commands);
@@ -1032,10 +1112,13 @@
     */
    public HashMap<String,Object> searchIdleShuttle(WrkMast wrkMast) {
        HashMap<String, Object> map = new HashMap<>();
        String locNo = wrkMast.getWrkSts() < 10 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();//库位号
        String locNo = wrkMast.getIoType() < 101 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();//库位号
        LocMast locMast = locMastService.queryByLoc(locNo);//找到库位记录
        int lev = Utils.getLev(locNo);//当前工作档库位层高
        ShuttleThread recentShuttle = null;//当前距离最近的四向穿梭车线程
        ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车
        ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车
        for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
            //获取四向穿梭车线程
@@ -1051,58 +1134,131 @@
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();//二维码对应库位号
            int shuttleLocNoLey = Utils.getLev(shuttleLocNo);//库位号对应层高
            if (lev == shuttleLocNoLey) {
                //当前四向穿梭车和工作档任务在同一层,则调配该车辆
                map.put("sameLay", true);//同一层
                map.put("result", shuttleThread);
                return map;
            }
            //更新当前最近的四向穿梭车
            if (recentShuttle == null) {
                recentShuttle = shuttleThread;
                //工作档楼层相同的穿梭车
                sameLev.add(shuttleThread);
            }else {
                ShuttleProtocol recentShuttleProtocol = recentShuttle.getShuttleProtocol();//目前最近穿梭车
                String recentShuttleLocNo = recentShuttleProtocol.getCurrentLocNo();//二维码对应库位号
                String recentShuttleLocNoLay = recentShuttleLocNo.substring(recentShuttleLocNo.length() - 2, recentShuttleLocNo.length());//库位号对应层高
                int recentShuttleLocNoLayInt = Integer.parseInt(recentShuttleLocNoLay);
                int i = Math.abs(lev - recentShuttleLocNoLayInt);//工作档楼层减最近穿梭车楼层,取绝对值
                int j = Math.abs(lev - shuttleLocNoLey);//工作档楼层减当前穿梭车楼层,取绝对值
                if (i < j) {
                    //更新最近穿梭车
                    recentShuttle = shuttleThread;
                } else if (i == j) {
                    //楼层相同情况
                    //找距离出库点最近的车
                    if (!(recentShuttleProtocol.isIdle() && shuttleProtocol.isIdle())) {
                        //只要有一辆车不是空闲则不进行调度
                        map.put("sameLay", false);//不同层
                        map.put("result", null);
                        return map;
                    }
                    //获取提升机
                    LiftSlave liftSlave = slaveProperties.getLift().get(0);
                    //提升机库位号
                    String recentLiftLocNo = liftSlave.getLiftLocNo(recentShuttleLocNoLayInt);
                    String shuttleLiftLocNo = liftSlave.getLiftLocNo(shuttleLocNoLey);
                    //当前最近四向穿梭车到提升机路径
                    List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentShuttleLocNo, recentLiftLocNo, ShuttleTaskModeType.PAK_IN.id);
                    //当前楼层四向穿梭车到提升机路径
                    List<NavigateNode> shuttlePath = NavigateUtils.calc(shuttleLocNo, shuttleLiftLocNo, ShuttleTaskModeType.PAK_IN.id);
                    //判断哪一个路径最短
                    if (shuttlePath.size() < recentShuttlePath.size()) {
                        //如果当前楼层的车路径更小,则更新最近穿梭车
                        recentShuttle = shuttleThread;
                    }
                }
                //工作档不同楼层的穿梭车
                diffLev.add(shuttleThread);
            }
//
//            //更新当前最近的四向穿梭车
//            if (recentShuttle == null) {
//                recentShuttle = shuttleThread;
//            }else {
//                ShuttleProtocol recentShuttleProtocol = recentShuttle.getShuttleProtocol();//目前最近穿梭车
//                String recentShuttleLocNo = recentShuttleProtocol.getCurrentLocNo();//二维码对应库位号
//                String recentShuttleLocNoLay = recentShuttleLocNo.substring(recentShuttleLocNo.length() - 2, recentShuttleLocNo.length());//库位号对应层高
//
//                int recentShuttleLocNoLayInt = Integer.parseInt(recentShuttleLocNoLay);
//                int i = Math.abs(lev - recentShuttleLocNoLayInt);//工作档楼层减最近穿梭车楼层,取绝对值
//                int j = Math.abs(lev - shuttleLocNoLey);//工作档楼层减当前穿梭车楼层,取绝对值
//                if (i < j) {
//                    //更新最近穿梭车
//                    recentShuttle = shuttleThread;
//                } else if (i == j) {
//                    //楼层相同情况
//                    //找距离出库点最近的车
//
//                    if (!(recentShuttleProtocol.isIdle() && shuttleProtocol.isIdle())) {
//                        //只要有一辆车不是空闲则不进行调度
//                        map.put("sameLay", false);//不同层
//                        map.put("result", null);
//                        return map;
//                    }
//
//                    //获取提升机
//                    LiftSlave liftSlave = slaveProperties.getLift().get(0);
//                    //提升机库位号
//                    String recentLiftLocNo = liftSlave.getLiftLocNo(recentShuttleLocNoLayInt);
//                    String shuttleLiftLocNo = liftSlave.getLiftLocNo(shuttleLocNoLey);
//
//                    //当前最近四向穿梭车到提升机路径
//                    List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentShuttleLocNo, recentLiftLocNo, ShuttleTaskModeType.PAK_IN.id);
//                    //当前楼层四向穿梭车到提升机路径
//                    List<NavigateNode> shuttlePath = NavigateUtils.calc(shuttleLocNo, shuttleLiftLocNo, ShuttleTaskModeType.PAK_IN.id);
//                    //判断哪一个路径最短
//                    if (shuttlePath.size() < recentShuttlePath.size()) {
//                        //如果当前楼层的车路径更小,则更新最近穿梭车
//                        recentShuttle = shuttleThread;
//                    }
//                }
//            }
        }
        map.put("sameLay", false);//不同层
        map.put("result", recentShuttle);
        if (sameLev.size() > 0) {
            //同一楼层有空闲穿梭车,则只在工作档楼层寻找
            //寻找离任务最近的穿梭车
            for (ShuttleThread shuttleThread : sameLev) {
                if (recentShuttle == null) {//最近穿梭车为空,则默认赋予为最近穿梭车
                    recentShuttle = shuttleThread;
                }
                //判断其他空闲穿梭车是否离任务最近
                String distLocNo = null;//目标地点,入库=》提升机口,出库=》货物库位号
                if (wrkMast.getIoType() < 101) {
                    //入库
                    distLocNo = Utils.levToOutInStaLocNo(lev);
                }else {
                    //出库
                    distLocNo = locNo;
                }
                //当前穿梭车库位号
                String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
                //目前最近穿梭车库位号
                String recentLocNo = recentShuttle.getShuttleProtocol().getCurrentLocNo();
                //当前最近四向穿梭车到目标地点距离
                List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, distLocNo, ShuttleTaskModeType.PAK_IN.id);
                //当前穿梭车线程到目标地点距离
                List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, distLocNo, ShuttleTaskModeType.PAK_IN.id);
                if (recentShuttlePath == null || currentShuttlePath == null) {
                    continue;
                }
                Integer recentAllDistance = NavigateUtils.getOriginPathAllDistance(recentShuttlePath);//计算当前路径行走总距离
                Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
                if (currentAllDistance < recentAllDistance) {
                    //如果当前楼层的车路径更小,则更新最近穿梭车
                    recentShuttle = shuttleThread;
                }
            }
            map.put("sameLay", true);//同层
            map.put("result", recentShuttle);
        }else {
            //同一楼层,没有空闲穿梭车,只能从其他楼层调度
            //寻找离任务最近的穿梭车
            for (ShuttleThread shuttleThread : diffLev) {
                if (recentShuttle == null) {//最近穿梭车为空,则默认赋予为最近穿梭车
                    recentShuttle = shuttleThread;
                }
                //当前穿梭车库位号
                String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
                int currentLev = Utils.getLev(currentLocNo);
                //目前最近穿梭车库位号
                String recentLocNo = recentShuttle.getShuttleProtocol().getCurrentLocNo();
                int recentLev = Utils.getLev(recentLocNo);
                //当前最近四向穿梭车到当前车子所在楼层的提升机口距离
                List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, Utils.levToOutInStaLocNo(recentLev), ShuttleTaskModeType.PAK_IN.id);
                //当前穿梭车线程到当前车子所在楼层的提升机口距离
                List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, Utils.levToOutInStaLocNo(currentLev), ShuttleTaskModeType.PAK_IN.id);
                if (recentShuttlePath == null || currentShuttlePath == null) {
                    continue;
                }
                Integer recentAllDistance = NavigateUtils.getOriginPathAllDistance(recentShuttlePath);//计算当前路径行走总距离
                Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
                if (currentAllDistance < recentAllDistance) {
                    //如果当前楼层的车路径更小,则更新最近穿梭车
                    recentShuttle = shuttleThread;
                }
            }
            map.put("sameLay", false);//不同层
            map.put("result", recentShuttle);
        }
        return map;
    }
@@ -1293,7 +1449,20 @@
                commands.add(command4);//将命令添加进list
                wrkMast.setWrkSts(3L);//3.提升机搬运中
            }else if(wrkMast.getWrkSts() == 6 || wrkMast.getWrkSts() == 23) {//6.迁移小车至提升机口完成 => 7.提升机迁移小车中 || 23.迁移小车至提升机口完成 => 24.提升机迁移小车中
            } else if (wrkMast.getWrkSts() == 6) {//6.迁移小车至提升机口完成 => 7.提升机迁移小车中
                liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号
                //工作档目标库位号
                String wrkMastLocNo = wrkMast.getIoType() == 101 ? wrkMast.getSourceLocNo() : wrkMast.getLocNo();
                //工作档目标库位楼层
                int wrkMastLocNoLey = Utils.getLev(wrkMastLocNo);
                //提升机前往目标楼层(工作档目标楼层)
                LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey);
                commands.add(command1);//将命令添加进list
                wrkMast.setWrkSts(7L);//6.迁移小车至提升机口完成 => 7.提升机迁移小车中
            } else if(wrkMast.getWrkSts() == 23) {//23.迁移小车至提升机口完成 => 24.提升机迁移小车中
                liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号
                //找到四向穿梭车的线程
@@ -1345,7 +1514,7 @@
                LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1);
                commands.add(command4);//将命令添加进list
                wrkMast.setWrkSts(wrkMast.getWrkSts() == 6 ? 7L : 24L);//6.迁移小车至提升机口完成 => 7.提升机迁移小车中 || 23.迁移小车至提升机口完成 => 24.提升机迁移小车中
                wrkMast.setWrkSts(24L);//23.迁移小车至提升机口完成 => 24.提升机迁移小车中
            } else if (wrkMast.getWrkSts() == 27) {//27.小车出库搬运完成
                //工作档源库位号
                String wrkMastLocNo = wrkMast.getSourceLocNo();
@@ -1421,31 +1590,6 @@
            if (liftProtocol == null) {
                continue;
            }
//            //当提升机状态处于工作中,但提升机实际为空闲状态,且时长超过30秒,自动复位
//            if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WORKING.id
//                    && liftProtocol.getTaskNo() != 0
//                    && !liftProtocol.getRunning()
//            ) {
//                if (liftProtocol.getWrkTime() == null) {
//                    continue;
//                }
//
//                Date wrkTime = liftProtocol.getWrkTime();
//                Date now = new Date();
//                long interval = (now.getTime() - wrkTime.getTime()) / 1000;//计算时间差
//                if (interval >= 30) {//超过30秒自动复位
//                    //设置提升机为空闲状态
//                    liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
//                    //任务号清零
//                    liftProtocol.setTaskNo((short) 0);
//                    //标记复位
//                    liftProtocol.setPakMk(true);
//                    //任务指令清零
//                    liftProtocol.setAssignCommand(null);
//                    News.info("提升机已确认且任务完成状态,复位。提升机号={}", liftProtocol.getLiftNo());
//                }
//            }
            //提升机为等待确认且空闲
            if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id
src/main/java/com/zy/asrs/utils/Utils.java
@@ -309,6 +309,26 @@
        return staNo;
    }
    //提升机位置反馈转换出入库站点库位号
    public static String liftArrivalToOutInStaLocNo(Short liftArrival) {
        String locNo = null;
        switch (liftArrival) {
            case 1:
                locNo = "1800201";
                break;
            case 4:
                locNo = "1800202";
                break;
            case 8:
                locNo = "1800203";
                break;
            case 16:
                locNo = "1800204";
                break;
        }
        return locNo;
    }
    //楼层转换对应出入库站点库位号
    public static String levToOutInStaLocNo(Integer lev) {
        String locNo = null;
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -184,6 +184,19 @@
    }
    /**
     * 根据原始节点结果,计算总行走距离
     */
    public static Integer getOriginPathAllDistance(List<NavigateNode> path) {
        ArrayList<ArrayList<NavigateNode>> sectionPath = NavigateUtils.getSectionPath(path);
        Integer allDistance = 0;
        for (ArrayList<NavigateNode> navigateNodes : sectionPath) {
            Integer distance = NavigateUtils.getCurrentPathAllDistance(navigateNodes);
            allDistance += distance;
        }
        return allDistance;
    }
    /**
     * 获取当前路径总行走距离
     */
    public static Integer getCurrentPathAllDistance(List<NavigateNode> path) {
src/main/java/com/zy/core/model/protocol/LiftProtocol.java
@@ -269,8 +269,45 @@
    }
    public void setPositionArrivalFeedback(Short position) {
        this.lev = position;//层高
        Short lev = 1;
        switch (position) {
            case 1:
                lev = 1;
                break;
            case 4:
                lev = 2;
                break;
            case 8:
                lev = 3;
                break;
            case 16:
                lev = 4;
                break;
        }
        this.lev = lev;//层高
        this.positionArrivalFeedback = position;//位置到达反馈
    }
    public Integer getPositionArrivalFeedback$() {
        if (this.positionArrivalFeedback == null) {
            return null;
        }
        switch (this.positionArrivalFeedback) {
            case 1:
                return 1;
            case 2:
                return 2;
            case 4:
                return 3;
            case 8:
                return 4;
            case 16:
                return 5;
        }
        return null;
    }
}
src/main/java/com/zy/core/thread/LiftThread.java
@@ -6,6 +6,7 @@
import HslCommunication.ModBus.ModbusTcpNet;
import com.alibaba.fastjson.JSON;
import com.core.common.DateUtils;
import com.core.common.RadixTools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasLift;
@@ -21,7 +22,6 @@
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.LiftSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.*;
@@ -127,7 +127,7 @@
                liftProtocol.setLiftLock(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content, 0)));
                //位置到达反馈
                liftProtocol.setPositionArrivalFeedback(modbusTcpNet.getByteTransform().TransInt16(content,2));
                byte by = modbusTcpNet.getByteTransform().TransByte(content, 5);
                int[] datas = CommonUtils.byteToBits(by);
                //准备就绪
@@ -400,6 +400,12 @@
            News.info("提升机命令下发成功,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
            liftProtocol.setWrkTime(new Date());//更新工作时间
            try {
                Thread.sleep(1000);//命令下发完成后休眠1s
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //判断数据是否执行完成
            if (commandStep < size - 1) {
                //更新redis数据
src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -525,8 +525,8 @@
                    //如果穿梭车在提升机内,移动时需要先下发出提升机命令
                    if (liftProtocol.getBarcode().intValue() == shuttleProtocol.getCurrentCode().intValue()) {
                        //穿梭车出提升机
                        Short liftLev = liftProtocol.getPositionArrivalFeedback();//提升机位置
                        String liftSiteLocNo = Utils.levToOutInStaLocNo(liftLev.intValue());
                        Short liftArrival = liftProtocol.getPositionArrivalFeedback();//提升机位置反馈
                        String liftSiteLocNo = Utils.liftArrivalToOutInStaLocNo(liftArrival);
                        LocMast locMast1 = locMastService.selectById(liftSiteLocNo);
                        ShuttleCommand moveCommand = getMoveCommand(liftProtocol.getBarcode(), Short.parseShort(locMast1.getQrCodeValue()), 1400, ShuttleRunDirection.BOTTOM.id, liftProtocol.getBarcode(), 1400, runSpeed);
                        commands.add(moveCommand);
@@ -745,6 +745,42 @@
        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1);
        LiftProtocol liftProtocol = liftThread.getLiftProtocol();
        //判断小车当前二维码是否为提升机二维码
        if (shuttleProtocol.getCurrentCode().intValue() == liftProtocol.getBarcode().intValue()) {
            //小车当前命令起始位置就是提升机二维码,说明小车需要向提升机外移动,则需要判断状态是否满足
            if (command.getStartCodeNum().intValue() == liftProtocol.getBarcode().intValue()){
                //提升机是否空闲,提升机是否到达目标楼层,目标楼层是否给出提升机到位信号位
                if (!liftProtocol.isIdle()) {
                    return false;//提升机忙,禁止下发命令
                }
                Short distCodeNum = command.getDistCodeNum();//目标二维码
                BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
                BasDevp basDevp = basDevpService.queryByQrCode(distCodeNum.intValue());//目标站点
                if (basDevp == null) {
                    return false;//找不到目标站,禁止下发命令
                }
                int lev = Utils.getLev(basDevp.getLocNo());//目标二维码所在楼层
                int liftLev = liftProtocol.getLev().intValue();//提升机所在楼层
                if (liftLev != lev) {
                    return false;//提升机不在目标楼层,禁止下发命令
                }
                //获取目标站信息
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                StaProtocol staProtocol = devpThread.getStation().get(basDevp.getDevNo());
                if (staProtocol == null) {
                    return false;//站点信息不存在,禁止下发命令
                }
                if (!staProtocol.isLiftArrival()) {
                    return false;//站点提升机到位信号false,禁止下发命令
                }
            }
        }
        //下发命令
        if (!write(command)) {
@@ -752,6 +788,12 @@
            return false;
        } else {
            News.info("四向穿梭车命令下发成功,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
            try {
                Thread.sleep(1000);//命令下发完后休眠1s
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //判断数据是否执行完成
            if (commandStep < size - 1) {
@@ -906,7 +948,7 @@
        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();//二维码对应库位号
        Integer shuttleLocNoLev = shuttleLocNo == null ? 0 : Utils.getLev(shuttleLocNo);//库位号对应层高
        //判断提升机是否在目标楼层
        //判断穿梭车和提升机是否在目标楼层
        if (shuttleLocNoLev >= 2) {
            shuttleLocNoLev++;
        }
@@ -916,7 +958,7 @@
            SiemensDevpThread siemensDevpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
            StaProtocol staProtocol = siemensDevpThread.getStation().get(siteNo);
            if (staProtocol.isLiftArrival()
                && liftProtocol.getPositionArrivalFeedback().intValue() == shuttleLocNoLev) {
                && liftProtocol.getPositionArrivalFeedback$() == shuttleLocNoLev) {
                //输送线反馈提升机到位且提升机楼层反馈为同一层,直接放行
                return true;
            }