| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | |
| | | * 修改 |
| | | */ |
| | | @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屏"); |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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屏幕新增 |
| | |
| | | */ |
| | | @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); |
| | | |
| | |
| | | */ |
| | | @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("修改成功"); |
| | | } |
| | |
| | | */ |
| | | @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("删除成功"); |
| | |
| | | @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(); |
| | |
| | | 设置屏幕开关 |
| | | */ |
| | | |
| | | @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屏"); |
| | | } |
| | |
| | | */ |
| | | @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屏"); |
| | | } |
| | |
| | | */ |
| | | @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屏"); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 测试 |
| | | * |
| | | * @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"); |
| | | } |
| | |
| | | */ |
| | | @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"); |
| | | } |
| | |
| | | |
| | | @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)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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()); |
| | | } |
| | | return ResponseUtil.success("清屏成功"); |
| | | } |
| | | } |