From 90d9a759ad1e2aa53d041a1f1a4209212907cb00 Mon Sep 17 00:00:00 2001 From: qlsxk <qlsxk@qq.com> Date: 星期六, 27 九月 2025 14:20:11 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/NyLiftThread.java | 166 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 111 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java index d531239..cb077fb 100644 --- a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java @@ -3,13 +3,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.DateUtils; import com.core.common.SpringUtils; -import com.zy.asrs.entity.BasLift; import com.zy.asrs.entity.DeviceConfig; import com.zy.asrs.entity.DeviceDataLog; -import com.zy.asrs.service.BasLiftService; import com.zy.asrs.service.DeviceDataLogService; import com.zy.asrs.utils.Utils; import com.zy.common.ExecuteSupport; @@ -184,8 +181,6 @@ liftProtocol.setHasTray(data.getInteger("hasTray") == 1); //鏈夊皬杞� liftProtocol.setHasCar(data.getInteger("hasCar") == 1); - //鍑哄叆搴撴ā寮� - liftProtocol.setIOMode(data.getInteger("iOMode")); //鏁呴殰鐮� liftProtocol.setErrorCode(data.getInteger("errorCode")); //褰撳墠灞� @@ -236,7 +231,7 @@ this.realtimeOriginData = JSON.toJSONString(data); - if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) { + if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 2) { //閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰� //淇濆瓨鏁版嵁璁板綍 DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); @@ -356,29 +351,10 @@ } @Override - public CommandResponse switchIOMode(LiftCommand command) { - CommandResponse response = new CommandResponse(false); - try { - //鍙戝嚭璇锋眰 - String resultKey = requestCommand(command); - //鏌ヨ璇锋眰缁撴灉 - JSONObject result = queryCommandStatus(resultKey); - if (result == null) { - return response;//璇锋眰澶辫触 - } - if(!result.getString("result").equals("success")) { - return response;//璇锋眰澶辫触 - } - - this.liftProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿 - response.setMessage(JSON.toJSONString(result)); - response.setResult(true); - return response; - } catch (Exception e) { - e.printStackTrace(); - response.setMessage(e.getMessage()); - return response; - } + public CommandResponse switchIOMode(LiftIoModeType type) { + CommandResponse response = new CommandResponse(true); + liftProtocol.setIOMode(type); + return response; } @Override @@ -395,6 +371,7 @@ || this.liftProtocol.getPlcTaskNo() == null || this.liftProtocol.getProtocolStatus() == null || this.liftProtocol.getModel() == null + || this.liftProtocol.getDeviceStatus() == null || this.liftProtocol.getErrorCode() == null || this.liftProtocol.getExtend() == null ) { @@ -403,19 +380,51 @@ InnerLiftExtend extend = (InnerLiftExtend) this.liftProtocol.getExtend(); - boolean res = this.liftProtocol.getProtocolStatus() == LiftProtocolStatusType.IDLE.id -// && this.liftProtocol.getPlcTaskNo() == 0 - && this.liftProtocol.getTaskNo() == 0 - && this.liftProtocol.getModel() == 2 - && this.liftProtocol.getErrorCode() == 0 - && !extend.getFrontOverrun() - && !extend.getBackOverrun() - && !extend.getLeftOverrun() - && !extend.getRightOverrun() - && !extend.getOverHeight() - && !extend.getOverWeight() - ; - return res; + if (this.liftProtocol.getProtocolStatus() != LiftProtocolStatusType.IDLE.id) { + return false;//浠诲姟涓嶇┖闂� + } + + if (this.liftProtocol.getTaskNo() != 0) { + return false;//鏈変换鍔″彿 + } + + if (this.liftProtocol.getModel() != 2) { + return false;//闈炶嚜鍔� + } + + if (this.liftProtocol.getDeviceStatus() != LiftDeviceStatusType.IDLE.id) { + return false;//闈炵┖闂� + } + + if (this.liftProtocol.getErrorCode() != 0) { + return false;//鏈夋晠闅� + } + + if (extend.getFrontOverrun()) { + return false; + } + + if (extend.getBackOverrun()) { + return false; + } + + if (extend.getLeftOverrun()) { + return false; + } + + if (extend.getRightOverrun()) { + return false; + } + + if (extend.getOverHeight()) { + return false; + } + + if (extend.getOverWeight()) { + return false; + } + + return true; } @Override @@ -432,8 +441,8 @@ } } - if (this.liftProtocol.getProtocolStatus() == null - || this.liftProtocol.getModel() == null + if (this.liftProtocol.getModel() == null + || this.liftProtocol.getDeviceStatus() == null || this.liftProtocol.getErrorCode() == null || this.liftProtocol.getExtend() == null ) { @@ -442,17 +451,43 @@ InnerLiftExtend extend = (InnerLiftExtend) this.liftProtocol.getExtend(); - boolean res = this.liftProtocol.getProtocolStatus() == LiftProtocolStatusType.IDLE.id - && this.liftProtocol.getModel() == 2 - && this.liftProtocol.getErrorCode() == 0 - && !extend.getFrontOverrun() - && !extend.getBackOverrun() - && !extend.getLeftOverrun() - && !extend.getRightOverrun() - && !extend.getOverHeight() - && !extend.getOverWeight() - ; - return res; + if (this.liftProtocol.getModel() != 2) { + return false;//闈炶嚜鍔� + } + + if (this.liftProtocol.getDeviceStatus() != LiftDeviceStatusType.IDLE.id) { + return false;//闈炵┖闂� + } + + if (this.liftProtocol.getErrorCode() != 0) { + return false;//鏈夋晠闅� + } + + if (extend.getFrontOverrun()) { + return false; + } + + if (extend.getBackOverrun()) { + return false; + } + + if (extend.getLeftOverrun()) { + return false; + } + + if (extend.getRightOverrun()) { + return false; + } + + if (extend.getOverHeight()) { + return false; + } + + if (extend.getOverWeight()) { + return false; + } + + return true; } @Override @@ -495,6 +530,10 @@ command.setPick(pick); command.setPut(put); + LiftStaProtocol pickSta = findSta(pick); + LiftStaProtocol putSta = findSta(put); + command.setPickLev(pickSta.getLev()); + command.setPutLev(putSta.getLev()); return command; } @@ -507,6 +546,10 @@ command.setPick(pick); command.setPut(put); + LiftStaProtocol pickSta = findSta(pick); + LiftStaProtocol putSta = findSta(put); + command.setPickLev(pickSta.getLev()); + command.setPutLev(putSta.getLev()); return command; } @@ -519,6 +562,10 @@ command.setPick(pick); command.setPut(put); + LiftStaProtocol pickSta = findSta(pick); + LiftStaProtocol putSta = findSta(put); + command.setPickLev(pickSta.getLev()); + command.setPutLev(putSta.getLev()); return command; } @@ -643,6 +690,15 @@ } } + private LiftStaProtocol findSta(Integer staNo) { + for (LiftStaProtocol liftStaProtocol : this.liftStaProtocols) { + if (liftStaProtocol.getSiteId().equals(staNo)) { + return liftStaProtocol; + } + } + return null; + } + /** * 鎵╁睍瀛楁 */ -- Gitblit v1.9.1