From 7635dc25bd2a4d565df496b2d96354639966768d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 25 九月 2025 11:09:44 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/utils/NotifyUtils.java | 70 +++++++++++++++++-----------------
1 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/NotifyUtils.java b/src/main/java/com/zy/asrs/utils/NotifyUtils.java
index 6a1f480..0468a0f 100644
--- a/src/main/java/com/zy/asrs/utils/NotifyUtils.java
+++ b/src/main/java/com/zy/asrs/utils/NotifyUtils.java
@@ -27,16 +27,16 @@
@Autowired
private ConfigService configService;
- public synchronized boolean notify(String deviceType, Integer device, String taskNo, NotifyMsgType msgType) {
- SlaveType type = SlaveType.findInstance(deviceType);
- if (type == null) {
- return false;
- }
- return append(type, device, taskNo, msgType);
+ public synchronized boolean notify(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType) {
+ return append(notifyType, device, taskNo, superTaskNo, msgType, null);
}
- public synchronized List<String> takeKeys(String deviceType, Integer device) {
- String key = getKey(deviceType, device);
+ public synchronized boolean notify(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType, String data) {
+ return append(notifyType, device, taskNo, superTaskNo, msgType, data);
+ }
+
+ public synchronized List<String> takeKeys(String notifyType, Integer device) {
+ String key = getKey(notifyType, device);
if(key == null){
return null;
}
@@ -53,46 +53,46 @@
return list;
}
- public String getKey(String deviceType, Integer device) {
- SlaveType type = SlaveType.findInstance(deviceType);
- if (type == null) {
- return null;
- }
+ public String getKey(String notifyType, Integer device) {
String key = null;
- switch (type) {
- case Shuttle:
- key = RedisKeyType.QUEUE_SHUTTLE.key + device;
- break;
- case ForkLift:
- key = RedisKeyType.QUEUE_FORK_LIFT.key + device;
- break;
- default:
- return null;
+ if (notifyType.equals(String.valueOf(SlaveType.Shuttle))) {
+ key = RedisKeyType.QUEUE_SHUTTLE.key + device;
+ } else if (notifyType.equals(String.valueOf(SlaveType.ForkLift))) {
+ key = RedisKeyType.QUEUE_FORK_LIFT.key + device;
+ } else if (notifyType.equals("task")) {
+ key = RedisKeyType.QUEUE_TASK.key + device;
+ } else {
+ return null;
}
return key;
}
- private boolean append(SlaveType deviceType, Integer device, String taskNo, NotifyMsgType msgType) {
- String key = null;
- switch (deviceType) {
- case Shuttle:
- key = RedisKeyType.QUEUE_SHUTTLE.key + device;
- break;
- case ForkLift:
- key = RedisKeyType.QUEUE_FORK_LIFT.key + device;
- break;
- default:
- return false;
+ private boolean append(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType, String data) {
+ boolean notifyEnable = true;
+ Config notifyEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyEnable"));
+ if (notifyEnableConfig != null) {
+ notifyEnable = notifyEnableConfig.getValue().equals("Y");
+ }
+
+ if (!notifyEnable) {
+ return false;
+ }
+
+ String key = getKey(notifyType, device);
+ if (key == null) {
+ return false;
}
NotifyDto dto = new NotifyDto();
dto.setId(snowflakeIdWorker.nextId());
- dto.setDeviceType(String.valueOf(deviceType));
+ dto.setNotifyType(notifyType);
dto.setDevice(device);
dto.setMsgType(msgType.flag);
- dto.setContent(msgType.desc);
+ dto.setMsgDesc(msgType.desc);
+ dto.setData(data);
dto.setTaskNo(taskNo);
+ dto.setSuperTaskNo(superTaskNo);
//閲嶈瘯娆℃暟
Config notifyFailTimesConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyFailTimes"));
--
Gitblit v1.9.1