自动化立体仓库 - WCS系统
#
Junjie
2023-10-14 ae0d613e60b2308d23b2760d514d0ff3356bfa48
src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -336,6 +336,7 @@
            );
            opt.setSend(1);//已下发
            opt.setResponse(JSON.toJSONString(result));//请求响应
            opt.setDeviceWrk(command.getWrkNo().toString());//设备工作号
            shuttleOptService.insert(opt);
        }
@@ -369,6 +370,7 @@
        }
        WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class);
        WrkMast wrkMast = wrkMastMapper.selectByWorkNo(wrkNo.intValue());
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        if (o == null) {
@@ -446,8 +448,9 @@
        }
        if (shuttleProtocol.getFree() == ShuttleStatusType.BUSY.id) {
            //停止充电
            if(!(command.getRequest().getBody().get("requestType").equals("stopCharge") && shuttleProtocol.getChargState() == 1)){
            String requestType = command.getRequest().getBody().get("requestType").toString();
            //停止充电 管制命令
            if(!(requestType.equals("stopCharge") && shuttleProtocol.getChargState() == 1) && !requestType.equals("resume")){
                return false;//小车状态忙,禁止执行命令
            }
        }
@@ -463,8 +466,15 @@
        }
        if (command.getRequest().getBody().get("requestType").equals("move")) {
            ArrayList<int[]> whiteList = new ArrayList<>();//设置节点的白名单
            if (wrkMast != null && ((wrkMast.getIoType() > 100 && wrkMast.getIoType() < 200) || wrkMast.getIoType() == 11)) {
                //出库任务,不检测首节点
                int[] startArr = NavigatePositionConvert.positionToXY(wrkMast.getSourceLocNo());//开始节点
                whiteList.add(startArr);
            }
            //检测路径是否可行走
            if (!checkPath(command.getNodes(), nextNodes, redisCommand)) {
            if (!checkPath(command.getNodes(), nextNodes, whiteList)) {
                return false;
            }
@@ -634,17 +644,17 @@
     * 检测路径是否可行走
     * 如果路径为目标库位,但不可行走,系统将尝试重新计算路径
     */
    private boolean checkPath(List<NavigateNode> currentNodes, List<NavigateNode> nextNodes, ShuttleRedisCommand redisCommand) {
    private boolean checkPath(List<NavigateNode> currentNodes, List<NavigateNode> nextNodes, List<int[]> whitePoints) {
        //检测路径是否可行走(检查路径锁定状态,检测路径是否有其他小车)
        //检测当前行走路径,和下一步路径
        boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(currentNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()));
        boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(currentNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), whitePoints);
        if (nextNodes == null) {
            if (checkPathIsAvailable) {
                return true;//可行走
            }
            return false;
        }else {
            boolean checkPathIsAvailable2 = NavigateUtils.checkPathIsAvailable(nextNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()));
            boolean checkPathIsAvailable2 = NavigateUtils.checkPathIsAvailable(nextNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()), whitePoints);
            if (checkPathIsAvailable && checkPathIsAvailable2) {
                return true;//可行走
            }
@@ -705,6 +715,19 @@
            return;
        }
        if (shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
            //跑库结束
            shuttleProtocol.setMoveLoc(false);
            shuttleProtocol.setMoveType(0);
            shuttleProtocol.setXStart(0);
            shuttleProtocol.setXTarget(0);
            shuttleProtocol.setXCurrent(0);
            shuttleProtocol.setYStart(0);
            shuttleProtocol.setYTarget(0);
            shuttleProtocol.setYCurrent(0);
            return;
        }
        if (shuttleProtocol.getMoveType() == 0) {//跑轨道
            ArrayList<String> locs = new ArrayList<>();
            for (int i = shuttleProtocol.getXCurrent(); i <= shuttleProtocol.getXTarget(); i++) {
@@ -735,7 +758,35 @@
                }
            }
        }else {//跑库位
            Integer xCurrent = shuttleProtocol.getXCurrent();
            if (xCurrent > shuttleProtocol.getXTarget()) {//当X值大于X目标值,进行归零且Y方向+1
                shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());
                shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);
                return;
            }
            Integer yCurrent = shuttleProtocol.getYCurrent();
            String locNo = Utils.getLocNo(xCurrent, yCurrent, lev);
            LocMast target = locMastService.selectById(locNo);
            if (target == null) {
                shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
                return;
            }
            if (!target.getLocSts().equals("O")) {
                shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
                return;
            }
            //调度去目标位置
            if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) {
                shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//小车和目标位置一致,跳过
            }else {
                boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), target.getLocNo());
                if (result) {//调度成功
                    shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
                }
            }
        }
    }