Junjie
2023-04-14 b5dad5bca39b68fdaaaf844e38fcc55e94bb34f1
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -606,115 +606,6 @@
        }
    }
//    /**
//     * 入库  ===>>  四向穿梭车入库作业下发
//     */
//    public synchronized void shuttleIoInExecute() {
//        // 根据输送线plc遍历
//        for (DevpSlave devp : slaveProperties.getDevp()) {
//            // 遍历入库站
//            for (DevpSlave.StaRack rackInStn : devp.getRackInStn()) {
//                // 获取入库站信息
//                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
//
//                StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo());
//                StaProtocol staProtocol105 = devpThread.getStation().get(105);
//                staProtocol105.setWorkNo((short) 752);
//                staProtocol105.setStaNo((short) 100);
//
//                StaProtocol staProtocol106 = devpThread.getStation().get(106);
//                staProtocol106.setWorkNo((short) 753);
//                staProtocol106.setStaNo((short) 100);
//
//                if (staProtocol == null) {
//                    continue;
//                } else {
//                    staProtocol = staProtocol.clone();
//                }
//                Short workNo = staProtocol.getWorkNo();
//
//                // 判断是否满足入库条件
//                if (true || staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()) {
//                    WrkMast wrkMast = wrkMastMapper.selectRackInStep48(workNo, staProtocol.getSiteId());
//                    if (wrkMast != null) {
//                        if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) {
//                            ShuttleThread shuttleThread = null;
//                            HashMap<String, Object> searchIdleShuttle = null;
//                            if (wrkMast.getWrkSts() == 4) {
//                                //寻找最近且空闲的四向穿梭车
//                                searchIdleShuttle = this.searchIdleShuttle(wrkMast);
//                                shuttleThread = (ShuttleThread) searchIdleShuttle.get("result");
//                            }else {
//                                //状态8,四向穿梭车已在提升机口,等待命令进行入库搬运动作
//                                Integer shuttleNo = wrkMast.getShuttleNo();//四向穿梭车号
//                                shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
//                            }
//
//                            if (shuttleThread == null) {
//                                continue;
//                            }
//
//                            ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
//                            if (!shuttleProtocol.isIdle()) {
//                                continue;
//                            }
//
//                            wrkMast.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());//给工作档分配四向穿梭车号
//
//                            //分配任务号
//                            shuttleProtocol.setTaskNo(wrkMast.getWrkNo().shortValue());
//                            //分配源库位
//                            shuttleProtocol.setSourceLocNo(wrkMast.getSourceLocNo());
//
//                            ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
//                            //四向穿梭车号
//                            assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());
//                            //任务号
//                            assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
//                            //入出库模式
//                            assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue());
//                            //源库位(小车当前位置)
//                            String currentLocNo = shuttleProtocol.getCurrentLocNo();
//                            assignCommand.setSourceLocNo(currentLocNo);
//
//                            if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) {
//                                //同一层
//                                //分配目标库位
//                                shuttleProtocol.setLocNo(wrkMast.getLocNo());
//                                //目标库位
//                                assignCommand.setLocNo(wrkMast.getLocNo());
//                                wrkMast.setWrkSts(9L);//小车入库中
//
//                                //获取从小车
//                            }else {
//                                //不同层,将目标库位分配成提升机库位号
//
//                                //小车当前层高
//                                Integer currentLev = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length()));
//
//                                //获取提升机
//                                LiftSlave liftSlave = slaveProperties.getLift().get(0);
//                                //提升机库位号
//                                String liftLocNo = liftSlave.getLiftLocNo(currentLev);
//                                shuttleProtocol.setLocNo(liftLocNo);
//                                //目标库位
//                                assignCommand.setLocNo(liftLocNo);
//                                wrkMast.setWrkSts(5L);//小车迁移状态
//                            }
//
//                            if (wrkMastMapper.updateById(wrkMast) > 0) {
//                                //下发任务
//                                MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
//                            }
//                        }
//
//                    }
//                }
//
//            }
//        }
//
//    }
    /**
     * 入库  ===>>  四向穿梭车入库作业下发
@@ -728,13 +619,13 @@
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo());
//                StaProtocol staProtocol105 = devpThread.getStation().get(105);
//                staProtocol105.setWorkNo((short) 752);
//                staProtocol105.setStaNo((short) 100);
//
//                StaProtocol staProtocol106 = devpThread.getStation().get(106);
//                staProtocol106.setWorkNo((short) 753);
//                staProtocol106.setStaNo((short) 100);
                StaProtocol staProtocol105 = devpThread.getStation().get(105);
                staProtocol105.setWorkNo((short) 752);
                staProtocol105.setStaNo((short) 100);
                StaProtocol staProtocol106 = devpThread.getStation().get(106);
                staProtocol106.setWorkNo((short) 753);
                staProtocol106.setStaNo((short) 100);
                if (staProtocol == null) {
                    continue;
@@ -797,6 +688,19 @@
                                //同一层直接取货无需经过提升机
                                //直接计算车到提升机取货再到库位路径指令
                                List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo);
                                if (wrkMast.getWrkSts() == 8) {
                                    //此时车在提升机内部,需要多下达一步指令让车移动到提升机口
                                    BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息
                                    ShuttleCommand moveCommand = new ShuttleCommand();
                                    moveCommand.setCommandWord((short) 1);
                                    moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机内部二维码
                                    moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());//提升机口二维码
                                    moveCommand.setStartToDistDistance(1300);
                                    moveCommand.setMiddleToDistDistance(0);
                                    moveCommand.setRunDirection(commands.get(0).getRunDirection());
                                    moveCommand.setCommandEnd((short) 1);
                                    commands.add(0, moveCommand);//将该指令添加到队头
                                }
                                assignCommand.setCommands(commands);
                                //分配目标库位
                                shuttleProtocol.setLocNo(wrkMast.getLocNo());
@@ -851,17 +755,24 @@
            ShuttleCommand command = new ShuttleCommand();
            command.setCommandWord((short) 1);
            command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
            command.setMiddleCodeNum((short) 0);
            command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
            //通过xy坐标小车二维码
            Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
            command.setStartCodeNum(startCodeNum);
            command.setMiddleCodeNum((short) 1);
            //通过xy坐标小车二维码
            Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
            command.setDistCodeNum(distCodeNum);
            command.setStartToDistDistance(allDistance);
            command.setMiddleToDistDistance(1000);
            command.setMiddleToDistDistance(0);
            command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
            command.setPalletLift((short) 1);
            command.setForceMoveDistance(1000);
            command.setForceMoveDistance(0);
            command.setChargeSwitch((short) 2);
            command.setIOControl((short) 0);
            command.setRunSpeed((short) 1000);
            command.setRadarTmp((short) 0);
            command.setCommandEnd((short) 1);
            commands.add(command);
@@ -890,17 +801,24 @@
            ShuttleCommand command = new ShuttleCommand();
            command.setCommandWord((short) 1);
            command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
            command.setMiddleCodeNum((short) 0);
            command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
            //通过xy坐标小车二维码
            Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
            command.setStartCodeNum(startCodeNum);
            command.setMiddleCodeNum((short) 1);
            //通过xy坐标小车二维码
            Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
            command.setDistCodeNum(distCodeNum);
            command.setStartToDistDistance(allDistance);
            command.setMiddleToDistDistance(1000);
            command.setMiddleToDistDistance(0);
            command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
            command.setPalletLift((short) 1);
            command.setForceMoveDistance(1000);
            command.setForceMoveDistance(0);
            command.setChargeSwitch((short) 2);
            command.setIOControl((short) 0);
            command.setRunSpeed((short) 1000);
            command.setRadarTmp((short) 0);
            command.setCommandEnd((short) 1);
            commands.add(command);
@@ -930,17 +848,24 @@
            command = new ShuttleCommand();
            command.setCommandWord((short) 1);
            command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY()));
            command.setMiddleCodeNum((short) 0);
            command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY()));
            //通过xy坐标小车二维码
            Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ());
            command.setStartCodeNum(startCodeNum);
            command.setMiddleCodeNum((short) 1);
            //通过xy坐标小车二维码
            Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
            command.setDistCodeNum(distCodeNum);
            command.setStartToDistDistance(allDistance);
            command.setMiddleToDistDistance(1000);
            command.setMiddleToDistDistance(0);
            command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id);
            command.setPalletLift((short) 1);
            command.setForceMoveDistance(1000);
            command.setForceMoveDistance(0);
            command.setChargeSwitch((short) 2);
            command.setIOControl((short) 0);
            command.setRunSpeed((short) 1000);
            command.setRadarTmp((short) 0);
            command.setCommandEnd((short) 1);
            commands.add(command);
@@ -1056,6 +981,18 @@
                        }
                    } else if (wrkMast.getWrkSts() == 25) {
                        List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo);
                        //此时车在提升机内部,需要多下达一步指令让车移动到提升机口
                        BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息
                        ShuttleCommand moveCommand = new ShuttleCommand();
                        moveCommand.setCommandWord((short) 1);//小车移动指令字
                        moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机二维码
                        moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());
                        moveCommand.setStartToDistDistance(1300);
                        moveCommand.setMiddleToDistDistance(0);
                        moveCommand.setRunDirection(commands.get(0).getRunDirection());
                        moveCommand.setCommandEnd((short) 1);
                        commands.add(0, moveCommand);//将该指令添加到队头
                        //分配目标库位
                        shuttleProtocol.setLocNo(wrkMast.getSourceLocNo());
                        //目标库位