| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.minio.entity.MinIoConstant; |
| | | import com.sandu.ximon.admin.param.IpVolumeMissionParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | |
| | | |
| | | |
| | | public boolean addMission(IpVolumeMissionParam missionparam) { |
| | | |
| | | List<Integer> fileIds = missionparam.getFileIds(); |
| | | List<IpVolumeFile> ipVolumeFiles = ipVolumeFileService.listByIds(fileIds); |
| | | ipVolumeFiles.forEach(file -> { |
| | | if (SecurityUtils.getClientId() != null) { |
| | | //非超管用户 |
| | | if (!SecurityUtils.getUserId().equals(file.getClientId()) && !SecurityUtils.getUserId().equals(file.getUserId())) { |
| | | //用户id和客户id都不匹配 |
| | | throw new BusinessException("文件归属异常,创建任务失败"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | String taskName = missionparam.getMissionName(); |
| | | |
| | |
| | | if (fileEntity == null) { |
| | | throw new BusinessException("fileId为" + fileId + "的文件不存在"); |
| | | } |
| | | if (fileEntity.getUserId() == null && fileEntity.getClientId() != null) { |
| | | fileEntity.setUserId(fileEntity.getClientId()); |
| | | } |
| | | String absolutePath; |
| | | absolutePath = MinIoConstant.getAbsolutePath( |
| | | MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(), |
| | | fileEntity.getFileName() |
| | | ); |
| | | if (fileEntity.getUserId() == null && fileEntity.getClientId() == null) { |
| | | absolutePath = MinIoConstant.getAbsolutePath( |
| | | MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName(), |
| | | 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); |
| | |
| | | taskFileEntity.setFileId(fileId); |
| | | |
| | | IpVolumeFile fileEntity = ipVolumeFileService.getById(fileId); |
| | | String absolutePath; |
| | | absolutePath = MinIoConstant.getAbsolutePath( |
| | | MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(), |
| | | fileEntity.getFileName() |
| | | ); |
| | | if (fileEntity.getUserId() == null && fileEntity.getClientId() == null) { |
| | | absolutePath = MinIoConstant.getAbsolutePath( |
| | | MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName(), |
| | | 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); |
| | |
| | | /** |
| | | * 删除任务 |
| | | * |
| | | * @param taskId |
| | | * @param taskIds |
| | | * @return0:成功 1:任务不处于空闲状态 2:服务器删除失败 |
| | | */ |
| | | public Integer deleteMission(Integer taskId) { |
| | | Integer del = TaskAPIUtils.delTask(taskId); |
| | | if (del == 0) { |
| | | IpVolumeMission byId = getById(taskId); |
| | | if (byId == null) { |
| | | return -1; |
| | | } |
| | | removeById(taskId); |
| | | broadcastV2TaskFileService.deleteByTaskId(taskId); |
| | | broadcastV2TaskTerminalService.deleteByTaskId(taskId); |
| | | public Integer deleteMission(List<Integer> taskIds) { |
| | | //删除失败的集合 |
| | | List<Integer> delIds = new ArrayList<Integer>(); |
| | | if (!taskIds.isEmpty()) { |
| | | taskIds.forEach(taskId -> { |
| | | Integer del = TaskAPIUtils.delTask(taskId); |
| | | if (del == 0) { |
| | | IpVolumeMission byId = getById(taskId); |
| | | if (byId == null) { |
| | | return; |
| | | } |
| | | removeById(taskId); |
| | | broadcastV2TaskFileService.deleteByTaskId(taskId); |
| | | broadcastV2TaskTerminalService.deleteByTaskId(taskId); |
| | | // broadcastV2TaskTerminalService.removeById(taskId); |
| | | } else { |
| | | delIds.add(taskId); |
| | | } |
| | | |
| | | /** |
| | | * IP音柱任务删除 日志记录开始 |
| | | */ |
| | | String content = "{删除的任务ID:" + taskId |
| | | + ",任务删除结果:" + del |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "IP音柱任务删除", content); |
| | | /** |
| | | * IP音柱任务删除 日志记录结束 |
| | | */ |
| | | }); |
| | | } else { |
| | | throw new BusinessException("任务id不能为空"); |
| | | } |
| | | |
| | | /** |
| | | * IP音柱任务删除 日志记录开始 |
| | | */ |
| | | String content = "{删除的任务ID:" + taskId |
| | | + ",任务删除结果:" + del |
| | | + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "IP音柱任务删除", content); |
| | | /** |
| | | * IP音柱任务删除 日志记录结束 |
| | | */ |
| | | |
| | | |
| | | return del; |
| | | if (delIds.isEmpty()) { |
| | | return 0; |
| | | } else { |
| | | throw new BusinessException("部分删除失败,失败的集合为:" + delIds); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | } else { |
| | | if (!byId.getClientId().equals(SecurityUtils.getUserId())&&!byId.getUserId().equals(SecurityUtils.getUserId())) { |
| | | if (!byId.getClientId().equals(SecurityUtils.getUserId()) && !byId.getUserId().equals(SecurityUtils.getUserId())) { |
| | | throw new BusinessException("任务归属错误"); |
| | | } |
| | | } |