自动化立体仓库 - WCS系统
#
Junjie
2023-09-20 49379100e381557f383f601616b2f6835295786d
#
4个文件已修改
236 ■■■■ 已修改文件
src/main/java/com/zy/asrs/mapper/WrkMastMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/WrkMastMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/WrkMastMapper.java
@@ -46,6 +46,8 @@
    WrkMast selectRackInStep4(Short workNo,Integer staNo);
    List<WrkMast> selectInStep4();
    WrkMast selectByWorkNo(Integer workNo);
    List<WrkMast> selectLiftStep223103();
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -665,6 +665,34 @@
     * 入库  ===>>  四向穿梭车入库作业下发
     */
    public synchronized void shuttleInExecute() {
        List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4();
        for (WrkMast wrkMast : wrkMasts) {
            //获取源站
            BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
            if (sourceBasDevp == null) {
                continue;//站点不存在
            }
            //获取目标站
            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo()));
            if (liftStaProtocol == null) {
                continue;//站点不存在
            }
            // 判断是否满足入库条件,自动、空闲、有物
            if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) {
                continue;
            }
            boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//小车搬入库中
            if (!step1) {
                continue;
            }
        }
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库站
@@ -688,30 +716,64 @@
                    continue;
                }
                WrkMast wrkMast = wrkMastMapper.selectRackInStep4(workNo, staProtocol.getSiteId());
                if (wrkMast == null) {
                    continue;
                }
                boolean step1 = this.shuttleInExecuteStep1(wrkMast, basDevp);//小车搬入库中
                if (!step1) {
                    continue;
                }
            }
        }
    }
//    /**
//     * 入库  ===>>  四向穿梭车入库作业下发
//     */
//    public synchronized void shuttleInExecute() {
//        // 根据输送线plc遍历
//        for (DevpSlave devp : slaveProperties.getDevp()) {
//            // 遍历入库站
//            for (DevpSlave.StaRack staRack : devp.getRackInStn()) {
//                // 获取入库站信息
//                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
//                StaProtocol staProtocol = devpThread.getStation().get(staRack.getStaNo());
//                if (staProtocol == null) {
//                    continue;
//                } else {
//                    staProtocol = staProtocol.clone();
//                }
//                Short workNo = staProtocol.getWorkNo();
//                BasDevp basDevp = basDevpService.selectById(staProtocol.getSiteId());
//                if (basDevp == null) {
//                    continue;//站点信息不存在
//                }
//
//                // 判断是否满足入库条件,自动、有物、四向穿梭车可取信号
//                if (!(staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isShuttleTakeEnable())) {
//                    continue;
//                }
//
//                WrkMast wrkMast = wrkMastMapper.selectRackInStep4(workNo, staProtocol.getSiteId());
//                if (wrkMast == null) {
//                    continue;
//                }
//
//                boolean step1 = this.shuttleInExecuteStep1(wrkMast, basDevp);//小车搬入库中
//                if (!step1) {
//                    continue;
//                }
//
//            }
//        }
//
//    }
    /**
     * 入库-小车搬入库中
     * 如需主方法执行continue,请返回false
     * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue
     */
    public boolean shuttleInExecuteStep1(WrkMast wrkMast, BasDevp basDevp) {
    public boolean shuttleInExecuteStep1(WrkMast wrkMast, LiftStaProtocol liftStaProtocol) {
        if (wrkMast.getWrkSts() == 4) {
            if (wrkMast.getShuttleNo() == null) {//没有绑定小车,进行调度
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), basDevp.getLocNo());//调度小车到货物所在输送站点进行取货
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//调度小车到货物所在输送站点进行取货
                return false;
            }
@@ -733,14 +795,14 @@
            }
            //判断小车是否到达输送站点库位
            if (!shuttleProtocol.getCurrentLocNo().equals(basDevp.getLocNo())) {
            if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
                //小车不在输送站点位置
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), basDevp.getLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在输送站点进行取货
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在输送站点进行取货
                return false;
            }
            //小车已抵达输送站点位置,进行搬运货物
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), basDevp.getLocNo(), wrkMast.getLocNo());
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo());
            if (result == null) {//路径计算失败
                return false;
            }
