| | |
| | | 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; |
| | | |
| | | /** |
| | | * 新增节目 |
| | |
| | | */ |
| | | 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("文件播放成功"); |
| | | } |
| | | } |
| | | } |