From e83761d390b593cff8b7c17144529e92eb482bd6 Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期三, 16 四月 2025 16:38:04 +0800 Subject: [PATCH] 1 --- src/main/java/com/zy/core/action/ShuttleAction.java | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 108 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java index a083581..61ed0ff 100644 --- a/src/main/java/com/zy/core/action/ShuttleAction.java +++ b/src/main/java/com/zy/core/action/ShuttleAction.java @@ -2,19 +2,25 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.zy.asrs.entity.BasShuttleOpt; +import com.zy.asrs.entity.LocMast; +import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.BasShuttleOptService; import com.zy.asrs.service.BasShuttleService; import com.zy.asrs.service.LocMastService; +import com.zy.asrs.service.WrkMastService; import com.zy.asrs.utils.Utils; import com.zy.common.ExecuteSupport; import com.zy.common.model.NavigateNode; import com.zy.common.utils.NavigateMapUtils; import com.zy.common.utils.RedisUtil; +import com.zy.common.utils.ShuttleOperaUtils; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; +import com.zy.core.dispatcher.ShuttleDispatchUtils; import com.zy.core.enums.*; import com.zy.core.model.CommandResponse; import com.zy.core.model.command.ShuttleAssignCommand; @@ -22,11 +28,13 @@ import com.zy.core.model.command.ShuttleRedisCommand; import com.zy.core.model.protocol.ShuttleProtocol; import com.zy.core.thread.ShuttleThread; +import com.zy.system.entity.Config; import com.zy.system.service.ConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -47,6 +55,10 @@ private ConfigService configService; @Autowired private BasShuttleOptService basShuttleOptService; + @Autowired + private WrkMastService wrkMastService; + @Autowired + private ShuttleDispatchUtils shuttleDispatchUtils; public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) { ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); @@ -207,8 +219,14 @@ // 绯荤粺浠诲姟 if (assignCommand.getAuto()) { if (!assignCommand.getCharge()) { - //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting - shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WAITING); + if (command.getMode() == ShuttleCommandModeType.UPDATE_LOCATION.id) { + //鏇存柊鍧愭爣浠诲姟鏃犻渶鎶涘嚭绛夊緟纭 + shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); + shuttleThread.setSyncTaskNo(0); + }else { + //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting + shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WAITING); + } }else { shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); } @@ -268,6 +286,94 @@ return true; } + //婕旂ず妯″紡 + public synchronized void demo(Integer shuttleNo) { + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); + if (shuttleThread == null) { + return; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return; + } + + if (!shuttleProtocol.getDemo()) { + return; + } + + WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(shuttleNo); + if (moveWorking != null) { + return; + } + + WrkMast shuttleWorking = wrkMastService.selectShuttleWorking(shuttleNo); + if(shuttleWorking != null) { + return; + } + + WrkMast chargeWorking = wrkMastService.selectChargeWorking(shuttleNo); + if (chargeWorking != null) { + return; + } + + if (shuttleThread.isRequireCharge()) { + return; + } + + if (!shuttleThread.isIdle()) { + return; + } + + boolean demoSwitchLev = false; + Config demoSwitchLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoSwitchLev")); + if (demoSwitchLevConfig != null) { + if (demoSwitchLevConfig.getValue().equals("Y")) { + demoSwitchLev = true; + } + } + + Config demoRunLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoRunLev")); + if (demoRunLevConfig == null) { + return; + } + List<Integer> levList = JSON.parseArray(demoRunLevConfig.getValue(), Integer.class); + + if (!demoSwitchLev) { + String currentLocNo = shuttleProtocol.getCurrentLocNo(); + levList = new ArrayList<>(); + levList.add(Utils.getLev(currentLocNo)); + } + + LocMast targetLoc = null; + EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); + wrapper.in("lev1", levList); + wrapper.eq("loc_sts", "O"); + wrapper.last("ORDER BY RAND() LIMIT 1"); + for (int i = 0; i < 3; i++) { + LocMast locMast = locMastService.selectOne(wrapper); + if(locMast == null) { + continue; + } + + ArrayList<String> locs = new ArrayList<>(); + locs.add(locMast.getLocNo()); + Integer shuttle = Utils.checkGroupLocHasShuttle(locs); + if(shuttle != null) { + continue; + } + + targetLoc = locMast; + break; + } + + if(targetLoc == null) { + return; + } + + shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo); + } + // //璺戝簱绋嬪簭 // public synchronized void moveLoc(Integer shuttleNo) { // ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); -- Gitblit v1.9.1