@@ -805,26 +867,15 @@
                return false;//出库站点不可出
            }
            //判断各楼层内部输送站点是否空闲无物
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo());
            if (liftThread == null) {
                return false;
            }
            //获取提升机站点list
            List<LiftStaProtocol> liftStaProtocols = liftThread.getLiftStaProtocols();
            if (liftStaProtocols.isEmpty()) {
                return false;
            //获取源站
            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo()));
            if (liftStaProtocol == null) {
                return false;//找不到站点
            }
            for (LiftStaProtocol liftStaProtocol : liftStaProtocols) {
                //判断当前出库任务对应楼层的提升机站点状态
                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getSourceLocNo())) {
                    if (liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray()) {
                        return false;//站点必须自动、空闲、没有托盘
                    }
                }
            if (liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray()) {
                return false;//站点必须自动、空闲、没有托盘
            }
            if (wrkMast.getShuttleNo() == null) {//没有绑定小车,进行调度
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到货物所在库位进行取货
@@ -851,12 +902,12 @@
            //判断小车是否到达货物库位
            if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
                //小车不在输送站点位置
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在输送站点进行取货
                shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在库位进行取货
                return false;
            }
            //小车已抵达货物位置,进行搬运货物
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), null);
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftStaProtocol.getLocNo());//将货物搬运至提升机输送站点
            if (result == null) {//出库路径计算失败
                return false;
            }
@@ -1047,7 +1098,17 @@
        //2.设备上走 ==> 3.提升机搬运中
        if (wrkMast.getWrkSts() == 2) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
            //获取源站
            BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
            if (sourceBasDevp == null) {
                return false;//找不到站点
            }
            if (!sourceBasDevp.getInEnable().equals("Y")) {
                return false;//站点不可入
            }
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo());
            if (liftThread == null) {
                return false;
            }
@@ -1055,37 +1116,38 @@
            if (liftProtocol == null) {
                return false;
            }
            if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
            if (!liftProtocol.isIdle()) {
                return false;
            }
            //判断提升机令牌是否未被占领
            if (liftProtocol.getToken() != 0) {
                return false;//提升机已被独占,禁止再派发任务
            }
            //判断提升机内是否有小车
            if (liftProtocol.getHasCar()) {
                return false;//有小车,禁止派发
            }
            //判断提升机内是否有托盘
            if (liftProtocol.getHasTray()) {
                return false;//有托盘,禁止派发
            }
            //判断提升机是否有其他任务
            WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId());
            if (liftWrkMast != null) {
                return false;//当前提升机存在未完成任务,等待下一次轮询
            }
            //获取源站对应的输送站点
            BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
            if (sourceBasDevp == null) {
                return false;//站点不存在
            }
            //获取源站对应的牛眼提升机站点编号(起点编号)
            Integer startSta = Integer.parseInt(sourceBasDevp.getQrCodeValue());
            Integer targetSta = null;
            //获取牛眼提升机站点编号(目标编号)
            for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getLocNo())) {
                    targetSta = liftStaProtocol.getStaNo();
                }
            //获取提升机站点
            LiftStaProtocol targetStaProtocol = NyLiftUtils.getLiftStaByLev(liftThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo()));
            if (targetStaProtocol == null) {
                return false;//站点不存在
            }
            if (targetSta == null) {
                return false;//站点编号不存在
            }
            Integer targetSta = targetStaProtocol.getStaNo();
            //获取提升机命令
            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
@@ -1124,7 +1186,17 @@
        //23.小车搬运完成 ==> 24.提升机搬运中
        if (wrkMast.getWrkSts() == 23) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
            //获取出库站点(目标站)
            BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo());
            if (basDevp == null) {
                return false;//出库站点不存在
            }
            if (!basDevp.getOutEnable().equals("Y")) {
                return false;//出库站点不可出
            }
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo());
            if (liftThread == null) {
                return false;
            }
@@ -1132,7 +1204,7 @@
            if (liftProtocol == null) {
                return false;
            }
            if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
            if (!liftProtocol.isIdle()) {
                return false;
            }
            //判断提升机令牌是否未被占领
