From 694962918618b6d9531d8ca876a6746e030387f1 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 23 八月 2022 11:38:26 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java |  102 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 89 insertions(+), 13 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 209edf0..fb4025e 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;
@@ -18,6 +19,7 @@
 import com.sandu.ximon.admin.utils.response.VnnoxPlayerResponse;
 import com.sandu.ximon.admin.utils.response.VnnoxResult;
 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 +29,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.net.URISyntaxException;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -110,7 +113,10 @@
      */
     public Map<String, Object> screenStatusChange(List<LedPlayerEntity> playerList, Integer screenStatus) {
         playerList.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getPlayerName().isEmpty() || item.getPlayerName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
         });
@@ -135,12 +141,12 @@
         playerList.forEach(n -> {
             if (finalSuccess.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 successList.add(vo);
             } else if (finalFail.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 faileList.add(vo);
             }
@@ -158,7 +164,10 @@
 
     public Map<String, Object> volChange(List<LedPlayerEntity> playerList, Integer vol) {
         playerList.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getPlayerName().isEmpty() || item.getPlayerName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
         });
@@ -178,12 +187,12 @@
         playerList.forEach(n -> {
             if (finalSuccess.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 successList.add(vo);
             } else if (finalFail.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 faileList.add(vo);
             }
@@ -196,7 +205,10 @@
 
     public Map<String, Object> brightnessChange(List<LedPlayerEntity> playerList, Integer brightness) {
         playerList.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getPlayerName().isEmpty() || item.getPlayerName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
         });
@@ -216,12 +228,12 @@
         playerList.forEach(n -> {
             if (finalSuccess.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 successList.add(vo);
             } else if (finalFail.contains(n.getPlayerId())) {
                 NovaPushResultVO vo = new NovaPushResultVO();
-                vo.setName(n.getPlayerName());
+                vo.setName(n.getName());
                 vo.setPlayerId(n.getPlayerId());
                 faileList.add(vo);
             }
@@ -275,6 +287,61 @@
         return map;
     }
 
+
+    // 鎵归噺鎴睆
+    public List<NovaScreenShorUrlVO> getScreenShotUrl(List<NovaPushResultVO> playerIds) {
+        List<NovaScreenShorUrlVO> screenShorUrlList = new ArrayList<>();
+
+        //浠巔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++;
+                    }
+                }
+                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();
+
+                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);
+            }
+        }
+        return screenShorUrlList;
+    }
+
+
 //    //閲嶅惎
 //    public VnnoxResult reboot(List<LedPlayerEntity> playerList) {
 //        return vnnoxAPIUtil.reboot(
@@ -288,7 +355,10 @@
     public Map<String, Object> reboot(List<NovaPushResultVO> nova) {
         List<String> playerIds = new ArrayList<>();
         nova.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getName().isEmpty() || item.getName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
             playerIds.add(item.getPlayerId());
@@ -327,7 +397,10 @@
     public Map<String, Object> syncPlay(List<NovaPushResultVO> nova, Integer option) {
         List<String> playerIds = new ArrayList<>();
         nova.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getName().isEmpty() || item.getName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
             playerIds.add(item.getPlayerId());
@@ -364,7 +437,10 @@
     public Map<String, Object> ntpSync(List<NovaPushResultVO> nova, boolean enable) {
         List<String> playerIds = new ArrayList<>();
         nova.forEach(item -> {
-            if (item.getPlayerId().isEmpty() || item.getName().isEmpty() || item.getName() == null || item.getPlayerId() == null) {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
                 throw new BusinessException("playerId鎴杙layerName涓虹┖");
             }
             playerIds.add(item.getPlayerId());
@@ -494,7 +570,7 @@
 
 
     private List<PlayerWidget> generateWaterAndSensorWidget(A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
-        //TODO
+
         List widgetList = new ArrayList<>();
         List<String> list = new ArrayList<>();
         if (Objects.nonNull(poleSensorEntity)) {

--
Gitblit v1.9.3