修正評分詳細沒有上傳問題
This commit is contained in:
@@ -3872,7 +3872,12 @@ export class ScoringService extends DatabaseServiceBase {
|
||||
);
|
||||
|
||||
// 4. 插入新的評分詳情
|
||||
console.log('🔍 開始插入評分詳情,scores:', scores);
|
||||
console.log('🔍 競賽規則數量:', rules.length);
|
||||
|
||||
for (const [ruleName, score] of Object.entries(scores)) {
|
||||
console.log(`🔍 處理評分項目: ${ruleName} = ${score}`);
|
||||
|
||||
if (typeof score === 'number' && score > 0) {
|
||||
// 找到對應的規則
|
||||
const rule = rules.find((r: any) => r.name === ruleName);
|
||||
@@ -3881,7 +3886,7 @@ export class ScoringService extends DatabaseServiceBase {
|
||||
if (rule) {
|
||||
const detailId = `jsd_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||
|
||||
console.log('🔍 插入評分詳情:', {
|
||||
console.log('🔍 準備插入評分詳情:', {
|
||||
detailId,
|
||||
finalJudgeScoreId,
|
||||
ruleId: rule.id,
|
||||
@@ -3890,23 +3895,48 @@ export class ScoringService extends DatabaseServiceBase {
|
||||
weight: rule.weight
|
||||
});
|
||||
|
||||
await DatabaseServiceBase.safeInsert(`
|
||||
INSERT INTO judge_score_details (id, judge_score_id, rule_id, rule_name, score, weight)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`, [
|
||||
detailId,
|
||||
finalJudgeScoreId,
|
||||
rule.id,
|
||||
rule.name,
|
||||
score,
|
||||
rule.weight
|
||||
]);
|
||||
try {
|
||||
await DatabaseServiceBase.safeInsert(`
|
||||
INSERT INTO judge_score_details (id, judge_score_id, rule_id, rule_name, score, weight)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`, [
|
||||
detailId,
|
||||
finalJudgeScoreId,
|
||||
rule.id,
|
||||
rule.name,
|
||||
score,
|
||||
rule.weight
|
||||
]);
|
||||
console.log('✅ 成功插入評分詳情:', ruleName);
|
||||
} catch (insertError) {
|
||||
console.error('❌ 插入評分詳情失敗:', insertError);
|
||||
console.error('插入數據:', {
|
||||
detailId,
|
||||
finalJudgeScoreId,
|
||||
ruleId: rule.id,
|
||||
ruleName: rule.name,
|
||||
score,
|
||||
weight: rule.weight
|
||||
});
|
||||
throw insertError;
|
||||
}
|
||||
} else {
|
||||
console.log(`⚠️ 找不到規則: ${ruleName}`);
|
||||
console.log('可用規則:', rules.map((r: any) => r.name));
|
||||
}
|
||||
} else {
|
||||
console.log(`⚠️ 跳過無效評分: ${ruleName} = ${score}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 驗證插入結果
|
||||
const insertedDetails = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT * FROM judge_score_details WHERE judge_score_id = ?',
|
||||
[finalJudgeScoreId]
|
||||
);
|
||||
console.log('🔍 插入後的評分詳情數量:', insertedDetails.length);
|
||||
console.log('🔍 插入後的評分詳情:', insertedDetails);
|
||||
|
||||
// 返回完整的評分記錄
|
||||
return await this.getJudgeScoreById(finalJudgeScoreId);
|
||||
|
||||
|
Reference in New Issue
Block a user