From 73ce8bebcc5d14f3fb62a19ee677abfcdfc776b4 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期六, 19 七月 2025 16:17:51 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/action/ShuttleAction.java | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java index f9fffa0..1bfe527 100644 --- a/src/main/java/com/zy/core/action/ShuttleAction.java +++ b/src/main/java/com/zy/core/action/ShuttleAction.java @@ -5,19 +5,19 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.zy.asrs.domain.param.CreateLocMoveTaskParam; 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.service.CommonService; 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; @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Random; @Component public class ShuttleAction { @@ -45,8 +46,6 @@ private RedisUtil redisUtil; @Autowired private NavigateMapUtils navigateMapUtils; - @Autowired - private BasShuttleService basShuttleService; @Autowired private LocMastService locMastService; @Autowired @@ -59,6 +58,8 @@ private WrkMastService wrkMastService; @Autowired private ShuttleDispatchUtils shuttleDispatchUtils; + @Autowired + private CommonService commonService; public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) { ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); @@ -365,7 +366,92 @@ return; } - shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo); + shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleProtocol.getShuttleNo()); + } + + public synchronized void demoModeCargoMove() { + Config demoCargoMoveConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoCargoMove")); + if (demoCargoMoveConfig == null) { + return; + } + + if (!demoCargoMoveConfig.getValue().equals("Y")) { + return; + } + + + Config demoRunLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoRunLev")); + if (demoRunLevConfig == null) { + return; + } + List<Integer> levList = JSON.parseArray(demoRunLevConfig.getValue(), Integer.class); + Random random = new Random(); + int index = random.nextInt(levList.size()); + Integer lev = levList.get(index); + + //鑾峰彇妤煎眰灏忚溅鏁伴噺 + int shuttleCountByLev = shuttleDispatchUtils.getShuttleCountByLev(lev); + //鑾峰彇妤煎眰璐х墿鎼繍浠诲姟 + int currentLevTask = 0; + for (WrkMast wrkMast : wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type", WrkIoType.LOC_MOVE.id))) { + if (Utils.getLev(wrkMast.getLocNo()) == lev) { + currentLevTask += 1; + } + } + + //鎼繍浠诲姟鏁伴噺瓒呰繃灏忚溅鏁伴噺锛屾殏鏃朵笉鐢熸垚鏂颁换鍔� + if (currentLevTask > shuttleCountByLev) { + return; + } + + LocMast sourceLoc = null; + EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); + wrapper.eq("lev1", lev); + wrapper.eq("loc_sts", "F"); + wrapper.last("ORDER BY RAND() LIMIT 1"); + for (int i = 0; i < 3; i++) { + LocMast locMast = locMastService.selectOne(wrapper); + if(locMast == null) { + continue; + } + + sourceLoc = locMast; + break; + } + + if(sourceLoc == null) { + return; + } + + LocMast targetLoc = null; + EntityWrapper<LocMast> targetWrapper = new EntityWrapper<>(); + targetWrapper.eq("lev1", lev); + targetWrapper.eq("loc_sts", "O"); + targetWrapper.last("ORDER BY RAND() LIMIT 1"); + for (int i = 0; i < 3; i++) { + LocMast locMast = locMastService.selectOne(targetWrapper); + if(locMast == null) { + continue; + } + + targetLoc = locMast; + break; + } + + if(targetLoc == null) { + return; + } + + try { + CreateLocMoveTaskParam param = new CreateLocMoveTaskParam(); + param.setSourceLocNo(sourceLoc.getLocNo()); + param.setLocNo(targetLoc.getLocNo()); + param.setTaskPri(13); + + boolean result = commonService.createLocMoveTask(param); + } catch (Exception e) { + e.printStackTrace(); + } } // //璺戝簱绋嬪簭 -- Gitblit v1.9.1