From 8abca3f5413d977f5b11ed74b12ee39cc8570851 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 22 八月 2023 13:20:03 +0800
Subject: [PATCH] #console

---
 src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java |   64 ++++++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java b/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java
index 6904bbc..c6d3533 100644
--- a/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java
@@ -2,9 +2,12 @@
 
 import com.alibaba.fastjson.JSON;
 import com.core.common.SpringUtils;
+import com.zy.asrs.entity.BasShuttle;
 import com.zy.asrs.service.BasShuttleService;
+import com.zy.asrs.utils.Utils;
 import com.zy.common.utils.NavigatePositionConvert;
 import com.zy.core.News;
+import com.zy.core.enums.ShuttleErrorCodeType;
 import com.zy.core.enums.ShuttleProtocolStatusType;
 import com.zy.core.enums.ShuttleStatusType;
 import com.zy.core.model.command.ShuttleAssignCommand;
@@ -161,6 +164,11 @@
     private NyShuttlePointClass coord;
 
     /**
+     * WCS搴撲綅xyz
+     */
+    private NyShuttlePointClass wcsPoint;
+
+    /**
      * 浠诲姟鐩殑搴撲綅xyztaskId(姝e湪鍔ㄤ綔鐨勪换鍔D)lastTaskId(鏈�鍚庝竴涓畬鎴愮殑浠诲姟ID)recentTaskId(鏀跺埌鐨勬渶鍚庝竴涓换鍔D)
      */
     private TaskClass task;
@@ -189,6 +197,13 @@
      * 闈炶嚜鍔ㄧ姸鎬佹椂闂磋鏃�(S)
      */
     private Integer errTime;
+
+    /**
+     * 鐙崰浠ょ墝
+     * 鏈浠诲姟鍗犳嵁锛屼护鐗屼负0
+     * 琚换鍔″崰鎹紝灏嗕换鍔″彿璧嬪�肩粰浠ょ墝
+     */
+    private Integer token = 0;
 
     //鎬婚噷绋嬫暟
     @Data
@@ -389,12 +404,17 @@
         String locNo = NavigatePositionConvert.nyXyzToLocNo(point.getX(), point.getY(), point.getZ());
         this.point = point;
         this.currentLocNo = locNo;
+        NyShuttlePointClass wcsPoint = new NyShuttlePointClass();
+        wcsPoint.setX(Utils.getRow(locNo));
+        wcsPoint.setY(Utils.getBay(locNo));
+        wcsPoint.setZ(Utils.getLev(locNo));
+        this.wcsPoint = wcsPoint;
     }
 
     // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵��
     public Boolean isIdle() {
         boolean res = this.free == ShuttleStatusType.IDLE.id
-                && this.pakMk.equals(true)
+                && !this.pakMk
                 && this.errState == 0
                 && this.taskNo == 0
                 && this.protocolStatus == ShuttleProtocolStatusType.IDLE.id
@@ -419,7 +439,7 @@
     // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵�侊紝浼犲叆鐨則askNo鍜屽綋鍓峵askNo鐩稿悓鏃跺厑璁告斁琛�
     public Boolean isIdle(int taskNo) {
         boolean res = this.free == ShuttleStatusType.IDLE.id
-                && this.pakMk.equals(true)
+                && !this.pakMk
                 && this.errState == 0
                 && (this.taskNo == 0 || this.taskNo == taskNo)
                 && this.protocolStatus.intValue() == ShuttleProtocolStatusType.IDLE.id
@@ -441,11 +461,49 @@
     // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵��
     public Boolean isIdleNoCharge() {
         boolean res = this.free == ShuttleStatusType.IDLE.id
-                && this.pakMk.equals(true)
+                && !this.pakMk
                 && this.errState == 0
                 && this.taskNo == 0
                 && this.protocolStatus == ShuttleProtocolStatusType.IDLE.id
                 ;
         return res;
     }
+
+    // 鏄惁婊¤冻鍏呯數鐘舵��
+    public Boolean isRequireCharge() {
+        if (this.free == null || this.pakMk == null || this.errState == null || this.taskNo == null) {
+            return false;
+        }
+
+        boolean res = this.free == ShuttleStatusType.IDLE.id
+                && !this.pakMk
+                && this.errState == 0
+                && this.taskNo == 0
+                && this.protocolStatusType.id == ShuttleProtocolStatusType.IDLE.id
+                ;
+        if (!res) {
+            return res;
+        } else {
+            // 鐢甸噺灏忎簬闃堝�兼垨鏈�浣庣數鑺數鍘嬪皬浜�2900mv锛岄渶瑕佽繘琛屽厖鐢�
+            try {
+                BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class);
+                if (shuttleService == null) {
+                    return false;
+
+                }
+                BasShuttle basShuttle = shuttleService.selectById(this.shuttleNo);
+                if (basShuttle == null) {
+                    return false;
+                }
+                Integer chargeLine = basShuttle.getChargeLine();
+                if (chargeLine == null) {
+                    return false;
+                }
+                return this.getPowerPercent() < chargeLine || this.minCellVoltage < 2900;
+            } catch (Exception e) {
+                News.error("fail", e);
+                return false;
+            }
+        }
+    }
 }

--
Gitblit v1.9.1