From 5e2fe6ce6e80dea99f6eda304dba6fafbb30ad63 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 09 九月 2022 11:34:13 +0800
Subject: [PATCH] 灯杆解绑fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java | 210 ++++++++++++++++++++++++++++++++--------------------
1 files changed, 129 insertions(+), 81 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
index a4e905d..9c399f8 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.service;
+import cn.hutool.core.collection.CollectionUtil;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.config.VnnoxConstant;
@@ -9,15 +10,14 @@
import com.sandu.ximon.admin.dto.nova.PlayerWidget;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.security.SecurityUtils;
-import com.sandu.ximon.admin.utils.RedisUtils;
-import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
-import com.sandu.ximon.admin.utils.VnnoxAPIUtil;
-import com.sandu.ximon.admin.utils.VnnoxProgramAPIUtil;
+import com.sandu.ximon.admin.utils.*;
import com.sandu.ximon.admin.utils.request.VnnoxScreenStatusType;
import com.sandu.ximon.admin.utils.response.VnnoxPlayerListResponse;
import com.sandu.ximon.admin.utils.response.VnnoxPlayerResponse;
import com.sandu.ximon.admin.utils.response.VnnoxResult;
+import com.sandu.ximon.admin.utils.response.VnnoxResultResponse;
import com.sandu.ximon.admin.vo.NovaPushResultVO;
+import com.sandu.ximon.admin.vo.NovaScreenShorUrlVO;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.domain.LedPlayerInfoEntity;
import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity;
@@ -27,6 +27,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.net.URISyntaxException;
+import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -47,6 +48,7 @@
private LedPlayerEntityService ledPlayerEntityService;
private VnnoxProgramAPIUtil vnnoxProgramAPIUtil;
+ private CountDownLatchUtil countDownLatchUtil;
/**
* 璁惧鏍¢獙娉ㄥ唽
@@ -154,7 +156,7 @@
// 鏍规嵁灞忓箷鐘舵�佽皟鏁碦EDIS鏍囪瘑浣�
for (String playerId : vnnoxResult.getSuccess()) {
- redisUtils.set(VnnoxConstant.REDIS_SCREEN_STATUS + playerId, screenStatus, VnnoxConstant.REDIS_MAX_SAVE_TIME);
+ redisUtils.set(VnnoxConstant.REDIS_SCREEN_STATUS + playerId, screenStatus);
}
return result;
}
@@ -171,7 +173,7 @@
VnnoxResult vnnoxResult = vnnoxAPIUtil.volChange(playerList.stream().map(item -> item.getPlayerId()).collect(Collectors.toList()), vol);
// 鏍规嵁闊抽噺璋冩暣REDIS鏍囪瘑浣�
for (String playerId : vnnoxResult.getSuccess()) {
- redisUtils.set(VnnoxConstant.REDIS_VOL + playerId, vol, VnnoxConstant.REDIS_MAX_SAVE_TIME);
+ redisUtils.set(VnnoxConstant.REDIS_VOL + playerId, vol,VnnoxConstant.STATUS_TIME);
}
List<String> success = vnnoxResult.getSuccess();
List<String> fail = vnnoxResult.getFail();
@@ -212,7 +214,7 @@
VnnoxResult vnnoxResult = vnnoxAPIUtil.brightnessChange(playerList.stream().map(item -> item.getPlayerId()).collect(Collectors.toList()), brightness);
// 鏍规嵁浜害璋冩暣REDIS鏍囪瘑浣�
for (String playerId : vnnoxResult.getSuccess()) {
- redisUtils.set(VnnoxConstant.REDIS_BRIGHTNESS + playerId, brightness, VnnoxConstant.REDIS_MAX_SAVE_TIME);
+ redisUtils.set(VnnoxConstant.REDIS_BRIGHTNESS + playerId, brightness, VnnoxConstant.STATUS_TIME);
}
List<String> success = vnnoxResult.getSuccess();
List<String> fail = vnnoxResult.getFail();
@@ -286,49 +288,57 @@
// 鎵归噺鎴睆
- public Map<String, String> getScreenShotUrl(List<String> playerIds) {
- Map<String, String> map = new HashMap();
+ public List<NovaScreenShorUrlVO> getScreenShotUrl(List<NovaPushResultVO> playerIds) throws InterruptedException {
+ List<NovaScreenShorUrlVO> screenShorUrlList = new ArrayList<>();
- playerIds.forEach(
- playId->{
- try {
- redisUtils.delete(VnnoxConstant.REDIS_SCREEN_SHOT + playId);
- } catch (Exception e) {
-
+ //浠巔layerIds涓幏鍙杙layerId
+ List<String> AllplayerIdsList = playerIds.stream().map(item -> item.getPlayerId()).collect(Collectors.toList());
+ List<List<String>> split = CollectionUtil.split(AllplayerIdsList, 100);
+ for (List<String> playerIdsList : split) {
+ VnnoxResult vnnoxResult = vnnoxAPIUtil.screenShot(playerIdsList);
+ LocalDateTime now = LocalDateTime.now();
+ NovaScreenShorUrlVO screenShorUrlVO;
+ for (String successStrId : vnnoxResult.getSuccess()) {
+ screenShorUrlVO = new NovaScreenShorUrlVO();
+ String url = null;
+ int num = 0;
+ while (num < 3) {
+ url = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + successStrId);
+ if (url != null) {
+ break;
+ } else {
+ num++;
+ Thread.sleep(500);
+ }
}
+ screenShorUrlVO.setShortUrl(url);
+ screenShorUrlVO.setPlayerId(successStrId);
+ screenShorUrlVO.setTime(now);
+ for (NovaPushResultVO bean : playerIds) {
+ if (bean.getPlayerId().equals(successStrId)) {
+ screenShorUrlVO.setName(bean.getName());
+ break;
+ }
+ }
+ screenShorUrlList.add(screenShorUrlVO);
}
- );
+ for (String failStrId : vnnoxResult.getFail()) {
+ screenShorUrlVO = new NovaScreenShorUrlVO();
- VnnoxResult vnnoxResult = vnnoxAPIUtil.screenShot(playerIds);
-
- if (null == vnnoxResult) {
- map.put("code", "500");
- map.put("msg", "璁惧宸蹭笅绾�");
- return map;
- }
-
- if (vnnoxResult.getSuccess().size() == 0) {
- map.put("code", "500");
- map.put("msg", "鑾峰彇缂╃暐鍥惧け璐�!");
- return map;
- }
- String url = null;
- Integer checkCount = 0;
- while (checkCount < 10) {
- url = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + playerIds.get(0));
- if (null != url) {
- break;
- }
- try {
- Thread.sleep(2000);
- checkCount = checkCount + 1;
- } catch (InterruptedException e) {
- e.printStackTrace();
+ String url = null;
+ screenShorUrlVO.setShortUrl(url);
+ screenShorUrlVO.setPlayerId(failStrId);
+ screenShorUrlVO.setTime(now);
+ for (NovaPushResultVO bean : playerIds) {
+ if (bean.getPlayerId().equals(failStrId)) {
+ screenShorUrlVO.setName(bean.getName());
+ break;
+ }
+ }
+ screenShorUrlList.add(screenShorUrlVO);
}
}
- map.put("url", url);
- map.put("code", "200");
- return map;
+ return screenShorUrlList;
}
@@ -490,46 +500,66 @@
/**
* 鑾峰彇缂撳瓨鏁版嵁
*
- * @param list
+ * @param
* @return
*/
- public List<LedPlayerEntity> setCacheInfo(List<LedPlayerEntity> list) {
- for (LedPlayerEntity playerEntity : list) {
- String playerId = playerEntity.getPlayerId();
- LedPlayerInfoEntity cache = new LedPlayerInfoEntity();
- // 璁剧疆灞忓箷鐘舵��
- String result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId);
- Integer screenStatus = 1;
- if (null != result) {
- screenStatus = Integer.parseInt(result);
+ public List<LedPlayerEntity> setCacheInfo(List<LedPlayerEntity> ledList) {
+ List<String> temp = new ArrayList<>();
+ for (LedPlayerEntity item : ledList) {
+ String playerId = item.getPlayerId();
+ if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null
+ || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null) {
+ temp.add(item.getPlayerId());
}
- cache.setScreenStatus(screenStatus);
- // 璁剧疆灞忓箷闊抽噺
- result = redisUtils.get(VnnoxConstant.REDIS_VOL + playerId);
- Integer vol = 0;
- if (null != result) {
- vol = Integer.parseInt(result);
- }
- cache.setVol(vol);
- // 璁剧疆灞忓箷浜害
- result = redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId);
- Integer brightness = 0;
- if (null != result) {
- brightness = Integer.parseInt(result);
- }
- cache.setBrightness(brightness);
-
- // 璁剧疆缂╃暐鍥捐闂矾寰�
- result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + playerId);
- if (null != result) {
- playerEntity.setScreenShotUrl(result);
- } else {
- playerEntity.setScreenShotUrl("");
- }
-
- playerEntity.setPlayerInfo(cache);
}
- return list;
+ if (temp.size() > 0) {
+ List<List<String>> split = CollectionUtil.split(temp, 100);
+ for (List<String> playIds : split) {
+ System.out.println(playIds.size());
+ vnnoxAPIUtil.asyncStatus(playIds);
+ }
+ }
+
+ List<List<LedPlayerEntity>> split = CollectionUtil.split(ledList, 100);
+ for (List<LedPlayerEntity> list : split) {
+ for (LedPlayerEntity playerEntity : list) {
+ String playerId = playerEntity.getPlayerId();
+ LedPlayerInfoEntity cache = new LedPlayerInfoEntity();
+ // 璁剧疆灞忓箷鐘舵��
+ String result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId);
+ Integer screenStatus = 1;
+ if (null != result) {
+ screenStatus = Integer.parseInt(result);
+ }
+ cache.setScreenStatus(screenStatus);
+ // 璁剧疆灞忓箷闊抽噺
+ result = redisUtils.get(VnnoxConstant.REDIS_VOL + playerId);
+ Integer vol = 0;
+ if (null != result) {
+ vol = Float.valueOf(result).intValue();
+
+ }
+ cache.setVol(vol);
+ // 璁剧疆灞忓箷浜害
+ result = redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId);
+ Integer brightness = 0;
+ if (null != result) {
+ brightness = Float.valueOf(result).intValue();
+ }
+ cache.setBrightness(brightness);
+
+ // 璁剧疆缂╃暐鍥捐闂矾寰�
+ result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + playerId);
+ if (null != result) {
+ playerEntity.setScreenShotUrl(result);
+ } else {
+ playerEntity.setScreenShotUrl("");
+ }
+
+ playerEntity.setPlayerInfo(cache);
+ }
+ }
+ return ledList;
}
@@ -560,7 +590,7 @@
private List<PlayerWidget> generateWaterAndSensorWidget(A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
- //TODO
+
List widgetList = new ArrayList<>();
List<String> list = new ArrayList<>();
if (Objects.nonNull(poleSensorEntity)) {
@@ -578,4 +608,22 @@
return widgetList;
}
+
+ /**
+ * 鏇存柊璇虹摝灞忓箷鍒嗚鲸鐜�
+ */
+ public void saveInfo() {
+ List<LedPlayerEntity> list = vnnoxAPIUtil.saveCurrentInfo(ledPlayerEntityService.list());
+ boolean b = SpringContextHolder.getBean(LedPlayerEntityService.class).updateBatchById(list);
+ if (b) {
+ LogUtils.error("鏇存柊璇虹摝灞忓箷鍒嗚鲸鐜囨垚鍔�");
+ }
+ }
+
+
+ public void asyncStatus(List<String> playerIds) {
+ VnnoxResultResponse vnnoxResultResponse = vnnoxAPIUtil.asyncStatus(playerIds);
+
+ }
+
}
--
Gitblit v1.9.3