From 3be7f43f9d7c1e0691407b1a3470186369b87bd9 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 13 五月 2022 10:37:17 +0800
Subject: [PATCH] 单灯数据直接下载

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java |  130 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 118 insertions(+), 12 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 7aab8c1..42043ca 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
@@ -7,7 +7,9 @@
 import com.sandu.common.domain.ResponseVO;
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.object.BaseConditionVO;
+import com.sandu.common.security.annotation.AnonymousAccess;
 import com.sandu.common.util.ResponseUtil;
+import com.sandu.common.util.SpringContextHolder;
 import com.sandu.ximon.admin.entity.ProgramPro;
 import com.sandu.ximon.admin.param.LEDScheduleParam_xixun;
 import com.sandu.ximon.admin.param.SetBrightnessParam;
@@ -54,6 +56,9 @@
      */
     @PostMapping("/addProgram")
     public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_ADD.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(xiXunPlayerService.insert(programPro));
     }
 
@@ -61,8 +66,10 @@
      * 淇敼
      */
     @PostMapping("/updateProgram")
-    // @RequiresPermissions("pole:polexixunplayer:update")
     public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_UPDATE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId());
         if (byId == null) {
             throw new BusinessException("鏈�夋嫨LED灞�");
@@ -85,6 +92,9 @@
      */
     @PostMapping("/deleteProgram/{pid}")
     public ResponseVO<Object> deleteProgram(@PathVariable Long pid) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DELETE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
     }
 
@@ -96,6 +106,9 @@
      */
     @GetMapping("/getByPid/{pid}")
     public ResponseVO<Object> getByPid(@PathVariable Long pid) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DETAIL.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(xiXunPlayerService.getByPid(pid));
     }
 
@@ -127,6 +140,9 @@
      */
     @PostMapping("/pushToXixun/{pid}")
     public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PUSH.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
         return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
     }
@@ -134,6 +150,9 @@
     //鎵ц涓殑鑺傜洰
     @GetMapping("/getProgram/{lightemitId}")
     public ResponseVO<Object> getProgram(@PathVariable Long lightemitId) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PLAYING.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId));
     }
 
@@ -146,6 +165,9 @@
      */
     @PostMapping("/saveLed")
     public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_LED_ADD.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         int count = poleLightemitService.count(new QueryWrapper<PoleLightemitEntity>().eq("lightemit_control_code", poleLightemit.getLightemitControlCode()));
         if (count != 0) {
             throw new BusinessException("LED鎺у埗鍗$紪鍙蜂笉鑳介噸澶�");
@@ -172,6 +194,9 @@
      */
     @PostMapping("/updateLed/{ledId}")
     public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId, @RequestBody PoleLightemitEntity poleLightemit) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_LED_UPDATE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         poleLightemitService.updatePoleLightemit(ledId, poleLightemit);
         return ResponseUtil.success("淇敼鎴愬姛");
     }
@@ -184,6 +209,9 @@
      */
     @PostMapping("/deleteLed")
     public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_LED_DELETE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         boolean b = poleLightemitService.deletePoleLightemit(ledIds);
         if (b) {
             return ResponseUtil.success("鍒犻櫎鎴愬姛");
@@ -206,12 +234,10 @@
             return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
         }
         List<PoleLightemitEntity> poleLightemitEntityList = poleLightemitService.listLed(keyword, isOnLine);
-        poleLightemitEntityList.forEach(
-                led -> {
-                    led.setStreetlightId(led.getPoleId());
-                    led.setStreetlightName(led.getPoleName());
-                }
-        );
+        poleLightemitEntityList.forEach(led -> {
+            led.setStreetlightId(led.getPoleId());
+            led.setStreetlightName(led.getPoleName());
+        });
 
         CommonPage commonPage = CommonPage.restPage(poleLightemitEntityList);
         int size = poleLightemitEntityList.size();
@@ -236,8 +262,12 @@
     璁剧疆灞忓箷寮�鍏�
      */
 
+    @AnonymousAccess
     @PostMapping("/setScreenOpen")
     public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_ON_OFF.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         if (setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null) {
             throw new BusinessException("鏈�夋嫨LED灞�");
         }
@@ -271,6 +301,9 @@
    */
     @GetMapping("/getPicture/{id}")
     public ResponseVO<Object> getPicture(@PathVariable Long id) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_SCREENSHOT.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         if (id == null) {
             throw new BusinessException("鏈�夋嫨LED灞�");
         }
