From b67bd85fbe51486dcacf5a5e3b308e4a0f3e2e43 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期日, 24 四月 2022 18:35:42 +0800
Subject: [PATCH] bug修复
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java | 164 ++++++++++++++++++++++--------------------------------
1 files changed, 68 insertions(+), 96 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 9005768..7aab8c1 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,9 +1,7 @@
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;
@@ -15,14 +13,14 @@
import com.sandu.ximon.admin.param.SetBrightnessParam;
import com.sandu.ximon.admin.param.SetScreenOpenParam;
import com.sandu.ximon.admin.param.SetVolumeParam;
+import com.sandu.ximon.admin.security.PermissionConfig;
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.*;
@@ -45,6 +43,7 @@
private final LedScheduleService scheduleService;
private final PoleBindingService bindingService;
private final PoleService poleService;
+ private PermissionConfig permissionConfig;
// private final ListPageUtil listPageUtil;
/**
@@ -109,31 +108,13 @@
*/
@GetMapping("/list")
public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+ 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));
}
@@ -150,6 +131,13 @@
return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
}
+ //鎵ц涓殑鑺傜洰
+ @GetMapping("/getProgram/{lightemitId}")
+ public ResponseVO<Object> getProgram(@PathVariable Long lightemitId) {
+ return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId));
+ }
+
+
/**
* LED灞忓箷鏂板
*
@@ -163,7 +151,11 @@
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);
@@ -210,74 +202,34 @@
@GetMapping("/listLed")
public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "isOnLine", required = false) boolean isOnLine) {
- 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());
+ if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
}
- wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class);
- if (StrUtil.isNotBlank(keyword)) {
- wrapper.like(PoleLightemitEntity::getLightemitName, keyword).or(
- lambdaQueryWrapper -> {
- lambdaQueryWrapper.like(PoleLightemitEntity::getLightemitControlCode, keyword);
- }
- );
+ 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();
+ commonPage.setTotal((long) size);
+ commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
+ if (size % baseConditionVO.getPageSize() == 0) {
+ commonPage.setTotalPage(size / baseConditionVO.getPageSize());
}
- 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));
+ return ResponseUtil.success(commonPage);
+ }
+
+ /**
+ * @param
+ * @return
+ */
+ @GetMapping("/getbycode")
+ public ResponseVO<Object> getLedByLightControlCode(String lightemitControlCode) {
+ return ResponseUtil.success(poleLightemitService.getLedByLightControlCode(lightemitControlCode));
}
/*
@@ -350,7 +302,7 @@
/*
- 璁剧疆闊抽噺
+ 璁剧疆浜害
*/
@PostMapping("/setBrightness")
public ResponseVO<Object> setBrightness(@RequestBody SetBrightnessParam setBrightnessParam) {
@@ -418,6 +370,9 @@
@GetMapping("/listSchedule")
public ResponseVO<Object> listSchedule(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+ if (!permissionConfig.check(MenuEnum.PLAYPLAN_LIST.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
return ResponseUtil.success(scheduleService.listSchedule(baseConditionVO, keyword));
}
@@ -436,5 +391,22 @@
return ResponseUtil.success("璁剧疆鎴愬姛");
}
+ /**
+ * 鑾峰彇鎵ц涓殑瀹氭椂
+ * @param
+ * @return
+ */
+ @GetMapping("/getPushSchedule")
+ public ResponseVO<Object> getPushSchedule(@RequestBody List<Long> ids) {
+ 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);
+ }
}
--
Gitblit v1.9.3