| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.CommonPage; |
| | |
| | | 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.ListPagingUtils; |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | @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屏"); |
| | | } |
| | | // 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); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | public ResponseVO<Object> list(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq, |
| | | @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()); |
| | | |
| | | return ResponseUtil.success(xiXunPlayerService.list(wrapper)); |
| | | List<PoleXixunPlayerEntity> list = xiXunPlayerService.listProgram(baseConditionVO, order, seq, keyword); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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控制卡编号不能重复"); |
| | |
| | | */ |
| | | @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("删除成功"); |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/listLed") |
| | | public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword, |
| | | public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq, |
| | | @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()); |
| | | } |
| | | ); |
| | | List<PoleLightemitEntity> poleLightemitEntityList = poleLightemitService.listLed(keyword, order, seq, isOnLine); |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | CommonPage commonPage = ListPagingUtils.pages(poleLightemitEntityList, baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | |
| | | return ResponseUtil.success(commonPage); |
| | | } |
| | | |
| | |
| | | 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屏"); |
| | | } |
| | |
| | | */ |
| | | @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屏"); |
| | | } |
| | |
| | | */ |
| | | @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("缺少对应用户权限"); |
| | | } |
| | | /** |
| | | * 熙汛定时删除 日志记录开始 |
| | | */ |
| | | |
| | | String content = "{删除的熙汛定时id:" + 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)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listSchedule") |
| | | public ResponseVO<Object> listSchedule(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | public ResponseVO<Object> listSchedule(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq, |
| | | @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)); |
| | | return ResponseUtil.success(scheduleService.listSchedule(baseConditionVO, order, seq, keyword)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @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 |
| | | */ |
| | | |
| | | @GetMapping("/getPushSchedule") |
| | | @PostMapping("/getPushSchedule") |
| | | public ResponseVO<Object> getPushSchedule(@RequestBody List<Long> ids) { |
| | | if(ids.isEmpty()){ |
| | | 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) { |
| | | for (Long id : ids) { |
| | | LedScheduleVO ledScheduleVO = scheduleService.getledschedules(id); |
| | | list.add(ledScheduleVO); |
| | | } |
| | |
| | | */ |
| | | @GetMapping("/closeWeatherPush/{id}") |
| | | public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) { |
| | | if(id==null){ |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_CLOSE_AIR.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | if (id == null) { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(id); |
| | |
| | | /** |
| | | * 清屏操作 |
| | | */ |
| | | @GetMapping("/clearScreen") |
| | | public ResponseVO<Object> clearScreen(@RequestBody List<String> codes) { |
| | | |
| | | if(codes.isEmpty()){ |
| | | @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(String playerId : codes) { |
| | | lightemitUtils.clear(playerId); |
| | | for (PoleLightemitEntity playerId : list) { |
| | | String clear = lightemitUtils.clear(playerId.getLightemitControlCode()); |
| | | lightemitUtils.clearPlayerTask(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("清屏成功"); |
| | | } |
| | | } |