@@ -288,6 +321,9 @@
    */
     @PostMapping("/getVolume/{id}")
     public ResponseVO<Object> getVolume(@PathVariable Long id) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_VOL_CHANGE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         if (id == null) {
             throw new BusinessException("鏈�夋嫨LED灞�");
         }
@@ -301,12 +337,27 @@
     }
 
 
+    /**
+     * 娴嬭瘯
+     *
+     * @param
+     * @return
+     */
+    @AnonymousAccess
+    @PostMapping("/test/{str}")
+    public ResponseVO<Object> setBrightness(@PathVariable String str) {
+        return ResponseUtil.success(lightemitUtils.getIsScreenOpen(str));
+    }
+
+
     /*
     璁剧疆浜害
    */
     @PostMapping("/setBrightness")
     public ResponseVO<Object> setBrightness(@RequestBody SetBrightnessParam setBrightnessParam) {
-
+        if (!permissionConfig.check(MenuEnum.XIXUN_BRIGHTNESS_CHANGE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         if (setBrightnessParam == null || setBrightnessParam.getIds() == null || setBrightnessParam.getBrightness() > 255) {
             throw new BusinessException("鍙傛暟閿欒涓虹┖鎴栦寒搴︿笉鑳借秴杩�255");
         }
@@ -329,7 +380,9 @@
   */
     @PostMapping("/setVolume")
     public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
-
+        if (!permissionConfig.check(MenuEnum.XIXUN_VOL_CHANGE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
             throw new BusinessException("闊抽噺鑼冨洿涓�0---15");
         }
@@ -349,21 +402,33 @@
 
     @PostMapping("/addSchedule")
     public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_ADD.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(scheduleService.insert(ledEntity));
     }
 
     @PostMapping("/updateSchedule")
     public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_UPDATE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
     }
 
     @PostMapping("/deleteSchedule")
     public ResponseVO<Object> deleteSchedule(@RequestBody List<Integer> ids) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_DELETE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(scheduleService.removeByIds(ids));
     }
 
     @GetMapping("/getSchedule/{id}")
     public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_DETAIL.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         return ResponseUtil.success(scheduleService.getSchedule(id));
     }
 
@@ -387,26 +452,67 @@
      */
     @PostMapping("/pushSchedule/{id}")
     public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
         scheduleService.ledschedulepush(id, lightemitIds);
         return ResponseUtil.success("璁剧疆鎴愬姛");
     }
 
     /**
      * 鑾峰彇鎵ц涓殑瀹氭椂
+     *
      * @param
      * @return
      */
 
-    @GetMapping("/getPushSchedule")
+    @PostMapping("/getPushSchedule")
     public ResponseVO<Object> getPushSchedule(@RequestBody List<Long> ids) {
-        if(ids.isEmpty()){
+        if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_SCHEDULE.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
+        if (ids.isEmpty()) {
             throw new BusinessException("鏈�夋嫨LED灞�");
         }
         List<LedScheduleVO> list = new ArrayList<>();
-        for(Long id : ids) {
+        for (Long id : ids) {
             LedScheduleVO ledScheduleVO = scheduleService.getledschedules(id);
             list.add(ledScheduleVO);
         }
         return ResponseUtil.success(list);
     }
+
+
+    /**
+     * 鍏抽棴澶╂皵鎺ㄩ��
+     */
+    @GetMapping("/closeWeatherPush/{id}")
+    public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_CLOSE_AIR.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
+        if (id == null) {
+            throw new BusinessException("鏈�夋嫨LED灞�");
+        }
+        SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(id);
+        return ResponseUtil.success("鍏抽棴鎴愬姛");
+    }
+
+    /**
+     * 娓呭睆鎿嶄綔
+     */
+    @PostMapping("/clearScreen")
+    public ResponseVO<Object> clearScreen(@RequestBody List<Long> ids) {
+        if (!permissionConfig.check(MenuEnum.XIXUN_CLEAN.getCode())) {
+            return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+        }
+        List<PoleLightemitEntity> list = poleLightemitService.listByIds(ids);
+        if (ids.isEmpty() && list.isEmpty()) {
+            throw new BusinessException("鏈�夋嫨LED灞�");
+        }
+        for (PoleLightemitEntity playerId : list) {
+            lightemitUtils.clear(playerId.getLightemitControlCode());
+        }
+        return ResponseUtil.success("娓呭睆鎴愬姛");
+    }
 }

--
Gitblit v1.9.3