#
Junjie
2024-06-13 732f97d740de606004cd19436ba19846bbd5b378
#
5个文件已修改
130 ■■■■■ 已修改文件
zy-asrs-flow/src/pages/map/utils.js 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapWsVo.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/utils.js
@@ -9,6 +9,7 @@
import conveyor from '/public/img/map/conveyor.png'
import point from '/public/img/map/point.svg'
import shuttle from '/public/img/map/shuttle.svg'
import { log } from 'three/examples/jsm/nodes/Nodes.js';
let app = null;
let mapContainer = null;
@@ -618,6 +619,8 @@
        // shuttle
        showShuttle(shuttleVo, curFloor, setCurSPrite);
    }
    showLockPath(mapVo.lockPath, curFloor, setCurSPrite);
}
export const drawTravelPath = (shuttleVo, curFloor) => {
@@ -679,4 +682,38 @@
    }, 1000).onUpdate(() => {
        updateEffect(shuttle);
    }).start();
}
export const showLockPath = (nodes, curFloor, setCurSPrite) => {
    const pathLineName = 'lockPath-' + curFloor;
    let pathLine = mapContainer.getChildByName(pathLineName);
    if (pathLine) {
        mapContainer.removeChild(pathLine);
    }
    pathLine = new PIXI.Graphics();
    pathLine.name = pathLineName;
    pathLine.lineStyle(3 * (1 / mapContainer.scale.x), 0xff0000, 0.8);
    pathLine.zIndex = SENSOR_ZINDEX.TRAVEL_PATH;
    let firstNode = true;
    for(let i = 0; i < nodes.length; i++) {
        const node = nodes[i];
        if (node.z !== curFloor) { continue }
        const shelf = querySprite(SENSOR_TYPE.SHELF, node.x + '-' + node.y);
        if (!shelf) { continue }
        let position = shelf.position;
        let x = position.x;
        let y = position.y;
        if (firstNode) {
            pathLine.moveTo(x, y);
            firstNode = false;
        } else {
            pathLine.lineTo(x, y);
        }
    }
    mapContainer.addChild(pathLine);
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/entity/MapWsVo.java
@@ -1,5 +1,6 @@
package com.zy.asrs.wcs.core.map.entity;
import com.zy.asrs.wcs.core.model.NavigateNode;
import lombok.Data;
import java.util.ArrayList;
@@ -13,4 +14,6 @@
    private List<MapWsShuttleVo> shuttleVos = new ArrayList<>();
    private List<NavigateNode> lockPath = new ArrayList<>();
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java
@@ -1,6 +1,7 @@
package com.zy.asrs.wcs.core.map.websocket;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.wcs.core.entity.BasShuttle;
@@ -9,6 +10,7 @@
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.service.BasShuttleService;
import com.zy.asrs.wcs.core.utils.NavigateMapUtils;
import com.zy.asrs.wcs.core.utils.Utils;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
@@ -17,6 +19,8 @@
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -38,12 +42,17 @@
    private DeviceService deviceService;
    @Autowired
    private BasShuttleService basShuttleService;
    @Autowired
    private DictService dictService;
    @Autowired
    private NavigateMapUtils navigateMapUtils;
    @Scheduled(cron = "0/1 * * * * ? ")
    public void sync() {
        MapWsVo wsVo = new MapWsVo();
        // shuttle
        wsVo.setShuttleVos(syncShuttle());
        wsVo.setLockPath(getMapLocPath());
        MapWebSocket.broadcast(JSON.toJSONString(wsVo));
    }
@@ -92,4 +101,20 @@
        return shuttleVos;
    }
    private List<NavigateNode> getMapLocPath() {
        List<NavigateNode> navigateNodes = new ArrayList<>();
        Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>()
                .eq(Dict::getFlag, "floor-list")
                .eq(Dict::getStatus, 1));
        if (dict != null) {
            for (Object o : JSON.parseArray(dict.getValue())) {
                JSONObject jsonObject = JSON.parseObject(o.toString());
                Integer lev = jsonObject.getInteger("value");
                List<NavigateNode> path = navigateMapUtils.getLockPath(lev);
                navigateNodes.addAll(path);
            }
        }
        return navigateNodes;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java
@@ -1,7 +1,10 @@
package com.zy.asrs.wcs.core.utils;
import com.alibaba.fastjson.JSON;
import com.zy.asrs.framework.common.SpringUtils;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.wcs.core.domain.dto.RedisMapDto;
import com.zy.asrs.wcs.core.model.MapNode;
import com.zy.asrs.wcs.core.model.NavigateNode;
@@ -19,13 +22,16 @@
    @Autowired
    private NavigateMapData navigateMapData;
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 写入路径节点数据到redis地图中
     * lock为true 禁用库位,lock为false恢复库位
     */
    public synchronized boolean writeNavigateNodeToRedisMap(Integer lev, Integer shuttleNo, List<NavigateNode> nodes, boolean lock) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        try {
            if (nodes.isEmpty()) {
                return true;
@@ -85,7 +91,10 @@
            redisMap.setData(JSON.toJSONString(lists));
            redisMap.setUpdateTime(new Date());
            //将数据库地图数据存入redis
            redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(redisMap));
            redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(redisMap, SerializerFeature.DisableCircularReferenceDetect));
            //保存路径锁节点
            saveLockPath(lev, nodes, lock);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
@@ -93,4 +102,52 @@
        return false;
    }
    //保存路径锁节点
    public void saveLockPath(Integer lev, List<NavigateNode> nodes, boolean lock) {
        Object o = redisUtil.get(DeviceRedisConstant.LOCK_PATH + lev);
        List<NavigateNode> navigateNodes = new ArrayList<>();
        if (o != null) {
            navigateNodes = JSON.parseArray(o.toString(), NavigateNode.class);
        }
        if (lock) {
            navigateNodes.addAll(nodes);
            redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(navigateNodes, SerializerFeature.DisableCircularReferenceDetect));
        }else {
            List<NavigateNode> tmp = new ArrayList<>();
            for (NavigateNode navigateNode : navigateNodes) {
                boolean flag = true;
                for (NavigateNode node : nodes) {
                    if (navigateNode.getX() == node.getX()
                            && navigateNode.getY() == node.getY()
                            && navigateNode.getZ() == node.getZ()) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    tmp.add(navigateNode);
                }
            }
            redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(tmp, SerializerFeature.DisableCircularReferenceDetect));
        }
    }
    //获取路径锁节点
    public List<NavigateNode> getLockPath(Integer lev) {
        Object obj = redisUtil.get(DeviceRedisConstant.LOCK_PATH + lev);
        List<NavigateNode> navigateNodes = new ArrayList<>();
        if (obj != null) {
            try {
                navigateNodes = objectMapper.readValue(obj.toString(), new TypeReference<List<NavigateNode>>() {});
            } catch (JsonProcessingException e) {
                throw new RuntimeException(e);
            }
        }
        return navigateNodes;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java
@@ -15,6 +15,8 @@
    public static final String MAP = "realtimeBasMap_";
    public static final String LOCK_PATH = "mapLockPath_";
    public static final String COMMAND_TMP = "command_tmp_";
}