From 8b8a2086509e28bb902166aa35e4c287eb906621 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 30 六月 2025 15:28:39 +0800 Subject: [PATCH] #禁止跨层 --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java | 75 +++++++++++++++++++++++++++++++------ 1 files changed, 62 insertions(+), 13 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java index c8c57b0..1946db0 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java @@ -1,20 +1,27 @@ package com.zy.asrs.wcs.core.action; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.wcs.core.entity.Task; import com.zy.asrs.wcs.core.model.command.*; import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; +import com.zy.asrs.wcs.core.service.TaskService; import com.zy.asrs.wcs.core.utils.RedisUtil; import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; +import com.zy.asrs.wcs.rcs.entity.BasLiftOpt; import com.zy.asrs.wcs.rcs.entity.Device; +import com.zy.asrs.wcs.rcs.model.CommandResponse; import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; +import com.zy.asrs.wcs.rcs.service.BasLiftOptService; import com.zy.asrs.wcs.rcs.thread.LiftThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Date; import java.util.List; @Component @@ -22,6 +29,10 @@ @Autowired private RedisUtil redisUtil; + @Autowired + private TaskService taskService; + @Autowired + private BasLiftOptService basLiftOptService; public synchronized boolean assignWork(Device device, LiftAssignCommand assignCommand) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); @@ -50,6 +61,11 @@ public synchronized boolean executeWork(Device device, Integer taskNo) { Object obj = redisUtil.get(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo); if (obj == null) { + return false; + } + + Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, taskNo)); + if (task == null) { return false; } @@ -98,6 +114,21 @@ if (liftProtocol.getLev() == command.getTargetLev()) { command.setComplete(true); } + + //鍒ゆ柇鎻愬崌鏈烘墭鐩樻槸鍚﹀瓨鍦� + if (liftProtocol.getHasTray()) { + return false; + } + + } else if (command.getMode() == LiftCommandModeType.RESET.id) { + //澶嶄綅 + command.setComplete(true); + } else if (command.getMode() == LiftCommandModeType.LOCK.id) { + //閿佸畾 + command.setComplete(true); + } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) { + //瑙i攣 + command.setComplete(true); } // 鏇存柊redis鏁版嵁 @@ -114,7 +145,6 @@ //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); - liftThread.commandFinished(taskNo);//璋冪敤瀹屾垚鍚庣画鎸囦护(閮ㄥ垎鎻愬崌鏈烘湁鍚庣画鎸囦护锛屽疄闄呮儏鍐电湅鏄惁鏈夌湡姝e疄鐜版柟娉�) redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo); return false;//绂佹鍐嶄笅鍙戝懡浠� } @@ -123,8 +153,26 @@ //鍙栧嚭鍛戒护 LiftCommand command = commands.get(commandStep); - boolean result = write(command, device); - if (!result) { + // 涓嬪彂鍛戒护 + CommandResponse response = write(command, device); + + //淇濆瓨鍛戒护鏃ュ織 + BasLiftOpt basLiftOpt = new BasLiftOpt(); + basLiftOpt.setTaskNo(taskNo); + basLiftOpt.setLiftNo(liftProtocol.getLiftNo()); + basLiftOpt.setMode(LiftCommandModeType.get(command.getMode()).desc); + basLiftOpt.setCommand(JSON.toJSONString(command)); + basLiftOpt.setSystemStatus(JSON.toJSONString(liftProtocol)); + basLiftOpt.setDeviceId(device.getId()); + basLiftOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); + basLiftOpt.setResponse(response.getMessage());//鑾峰彇鍝嶅簲 + basLiftOpt.setSendTime(new Date());//鎸囦护涓嬪彂鏃堕棿 + basLiftOpt.setSend(response.getResult() ? 1 : 0); + basLiftOpt.setHostId(device.getHostId()); + //淇濆瓨鍛戒护娴佹按 + basLiftOptService.save(basLiftOpt); + + if (!response.getResult()) { News.error("鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); return false; } else { @@ -140,30 +188,31 @@ return true; } - private synchronized boolean write(LiftCommand command, Device device) { + private synchronized CommandResponse write(LiftCommand command, Device device) { + CommandResponse response = new CommandResponse(false); if (null == command) { News.error("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); - return false; + response.setMessage("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�"); + return response; } LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); if (liftThread == null) { - return false; + return response; } - boolean result = false; if (command.getMode() == LiftCommandModeType.MOVE.id) { - result = liftThread.move(command); + response = liftThread.move(command); } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) { - result = liftThread.palletInOut(command); + response = liftThread.palletInOut(command); } else if (command.getMode() == LiftCommandModeType.LOCK.id) { - result = liftThread.lock(command); + response = liftThread.lock(command); } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) { - result = liftThread.unlock(command); + response = liftThread.unlock(command); } else if (command.getMode() == LiftCommandModeType.RESET.id) { - result = liftThread.reset(command); + response = liftThread.reset(command); } - return result; + return response; } } -- Gitblit v1.9.1