| | |
| | | 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.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.entity.ProgramPro; |
| | | import com.sandu.ximon.admin.param.LEDScheduleParam_xixun; |
| | | import com.sandu.ximon.admin.param.SetScreenOpenParam; |
| | | import com.sandu.ximon.admin.param.SetVolumeParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.service.ClientService; |
| | | import com.sandu.ximon.admin.service.LedScheduleService; |
| | | import com.sandu.ximon.admin.service.PoleLightemitService; |
| | | import com.sandu.ximon.admin.service.XiXunPlayerService; |
| | | import com.sandu.ximon.admin.service.*; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | | 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 lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | |
| | | private final PoleLightemitService poleLightemitService; |
| | | private final LightemitUtils lightemitUtils; |
| | | private final LedScheduleService scheduleService; |
| | | private final PoleBindingService bindingService; |
| | | // 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){ |
| | | // @RequiresPermissions("pole:polexixunplayer:update") |
| | | public ResponseVO<Object> update(@RequestBody ProgramPro programPro) { |
| | | PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId()); |
| | | if(byId==null){ |
| | | throw new BusinessException("参数错误"); |
| | | if (byId == null) { |
| | | throw new BusinessException("参数错误"); |
| | | } |
| | | // 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); |
| | | 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 |
| | |
| | | // ); |
| | | // } |
| | | // return ResponseUtil.success(poleLightemitService.list(wrapper)); |
| | | if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | |
| | | return ResponseUtil.success(xiXunPlayerService.list(wrapper)); // todo |
| | | }else { |
| | | } else { |
| | | return ResponseUtil.success(xiXunPlayerService.list(wrapper)); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 节目推送 |
| | | * |
| | | * @param pid |
| | | * @param lightemitIds |
| | | * @return |
| | | */ |
| | | @GetMapping("/pushToXixun/{pid}") |
| | | public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds ){ |
| | | xiXunPlayerService.videoXixunPlayer(pid,lightemitIds); |
| | | public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) { |
| | | xiXunPlayerService.videoXixunPlayer(pid, lightemitIds); |
| | | return ResponseUtil.success("推送成功"); |
| | | } |
| | | |
| | | /** |
| | | * 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()); |
| | |
| | | |
| | | /** |
| | | * LED屏幕修改 |
| | | * |
| | | * @param ledId |
| | | * @param poleLightemit |
| | | * @return |
| | | */ |
| | | @PostMapping("/updateLed/{ledId}") |
| | | public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId,@RequestBody PoleLightemitEntity poleLightemit){ |
| | | poleLightemitService.updatePoleLightemit(ledId,poleLightemit); |
| | | 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){ |
| | | public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds) { |
| | | boolean b = poleLightemitService.deletePoleLightemit(ledIds); |
| | | if(b){ |
| | | if (b) { |
| | | return ResponseUtil.success("删除成功"); |
| | | }else { |
| | | } 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) { |
| | | 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())){ |
| | | if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | boolean clientId = clientService.findClientId(); |
| | | if(clientId){ |
| | | wrapper= wrapper.eq(PoleLightemitEntity::getUserId,SecurityUtils.getUserId()); |
| | | if (clientId) { |
| | | wrapper = wrapper.eq(PoleLightemitEntity::getUserId, SecurityUtils.getUserId()); |
| | | } |
| | | wrapper= wrapper.eq(PoleLightemitEntity::getClientId,clientService.getClientId()); |
| | | wrapper = wrapper.eq(PoleLightemitEntity::getClientId, clientService.getClientId()); |
| | | } |
| | | wrapper=Wrappers.lambdaQuery(PoleLightemitEntity.class); |
| | | if(StrUtil.isNotBlank(keyword)){ |
| | | wrapper.like(PoleLightemitEntity::getLightemitName,keyword).or( |
| | | wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class); |
| | | if (StrUtil.isNotBlank(keyword)) { |
| | | wrapper.like(PoleLightemitEntity::getLightemitName, keyword).or( |
| | | lambdaQueryWrapper -> { |
| | | lambdaQueryWrapper.like(PoleLightemitEntity::getLightemitControlCode, keyword); |
| | | } |
| | | ); |
| | | } |
| | | return ResponseUtil.success(poleLightemitService.list(wrapper)); |
| | | 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)); |
| | | } |
| | | |
| | | @GetMapping("/onLineLed") |
| | | public ResponseVO<Object> onlineLed() { |
| | | return ResponseUtil.success(poleLightemitService.ledList()); |
| | | /* |
| | | 设置屏幕开关 |
| | | */ |
| | | |
| | | @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屏"); |
| | | public ResponseVO<Object> getPicture(@PathVariable Long id) { |
| | | if (id == null) { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id); |
| | | if(poleLightemitEntity != null){ |
| | | if (poleLightemitEntity != null) { |
| | | String result = lightemitUtils.getPicture(poleLightemitEntity.getLightemitControlCode()); |
| | | return ResponseUtil.success(result); |
| | | }else { |
| | | } else { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | } |
| | |
| | | 获取音量 |
| | | */ |
| | | @PostMapping("/getVolume/{id}") |
| | | public ResponseVO<Object> getVolume(@PathVariable Long id){ |
| | | if(id == null){ |
| | | public ResponseVO<Object> getVolume(@PathVariable Long id) { |
| | | if (id == null) { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id); |
| | | if(poleLightemitEntity != null){ |
| | | if (poleLightemitEntity != null) { |
| | | String result = lightemitUtils.getVoiume(poleLightemitEntity.getLightemitControlCode()); |
| | | return ResponseUtil.success(result); |
| | | }else { |
| | | } else { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | } |
| | |
| | | 设置音量 |
| | | */ |
| | | @PostMapping("/setVolume") |
| | | public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity){ |
| | | public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) { |
| | | |
| | | if(setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15){ |
| | | if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) { |
| | | throw new BusinessException("参数错误"); |
| | | } |
| | | |
| | |
| | | poleLightemitService.setVolume(poleLightemitEntity.getLightemitControlCode(), setVolumeEntity.getVolume()); |
| | | } |
| | | return ResponseUtil.success("设置音量成功"); |
| | | }else { |
| | | } else { |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/addSchedule") |
| | | public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity){ |
| | | public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) { |
| | | return ResponseUtil.success(scheduleService.insert(ledEntity)); |
| | | } |
| | | |
| | | @PostMapping("/updateSchedule") |
| | | public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity){ |
| | | public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) { |
| | | return ResponseUtil.success(scheduleService.updateSchedule(ledEntity)); |
| | | } |
| | | |
| | | @GetMapping("/getSchedule/{id}") |
| | | public ResponseVO<Object> getSchedule(@PathVariable Integer id){ |
| | | public ResponseVO<Object> getSchedule(@PathVariable Integer id) { |
| | | return ResponseUtil.success(scheduleService.getSchedule(id)); |
| | | } |
| | | |
| | | @PostMapping("/pushSchedule/{id}") |
| | | public ResponseVO<Object> pushSchedule(@PathVariable Integer id,@RequestBody Long[] lightemitIds){ |
| | | scheduleService.ledschedulepush(id,lightemitIds); |
| | | public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) { |
| | | scheduleService.ledschedulepush(id, lightemitIds); |
| | | return ResponseUtil.success("设置成功"); |
| | | } |
| | | |