From c1d66ef17e3538c056db1df1d023e7153e7594e5 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 28 一月 2026 16:15:58 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/NotifyScheduler.java |   77 ++++++++------------------------------
 1 files changed, 16 insertions(+), 61 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/NotifyScheduler.java b/src/main/java/com/zy/asrs/task/NotifyScheduler.java
index 8e40b08..202a5ad 100644
--- a/src/main/java/com/zy/asrs/task/NotifyScheduler.java
+++ b/src/main/java/com/zy/asrs/task/NotifyScheduler.java
@@ -1,15 +1,11 @@
 package com.zy.asrs.task;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.zy.asrs.domain.NotifyDto;
 import com.zy.asrs.entity.DeviceConfig;
-import com.zy.asrs.entity.HttpRequestLog;
 import com.zy.asrs.service.DeviceConfigService;
-import com.zy.asrs.service.HttpRequestLogService;
+import com.zy.asrs.service.NotifyAsyncService;
 import com.zy.asrs.utils.NotifyUtils;
-import com.zy.common.utils.HttpHandler;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.enums.SlaveType;
 import com.zy.system.entity.Config;
@@ -19,7 +15,6 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import java.util.Date;
 import java.util.List;
 
 @Component
@@ -33,12 +28,12 @@
     @Autowired
     private ConfigService configService;
     @Autowired
-    private HttpRequestLogService httpRequestLogService;
-    @Autowired
     private DeviceConfigService deviceConfigService;
+    @Autowired
+    private NotifyAsyncService notifyAsyncService;
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void notifyShuttle(){
+    public synchronized void notifyShuttle() {
         List<DeviceConfig> deviceList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                 .eq("device_type", String.valueOf(SlaveType.Crn)));
         for (DeviceConfig device : deviceList) {
@@ -47,7 +42,7 @@
     }
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void notifyForkLift(){
+    public synchronized void notifyForkLift() {
         List<DeviceConfig> deviceList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                 .eq("device_type", String.valueOf(SlaveType.Rgv)));
         for (DeviceConfig device : deviceList) {
@@ -56,23 +51,23 @@
     }
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void notifyTask(){
+    public synchronized void notifyTask() {
         notifyMsg("task", 1);
     }
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void notifyCrn(){
-        notifyMsg("crn", 1);
+    public synchronized void notifyCrn() {
+        notifyMsg(String.valueOf(SlaveType.Crn), 1);
     }
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public synchronized void notifyDualCrn(){
-        notifyMsg("dualCrn", 1);
+    public synchronized void notifyDualCrn() {
+        notifyMsg(String.valueOf(SlaveType.DualCrn), 1);
     }
 
     private synchronized void notifyMsg(String notifyType, Integer device) {
         Config notifyEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyEnable"));
-        if(notifyEnableConfig == null){
+        if (notifyEnableConfig == null) {
             return;
         }
         String notifyEnable = notifyEnableConfig.getValue();
@@ -81,19 +76,19 @@
         }
 
         Config notifyUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyUri"));
-        if(notifyUriConfig == null){
+        if (notifyUriConfig == null) {
             return;
         }
         String notifyUri = notifyUriConfig.getValue();
 
         Config notifyUriPathConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyUriPath"));
-        if(notifyUriPathConfig == null){
+        if (notifyUriPathConfig == null) {
             return;
         }
         String notifyUriPath = notifyUriPathConfig.getValue();
 
         List<String> keys = notifyUtils.takeKeys(notifyType, device);
-        if(keys == null){
+        if (keys == null) {
             return;
         }
 
@@ -112,48 +107,8 @@
                 continue;
             }
 
-            HttpRequestLog httpRequestLog = new HttpRequestLog();
-            httpRequestLog.setName(notifyUri + notifyUriPath);
-            httpRequestLog.setRequest(JSON.toJSONString(notifyDto));
-            httpRequestLog.setCreateTime(new Date());
-
-            try {
-                //瑙﹀彂閫氱煡
-                String response = new HttpHandler.Builder()
-                        .setUri(notifyUri)
-                        .setPath(notifyUriPath)
-                        .setJson(JSON.toJSONString(notifyDto))
-                        .build()
-                        .doPost();
-                httpRequestLog.setResponse(response);
-
-                JSONObject jsonObject = JSON.parseObject(response);
-                Integer code = jsonObject.getInteger("code");
-                if(code == 200){
-                    //閫氱煡鎴愬姛
-                    redisUtil.del(key);
-
-                    continue;
-                }
-            }catch (Exception e){
-                e.printStackTrace();
-            }finally {
-                //淇濆瓨璁板綍
-                httpRequestLogService.insert(httpRequestLog);
-            }
-
-            //閫氱煡澶辫触
-            int times = notifyDto.getRetryTimes() + 1;
-            if (times >= notifyDto.getFailTimes()) {
-                //瓒呰繃娆℃暟
-                redisUtil.del(key);
-                continue;
-            }
-
-            notifyDto.setLastRetryTime(System.currentTimeMillis());
-            notifyDto.setRetryTimes(times);
-            redisUtil.set(key, notifyDto);
-            continue;
+            // 寮傛鍙戦�侀�氱煡锛岄伩鍏嶉樆濉炲畾鏃跺櫒绾跨▼
+            notifyAsyncService.sendNotifyAsync(notifyUri, notifyUriPath, key, notifyDto);
         }
     }
 

--
Gitblit v1.9.1