From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java |  129 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 115 insertions(+), 14 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
index d1e011d..d6e85e1 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
@@ -6,6 +6,8 @@
 import com.sandu.common.domain.CommonPage;
 import com.sandu.common.domain.ResponseVO;
 import com.sandu.common.execption.BusinessException;
+import com.sandu.common.file.FileUploadDto;
+import com.sandu.common.file.impl.AliOssFileServiceImpl;
 import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.util.ResponseUtil;
 import com.sandu.common.util.SpringContextHolder;
@@ -25,7 +27,9 @@
 import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
 import com.sandu.ximon.dao.enums.MenuEnum;
 import lombok.AllArgsConstructor;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.*;
 
@@ -46,7 +50,10 @@
     private final LedScheduleService scheduleService;
 
     private PermissionConfig permissionConfig;
-    // private final ListPageUtil listPageUtil;
+
+
+    private final AliOssFileServiceImpl aliOssFileService;
+    private final FileOperationRecordService fileOperationRecordService;
 
     /**
      * 鏂板鑺傜洰
@@ -89,15 +96,15 @@
     /**
      * 鍒犻櫎鑺傜洰
      *
-     * @param pid
+     * @param
      * @return
      */
-    @PostMapping("/deleteProgram/{pid}")
-    public ResponseVO<Object> deleteProgram(@PathVariable Long pid) {
+    @PostMapping("/deleteProgram")
+    public ResponseVO<Object> deleteProgram(@RequestBody List<Long> pids) {
         if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DELETE.getCode())) {
             return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
         }
-        return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
+        return ResponseUtil.success(xiXunPlayerService.deleteProgram(pids));
     }
 
     /**
@@ -156,7 +163,7 @@
         if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PLAYING.getCode())) {
             return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
         }
-        return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId));
+        return ResponseUtil.success(poleLightemitService.getProgram(lightemitId));
     }
 
 
@@ -450,8 +457,23 @@
         if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) {
             return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
         }
-        scheduleService.ledschedulepush(id, lightemitIds);
-        return ResponseUtil.success("璁剧疆鎴愬姛");
+        return ResponseUtil.success(scheduleService.ledschedulepush(id, lightemitIds));
+    }
+
+    /**
+     * 娓呯┖瀹氭椂
+     *
+     * @param
+     * @param lightemitIds
+     * @return
+     */
+    @PostMapping("/deletePushSchedule")
+    public ResponseVO<Object> deletePushSchedule(@RequestBody Long[] lightemitIds) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
+
+        return ResponseUtil.success(scheduleService.deleteSchedulePush(lightemitIds));
     }
 
     /**
@@ -481,15 +503,15 @@
     /**
      * 鍏抽棴澶╂皵鎺ㄩ��
      */
-    @GetMapping("/closeWeatherPush/{id}")
-    public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) {
+    @GetMapping("/closeWeatherPush/{poleId}")
+    public ResponseVO<Object> closeWeatherPush(@PathVariable Long poleId) {
         if (!permissionConfig.check(MenuEnum.XIXUN_CLOSE_AIR.getCode())) {
             return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
         }
-        if (id == null) {
-            throw new BusinessException("鏈�夋嫨LED灞�");
+        if (poleId == null) {
+            throw new BusinessException("鐏潌id涓嶈兘涓虹┖!");
         }
-        SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(id);
+        SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(poleId);
         return ResponseUtil.success("鍏抽棴鎴愬姛");
     }
 
@@ -506,7 +528,12 @@
             throw new BusinessException("鏈�夋嫨LED灞�");
         }
         for (PoleLightemitEntity playerId : list) {
-            lightemitUtils.clear(playerId.getLightemitControlCode());
+            //娓呭睆
+            String clear = lightemitUtils.clear(playerId.getLightemitControlCode());
+            //娓呴櫎鎾斁鍒楄〃
+            lightemitUtils.clearVideoPlay(playerId.getLightemitControlCode());
+            //娓呴櫎鑺傜洰鍒楄〃
+            lightemitUtils.clearPlayerTask(playerId.getLightemitControlCode());
         }
 
         /**
@@ -526,4 +553,78 @@
          */
         return ResponseUtil.success("娓呭睆鎴愬姛");
     }
