From dda268997ca8f8a364f7c19b45d7a43a50a98efe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 25 十月 2022 18:00:11 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java |  599 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 504 insertions(+), 95 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 b0c7ce0..efeefdf 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,21 +1,20 @@
 package com.sandu.ximon.admin.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSON;
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.util.SpringContextHolder;
 import com.sandu.ximon.admin.config.VnnoxConstant;
-import com.sandu.ximon.admin.dto.nova.AirDataProgram;
-import com.sandu.ximon.admin.dto.nova.PlayerLayout;
-import com.sandu.ximon.admin.dto.nova.PlayerPage;
-import com.sandu.ximon.admin.dto.nova.PlayerWidget;
 import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
-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.redis.DeviceRedisKey;
+import com.sandu.ximon.admin.security.SecurityUtils;
+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.*;
 import com.sandu.ximon.dao.domain.LedPlayerEntity;
 import com.sandu.ximon.dao.domain.LedPlayerInfoEntity;
 import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity;
@@ -25,6 +24,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.net.URISyntaxException;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -45,6 +45,7 @@
     private LedPlayerEntityService ledPlayerEntityService;
 
     private VnnoxProgramAPIUtil vnnoxProgramAPIUtil;
+    private CountDownLatchUtil countDownLatchUtil;
 
     /**
      * 璁惧鏍¢獙娉ㄥ唽
@@ -106,7 +107,15 @@
      * @param screenStatus
      * @return
      */
-    public VnnoxResult screenStatusChange(List<LedPlayerEntity> playerList, Integer screenStatus) {
+    public Map<String, Object> screenStatusChange(List<LedPlayerEntity> playerList, Integer screenStatus) {
+        playerList.forEach(item -> {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+        });
         VnnoxScreenStatusType type;
         if (screenStatus.equals(0)) {
             type = VnnoxScreenStatusType.CLOSE;
@@ -115,29 +124,120 @@
         }
 
         VnnoxResult vnnoxResult = vnnoxAPIUtil.screenStatus(playerList.stream().map(item -> item.getPlayerId()).collect(Collectors.toList()), type);
+
+
+        List<String> success = vnnoxResult.getSuccess();
+        List<String> fail = vnnoxResult.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        playerList.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                successList.add(vo);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                faileList.add(vo);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+
         //  鏍规嵁灞忓箷鐘舵�佽皟鏁碦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 vnnoxResult;
+        return result;
     }
 
-    public VnnoxResult volChange(List<LedPlayerEntity> playerList, Integer vol) {
+    public Map<String, Object> volChange(List<LedPlayerEntity> playerList, Integer vol) {
+        playerList.forEach(item -> {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+        });
         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);
         }
-        return vnnoxResult;
+        List<String> success = vnnoxResult.getSuccess();
+        List<String> fail = vnnoxResult.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        playerList.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                successList.add(vo);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                faileList.add(vo);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+        return result;
     }
 
-    public VnnoxResult brightnessChange(List<LedPlayerEntity> playerList, Integer brightness) {
+    public Map<String, Object> brightnessChange(List<LedPlayerEntity> playerList, Integer brightness) {
+        playerList.forEach(item -> {
+            if (item.getName() == null || item.getPlayerId() == null) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+            if (item.getPlayerId().isEmpty() || item.getName().isEmpty()) {
+                throw new BusinessException("playerId鎴杙layerName涓虹┖");
+            }
+        });
         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);
         }
-        return vnnoxResult;
+        List<String> success = vnnoxResult.getSuccess();
+        List<String> fail = vnnoxResult.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        playerList.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                successList.add(vo);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                NovaPushResultVO vo = new NovaPushResultVO();
+                vo.setName(n.getName());
+                vo.setPlayerId(n.getPlayerId());
+                faileList.add(vo);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+        return result;
 
     }
 
@@ -183,6 +283,62 @@
         return map;
     }
 
