| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.MinIoConstant; |
| | | import com.sandu.ximon.admin.param.IpVolumeMissionParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.TaskAPIUtils; |
| | |
| | | import com.sandu.ximon.admin.vo.TaskTerminalVO; |
| | | import com.sandu.ximon.admin.vo.TaskVO; |
| | | import com.sandu.ximon.dao.bo.IpVolumeMissionBo; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.domain.BroadcastV2TaskFile; |
| | | import com.sandu.ximon.dao.domain.BroadcastV2TaskTerminal; |
| | | import com.sandu.ximon.dao.domain.IpVolumeFile; |
| | | import com.sandu.ximon.dao.domain.IpVolumeMission; |
| | | import com.sandu.ximon.dao.mapper.IpVolumeMissionMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | |
| | | // 封装播放文件列表 |
| | | List<TaskMediaFileVO> taskMediaFileVOS = new ArrayList<>(); |
| | | List<BroadcastV2TaskFile> taskFileEntityList = new ArrayList<>(); |
| | | int i = 1; |
| | | int i = 6666; |
| | | for (Integer fileId : new HashSet<>(missionparam.getFileIds())) { |
| | | TaskMediaFileVO taskMediaFileVO = new TaskMediaFileVO(); |
| | | BroadcastV2TaskFile taskFileEntity = new BroadcastV2TaskFile(); |
| | |
| | | taskFileEntity.setFileId(fileId); |
| | | |
| | | IpVolumeFile fileEntity = ipVolumeFileService.getById(fileId); |
| | | String absolutePath = MinIoConstant.getAbsolutePath( |
| | | MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(), |
| | | fileEntity.getFileName() |
| | | ); |
| | | // String absolutePath = MinIoConstant.getAbsolutePath( |
| | | // MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(), |
| | | // fileEntity.getFileName() |
| | | // ); |
| | | |
| | | taskMediaFileVO.setI(i); |
| | | i++; |
| | | taskMediaFileVO.setT(0); |
| | | taskMediaFileVO.setN(absolutePath); |
| | | taskMediaFileVO.setN(fileEntity.getFileUrl()); |
| | | taskMediaFileVO.setS(BigInteger.valueOf(fileEntity.getOriginSize())); |
| | | |
| | | taskMediaFileVOS.add(taskMediaFileVO); |
| | |
| | | //return new ArrayList<>(); |
| | | } |
| | | |
| | | public IpVolumeMission getByTaskId(Integer taskId) { |
| | | public TaskVO getByTaskId(Integer taskId) { |
| | | TaskVO task = TaskAPIUtils.getTask(taskId); |
| | | if (task == null) { |
| | | throw new BusinessException("服务器未找到该任务"); |
| | |
| | | |
| | | |
| | | } |
| | | task.setWeeks("0" + Integer.toBinaryString(byId.getWeek())); |
| | | // byId.setWeeks("0" + Integer.toBinaryString(byId.getWeek())); |
| | | |
| | | byId.setWeeks("0" + Integer.toBinaryString(byId.getWeek())); |
| | | |
| | | // IpVolumeMissionBo bo = new IpVolumeMissionBo(); |
| | | List<BroadcastV2TaskFile> taskFiles = broadcastV2TaskFileService.list(Wrappers.lambdaQuery(BroadcastV2TaskFile.class) |
| | | .eq(BroadcastV2TaskFile::getTaskId, taskId)); |
| | | List<BroadcastV2TaskTerminal> taskTerminals = broadcastV2TaskTerminalService.list(Wrappers.lambdaQuery(BroadcastV2TaskTerminal.class) |
| | | .eq(BroadcastV2TaskTerminal::getTaskId, taskId)); |
| | | |
| | | // if(taskFiles.isEmpty()||taskTerminals.isEmpty()){ |
| | | // throw new BusinessException(""); |
| | | // } |
| | | if(!taskFiles.isEmpty()){ |
| | | taskFiles.forEach( |
| | | fileId->{ |
| | | if (!taskFiles.isEmpty()) { |
| | | taskFiles.forEach( |
| | | fileId -> { |
| | | // IpVolumeFile volumeFile = ipVolumeFileService.getById(fileId.getFileId()); |
| | | // if(volumeFile==null){ |
| | | // throw new BusinessException("任务文件不存在"); |
| | | // } |
| | | byId.getFileIds().add(fileId.getFileId()); |
| | | } |
| | | ); |
| | | task.getFileIds().add(fileId.getFileId()); |
| | | // byId.getFileIds().add(fileId.getFileId()); |
| | | } |
| | | ); |
| | | |
| | | } |
| | | if(!taskTerminals.isEmpty()){ |
| | | if (!taskTerminals.isEmpty()) { |
| | | taskTerminals.forEach( |
| | | terminalId->{ |
| | | terminalId -> { |
| | | // BroadcastTerminalV2Entity v2Entity = ipVolumeService.getById(terminalId.getTerminalId()); |
| | | // if(v2Entity==null){ |
| | | // throw new BusinessException("该任务暂无设备使用"); |
| | | // } |
| | | byId.getTerminalIds().add(terminalId.getTerminalId()); |
| | | task.getTerminalIds().add(terminalId.getTerminalId()); |
| | | // byId.getTerminalIds().add(terminalId.getTerminalId()); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | return byId; |
| | | // Map map=new HashMap(); |
| | | // map.put("本地",byId); |
| | | // map.put("服务器",task); |
| | | |
| | | System.out.println(JSON.toJSONString(task)); |
| | | System.out.println(task); |
| | | return task; |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public boolean stopTask(Integer taskId) { |
| | | return TaskAPIUtils.stopTask(taskId); |
| | | } |
| | | } |