From c88f44a7d604bf91e22a5cb076018884a01a6261 Mon Sep 17 00:00:00 2001
From: Van333 <van666666@foxmail.com>
Date: 星期六, 19 十一月 2022 15:11:17 +0800
Subject: [PATCH] 替换阿里oss为本地minio,关闭对时存在定时任务时睡眠10min
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java | 57 ++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
index cdad378..714e1f3 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -51,6 +51,8 @@
import java.util.*;
import java.util.stream.Collectors;
+import static com.sandu.ximon.admin.localMQTT.callback.StatusMqttCallBack.localMqttConnectStatusMap;
+
/**
* @author chenjiantian
* @date 2021/12/13 16:00
@@ -144,7 +146,8 @@
// 鑾峰彇鏈�杩戠殑涓婃姤鏃堕棿
List<String> deviceCodeList = listLight.stream().map(Light::getDeviceCode).collect(Collectors.toList());
- //鎷嗗垎list
+
+// //鎷嗗垎list
List<List<String>> split = CollectionUtil.split(deviceCodeList, 100);
List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = null;
@@ -202,13 +205,17 @@
*/
public Light getLight(String deviceCode) {
Light one = getOne(Wrappers.<Light>lambdaQuery().eq(Light::getDeviceCode, deviceCode));
- Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
- if (o != null) {
- one.setOnlineStatus(1);
+ if (one == null) {
+ return null;
} else {
- one.setOnlineStatus(0);
+ Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
+ if (o != null) {
+ one.setOnlineStatus(1);
+ } else {
+ one.setOnlineStatus(0);
+ }
+ return one;
}
- return one;
}
/**
@@ -261,13 +268,17 @@
List<Map<String, Object>> resultList = new ArrayList<>();
for (LightControlParam param : paramList) {
- A5LightBrightnessReqInnerFrame lightControlFrame = new A5LightBrightnessReqInnerFrame(param.getBrightness(), param.getLightAddress());
- A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), lightControlFrame);
+ A5LightBrightnessReqInnerFrame
+ lightControlFrame = new A5LightBrightnessReqInnerFrame(param.getBrightness(), param.getLightAddress());
+ A5Frame a5Frame = new A5Frame(
+ A5OrderEnum.REQUEST_LIGHT_DATA.getCode(),
+ lightControlFrame);
Map<String, Object> map = new HashMap<>();
try {
map.put("deviceCode", param.getDeviceCode());
WrapResponseCommonFrame<A5LightBrightnessRespInnerFrame> frame
- = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a5Frame, A5LightBrightnessRespInnerFrame.class);
+ = MainBoardInvokeSyncService.getInstance().sendRRPC
+ (param.getDeviceCode(), a5Frame, A5LightBrightnessRespInnerFrame.class);
//瀛樺偍鎺у埗甯ф寚浠�
StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "鍗曠伅甯�-浜害鎺у埗", a5Frame, frame);
@@ -1002,9 +1013,7 @@
A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), setCalendarReqInnerFrame);
System.out.println(a5Frame + " -----a5Frame");
- CommonFrame commonFrame;
-
- commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a5Frame);
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a5Frame);
StoreOperationRecordsUtils.storeInnerFrameData(one.getDeviceCode(), "鍗曠伅甯�-璁剧疆鏃ュ巻", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -1023,9 +1032,10 @@
public void timeSynchronizationInitiative(String deviceCode, String lightAddress) {
//鍗曠伅淇℃伅
Light light = getLight(deviceCode);
- if (light == null) {
- log.error("鍗曠伅涓诲姩鍚屾鏃堕棿璇锋眰寮傚父锛屽崟鐏俊鎭笉瀛樺湪锛�");
- }
+// if (light == null) {
+// log.error("鍗曠伅涓诲姩鍚屾鏃堕棿璇锋眰寮傚父锛屽崟鐏俊鎭笉瀛樺湪锛�");
+// return;
+// }
//鍗曠伅浠诲姟淇℃伅
LightTaskPoleRelation lightTaskPoleRelation = SpringContextHolder.getBean(LightTaskPoleRelationService.class)
.getOne(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
@@ -1084,14 +1094,15 @@
count++;
}
if (haveTime) {
- try {
- long longTime = cal.getTimeInMillis() - System.currentTimeMillis();
- log.error("鐫$湢鏃堕棿锛堟绉掞級锛�" + longTime);
- Thread.sleep(longTime);
- SetCalendar(light.getLightId(), lightAddress);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ log.error("瀛樺湪瀹氭椂浠诲姟锛�" + light.getLightId()+","+light.getDeviceCode());
+// try {
+// long longTime = cal.getTimeInMillis() - System.currentTimeMillis();
+// log.error("鐫$湢鏃堕棿锛堟绉掞級锛�" + longTime);
+// Thread.sleep(longTime);
+// SetCalendar(light.getLightId(), lightAddress);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
} else {
log.error("鐏潌ID涓猴細" + light.getLightId() + "锛岀伅澶村湴鍧�涓猴細" + lightAddress + "娌℃湁鎵惧埌鍙悓姝ョ殑鏃堕棿锛岃妫�鏌ヤ换鍔★紒");
}
--
Gitblit v1.9.3