diff --git a/apps/desktop/src-tauri/src/business/services/video_classification_service.rs b/apps/desktop/src-tauri/src/business/services/video_classification_service.rs index e609bb2..37fb339 100644 --- a/apps/desktop/src-tauri/src/business/services/video_classification_service.rs +++ b/apps/desktop/src-tauri/src/business/services/video_classification_service.rs @@ -40,10 +40,29 @@ impl VideoClassificationService { /// 为素材创建批量分类任务 pub async fn create_batch_classification_tasks(&self, request: BatchClassificationRequest) -> Result> { + println!("🎬 创建批量分类任务"); + println!(" 素材ID: {}", request.material_id); + println!(" 项目ID: {}", request.project_id); + // 获取素材信息 - let _material = self.material_repo.get_by_id(&request.material_id)? + let material = self.material_repo.get_by_id(&request.material_id)? .ok_or_else(|| anyhow!("素材不存在: {}", request.material_id))?; + println!(" 素材项目ID: {}", material.project_id); + + // 验证项目ID是否匹配,如果不匹配则尝试修复 + if material.project_id != request.project_id { + println!("⚠️ 项目ID不匹配,尝试修复: 素材项目ID={}, 请求项目ID={}", material.project_id, request.project_id); + + // 验证请求的项目ID是否存在 + if let Ok(Some(_)) = self.material_repo.get_project_by_id(&request.project_id).await { + println!("✅ 请求的项目ID有效,将使用请求的项目ID进行分类"); + // 使用请求的项目ID,而不是素材中的项目ID + } else { + return Err(anyhow!("请求的项目ID无效: {}", request.project_id)); + } + } + // 获取素材的所有片段 let segments = self.material_repo.get_segments(&request.material_id)?; @@ -225,6 +244,11 @@ impl VideoClassificationService { /// 移动视频文件到分类文件夹 async fn move_video_to_category_folder(&self, record: &VideoClassificationRecord) -> Result<()> { + println!("🔍 开始移动文件到分类文件夹"); + println!(" 项目ID: {}", record.project_id); + println!(" 分类类别: {}", record.category); + println!(" 片段ID: {}", record.segment_id); + // 获取项目信息 let project = self.material_repo.get_project_by_id(&record.project_id).await? .ok_or_else(|| anyhow!("项目不存在: {}", record.project_id))?;