#
Junjie
4 天以前 73ce8bebcc5d14f3fb62a19ee677abfcdfc776b4
#
14个文件已修改
304 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/ConsoleController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ShuttleController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/Utils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/enums/NavigationMapType.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateMapData.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateMapUtils.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateSolution.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateUtils.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/action/ShuttleAction.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/task/ShuttleDemoScheduler.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -90,7 +90,8 @@
        BasMap basMap = JSON.parseObject(data.toString(), BasMap.class);
        //解析json地图数据
        ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
        List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//过滤地图数据
        List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//过滤地图数据
        return R.ok().add(lists);
    }
src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -310,11 +310,11 @@
        if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
            //移动到目标库位
            Integer mapType = NavigationMapType.NORMAL.id;
            List<NavigationMapType> mapTypes = NavigationMapType.getMapTypes(NavigationMapType.NORMAL);
            if (shuttleProtocol.getHasLift()) {
                mapType = NavigationMapType.DFX.id;
                mapTypes = NavigationMapType.getMapTypes(NavigationMapType.DFX);
            }
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapTypes, assignCommand, shuttleThread);
            if (commands == null) {
                throw new CoolException("路径计算失败");
            }
@@ -354,7 +354,7 @@
            return R.ok();
        } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_TASK) {
            //移动到目标库位(生成移动任务)
            shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(WrkIoType.LOC_MOVE.id), param.getDistLocNo(), param.getShuttleNo());
            shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(WrkIoType.SHUTTLE_MOVE.id), param.getDistLocNo(), param.getShuttleNo());
            return R.ok();
        } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_DEMO_OPEN) {
            //演示模式-开
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -196,7 +196,7 @@
            assignCommand.setAuto(true);//自动模式
            //获取小车到输送站点行走命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;
@@ -334,7 +334,7 @@
                //强制预留一台小车给入库任务
                int lev = Utils.getLev(wrkMast.getSourceLocNo());
                //获取当前楼层有几台可用小车
                int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev);
                int shuttleCount = shuttleDispatchUtils.getShuttleEnableUseCountByLev(lev);
                if (shuttleCount >= 2) {//只有可用小车数量大于2,才进行入库任务预留小车
                    int shuttleWrkInObligateCount = 1;//预留小车数量
                    Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1));
@@ -393,7 +393,7 @@
            assignCommand.setAuto(true);//自动模式
            //获取小车到输送站点行走命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;
@@ -601,7 +601,7 @@
            assignCommand.setAuto(true);//自动模式
            //获取小车到输送站点行走命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;
@@ -1585,7 +1585,7 @@
            assignCommand.setAuto(true);//自动模式
            //计算近点位置
            String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, null, null, 1);
            String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1);
            if (endLocation == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,小车近点位置计算失败", wrkMast.getWrkNo());
                return false;
@@ -1601,7 +1601,7 @@
            }
            //获取小车到近点行走命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.SHUTTLE), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;//路径解锁失败
@@ -1716,7 +1716,7 @@
            assignCommand.setAuto(true);//自动模式
            //获取小车到提升机行走命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;//路径解锁失败
