From 3b64c807f60e5d6b71deca3f79c9be4be19abfaa Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 23 二月 2024 10:47:58 +0800
Subject: [PATCH] #显示器更新

---
 src/main/java/com/zy/core/thread/NyShuttleThread.java |   74 +++++++++++++++++++++++++++++++------
 1 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java
index 592adc1..d5f4ae2 100644
--- a/src/main/java/com/zy/core/thread/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -243,15 +243,21 @@
                 }
 //                log.warn(JSON.toJSONString(shuttleProtocol));//杈撳嚭灏忚溅鐘舵��
 
-                //淇濆瓨鏁版嵁璁板綍
-                DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class);
-                DeviceDataLog deviceDataLog = new DeviceDataLog();
-                deviceDataLog.setOriginData(JSON.toJSONString(jsonObject));
-                deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol));
-                deviceDataLog.setType("shuttle");
-                deviceDataLog.setDeviceNo(shuttleProtocol.getShuttleNo().intValue());
-                deviceDataLog.setCreateTime(new Date());
-                deviceDataLogService.insert(deviceDataLog);
+                if (System.currentTimeMillis() - shuttleProtocol.getDeviceDataLog() > 1000 * 5) {
+                    //閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰�
+                    //淇濆瓨鏁版嵁璁板綍
+                    DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class);
+                    DeviceDataLog deviceDataLog = new DeviceDataLog();
+                    deviceDataLog.setOriginData(JSON.toJSONString(jsonObject));
+                    deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol));
+                    deviceDataLog.setType("shuttle");
+                    deviceDataLog.setDeviceNo(shuttleProtocol.getShuttleNo().intValue());
+                    deviceDataLog.setCreateTime(new Date());
+                    deviceDataLogService.insert(deviceDataLog);
+
+                    //鏇存柊閲囬泦鏃堕棿
+                    shuttleProtocol.setDeviceDataLog(System.currentTimeMillis());
+                }
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -429,7 +435,7 @@
                         if (!(targetNode.getX() == node.getX() && targetNode.getY() == node.getY())) {
                             nodes.remove(nodes.size() - 1);//鍓旈櫎灏捐妭鐐�
                         }
-                        boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), nodes, false);//瑙i攣璺緞
+                        boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), shuttleProtocol.getShuttleNo().intValue(), nodes, false);//瑙i攣璺緞
                         if (!result) {
                             return false;//瑙i攣澶辫触
                         }
@@ -794,7 +800,7 @@
                     }
                 }
             }
-        }else {//璺戝簱浣�
+        } else if (shuttleProtocol.getMoveType() == 1) {//璺戝簱浣�
             Integer xCurrent = shuttleProtocol.getXCurrent();
             if (xCurrent > shuttleProtocol.getXTarget()) {//褰揦鍊煎ぇ浜嶺鐩爣鍊硷紝杩涜褰掗浂涓擸鏂瑰悜+1
                 shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());
@@ -818,12 +824,56 @@
             //璋冨害鍘荤洰鏍囦綅缃�
             if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) {
                 shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝璺宠繃
-            }else {
+            } else {
                 boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), target.getLocNo());
                 if (result) {//璋冨害鎴愬姛
                     shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
                 }
             }
+        } else if (shuttleProtocol.getMoveType() == 2) {//姣嶈建閬撳惊鐜窇
+            Integer xCurrent = shuttleProtocol.getXCurrent();
+            Integer yCurrent = shuttleProtocol.getYCurrent();
+
+            String locNo = Utils.getLocNo(xCurrent, yCurrent, lev);
+            //璋冨害鍘荤洰鏍囦綅缃�
+            if (shuttleProtocol.getCurrentLocNo().equals(locNo)) {
+                if (yCurrent.equals(shuttleProtocol.getYStart())) {
+                    shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
+                }else {
+                    shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
+                }
+            } else {
+                boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo);
+                if (result) {//璋冨害鎴愬姛
+                    if (yCurrent.equals(shuttleProtocol.getYStart())) {
+                        shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//鍒囨崲搴撲綅
+                    }else {
+                        shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//鍒囨崲搴撲綅
+                    }
+                }
+            }
+        } else if (shuttleProtocol.getMoveType() == 3) {//瀛愯建閬撳惊鐜窇
+            Integer xCurrent = shuttleProtocol.getXCurrent();
+            Integer yCurrent = shuttleProtocol.getYCurrent();
+
+            String locNo = Utils.getLocNo(xCurrent, yCurrent, lev);
+            //璋冨害鍘荤洰鏍囦綅缃�
+            if (shuttleProtocol.getCurrentLocNo().equals(locNo)) {
+                if (xCurrent.equals(shuttleProtocol.getXStart())) {
+                    shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
+                }else {
+                    shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
+                }
+            } else {
+                boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo);
+                if (result) {//璋冨害鎴愬姛
+                    if (xCurrent.equals(shuttleProtocol.getXStart())) {
+                        shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//鍒囨崲搴撲綅
+                    }else {
+                        shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//鍒囨崲搴撲綅
+                    }
+                }
+            }
         }
     }
 

--
Gitblit v1.9.1