From d56b8093dc9e3e75f8efe1a0f1aa6d821c9c3dfb Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期二, 15 四月 2025 13:30:35 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java | 77 +++++++++++++++++++++++++++----------- 1 files changed, 54 insertions(+), 23 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java index 7e5b117..0be1c20 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java @@ -16,6 +16,7 @@ import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; import com.zy.asrs.wcs.core.model.enums.MotionCtgType; import com.zy.asrs.wcs.core.service.BasLiftService; +import com.zy.asrs.wcs.core.utils.LiftDispatcher; import com.zy.asrs.wcs.core.utils.RedisUtil; import com.zy.asrs.wcs.core.utils.Utils; import com.zy.asrs.wcs.rcs.News; @@ -47,22 +48,6 @@ public NyLiftThread(Device device, RedisUtil redisUtil) { this.device = device; this.redisUtil = redisUtil; - - //鍒濆鍖栫珯鐐� - BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); - BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>() - .eq(BasLift::getDeviceId, device.getId())); - List<BasLiftStaDto> staList = JSON.parseArray(basLift.getSta(), BasLiftStaDto.class); - this.staList = staList; - for (BasLiftStaDto sta : staList) { - LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); - liftStaProtocol.setStaNo(sta.getStaNo());//绔欑偣鍙� - liftStaProtocol.setLev(sta.getLev());//绔欑偣妤煎眰 - String locNo = Utils.getLocNo(sta.getRow(), sta.getBay(), sta.getLev()); - liftStaProtocol.setLocNo(locNo);//绔欑偣搴撲綅鍙� - liftStaProtocol.setLiftNo(basLift.getLiftNo());//鎻愬崌鏈哄彿 - liftStaProtocols.add(liftStaProtocol); - } } @Override @@ -94,6 +79,24 @@ private void readStatus() { try { + if (liftStaProtocols.isEmpty()) { + //鍒濆鍖栫珯鐐� + BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); + BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>() + .eq(BasLift::getDeviceId, device.getId())); + List<BasLiftStaDto> staList = JSON.parseArray(basLift.getSta(), BasLiftStaDto.class); + this.staList = staList; + for (BasLiftStaDto sta : staList) { + LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); + liftStaProtocol.setStaNo(sta.getStaNo());//绔欑偣鍙� + liftStaProtocol.setLev(sta.getLev());//绔欑偣妤煎眰 + String locNo = Utils.getLocNo(sta.getRow(), sta.getBay(), sta.getLev()); + liftStaProtocol.setLocNo(locNo);//绔欑偣搴撲綅鍙� + liftStaProtocol.setLiftNo(basLift.getLiftNo());//鎻愬崌鏈哄彿 + liftStaProtocols.add(liftStaProtocol); + } + } + //鑾峰彇鎻愬崌鏈烘暟鎹� OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB82.4.0", (short) 10); if (result1.IsSuccess) { @@ -133,7 +136,7 @@ //鏈夊皬杞� liftProtocol.setHasCar(status2[6]); //璁惧鏁呴殰 - liftProtocol.setErrorCode(String.valueOf(status2[7])); + liftProtocol.setErrorCode(status2[7]?"1":"0"); //鐩殑鍦板潃 liftProtocol.setDistAddress(siemensS7Net.getByteTransform().TransInt16(result1.Content, 4)); //宸插畬鎴愪换鍔″彿 @@ -147,6 +150,12 @@ //浠诲姟鍙� liftExtend.setLiftTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2))); liftProtocol.setExtend(liftExtend); + + boolean ready = true; + if (!liftProtocol.getModel() || liftProtocol.getRun()) { + ready = false; + } + liftProtocol.setReady(ready);//灏辩华鐘舵�� }else { @@ -276,6 +285,18 @@ array[i] = shorts.get(i); } + LiftDispatcher liftDispatcher = SpringUtils.getBean(LiftDispatcher.class); + + Integer origin = command.getOriginLev(); + Integer target = command.getTargetLev(); + if (command.getMode() == 2) { + origin = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), liftProtocol.getLev()); + target = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), command.getTargetLev()); + } + + array[1] = origin.shortValue(); + array[2] = target.shortValue(); + OperateResult result = siemensS7Net.Write("DB83.0", array); if (result != null && result.IsSuccess) { liftProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿 @@ -375,19 +396,29 @@ @Override public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) { - return taskNo; + int deviceTaskNo = taskNo; + try { + deviceTaskNo = Utils.getTaskNo("LIFT_TASK_NO"); + } catch (Exception e) { + return taskNo; + } + return deviceTaskNo; } @Override public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) { /** * 浠诲姟绫诲瀷 - * 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� - * 2=绉诲皬杞︼紝鍗囬檷鏈虹Щ鍒扮洰鏍囧眰锛岀瓑寰� + 1=绉绘墭鐩橈紱鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囩珯鍙� + 2=鎹㈠眰锛屽崌闄嶆満绉诲埌鐩爣灞傦紝绛夊緟 + 3=鍏ュ簱鎵樼洏,鍗囬檷鏈哄皢婧愮珯鍙版墭鐩樼Щ鍒扮洰鏍囧眰鏁帮紱 + 4=鍑哄簱鎵樼洏锛屽崌闄嶆満灏嗘簮绔欏彴鎵樼洏绉诲埌鐩爣绔欏彴 */ short taskMode = 2; - if (mode.equals(LiftCommandModeType.PALLET_INOUT)) { - taskMode = 1; + if (mode.equals(LiftCommandModeType.PALLET_IN)) { + taskMode = 3; + } else if (mode.equals(LiftCommandModeType.PALLET_OUT)) { + taskMode = 4; } // 寮�濮嬩换鍔� @@ -404,7 +435,7 @@ LiftCommand command = new LiftCommand(); command.setLiftNo(Integer.valueOf(this.device.getDeviceNo())); command.setBody(JSON.toJSONString(array)); - command.setMode(LiftCommandModeType.MOVE.id); + command.setMode(mode.id); command.setOriginLev(sourceLev); command.setTargetLev(targetLev); -- Gitblit v1.9.1