@@ -1900,7 +1900,7 @@
            assignCommand.setLocNo(wrkMast.getLocNo());//目标库位
            //获取小车到目标库位命令
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread);
            if (commands == null) {
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
                return false;//路径计算失败
src/main/java/com/zy/asrs/utils/Utils.java
@@ -252,7 +252,7 @@
        String recentLocNo = null;
        for (LocMast locMast : locMasts) {
            //待机位到目标点距离
            List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//搜索空闲穿梭车,使用正常通道地图
            List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//搜索空闲穿梭车,使用正常通道地图
            if (currentShuttlePath == null) {
                continue;
            }
src/main/java/com/zy/common/model/enums/NavigationMapType.java
@@ -1,10 +1,15 @@
package com.zy.common.model.enums;
import java.util.ArrayList;
import java.util.List;
public enum NavigationMapType {
    NONE(-1, "无过滤"),
    DFX(1, "过滤库位状态DFX"),
    NORMAL(2, "过滤库位状态X"),
    DFX(1, "地图携带库位状态DFX"),
    NORMAL(2, "地图携带库位状态X"),
    SHUTTLE(3, "地图携带小车"),
    LIFT(4, "地图携带提升机"),
    ;
    public Integer id;
@@ -39,4 +44,20 @@
        return null;
    }
    public static List<NavigationMapType> getDfxWithDevice() {
        return getMapTypes(DFX, SHUTTLE, LIFT);
    }
    public static List<NavigationMapType> getNormalWithDevice() {
        return getMapTypes(NORMAL, SHUTTLE, LIFT);
    }
    public static List<NavigationMapType> getMapTypes(NavigationMapType... types) {
        List<NavigationMapType> mapTypes = new ArrayList<>();
        for (NavigationMapType type : types) {
            mapTypes.add(type);
        }
        return mapTypes;
    }
}
src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -35,14 +35,14 @@
    @Autowired
    private BasMapService basMapService;
    public int[][] getData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
    public int[][] getData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        try {
            BasMap basMap = basMapService.selectLatestMap(lev);
            String originData = basMap.getOriginData();
            //解析json地图数据
            ArrayList arrayList = JSON.parseObject(originData, ArrayList.class);
            List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
            List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
            int[][] map = new int[lists.size()][];
            int j = 0;
            for (List<MapNode> list : lists) {
@@ -66,7 +66,7 @@
    /**
     * 尝试从redis获取数据
     */
    public int[][] getDataFromRedis(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
    public int[][] getDataFromRedis(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        Object o = redisUtil.get(RedisKeyType.MAP.key + lev);
        if (o == null) {
@@ -74,15 +74,15 @@
        }
        BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
        return this.getDataFormString(lev, basMap.getData(), mapType, whitePoints, shuttlePoints);
        return this.getDataFormString(lev, basMap.getData(), mapTypes, whitePoints, shuttlePoints);
    }
    /**
     * 从List数据中获取地图
     */
    public int[][] getDataFormString(Integer lev, String data, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
    public int[][] getDataFormString(Integer lev, String data, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        ArrayList arrayList = JSON.parseObject(data, ArrayList.class);
        List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
        List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
        int[][] map = new int[lists.size()][];
        int j = 0;
        for (List<MapNode> list : lists) {
@@ -139,18 +139,30 @@
     * @param whitePoints 白名单节点,不需要被过滤
     * @param shuttlePoints 穿梭车节点,需要加载进地图
     */
    public List<List<MapNode>> filterMap(Integer mapType, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
    public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        //重建数据格式
        List<List<MapNode>> lists = rebuildData(arrayList);
        //载入库位信息
        lists = loadLocMast(mapType, lists, lev, whitePoints);
        List<NavigationMapType> locMapType = new ArrayList<>();
        locMapType.add(NavigationMapType.NONE);
        locMapType.add(NavigationMapType.DFX);
        locMapType.add(NavigationMapType.NORMAL);
        for (NavigationMapType mapType : mapTypes) {
            if(locMapType.contains(mapType)) {
                //载入库位信息
                lists = loadLocMast(mapType.id, lists, lev, whitePoints);
            }
        //加载车辆
        lists = loadShuttle(lists, shuttlePoints);
            if (mapType.equals(NavigationMapType.SHUTTLE)) {
                //加载车辆
                lists = loadShuttle(lists, shuttlePoints);
            }
        //加载货叉提升机点位
        lists = loadForkLift(lists, mapType, lev);
            if (mapType.equals(NavigationMapType.SHUTTLE)) {
                //加载货叉提升机点位
                lists = loadForkLift(lists, lev);
            }
        }
        //加载白名单节点
        lists = loadWhite(lists, lev, whitePoints);
@@ -283,7 +295,7 @@
    }
    //加载货叉提升机点位
    public List<List<MapNode>> loadForkLift(List<List<MapNode>> lists, Integer mapType, Integer lev) {
    public List<List<MapNode>> loadForkLift(List<List<MapNode>> lists, Integer lev) {
        try {
            //加载货叉提升机放货点位数据
            List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
@@ -304,16 +316,16 @@
                    List<MapNode> list = lists.get(row);
                    MapNode mapNode = list.get(bay);
                    if (mapType == NavigationMapType.DFX.id) {
                        //车辆有货
                        if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) {
                            mapNode.setValue(MapNodeType.DISABLE.id);
                        }
                    } else {
                        if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) {
                            mapNode.setValue(MapNodeType.CAR.id);
                        }
                    }
//                    if (mapType == NavigationMapType.DFX.id) {
//                        //车辆有货
//                        if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) {
//                            mapNode.setValue(MapNodeType.DISABLE.id);
//                        }
//                    } else {
//                        if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) {
//                            mapNode.setValue(MapNodeType.CAR.id);
//                        }
//                    }
                    //更新list
                    list.set(bay, mapNode);
src/main/java/com/zy/common/utils/NavigateMapUtils.java
@@ -48,7 +48,10 @@
            BasMap basMap = JSON.parseObject(o.toString(), BasMap.class);
            ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
            //带小车地图
            List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, shuttlePoints);//获取带小车地图数据
            List<NavigationMapType> mapTypes = new ArrayList<>();
            mapTypes.add(NavigationMapType.NONE);
            mapTypes.add(NavigationMapType.SHUTTLE);
            List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(mapTypes, arrayList, lev, null, shuttlePoints);//获取带小车地图数据
            //获取全部地图数据
            List<List<MapNode>> lists = navigateMapData.rebuildData(arrayList);
src/main/java/com/zy/common/utils/NavigateSolution.java
@@ -5,6 +5,7 @@
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.common.model.NavigateNode;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.core.enums.MapNodeType;
import com.zy.core.model.PythonResult;
import com.zy.system.entity.Config;
@@ -25,10 +26,10 @@
    int[][] map = {{}};
    public NavigateSolution(Integer mapType, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
    public NavigateSolution(List<NavigationMapType> mapTypes, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        //载入地图指定层高地图
        NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class);
        int[][] data = mapData.getDataFromRedis(lev, mapType, whitePoints, shuttlePoints);
        int[][] data = mapData.getDataFromRedis(lev, mapTypes, whitePoints, shuttlePoints);
        if (data == null) {
            throw new CoolException("地图未载入!");
        }
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -32,11 +32,11 @@
    @Autowired
    private NavigateMapData navigateMapData;
    public List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) {
        return calcJava(startPoint, endPoint, mapType, shuttlePoints, whites);
    public List<NavigateNode> calc(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) {
        return calcJava(startPoint, endPoint, mapTypes, shuttlePoints, whites);
    }
    public List<NavigateNode> calcJava(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) {
    public List<NavigateNode> calcJava(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) {
        //通过开始编号和结束编号获取对应的xy轴坐标
        int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//开始节点
        int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//结束节点
@@ -49,7 +49,7 @@
        //获取当前节点计算的层高,并赋值到每一个节点中
        int lev = Utils.getLev(startPoint);
        NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
        NavigateSolution solution = new NavigateSolution(mapTypes, lev, whiteList, shuttlePoints);
        int[][] map = solution.map;
        //初始化开始节点
@@ -109,7 +109,7 @@
        return list;
    }
    public List<NavigateNode> calcPython(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites) {
    public List<NavigateNode> calcPython(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites) {
        //通过开始编号和结束编号获取对应的xy轴坐标
        int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//开始节点
        int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//结束节点
@@ -122,7 +122,7 @@
        //获取当前节点计算的层高,并赋值到每一个节点中
        int lev = Utils.getLev(startPoint);
        NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints);
        NavigateSolution solution = new NavigateSolution(mapTypes, lev, whiteList, shuttlePoints);
        int[][] map = solution.map;
        //初始化开始节点
@@ -189,9 +189,9 @@
    }
    //计算带末端段落路径
    public ArrayList<ArrayList<NavigateNode>> calcEndPath(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) {
    public ArrayList<ArrayList<NavigateNode>> calcEndPath(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) {
        //计算路径
        List<NavigateNode> navigateNodes = calc(startPoint, endPoint, mapType, shuttlePoints, whites);
        List<NavigateNode> navigateNodes = calc(startPoint, endPoint, mapTypes, shuttlePoints, whites);
        if (navigateNodes == null) {
            News.error("{} dash {} can't find navigate path!", startPoint, endPoint);
            return null;
@@ -215,8 +215,8 @@
    }
    //计算末端段落地址
    public String calcEndLocation(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) {
        ArrayList<ArrayList<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapType, shuttlePoints, whites, lastPathPart);
    public String calcEndLocation(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) {
        ArrayList<ArrayList<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapTypes, shuttlePoints, whites, lastPathPart);
        if (endPath == null) {
            return null;
        }
@@ -403,7 +403,7 @@
     * 检测路径是否可用(可走)
     */
    public boolean checkPathIsAvailable(List<NavigateNode> path, Integer shuttleNo, Integer lev) {
        int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.DFX.id, null, Utils.getShuttlePoints(shuttleNo, lev));
        int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.getDfxWithDevice(), null, Utils.getShuttlePoints(shuttleNo, lev));
        for (NavigateNode node : path) {
            int value = map[node.getX()][node.getY()];
            if (value != MapNodeType.NORMAL_PATH.id && value != MapNodeType.MAIN_PATH.id && value != MapNodeType.CHARGE.id && value != MapNodeType.CONVEYOR_CAR_GO.id) {//母轨道3、子轨道0、充电桩5、小车可走输送站
@@ -479,7 +479,7 @@
    public boolean checkLocPathIsAvailable(String startLocNo, String endLocNo) {
        List<int[]> shuttlePoints = Utils.getShuttlePoints(0, Utils.getLev(startLocNo));
        //计算库位到提升机库位,路径是否可用
        List<NavigateNode> nodeList = this.calc(startLocNo, endLocNo, NavigationMapType.DFX.id, shuttlePoints, null);
        List<NavigateNode> nodeList = this.calc(startLocNo, endLocNo, NavigationMapType.getMapTypes(NavigationMapType.DFX), shuttlePoints, null);
        if (nodeList == null) {
            return false;
        }
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
@@ -10,6 +10,7 @@
import com.zy.asrs.utils.Utils;
import com.zy.common.model.MapNode;
import com.zy.common.model.NavigateNode;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
@@ -50,11 +51,11 @@
    @Autowired
    private DeviceConfigService deviceConfigService;
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
        return getStartToTargetCommands(startLocNo, endLocNo, mapType, null, assignCommand, shuttleThread);
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
        return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread);
    }
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, Integer mapType, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null) {
            return null;
@@ -62,7 +63,7 @@
        Integer shuttleNo = shuttleProtocol.getShuttleNo();
        //获取小车移动速度
        Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites);
        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites);
        if (nodeList == null) {
            News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
            shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo);
@@ -122,7 +123,7 @@
        return commands;
    }
    public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
    public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
        NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo);
        NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo);
        List<NavigateNode> unlockPath = new ArrayList<>();
@@ -145,7 +146,7 @@
        //获取小车移动速度
        Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000);
        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null);
        List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null);
        if (nodeList == null) {
            News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
            shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo);
src/main/java/com/zy/core/action/ShuttleAction.java
@@ -5,19 +5,19 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.domain.param.CreateLocMoveTaskParam;
import com.zy.asrs.entity.BasShuttleOpt;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasShuttleOptService;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.ExecuteSupport;
import com.zy.common.model.NavigateNode;
import com.zy.common.service.CommonService;
import com.zy.common.utils.NavigateMapUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.common.utils.ShuttleOperaUtils;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
@Component
public class ShuttleAction {
@@ -45,8 +46,6 @@
    private RedisUtil redisUtil;
    @Autowired
    private NavigateMapUtils navigateMapUtils;
    @Autowired
    private BasShuttleService basShuttleService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
@@ -59,6 +58,8 @@
    private WrkMastService wrkMastService;
    @Autowired
    private ShuttleDispatchUtils shuttleDispatchUtils;
    @Autowired
    private CommonService commonService;
    public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) {
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
@@ -365,7 +366,92 @@
            return;
        }
        shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo);
        shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleProtocol.getShuttleNo());
    }
    public synchronized void demoModeCargoMove() {
        Config demoCargoMoveConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoCargoMove"));
        if (demoCargoMoveConfig == null) {
            return;
        }
        if (!demoCargoMoveConfig.getValue().equals("Y")) {
            return;
        }
        Config demoRunLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoRunLev"));
        if (demoRunLevConfig == null) {
            return;
        }
        List<Integer> levList = JSON.parseArray(demoRunLevConfig.getValue(), Integer.class);
        Random random = new Random();
        int index = random.nextInt(levList.size());
        Integer lev = levList.get(index);
        //获取楼层小车数量
        int shuttleCountByLev = shuttleDispatchUtils.getShuttleCountByLev(lev);
        //获取楼层货物搬运任务
        int currentLevTask = 0;
        for (WrkMast wrkMast : wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type", WrkIoType.LOC_MOVE.id))) {
            if (Utils.getLev(wrkMast.getLocNo()) == lev) {
                currentLevTask += 1;
            }
        }
        //搬运任务数量超过小车数量,暂时不生成新任务
        if (currentLevTask > shuttleCountByLev) {
            return;
        }
        LocMast sourceLoc = null;
        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
        wrapper.eq("lev1", lev);
        wrapper.eq("loc_sts", "F");
        wrapper.last("ORDER BY RAND() LIMIT 1");
        for (int i = 0; i < 3; i++) {
            LocMast locMast = locMastService.selectOne(wrapper);
            if(locMast == null) {
                continue;
            }
            sourceLoc = locMast;
            break;
        }
        if(sourceLoc == null) {
            return;
        }
        LocMast targetLoc = null;
        EntityWrapper<LocMast> targetWrapper = new EntityWrapper<>();
        targetWrapper.eq("lev1", lev);
        targetWrapper.eq("loc_sts", "O");
        targetWrapper.last("ORDER BY RAND() LIMIT 1");
        for (int i = 0; i < 3; i++) {
            LocMast locMast = locMastService.selectOne(targetWrapper);
            if(locMast == null) {
                continue;
            }
            targetLoc = locMast;
            break;
        }
        if(targetLoc == null) {
            return;
        }
        try {
            CreateLocMoveTaskParam param = new CreateLocMoveTaskParam();
            param.setSourceLocNo(sourceLoc.getLocNo());
            param.setLocNo(targetLoc.getLocNo());
            param.setTaskPri(13);
            boolean result = commonService.createLocMoveTask(param);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//    //跑库程序
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -129,7 +129,7 @@
                //当前穿梭车库位号
                String currentLocNo = shuttleProtocol.getCurrentLocNo();
                //当前穿梭车线程到目标地点距离
                List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
                List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, new ArrayList<NavigationMapType>(){{add(NavigationMapType.NORMAL);}}, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
                if (currentShuttlePath == null) {
                    continue;
                }
@@ -174,7 +174,7 @@
                    int currentLev = Utils.getLev(currentLocNo);
                    //判断当前楼层是否有任务,如果有则不分配这辆车
                    List<WrkMast> wrkMasts1 = wrkMastService.selectWrkByLev(currentLev);
                    int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量
                    int shuttleCount = this.getShuttleEnableUseCountByLev(currentLev);//获取穿梭车楼层车辆数量
                    if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
                        //存在其他任务且可用小车数量小于等于1,跳过这辆车
                        continue;
@@ -498,7 +498,7 @@
            String locNo = forkLiftStaProtocol.getLocNo();//站点库位号
            //当前穿梭车线程到目标地点距离
            List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//使用正常通道地图
            List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.getMapTypes(NavigationMapType.NORMAL), Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//使用正常通道地图
            if (currentShuttlePath == null) {
                continue;
            }
@@ -528,7 +528,7 @@
    /**
     * 获取楼层可用小车数量
     */
    public int getShuttleCountByLev(int lev) {
    public int getShuttleEnableUseCountByLev(int lev) {
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        int count = 0;
@@ -561,4 +561,36 @@
        return count;
    }
    /**
     * 获取楼层小车数量
     */
    public int getShuttleCountByLev(int lev) {
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        int count = 0;
        for (DeviceConfig device : shuttleList) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
            if (shuttleThread == null) {
                continue;
            }
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                continue;
            }
            if (shuttleProtocol.getCurrentLocNo() == null) {
                continue;
            }
            if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) == lev) {
                //同一楼层可用小车
                count++;
                continue;
            }
        }
        return count;
    }
}
src/main/java/com/zy/core/task/ShuttleDemoScheduler.java
@@ -30,4 +30,9 @@
        }
    }
    @Scheduled(cron = "0/3 * * * * ? ")
    public synchronized void executeCargoMove() {
        shuttleAction.demoModeCargoMove();
    }
}
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -732,7 +732,7 @@
                //将路径锁与小车路径进行匹配
                ArrayList<NavigateNode> tmp = new ArrayList<>();
                //检测路径是否被锁定
                int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.DFX.id, null, null);
                int[][] map = navigateMapData.getDataFromRedis(lev, NavigationMapType.getDfxWithDevice(), null, null);
                for (NavigateNode node : path) {
                    if(map[node.getX()][node.getY()] == -999) {
                        tmp.add(node);