+
+    // 鎵归噺鎴睆
+    public List<NovaScreenShorUrlVO> getScreenShotUrl(List<NovaPushResultVO> playerIds) throws InterruptedException {
+        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++;
+                        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();
+
+                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(
@@ -193,8 +349,40 @@
 //    }
 
     //閲嶅惎
-    public VnnoxResult reboot(List<String> playerList) {
-        return vnnoxAPIUtil.reboot(playerList);
+    public Map<String, Object> reboot(List<NovaPushResultVO> nova) {
+        List<String> playerIds = new ArrayList<>();
+        nova.forEach(item -> {
+            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());
+        });
+
+        VnnoxResult reboot = vnnoxAPIUtil.reboot(playerIds);
+
+
+        List<String> success = reboot.getSuccess();
+        List<String> fail = reboot.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        nova.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                successList.add(n);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                faileList.add(n);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+        return result;
     }
 
     /**
@@ -203,8 +391,38 @@
      * @param
      * @return
      */
-    public VnnoxResult syncPlay(List<String> playerList, Integer option) {
-        return vnnoxAPIUtil.syncPlay(playerList, option);
+    public Map<String, Object> syncPlay(List<NovaPushResultVO> nova, Integer option) {
+        List<String> playerIds = new ArrayList<>();
+        nova.forEach(item -> {
+            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());
+        });
+        VnnoxResult vnnoxResult = vnnoxAPIUtil.syncPlay(playerIds, option);
+
+        List<String> success = vnnoxResult.getSuccess();
+        List<String> fail = vnnoxResult.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        nova.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                successList.add(n);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                faileList.add(n);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+        return result;
     }
 
     /**
@@ -213,8 +431,38 @@
      * @param
      * @return
      */
-    public VnnoxResult ntpSync(List<String> playerList, boolean enable) {
-        return vnnoxAPIUtil.ntpSync(playerList, enable);
+    public Map<String, Object> ntpSync(List<NovaPushResultVO> nova, boolean enable) {
+        List<String> playerIds = new ArrayList<>();
+        nova.forEach(item -> {
+            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());
+        });
+        VnnoxResult vnnoxResult = vnnoxAPIUtil.ntpSync(playerIds, enable);
+
+        List<String> success = vnnoxResult.getSuccess();
+        List<String> fail = vnnoxResult.getFail();
+        //鎷兼帴鎴愬姛澶辫触鐨勭粨鏋�
+        Map<String, Object> result = new HashMap<>();
+        List<NovaPushResultVO> successList = new ArrayList<>();
+        List<NovaPushResultVO> faileList = new ArrayList<>();
+        List<String> finalSuccess = success;
+        List<String> finalFail = fail;
+        nova.forEach(n -> {
+            if (finalSuccess.contains(n.getPlayerId())) {
+                successList.add(n);
+            } else if (finalFail.contains(n.getPlayerId())) {
+                faileList.add(n);
+            }
+        });
+
+        result.put("success", successList);
+        result.put("fail", faileList);
+        return result;
     }
 
 
@@ -223,9 +471,11 @@
         if (byId == null) {
             throw new BusinessException("鏈壘鍒拌璁惧");
         }
-        boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getSn(), PoleBindingEnums.VONNOX);
-        if (!belong) {
-            throw new BusinessException("璇ヨ澶囦笉灞炰簬鎮�,涓嶈兘淇敼璁惧淇℃伅");
+        if (SecurityUtils.getClientId() != null) {
+            boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getSn(), PoleBindingEnums.VONNOX);
+            if (!belong) {
+                throw new BusinessException("璇ヨ澶囦笉灞炰簬鎮�,涓嶈兘淇敼璁惧淇℃伅");
+            }
         }
         LedPlayerEntity led = new LedPlayerEntity();
         led.setId(id);
@@ -247,101 +497,260 @@
     /**
      * 鑾峰彇缂撳瓨鏁版嵁
      *
-     * @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
+                    || redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + 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);
-            System.out.println(playerId + "鐨勮矾寰勭粨鏋�:-----------------------------" + result);
-            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 = 0;
+                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;
     }
 
 
-    public VnnoxResult publishWaterData(String playerId, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
+    public VnnoxResult WaterData(String playerId, Long duration, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
         List<String> playerIds = new ArrayList<>();
         playerIds.add(playerId);
-        AirDataProgram playerProgram = new AirDataProgram();
+        NovaWeatherVO playerProgram = new NovaWeatherVO();
         playerProgram.setPlayerIds(playerIds);
-        PlayerPage playerPage = new PlayerPage();
-        playerPage.setName("AirData page");
-        List<PlayerWidget> widgetList = generateWaterAndSensorWidget(poleSensorEntity);
-        playerPage.setWidgets(widgetList);
-        List<PlayerPage> list = new ArrayList<>();
-        list.add(playerPage);
-        playerProgram.setPages(list);
-        playerProgram.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
 
+        NovaWeatherVO.AttributeDTO attributeDTO = new NovaWeatherVO.AttributeDTO();
+        attributeDTO.setDuration(duration);
+        playerProgram.setAttribute(attributeDTO);
+        List<NovaWeatherVO.PageDTO.WidgetsDTO> widgets = setWeather(duration, poleSensorEntity);
+        NovaWeatherVO.PageDTO page = new NovaWeatherVO.PageDTO();
+        page.setWidgets(widgets);
+        playerProgram.setPage(page);
 
-        /**
-         * 璇虹摝鎺ㄩ�佸ぇ姘旀暟鎹� 鏃ュ織璁板綍寮�濮�
-         ////         */
-//        String content = "{璇虹摝playerId锛�" + playerId + ",鑺傜洰鍐呭锛�" + JSON.toJSONString(playerProgram) + " }";
-//        StoreOperationRecordsUtils.storeOperationData(null, null, "澶ф皵鏁版嵁鎺ㄩ�佸埌璇虹摝", content);
-        /**
-         * 璇虹摝鎺ㄩ�佸ぇ姘旀暟鎹� 鏃ュ織璁板綍缁撴潫
-         */
-
-        return vnnoxProgramAPIUtil.normalProgram(playerProgram).getData();
+        return vnnoxProgramAPIUtil.emergencyProgram(playerProgram).getData();
     }
 
 
