|
|
@@ -9,31 +9,39 @@ import com.video.script.admin.entity.VideoScriptTask;
|
|
|
import com.video.script.admin.mapper.VideoScriptTaskMapper;
|
|
|
import com.video.script.admin.service.LlmScriptClient;
|
|
|
import com.video.script.admin.service.TaskService;
|
|
|
+import com.video.script.admin.service.VideoAnalysisClient;
|
|
|
import com.video.script.admin.service.VideoTranscriptionClient;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
public class TaskServiceImpl implements TaskService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
|
|
|
+
|
|
|
private final VideoScriptTaskMapper videoScriptTaskMapper;
|
|
|
private final LlmScriptClient llmScriptClient;
|
|
|
private final LlmProperties llmProperties;
|
|
|
private final VideoTranscriptionClient videoTranscriptionClient;
|
|
|
+ private final VideoAnalysisClient videoAnalysisClient;
|
|
|
private final AsrProperties asrProperties;
|
|
|
|
|
|
public TaskServiceImpl(VideoScriptTaskMapper videoScriptTaskMapper,
|
|
|
LlmScriptClient llmScriptClient,
|
|
|
LlmProperties llmProperties,
|
|
|
VideoTranscriptionClient videoTranscriptionClient,
|
|
|
+ VideoAnalysisClient videoAnalysisClient,
|
|
|
AsrProperties asrProperties) {
|
|
|
this.videoScriptTaskMapper = videoScriptTaskMapper;
|
|
|
this.llmScriptClient = llmScriptClient;
|
|
|
this.llmProperties = llmProperties;
|
|
|
this.videoTranscriptionClient = videoTranscriptionClient;
|
|
|
+ this.videoAnalysisClient = videoAnalysisClient;
|
|
|
this.asrProperties = asrProperties;
|
|
|
}
|
|
|
|
|
|
@@ -86,6 +94,12 @@ public class TaskServiceImpl implements TaskService {
|
|
|
if (entity == null) {
|
|
|
throw new BusinessException("任务不存在");
|
|
|
}
|
|
|
+ String originalTaskName = entity.getTaskName();
|
|
|
+ String originalVideoUrl = entity.getVideoUrl();
|
|
|
+ String originalVideoUrls = entity.getVideoUrls();
|
|
|
+ String originalScriptType = entity.getScriptType();
|
|
|
+ String originalPromptHint = entity.getPromptHint();
|
|
|
+ Boolean originalUseOmniAnalysis = entity.getUseOmniAnalysis();
|
|
|
entity.setId(request.getId());
|
|
|
if (StringUtils.isNotBlank(request.getTaskName())) {
|
|
|
entity.setTaskName(request.getTaskName());
|
|
|
@@ -111,6 +125,9 @@ public class TaskServiceImpl implements TaskService {
|
|
|
if (request.getVideoContent() != null) {
|
|
|
entity.setVideoContent(request.getVideoContent());
|
|
|
}
|
|
|
+ if (request.getOmniContent() != null) {
|
|
|
+ entity.setOmniContent(request.getOmniContent());
|
|
|
+ }
|
|
|
if (request.getAnalysisContent() != null) {
|
|
|
entity.setAnalysisContent(request.getAnalysisContent());
|
|
|
}
|
|
|
@@ -123,6 +140,20 @@ public class TaskServiceImpl implements TaskService {
|
|
|
if (request.getCodedeskTaskId() != null) {
|
|
|
entity.setCodedeskTaskId(StringUtils.trimToNull(request.getCodedeskTaskId()));
|
|
|
}
|
|
|
+ if (request.getUseOmniAnalysis() != null) {
|
|
|
+ entity.setUseOmniAnalysis(request.getUseOmniAnalysis());
|
|
|
+ }
|
|
|
+ if (shouldRegenerate(request, entity, originalTaskName, originalVideoUrl, originalVideoUrls,
|
|
|
+ originalScriptType, originalPromptHint, originalUseOmniAnalysis)) {
|
|
|
+ entity.setStatus("PENDING");
|
|
|
+ entity.setTranscript(null);
|
|
|
+ entity.setVideoContent(null);
|
|
|
+ entity.setOmniContent(null);
|
|
|
+ entity.setAnalysisContent(null);
|
|
|
+ entity.setScriptContent(null);
|
|
|
+ entity.setSummary(null);
|
|
|
+ entity.setErrorMessage(null);
|
|
|
+ }
|
|
|
videoScriptTaskMapper.update(entity);
|
|
|
}
|
|
|
|
|
|
@@ -136,10 +167,12 @@ public class TaskServiceImpl implements TaskService {
|
|
|
entity.setPromptHint(resolvePromptHint(request));
|
|
|
entity.setTranscript(request.getTranscript());
|
|
|
entity.setVideoContent(resolveInitialVideoContent(request));
|
|
|
+ entity.setOmniContent(StringUtils.trimToNull(request.getOmniContent()));
|
|
|
entity.setAnalysisContent(request.getAnalysisContent());
|
|
|
entity.setScriptContent(request.getScriptContent());
|
|
|
entity.setSummary(request.getSummary());
|
|
|
entity.setCodedeskTaskId(StringUtils.trimToNull(request.getCodedeskTaskId()));
|
|
|
+ entity.setUseOmniAnalysis(Boolean.TRUE.equals(request.getUseOmniAnalysis()));
|
|
|
entity.setCreatorId(UserContext.getUserId());
|
|
|
return entity;
|
|
|
}
|
|
|
@@ -151,6 +184,7 @@ public class TaskServiceImpl implements TaskService {
|
|
|
"RUNNING",
|
|
|
entity.getTranscript(),
|
|
|
entity.getVideoContent(),
|
|
|
+ entity.getOmniContent(),
|
|
|
entity.getAnalysisContent(),
|
|
|
entity.getScriptContent(),
|
|
|
entity.getSummary(),
|
|
|
@@ -169,6 +203,7 @@ public class TaskServiceImpl implements TaskService {
|
|
|
"RUNNING",
|
|
|
entity.getTranscript(),
|
|
|
entity.getVideoContent(),
|
|
|
+ entity.getOmniContent(),
|
|
|
entity.getAnalysisContent(),
|
|
|
entity.getScriptContent(),
|
|
|
entity.getSummary(),
|
|
|
@@ -176,12 +211,37 @@ public class TaskServiceImpl implements TaskService {
|
|
|
null
|
|
|
);
|
|
|
}
|
|
|
+ if (Boolean.TRUE.equals(entity.getUseOmniAnalysis())) {
|
|
|
+ String omniVideoContent = videoAnalysisClient.analyze(entity);
|
|
|
+ if (StringUtils.isNotBlank(omniVideoContent)) {
|
|
|
+ entity.setOmniContent(omniVideoContent);
|
|
|
+ log.info("Omni output assigned to qwen3.7-plus input, taskId={}, taskName={}, transcriptLength={}, videoContentLength={}, omniContentLength={}",
|
|
|
+ entity.getId(),
|
|
|
+ entity.getTaskName(),
|
|
|
+ StringUtils.length(entity.getTranscript()),
|
|
|
+ StringUtils.length(entity.getVideoContent()),
|
|
|
+ StringUtils.length(entity.getOmniContent()));
|
|
|
+ videoScriptTaskMapper.updateCallbackResult(
|
|
|
+ entity.getId(),
|
|
|
+ "RUNNING",
|
|
|
+ entity.getTranscript(),
|
|
|
+ entity.getVideoContent(),
|
|
|
+ entity.getOmniContent(),
|
|
|
+ entity.getAnalysisContent(),
|
|
|
+ entity.getScriptContent(),
|
|
|
+ entity.getSummary(),
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
LlmScriptClient.ScriptGenerationResult result = llmScriptClient.generate(entity);
|
|
|
videoScriptTaskMapper.updateCallbackResult(
|
|
|
entity.getId(),
|
|
|
"DONE",
|
|
|
entity.getTranscript(),
|
|
|
entity.getVideoContent(),
|
|
|
+ entity.getOmniContent(),
|
|
|
result.getAnalysisContent(),
|
|
|
result.getScriptContent(),
|
|
|
result.getSummary(),
|
|
|
@@ -194,6 +254,7 @@ public class TaskServiceImpl implements TaskService {
|
|
|
"FAILED",
|
|
|
entity.getTranscript(),
|
|
|
entity.getVideoContent(),
|
|
|
+ entity.getOmniContent(),
|
|
|
entity.getAnalysisContent(),
|
|
|
entity.getScriptContent(),
|
|
|
entity.getSummary(),
|
|
|
@@ -230,6 +291,36 @@ public class TaskServiceImpl implements TaskService {
|
|
|
return request.getPromptHint() != null ? request.getVideoContent() : null;
|
|
|
}
|
|
|
|
|
|
+ private boolean shouldRegenerate(TaskSaveRequest request,
|
|
|
+ VideoScriptTask entity,
|
|
|
+ String originalTaskName,
|
|
|
+ String originalVideoUrl,
|
|
|
+ String originalVideoUrls,
|
|
|
+ String originalScriptType,
|
|
|
+ String originalPromptHint,
|
|
|
+ Boolean originalUseOmniAnalysis) {
|
|
|
+ if (request.getId() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(originalTaskName, entity.getTaskName())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(originalVideoUrl, entity.getVideoUrl())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(originalVideoUrls, entity.getVideoUrls())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(originalScriptType, entity.getScriptType())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(originalPromptHint, entity.getPromptHint())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return !java.util.Objects.equals(Boolean.TRUE.equals(originalUseOmniAnalysis),
|
|
|
+ Boolean.TRUE.equals(entity.getUseOmniAnalysis()));
|
|
|
+ }
|
|
|
+
|
|
|
private void normalizeLegacyPromptHint(VideoScriptTask entity) {
|
|
|
if (StringUtils.isBlank(entity.getPromptHint())
|
|
|
&& StringUtils.isBlank(entity.getTranscript())
|