From 2801c1b1ce328e27d044f26cdf9609e7c90478d7 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期四, 30 十一月 2023 18:37:50 +0800
Subject: [PATCH] #盘点逻辑修改

---
 src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java |  178 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 140 insertions(+), 38 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 27cb465..a181ee3 100644
--- a/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/NyShuttleProtocol.java
@@ -3,17 +3,17 @@
 import com.alibaba.fastjson.JSON;
 import com.core.common.SpringUtils;
 import com.zy.asrs.entity.BasShuttle;
+import com.zy.asrs.entity.BasShuttleErr;
+import com.zy.asrs.service.BasShuttleErrService;
 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;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-
-import java.util.List;
 
 /**
  * 鐗涚溂鍥涘悜绌挎杞�
@@ -163,6 +163,11 @@
     private NyShuttlePointClass coord;
 
     /**
+     * WCS搴撲綅xyz
+     */
+    private NyShuttlePointClass wcsPoint;
+
+    /**
      * 浠诲姟鐩殑搴撲綅xyztaskId(姝e湪鍔ㄤ綔鐨勪换鍔D)lastTaskId(鏈�鍚庝竴涓畬鎴愮殑浠诲姟ID)recentTaskId(鏀跺埌鐨勬渶鍚庝竴涓换鍔D)
      */
     private TaskClass task;
@@ -180,7 +185,7 @@
     /**
      * 鏁呴殰鐮�
      */
-    private List<Integer> errCode;
+    private Integer errCode;
 
     /**
      * mileage鎬婚噷绋嬫暟(绫�)锛宭iftNumber椤跺崌鎬绘暟dropNumber涓嬮檷鎬绘暟reversingX鎹鎬绘暟reversingY鎹鎬绘暟
@@ -191,6 +196,53 @@
      * 闈炶嚜鍔ㄧ姸鎬佹椂闂磋鏃�(S)
      */
     private Integer errTime;
+
+    /**
+     * 鐙崰浠ょ墝
+     * 鏈浠诲姟鍗犳嵁锛屼护鐗屼负0
+     * 琚换鍔″崰鎹紝灏嗕换鍔″彿璧嬪�肩粰浠ょ墝
+     */
+    private Integer token = 0;
+
+    /**
+     * 璺戝簱鐘舵��
+     */
+    private Boolean moveLoc = false;
+
+    /**
+     * 璺戝簱绫诲瀷锛�0:璺戣建閬擄紝1锛氳窇搴撲綅
+     */
+    private Integer moveType = 0;
+
+    /**
+     * 璺戝簱X璧风偣
+     */
+    private Integer xStart = 0;
+
+    /**
+     * 璺戝簱X缁堢偣
+     */
+    private Integer xTarget = 0;
+
+    /**
+     * 璺戝簱X褰撳墠鐐逛綅
+     */
+    private Integer xCurrent = 0;
+
+    /**
+     * 璺戝簱Y璧风偣
+     */
+    private Integer yStart = 0;
+
+    /**
+     * 璺戝簱Y缁堢偣
+     */
+    private Integer yTarget = 0;
+
+    /**
+     * 璺戝簱Y褰撳墠鐐逛綅
+     */
+    private Integer yCurrent = 0;
 
     //鎬婚噷绋嬫暟
     @Data
@@ -222,7 +274,14 @@
         if (this.getFree() == null) {
             return "";
         }
-        return this.getFree() == 1 ? "绌洪棽" : "杩愯涓�";
+        return this.getFree() == 0 ? "杩愯涓�" : "绌洪棽";
+    }
+
+    public String getWorkingMode$() {
+        if (this.getWorkingMode() == null) {
+            return "";
+        }
+        return this.getWorkingMode() == 0 ? "鎵嬪姩" : "鑷姩";
     }
 
     public String getLoadState$() {
@@ -251,7 +310,7 @@
             return "";
         }
 
-        switch (this.getRunDir()) {
+        switch (this.getLiftPosition()) {
             case 0:
                 return "鏈煡";
             case 1:
@@ -380,6 +439,13 @@
         return NavigatePositionConvert.nyXyzToLocNo(this.getPoint().getX(), this.getPoint().getY(), this.getPoint().getZ());
     }
 
+    public String getPoint$$() {
+        if (this.getPoint() == null) {
+            return "";
+        }
+        return JSON.toJSONString(this.getPoint());
+    }
+
     public String getCoord$() {
         if (this.getCoord() == null) {
             return "";
@@ -387,65 +453,95 @@
         return JSON.toJSONString(this.getCoord());
     }
 
+    public String getErrCode$() {
+        if (this.getErrCode() == null) {
+            return "";
+        }
+        BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
+        BasShuttleErr basShuttleErr = basShuttleErrService.selectById(this.getErrCode());
+        if (basShuttleErr == null) {
+            return this.getErrCode().toString();
+        }
+        return basShuttleErr.getErrName();
+    }
+
     public void setPoint(NyShuttlePointClass point) {
         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
                 ;
-        if (!res) {
-            return res;
-        } else {
-            // 鐢甸噺
-            try {
-                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
-                if (chargeLine == null) {
-                    return false;
-                }
-                return this.getPowerPercent() >= chargeLine;
-            } catch (Exception e) {
-                News.error("fail", e);
-                return false;
-            }
-        }
+        return res;
+//        if (!res) {
+//            return res;
+//        } else {
+//            // 鐢甸噺
+//            try {
+//                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
+//                if (chargeLine == null) {
+//                    return false;
+//                }
+//                return this.getPowerPercent() >= chargeLine;
+//            } catch (Exception e) {
+//                News.error("fail", e);
+//                return false;
+//            }
+//        }
     }
 
     // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵�侊紝浼犲叆鐨則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
                 ;
-        if (!res) {
-            return res;
-        } else {
-            // 鐢甸噺
-            try {
-                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
-                return this.getPowerPercent() > chargeLine;
-            } catch (Exception e) {
-                News.error("fail", e);
-                return false;
-            }
-        }
+        return res;
+//        if (!res) {
+//            return res;
+//        } else {
+//            // 鐢甸噺
+//            try {
+//                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
+//                return this.getPowerPercent() > chargeLine;
+//            } catch (Exception e) {
+//                News.error("fail", e);
+//                return false;
+//            }
+//        }
     }
 
     // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵��
     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 isIdleNoCharge(int taskNo) {
+        boolean res = this.free == ShuttleStatusType.IDLE.id
+                && !this.pakMk
+                && this.errState == 0
+                && (this.taskNo == 0 || this.taskNo == taskNo)
                 && this.protocolStatus == ShuttleProtocolStatusType.IDLE.id
                 ;
         return res;
@@ -458,7 +554,7 @@
         }
 
         boolean res = this.free == ShuttleStatusType.IDLE.id
-                && this.pakMk
+                && !this.pakMk
                 && this.errState == 0
                 && this.taskNo == 0
                 && this.protocolStatusType.id == ShuttleProtocolStatusType.IDLE.id
@@ -481,11 +577,17 @@
                 if (chargeLine == null) {
                     return false;
                 }
-                return this.getPowerPercent() < chargeLine || this.minCellVoltage < 2900;
+                return this.getPowerPercent() < chargeLine;
             } catch (Exception e) {
                 News.error("fail", e);
                 return false;
             }
         }
     }
+
+    public void setShuttleNo(Short shuttleNo) {
+        if (shuttleNo != 0) {
+            this.shuttleNo = shuttleNo;
+        }
+    }
 }

--
Gitblit v1.9.1