From 2a30823fa12361a2873d914edca1c5ffe684d3ec Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@gmail.com>
Date: 星期二, 27 一月 2026 15:21:33 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java | 4
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java | 9 +
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java | 9 +
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java | 9 +
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java | 178 ++++++++++++++++++++++++++++++++++++++++++++
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java | 9 +
6 files changed, 204 insertions(+), 14 deletions(-)
diff --git a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java
index 0aaa444..de4f0f6 100644
--- a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java
+++ b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
+import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
@Override
public byte[] writeToBytes() {
+ return Utils.reverse(RadixTools.shortToByte(this.height));
+
// byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
// byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
// return Utils.merge(heightBytes, depthBytes);
- byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
- byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
- return Utils.merge(heightByte, depthByte);
+// byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
+// byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
+// return Utils.merge(heightByte, depthByte);
// return new byte[]{ heightByte, depthByte };
}
diff --git a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java
index c1a352b..be3593e 100644
--- a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java
+++ b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
+import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
@Override
public byte[] writeToBytes() {
+ return Utils.reverse(RadixTools.shortToByte(this.height));
+
// byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
// byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
// return Utils.merge(heightBytes, depthBytes);
- byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
- byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
- return Utils.merge(heightByte, depthByte);
+// byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
+// byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
+// return Utils.merge(heightByte, depthByte);
// return new byte[]{ heightByte, depthByte };
}
diff --git a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java
index 5493d4a..fed00bb 100644
--- a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java
+++ b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
+import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
@Override
public byte[] writeToBytes() {
+ return Utils.reverse(RadixTools.shortToByte(this.height));
+
// byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
// byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
// return Utils.merge(heightBytes, depthBytes);
- byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
- byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
- return Utils.merge(heightByte, depthByte);
+// byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
+// byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
+// return Utils.merge(heightByte, depthByte);
// return new byte[]{ heightByte, depthByte };
}
diff --git a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java
index eef4c92..ee8ee86 100644
--- a/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java
+++ b/zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
+import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
@Override
public byte[] writeToBytes() {
+ return Utils.reverse(RadixTools.shortToByte(this.height));
+
// byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
// byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
// return Utils.merge(heightBytes, depthBytes);
- byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
- byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
- return Utils.merge(heightByte, depthByte);
+// byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
+// byte depthByte = (byte) ((this.depth == null ? 0 : this.depth) & 0xFF);
+// return Utils.merge(heightByte, depthByte);
// return new byte[]{ heightByte, depthByte };
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java
new file mode 100644
index 0000000..7c24098
--- /dev/null
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java
@@ -0,0 +1,178 @@
+package com.zy.acs.manager.core.scheduler;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.acs.common.constant.RedisConstant;
+import com.zy.acs.common.utils.RedisSupport;
+import com.zy.acs.framework.common.Cools;
+import com.zy.acs.framework.common.SnowflakeIdWorker;
+import com.zy.acs.manager.common.domain.TaskDto;
+import com.zy.acs.manager.core.service.AreaGovernService;
+import com.zy.acs.manager.core.service.MainService;
+import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
+import com.zy.acs.manager.manager.entity.*;
+import com.zy.acs.manager.manager.enums.AgvModelType;
+import com.zy.acs.manager.manager.enums.BusStsType;
+import com.zy.acs.manager.manager.enums.LocStsType;
+import com.zy.acs.manager.manager.enums.StatusType;
+import com.zy.acs.manager.manager.service.*;
+import com.zy.acs.manager.manager.service.impl.CodeServiceImpl;
+import com.zy.acs.manager.system.service.ConfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Slf4j
+@Component
+public class ConveyorAutoRunScheduler {
+
+ private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.CTU_BOX_TRANSPORT_AGV;
+
+ private final RedisSupport redis = RedisSupport.defaultRedisSupport;
+
+ @Autowired
+ private AgvService agvService;
+ @Autowired
+ private BusService busService;
+ @Autowired
+ private MainService mainService;
+ @Autowired
+ private ConfigService configService;
+ @Autowired
+ private LocService locService;
+ @Autowired
+ private StaService staService;
+ @Autowired
+ private AgvModelService agvModelService;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+ @Autowired
+ private AreaGovernService areaGovernService;
+ @Autowired
+ private CodeServiceImpl codeService;
+
+ // @Scheduled(fixedRate = 500) // 鍥哄畾棰戠巼鎵ц锛屼笉鍚屾
+ @Scheduled(fixedDelay = 1000) // 鍥哄畾棰戠巼鎵ц锛屽悓姝�
+// @Scheduled(cron = "0/1 * * * * ? ")
+ private void execute() {
+ //if (!configService.getVal("ConveyorTaskAssignMode", Boolean.class)) { return; }
+ AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, DEFAULT_AGV_MODEL.toString()));
+ if (null == agvModel) { return; }
+
+ //this.autoRun(agvModel);
+ }
+
+ private void autoRun(AgvModel agvModel) {
+ int availableAgvCount = this.getAvailableAgvCount();
+ if (0 == availableAgvCount) { return; }
+
+// List<String> staPreNos = getStaPrefixes(staGroupList);
+ List<String> staPreNos = new ArrayList<>();
+ String memo = "DEMO_STA_" + String.join("-", staPreNos);
+
+
+ // 鏈�澶� ? 缁刡us杩愯
+ if (1 <= busService.count(new LambdaQueryWrapper<Bus>()
+ .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val())
+ .in(Bus::getMemo, memo)
+ )) { return; }
+
+
+ // 鍑哄簱
+ this.runLocToSta(agvModel, memo);
+
+ }
+
+
+ // 鍑哄簱
+ private void runLocToSta(AgvModel agvModel, String memo) {
+
+ // IDLE STA
+ List<Sta> idleList = new ArrayList<>();
+ idleList.add(staService.selectByStaNo("1001"));
+ idleList.add(staService.selectByStaNo("1007"));
+ if (Cools.isEmpty(idleList)) { return; }
+ Collections.shuffle(idleList);
+
+ OpenBusSubmitParam param = new OpenBusSubmitParam();
+ param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19));
+ for (int i = 0; i < agvModel.getBackpack() ; i++) {
+ Sta idleSta = idleList.get(i);
+ String staCode = codeService.getCacheById(idleSta.getCode()).getData();
+
+ Loc stockLoc = null;
+
+ // 鎵�鍦ㄥ尯鍩熺殑鏉$爜锛屽鏋滄病鏈塧rea缁戝畾锛屽氨鍏ㄥ湴鍥�
+ List<String> codeList = areaGovernService.queryCodesByOneCode(staCode);
+ if (Cools.isEmpty(codeList)) {
+ stockLoc = locService.selectRandOneByLocSts(LocStsType.STOCK.val(), 1);
+ } else {
+ Collections.shuffle(codeList);
+ for (String codeData : codeList) {
+ Code code = codeService.getCacheByData(codeData);
+ if (null == code) { break; }
+ List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>()
+ .eq(Loc::getCode, code.getId()).eq(Loc::getLocSts, LocStsType.STOCK.val()));
+ if (Cools.isEmpty(locList)) {
+ break;
+ } else if (locList.size() == 1) {
+ stockLoc = locList.get(0);
+ } else {
+ Collections.shuffle(locList);
+ stockLoc = locList.get(0);
+ }
+ if (null != stockLoc) {
+ break;
+ }
+ }
+ }
+
+ if (null == stockLoc) { break; }
+
+ TaskDto taskDto = new TaskDto();
+ taskDto.setOriLoc(stockLoc.getLocNo());
+ taskDto.setDestSta(idleSta.getStaNo());
+ taskDto.setPriority(100);
+ taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
+
+ param.getTaskList().add(taskDto);
+ }
+ if (Cools.isEmpty(param.getTaskList())) { return; }
+
+ mainService.generateBusAndTask(param, memo);
+ }
+
+
+
+ public static List<String> getStaPrefixes(List<String> staGroupList) {
+ Set<String> rowSet = new HashSet<>();
+ for (String s : staGroupList) {
+ rowSet.add(s.split("-")[0]);
+ }
+ List<String> result = new ArrayList<>(rowSet);
+ result.sort(Comparator.comparingInt(Integer::parseInt));
+ return result;
+ }
+
+ private int getAvailableAgvCount() {
+ int res = 0;
+ List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
+ if (Cools.isEmpty(agvList)) {
+ return res;
+ }
+ for (Agv agv : agvList) {
+ if (null == redis.getObject(RedisConstant.AGV_ONLINE_FLAG, agv.getUuid())) {
+ continue;
+ }
+ if (!agv.getStatusBool()) {
+ continue;
+ }
+ res++;
+ }
+
+ return res;
+ }
+
+}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java
index 9edfdf1..361db5d 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java
@@ -18,8 +18,8 @@
@Service
public class TransferStationHandler {
- private static final int DEFAULT_LOAD_DELAY_MS = 1000; // load ( inbound ) delay timeout
- private static final int DEFAULT_PLACE_DELAY_MS = 15000; // place ( outbound ) delay timeout
+ private static final int DEFAULT_LOAD_DELAY_MS = 15000; // load ( inbound ) delay timeout
+ private static final int DEFAULT_PLACE_DELAY_MS = 1000; // place ( outbound ) delay timeout
@Autowired
private SegmentService segmentService;
--
Gitblit v1.9.1