+
+
+    /**
+     * 鐔欐睕鐩存帴涓婁紶瑙嗛鍒版挱鏀惧櫒鎾斁
+     */
+    @PostMapping("/pushVideo")
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseVO<Object> video(@RequestParam("file") MultipartFile file,
+                                    @RequestParam("lightemitId") List<Long> lightemitIds,
+                                    @RequestParam("type") Integer type) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PUSH.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
+        if (file == null || lightemitIds.isEmpty()) {
+            throw new BusinessException("鏈�夋嫨LED灞忔垨鏂囦欢");
+        }
+
+        FileUploadDto fileUploadDto = aliOssFileService.uploadFile(file);
+        if (type == null && (type > 2 || type < 1)) {
+            throw new BusinessException("璇烽�夋嫨姝g‘鐨勬挱鏀剧被鍨�");
+        }
+
+        if (type == 1 && !"mp4".equals(fileUploadDto.getFileType())) {
+            throw new BusinessException("璇蜂笉瑕佸湪鎾斁瑙嗛鏃堕�夋嫨闈瀖p4鏂囦欢");
+        } else if (type == 2 && (!"jpg".equals(fileUploadDto.getFileType()) && !"gif".equals(fileUploadDto.getFileType()) && !"png".equals(fileUploadDto.getFileType()))) {
+            throw new BusinessException("璇蜂笉瑕佸湪鎾斁鍥剧墖鏃舵椂閫夋嫨闈瀓pg/gif/png鏂囦欢");
+        }
+
+
+        //鑾峰彇鎵�鏈塴ed鏁版嵁
+        List<PoleLightemitEntity> poleLightemitControllers = poleLightemitService.listByIds(lightemitIds);
+
+        int num = 0;
+        if (!poleLightemitControllers.isEmpty()) {
+
+            Iterator iterator = poleLightemitControllers.iterator();
+            while (iterator.hasNext()) {
+                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
+                //涓婁紶瑙嗛
+                String s = poleLightemitService.videoUpload(poleLightemitEntity.getLightemitControlCode(), fileUploadDto, type);
+                if ("鎺ㄩ�佸け璐�".equals(s)) {
+                    num++;
+                }
+            }
+        } else {
+            throw new BusinessException("鏈纭�夋嫨LED灞�");
+        }
+
+        /**
+         * 鐔欐睕涓婁紶鏂囦欢鎾斁 鏃ュ織璁板綍寮�濮�
+         */
+        //鑾峰彇listCode
+        List<String> listCode = new ArrayList<>();
+        List<String> msg = new ArrayList<>();
+        for (PoleLightemitEntity poleLightemitEntity : poleLightemitControllers) {
+            listCode.add(poleLightemitEntity.getLightemitControlCode());
+            msg.add("[灞忓箷鍚嶇О" + poleLightemitEntity.getLightemitName() + "璁惧缂栫爜" + poleLightemitEntity.getLightemitControlCode() + "],");
+        }
+        String content = JSON.toJSONString(msg);
+        StoreOperationRecordsUtils.storeOperationData(listCode, null, "鐔欐睕鏂囦欢鎺ㄩ��", content);
+        /**
+         * 鐔欐睕涓婁紶鏂囦欢鎾斁 鏃ュ織璁板綍缁撴潫
+         */
+
+        if (num != 0 && num != lightemitIds.size()) {
+            //瀛樺湪澶辫触浣嗘槸涓嶅畬鍏ㄥけ璐�
+            return ResponseUtil.success("閮ㄥ垎鏂囦欢鎾斁鎴愬姛");
+        } else if (num == lightemitIds.size()) {
+            //鍏ㄩ儴澶辫触
+            return ResponseUtil.fail("鏂囦欢鎾斁澶辫触");
+        } else {
+            return ResponseUtil.success("鏂囦欢鎾斁鎴愬姛");
+        }
+    }
 }

--
Gitblit v1.9.3