Junjie
2023-11-03 6f04f99ffcfc294280d65455f2430e01bc5126f8
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -863,6 +863,12 @@
                return false;//出库站点不可出
            }
            Integer liftNo = basDevp.getLiftNo();//搜索出库提升机是否存在入库任务,如存在禁止出库
            List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo);
            if (!liftWrkMasts.isEmpty()) {
                return false;//存在入库任务,禁止出库
            }
            //获取源站
            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo()));
            if (liftStaProtocol == null) {
@@ -1107,6 +1113,18 @@
            if (!sourceBasDevp.getInEnable().equals("Y")) {
                return false;//站点不可入
            }
            //判断提升机整个三楼是否都处于入库模式
            Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1);
            Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5);
            Integer outInModel3 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 8);
            if (outInModel1 == null || outInModel2 == null || outInModel3 == null) {
                return false;//不存在出入库模式
            }
            if (outInModel1 == 2 || outInModel2 == 2 && outInModel3 == 2) {
                return false;//只要有一个处于出库模式,禁止入库
            }
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo());
@@ -2015,10 +2033,10 @@
    }
    /**
     * AGV补货 => 机械臂拣料
     * AGV补货 => 生成入库通知档
     */
    public void agvRestockByRobot() {
        //检测300站是否自动、有物、工作号
    public void robotGenerateAgvTask() {
//检测300站是否自动、有物、工作号
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 获取入库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
@@ -2048,7 +2066,7 @@
                    } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) {
                        //自动、无物
                        targetSta = (short) 317;
                    }else {
                    } else {
                        continue;//没有空闲站点
                    }
@@ -2107,9 +2125,23 @@
                    }
                }
            }
        }
    }
    /**
     * AGV补货 => 机械臂拣料
     */
    public void agvRestockByRobot() {
        //检测300站是否自动、有物、工作号
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 获取入库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            StaProtocol staProtocol303 = devpThread.getStation().get(303);
            StaProtocol staProtocol317 = devpThread.getStation().get(317);
            if (staProtocol303 == null || staProtocol317 == null) {
                continue;
            }
            if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) {
                //调度机械臂
                //查询是否有工作档
@@ -2172,7 +2204,7 @@
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-301-001-01@3", barcode);
                    agvRestockCall("301-1", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            }
@@ -2186,7 +2218,7 @@
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-302-001-01@3", barcode);
                    agvRestockCall("302-1", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            }
@@ -2694,6 +2726,18 @@
                return false;
            }
            //获取源输送站
            LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
            if (liftSta == null) {
                return false;//找不到站点
            }
            //判断提升机是否有其他任务(该任务需要换层必须提前独占提升机)
            WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo());
            if (liftWrkMast != null) {
                return false;//当前提升机存在未完成任务,等待下一次轮询
            }
            //*************尝试锁定目标站路径***************
            List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(wrkMast.getStaNo());
            if (targetNodes == null) {
@@ -2709,18 +2753,6 @@
                return false;//路径锁定失败
            }
            //*************尝试锁定目标站路径***************
            //获取源输送站
            LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
            if (liftSta == null) {
                return false;//找不到站点
            }
            //判断提升机是否有其他任务(该任务需要换层必须提前独占提升机)
            WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo());
            if (liftWrkMast != null) {
                return false;//当前提升机存在未完成任务,等待下一次轮询
            }
            //获取小车到输送站点行走命令
            NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id);
@@ -3078,18 +3110,6 @@
                return false;//没有设置提升机点位坐标
            }
            //*************尝试解锁目标站路径***************
            List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
            if (targetNodes == null) {
                return false;//未获取到节点
            }
            //尝试解锁目标站路径
            boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//所使用的路径进行解锁
            if (!result) {
                return false;//路径解锁失败
            }
            //*************尝试解锁目标站路径***************
            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
            liftNode.setZ(liftSta.getLev());
@@ -3154,22 +3174,26 @@
                return false;
            }
//            //获取目标站对应的输送站点
//            BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
//            if (targetBasDevp == null) {
//                return false;//缺少站点信息
//            }
//            //跨楼层移动任务
//            if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
//                //获取目标站
//                LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
//                if (liftSta == null) {
//                    return false;//找不到站点
//                }
//
//            //获取提升机数据
//            BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo());
//            if (basLift == null) {
//                return false;//没有提升机数据
//                //*************尝试解锁目标站路径***************
//                List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
//                if (targetNodes == null) {
//                    return false;//未获取到节点
//                }
//                //尝试解锁目标站路径
//                boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//所使用的路径进行解锁
//                if (!result) {
//                    return false;//路径解锁失败
//                }
//                //*************尝试解锁目标站路径***************
//            }
//            if (basLift.getPoint() == null) {
//                return false;//没有设置提升机点位坐标
//            }
//            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
//            liftNode.setZ(basLift.getPoint$().getZ());
            //小车已经在目标库位,直接认定小车移动任务完成
            if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) {
@@ -3198,8 +3222,32 @@
                return false;
            }
            //获取小车到目标库位命令
            NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
            NyShuttleOperaResult result = null;
            //跨楼层移动任务
            if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
                //需要将前两个节点作为白名单节点传入
                //获取目标站
                LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
                if (liftSta == null) {
                    return false;//找不到站点
                }
                List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
                if (targetNodes == null) {
                    return false;//未获取到节点
                }
                //设置计算节点的白名单
                ArrayList<int[]> whiteList = new ArrayList<>();//设置计算节点的白名单
                for (NavigateNode node : targetNodes) {
                    whiteList.add(new int[]{node.getX(), node.getY()});
                }
                result = NyShuttleOperaUtils.getStartToTargetCommandsByWhites(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList);
            }else {
                //获取小车到目标库位命令
                result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
            }
            if (result == null) {
                return false;//路径计算失败
            }