From 1ff4b70e59b8c9ceb80d0a695d26b4419ed349f1 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期三, 08 一月 2025 09:48:53 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java | 255 +++++++++++++++++++++++++------------------------- 1 files changed, 129 insertions(+), 126 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 d370e72..003af3f 100644 --- a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java +++ b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java @@ -1,14 +1,14 @@ package com.zy.core.model.protocol; +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.BasShuttleService; +import com.zy.asrs.service.BasShuttleErrService; import com.zy.asrs.service.LocMastService; -import com.zy.core.News; -import com.zy.core.enums.ShuttleErrorCodeType; +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; @@ -17,22 +17,18 @@ */ @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; /** * 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛� @@ -40,7 +36,7 @@ private Integer protocolStatus; /** - * 褰撳墠灏忚溅鐘舵�佹灇涓� + * 褰撳墠灏忚溅浣滀笟鐘舵�佹灇涓� */ private ShuttleProtocolStatusType protocolStatusType; @@ -55,127 +51,130 @@ private String locNo; /** - * 灏忚溅蹇欑姸鎬佷綅 - * 1: 蹇� - * 0: 绌洪棽 + * 灏忚溅璁惧鐘舵�� */ - 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; /** - * 閿欒淇℃伅鐮� + * 鏄惁鏈夋墭鐩� */ - private Short statusErrorCode; + private Boolean hasPallet; /** - * PLC杈撳叆鐘舵�� + * 琛岄┒鏂瑰悜 */ - private Short plcInputStatus; + private String runDirection; /** - * 褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸�� + * 鏄惁涓哄厖鐢电姸鎬� */ - private Short currentOrBeforeCode; + private Boolean hasCharge; /** - * 璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲� + * 鐢垫睜鐢靛帇 */ - private Short codeOffsetX; + private Integer batteryVoltage; - /** - * 璇诲埌鐨勪簩缁寸爜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 Long deviceDataLog = System.currentTimeMillis(); + + /** + * 鎸囦护涓嬪彂鏃堕棿 + */ + private Long sendTime = 0L; + + /** + * 鏈�杩戜竴娆″湪绾挎椂闂� + */ + private Long lastOnlineTime = System.currentTimeMillis(); + + /** + * 鎵╁睍瀛楁 + */ + private Object extend; /** * 璁剧疆灏忚溅鐘舵�� @@ -193,41 +192,33 @@ 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 = 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; } //閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿 @@ -237,11 +228,23 @@ return null; } //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) - LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode.toString()); + 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(); + } + } -- Gitblit v1.9.1