#
Junjie
2025-11-21 7f9435bb4a074b4964f290c4d6905e0e233a19ec
#
8个文件已修改
283 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/BasMapController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/BasMapService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/BasMapServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateSolution.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateUtils.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/watch/console.html 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/BasMapController.java
@@ -140,6 +140,13 @@
        return R.ok().add(basMap.getData());
    }
    @GetMapping("/basMap/getLevList")
    @ManagerAuth
    public R getLevList() {
        List<Integer> levList = basMapService.getLevList();
        return R.ok().add(levList);
    }
    @Autowired
    private MapExcelUtils mapExcelUtils;
@@ -151,9 +158,9 @@
        HashMap<Integer, List<List<HashMap<String, Object>>>> dataMap = mapExcelUtils.readExcel(filePath);
        List<List<HashMap<String, Object>>> dataList = new ArrayList<>();
        for (Map.Entry<Integer, List<List<HashMap<String, Object>>>> entry : dataMap.entrySet()) {
            Integer key = entry.getKey();
            Integer lev = entry.getKey();
            List<List<HashMap<String, Object>>> dataList = new ArrayList<>();
            List<List<HashMap<String, Object>>> list = entry.getValue();
            for (int i = 0; i < list.size(); i++) {
@@ -195,17 +202,18 @@
                }
                dataList.add(arrayList);
            }
        }
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1));
        if (basMap == null){
            basMap = new BasMap();
            BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
            if (basMap == null){
                basMap = new BasMap();
            }
            basMap.setData(JSON.toJSONString(dataList));
            basMap.setOriginData(JSON.toJSONString(dataList));
            basMap.setCreateTime(new Date());
            basMap.setUpdateTime(new Date());
            basMap.setLev(lev);
            basMapService.insertOrUpdate(basMap);
        }
        basMap.setData(JSON.toJSONString(dataList));
        basMap.setOriginData(JSON.toJSONString(dataList));
        basMap.setCreateTime(new Date());
        basMap.setUpdateTime(new Date());
        basMapService.insertOrUpdate(basMap);
        return R.ok();
    }
src/main/java/com/zy/asrs/service/BasMapService.java
@@ -1,6 +1,9 @@
package com.zy.asrs.service;
import com.zy.asrs.entity.BasMap;
import java.util.List;
import com.baomidou.mybatisplus.service.IService;
public interface BasMapService extends IService<BasMap> {
@@ -9,4 +12,6 @@
    boolean deleteByLev(Integer lev);//删除指定楼层地图
    List<Integer> getLevList();//获取所有楼层地图
}
src/main/java/com/zy/asrs/service/impl/BasMapServiceImpl.java
@@ -3,7 +3,12 @@
import com.zy.asrs.mapper.BasMapMapper;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.service.BasMapService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
@Service("basMapService")
@@ -19,4 +24,9 @@
        return this.baseMapper.deleteByLev(lev);
    }
    @Override
    public List<Integer> getLevList() {
        return this.baseMapper.selectList(new EntityWrapper<>()).stream().map(BasMap::getLev).collect(Collectors.toList());
    }
}
src/main/java/com/zy/common/utils/NavigateSolution.java
@@ -23,9 +23,9 @@
    //用来存放已经出现过的结点。
    Map<String, Integer> bestGMap = new HashMap<>();
    public List<List<NavigateNode>> getStationMap() {
    public List<List<NavigateNode>> getStationMap(int lev) {
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1));
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
        if (basMap == null) {
            throw new CoolException("地图不存在");
        }
