| | |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.common.file.impl.AliOssFileServiceImpl; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | |
| | | import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | private final LedScheduleService scheduleService; |
| | | |
| | | private PermissionConfig permissionConfig; |
| | | // private final ListPageUtil listPageUtil; |
| | | |
| | | |
| | | private final AliOssFileServiceImpl aliOssFileService; |
| | | private final FileOperationRecordService fileOperationRecordService; |
| | | |
| | | /** |
| | | * 新增节目 |
| | |
| | | /** |
| | | * 删除节目 |
| | | * |
| | | * @param pid |
| | | * @param |
| | | * @return |
| | | */ |
| | | @PostMapping("/deleteProgram/{pid}") |
| | | public ResponseVO<Object> deleteProgram(@PathVariable Long pid) { |
| | | @PostMapping("/deleteProgram") |
| | | public ResponseVO<Object> deleteProgram(@RequestBody List<Long> pids) { |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid)); |
| | | return ResponseUtil.success(xiXunPlayerService.deleteProgram(pids)); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PLAYING.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(xiXunPlayerService.getByPid(lightemitId)); |
| | | return ResponseUtil.success(poleLightemitService.getProgram(lightemitId)); |
| | | } |
| | | |
| | | |
| | |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | scheduleService.ledschedulepush(id, lightemitIds); |
| | | return ResponseUtil.success("设置成功"); |
| | | return ResponseUtil.success(scheduleService.ledschedulepush(id, lightemitIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清空定时 |
| | | * |
| | | * @param |
| | | * @param lightemitIds |
| | | * @return |
| | | */ |
| | | @PostMapping("/deletePushSchedule") |
| | | public ResponseVO<Object> deletePushSchedule(@RequestBody Long[] lightemitIds) { |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_PLAN_PUSH_SCHEDULE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | |
| | | return ResponseUtil.success(scheduleService.deleteSchedulePush(lightemitIds)); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 关闭天气推送 |
| | | */ |
| | | @GetMapping("/closeWeatherPush/{id}") |
| | | public ResponseVO<Object> closeWeatherPush(@PathVariable Long id) { |
| | | @GetMapping("/closeWeatherPush/{poleId}") |
| | | public ResponseVO<Object> closeWeatherPush(@PathVariable Long poleId) { |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_CLOSE_AIR.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | if (id == null) { |
| | | throw new BusinessException("未选择LED屏"); |
| | | if (poleId == null) { |
| | | throw new BusinessException("灯杆id不能为空!"); |
| | | } |
| | | SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(id); |
| | | SpringContextHolder.getBean(PoleService.class).closeXiXunAirPush(poleId); |
| | | return ResponseUtil.success("关闭成功"); |
| | | } |
| | | |
| | |
| | | throw new BusinessException("未选择LED屏"); |
| | | } |
| | | for (PoleLightemitEntity playerId : list) { |
| | | //清屏 |
| | | String clear = lightemitUtils.clear(playerId.getLightemitControlCode()); |
| | | //清除播放列表 |
| | | lightemitUtils.clearVideoPlay(playerId.getLightemitControlCode()); |
| | | //清除节目列表 |
| | | lightemitUtils.clearPlayerTask(playerId.getLightemitControlCode()); |
| | | } |
| | | |
| | |
| | | */ |
| | | return ResponseUtil.success("清屏成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 熙汛直接上传视频到播放器播放 |
| | | */ |
| | | @PostMapping("/pushVideo") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseVO<Object> video(@RequestParam("file") MultipartFile file, |
| | | @RequestParam("lightemitId") List<Long> lightemitIds, |
| | | @RequestParam("type") Integer type) { |
| | | if (!permissionConfig.check(MenuEnum.XIXUN_PROGRAM_PUSH.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | if (file == null || lightemitIds.isEmpty()) { |
| | | throw new BusinessException("未选择LED屏或文件"); |
| | | } |
| | | |
| | | FileUploadDto fileUploadDto = aliOssFileService.uploadFile(file); |
| | | if (type == null && (type > 2 || type < 1)) { |
| | | throw new BusinessException("请选择正确的播放类型"); |
| | | } |
| | | |
| | | if (type == 1 && !"mp4".equals(fileUploadDto.getFileType())) { |
| | | throw new BusinessException("请不要在播放视频时选择非mp4文件"); |
| | | } else if (type == 2 && (!"jpg".equals(fileUploadDto.getFileType()) && !"gif".equals(fileUploadDto.getFileType()) && !"png".equals(fileUploadDto.getFileType()))) { |
| | | throw new BusinessException("请不要在播放图片时时选择非jpg/gif/png文件"); |
| | | } |
| | | |
| | | |
| | | //获取所有led数据 |
| | | List<PoleLightemitEntity> poleLightemitControllers = poleLightemitService.listByIds(lightemitIds); |
| | | |
| | | int num = 0; |
| | | if (!poleLightemitControllers.isEmpty()) { |
| | | |
| | | Iterator iterator = poleLightemitControllers.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next(); |
| | | //上传视频 |
| | | String s = poleLightemitService.videoUpload(poleLightemitEntity.getLightemitControlCode(), fileUploadDto, type); |
| | | if ("推送失败".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } else { |
| | | throw new BusinessException("未正确选择LED屏"); |
| | | } |
| | | |
| | | /** |
| | | * 熙汛上传文件播放 日志记录开始 |
| | | */ |
| | | //获取listCode |
| | | List<String> listCode = new ArrayList<>(); |
| | | List<String> msg = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntity : poleLightemitControllers) { |
| | | listCode.add(poleLightemitEntity.getLightemitControlCode()); |
| | | msg.add("[屏幕名称" + poleLightemitEntity.getLightemitName() + "设备编码" + poleLightemitEntity.getLightemitControlCode() + "],"); |
| | | } |
| | | String content = JSON.toJSONString(msg); |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "熙汛文件推送", content); |
| | | /** |
| | | * 熙汛上传文件播放 日志记录结束 |
| | | */ |
| | | |
| | | if (num != 0 && num != lightemitIds.size()) { |
| | | //存在失败但是不完全失败 |
| | | return ResponseUtil.success("部分文件播放成功"); |
| | | } else if (num == lightemitIds.size()) { |
| | | //全部失败 |
| | | return ResponseUtil.fail("文件播放失败"); |
| | | } else { |
| | | return ResponseUtil.success("文件播放成功"); |
| | | } |
| | | } |
| | | } |