From e356cb699f91ff4359ef0e835fd311436489b9d8 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期三, 26 十月 2022 12:51:22 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 36 ++++++++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 0763134..c4be203 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.*; @@ -898,7 +899,7 @@ } } } - // 娌℃湁灏忚溅 + // 娌℃湁灏忚溅 } else { if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) { // 瀵绘壘褰撳墠鍫嗗灈鏈哄搴旂殑灏忚溅 @@ -1290,17 +1291,32 @@ * 鏌ユ壘褰撳墠搴撲綅鏈�閫傚悎鐨勭┛姊溅鏉ヤ綔涓� */ public SteThread queryIdleCar(WrkMast wrkMast) { - Integer crnNo = wrkMast.getCrnNo(); - BasSte basSte = basSteService.findByCrnNo(crnNo); - // 鑾峰彇绌挎杞︿俊鎭� - SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo()); - SteProtocol steProtocol = steThread.getSteProtocol(); - if (steProtocol != null) { - if (steProtocol.isIdle()) { - return steThread; + List<BasSte> basStes = basSteService.selectList(new EntityWrapper<>()); + int val = 0; + SteThread result = null; + for (BasSte basSte : basStes) { + // 鑾峰彇绌挎杞︿俊鎭� + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo()); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { continue; } + if (!steProtocol.isIdle()) { continue; } + String locNo = wrkMast.getWrkSts() < 10 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo(); + LocMast locMast = locMastService.selectById(locNo); + int lev = locMast.getLev1(); + int bay = locMast.getBay1(); + int levAbs = Math.abs(lev - steProtocol.getLev()); + int bayAbs = Math.abs(bay - steProtocol.getBay()); + if (val == 0) { + val = levAbs + bayAbs; + result = steThread; + } else { + if ((levAbs + bayAbs) < val) { + val = levAbs + bayAbs; + result = steThread; + } } } - return null; + return result; } /** -- Gitblit v1.9.1