You've already forked FrameTour-BE
渲染机支持配置存储地址
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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))) {
|
||||
|
@ -32,13 +32,14 @@ spring:
|
||||
password: ZhEnTuAi
|
||||
timeout: 40000
|
||||
# 配置用户头像存放静态资源文件夹
|
||||
resources:
|
||||
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
|
||||
# 配置请求文件大小
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
|
||||
|
||||
# MyBatis
|
||||
mybatis-plus:
|
||||
|
@ -71,8 +71,7 @@
|
||||
</delete>
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.device.resp.DeviceRespVO">
|
||||
select d.id, scenic_id, d.name, no, d.longitude, d.latitude, d.status, create_at, d.update_at, s.name scenic_name, d.keepalive_at, d.online, p.wvp_device_no as device_no, p.wvp_channel_no channel_no,
|
||||
(select s.url from source s where s.device_id=d.id order by id desc limit 1) coverUrl,
|
||||
(select s.create_time from source s where s.device_id=d.id order by id desc limit 1) coverTime
|
||||
(select s.url from source s where s.device_id=d.id order by id desc limit 1) coverUrl
|
||||
from device d
|
||||
left join scenic s on d.scenic_id = s.id
|
||||
left join device_preview_config p on d.id = p.device_id and p.status = 1
|
||||
|
@ -122,7 +122,7 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="findByAccessKey" resultType="com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity">
|
||||
select id, `name`, scenic_only, test_only, `online`, `status`, create_at, update_at
|
||||
select id, `name`, scenic_only, test_only, `online`, `status`, create_at, update_at, store_type, store_config_json
|
||||
from render_worker
|
||||
where access_key = #{accessKey} and status = 1
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user