From 14ce780fb9977acad2b6dabf9033635b076f590b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期六, 07 五月 2022 14:49:12 +0800
Subject: [PATCH] Changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java | 424 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 394 insertions(+), 30 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 9fab077..ec6b235 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
@@ -2,27 +2,31 @@
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.baomidou.mybatisplus.extension.api.R;
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;
+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.ClientService;
-import com.sandu.ximon.admin.service.PoleLightemitService;
-import com.sandu.ximon.admin.service.XiXunPlayerService;
-import com.sandu.ximon.dao.domain.LedPlayerEntity;
+import com.sandu.ximon.admin.service.*;
+import com.sandu.ximon.admin.utils.LightemitUtils;
+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.*;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* @Author liuhaonan
@@ -37,55 +41,415 @@
private final XiXunPlayerService xiXunPlayerService;
private final ClientService clientService;
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;
+ /**
+ * 鏂板鑺傜洰
+ *
+ * @param programPro
+ * @return
+ */
@PostMapping("/addProgram")
- public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro){
- return ResponseUtil.success(xiXunPlayerService.insert(programPro));
+ public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro) {
+ return ResponseUtil.success(xiXunPlayerService.insert(programPro));
}
+ /**
+ * 淇敼
+ */
+ @PostMapping("/updateProgram")
+ // @RequiresPermissions("pole:polexixunplayer:update")
+ public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
+ 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);
+ }
+ ;
+ return ResponseUtil.success(insert);
+ }
+
+ /**
+ * 鍒犻櫎鑺傜洰
+ *
+ * @param pid
+ * @return
+ */
@PostMapping("/deleteProgram/{pid}")
- public ResponseVO<Object> deleteProgram(@PathVariable Long pid){
+ public ResponseVO<Object> deleteProgram(@PathVariable Long pid) {
return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
}
+ /**
+ * 鑾峰彇鑺傜洰璇︽儏
+ *
+ * @param pid
+ * @return
+ */
@GetMapping("/getByPid/{pid}")
- public ResponseVO<Object> getByPid(@PathVariable Long pid){
+ public ResponseVO<Object> getByPid(@PathVariable Long pid) {
return ResponseUtil.success(xiXunPlayerService.getByPid(pid));
}
+
+ /**
+ * 鑺傜洰鍒楄〃
+ *
+ * @param baseConditionVO
+ * @param keyword
+ * @return
+ */
@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())) {
-// clientService.findClientId()
-// wrapper.eq(PoleXixunPlayerEntity::getCreateUserId,)
- //wrapper.eq(LedPlayerEntity::get)
- return ResponseUtil.success(xiXunPlayerService.list(wrapper)); // todo
- }else {
- return ResponseUtil.success(xiXunPlayerService.list(wrapper));
- }
+ return ResponseUtil.success(xiXunPlayerService.list(wrapper));
}
- @GetMapping("/pushToXixun/{pid}")
- public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds ){
- xiXunPlayerService.videoXixunPlayer(pid,lightemitIds);
+ /**
+ * 鑺傜洰鎺ㄩ��
+ *
+ * @param pid
+ * @param lightemitIds
+ * @return
+ */
+ @PostMapping("/pushToXixun/{pid}")
+ public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
+ xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
}
+ //鎵ц涓殑鑺傜洰
+ @GetMapping("/getProgram/{lightemitId}")
+ public ResponseVO<Object> getProgram(@PathVariable Long lightemitId) {
+ return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId));
+ }
+
+
+ /**
+ * LED灞忓箷鏂板
+ *
+ * @param poleLightemit
+ * @return
+ */
@PostMapping("/saveLed")
- public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit){
+ public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit) {
int count = poleLightemitService.count(new QueryWrapper<PoleLightemitEntity>().eq("lightemit_control_code", poleLightemit.getLightemitControlCode()));
- if(count != 0){
- throw new BusinessException("LED鎺у埗鍗$紪鍙蜂笉鑳介噸澶�");
+ 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);
- return ResponseUtil.success("");
+
+ return ResponseUtil.success("鏂板鎴愬姛");
}
+ /**
+ * LED灞忓箷淇敼
+ *
+ * @param ledId
+ * @param poleLightemit
+ * @return
+ */
+ @PostMapping("/updateLed/{ledId}")
+ public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId, @RequestBody PoleLightemitEntity poleLightemit) {
+ poleLightemitService.updatePoleLightemit(ledId, poleLightemit);
+ return ResponseUtil.success("淇敼鎴愬姛");
+ }
+
+ /**
+ * LED灞忓箷鍒犻櫎
+ *
+ * @param ledIds
+ * @return
+ */
+ @PostMapping("/deleteLed")
+ public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds) {
+ boolean b = poleLightemitService.deletePoleLightemit(ledIds);
+ if (b) {
+ return ResponseUtil.success("鍒犻櫎鎴愬姛");
+ } else {
+ return ResponseUtil.success("鍒犻櫎澶辫触");
+ }
+ }
+
+ /**
+ * LED灞忓箷鍒楄〃
+ *
+ * @param baseConditionVO
+ * @param keyword
+ * @return
+ */
+ @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();
+ commonPage.setTotal((long) size);
+ commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
+ if (size % baseConditionVO.getPageSize() == 0) {
+ commonPage.setTotalPage(size / baseConditionVO.getPageSize());
+ }
+ return ResponseUtil.success(commonPage);
+ }
+
+ /**
+ * @param
+ * @return
+ */
+ @GetMapping("/getbycode")
+ public ResponseVO<Object> getLedByLightControlCode(String lightemitControlCode) {
+ return ResponseUtil.success(poleLightemitService.getLedByLightControlCode(lightemitControlCode));
+ }
+
+ /*
+ 璁剧疆灞忓箷寮�鍏�
+ */
+
+ @PostMapping("/setScreenOpen")
+ public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity) {
+ if (setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null) {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setScreenOpenEntity.getIds()));
+ if (!poleLightemitControllers.isEmpty()) {
+
+ Map<Long, Object> map = new HashMap<>();
+
+ Iterator iterator = poleLightemitControllers.iterator();
+ while (iterator.hasNext()) {
+ PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
+ //缁撴灉鏌ヨ
+ String result = lightemitUtils.setScreenOpen(poleLightemitEntity.getLightemitControlCode(), setScreenOpenEntity.getBool());
+
+ System.out.println("result:---------------------" + result);
+ if (result.isEmpty() || !"true".equals(result)) {
+
+ }
+
+ map.put(poleLightemitEntity.getLightemitId(), result);
+ }
+ return ResponseUtil.success(map);
+ } else {
+ throw new BusinessException("鏈纭�夋嫨LED灞�");
+ }
+ }
+
+
+ /*
+ 鑾峰彇led瀹炴椂鐢婚潰
+ */
+ @GetMapping("/getPicture/{id}")
+ public ResponseVO<Object> getPicture(@PathVariable Long id) {
+ if (id == null) {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id);
+ if (poleLightemitEntity != null) {
+ String result = lightemitUtils.getPicture(poleLightemitEntity.getLightemitControlCode());
+ return ResponseUtil.success(result);
+ } else {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ }
+
+ /*
+ 鑾峰彇闊抽噺
+ */
+ @PostMapping("/getVolume/{id}")
+ public ResponseVO<Object> getVolume(@PathVariable Long id) {
+ if (id == null) {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id);
+ if (poleLightemitEntity != null) {
+ String result = lightemitUtils.getVoiume(poleLightemitEntity.getLightemitControlCode());
+ return ResponseUtil.success(result);
+ } else {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ }
+
+
+ /**
+ * 娴嬭瘯
+ * @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 (setBrightnessParam == null || setBrightnessParam.getIds() == null || setBrightnessParam.getBrightness() > 255) {
+ throw new BusinessException("鍙傛暟閿欒涓虹┖鎴栦寒搴︿笉鑳借秴杩�255");
+ }
+
+ Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setBrightnessParam.getIds()));
+ if (!poleLightemitControllers.isEmpty()) {
+ Iterator iterator = poleLightemitControllers.iterator();
+ while (iterator.hasNext()) {
+ PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
+ poleLightemitService.setBrightness(poleLightemitEntity.getLightemitControlCode(), setBrightnessParam.getBrightness());
+ }
+ return ResponseUtil.success("璁剧疆浜害鎴愬姛");
+ } else {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ }
+
+ /*
+ 璁剧疆闊抽噺
+ */
+ @PostMapping("/setVolume")
+ public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
+
+ if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
+ throw new BusinessException("闊抽噺鑼冨洿涓�0---15");
+ }
+
+ Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setVolumeEntity.getIds()));
+ if (!poleLightemitControllers.isEmpty()) {
+ Iterator iterator = poleLightemitControllers.iterator();
+ while (iterator.hasNext()) {
+ PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
+ poleLightemitService.setVolume(poleLightemitEntity.getLightemitControlCode(), setVolumeEntity.getVolume());
+ }
+ return ResponseUtil.success("璁剧疆闊抽噺鎴愬姛");
+ } else {
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ }
+
+ @PostMapping("/addSchedule")
+ public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
+ return ResponseUtil.success(scheduleService.insert(ledEntity));
+ }
+
+ @PostMapping("/updateSchedule")
+ public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
+ return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
+ }
+
+ @PostMapping("/deleteSchedule")
+ public ResponseVO<Object> deleteSchedule(@RequestBody List<Integer> ids) {
+ return ResponseUtil.success(scheduleService.removeByIds(ids));
+ }
+
+ @GetMapping("/getSchedule/{id}")
+ public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
+ return ResponseUtil.success(scheduleService.getSchedule(id));
+ }
+
+
+ @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));
+ }
+
+
+ /**
+ * 璁剧疆瀹氭椂
+ *
+ * @param id
+ * @param lightemitIds
+ * @return
+ */
+ @PostMapping("/pushSchedule/{id}")
+ public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
+ scheduleService.ledschedulepush(id, lightemitIds);
+ 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);
+ }
+
+
+ /**
+ * 鍏抽棴澶╂皵鎺ㄩ��
+ */
+ @GetMapping("/closeWeatherPush/{id}")
+ public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) {
+ 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) {
+ 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