From 77d4d872d13145e8aef2f6a361202e87cf84ee8f Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 16 八月 2022 10:52:38 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java |  276 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 144 insertions(+), 132 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
index bb04b27..1b4e15c 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
@@ -1,5 +1,6 @@
 package com.sandu.ximon.admin.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
@@ -27,6 +28,7 @@
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 鎾斁璁″垝
@@ -188,72 +190,77 @@
         nova.forEach(n -> {
             playerIds.add(n.getPlayerId());
         });
-
-        PlayerProgram program = new PlayerProgram();
-        program.setPlayerIds(playerIds);
-
-        //鑾峰彇鑺傜洰瀹炰綋
-
-
-        List<PlayerPage> programDtos = JSON.parseArray(pushToLed.getPages(), PlayerPage.class);
-        programDtos.forEach(
-                programDto -> {
-                    programDto.getWidgets().forEach(
-                            widget -> {
-                                if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
-                                    String url = widget.getUrl();
-                                    LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
-                                    if (one == null) {
-                                        throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
-                                    }
-                                    widget.setMd5(one.getMd5());
-                                    widget.setSize(Long.parseLong(one.getSize()));
-                                }
-                            }
-                    );
-                }
-        );
-
-        program.setPages(programDtos);
-
-        //鑾峰彇鑺傜洰瀹氭椂瀹炰綋
-        PlayerSchedule playerSchedule = JSON.parseObject(pushToLed.getSchedule(), PlayerSchedule.class);
-        //鍒犻櫎鏃堕棿鐨勫悗涓変綅
-        List<PlayerSchedulePlans> plans = playerSchedule.getPlans();
-        plans.forEach(
-                plan -> {
-                    plan.setStartTime(plan.getStartTime().substring(0, plan.getStartTime().length() - 3));
-                    plan.setEndTime(plan.getEndTime().substring(0, plan.getEndTime().length() - 3));
-                }
-        );
-        program.setSchedule(playerSchedule);
-
-
-        program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
-        LogUtils.error("鑺傜洰鍐呭+++++++++++" + JSON.toJSONString(program));
-        VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.normalProgram(program);
-        vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(pushToLed.getVolume()).intValue());
-
         List<String> success = new ArrayList<>();
         List<String> fail = new ArrayList<>();
-        if (vnnoxResultResponse.getData() != null) {
-            success = vnnoxResultResponse.getData().getSuccess();
-            fail = vnnoxResultResponse.getData().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);
+
+
+        List<List<String>> split = CollectionUtil.split(playerIds, 100);
+        for (List<String> playIds : split) {
+            PlayerProgram program = new PlayerProgram();
+            program.setPlayerIds(playIds);
+
+            //鑾峰彇鑺傜洰瀹炰綋
+
+            List<PlayerPage> programDtos = JSON.parseArray(pushToLed.getPages(), PlayerPage.class);
+            programDtos.forEach(
+                    programDto -> {
+                        programDto.getWidgets().forEach(
+                                widget -> {
+                                    if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
+                                        String url = widget.getUrl();
+                                        LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
+                                        if (one == null) {
+                                            throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
+                                        }
+                                        widget.setMd5(one.getMd5());
+                                        widget.setSize(Long.parseLong(one.getSize()));
+                                    }
+                                }
+                        );
+                    }
+            );
+
+            program.setPages(programDtos);
+
+            //鑾峰彇鑺傜洰瀹氭椂瀹炰綋
+            PlayerSchedule playerSchedule = JSON.parseObject(pushToLed.getSchedule(), PlayerSchedule.class);
+            //鍒犻櫎鏃堕棿鐨勫悗涓変綅
+            List<PlayerSchedulePlans> plans = playerSchedule.getPlans();
+            plans.forEach(
+                    plan -> {
+                        plan.setStartTime(plan.getStartTime().substring(0, plan.getStartTime().length() - 3));
+                        plan.setEndTime(plan.getEndTime().substring(0, plan.getEndTime().length() - 3));
+                    }
+            );
+            program.setSchedule(playerSchedule);
+
+
+            program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
+            LogUtils.error("鑺傜洰鍐呭+++++++++++" + JSON.toJSONString(program));
+            VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.normalProgram(program);
+            vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(pushToLed.getVolume()).intValue());
+
+
+            if (vnnoxResultResponse.getData() != null) {
+                success = vnnoxResultResponse.getData().getSuccess();
+                fail = vnnoxResultResponse.getData().getFail();
             }
