From 1d624dfdb040825ffecba6c792c480be662b2dbc Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 10 四月 2025 17:39:56 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java | 421 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 245 insertions(+), 176 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 b82f97b..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,123 +1,66 @@ package com.zy.core.model.protocol; -import com.zy.core.enums.ShuttleStatusType; +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; /** * 浠诲姟鍙� */ - public Short taskNo = 0; + private Integer taskNo; /** - * 鎺� + * 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛� */ - public Short row; + private Integer protocolStatus; /** - * 鍒� + * 褰撳墠灏忚溅浣滀笟鐘舵�佹灇涓� */ - public Short bay; + private ShuttleProtocolStatusType protocolStatusType; /** - * 灞� + * 婧愬簱浣� */ - public Short lev; + private String sourceLocNo; /** - * 鎺у埗鎸囦护瀛� + * 鐩爣搴撲綅 */ - private Integer commandWord; + private String locNo; /** - * 鍚浜岀淮缂栧彿 + * 灏忚溅璁惧鐘舵��0:蹇欑 1:绌洪棽 */ - private Integer startCodeNum; + private Integer deviceStatus; /** - * 涓棿浜岀淮缂栧彿 + * 灏忚溅妯″紡锛�0锛氭墜鍔� 1锛氳嚜鍔� */ - private Integer middleCodeNum; - - /** - * 鐩爣浜岀淮缂栧彿 - */ - private Integer distCodeNum; - - /** - * 璧风偣鍒扮洰鏍囩偣鐨勮窛绂婚暱搴� - */ - private Integer startToDistDistance; - - /** - * 涓棿鐐瑰埌鐩爣鐐圭殑璺濈闀垮害 - */ - private Integer middleToDistDistance; - - /** - * 灏忚溅杩愯鏂瑰悜 - */ - private Integer runDirection; - - /** - * 鎵樼洏椤跺崌 - */ - private Integer palletLift; - - /** - * 灏忚溅寮哄埗绉诲姩璺濈 - */ - private Integer forceMoveDistance; - - /** - * 鍏呯數寮�鍏� - */ - private Integer chargeSwitch; - - /** - * 灏忚溅IO鎺у埗 - */ - private Integer IOControl; - - /** - * 灏忚溅杩愯閫熷害 - */ - private Integer runSpeed; - - /** - * 灏忚溅闆疯揪澶囩敤 - */ - private Integer radarTmp; - - /** - * 鎸囦护缁撴潫浣� - */ - private Integer commandEnd; - - - /** - * 灏忚溅蹇欑姸鎬佷綅 - * true: 蹇� - * false: 绌洪棽 - */ - private Boolean busyStatus; - - /** - * 灏忚溅蹇欑姸鎬佷綅鏋氫妇 - */ - private ShuttleStatusType busyStatusType; + private Integer mode; /** * 褰撳墠浜岀淮鐮� @@ -126,169 +69,295 @@ private String currentCode; /** - * 鐢垫睜鐢甸噺鐧惧垎姣� + * 鐢垫睜鐢甸噺 */ - private Double batteryPower; - - /** - * 鐢垫睜娓╁害 - */ - private Double batteryTemp; + private String batteryPower; /** * 閿欒缂栧彿 */ - private Integer errorCode; + private String errorCode; + + + //**********************闈炲繀椤诲睘鎬э紝瀹為檯浣跨敤涓彲鑳藉瓨鍦ㄧ┖鍊�********************** /** - * Plc杈撳嚭鐘舵�両O + * 鐢垫睜娓╁害 */ - private byte plcOutputStatusIO; + private String batteryTemp; /** - * 閿欒淇℃伅鐮� + * 鏄惁椤跺崌 */ - private Integer statusErrorCode; + private Boolean hasLift; /** - * PLC杈撳叆鐘舵�� + * 鏄惁鏈夋墭鐩� */ - private byte plcInputStatus; + private Boolean hasPallet; /** - * 褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸�� + * 琛岄┒鏂瑰悜 */ - private String currentOrBeforeCode; + private String runDirection; /** - * 璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲� + * 鏄惁涓哄厖鐢电姸鎬� */ - private Integer codeOffsetX; + private Boolean hasCharge; /** - * 璇诲埌鐨勪簩缁寸爜Y鏂瑰悜鍋忕Щ閲� + * 鐢垫睜鐢靛帇 */ - private Integer codeOffsetY; + private Integer batteryVoltage; /** - * 褰撳墠鐨勭數鍘嬪�� + * 杩愯閫熷害 */ - private Double currentVoltage; + private Integer speed; + + + //**********************绯荤粺鑷韩鎵�闇�灞炴��********************** + /** + * 浣滀笟鏍囪 false琛ㄧず姝e湪浣滀笟 + */ + private Boolean pakMk = true; /** - * 褰撳墠鐨勬ā鎷熼噺鍊� + * 璺戝簱鐘舵�� */ - private Integer currentAnalogValue; + private Boolean moveLoc = false; /** - * 褰撳墠鐨勫崌闄嶄己鏈嶉�熷害 + * 璺戝簱绫诲瀷锛�0:璺戣建閬擄紝1锛氳窇搴撲綅 */ - private Double currentLiftServoSpeed; + private Integer moveType = 0; /** - * 褰撳墠鐨勮璧颁己鏈嶉�熷害 + * 璺戝簱X璧风偣 */ - private Double currentMoveServoSpeed; + private Integer xStart = 0; /** - * 褰撳墠鐨勫崌闄嶄己鏈嶈礋杞界巼 + * 璺戝簱X缁堢偣 */ - private Double currentLiftServoLoad; + private Integer xTarget = 0; /** - * 褰撳墠鐨勮璧颁己鏈嶈礋杞界巼 + * 璺戝簱X褰撳墠鐐逛綅 */ - private Double currentMoveServoLoad; + private Integer xCurrent = 0; /** - * 浣滀笟鏍囪 + * 璺戝簱Y璧风偣 */ - private String pakMk = "-"; - - // 浠诲姟淇℃伅 --------------------------------------------------------- - /** - * 96.鍏ュ簱浠诲姟涓� - */ - private boolean pakInTask; + private Integer yStart = 0; /** - * 97. 鍑哄簱浠诲姟涓� + * 璺戝簱Y缁堢偣 */ - private boolean pakOutTask; + private Integer yTarget = 0; /** - * 98. 绉诲簱浠诲姟涓� + * 璺戝簱Y褰撳墠鐐逛綅 */ - private boolean pakMoveTask; + private Integer yCurrent = 0; /** - * 99. 鍥炲師鐐逛换鍔′腑 + * 婕旂ず妯″紡 */ - private boolean goHpTask; + private Boolean demo = false; /** - * 100. 鍘诲弽鍘熺偣浠诲姟涓� + * 鏃ュ織閲囬泦鏃堕棿 */ - private boolean goOHpTask; + private Long deviceDataLog = System.currentTimeMillis(); /** - * 101. 鍘诲師鐐归伩璁╀綅 + * 鎸囦护涓嬪彂鏃堕棿 */ - private boolean goHpAvoid; + private Long sendTime = 0L; /** - * 102. 鍘诲弽鍘熺偣閬胯浣� + * 鏈�杩戜竴娆″湪绾挎椂闂� */ - private boolean goOHpAvoid; + private Long lastOnlineTime = System.currentTimeMillis(); /** - * 104. 鍏ュ簱鍙栫┖缁撴潫 + * 鎵╁睍瀛楁 */ - private boolean pakInEmpty; + private Object extend; /** - * 105. 鍏ュ簱姝e父缁撴潫 + * 绯荤粺娑堟伅 */ - private boolean pakInFinish; + private String systemMsg; - /** - * 106. 鍑哄簱鍙栫┖缁撴潫 - */ - private boolean pakOutEmpty; - - /** - * 107. 鍑哄簱姝e父缁撴潫 - */ - private boolean pakOutFinish; - - /** - * 108. 鍘诲師鐐归伩璁╁畬鎴� - */ - private boolean goHpAvoidFinish; - - /** - * 109. 鍘诲弽鍘熺偣閬胯瀹屾垚 - */ - private boolean goOHpAvoidFinish; - - /** - * 110. 鍘诲師鐐归伩璁╁畬鎴� - */ - private boolean goHpAvoidErr; - - /** - * 111. 鍘诲弽鍘熺偣閬胯瀹屾垚 - */ - private boolean goOHpAvoidErr; - - public void setBusyStatus(Boolean 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.booleanValue(); - this.busyStatusType = type; + /** + * 璁剧疆灏忚溅鐘舵�� + */ + public void setProtocolStatus(Integer status) { + this.protocolStatus = status; + this.protocolStatusType = ShuttleProtocolStatusType.get(status); + } + + /** + * 璁剧疆灏忚溅鐘舵�� + */ + 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