From e83761d390b593cff8b7c17144529e92eb482bd6 Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期三, 16 四月 2025 16:38:04 +0800
Subject: [PATCH] 1

---
 src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java |  342 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 238 insertions(+), 104 deletions(-)

diff --git a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
index 7205ca1..b785a03 100644
--- a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
@@ -1,31 +1,46 @@
 package com.zy.core.model.protocol;
 
-import com.zy.core.enums.ShuttleStatusType;
-import com.zy.core.model.command.ShuttleAssignCommand;
+import com.core.common.Cools;
+import com.core.common.SpringUtils;
+import com.zy.asrs.entity.BasShuttleErr;
+import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.service.BasShuttleErrService;
+import com.zy.asrs.service.LocMastService;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.enums.RedisKeyType;
+import com.zy.core.enums.ShuttleProtocolStatusType;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
+
+import java.util.HashMap;
 
 /**
  * 鍥涘悜绌挎杞�
  */
 @Slf4j
 @Data
-public class ShuttleProtocol {
+public class ShuttleProtocol implements Cloneable {
 
+    //**********************蹇呴』瀛樺湪灞炴��**********************
     /**
      * 鍥涘悜绌挎杞﹀彿
      */
-    private Short shuttleNo;
+    private Integer shuttleNo;
 
     /**
      * 浠诲姟鍙�
      */
-    private Short taskNo = 0;
+    private Integer taskNo;
 
     /**
-     * 浠诲姟鎸囦护
+     * 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛�
      */
-    private ShuttleAssignCommand assignCommand;
+    private Integer protocolStatus;
+
+    /**
+     * 褰撳墠灏忚溅浣滀笟鐘舵�佹灇涓�
+     */
+    private ShuttleProtocolStatusType protocolStatusType;
 
     /**
      * 婧愬簱浣�
@@ -38,192 +53,311 @@
     private String locNo;
 
     /**
-     * 灏忚溅蹇欑姸鎬佷綅
-     * 1: 蹇�
-     * 0: 绌洪棽
+     * 灏忚溅璁惧鐘舵��0:蹇欑 1:绌洪棽
      */
-    private Short busyStatus;
+    private Integer deviceStatus;
 
     /**
-     * 灏忚溅蹇欑姸鎬佷綅鏋氫妇
+     * 灏忚溅妯″紡锛�0锛氭墜鍔� 1锛氳嚜鍔�
      */
-    private ShuttleStatusType busyStatusType;
+    private Integer mode;
 
     /**
      * 褰撳墠浜岀淮鐮�
      * 0涓虹┖
      */
-    private Short currentCode;
+    private String currentCode;
 
     /**
-     * 鐢垫睜鐢甸噺鐧惧垎姣�
+     * 鐢垫睜鐢甸噺
      */
-    private Short batteryPower;
-
-    /**
-     * 鐢垫睜娓╁害
-     */
-    private Short batteryTemp;
+    private String batteryPower;
 
     /**
      * 閿欒缂栧彿
      */
-    private Short errorCode;
+    private String errorCode;
+
+
+    //**********************闈炲繀椤诲睘鎬э紝瀹為檯浣跨敤涓彲鑳藉瓨鍦ㄧ┖鍊�**********************
 
     /**
-     * Plc杈撳嚭鐘舵�両O
+     * 鐢垫睜娓╁害
      */
-    private Short plcOutputStatusIO;
+    private String batteryTemp;
 
     /**
-     * 閿欒淇℃伅鐮�
+     * 鏄惁椤跺崌
      */
-    private Short statusErrorCode;
+    private Boolean hasLift;
 
     /**
-     * PLC杈撳叆鐘舵��
+     * 鏄惁鏈夋墭鐩�
      */
-    private Short plcInputStatus;
+    private Boolean hasPallet;
 
     /**
-     * 褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸��
+     * 琛岄┒鏂瑰悜
      */
-    private Short currentOrBeforeCode;
+    private String runDirection;
 
     /**
-     * 璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲�
+     * 鏄惁涓哄厖鐢电姸鎬�
      */
-    private Short codeOffsetX;
+    private Boolean hasCharge;
 
     /**
-     * 璇诲埌鐨勪簩缁寸爜Y鏂瑰悜鍋忕Щ閲�
+     * 鐢垫睜鐢靛帇
      */
-    private Short codeOffsetY;
+    private Integer batteryVoltage;
 
     /**
-     * 褰撳墠鐨勭數鍘嬪��
+     * 杩愯閫熷害
      */
-    private Short currentVoltage;
+    private Integer speed;
 
-    /**
-     * 褰撳墠鐨勬ā鎷熼噺鍊�
-     */
-    private Short currentAnalogValue;
 
+    //**********************绯荤粺鑷韩鎵�闇�灞炴��**********************
     /**
-     * 褰撳墠鐨勫崌闄嶄己鏈嶉�熷害
-     */
-    private Short currentLiftServoSpeed;
-
-    /**
-     * 褰撳墠鐨勮璧颁己鏈嶉�熷害
-     */
-    private Short currentMoveServoSpeed;
-
-    /**
-     * 褰撳墠鐨勫崌闄嶄己鏈嶈礋杞界巼
-     */
-    private Short currentLiftServoLoad;
-
-    /**
-     * 褰撳墠鐨勮璧颁己鏈嶈礋杞界巼
-     */
-    private Short currentMoveServoLoad;
-
-    /**
-     * 浣滀笟鏍囪
+     * 浣滀笟鏍囪 false琛ㄧず姝e湪浣滀笟
      */
     private Boolean pakMk = true;
 
-    // 浠诲姟淇℃伅 ---------------------------------------------------------
     /**
-     * 96.鍏ュ簱浠诲姟涓�
+     * 璺戝簱鐘舵��
      */
-    private boolean pakInTask;
+    private Boolean moveLoc = false;
 
     /**
-     * 97. 鍑哄簱浠诲姟涓�
+     * 璺戝簱绫诲瀷锛�0:璺戣建閬擄紝1锛氳窇搴撲綅
      */
-    private boolean pakOutTask;
+    private Integer moveType = 0;
 
     /**
-     * 98. 绉诲簱浠诲姟涓�
+     * 璺戝簱X璧风偣
      */
-    private boolean pakMoveTask;
+    private Integer xStart = 0;
 
     /**
-     * 99. 鍥炲師鐐逛换鍔′腑
+     * 璺戝簱X缁堢偣
      */
-    private boolean goHpTask;
+    private Integer xTarget = 0;
 
     /**
-     * 100. 鍘诲弽鍘熺偣浠诲姟涓�
+     * 璺戝簱X褰撳墠鐐逛綅
      */
-    private boolean goOHpTask;
+    private Integer xCurrent = 0;
 
     /**
-     * 101. 鍘诲師鐐归伩璁╀綅
+     * 璺戝簱Y璧风偣
      */
-    private boolean goHpAvoid;
+    private Integer yStart = 0;
 
     /**
-     * 102. 鍘诲弽鍘熺偣閬胯浣�
+     * 璺戝簱Y缁堢偣
      */
-    private boolean goOHpAvoid;
+    private Integer yTarget = 0;
 
     /**
-     * 104. 鍏ュ簱鍙栫┖缁撴潫
+     * 璺戝簱Y褰撳墠鐐逛綅
      */
-    private boolean pakInEmpty;
+    private Integer yCurrent = 0;
 
     /**
-     * 105. 鍏ュ簱姝e父缁撴潫
+     * 婕旂ず妯″紡
      */
-    private boolean pakInFinish;
+    private Boolean demo = false;
 
     /**
-     * 106. 鍑哄簱鍙栫┖缁撴潫
+     * 鏃ュ織閲囬泦鏃堕棿
      */
-    private boolean pakOutEmpty;
+    private Long deviceDataLog = System.currentTimeMillis();
 
     /**
-     * 107. 鍑哄簱姝e父缁撴潫
+     * 鎸囦护涓嬪彂鏃堕棿
      */
-    private boolean pakOutFinish;
+    private Long sendTime = 0L;
 
     /**
-     * 108. 鍘诲師鐐归伩璁╁畬鎴�
+     * 鏈�杩戜竴娆″湪绾挎椂闂�
      */
-    private boolean goHpAvoidFinish;
+    private Long lastOnlineTime = System.currentTimeMillis();
 
     /**
-     * 109. 鍘诲弽鍘熺偣閬胯瀹屾垚
+     * 鎵╁睍瀛楁
      */
-    private boolean goOHpAvoidFinish;
+    private Object extend;
 
     /**
-     * 110. 鍘诲師鐐归伩璁╁畬鎴�
+     * 绯荤粺娑堟伅
      */
-    private boolean goHpAvoidErr;
+    private String systemMsg;
 
-    /**
-     * 111. 鍘诲弽鍘熺偣閬胯瀹屾垚
-     */
-    private boolean goOHpAvoidErr;
-
-    public void setBusyStatus(Short status) {
-        this.busyStatus = status;
-        this.busyStatusType = ShuttleStatusType.get(status);
+    public String getProtocolStatus$() {
+        if (this.protocolStatusType == null) {
+            return "";
+        }
+        return this.protocolStatusType.desc;
     }
 
-    public void setBusyStatus(ShuttleStatusType type) {
-        this.busyStatus = type.id.shortValue();
-        this.busyStatusType = type;
+    /**
+     * 璁剧疆灏忚溅鐘舵��
+     */
+    public void setProtocolStatus(Integer status) {
+        this.protocolStatus = status;
+        this.protocolStatusType = ShuttleProtocolStatusType.get(status);
     }
 
-    //鑾峰彇鐢垫睜鐢甸噺
-    public Short getBatteryPower() {
-        return (short) (this.batteryPower * 0.1);
+    /**
+     * 璁剧疆灏忚溅鐘舵��
+     */
+    public void setProtocolStatus(ShuttleProtocolStatusType status) {
+        this.protocolStatus = status.id;
+        this.protocolStatusType = status;
+    }
+
+    public Integer getTaskNo() {
+        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+        if (null != redisUtil) {
+            Object o = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + this.shuttleNo);
+            if (!Cools.isEmpty(o)) {
+                this.taskNo = Integer.parseInt(String.valueOf(o));
+            }
+        }
+        return this.taskNo == null ? 0 : this.taskNo;
+    }
+
+    public synchronized void setSyncTaskNo(Integer taskNo) {
+        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+        if (null != redisUtil) {
+            redisUtil.set(RedisKeyType.SHUTTLE_FLAG.key + this.shuttleNo, taskNo);
+            this.taskNo = taskNo;
+        }
+    }
+
+    @Override
+    public ShuttleProtocol clone() {
+        try {
+            return (ShuttleProtocol) super.clone();
+        } catch (CloneNotSupportedException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    //閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿
+    public String getCurrentLocNo() {
+        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
+        if (locMastService == null) {
+            return null;
+        }
+        //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+        LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
+        if (currentLocMast == null) {
+            return null;
+        }
+        return currentLocMast.getLocNo();
+    }
+
+    public String getStatusErrorCode$() {
+        BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
+        if (this.errorCode == null) {
+            return "";
+        }
+        BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(Integer.valueOf(this.errorCode));
+        if (basShuttleErr == null) {
+            return this.errorCode;
+        }
+        return basShuttleErr.getErrName();
+    }
+
+    public String getMode$() {
+        if (this.mode == null) {
+            return "";
+        }
+        if (this.mode == 0) {
+            return "鎵嬪姩";
+        } else if (this.mode == 1) {
+            return "鑷姩";
+        }
+
+        return "";
+    }
+
+    public String getDeviceStatus$() {
+        if (this.deviceStatus == null) {
+            return "";
+        }
+        if (this.deviceStatus == 0) {
+            return "蹇欑";
+        } else if (this.deviceStatus == 1) {
+            return "绌洪棽";
+        }
+
+        return "";
+    }
+
+    public String getHasLift$() {
+        if (this.hasLift == null) {
+            return "";
+        }
+
+        return this.hasLift ? "Y" : "N";
+    }
+
+    public String getHasCharge$() {
+        if (this.hasCharge == null) {
+            return "";
+        }
+
+        return this.hasCharge ? "Y" : "N";
+    }
+
+    public String getHasPallet$() {
+        if (this.hasPallet == null) {
+            return "";
+        }
+
+        return this.hasPallet ? "Y" : "N";
+    }
+
+    public String getPakMk$() {
+        if (this.pakMk == null) {
+            return "";
+        }
+
+        return this.pakMk ? "Y" : "N";
+    }
+
+    public String getDemo$() {
+        if (this.demo == null) {
+            return "";
+        }
+
+        return this.demo ? "Y" : "N";
+    }
+
+    public HashMap<String, Object> getPoint() {
+        HashMap<String, Object> map = new HashMap<>();
+        if (this.currentCode == null) {
+            return map;
+        }
+
+        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
+        if (locMastService == null) {
+            return map;
+        }
+
+        //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+        LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
+        if (currentLocMast == null) {
+            return map;
+        }
+
+        map.put("x", currentLocMast.getRow1());
+        map.put("y", currentLocMast.getBay1());
+        map.put("z", currentLocMast.getLev1());
+        return map;
     }
 
 }

--
Gitblit v1.9.1