@@ -63,9 +63,9 @@
        return navigateNodeList;
    }
    public List<List<NavigateNode>> getRgvTrackMap() {
    public List<List<NavigateNode>> getRgvTrackMap(int lev) {
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1));
        BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev));
        if (basMap == null) {
            throw new CoolException("地图不存在");
        }
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -14,9 +14,9 @@
@Component
public class NavigateUtils {
    public synchronized List<NavigateNode> calcByStationId(Integer startStationId, Integer endStationId) {
    public synchronized List<NavigateNode> calcByStationId(int lev, Integer startStationId, Integer endStationId) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        NavigateNode startNode = navigateSolution.findStationNavigateNode(stationMap, startStationId);
        if (startNode == null){
@@ -66,9 +66,9 @@
        return fitlerList;
    }
    public synchronized List<NavigateNode> calcByTrackSiteNo(Integer startTrackSiteNo, Integer endTrackSiteNo) {
    public synchronized List<NavigateNode> calcByTrackSiteNo(int lev, Integer startTrackSiteNo, Integer endTrackSiteNo) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap();
        List<List<NavigateNode>> rgvTrackMap = navigateSolution.getRgvTrackMap(lev);
        NavigateNode startNode = navigateSolution.findTrackSiteNoNavigateNode(rgvTrackMap, startTrackSiteNo);
        if (startNode == null){
@@ -118,4 +118,30 @@
        return fitlerList;
    }
    public synchronized List<NavigateNode> findLiftStationList(int lev) {
        NavigateSolution navigateSolution = new NavigateSolution();
        List<List<NavigateNode>> stationMap = navigateSolution.getStationMap(lev);
        List<NavigateNode> liftStationList = new ArrayList<>();
        for (List<NavigateNode> navigateNodes : stationMap) {
            for (NavigateNode navigateNode : navigateNodes) {
                String nodeType = navigateNode.getNodeType();
                if(nodeType == null){
                    continue;
                }
                if(!nodeType.equals("devp")){
                    continue;
                }
                JSONObject valuObject = JSON.parseObject(navigateNode.getNodeValue());
                if(valuObject == null){
                    continue;
                }
                if (valuObject.containsKey("liftNo")) {
                    liftStationList.add(navigateNode);
                }
            }
        }
        return liftStationList;
    }
}
src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java
@@ -4,16 +4,15 @@
import com.alibaba.fastjson.JSONObject;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.service.BasMapService;
import com.zy.common.model.NavigateNode;
import com.zy.common.utils.NavigateUtils;
import com.zy.core.enums.RgvModeType;
import com.zy.core.enums.RgvStatusType;
import com.zy.core.enums.RgvTaskModeType;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.command.RgvCommand;
import com.zy.core.network.api.ZyRgvConnectApi;
import com.zy.core.network.entity.ZyRgvStatusEntity;
import com.zy.core.network.entity.ZyStationStatusEntity;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -73,9 +72,21 @@
            return;
        }
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        if (basMapService == null) {
            return;
        }
        List<Integer> levList = basMapService.getLevList();
        List<NavigateNode> navigateNodes = null;
        try {
            navigateNodes = navigateUtils.calcByTrackSiteNo(status.getRgvPos(), sourcePos);
            for (Integer lev : levList) {
                navigateNodes = navigateUtils.calcByTrackSiteNo(lev, status.getRgvPos(), sourcePos);
                if (navigateNodes != null) {
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -86,7 +97,12 @@
        List<NavigateNode> targetNavigateNodes = null;
        try {
            targetNavigateNodes = navigateUtils.calcByTrackSiteNo(sourcePos, targetPos);
            for (Integer lev : levList) {
                targetNavigateNodes = navigateUtils.calcByTrackSiteNo(lev, sourcePos, targetPos);
                if (targetNavigateNodes != null) {
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -133,9 +149,21 @@
            return;
        }
        BasMapService basMapService = SpringUtils.getBean(BasMapService.class);
        if (basMapService == null) {
            return;
        }
        List<Integer> levList = basMapService.getLevList();
        List<NavigateNode> navigateNodes = null;
        try {
            navigateNodes = navigateUtils.calcByTrackSiteNo(status.getRgvPos(), targetPos);
            for (Integer lev : levList) {
                navigateNodes = navigateUtils.calcByTrackSiteNo(lev, status.getRgvPos(), targetPos);
                if (navigateNodes != null) {
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -77,6 +77,20 @@
    }
    private void handleCommand(StationCommand command) {
        Integer stationId = command.getStationId();
        Integer targetStationId = command.getTargetStaNo();
        String startLev = String.valueOf(stationId).substring(0, 1);
        String endLev = String.valueOf(targetStationId).substring(0, 1);
        if (startLev.equals(endLev)) {
            currentLevCommand(command);
        }else {
            diffLevCommand(command);
        }
    }
    private void currentLevCommand(StationCommand command) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
            return;
@@ -86,10 +100,12 @@
        Integer stationId = command.getStationId();
        Integer targetStationId = command.getTargetStaNo();
        String startLev = String.valueOf(stationId).substring(0, 1);
        List<NavigateNode> navigateNodes = null;
        try {
            navigateNodes = navigateUtils.calcByStationId(stationId, targetStationId);
            navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, targetStationId);
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -98,6 +114,86 @@
            return;
        }
        stationMove(navigateNodes, taskNo, targetStationId);
    }
    private void diffLevCommand(StationCommand command) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
            return;
        }
        Integer taskNo = command.getTaskNo();
        Integer stationId = command.getStationId();
        Integer targetStationId = command.getTargetStaNo();
        String startLev = String.valueOf(stationId).substring(0, 1);
        String endLev = String.valueOf(targetStationId).substring(0, 1);
        List<NavigateNode> navigateNodes = null;
        List<NavigateNode> targetNavigateNodes = null;
        try {
            List<NavigateNode> liftStationList = navigateUtils.findLiftStationList(Integer.parseInt(startLev));
            if(liftStationList.isEmpty()){
                //未找到提升机节点
                return;
            }
            List<NavigateNode> targetLiftStationList = navigateUtils.findLiftStationList(Integer.parseInt(endLev));
            if(targetLiftStationList.isEmpty()){
                //未找到提升机节点
                return;
            }
            for (NavigateNode liftStation : liftStationList) {
                JSONObject valuObject = JSON.parseObject(liftStation.getNodeValue());
                if(valuObject == null){
                    continue;
                }
                Integer liftStationId = valuObject.getInteger("stationId");
                Integer liftNo = valuObject.getInteger("liftNo");
                Integer targetLiftStationId = null;
                for (NavigateNode targetLiftStation : targetLiftStationList) {
                    JSONObject targetValuObject = JSON.parseObject(targetLiftStation.getNodeValue());
                    if(targetValuObject == null){
                        continue;
                    }
                    Integer targetLiftNo = targetValuObject.getInteger("liftNo");
                    if(liftNo.equals(targetLiftNo)){
                        targetLiftStationId = targetValuObject.getInteger("stationId");
                        break;
                    }
                }
                if(targetLiftStationId == null){
                    continue;
                }
                navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationId, liftStationId);
                if(navigateNodes == null){
                    continue;
                }
                //计算提升机到目标站的路径
                targetNavigateNodes = navigateUtils.calcByStationId(Integer.parseInt(endLev), targetLiftStationId, targetStationId);
                if(targetNavigateNodes == null) {
                    continue;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (navigateNodes == null || targetNavigateNodes == null) {
            return;
        }
        stationMove(navigateNodes, taskNo, stationId);
        stationMove(targetNavigateNodes, taskNo, targetStationId);
    }
    private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId) {
        Integer lastStationId = null;
        for (int i = 0; i < navigateNodes.size(); i++) {
            NavigateNode navigateNode = navigateNodes.get(i);
src/main/webapp/views/watch/console.html
@@ -32,7 +32,14 @@
                        </el-tab-pane>
                    </el-tabs>
                </div>
                <div id="mapDataId" style="position: relative;" :style="{zoom: mapSettingParam.zoom / 100}">
                <div style="position: absolute;top: 15px;left: 50%;display: flex;">
                    <div v-if="levList.length > 1" v-for="(lev,index) in levList" :key="index" style="margin-right: 10px;">
                        <el-button :type="currentLev == lev ? 'primary' : ''" @click="switchLev(lev)" size="mini">{{ lev }}F</el-button>
                    </div>
                </div>
                <div id="mapDataId" style="position: relative;margin-top: 50px;" :style="{zoom: mapSettingParam.zoom / 100}">
                    <table class="excel-table">
                        <tr v-for="(row,index) in map" :key="index">
                            <td
@@ -63,10 +70,6 @@
                                </div>
                            </td>
<!--                            <td>-->
<!--                                &lt;!&ndash; 显示行号 &ndash;&gt;-->
<!--                                <div class="item" style="background: none;color: #000;">#{{index+1}}</div>-->
<!--                            </td>-->
                        </tr>
                    </table>
                </div>
@@ -83,7 +86,8 @@
                el: '#app',
                data: {
                    map: [],//地图数据
                    crnList: [], //堆垛机集合
                    levList: [],
                    currentLev: 1,
                    systemStatus: true,//系统运行状态
                    consoleInterval: null,//定时器存储变量
                    crnInitPosition: [],
@@ -112,6 +116,7 @@
                    init() {
                        this.getMap()
                        this.getSystemRunningStatus() //获取系统运行状态
                        this.getLevList() //获取地图层级列表
                        this.consoleInterval = setInterval(() => {
                            this.getCrnInfo() //获取堆垛机数据
@@ -119,13 +124,28 @@
                            this.getRgvInfo() //获取RGV数据
                        }, 1000)
                    },
                    getLevList() {
                        let that = this;
                        $.ajax({
                            url: baseUrl + "/basMap/getLevList",
                            headers: {
                                'token': localStorage.getItem('token')
                            },
                            method: "get",
                            success: (res) => {
                                let data = res.data;
                                that.levList = data;
                            }
                        })
                    },
                    //获取地图数据
                    getMap() {
                        let that = this
                        let rowPx = 35;
                        let colPx = 35;
                        $.ajax({
                            url: baseUrl + "/basMap/lev/1/auth",
                            url: baseUrl + "/basMap/lev/" + this.currentLev + "/auth",
                            headers: {
                                'token': localStorage.getItem('token')
                            },
@@ -147,9 +167,13 @@
                                        col.width = (col.cellWidth / 30) + "px";
                                    })
                                })
                                this.map = mapData;
                                that.map = mapData;
                            }
                        })
                    },
                    switchLev(lev) {
                        this.currentLev = lev;
                        this.getMap()
                    },
                    openCrn(id) {
                        this.crnParam.crnNo = id;
@@ -204,6 +228,9 @@
                                        let position = []
                                        for (var i = 0; i < crns.length; i++) {
                                            var crnEl = $("#crn-" + crns[i].crnId);
                                            if(crnEl.offset() == undefined) {
                                                continue;
                                            }
                                            position.push({
                                                id: crns[i].crnId,
                                                left: crnEl.offset().left + crnEl.width()
@@ -241,8 +268,6 @@
                                            crnStatus: crns[i].crnStatus
                                        })
                                    }
                                    that.crnList = crnList;
                                } else if (res.code === 403) {
                                    parent.location.href = baseUrl + "/login";
                                } else {
@@ -266,6 +291,9 @@
                                        let position = []
                                        for (var i = 0; i < rgvs.length; i++) {
                                            var rgvEl = $("#rgv-" + rgvs[i].rgvNo);
                                            if(rgvEl.offset() == undefined) {
                                                continue;
                                            }
                                            position.push({
                                                id: rgvs[i].rgvNo,
                                                trackSiteNo: rgvs[i].trackSiteNo,
@@ -278,15 +306,23 @@
                                    for (var i = 0; i < rgvs.length; i++) {
                                        var rgvEl = $("#rgv-" + rgvs[i].rgvNo);
                                        if (rgvs[i].rgvStatus == 'IDLE') {
                                        if (rgvs[i].rgvStatus == 'idle') {
                                            rgvEl.attr("class", "rgv-item");
                                        }else if (rgvs[i].rgvStatus == 'WORKING') {
                                        }else if (rgvs[i].rgvStatus == 'working') {
                                            rgvEl.attr("class", "rgv-item machine-working");
                                        }else if (rgvs[i].rgvStatus == 'waiting') {
                                            rgvEl.attr("class", "rgv-item machine-working");
                                        }else {
                                            rgvEl.attr("class", "rgv-item machine-un-auto");
                                        }
                                        let trackSiteNo = rgvs[i].trackSiteNo;
                                        let trackSiteEl = $("#rgvTrackSiteNo-" + trackSiteNo);
                                        if(rgvEl.offsetParent().offset() == undefined) {
                                            continue;
                                        }
                                        let parentLeft = rgvEl.offsetParent().offset().left;
                                        let targetPosition = trackSiteEl.parent().parent().offset().left - parentLeft;
                                        let rgvPosition = rgvEl.position().left;