From d9505e143cdf452c3a33752b380ee1b3a410601d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 16 十月 2025 14:48:52 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java | 457 +++++++++++++++++++++++++++++++--------------------------
1 files changed, 249 insertions(+), 208 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 e736217..126af7d 100644
--- a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
@@ -1,42 +1,38 @@
package com.zy.core.model.protocol;
+import com.core.common.Cools;
import com.core.common.SpringUtils;
-import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.BasShuttleErr;
import com.zy.asrs.entity.LocMast;
-import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.BasShuttleErrService;
-import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.LocMastService;
-import com.zy.core.News;
-import com.zy.core.enums.ShuttleErrorCodeType;
+import com.zy.common.model.NavigateNode;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.enums.RedisKeyType;
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.HashMap;
+import java.util.List;
/**
* 鍥涘悜绌挎杞�
*/
@Slf4j
@Data
-public class ShuttleProtocol {
+public class ShuttleProtocol implements Cloneable {
+ //**********************蹇呴』瀛樺湪灞炴��**********************
/**
* 鍥涘悜绌挎杞﹀彿
*/
- private Short shuttleNo;
+ private Integer shuttleNo;
/**
* 浠诲姟鍙�
*/
- private Short taskNo = 0;
-
- /**
- * 浠诲姟鎸囦护
- */
- private ShuttleAssignCommand assignCommand;
+ private Integer taskNo;
/**
* 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛�
@@ -44,7 +40,7 @@
private Integer protocolStatus;
/**
- * 褰撳墠灏忚溅鐘舵�佹灇涓�
+ * 褰撳墠灏忚溅浣滀笟鐘舵�佹灇涓�
*/
private ShuttleProtocolStatusType protocolStatusType;
@@ -59,146 +55,166 @@
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;
+
+
+ //**********************闈炲繀椤诲睘鎬э紝瀹為檯浣跨敤涓彲鑳藉瓨鍦ㄧ┖鍊�**********************
/**
- * 閿欒缂栧彿鏋氫妇
+ * 鐢垫睜娓╁害
*/
- private ShuttleErrorCodeType errorCodeType;
+ private String batteryTemp;
/**
- * Plc杈撳嚭鐘舵�両O
+ * 鏄惁椤跺崌
*/
- private Short plcOutputStatusIO;
+ private Boolean hasLift;
/**
- * Plc杈撳嚭鐘舵�両O-椤跺崌浣�
+ * 鏄惁鏈夋墭鐩�
*/
- private Boolean plcOutputLift;
+ private Boolean hasPallet;
/**
- * Plc杈撳嚭鐘舵�両O-鎹㈠悜浣�
+ * 琛岄┒鏂瑰悜
*/
- private Boolean plcOutputTransfer;
+ private String runDirection;
/**
- * Plc杈撳嚭鐘舵�両O-鎶遍椄浣�
+ * 鏄惁涓哄厖鐢电姸鎬�
*/
- private Boolean plcOutputBrake;
+ private Boolean hasCharge;
/**
- * Plc杈撳嚭鐘舵�両O-鍏呯數浣�
+ * 鐢垫睜鐢靛帇
*/
- private Boolean plcOutputCharge;
+ private Integer batteryVoltage;
/**
- * 閿欒淇℃伅鐮�
+ * 杩愯閫熷害
*/
- private Short statusErrorCode;
+ private Integer speed;
- /**
- * PLC杈撳叆鐘舵��
- */
- private Short plcInputStatus;
+ //**********************绯荤粺鑷韩鎵�闇�灞炴��**********************
/**
- * 褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸��
- */
- private Short currentOrBeforeCode;
-
- /**
- * 璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲�
- */
- private Short codeOffsetX;
-
- /**
- * 璇诲埌鐨勪簩缁寸爜Y鏂瑰悜鍋忕Щ閲�
- */
- private Short codeOffsetY;
-
- /**
- * 褰撳墠鐨勭數鍘嬪��
- */
- private Short currentVoltage;
-
- /**
- * 褰撳墠鐨勬ā鎷熼噺鍊�
- */
- private Short currentAnalogValue;
-
- /**
- * 褰撳墠鐨勫崌闄嶄己鏈嶉�熷害
- */
- private Short currentLiftServoSpeed;
-
- /**
- * 褰撳墠鐨勮璧颁己鏈嶉�熷害
- */
- private Short currentMoveServoSpeed;
-
- /**
- * 褰撳墠鐨勫崌闄嶄己鏈嶈礋杞界巼
- */
- private Short currentLiftServoLoad;
-
- /**
- * 褰撳墠鐨勮璧颁己鏈嶈礋杞界巼
- */
- private Short currentMoveServoLoad;
-
- /**
- * 浣滀笟鏍囪
+ * 浣滀笟鏍囪 false琛ㄧず姝e湪浣滀笟
*/
private Boolean pakMk = true;
- public void setBusyStatus(Short status) {
- this.busyStatus = status;
- this.busyStatusType = ShuttleStatusType.get(status);
- }
+ /**
+ * 璺戝簱鐘舵��
+ */
+ private Boolean moveLoc = false;
- public void setBusyStatus(ShuttleStatusType type) {
- this.busyStatus = type.id.shortValue();
- this.busyStatusType = type;
- }
+ /**
+ * 璺戝簱绫诲瀷锛�0:璺戣建閬擄紝1锛氳窇搴撲綅
+ */
+ private Integer moveType = 0;
- //鑾峰彇鐢垫睜鐢甸噺
- public Short getBatteryPower$() {
- return (short) (this.batteryPower * 0.1);
- }
+ /**
+ * 璺戝簱X璧风偣
+ */
+ private Integer xStart = 0;
- //鑾峰彇鐢垫睜娓╁害
- public Short getBatteryTemp$() {
- return (short) (this.batteryTemp * 0.1);
+ /**
+ * 璺戝簱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;
+
+ /**
+ * 婕旂ず妯″紡
+ */
+ private Boolean demo = false;
+
+ /**
+ * 鏃ュ織閲囬泦鏃堕棿
+ */
+ private Long deviceDataLog = System.currentTimeMillis();
+
+ /**
+ * 鎸囦护涓嬪彂鏃堕棿
+ */
+ private Long sendTime = 0L;
+
+ /**
+ * 鏈�杩戜竴娆″湪绾挎椂闂�
+ */
+ private Long lastOnlineTime = System.currentTimeMillis();
+
+ /**
+ * 灏忚溅绌洪棽鏃堕棿
+ */
+ private Long idleTime = System.currentTimeMillis();
+
+ /**
+ * 鎵╁睍瀛楁
+ */
+ private Object extend;
+
+ /**
+ * 绯荤粺娑堟伅
+ */
+ private String systemMsg;
+
+ /**
+ * 浜ら�氱鍒�
+ */
+ private Boolean trafficControl = false;
+
+ /**
+ * 浜ら�氱鍒禢odes
+ */
+ private List<NavigateNode> trafficControlNodes = null;
+
+ public String getProtocolStatus$() {
+ if (this.protocolStatusType == null) {
+ return "";
+ }
+ return this.protocolStatusType.desc;
}
/**
@@ -217,97 +233,41 @@
this.protocolStatusType = status;
}
- /**
- * 璁剧疆閿欒缂栧彿
- */
- public void setErrorCode(Short errorCode) {
- this.errorCode = errorCode;
- this.errorCodeType = ShuttleErrorCodeType.get(errorCode.intValue());
- }
-
- /**
- * 璁剧疆閿欒缂栧彿
- */
- public void setErrorCode(ShuttleErrorCodeType type) {
- this.errorCode = type.id.shortValue();
- this.errorCodeType = type;
- }
-
- // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵��
- public Boolean isIdle() {
- boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE)
- && this.pakMk.equals(true)
- && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL)
- && this.taskNo == 0
- ;
- if (!res) {
- return res;
- } else {
- // 鐢甸噺
- try {
- Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
- return this.getBatteryPower$() > chargeLine;
- } catch (Exception e) {
- News.error("fail", e);
- return false;
+ public Integer getTaskNo() {
+ RedisUtil redisUtil = null;
+ try {
+ redisUtil = SpringUtils.getBean(RedisUtil.class);
+ }catch (Exception e) {}
+ 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;
}
- // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵�侊紝浼犲叆鐨則askNo鍜屽綋鍓峵askNo鐩稿悓鏃跺厑璁告斁琛�
- public Boolean isIdle(Short taskNo) {
- boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE)
- && this.pakMk.equals(true)
- && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL)
- && (this.taskNo == 0 || this.taskNo == taskNo)
- ;
- if (!res) {
- return res;
- } else {
- // 鐢甸噺
- try {
- Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
- return this.getBatteryPower$() > chargeLine;
- } catch (Exception e) {
- News.error("fail", e);
- return false;
- }
+ @Override
+ public ShuttleProtocol clone() {
+ try {
+ return (ShuttleProtocol) super.clone();
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
}
- }
-
- // 鏄惁婊¤冻鍏呯數鐘舵��
- public Boolean isRequireCharge() {
- if (this.busyStatusType == null || this.pakMk == null || this.errorCodeType == null || this.taskNo == null) {
- return false;
- }
-
- boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE)
- && this.pakMk.equals(true)
- && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL)
- && this.taskNo == 0
- ;
- if (!res) {
- return res;
- } else {
- // 鐢甸噺灏忎簬闃堝�兼垨鐢靛帇灏忎簬48V锛岄渶瑕佽繘琛屽厖鐢�
- try {
- Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
- return this.getBatteryPower$() < chargeLine || this.currentVoltage < 480;
- } catch (Exception e) {
- News.error("fail", e);
- return false;
- }
- }
+ return null;
}
//閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿
public String getCurrentLocNo() {
- LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
+ LocMastService locMastService = null;
+ try {
+ locMastService = SpringUtils.getBean(LocMastService.class);
+ }catch (Exception e) {}
if (locMastService == null) {
return null;
}
//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
- LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode.toString());
+ LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
if (currentLocMast == null) {
return null;
}
@@ -315,32 +275,113 @@
}
public String getStatusErrorCode$() {
- BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
- BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(this.statusErrorCode.intValue());
+ BasShuttleErrService basShuttleErrService = null;
+ try {
+ basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
+ }catch (Exception e) {}
+ if (basShuttleErrService == null) {
+ return "";
+ }
+ if (this.errorCode == null) {
+ return "";
+ }
+ BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(Integer.valueOf(this.errorCode));
if (basShuttleErr == null) {
- return null;
+ return this.errorCode;
}
return basShuttleErr.getErrName();
}
- public void setCurrentCode(Short currentCode) {
- this.currentCode = currentCode;
- LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
- if (locMastService != null) {
- LocMast locMast = locMastService.queryByQrCode(currentCode.toString());
- if (locMast == null) {
- //鏌ヤ笉鍒板簱浣嶅彿锛屾煡璇㈡槸鍚︿负绔欑偣
- BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
- if (basDevpService != null) {
- BasDevp basDevp = basDevpService.queryByLocNo(currentCode.toString());
- if (basDevp != null) {
- this.locNo = basDevp.getLocNo();
- }
- }
- }else{
- this.locNo = locMast.getLocNo();
- }
+ 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<>();
+ LocMastService locMastService = null;
+ try {
+ locMastService = SpringUtils.getBean(LocMastService.class);
+ }catch (Exception e) {}
+ if (locMastService == null) {
+ return map;
+ }
+
+ if (this.currentCode == 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