From 2c02ce3745c94be523b045d6f00815ec9f3b9b9a Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 25 九月 2025 16:51:32 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 128 +++++++++++++++++++++++++++++++++--------- 1 files changed, 99 insertions(+), 29 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..1a31154 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -2,7 +2,6 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; -import com.core.common.SpringUtils; import com.zy.asrs.domain.enums.NotifyMsgType; import com.zy.asrs.entity.*; import com.zy.asrs.service.*; @@ -143,7 +142,7 @@ public synchronized boolean shuttleInExecuteStep1(WrkMast wrkMast) { if (wrkMast.getWrkSts() == WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts) { //鑾峰彇鐩爣绔� - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); if (liftSta == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo()); return false; @@ -272,30 +271,30 @@ Integer liftNo = wrkMast.getLiftNo(); if (liftNo == null) { //閫氳繃杈撻�佺嚎绔欏彿鑾峰彇鎻愬崌鏈哄彿 - liftNo = ForkLiftUtils.getConveyorBindLiftNo(wrkMast.getStaNo()); + liftNo = LiftUtils.getConveyorBindLiftNo(wrkMast.getStaNo()); if (liftNo == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); return false; } } - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); + if (liftThread == null) { return false; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { return false; } //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡嚭搴撴ā寮� - if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { + if (!liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡嚭搴撴ā寮忥紝绂佹鍑哄簱", wrkMast.getWrkNo()); return false; } //鑾峰彇婧愮珯 - ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo())); + LiftStaProtocol liftSta = LiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo())); if (liftSta == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo()); return false; @@ -696,7 +695,7 @@ } //鑾峰彇鎻愬崌鏈哄懡浠� - LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); + LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getSiteId()); ArrayList<LiftCommand> commands = new ArrayList<>(); commands.add(liftCommand); @@ -705,7 +704,7 @@ assignCommand.setCommands(commands); assignCommand.setLiftNo(liftNo); assignCommand.setTaskNo(wrkMast.getWrkNo()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id); + assignCommand.setTaskMode(LiftTaskModeType.PICK_PUT.id); wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑 wrkMast.setSystemMsg("");//娓呯┖娑堟伅 @@ -778,7 +777,7 @@ if (liftNo == null) { //鏈垎閰嶆彁鍗囨満 Integer staNo = wrkMast.getStaNo(); - liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo); + liftNo = LiftUtils.getConveyorBindLiftNo(staNo); if(liftNo == null) { News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo()); return false; @@ -828,7 +827,7 @@ assignCommand.setCommands(commands); assignCommand.setLiftNo(liftNo); assignCommand.setTaskNo(wrkMast.getWrkNo()); - assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id); + assignCommand.setTaskMode(LiftTaskModeType.PICK_PUT.id); wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑 wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 @@ -894,8 +893,8 @@ News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); } }else { - boolean checkPreviewDispatchForkLift = commonService.checkWorkNoContainMk(liftProtocol.getTaskNo(), WrkIoType.PREVIEW_LIFT_MOVE.id); - if (checkPreviewDispatchForkLift) { + boolean checkPreviewDispatchLift = commonService.checkWorkNoContainMk(liftProtocol.getTaskNo(), WrkIoType.PREVIEW_LIFT_MOVE.id); + if (checkPreviewDispatchLift) { //灞炰簬鎻愬崌鏈洪璋冨害绉诲姩浠诲姟 //鏃犲伐浣滄。鏀拺锛岀洿鎺ョ‘璁ゅ畬鎴� liftThread.setSyncTaskNo(0); @@ -1001,31 +1000,31 @@ */ private void recLiftErr() { Date now = new Date(); - List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() - .eq("device_type", String.valueOf(SlaveType.ForkLift))); - for (DeviceConfig device : forkliftList) { + List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() + .eq("device_type", String.valueOf(SlaveType.Lift))); + for (DeviceConfig device : liftList) { // 鑾峰彇鎻愬崌鏈轰俊鎭� - ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo()); - if (forkLiftThread == null) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo()); + if (liftThread == null) { continue; } - ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); - if (forkLiftProtocol == null) { + LiftProtocol liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { continue; } - if (forkLiftProtocol.getTaskNo() != 0) { + if (liftProtocol.getTaskNo() != 0) { //鏈変换鍔� - BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(device.getDeviceNo(), forkLiftProtocol.getTaskNo()); + BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(device.getDeviceNo(), liftProtocol.getTaskNo()); // 鏈夊紓甯� if (latest == null) { - if (forkLiftProtocol.getErrorCode() != null && forkLiftProtocol.getErrorCode() != 0) { - WrkMast wrkMast = wrkMastService.selectByWorkNo(forkLiftProtocol.getWrkNo()); + if (liftProtocol.getErrorCode() != null && liftProtocol.getErrorCode() != 0) { + WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo()); if (wrkMast == null) { continue; } - BasLiftErr basLiftErr = basLiftErrService.queryByCode(forkLiftProtocol.getErrorCode()); + BasLiftErr basLiftErr = basLiftErrService.queryByCode(liftProtocol.getErrorCode()); String errName = basLiftErr==null? "鏈煡寮傚父":basLiftErr.getErrName(); BasLiftErrLog basLiftErrLog = new BasLiftErrLog( @@ -1050,7 +1049,7 @@ now, // 淇敼鏃堕棿 null, // 淇敼浜哄憳 "浠诲姟涓紓甯�", // 澶囨敞 - JSON.toJSONString(forkLiftProtocol) // 绯荤粺鐘舵�佹暟鎹� + JSON.toJSONString(liftProtocol) // 绯荤粺鐘舵�佹暟鎹� ); if (!basLiftErrLogService.insert(basLiftErrLog)) { News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", device.getDeviceNo(), errName); @@ -1058,7 +1057,7 @@ } } else { // 寮傚父淇 - if (forkLiftProtocol.getErrorCode() == null || forkLiftProtocol.getErrorCode() == 0) { + if (liftProtocol.getErrorCode() == null || liftProtocol.getErrorCode() == 0) { latest.setEndTime(now); latest.setUpdateTime(now); latest.setStatus(2); @@ -1945,4 +1944,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); + } + } + } + } + } -- Gitblit v1.9.1