From feac6e0c2db4e60d55417fde1971a0bc6d703566 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 27 五月 2022 15:58:28 +0800
Subject: [PATCH] fix
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java | 195 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 171 insertions(+), 24 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 874acf9..d12fb0e 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
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.controller;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
@@ -8,6 +9,7 @@
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
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;
@@ -17,6 +19,8 @@
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.*;
import com.sandu.ximon.admin.utils.LightemitUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
+import com.sandu.ximon.admin.vo.LedScheduleVO;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
import com.sandu.ximon.dao.enums.MenuEnum;
@@ -40,8 +44,7 @@
private final PoleLightemitService poleLightemitService;
private final LightemitUtils lightemitUtils;
private final LedScheduleService scheduleService;
- private final PoleBindingService bindingService;
- private final PoleService poleService;
+
private PermissionConfig permissionConfig;
// private final ListPageUtil listPageUtil;
@@ -53,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));
}
@@ -60,20 +66,24 @@
* 淇敼
*/
@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灞�");
}
-// QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
-// queryWrapper.eq("program_code", programPro.get_id());
- boolean insert = false;
- if (xiXunPlayerService.removeById(programPro.getProgramId())) {
- insert = xiXunPlayerService.insert(programPro);
+
+ boolean update = xiXunPlayerService.update(programPro);
+ if (update) {
+ return ResponseUtil.success("缂栬緫鎴愬姛锛�");
+
+ } else {
+ return ResponseUtil.fail("缂栬緫澶辫触锛�");
+
}
- ;
- return ResponseUtil.success(insert);
+
}
/**
@@ -84,6 +94,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));
}
@@ -95,6 +108,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));
}
@@ -126,9 +142,22 @@
*/
@PostMapping("/pushToXixun/{pid}")
public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
- xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
- return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
+ if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PUSH.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
+
+ return ResponseUtil.success(xiXunPlayerService.videoXixunPlayer(pid, lightemitIds));
}
+
+ //鎵ц涓殑鑺傜洰
+ @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));
+ }
+
/**
* LED灞忓箷鏂板
@@ -138,12 +167,19 @@
*/
@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鎺у埗鍗$紪鍙蜂笉鑳介噸澶�");
}
- poleLightemit.setCreateUserId(SecurityUtils.getClientId());
+ if (SecurityUtils.getClientId() == null) {
+ poleLightemit.setClientId(clientService.getClientId());
+ poleLightemit.setUserId(SecurityUtils.getUserId());
+ poleLightemit.setCreateUserId(SecurityUtils.getUserId());
+ }
poleLightemitService.savePoleLightemit(poleLightemit);
@@ -160,6 +196,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("淇敼鎴愬姛");
}
@@ -172,6 +211,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("鍒犻櫎鎴愬姛");
@@ -194,12 +236,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();
@@ -220,12 +260,14 @@
return ResponseUtil.success(poleLightemitService.getLedByLightControlCode(lightemitControlCode));
}
- /*
- 璁剧疆灞忓箷寮�鍏�
+ /**
+ * 璁剧疆灞忓箷寮�鍏�
*/
-
@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灞�");
}
@@ -259,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灞�");
}
@@ -276,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灞�");
}
@@ -294,7 +342,9 @@
*/
@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");
}
@@ -317,7 +367,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");
}
@@ -337,21 +389,42 @@
@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("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
+ /**
+ * 鐔欐睕瀹氭椂鍒犻櫎 鏃ュ織璁板綍寮�濮�
+ */
+
+ String content = "{鍒犻櫎鐨勭啓姹涘畾鏃秈d锛�" + ids + " }";
+ StoreOperationRecordsUtils.storeOperationData(null, null, "鐔欐睕瀹氭椂浠诲姟鍒犻櫎", content);
+ /**
+ * 鐔欐睕瀹氭椂鍒犻櫎 鏃ュ織璁板綍缁撴潫
+ */
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));
}
@@ -375,9 +448,83 @@
*/
@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
+ */
+ @PostMapping("/getPushSchedule")
+ public ResponseVO<Object> getPushSchedule(@RequestBody List<Long> ids) {
+ 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) {
+ 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());
+ }
+
+ /**
+ * 鐔欐睕娓呭睆 鏃ュ織璁板綍寮�濮�
+ */
+ //鑾峰彇listCode
+ List<String> listCode = new ArrayList<>();
+ List<String> msg = new ArrayList<>();
+ for (PoleLightemitEntity poleLightemitEntity : list) {
+ listCode.add(poleLightemitEntity.getLightemitControlCode());
+ msg.add("[灞忓箷鍚嶇О" + poleLightemitEntity.getLightemitName() + "璁惧缂栫爜" + poleLightemitEntity.getLightemitControlCode() + "],");
+ }
+ String content = JSON.toJSONString(msg);
+ StoreOperationRecordsUtils.storeOperationData(listCode, null, "鐔欐睕娓呭睆", content);
+ /**
+ * 鐔欐睕娓呭睆 鏃ュ織璁板綍缁撴潫
+ */
+ return ResponseUtil.success("娓呭睆鎴愬姛");
+ }
}
--
Gitblit v1.9.3