From aab74f9728236408a573b6502d623eca2e8fff5b Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期二, 18 六月 2024 15:06:36 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java | 36 +++++++++++++++++++++++++++++++++++- 1 files changed, 35 insertions(+), 1 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java index 925be94..7b30f2c 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java @@ -1,13 +1,17 @@ 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; import com.zy.asrs.wcs.core.map.entity.MapWsShuttleVo; import com.zy.asrs.wcs.core.map.entity.MapWsVo; +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; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; @@ -15,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; @@ -22,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; /** * Created by vincent on 4/11/2024 @@ -35,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)); } @@ -61,7 +73,6 @@ if (null != basShuttle && !Cools.isEmpty(basShuttle.getProtocol())) { ShuttleProtocol protocol = JSON.parseObject(basShuttle.getProtocol(), ShuttleProtocol.class); shuttleVo.setCurLocNo(protocol.getCurrentLocNo()); - } } }; @@ -78,9 +89,32 @@ } shuttleVo.setCurLocNo(protocol.getCurrentLocNo()); + + List<NavigateNode> moveAdvancePath = thread.getMoveAdvancePath(); + if (!Cools.isEmpty(moveAdvancePath)) { + shuttleVo.setTravelPath(moveAdvancePath.stream() + .map(path -> Utils.getLocNo(path.getX(), path.getY(), path.getZ())) + .collect(Collectors.toList())); + } } 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; + } + } -- Gitblit v1.9.1