From 925b834a3341dbe9f486964a7ad5d1affd7a404d Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 24 十月 2023 13:33:05 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java | 100 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 97 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java index 138a943..525078e 100644 --- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java @@ -1,12 +1,17 @@ package com.zy.common.utils; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.common.SpringUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.BasDevp; +import com.zy.asrs.entity.BasShuttle; import com.zy.asrs.entity.WrkCharge; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.mapper.WrkChargeMapper; import com.zy.asrs.mapper.WrkMastMapper; import com.zy.asrs.service.BasDevpService; +import com.zy.asrs.service.BasShuttleService; import com.zy.asrs.service.WrkMastService; import com.zy.asrs.utils.Utils; import com.zy.common.model.NavigateNode; @@ -24,6 +29,8 @@ import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.LiftThread; import com.zy.core.thread.NyShuttleThread; +import com.zy.system.entity.Config; +import com.zy.system.service.ConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,6 +69,14 @@ * 璋冨害杞﹁締 */ public boolean dispatchShuttle(Integer wrkNo, String locNo) { + //妫�娴嬬洰鏍囧簱浣嶇粍鏄惁瀛樺湪灏忚溅锛屽瀛樺湪灏忚溅鍒欑洿鎺ユ寚瀹氳杞� + List<String> groupLoc = Utils.getGroupLoc(locNo); + Integer groupShuttleNo = Utils.checkGroupLocHasShuttle(groupLoc); + if (groupShuttleNo != null) { + //瀛樺湪灏忚溅锛岀洿鎺ヨ皟搴﹁杞� + return shuttleMoveGenerate(wrkNo, locNo, groupShuttleNo); + } + ArrayList<NyShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅 ArrayList<NyShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅 @@ -130,7 +145,15 @@ WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo); if (wrkMast1 != null) { - int lev = Utils.getLev(wrkMast1.getLocNo());//鐩爣妤煎眰 + String locNO=wrkMast1.getIoType()<100?wrkMast1.getLocNo():wrkMast1.getSourceLocNo(); + int lev = Utils.getLev(locNO);//鐩爣妤煎眰 + + //妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� + boolean checkDispatchMaxNum = checkDispatchMaxNum(lev); + if (!checkDispatchMaxNum) { + return false; + } + int recentValue = 99999;//鏈�灏忓樊鍊� for (NyShuttleThread shuttleThread : diffLev) { //褰撳墠绌挎杞﹀簱浣嶅彿 @@ -221,7 +244,7 @@ if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) { //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴� //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� - LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo); + LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo)); if (liftSta == null) { return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐� } @@ -266,9 +289,70 @@ } /** + * 妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� + * true: 灏忎簬鏈�澶ф暟閲� false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲� + */ + public boolean checkDispatchMaxNum(Integer lev) { + BasShuttleService basShuttleService = SpringUtils.getBean(BasShuttleService.class); + ConfigService configService = SpringUtils.getBean(ConfigService.class); + EntityWrapper<Config> wrapper = new EntityWrapper<>(); + wrapper.eq("code", "dispatchShuttleMaxNum"); + Config config = configService.selectOne(wrapper); + if (config == null) { + return false; + } + + int levCount = 0;//鐩爣妤煎眰杞﹁締鏁伴噺 + for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { + continue; + } + + NyShuttleProtocol.NyShuttlePointClass point = null; + if (shuttleProtocol.getPoint() == null) { + BasShuttle basShuttle = basShuttleService.selectById(shuttle.getId());//灏忚溅濡傛灉娌℃湁鏁版嵁锛屼粠鏁版嵁搴撳彇鏁版嵁 + if (basShuttle == null || basShuttle.getPoint() == null) { + continue; + } + point = JSON.parseObject(basShuttle.getPoint(), NyShuttleProtocol.NyShuttlePointClass.class); + }else { + point = shuttleProtocol.getPoint(); + } + + if (point.getZ().equals(lev)) { + levCount++;//鐩爣妤煎眰鏈夎溅锛屾暟閲忓鍔� + } + } + + //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞︾Щ鍔ㄥ伐浣滄。 + for (WrkMast wrkMast : wrkMastMapper.selectShuttleMoveWrk()) { + if (wrkMast.getSourceLocNo() == null || wrkMast.getLocNo() == null) { + continue; + } + + int sourceLev = Utils.getLev(wrkMast.getSourceLocNo());//宸ヤ綔妗f簮妤煎眰 + int targetLev = Utils.getLev(wrkMast.getLocNo());//宸ヤ綔妗g洰鏍囨ゼ灞� + if (sourceLev == lev) { + continue;//宸ヤ綔妗fゼ灞傚拰鐩爣妤煎眰鐩稿悓锛岃烦杩� + } + + if (targetLev == lev) { + levCount++;//宸ヤ綔妗g洰鏍囨ゼ灞傚拰瀹為檯妤煎眰鐩稿悓锛屾暟閲忓鍔� + continue; + } + } + + + return levCount < Integer.parseInt(config.getValue()); + } + + /** * 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� */ - public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) { + public LiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) { //鑾峰彇鍥涘悜绌挎杞︾嚎绋� NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); if (shuttleThread == null) { @@ -300,6 +384,16 @@ continue; } + //鍒ゆ柇鐩爣妤煎眰绔欑偣鏄惁鏃犳墭鐩� + LiftStaProtocol targetLiftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), targetLev); + if (targetLiftStaProtocol == null) { + continue; + } + + if (targetLiftStaProtocol.getHasTray()) { + continue;//鏈夋墭鐩樿烦杩� + } + list.add(liftStaProtocol); } -- Gitblit v1.9.1