From 05b57adb20382ff1ceb99cea676fe3dce7908514 Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 25 九月 2025 16:20:04 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/LiftThread.java | 2 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 71 +++++++++++++++++++++++++++++++++++ src/main/java/com/zy/core/MainProcess.java | 3 + src/main/java/com/zy/core/thread/impl/NyLiftThread.java | 27 ++----------- 4 files changed, 79 insertions(+), 24 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 d6ba0f3..dda1f5e 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -1945,4 +1945,75 @@ return true; } + //鑷姩鍒囨崲鍑哄叆搴撴ā寮� + public void autoSwitchLiftIOMode() { + List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() + .eq("device_type", String.valueOf(SlaveType.Lift))); + for (DeviceConfig device : liftList) { + Integer liftNo = device.getDeviceNo(); + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + continue; + } + + List<Integer> liftAllStaNo = LiftUtils.getLiftAllStaNo(liftNo); + if (liftAllStaNo.isEmpty()) { + continue; + } + + List<Integer> conveyorBindLiftAllStaNo = LiftUtils.getConveyorBindLiftAllStaNo(liftNo); + if (conveyorBindLiftAllStaNo.isEmpty()) { + continue; + } + + //鑾峰彇鍏ュ簱浠诲姟 + List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("sta_no", liftAllStaNo) + .in("wrk_sts" + , WrkStsType.NEW_INBOUND.sts + , WrkStsType.INBOUND_DEVICE_RUN.sts + , WrkStsType.INBOUND_LIFT_RUN.sts + , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts + , WrkStsType.INBOUND_SHUTTLE_RUN.sts + , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts + )); + + //鑾峰彇鍑哄簱浠诲姟 + List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() + .in("sta_no", conveyorBindLiftAllStaNo) + .in("wrk_sts" + , WrkStsType.NEW_OUTBOUND.sts + , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts + , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts + , WrkStsType.OUTBOUND_LIFT_RUN.sts + , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts + )); + + if (liftProtocol.getIOModeType().equals(LiftIoModeType.NONE)) { + //鏈煡妯″紡 + if (!inWrkMasts.isEmpty()) { + liftThread.switchIOMode(LiftIoModeType.IN); + } else if (!outWrkMasts.isEmpty()) { + liftThread.switchIOMode(LiftIoModeType.OUT); + }else { + liftThread.switchIOMode(LiftIoModeType.IN); + } + } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.IN)) { + //鍏ュ簱妯″紡 + if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) { + liftThread.switchIOMode(LiftIoModeType.OUT); + } + } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) { + //鍑哄簱妯″紡 + if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) { + liftThread.switchIOMode(LiftIoModeType.IN); + } + } + } + } + } diff --git a/src/main/java/com/zy/core/MainProcess.java b/src/main/java/com/zy/core/MainProcess.java index 4e7e797..de9f387 100644 --- a/src/main/java/com/zy/core/MainProcess.java +++ b/src/main/java/com/zy/core/MainProcess.java @@ -78,6 +78,9 @@ mainService.loopShuttleCharge(); mainService.executeShuttleCharge(); + //鑷姩鍒囨崲鍑哄叆搴撴ā寮� + mainService.autoSwitchLiftIOMode(); + // 闂撮殧 Thread.sleep(200); } catch (Exception e) { diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java index e2da9fc..df824d9 100644 --- a/src/main/java/com/zy/core/thread/LiftThread.java +++ b/src/main/java/com/zy/core/thread/LiftThread.java @@ -24,7 +24,7 @@ CommandResponse move(LiftCommand command);//灏忚溅绉诲姩 - CommandResponse switchIOMode(LiftCommand command);//鍒囨崲鍑哄叆搴撴ā寮� + CommandResponse switchIOMode(LiftIoModeType type);//鍒囨崲鍑哄叆搴撴ā寮� CommandResponse reset();//澶嶄綅 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 8ff9e2c..a11eccf 100644 --- a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java @@ -353,29 +353,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.setIOModeType(type); + return response; } @Override -- Gitblit v1.9.1