@@ -1146,16 +1218,11 @@
            }
            //获取源站对应的牛眼提升机站点编号(起点编号)
            Integer startSta = null;
            for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getLocNo())) {
                    startSta = liftStaProtocol.getStaNo();
                }
            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftThread.getSlave().getId(), Utils.getLev(wrkMast.getSourceLocNo()));
            if (liftStaProtocol == null) {
                return false;//找不到站点
            }
            if (startSta == null) {
                return false;//站点编号不存在
            }
            Integer startSta = liftStaProtocol.getStaNo();
            //获目标站源站对应的输送站点
            BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo());
@@ -1166,7 +1233,7 @@
            Integer targetSta = Integer.parseInt(targetBasDevp.getQrCodeValue());
            //获取提升机命令
            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftThread.getSlave().getId(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
            ArrayList<NyLiftCommand> commands = new ArrayList<>();
            commands.add(liftCommand);
@@ -1327,7 +1394,7 @@
            }
            //小车已抵达源库位,进行搬运货物
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), wrkMast.getLocNo());
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getLocNo());
            if (result == null) {//路径计算失败
                return false;
            }
@@ -1396,7 +1463,7 @@
            Integer staNo = liftSta.getLiftNo() * 100 + Utils.getLev(wrkMast.getLocNo());//目标站
            //小车已抵达源库位,将货物搬运到输送站点
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo());
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo());
            if (result == null) {//路径计算失败
                return false;
            }
@@ -1487,7 +1554,7 @@
    }
    /**
     * 跨楼层库位移转-调度车辆取货并运送到目标枯萎
     * 跨楼层库位移转-调度车辆取货并运送到目标库位
     * 如需主方法执行continue,请返回false
     * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue
     */
@@ -1525,7 +1592,7 @@
            }
            //小车已抵达目标输送站点,将货物搬运到目标库位
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo());
            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo());
            if (result == null) {//路径计算失败
                return false;
            }
src/main/java/com/zy/common/utils/NyShuttleOperaUtils.java
@@ -19,6 +19,34 @@
     * @param shuttleNo 小车号
     * @param wrkNo 工作号
     * @param startPoint 起点(小车当前位置)
     * @param targetPoint 目标点(货物目标位置)
     */
    public static NyShuttleOperaResult getShuttleTransportCommands(Integer shuttleNo, Integer wrkNo, String startPoint, String targetPoint) {
        //行走路径
        ArrayList<NavigateNode> nodes = new ArrayList<>();
        //命令集合
        ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();
        //计算起点到目标点命令
        NyShuttleOperaResult result = getStartToTargetCommands(shuttleNo, wrkNo, startPoint, targetPoint);
        if (result == null) {
            //计算结果必须不为空,否则计算失败
            return null;
        }
        nodes.addAll(result.getNodes());
        //起点位置下发一条顶升命令将货物进行搬运
        commands.add(NyHttpUtils.getPalletLiftCommand(shuttleNo, wrkNo, true));
        commands.addAll(result.getCommands());//起点到目标点移动命令
        //当小车行走到目标点后,需要下发一条下降命令将货物放置
        commands.add(NyHttpUtils.getPalletLiftCommand(shuttleNo, wrkNo, false));
        return result(commands, nodes);
    }
    /**
     * 计算并获取小车从起点——中间点——目标点之间搬运货物动作命令
     * @param shuttleNo 小车号
     * @param wrkNo 工作号
     * @param startPoint 起点(小车当前位置)
     * @param middlePoint 中间点(货物位置)
     * @param targetPoint 目标点(货物目标位置)
     */
src/main/resources/mapper/WrkMastMapper.xml
@@ -117,6 +117,15 @@
        order by io_pri desc,wrk_sts desc
    </select>
    <select id="selectInStep4" resultMap="BaseResultMap">
        select *
        from dbo.asr_wrk_mast
        where 1=1
        and wrk_sts = 4
        and io_type in (1,10,53)
        order by io_pri desc,wrk_sts desc
    </select>
    <select id="selectByWorkNo" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast
        where wrk_no=#{workNo}