From a42ae1ffc20459dc46a88590bc4a94f9280f2d3d Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 10 五月 2024 15:31:28 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 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 a63e648..c452134 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
@@ -2,10 +2,14 @@
 
 import com.alibaba.fastjson.JSON;
 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.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;
@@ -19,6 +23,8 @@
 
 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
@@ -46,21 +52,41 @@
 
         List<Device> deviceList = deviceService.list(new LambdaQueryWrapper<Device>().eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()));
         for (Device device : deviceList) {
-//            basShuttleService.
+            MapWsShuttleVo shuttleVo = new MapWsShuttleVo();
+            shuttleVos.add(shuttleVo);
+
+            shuttleVo.setShuttleNo(device.getDeviceNo());
+
+            Consumer<Device> consumer = new Consumer<Device>() {
+                @Override
+                public void accept(Device device) {
+                    BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, device.getId()));
+                    if (null != basShuttle && !Cools.isEmpty(basShuttle.getProtocol())) {
+                        ShuttleProtocol protocol = JSON.parseObject(basShuttle.getProtocol(), ShuttleProtocol.class);
+                        shuttleVo.setCurLocNo(protocol.getCurrentLocNo());
+                    }
+                }
+            };
+
             ShuttleThread thread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
             if (null == thread) {
+                consumer.accept(device);
                 continue;
             }
             ShuttleProtocol protocol = thread.getStatus();
             if (null == protocol) {
+                consumer.accept(device);
                 continue;
             }
 
-            MapWsShuttleVo shuttleVo = new MapWsShuttleVo();
-//            shuttleVo.setShuttleNo();
+            shuttleVo.setCurLocNo(protocol.getCurrentLocNo());
 
-
-            shuttleVos.add(shuttleVo);
+            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;

--
Gitblit v1.9.1