From 7df7fe34a495f09fec967504d42e152ab17f2235 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 10 五月 2022 18:28:50 +0800
Subject: [PATCH] 一键求助
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java | 260 ++++++++++++++++++++++++++++++---------------------
1 files changed, 151 insertions(+), 109 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 db591c3..397febb 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,15 +1,15 @@
package com.sandu.ximon.admin.controller;
-import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
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;
@@ -19,11 +19,9 @@
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.*;
import com.sandu.ximon.admin.utils.LightemitUtils;
-import com.sandu.ximon.dao.domain.Pole;
-import com.sandu.ximon.dao.domain.PoleBinding;
+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.AdministratorEnums;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -58,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));
}
@@ -65,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灞�");
@@ -89,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));
}
@@ -100,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));
}
@@ -115,31 +124,10 @@
if (!permissionConfig.check(MenuEnum.LED_PROGRAM_LIST.getCode())) {
return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
}
+ LambdaQueryWrapper<PoleXixunPlayerEntity> wrapper = xiXunPlayerService.XixunPlayerList(keyword);
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
- LambdaQueryWrapper<PoleXixunPlayerEntity> wrapper = Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).like(PoleXixunPlayerEntity::getProgramName, keyword);
-// if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())){
-// boolean clientId = clientService.findClientId();
-// if(clientId){
-// wrapper= wrapper.eq(PoleXixunPlayerEntity::getUserId,SecurityUtils.getUserId());
-// }
-// wrapper= wrapper.eq(PoleXixunPlayerEntity::getClientId,clientService.getClientId());
-// }
-// wrapper=Wrappers.lambdaQuery(PoleXixunPlayerEntity.class);
-// if(StrUtil.isNotBlank(keyword)){
-// wrapper.like(PoleXixunPlayerEntity::getLightemitName,keyword).or(
-// lambdaQueryWrapper -> {
-// lambdaQueryWrapper.like(PoleXixunPlayerEntity::getLightemitControlCode, keyword);
-// }
-// );
-// }
-// return ResponseUtil.success(poleLightemitService.list(wrapper));
- if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
-
- return ResponseUtil.success(xiXunPlayerService.list(wrapper)); // todo
- } else {
- return ResponseUtil.success(xiXunPlayerService.list(wrapper));
- }
+ return ResponseUtil.success(xiXunPlayerService.list(wrapper));
}
@@ -152,9 +140,22 @@
*/
@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("鎺ㄩ�佹垚鍔�");
}
+
+ //鎵ц涓殑鑺傜洰
+ @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灞忓箷鏂板
@@ -164,12 +165,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);
@@ -186,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("淇敼鎴愬姛");
}
@@ -198,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("鍒犻櫎鎴愬姛");
@@ -216,8 +230,16 @@
@GetMapping("/listLed")
public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "isOnLine", required = false) boolean isOnLine) {
-
+ if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
List<PoleLightemitEntity> poleLightemitEntityList = poleLightemitService.listLed(keyword, isOnLine);
+ poleLightemitEntityList.forEach(
+ led -> {
+ led.setStreetlightId(led.getPoleId());
+ led.setStreetlightName(led.getPoleName());
+ }
+ );
CommonPage commonPage = CommonPage.restPage(poleLightemitEntityList);
int size = poleLightemitEntityList.size();
@@ -227,89 +249,14 @@
commonPage.setTotalPage(size / baseConditionVO.getPageSize());
}
return ResponseUtil.success(commonPage);
-
-
-// if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) {
-// return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
-// }
-// PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-// LambdaQueryWrapper<PoleLightemitEntity> wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class);
-// if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
-// boolean clientId = clientService.findClientId();
-// if (clientId) {
-// wrapper = wrapper.eq(PoleLightemitEntity::getUserId, SecurityUtils.getUserId());
-// }
-// wrapper = wrapper.eq(PoleLightemitEntity::getClientId, clientService.getClientId());
-// }
-// wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class);
-// if (StrUtil.isNotBlank(keyword)) {
-// wrapper.like(PoleLightemitEntity::getLightemitName, keyword).or(
-// lambdaQueryWrapper -> {
-// lambdaQueryWrapper.like(PoleLightemitEntity::getLightemitControlCode, keyword);
-// }
-// );
-// }
-// List<PoleBinding> bindings = bindingService.list(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceType, 1));
-// List<PoleLightemitEntity> list = poleLightemitService.list(wrapper);
-// if (isOnLine) {
-// List<PoleLightemitEntity> results = poleLightemitService.ledOnline(list);
-// results.forEach(
-// led -> {
-// bindings.forEach(
-// bind -> {
-// if (bind.getDeviceCode() != null && led.getLightemitControlCode() == bind.getDeviceCode()) {
-// led.setStreetlightId(bind.getPoleId());
-// System.out.println("鏈夋病鏈夎繍琛屽埌杩欓噷?---------------" + bind.getPoleId());
-// led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
-// }
-// }
-// );
-// }
-// );
-// CommonPage commonPage = CommonPage.restPage(results);
-// int size = results.size();
-// commonPage.setTotal((long) size);
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
-// if (size % baseConditionVO.getPageSize() == 0) {
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize());
-// }
-// return ResponseUtil.success(commonPage);
-// } else {
-// poleLightemitService.ledOnlineCheck(list);
-// list.forEach(
-// led -> {
-// bindings.forEach(
-// bind -> {
-// if (bind.getDeviceCode() != null && led.getLightemitControlCode().equals(bind.getDeviceCode())) {
-// led.setStreetlightId(bind.getPoleId());
-// System.out.println("鏈夋病鏈夎繍琛屽埌杩欓噷?---------------" + bind.getPoleId());
-// led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
-// }
-// }
-// );
-// }
-// );
-// CommonPage commonPage = CommonPage.restPage(list);
-// int size = list.size();
-// commonPage.setTotal((long) size);
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
-// if (size % baseConditionVO.getPageSize() == 0) {
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize());
-// }
-// return ResponseUtil.success(commonPage);
-// // return ResponseUtil.success(list);
-// }
-//// return ResponseUtil.success(poleLightemitService.list(wrapper));
}
/**
- *
- *
* @param
* @return
*/
@GetMapping("/getbycode")
- public ResponseVO<Object> getLedByLightControlCode(String lightemitControlCode) {
+ public ResponseVO<Object> getLedByLightControlCode(String lightemitControlCode) {
return ResponseUtil.success(poleLightemitService.getLedByLightControlCode(lightemitControlCode));
}
@@ -317,8 +264,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灞�");
}
@@ -352,6 +303,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灞�");
}
@@ -369,6 +323,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灞�");
}
@@ -382,12 +339,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");
}
@@ -410,7 +382,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");
}
@@ -430,21 +404,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));
}
@@ -468,11 +454,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
+ */
+
+ @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("鍏抽棴鎴愬姛");
+ }
+ /**
+ * 娓呭睆鎿嶄綔
+ */
+ @GetMapping("/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