一键成片功能优化,生成剪辑url存储逻辑
This commit is contained in:
@@ -123,10 +123,11 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ice20201109</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<artifactId>alibabacloud-ice20201109</artifactId>
|
||||
<version>5.0.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+24
-14
@@ -1,7 +1,9 @@
|
||||
package com.central.order.config;
|
||||
|
||||
import com.aliyun.ice20201109.Client;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.aliyun.auth.credentials.Credential;
|
||||
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
|
||||
import com.aliyun.sdk.service.ice20201109.AsyncClient;
|
||||
import darabonba.core.client.ClientOverrideConfiguration;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -11,22 +13,30 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "aliyun.ims")
|
||||
public class AliyunImsConfig {
|
||||
private String endpoint = "ice.cn-beijing.aliyuncs.com";
|
||||
private String endpoint; // ice.cn-beijing.aliyuncs.com
|
||||
private String ossEndpoint; // oss-cn-beijing.aliyuncs.com
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private String region;
|
||||
private String projectName;
|
||||
private String pipelineName;
|
||||
private String templateId;
|
||||
private String region; // cn-beijing
|
||||
private String bucket; // goflyapp
|
||||
private String callbackUrl;
|
||||
private String bucket;
|
||||
|
||||
@Bean
|
||||
public Client imsClient() throws Exception {
|
||||
Config config = new Config()
|
||||
.setAccessKeyId(accessKeyId)
|
||||
.setAccessKeySecret(accessKeySecret)
|
||||
.setEndpoint(endpoint);
|
||||
return new Client(config);
|
||||
public AsyncClient imsClient() {
|
||||
// 配置凭证
|
||||
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
|
||||
.accessKeyId(accessKeyId)
|
||||
.accessKeySecret(accessKeySecret)
|
||||
.build());
|
||||
|
||||
// 配置客户端
|
||||
return AsyncClient.builder()
|
||||
.region(region)
|
||||
.credentialsProvider(provider)
|
||||
.overrideConfiguration(
|
||||
ClientOverrideConfiguration.create()
|
||||
.setEndpointOverride(endpoint)
|
||||
)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-106
@@ -4,22 +4,22 @@ import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.constants.EditTaskStatus;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.model.*;
|
||||
import com.central.order.model.EditTask;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.dto.CallbackDTO;
|
||||
import com.central.order.model.params.EditTaskQueryParams;
|
||||
import com.central.order.service.*;
|
||||
import com.central.order.service.IEditTaskService;
|
||||
import com.central.order.service.IOrderFileService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.service.IVideoEditService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -33,16 +33,6 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class AutoCutVideoController {
|
||||
|
||||
@Value("${videos.edit-config.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${videos.edit-config.app-id}")
|
||||
private String appId;
|
||||
|
||||
@Value("${videos.edit-config.callback-url}")
|
||||
private String callbackUrl;
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
@Autowired
|
||||
@@ -50,10 +40,6 @@ public class AutoCutVideoController {
|
||||
@Autowired
|
||||
private IOrderFileService orderFileService;
|
||||
@Autowired
|
||||
private ITourismFileService tourismFileService;
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
@Autowired
|
||||
private IVideoEditService videoEditService;
|
||||
|
||||
@Operation(summary = "根据订单号生成视频")
|
||||
@@ -77,13 +63,14 @@ public class AutoCutVideoController {
|
||||
|
||||
// 4. 获取素材文件
|
||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
||||
|
||||
// 5. 提交编辑任务
|
||||
String jobId = videoEditService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||
String jobId = videoEditService.submitEditTask(orderNo, orderFiles);
|
||||
|
||||
// 6. 更新任务信息
|
||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||
task.setJobId(jobId);
|
||||
task.setStatus(EditTaskStatus.PROCESSING);
|
||||
editTaskService.saveOrUpdateTask(task);
|
||||
|
||||
return Result.succeed(jobId);
|
||||
|
||||
@@ -157,88 +144,6 @@ public class AutoCutVideoController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建素材数据
|
||||
*/
|
||||
private SourceDTO buildSourceDTO(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
// 1. 初始化列表
|
||||
List<String> textList = new ArrayList<>();
|
||||
List<String> videoList = new ArrayList<>();
|
||||
List<String> audioList = new ArrayList<>();
|
||||
List<String> imageList = new ArrayList<>();
|
||||
|
||||
// 2. 处理订单文件
|
||||
if (!orderFiles.isEmpty()) {
|
||||
for (OrderFile file : orderFiles) {
|
||||
String fileUrl = fileCenterService.getViewUrlByPath(file.getFilePath());
|
||||
|
||||
// 根据文件类型分类
|
||||
switch (getFileType(file.getFileType())) {
|
||||
case "video":
|
||||
videoList.add(fileUrl);
|
||||
break;
|
||||
case "audio":
|
||||
audioList.add(fileUrl);
|
||||
break;
|
||||
case "image":
|
||||
imageList.add(fileUrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 处理景区素材
|
||||
if (!tourismFiles.isEmpty()) {
|
||||
for (TourismFile file : tourismFiles) {
|
||||
String fileUrl = fileCenterService.getViewUrlByPath(file.getImageUrl());
|
||||
imageList.add(fileUrl);
|
||||
|
||||
// 如果有景区描述,添加到文本列表
|
||||
if (StringUtils.hasText(file.getDescription())) {
|
||||
textList.add(file.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 构建返回对象
|
||||
return new SourceDTO(textList, videoList, audioList, imageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建请求参数
|
||||
*/
|
||||
private RequestParamsEntity buildRequestParams(Order order, SourceDTO sourceDTO) {
|
||||
return RequestParamsEntity.builder()
|
||||
.appId(appId) // 使用配置文件中的appId
|
||||
.taskId(order.getOrderNo())
|
||||
.callbackUrl(callbackUrl) // 使用配置文件中的callbackUrl
|
||||
.source(sourceDTO)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*/
|
||||
private String getFileType(String mimeType) {
|
||||
if (mimeType == null) {
|
||||
return "other";
|
||||
}
|
||||
|
||||
if (mimeType.startsWith("video/")) {
|
||||
return "video";
|
||||
} else if (mimeType.startsWith("audio/")) {
|
||||
return "audio";
|
||||
} else if (mimeType.startsWith("image/")) {
|
||||
return "image";
|
||||
}
|
||||
|
||||
return "other";
|
||||
}
|
||||
|
||||
private String extractJobId(Object response) {
|
||||
// Implementation of extractJobId method
|
||||
return null; // Placeholder return, actual implementation needed
|
||||
}
|
||||
|
||||
private boolean isValidCallback(CallbackDTO callback) {
|
||||
// Implementation of isValidCallback method
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.central.db.mapper.SuperMapper;
|
||||
import com.central.order.model.OrderFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,4 +41,9 @@ public interface OrderFileMapper extends SuperMapper<OrderFile> {
|
||||
|
||||
List<OrderFile> findListByUser(Page<OrderFile> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取订单的视频文件
|
||||
*/
|
||||
@Select("SELECT * FROM order_files WHERE order_no = #{orderNo} AND file_type = 'video/mp4' ORDER BY create_time ASC")
|
||||
List<OrderFile> getOrderVideoFiles(@Param("orderNo") String orderNo);
|
||||
}
|
||||
|
||||
+5
-2
@@ -6,9 +6,12 @@ import java.util.List;
|
||||
|
||||
public interface IMediaService {
|
||||
/**
|
||||
* 提交智能一键成片任务
|
||||
* 提交编辑任务
|
||||
* @param orderNo 订单号
|
||||
* @param orderFiles 订单文件列表
|
||||
* @return 任务ID
|
||||
*/
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles);
|
||||
|
||||
/**
|
||||
* 查询任务状态
|
||||
|
||||
+7
@@ -72,5 +72,12 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||
* @return
|
||||
*/
|
||||
int delete(Long id);
|
||||
|
||||
/**
|
||||
* 获取订单的视频文件列表
|
||||
* @param orderNo 订单号
|
||||
* @return 视频文件列表
|
||||
*/
|
||||
List<OrderFile> getOrderVideoFiles(String orderNo);
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -1,7 +1,6 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.model.dto.VideoEditStatus;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,10 +14,9 @@ public interface IVideoEditService {
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param orderFiles 订单相关文件
|
||||
* @param tourismFiles 景区相关文件
|
||||
* @return 任务ID
|
||||
*/
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles);
|
||||
|
||||
/**
|
||||
* 查询编辑任务状态
|
||||
@@ -27,4 +25,4 @@ public interface IVideoEditService {
|
||||
* @return 任务状态
|
||||
*/
|
||||
VideoEditStatus queryEditStatus(String jobId);
|
||||
}
|
||||
}
|
||||
|
||||
+172
-147
@@ -1,73 +1,112 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.ice20201109.Client;
|
||||
import com.aliyun.ice20201109.models.GetMediaProducingJobRequest;
|
||||
import com.aliyun.ice20201109.models.GetMediaProducingJobResponse;
|
||||
import com.aliyun.ice20201109.models.SubmitMediaProducingJobRequest;
|
||||
import com.aliyun.ice20201109.models.SubmitMediaProducingJobResponse;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.aliyun.sdk.service.ice20201109.AsyncClient;
|
||||
import com.aliyun.sdk.service.ice20201109.models.GetMediaProducingJobRequest;
|
||||
import com.aliyun.sdk.service.ice20201109.models.GetMediaProducingJobResponse;
|
||||
import com.aliyun.sdk.service.ice20201109.models.SubmitMediaProducingJobRequest;
|
||||
import com.aliyun.sdk.service.ice20201109.models.SubmitMediaProducingJobResponse;
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.order.config.AliyunImsConfig;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.order.service.IMediaService;
|
||||
import com.central.order.service.IOrderFileService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MediaServiceImpl implements IMediaService {
|
||||
|
||||
private final Client imsClient;
|
||||
private final AliyunImsConfig imsConfig;
|
||||
@Autowired
|
||||
private AsyncClient imsClient;
|
||||
@Autowired
|
||||
private AliyunImsConfig imsConfig;
|
||||
@Autowired
|
||||
private IQrCodeService qrCodeService;
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
@Autowired
|
||||
private IOrderFileService orderFileService;
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
@Override
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles) {
|
||||
try {
|
||||
// 1. 构建时间线配置
|
||||
String timeline = buildTimeline(orderFiles, tourismFiles);
|
||||
|
||||
// 2. 构建输出配置
|
||||
String outputConfig = buildOutputConfig(orderNo);
|
||||
|
||||
// 3. 构建项目元数据
|
||||
String projectMetadata = buildProjectMetadata(orderNo);
|
||||
|
||||
// 4. 构建userData
|
||||
String userData = buildUserData(orderNo);
|
||||
|
||||
// 打印请求参数,方便调试
|
||||
log.info("提交任务参数: timeline={}, outputConfig={}, projectMetadata={}, userData={}",
|
||||
timeline, outputConfig, projectMetadata, userData);
|
||||
|
||||
// 5. 构建请求
|
||||
SubmitMediaProducingJobRequest request = new SubmitMediaProducingJobRequest()
|
||||
.setTimeline(timeline)
|
||||
.setOutputMediaConfig(outputConfig)
|
||||
.setProjectMetadata(projectMetadata)
|
||||
.setUserData(userData);
|
||||
|
||||
// 6. 提交任务
|
||||
SubmitMediaProducingJobResponse response = imsClient.submitMediaProducingJob(request);
|
||||
|
||||
if (response != null && response.getStatusCode() == 200) {
|
||||
String jobId = response.getBody().getJobId();
|
||||
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}, projectId={}",
|
||||
orderNo, jobId, response.getBody().getProjectId());
|
||||
return jobId;
|
||||
} else {
|
||||
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getRequestId() : "未知错误"));
|
||||
// 1. 获取订单信息
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
|
||||
// 2. 获取二维码信息
|
||||
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||
if (qrCode == null || qrCode.getTemplateId() == null) {
|
||||
throw new BusinessException("未配置视频模板ID");
|
||||
}
|
||||
|
||||
// 3. 获取订单视频文件
|
||||
List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
||||
if (videoFiles == null || videoFiles.size() < 2) {
|
||||
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
||||
}
|
||||
|
||||
// 构建并验证参数
|
||||
String clipsParam = buildClipsParam(orderNo, videoFiles);
|
||||
String outputConfig = buildOutputConfig(orderNo);
|
||||
String userData = buildUserData(order, qrCode);
|
||||
|
||||
// 打印完整的请求参数用于调试
|
||||
log.info("提交任务参数: orderNo={}, templateId={}", orderNo, qrCode.getTemplateId());
|
||||
log.info("clips参数: {}", clipsParam);
|
||||
log.info("输出配置: {}", outputConfig);
|
||||
log.info("用户数据: {}", userData);
|
||||
|
||||
// 构建请求
|
||||
SubmitMediaProducingJobRequest request = SubmitMediaProducingJobRequest.builder()
|
||||
.templateId(qrCode.getTemplateId())
|
||||
.clipsParam(clipsParam)
|
||||
.outputMediaConfig(outputConfig)
|
||||
.userData(userData)
|
||||
.build();
|
||||
|
||||
// 提交任务
|
||||
CompletableFuture<SubmitMediaProducingJobResponse> future =
|
||||
imsClient.submitMediaProducingJob(request);
|
||||
SubmitMediaProducingJobResponse response = future.get(30, TimeUnit.SECONDS);
|
||||
|
||||
// 6. 处理响应
|
||||
if (response != null && response.getBody() != null) {
|
||||
String jobId = response.getBody().getJobId();
|
||||
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}, templateId={}",
|
||||
orderNo, jobId, qrCode.getTemplateId());
|
||||
return jobId;
|
||||
} else {
|
||||
throw new BusinessException("提交任务失败: 响应为空");
|
||||
}
|
||||
|
||||
} catch (TimeoutException e) {
|
||||
log.error("提交任务超时: orderNo={}", orderNo, e);
|
||||
throw new BusinessException("提交任务超时");
|
||||
} catch (Exception e) {
|
||||
log.error("提交智能一键成片任务失败: orderNo={}", orderNo, e);
|
||||
log.error("提交智能一键成片任务失败: orderNo={}, error={}", orderNo, e.getMessage(), e);
|
||||
throw new BusinessException("提交任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -75,10 +114,13 @@ public class MediaServiceImpl implements IMediaService {
|
||||
@Override
|
||||
public String getTaskStatus(String jobId) {
|
||||
try {
|
||||
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
|
||||
.setJobId(jobId);
|
||||
GetMediaProducingJobRequest request = GetMediaProducingJobRequest.builder()
|
||||
.jobId(jobId)
|
||||
.build();
|
||||
|
||||
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
|
||||
CompletableFuture<GetMediaProducingJobResponse> future =
|
||||
imsClient.getMediaProducingJob(request);
|
||||
GetMediaProducingJobResponse response = future.get(10, TimeUnit.SECONDS);
|
||||
|
||||
if (response != null && response.getBody() != null
|
||||
&& response.getBody().getMediaProducingJob() != null) {
|
||||
@@ -95,16 +137,15 @@ public class MediaServiceImpl implements IMediaService {
|
||||
@Override
|
||||
public String getTaskResult(String jobId) {
|
||||
try {
|
||||
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
|
||||
.setJobId(jobId);
|
||||
|
||||
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
|
||||
|
||||
if (response != null && response.getBody() != null
|
||||
&& response.getBody().getMediaProducingJob() != null) {
|
||||
return response.getBody().getMediaProducingJob().getMediaURL();
|
||||
}
|
||||
return null;
|
||||
GetMediaProducingJobRequest getMediaProducingJobRequest =
|
||||
GetMediaProducingJobRequest
|
||||
.builder()
|
||||
.jobId(jobId)
|
||||
.build();
|
||||
CompletableFuture<GetMediaProducingJobResponse> response =
|
||||
imsClient.getMediaProducingJob(getMediaProducingJobRequest);
|
||||
GetMediaProducingJobResponse resp = response.get();
|
||||
return new Gson().toJson(resp);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取任务结果失败: jobId={}", jobId, e);
|
||||
@@ -112,103 +153,87 @@ public class MediaServiceImpl implements IMediaService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建输出配置
|
||||
* 按照阿里云文档格式:
|
||||
* {
|
||||
* "MediaURL": "oss://bucket-name/output/example.mp4"
|
||||
* }
|
||||
*/
|
||||
private String buildOutputConfig(String orderNo) {
|
||||
Map<String, String> config = new HashMap<>();
|
||||
// 注意:这里只需要设置MediaURL
|
||||
config.put("MediaURL", String.format("oss://%s/output/%s_%s.mp4",
|
||||
imsConfig.getBucket(),
|
||||
orderNo,
|
||||
System.currentTimeMillis()
|
||||
));
|
||||
|
||||
String configJson = JSON.toJSONString(config);
|
||||
log.debug("输出配置: {}", configJson);
|
||||
return configJson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建时间线配置
|
||||
* 按照阿里云文档格式:
|
||||
* {
|
||||
* "VideoTracks": [{
|
||||
* "VideoTrackClips": [{
|
||||
* "MediaId": "xxxxx"
|
||||
* }]
|
||||
* }]
|
||||
* }
|
||||
*/
|
||||
private String buildTimeline(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
Map<String, Object> timeline = new HashMap<>();
|
||||
List<Map<String, Object>> videoTracks = new ArrayList<>();
|
||||
Map<String, Object> videoTrack = new HashMap<>();
|
||||
List<Map<String, Object>> videoTrackClips = new ArrayList<>();
|
||||
|
||||
// 处理订单文件
|
||||
if (orderFiles != null) {
|
||||
for (OrderFile file : orderFiles) {
|
||||
Map<String, Object> clip = new HashMap<>();
|
||||
clip.put("MediaId", getMediaId(file.getFilePath()));
|
||||
videoTrackClips.add(clip);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理景区文件
|
||||
if (tourismFiles != null) {
|
||||
for (TourismFile file : tourismFiles) {
|
||||
Map<String, Object> clip = new HashMap<>();
|
||||
clip.put("MediaId", getMediaId(file.getImageUrl()));
|
||||
videoTrackClips.add(clip);
|
||||
}
|
||||
}
|
||||
|
||||
videoTrack.put("VideoTrackClips", videoTrackClips);
|
||||
videoTracks.add(videoTrack);
|
||||
timeline.put("VideoTracks", videoTracks);
|
||||
|
||||
String timelineJson = JSON.toJSONString(timeline);
|
||||
log.debug("时间线配置: {}", timelineJson);
|
||||
return timelineJson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建项目元数据
|
||||
*/
|
||||
private String buildProjectMetadata(String orderNo) {
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put("title", "订单视频_" + orderNo);
|
||||
metadata.put("description", "智能一键成片生成的视频");
|
||||
metadata.put("tags", "订单视频,自动生成");
|
||||
|
||||
String metadataJson = JSON.toJSONString(metadata);
|
||||
log.debug("项目元数据: {}", metadataJson);
|
||||
return metadataJson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建用户数据
|
||||
*/
|
||||
private String buildUserData(String orderNo) {
|
||||
Map<String, String> userData = new HashMap<>();
|
||||
userData.put("orderNo", orderNo);
|
||||
private String buildUserData(Order order, QrCode qrCode) {
|
||||
try {
|
||||
Map<String, Object> userData = new HashMap<>();
|
||||
// 订单信息
|
||||
userData.put("orderNo", order.getOrderNo());
|
||||
userData.put("orderId", order.getId());
|
||||
// 二维码信息
|
||||
userData.put("codeId", order.getCodeId());
|
||||
userData.put("templateId", qrCode.getTemplateId());
|
||||
// 其他信息
|
||||
userData.put("timestamp", System.currentTimeMillis());
|
||||
userData.put("source", "order_center");
|
||||
|
||||
String userDataJson = JSON.toJSONString(userData);
|
||||
log.debug("用户数据: {}", userDataJson);
|
||||
return userDataJson;
|
||||
String userDataJson = JSON.toJSONString(userData);
|
||||
log.debug("用户数据: {}", userDataJson);
|
||||
return userDataJson;
|
||||
} catch (Exception e) {
|
||||
log.error("构建用户数据失败: orderNo={}", order.getOrderNo(), e);
|
||||
throw new BusinessException("构建用户数据失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取媒体ID
|
||||
* 构建剪辑参数
|
||||
*/
|
||||
private String getMediaId(String filePath) {
|
||||
// TODO: 这里需要实现获取MediaId的逻辑
|
||||
// 可能需要先将文件上传到阿里云,然后获取MediaId
|
||||
return filePath;
|
||||
private String buildClipsParam(String orderNo, List<OrderFile> videoFiles) {
|
||||
try {
|
||||
Map<String, String> clips = new HashMap<>();
|
||||
|
||||
// 使用完整的OSS URL
|
||||
String firstUrl = fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath());
|
||||
clips.put("1", firstUrl);
|
||||
|
||||
String secondUrl = fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath());
|
||||
clips.put("2", secondUrl);
|
||||
|
||||
String clipsJson = JSON.toJSONString(clips);
|
||||
log.info("剪辑参数: orderNo={}, clips={}", orderNo, clipsJson);
|
||||
return clipsJson;
|
||||
} catch (Exception e) {
|
||||
log.error("构建剪辑参数失败: orderNo={}", orderNo, e);
|
||||
throw new BusinessException("构建剪辑参数失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建输出配置
|
||||
*/
|
||||
private String buildOutputConfig(String orderNo) {
|
||||
try {
|
||||
Map<String, String> config = new HashMap<>();
|
||||
// 使用正确的OSS路径格式
|
||||
config.put("MediaURL", String.format("https://"+imsConfig.getBucket()+"."+imsConfig.getOssEndpoint()+"/output/%s_%s.mp4",
|
||||
orderNo,
|
||||
System.currentTimeMillis()
|
||||
));
|
||||
|
||||
String configJson = JSON.toJSONString(config);
|
||||
log.info("输出配置: {}", configJson);
|
||||
return configJson;
|
||||
} catch (Exception e) {
|
||||
log.error("构建输出配置失败: orderNo={}", orderNo, e);
|
||||
throw new BusinessException("构建输出配置失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取媒体URL
|
||||
*/
|
||||
private String getMediaUrl(String filePath) {
|
||||
try {
|
||||
return String.format("https://goflyapp.%s/picture/%s",
|
||||
imsConfig.getOssEndpoint(),
|
||||
filePath
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("生成媒体URL失败: filePath={}", filePath, e);
|
||||
throw new BusinessException("生成媒体URL失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -81,4 +82,15 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderFile> getOrderVideoFiles(String orderNo) {
|
||||
try {
|
||||
log.debug("查询订单视频文件: orderNo={}", orderNo);
|
||||
return baseMapper.getOrderVideoFiles(orderNo);
|
||||
} catch (Exception e) {
|
||||
log.error("查询订单视频文件失败: orderNo={}", orderNo, e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -3,7 +3,6 @@ package com.central.order.service.impl;
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.order.constants.EditTaskStatus;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.model.dto.VideoEditStatus;
|
||||
import com.central.order.service.IEditTaskService;
|
||||
import com.central.order.service.IMediaService;
|
||||
@@ -28,10 +27,10 @@ public class VideoEditServiceImpl implements IVideoEditService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles) {
|
||||
try {
|
||||
// 提交智能一键成片任务
|
||||
String jobId = mediaService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||
String jobId = mediaService.submitEditTask(orderNo, orderFiles);
|
||||
|
||||
// 更新任务状态
|
||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||
|
||||
@@ -73,20 +73,13 @@ file:
|
||||
# jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/logger-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||
# username: ${zlt.datasource.username}
|
||||
# password: ${zlt.datasource.password}
|
||||
videos:
|
||||
edit-config:
|
||||
url: ${VIDEOS_EDIT_URL:http://example.com/api/edit}
|
||||
app-id: ${VIDEOS_APP_ID:gcb4432dcc7e4e3a92063807f3e75d58}
|
||||
callback-url: ${VIDEOS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
||||
|
||||
aliyun:
|
||||
ims:
|
||||
oss-endpoint: oss-cn-beijing.aliyuncs.com
|
||||
access-key-id: LTAI5tSNV1RvexXpMMCZhxSe
|
||||
access-key-secret: XocJRWU8emwjjvYLTrc04l91VZMkQK
|
||||
endpoint: ice.cn-beijing.aliyuncs.com
|
||||
access-key-id: ${zlt.oss.secretId}
|
||||
access-key-secret: ${zlt.oss.secretKey}
|
||||
region: cn-beijing
|
||||
project-name: ${IMS_PROJECT_NAME}
|
||||
pipeline-name: ${IMS_PIPELINE_NAME}
|
||||
template-id: ${IMS_TEMPLATE_ID:e26a222d7cfb4a1dae85077efaeb05cd}
|
||||
callback-url: ${IMS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
||||
bucket: ${zlt.oss.bucketName}
|
||||
bucket: goflyapp # 使用实际存在的bucket名称
|
||||
|
||||
|
||||
@@ -127,9 +127,9 @@ const TableList: React.FC = () => {
|
||||
|
||||
if (response.resp_code === 0) {
|
||||
return {
|
||||
data: response.data.records || [],
|
||||
data: response.data.data || [],
|
||||
success: true,
|
||||
total: response.data.total || 0,
|
||||
total: response.data.count || 0,
|
||||
};
|
||||
}
|
||||
message.error(response.resp_msg);
|
||||
|
||||
+24
-4
@@ -6,6 +6,8 @@ import {
|
||||
ProFormText,
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form } from 'antd';
|
||||
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
||||
|
||||
interface CreateFormProps {
|
||||
visible: boolean;
|
||||
@@ -26,6 +28,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
waylineOptions,
|
||||
deviceOptions,
|
||||
}) => {
|
||||
// 使用 Form.useWatch 监听 enableProfit 的值
|
||||
const [form] = Form.useForm();
|
||||
const enableProfit = Form.useWatch('enableProfit', form);
|
||||
|
||||
return (
|
||||
<ModalForm
|
||||
title="新增二维码"
|
||||
@@ -33,6 +39,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
onVisibleChange={onVisibleChange}
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={onSubmit}
|
||||
form={form}
|
||||
initialValues={{
|
||||
enableProfit: 0, // 默认不开启分润
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
@@ -114,22 +124,31 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="enableProfit"
|
||||
label="是否开启分润"
|
||||
options={ENABLE_PROFIT_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否开启分润' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="payeeType"
|
||||
label="分账账号类型"
|
||||
options={[
|
||||
{ label: '商户ID', value: 'MERCHANT_ID' },
|
||||
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
||||
]}
|
||||
options={PAYEE_TYPE_OPTIONS}
|
||||
placeholder="请选择分账账号类型"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
<ProFormText
|
||||
width="md"
|
||||
name="payeeAccount"
|
||||
label="分账账号"
|
||||
placeholder="请输入分账账号"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
@@ -141,6 +160,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
min={0}
|
||||
max={100}
|
||||
placeholder="请输入分账比例"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
|
||||
+23
-6
@@ -6,7 +6,7 @@ import {
|
||||
ProFormText,
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS } from '../index';
|
||||
import { Form, Space } from 'antd';
|
||||
import styles from './index.less';
|
||||
|
||||
@@ -31,6 +31,9 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
waylineOptions,
|
||||
deviceOptions,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const enableProfit = Form.useWatch('enableProfit', form);
|
||||
|
||||
return (
|
||||
<ModalForm
|
||||
title="修改二维码"
|
||||
@@ -38,7 +41,11 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
onVisibleChange={onVisibleChange}
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={onSubmit}
|
||||
initialValues={values}
|
||||
form={form}
|
||||
initialValues={{
|
||||
...values,
|
||||
enableProfit: values?.enableProfit ?? 0,
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
@@ -119,22 +126,31 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="enableProfit"
|
||||
label="是否开启分润"
|
||||
options={ENABLE_PROFIT_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否开启分润' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="payeeType"
|
||||
label="分账账号类型"
|
||||
options={[
|
||||
{ label: '商户ID', value: 'MERCHANT_ID' },
|
||||
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
||||
]}
|
||||
options={PAYEE_TYPE_OPTIONS}
|
||||
placeholder="请选择分账账号类型"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
<ProFormText
|
||||
width="md"
|
||||
name="payeeAccount"
|
||||
label="分账账号"
|
||||
placeholder="请输入分账账号"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
@@ -146,6 +162,7 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
min={0}
|
||||
max={100}
|
||||
placeholder="请输入分账比例"
|
||||
disabled={enableProfit === 0}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
|
||||
@@ -43,6 +43,12 @@ export const PAYEE_STATUS_OPTIONS = [
|
||||
{ label: '验证失败', value: 2 },
|
||||
] as const;
|
||||
|
||||
// 添加分润状态常量
|
||||
export const ENABLE_PROFIT_OPTIONS = [
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
] as const;
|
||||
|
||||
const handleApiRequest = async (
|
||||
apiCall: () => Promise<any>,
|
||||
loadingMessage: string,
|
||||
@@ -301,25 +307,36 @@ const TableList: React.FC = () => {
|
||||
render: (status) => renderStatus(status as number),
|
||||
},
|
||||
{
|
||||
title: '分账账号',
|
||||
dataIndex: 'payeeAccount',
|
||||
width: 140,
|
||||
ellipsis: true,
|
||||
title: '是否开启分润',
|
||||
dataIndex: 'enableProfit',
|
||||
width: 120,
|
||||
render: (_, record) => {
|
||||
const status = record.enableProfit === 1 ? '是' : '否';
|
||||
const color = record.enableProfit === 1 ? 'green' : 'default';
|
||||
return <Tag color={color}>{status}</Tag>;
|
||||
},
|
||||
valueEnum: {
|
||||
0: { text: '否' },
|
||||
1: { text: '是' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '账号类型',
|
||||
dataIndex: 'payeeType',
|
||||
width: 100,
|
||||
valueEnum: {
|
||||
'MERCHANT_ID': { text: '商户ID' },
|
||||
'PERSONAL_OPENID': { text: '个人openid' },
|
||||
title: '分账账号',
|
||||
dataIndex: 'payeeAccount',
|
||||
width: 180,
|
||||
render: (_, record) => {
|
||||
if (record.enableProfit !== 1) return '-';
|
||||
return record.payeeAccount || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '分账比例',
|
||||
dataIndex: 'profitRate',
|
||||
width: 100,
|
||||
render: (val) => val ? `${val}%` : '-',
|
||||
render: (_, record) => {
|
||||
if (record.enableProfit !== 1) return '-';
|
||||
return record.profitRate ? `${record.profitRate}%` : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '验证状态',
|
||||
@@ -358,6 +375,15 @@ const TableList: React.FC = () => {
|
||||
width: 160,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '账号类型',
|
||||
dataIndex: 'payeeType',
|
||||
width: 100,
|
||||
valueEnum: {
|
||||
'MERCHANT_ID': { text: '商户ID' },
|
||||
'PERSONAL_OPENID': { text: '个人openid' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
|
||||
Reference in New Issue
Block a user