-    private List<PlayerWidget> generateWaterAndSensorWidget(A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
-        List widgetList = new ArrayList<>();
+    private List<NovaWeatherVO.PageDTO.WidgetsDTO> setWeather(Long duration, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
+
+        List<NovaWeatherVO.PageDTO.WidgetsDTO> widgets = new ArrayList<>();
         List<String> list = new ArrayList<>();
-//        if (Objects.nonNull(waterDataEntity)) {
-//            list.add("姘磋川鐜鐩戞祴瀹炴椂鏁版嵁锛�");
-//            list.add("ph锛�"+waterDataEntity.getPh());
-//            list.add("婧惰В姘э細"+waterDataEntity.getDoData() + "(mg/L)");
-//            list.add("鐢靛鐜囷細"+waterDataEntity.getEc() + "(10^(-6)S)");
-//            list.add("娴婂害锛�"+waterDataEntity.getNtu() + "NTU");
-//        }
         if (Objects.nonNull(poleSensorEntity)) {
-//            list.add("鐜鐩戞祴锛�");
+            list.add("鐜鐩戞祴锛�");
             list.add("娓╁害锛�" + poleSensorEntity.getTemperature() + "掳");
             list.add("婀垮害锛�" + poleSensorEntity.getHumidity() + "%");
             list.add("pm25锛�" + poleSensorEntity.getPm25() + "渭g/m鲁");
             list.add("pm10锛�" + poleSensorEntity.getPm10() + "渭g/m鲁");
             list.add("鐢查啗锛�" + poleSensorEntity.getEch2o() + "渭g/m鲁");
             list.add("CO2锛�" + poleSensorEntity.getCo2() + "ppm");
+        } else {
+            list.add("澶ф皵璁惧涓嶅湪绾�");
+            list.add("鐩墠鏄浐瀹氭暟鎹細");
+            list.add("鐜鐩戞祴锛�");
+            list.add("娓╁害锛� 40掳");
+            list.add("婀垮害锛� 60%");
+            list.add("pm25锛�0.58 渭g/m鲁");
+            list.add("pm10锛�0.58 渭g/m鲁");
+            list.add("鐢查啗锛�99.9 渭g/m鲁");
+            list.add("CO2锛�200 ppm");
         }
 
-        widgetList.add(new PlayerWidget().generateScrollUpTextWidget("weather", 1, 100000L, list, "#FFFFFF", 15, new PlayerLayout("0%", "5%", "100%", "100%")));
 
-        return widgetList;
+        List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO> lines = new ArrayList<>();
+
+        list.forEach(txt -> {
+            List<NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO> textAttributes = new ArrayList<>();
+
+            NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO linesDTO = new NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO();
+            NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO textAttributesDTO = new NovaWeatherVO.PageDTO.WidgetsDTO.LinesDTO.TextAttributesDTO();
+            textAttributesDTO.setContent(txt);
+            textAttributes.add(textAttributesDTO);
+            System.out.println(txt + "鏂囨湰鍐呭");
+            linesDTO.setTextAttributes(textAttributes);
+            lines.add(linesDTO);
+        });
+
+        NovaWeatherVO.PageDTO.WidgetsDTO widgetsDTO = new NovaWeatherVO.PageDTO.WidgetsDTO();
+        NovaWeatherVO.PageDTO.WidgetsDTO.ScrollAttributeDTO scrollAttribute = new NovaWeatherVO.PageDTO.WidgetsDTO.ScrollAttributeDTO();
+
+        NovaWeatherVO.PageDTO.WidgetsDTO.LayoutDTO layout = new NovaWeatherVO.PageDTO.WidgetsDTO.LayoutDTO();
+
+        widgetsDTO.setScrollAttribute(scrollAttribute);
+        widgetsDTO.setLayout(layout);
+        widgetsDTO.setLines(lines);
+
+        widgetsDTO.setDuration(duration);
+        widgets.add(widgetsDTO);
+        System.out.println(lines + "鎾斁鍐呭");
+
+        return widgets;
     }
 
+
+    /**
+     * 鏇存柊璇虹摝灞忓箷鍒嗚鲸鐜�
+     */
+    public void saveInfo() {
+        List<LedPlayerEntity> all = ledPlayerEntityService.list();
+        List<List<LedPlayerEntity>> split = CollectionUtil.split(all, 100);
+        List<LedPlayerEntity> list = new ArrayList<>();
+        for (List<LedPlayerEntity> ledList : split) {
+            list.addAll(vnnoxAPIUtil.saveCurrentInfo(ledList));
+        }
+        boolean b = SpringContextHolder.getBean(LedPlayerEntityService.class).updateBatchById(list);
+        if (b) {
+            LogUtils.error("鏇存柊璇虹摝灞忓箷鍒嗚鲸鐜囨垚鍔�");
+        }
+    }
+
+
+    public void asyncStatus(List<String> playerIds) {
+        VnnoxResultResponse vnnoxResultResponse = vnnoxAPIUtil.asyncStatus(playerIds);
+    }
+
+    /**
+     * 鑾峰彇璇虹摝灞忓箷淇℃伅
+     *
+     * @param stateValue
+     * @param playIdList
+     * @return
+     */
+    public List<NovaAStateInfoVO> getInfo(String stateValue, List<String> playIdList) {
+        List<NovaAStateInfoVO> list = new ArrayList<>();
+        NovaAStateInfoVO novaAStateInfoVO;
+        for (String playId : playIdList) {
+            String volumeValue = RedisUtils.getBean().get(VnnoxConstant.REDIS_VOL + playId);
+            String brightnessValue = RedisUtils.getBean().get(VnnoxConstant.REDIS_BRIGHTNESS + playId);
+            String videoSourceValue = RedisUtils.getBean().get(VnnoxConstant.VIDEO_SOURCE_VALUE + playId);
+            String timezoneValue = RedisUtils.getBean().get(VnnoxConstant.TIME_VALUE_TIMEZONE + playId);
+            String timeValue = RedisUtils.getBean().get(VnnoxConstant.TIME_VALUE_TIME + playId);
+            String screenPowerStatus = RedisUtils.getBean().get(VnnoxConstant.REDIS_SCREEN_STATUS + playId);
+            String syncPlayStatus = RedisUtils.getBean().get(VnnoxConstant.SYNC_PLAY_STATUS + playId);
+            novaAStateInfoVO = new NovaAStateInfoVO();
+            novaAStateInfoVO.setPlayerId(playId);
+            switch (stateValue) {
+                case "all":
+                    novaAStateInfoVO.setVolumeValue(volumeValue);
+                    novaAStateInfoVO.setBrightnessValue(brightnessValue);
+                    novaAStateInfoVO.setVideoSourceValue(videoSourceValue);
+                    novaAStateInfoVO.setTimezoneValue(timezoneValue);
+                    novaAStateInfoVO.setTimeValue(timeValue);
+                    novaAStateInfoVO.setScreenPowerStatus(screenPowerStatus);
+                    novaAStateInfoVO.setSyncPlayStatus(syncPlayStatus);
+                    break;
+                case "volumeValue":
+                    novaAStateInfoVO.setVolumeValue(volumeValue);
+                    break;
+                case "brightnessValue":
+                    novaAStateInfoVO.setBrightnessValue(brightnessValue);
+                    break;
+                case "videoSourceValue":
+                    novaAStateInfoVO.setVideoSourceValue(videoSourceValue);
+                    break;
+                case "timeValue":
+                    novaAStateInfoVO.setTimezoneValue(timezoneValue);
+                    novaAStateInfoVO.setTimeValue(timeValue);
+                    break;
+                case "screenPowerStatus":
+                    novaAStateInfoVO.setScreenPowerStatus(screenPowerStatus);
+                    break;
+                case "syncPlayStatus":
+                    novaAStateInfoVO.setSyncPlayStatus(syncPlayStatus);
+                    break;
+                default:
+            }
+            list.add(novaAStateInfoVO);
+        }
+        return list;
+    }
+
+    public void getAsyncStatus(List<String> playerIdList, String stateValue) {
+        List<List<String>> split = CollectionUtil.split(playerIdList, 100);
+        split.forEach(
+                playerIds -> {
+                    vnnoxAPIUtil.getAsyncStatus(playerIdList, stateValue);
+                }
+        );
+    }
+
+
+    /**
+     * 鍚慠edis涓瓨鍏ヨ澶囩姸鎬�
+     */
+    public void setCacheData() {
+
+        List<List<LedPlayerEntity>> split = CollectionUtil.split(ledPlayerEntityService.list(), 100);
+        List<LedPlayerEntity> ledList = new ArrayList<>();
+        split.forEach(
+                list -> {
+                    List<LedPlayerEntity> ledPlayerEntities = vnnoxAPIUtil.syncCurrentInfo(list);
+                    ledList.addAll(ledPlayerEntities);
+                }
+        );
+
+        ledList.forEach(
+                device -> {
+                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
+                    deviceStatus.setDeviceId(device.getPlayerId());
+                    if (device.getOnlineStatus() == 0) {
+                        deviceStatus.setStatus(1);
+                    } else if (device.getOnlineStatus() == 1) {
+                        deviceStatus.setStatus(0);
+                    } else {
+                        deviceStatus.setStatus(1);
+                    }
+                    redisUtils.set(DeviceRedisKey.NOVA + device.getPlayerId(), JSON.toJSONString(deviceStatus));
+//                    redisUtils.delete(DeviceRedisKey.IP_BROADCAST + device.getId());
+                }
+        );
+
+    }
 }

--
Gitblit v1.9.3