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 | 375 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 235 insertions(+), 140 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 e29ec7d..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,38 +1,36 @@ 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; + +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 ShuttleAssignCommand assignCommand; + private Integer taskNo; /** * 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛� @@ -40,7 +38,7 @@ private Integer protocolStatus; /** - * 褰撳墠灏忚溅鐘舵�佹灇涓� + * 褰撳墠灏忚溅浣滀笟鐘舵�佹灇涓� */ private ShuttleProtocolStatusType protocolStatusType; @@ -55,126 +53,151 @@ 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; /** - * 閿欒淇℃伅鐮� + * 鏄惁鏈夋墭鐩� */ - 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 Integer speed; - /** - * 褰撳墠鐨勭數鍘嬪�� - */ - 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 Object extend; + + /** + * 绯荤粺娑堟伅 + */ + private String systemMsg; + + public String getProtocolStatus$() { + if (this.protocolStatusType == null) { + return ""; + } + return this.protocolStatusType.desc; } /** @@ -193,62 +216,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; } } - // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵�侊紝浼犲叆鐨則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(); } + return null; } //閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿 @@ -258,11 +252,112 @@ 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(); + } + + 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