渲染机支持配置存储地址

This commit is contained in:
2025-04-20 15:06:02 +08:00
parent b36da6ff35
commit 3863c0d963
9 changed files with 45 additions and 23 deletions

View File

@ -2,6 +2,7 @@ package com.ycwl.basic.controller.task;
import com.ycwl.basic.annotation.IgnoreLogReq;
import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
import com.ycwl.basic.model.task.req.TaskReqVo;
import com.ycwl.basic.model.task.req.TaskSuccessReqVo;
@ -11,6 +12,7 @@ import com.ycwl.basic.service.task.TaskService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -35,6 +37,11 @@ public class TaskTaskController {
return ApiResponse.success(respVo);
}
@GetMapping("/{taskId}/info")
public ApiResponse<TaskRespVO> taskInfo(@PathVariable Long taskId) {
return ApiResponse.success(taskService.taskInfo(taskId));
}
@PostMapping("/template/{templateId}")
public ApiResponse<TemplateRespVO> getTemplateById(@PathVariable Long templateId, @RequestBody WorkerAuthReqVo req) {
return ApiResponse.success(taskService.workerGetTemplate(templateId, req));
@ -43,7 +50,6 @@ public class TaskTaskController {
@PostMapping("/{taskId}/uploadUrl")
public ApiResponse<String> getUploadUrl(@PathVariable Long taskId, @RequestBody WorkerAuthReqVo req) {
String urlForUpload = taskService.getUploadUrl(taskId, req);
urlForUpload = urlForUpload.replace("-internal.aliyuncs.com", ".aliyuncs.com");
return ApiResponse.success(urlForUpload);
}

View File

@ -33,8 +33,6 @@ public class DeviceRespVO {
private Integer online;
private String coverUrl;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date coverTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createAt;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateAt;

View File

@ -2,6 +2,7 @@ package com.ycwl.basic.model.pc.renderWorker.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ycwl.basic.storage.enums.StorageType;
import lombok.Data;
import java.math.BigDecimal;
@ -77,4 +78,12 @@ public class RenderWorkerEntity {
private Date updateAt;
/**
* 存储类型
*/
private StorageType storeType;
/**
* 存储配置
*/
private String storeConfigJson;
}

View File

@ -1,5 +1,6 @@
package com.ycwl.basic.service.task;
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
import com.ycwl.basic.model.task.req.TaskReqVo;
import com.ycwl.basic.model.task.req.TaskSuccessReqVo;
@ -32,4 +33,6 @@ public interface TaskService {
Date getTaskShotDate(Long taskId);
void sendVideoGeneratedServiceNotification(Long taskId, Long memberId);
TaskRespVO taskInfo(Long taskId);
}

View File

@ -650,18 +650,23 @@ public class TaskTaskServiceImpl implements TaskService {
if (task == null) {
return null;
}
IStorageAdapter adapter = scenicService.getScenicTmpStorageAdapter(task.getScenicId());
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, task.getId() + "_" + task.getScenicId() + ".mp4");
if (StringUtils.isBlank(task.getVideoUrl())) {
// 生成
String url = adapter.getUrl(filename);
TaskEntity updateTask = new TaskEntity();
updateTask.setId(taskId);
updateTask.setVideoUrl(url);
taskMapper.update(updateTask);
videoTaskRepository.clearTaskCache(updateTask.getId());
RenderWorkerEntity worker = getWorker(req);
IStorageAdapter adapter;
try {
adapter = StorageFactory.get(worker.getStoreType());
adapter.loadConfig(JSONObject.parseObject(worker.getStoreConfigJson(), Map.class));
} catch (Exception e) {
adapter = scenicService.getScenicStorageAdapter(task.getScenicId());
}
return adapter.getUrlForUpload(new Date(System.currentTimeMillis() + 1000 * 60 * 60), "video/mp4", filename);
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, task.getId() + "_" + task.getScenicId() + ".mp4");
// 生成
String url = adapter.getUrl(filename);
TaskEntity updateTask = new TaskEntity();
updateTask.setId(taskId);
updateTask.setVideoUrl(url);
taskMapper.update(updateTask);
videoTaskRepository.clearTaskCache(updateTask.getId());
return adapter.getUrlForUpload(new Date(System.currentTimeMillis() + 1000 * 3600), "video/mp4", filename);
}
public void sendVideoGeneratedServiceNotification(Long taskId) {
@ -733,4 +738,9 @@ public class TaskTaskServiceImpl implements TaskService {
adapter.sendTo(new NotifyContent(title, page, params), openId);
}
}
@Override
public TaskRespVO taskInfo(Long taskId) {
return taskMapper.getById(taskId);
}
}

View File

@ -110,10 +110,6 @@ public class VideoReUploader {
if (entity.getScenicId() == null) {
return;
}
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(entity.getScenicId());
if (scenicConfig == null || scenicConfig.getTmpStoreType() == null || scenicConfig.getTmpStoreConfigJson() == null) {
return;
}
final String dstFilePath = StorageUtil.joinPath(StorageConstant.VLOG_PATH, entity.getTaskId() + "_" + entity.getScenicId() + ".mp4");
final IStorageAdapter adapter = scenicService.getScenicStorageAdapter(entity.getScenicId());
if (StringUtils.equals(url, adapter.getUrl(dstFilePath))) {