| | |
| | | import com.sandu.common.util.ResponseUtil; |
| | | 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.*; |
| | | 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.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.*; |
| | | |
| | |
| | | private final LightemitUtils lightemitUtils; |
| | | private final LedScheduleService scheduleService; |
| | | private final PoleBindingService bindingService; |
| | | private final PoleService poleService; |
| | | private PermissionConfig permissionConfig; |
| | | // private final ListPageUtil listPageUtil; |
| | | |
| | | /** |
| | |
| | | public ResponseVO<Object> update(@RequestBody ProgramPro programPro) { |
| | | PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId()); |
| | | if (byId == null) { |
| | | throw new BusinessException("参数错误"); |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | // QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>(); |
| | | // queryWrapper.eq("program_code", programPro.get_id()); |
| | |
| | | */ |
| | | @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("缺少对应用户权限"); |
| | | } |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | |
| | | LambdaQueryWrapper<PoleXixunPlayerEntity> wrapper = Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).like(PoleXixunPlayerEntity::getProgramName, keyword); |
| | |
| | | * @param lightemitIds |
| | | * @return |
| | | */ |
| | | @GetMapping("/pushToXixun/{pid}") |
| | | public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) { |
| | | @PostMapping("/pushToXixun/{pid}") |
| | | public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) { |
| | | xiXunPlayerService.videoXixunPlayer(pid, lightemitIds); |
| | | 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) { |
| | | 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()); |
| | | |
| | | List<PoleLightemitEntity> poleLightemitEntityList = poleLightemitService.listLed(keyword, 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()); |
| | | } |
| | | 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()); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | 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()); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | // return ResponseUtil.success(poleLightemitService.list(wrapper)); |
| | | 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) { |
| | | return ResponseUtil.success(poleLightemitService.getLedByLightControlCode(lightemitControlCode)); |
| | | } |
| | | |
| | | /* |
| | |
| | | |
| | | |
| | | /* |
| | | 设置音量 |
| | | 设置亮度 |
| | | */ |
| | | @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("参数错误"); |
| | | throw new BusinessException("音量范围为0---15"); |
| | | } |
| | | |
| | | Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setVolumeEntity.getIds())); |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |