From 53292dc3901548020ae6cdb10de3a0c690ef354a Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 19 三月 2025 10:01:12 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/task/NotifyScheduler.java | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/asrs/task/NotifyScheduler.java b/src/main/java/com/zy/asrs/task/NotifyScheduler.java
index 0c786e3..43fe4f9 100644
--- a/src/main/java/com/zy/asrs/task/NotifyScheduler.java
+++ b/src/main/java/com/zy/asrs/task/NotifyScheduler.java
@@ -4,6 +4,8 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.domain.NotifyDto;
+import com.zy.asrs.entity.HttpRequestLog;
+import com.zy.asrs.service.HttpRequestLogService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.common.utils.RedisUtil;
@@ -18,6 +20,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import java.util.Date;
import java.util.List;
@Component
@@ -32,6 +35,8 @@
private SlaveProperties slaveProperties;
@Autowired
private ConfigService configService;
+ @Autowired
+ private HttpRequestLogService httpRequestLogService;
@Scheduled(cron = "0/3 * * * * ? ")
public synchronized void notifyShuttle(){
@@ -45,6 +50,11 @@
for (ForkLiftSlave slave : slaveProperties.getForkLift()) {
notifyMsg(String.valueOf(SlaveType.ForkLift), slave.getId());
}
+ }
+
+ @Scheduled(cron = "0/3 * * * * ? ")
+ public synchronized void notifyTask(){
+ notifyMsg("task", 1);
}
private synchronized void notifyMsg(String notifyType, Integer device) {
@@ -89,6 +99,11 @@
continue;
}
+ HttpRequestLog httpRequestLog = new HttpRequestLog();
+ httpRequestLog.setName(notifyUri + notifyUriPath);
+ httpRequestLog.setRequest(JSON.toJSONString(notifyDto));
+ httpRequestLog.setCreateTime(new Date());
+
try {
//瑙﹀彂閫氱煡
String response = new HttpHandler.Builder()
@@ -97,15 +112,21 @@
.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);
}
//閫氱煡澶辫触
--
Gitblit v1.9.1