From f619c9d1736a3690382b58316183cee4f7dc67e6 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期六, 04 十一月 2023 13:58:15 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/utils/Utils.java | 95 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 91 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java index c1c8732..afd653a 100644 --- a/src/main/java/com/zy/asrs/utils/Utils.java +++ b/src/main/java/com/zy/asrs/utils/Utils.java @@ -20,6 +20,7 @@ import com.zy.common.utils.NavigatePositionConvert; import com.zy.common.utils.NavigateUtils; import com.zy.common.utils.ShuttleDispatchUtils; +import com.zy.core.DevpThread; import com.zy.core.Slave; import com.zy.core.cache.MessageQueue; import com.zy.core.cache.SlaveConnection; @@ -32,15 +33,13 @@ import com.zy.core.model.command.ShuttleCommand; import com.zy.core.model.protocol.NyShuttleProtocol; import com.zy.core.model.protocol.ShuttleProtocol; +import com.zy.core.model.protocol.StaProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.NyShuttleThread; import com.zy.core.thread.ShuttleThread; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; /** * Created by vincent on 2020/8/27 @@ -506,4 +505,92 @@ return false;//鎸囧畾妤煎眰娌℃湁绌挎杞� } + //妫�娴嬪簱浣嶇粍鏄惁瀛樺湪灏忚溅锛屽瓨鍦ㄨ繑鍥炲皬杞﹀彿銆� + public static Integer checkGroupLocHasShuttle(List<String> groupLoc) { + if (groupLoc == null) { + return null; + } + + if (groupLoc.isEmpty()) { + return null; + } + + SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); + if (slaveProperties == null) { + return null; + } + + for (String loc : groupLoc) { + for (ShuttleSlave slave : slaveProperties.getShuttle()) { + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); + if (shuttleThread == null) { + continue; + } + + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; + } + + if (shuttleProtocol.getCurrentLocNo() == null) { + continue; + } + + if (shuttleProtocol.getCurrentLocNo().equals(loc)) { + //瀛樺湪灏忚溅 + return slave.getId(); + } + } + } + + return null; + } + + //閫氳繃鎻愬崌鏈哄彿鍜屾ゼ灞傝幏鍙栧嚭鍏ュ簱妯″紡 + public static Integer getOutInModelByLift(Integer liftNo, Integer lev) { + ArrayList<Integer> lev1 = new ArrayList<Integer>() {{ + add(100);add(103); + add(105); + }}; + ArrayList<Integer> lev2 = new ArrayList<Integer>() {{ + add(200);add(203); + add(205); + }}; + ArrayList<Integer> lev3 = new ArrayList<Integer>() {{ + add(341);add(346); + }}; + + Integer staNo = null; + if (lev <= 4) { + staNo = lev1.get(liftNo - 1); + } else if (lev >= 5 && lev <= 7) { + staNo = lev2.get(liftNo - 1); + } else if ((lev >=8 && lev <= 10) && liftNo != 1) { + staNo = lev3.get(liftNo - 2); + } + + if (staNo != null) { + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); + StaProtocol staProtocol = devpThread.getStation().get(staNo); + if (staProtocol == null) { + return null; + } + + if (staNo == 100 || staNo == 200) {//1鍙锋彁鍗囨満100绔欏拰200绔欓粯璁ゅ叏鏄嚭搴撴ā寮� + return 2;//鍑哄簱妯″紡 + } + + if (staNo == 341) { + return 1;//341绔欓粯璁ゅ彧鑳藉叆搴撴ā寮� + } + + if (staProtocol.getOutInModel() == null) { + return null;//娌℃湁鍑哄叆搴撲俊鍙� + } + + return staProtocol.getOutInModel().intValue(); + } + return null; + } + } -- Gitblit v1.9.1