提交 9b011f87 authored 作者: 王鹏飞's avatar 王鹏飞

优化评分

上级 6242443a
...@@ -48,18 +48,45 @@ export function useScore() { ...@@ -48,18 +48,45 @@ export function useScore() {
return { ...detail, scores } return { ...detail, scores }
} }
const handleAIScoreList = async () => { // 并发限制处理函数
isLoading.value = true const processBatch = async (items: any[], batchSize: number) => {
const list = await fetchScoreList() const results = []
for (const item of list) { for (let i = 0; i < items.length; i += batchSize) {
const batch = items.slice(i, i + batchSize)
const batchPromises = batch.map(async (item) => {
try {
console.log('AI评分中', item.id) console.log('AI评分中', item.id)
const detail = await fetchScoreDetail(item.id) const detail = await fetchScoreDetail(item.id)
// 修改为评分中 // 修改为评分中
await updateScore({ id: detail.id, check_status: 1 }) await updateScore({ id: detail.id, check_status: 1 })
await handleAIScore(detail) await handleAIScore(detail)
return { success: true, id: item.id }
} catch (error) {
console.error(`AI评分失败 ${item.id}:`, error)
return { success: false, id: item.id, error }
}
})
const batchResults = await Promise.allSettled(batchPromises)
results.push(...batchResults)
}
return results
} }
const handleAIScoreList = async () => {
isLoading.value = true
try {
const list = await fetchScoreList()
// 并发处理,每批处理5个,可以根据需要调整
const batchSize = 5
await processBatch(list, batchSize)
ElMessage.success(`批量评分完成,共处理 ${list.length} 条`)
} catch (error) {
console.error('批量评分失败:', error)
ElMessage.error('批量评分过程中出现错误')
} finally {
isLoading.value = false isLoading.value = false
} }
}
const handleAIScore = async (detail: any) => { const handleAIScore = async (detail: any) => {
const liveData = detail.live_data const liveData = detail.live_data
......
...@@ -54,7 +54,7 @@ const fetchDetail = async () => { ...@@ -54,7 +54,7 @@ const fetchDetail = async () => {
console.log('评分列表解析失败', error) console.log('评分列表解析失败', error)
scores = [] scores = []
} }
const myScore = scores.find((item) => item.checker_id == userStore.user.id)?.scores const myScore = scores.find((item) => item.checker_id == userStore.user.id && !item.is_ai)?.scores
const aiScore = scores.find((item) => item.is_ai)?.scores const aiScore = scores.find((item) => item.is_ai)?.scores
Object.assign(scoreDetails, cloneDeep(myScore || aiScore || {})) Object.assign(scoreDetails, cloneDeep(myScore || aiScore || {}))
} }
...@@ -100,7 +100,7 @@ const commitScore = (status = 1, isAI = false) => { ...@@ -100,7 +100,7 @@ const commitScore = (status = 1, isAI = false) => {
} }
// 去掉当前评分人的评分,并添加当前评分人的评分 // 去掉当前评分人的评分,并添加当前评分人的评分
scores = [...scores.filter((item) => item.checker_id != userStore.user.id), myScore] scores = [...scores.filter((item) => !(item.checker_id == userStore.user.id && !item.is_ai)), myScore]
// 总平均分,过滤掉AI评分 // 总平均分,过滤掉AI评分
const validScores = scores.filter((item) => !item.is_ai) const validScores = scores.filter((item) => !item.is_ai)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论