diff --git a/apps/desktop/src-tauri/src/business/services/material_matching_service.rs b/apps/desktop/src-tauri/src/business/services/material_matching_service.rs index 083030b..95ca955 100644 --- a/apps/desktop/src-tauri/src/business/services/material_matching_service.rs +++ b/apps/desktop/src-tauri/src/business/services/material_matching_service.rs @@ -247,22 +247,22 @@ impl MaterialMatchingService { } } - // 计算统计信息 - 修正:固定素材不计入总数和失败数 + // 计算统计信息 let total_segments = track_segments.len() as u32; let fixed_segments_count = fixed_segments.len() as u32; - let matchable_segments = total_segments - fixed_segments_count; // 可匹配的片段数 let matched_segments = matches.len() as u32; let failed_segments_count = failed_segments.len() as u32; - // 成功率基于可匹配的片段计算 - let success_rate = if matchable_segments > 0 { - matched_segments as f64 / matchable_segments as f64 + // 正确的成功率计算:(成功匹配的片段 + 固定片段) / 总片段数 + let successful_segments = matched_segments + fixed_segments_count; + let success_rate = if total_segments > 0 { + successful_segments as f64 / total_segments as f64 } else { - 1.0 // 如果没有需要匹配的片段,成功率为100% + 1.0 // 如果没有片段,成功率为100% }; let statistics = MatchingStatistics { - total_segments: matchable_segments, // 只统计需要匹配的片段 + total_segments, // 统计所有片段 matched_segments, failed_segments: failed_segments_count, success_rate, @@ -1066,12 +1066,12 @@ impl MaterialMatchingService { let failed_segments_count = failed_segments.len() as u32; let fixed_segments_count = fixed_segments.len() as u32; - // 修正成功率计算:只考虑需要匹配的片段 - let matchable_segments = total_segments - fixed_segments_count; - let success_rate = if matchable_segments > 0 { - matched_segments as f64 / matchable_segments as f64 + // 正确的成功率计算:(成功匹配的片段 + 固定片段) / 总片段数 + let successful_segments = matched_segments + fixed_segments_count; + let success_rate = if total_segments > 0 { + successful_segments as f64 / total_segments as f64 } else { - 1.0 // 如果没有需要匹配的片段,成功率为100% + 1.0 // 如果没有片段,成功率为100% }; // 判断匹配是否成功:所有需要匹配的片段都成功匹配 @@ -1084,7 +1084,7 @@ impl MaterialMatchingService { project_id: request.project_id.clone(), matches, statistics: MatchingStatistics { - total_segments: matchable_segments, // 只统计需要匹配的片段 + total_segments, // 统计所有片段 matched_segments, failed_segments: failed_segments_count, success_rate,