feat: 客户端pad

This commit is contained in:
2026-03-11 21:29:55 +08:00
parent 5e66537a87
commit 44975cde97
21 changed files with 2810 additions and 9 deletions
@@ -25,6 +25,8 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@Service
@@ -220,15 +222,49 @@ public class MediaServiceImpl implements IMediaService {
/**
* 基于模板配置构建clips参数
* fileIndex 匹配文件路径中的拍照顺序号(如 DJI_20260311104552_0014_V.mp4 中的 0014 → 14)
*/
private String buildClipsParamFromConfig(List<OrderFile> videoFiles, ClipsConfig config) {
Map<String, String> clips = new HashMap<>();
for (ClipsConfig.ClipMapping m : config.getMappings()) {
clips.put(m.getSlot(), getUrlBySafeIndex(videoFiles, m.getFileIndex()));
clips.put(m.getSlot(), getUrlBySequenceNumber(videoFiles, m.getFileIndex()));
}
return JSON.toJSONString(clips);
}
/** 从文件路径中提取拍照顺序号,如 DJI_20260311104552_0014_V.mp4 → 14 */
private static final Pattern SEQUENCE_PATTERN = Pattern.compile("DJI_\\d+_(\\d+)_");
private int extractSequenceNumber(String filePath) {
if (filePath == null) {
return -1;
}
// 取文件名部分,避免匹配到目录名中的序号
int lastSlash = filePath.lastIndexOf('/');
String fileName = (lastSlash >= 0) ? filePath.substring(lastSlash + 1) : filePath;
Matcher matcher = SEQUENCE_PATTERN.matcher(fileName);
if (matcher.find()) {
return Integer.parseInt(matcher.group(1));
}
return -1;
}
/**
* 根据配置的 fileIndex 匹配素材路径中的拍照顺序号,找到对应文件
*/
private String getUrlBySequenceNumber(List<OrderFile> videoFiles, int fileIndex) {
if (videoFiles == null || videoFiles.isEmpty() || fileIndex < 0) {
return "";
}
for (OrderFile file : videoFiles) {
if (extractSequenceNumber(file.getFilePath()) == fileIndex) {
return fileCenterService.getViewUrlByPath(file.getFilePath());
}
}
log.warn("未找到拍照顺序号={}的素材文件", fileIndex);
return "";
}
/**
* 默认剪辑参数构建(原有硬编码逻辑,作为兜底)
*/