-        });
+
+            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);
@@ -288,40 +295,41 @@
             throw new BusinessException("鏈壘鍒拌妭鐩�");
         }
         List<SchedulesDTO> schedulesDTOS = JSON.parseArray(one.getSchedules(), SchedulesDTO.class);
-        ProgramSchedule programSchedule = new ProgramSchedule();
-        programSchedule.setSchedules(schedulesDTOS);
-        List<String> playerIds = new ArrayList<>();
-        nova.forEach(
-                n -> {
-                    playerIds.add(n.getPlayerId());
-                }
-        );
-        //璁剧疆
-        programSchedule.setPlayerIds(playerIds);
-        VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.timeProgram(programSchedule);
+
         List<String> success = new ArrayList<>();
         List<String> fail = new ArrayList<>();
-        if (vnnoxResultResponse.getData() != null) {
-            success = vnnoxResultResponse.getData().getSuccess();
-            fail = vnnoxResultResponse.getData().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);
-                    }
-                }
 
-        );
+        List<List<String>> split = CollectionUtil.split(nova.stream().map(NovaPushResultVO::getPlayerId).collect(Collectors.toList()), 100);
+        for (List<String> playerIds : split) {
+            //璁剧疆
+            ProgramSchedule programSchedule = new ProgramSchedule();
+            programSchedule.setSchedules(schedulesDTOS);
+            programSchedule.setPlayerIds(playerIds);
+            VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.timeProgram(programSchedule);
+
+
+            if (vnnoxResultResponse.getData() != null) {
+                success = vnnoxResultResponse.getData().getSuccess();
+                fail = vnnoxResultResponse.getData().getFail();
+            }
+            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);
@@ -426,61 +434,65 @@
             throw new BusinessException("璇蜂笉瑕佹搷浣滃叾浠栦汉鐨勮妭鐩�");
         }
         String pages = ledProgram.getPages();
-        List<String> playerIds = new ArrayList<>();
-        nova.forEach(n -> {
-            playerIds.add(n.getPlayerId());
-        });
 
-        PlayerProgram program = new PlayerProgram();
-        List<PlayerPage> programDtos = JSON.parseArray(pages, PlayerPage.class);
-        programDtos.forEach(
-                programDto -> {
-                    programDto.getWidgets().forEach(
-                            widget -> {
-                                if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
-                                    String url = widget.getUrl();
-                                    LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
-                                    if (one == null) {
-                                        throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
-                                    }
-                                    widget.setMd5(one.getMd5());
-                                    widget.setSize(Long.parseLong(one.getSize()));
-                                }
-                            }
-                    );
-                }
-        );
-        program.setPlayerIds(playerIds);
-        //鑾峰彇鑺傜洰瀹炰綋
-        program.setPages(programDtos);
-
-        program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
-        VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.pushProgram(program);
-
-        if (vnnoxResultResponse == null || vnnoxResultResponse.getData() == null) {
-            throw new BusinessException("鎺ㄩ�佸け璐�");
-        }
 
         List<String> success = new ArrayList<>();
         List<String> fail = new ArrayList<>();
-        if (vnnoxResultResponse.getData() != null) {
-            success = vnnoxResultResponse.getData().getSuccess();
-            fail = vnnoxResultResponse.getData().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);
+
+
+        List<List<String>> split = CollectionUtil.split(nova.stream().map(NovaPushResultVO::getPlayerId).collect(Collectors.toList()), 100);
+
+        for (List<String> playerIds : split) {
+            PlayerProgram program = new PlayerProgram();
+            List<PlayerPage> programDtos = JSON.parseArray(pages, PlayerPage.class);
+            programDtos.forEach(
+                    programDto -> {
+                        programDto.getWidgets().forEach(
+                                widget -> {
+                                    if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
+                                        String url = widget.getUrl();
+                                        LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
+                                        if (one == null) {
+                                            throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
+                                        }
+                                        widget.setMd5(one.getMd5());
+                                        widget.setSize(Long.parseLong(one.getSize()));
+                                    }
+                                }
+                        );
+                    }
+            );
+            program.setPlayerIds(playerIds);
+            //鑾峰彇鑺傜洰瀹炰綋
+            program.setPages(programDtos);
+
+            program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
+            VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.pushProgram(program);
+
+            if (vnnoxResultResponse == null || vnnoxResultResponse.getData() == null) {
+                throw new BusinessException("鎺ㄩ�佸け璐�");
             }
-        });
+
+
+            if (vnnoxResultResponse.getData() != null) {
+                success = vnnoxResultResponse.getData().getSuccess();
+                fail = vnnoxResultResponse.getData().getFail();
+            }
+
+            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);

--
Gitblit v1.9.3