From 77edfb324184d304ae7763aae3ab609f2b495da4 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 22 七月 2022 17:31:47 +0800
Subject: [PATCH] fix

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java |   37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 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 aa7789b..31ca00f 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
@@ -29,10 +29,7 @@
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 鎾斁璁″垝
@@ -172,7 +169,13 @@
     }
 
     public Map<String, Object> pushToLed(Long planId, List<NovaPushResultVO> nova) {
+        if (nova == null) {
+            throw new BusinessException("璇烽�夋嫨姝g‘鐨凩ED灞�");
+        }
         PushToLed pushToLed = playPlanMapper.pushToLed(planId);
+        if (pushToLed.getPages() == null) {
+            throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+        }
         PlayPlanNv byId = getById(planId);
         if (pushToLed == null) {
             throw new BusinessException("鏈壘鍒拌鎾斁璁″垝");
@@ -186,8 +189,26 @@
         program.setPlayerIds(playerIds);
 
         //鑾峰彇鑺傜洰瀹炰綋
-        program.setPages(JSON.parseObject(pushToLed.getPages(), List.class));
 
+
+        List<ProgramDto> programDtos = JSON.parseArray(pushToLed.getPages(), ProgramDto.class);
+        programDtos.forEach(
+                programDto -> {
+                    programDto.getWidgets().forEach(
+                            widget -> {
+                                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(one.getSize());
+                            }
+                    );
+                }
+        );
+
+        program.setPages(programDtos);
 
         //鑾峰彇鑺傜洰瀹氭椂瀹炰綋
         program.setSchedule((JSON.parseObject(pushToLed.getSchedule(), Map.class)));
@@ -392,6 +413,12 @@
         if (ledProgram == null) {
             throw new BusinessException("鏈壘鍒拌妭鐩�");
         }
+        if (ledProgram.getPages() == null) {
+            throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+        }
+        if (SecurityUtils.getClientId() != null && !Objects.equals(ledProgram.getClientId(), SecurityUtils.getUserId()) && !Objects.equals(ledProgram.getClientId(), SecurityUtils.getClientId())) {
+            throw new BusinessException("璇蜂笉瑕佹搷浣滃叾浠栦汉鐨勮妭鐩�");
+        }
         String pages = ledProgram.getPages();
         List<String> playerIds = new ArrayList<>();
         nova.forEach(n -> {

--
Gitblit v1.9.3