From 51ed62dfe590a139a908dc798d3ffdc8a4928f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Tue, 22 Sep 2026 10:48:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B4=A8=E9=87=8F=E8=A3=81?= =?UTF-8?q?=E5=88=A4=E8=A7=84=E5=AE=9A=E8=B5=9B=E6=89=93=E5=88=86=E4=B8=BA?= =?UTF-8?q?0=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/prescribed_execution_rule.dart | 12 ++++++++++ .../controllers/scoring_controller.dart | 16 ++++++++++--- test/score_item_key_matcher_test.dart | 23 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/core/models/prescribed_execution_rule.dart b/lib/core/models/prescribed_execution_rule.dart index 152e894..a94297e 100644 --- a/lib/core/models/prescribed_execution_rule.dart +++ b/lib/core/models/prescribed_execution_rule.dart @@ -20,6 +20,18 @@ class ExecutionScoreCriterion { } abstract final class PrescribedExecutionRuleCatalog { + /// 服务端规定赛评分项编码到平板控件键的映射。 + /// 按编码匹配可避免“动作的准确性”与“动作准确性”等文案差异丢分。 + static const serverItemAliases = { + 'CQ_ACCURACY': '动作准确性', + 'CQ_PROFICIENCY': '动作熟练性', + 'CQ_SYNCHRONY': '动作合拍性', + // 兼容内置规则定义中的旧编码,已部署数据使用 CQ_SYNCHRONY。 + 'CQ_SYNCHRONIZATION': '动作合拍性', + 'CQ_ABILITY_CONSISTENCY': '运动能力一致性', + 'CQ_SKILL_CONSISTENCY': '表演技巧一致性', + }; + static const individual = [ ExecutionScoreCriterion( name: '动作准确性', diff --git a/lib/modules/scoring/controllers/scoring_controller.dart b/lib/modules/scoring/controllers/scoring_controller.dart index 6898ccc..70a222b 100644 --- a/lib/modules/scoring/controllers/scoring_controller.dart +++ b/lib/modules/scoring/controllers/scoring_controller.dart @@ -379,7 +379,13 @@ class ScoringController extends GetxController { if (profile.role == ScoreRole.creative || profile.role == ScoreRole.execution) { - final key = _matchingKey(performanceItems.keys, item.name); + final key = _matchingKey( + performanceItems.keys, + '${item.code} ${item.name}', + aliases: profile.role == ScoreRole.execution + ? PrescribedExecutionRuleCatalog.serverItemAliases + : const {}, + ); if (key != null) { performanceItems[key] = score.clamp(0, performanceItemMaximum(key)); _itemUiKeys[item.code] = key; @@ -460,8 +466,12 @@ class ScoringController extends GetxController { return codeMatch.group(1) == '0_5' ? '0.5' : codeMatch.group(1); } - String? _matchingKey(Iterable keys, String source) { - return ScoreItemKeyMatcher.match(keys, source); + String? _matchingKey( + Iterable keys, + String source, { + Map aliases = const {}, + }) { + return ScoreItemKeyMatcher.match(keys, source, aliases: aliases); } String? _requiredElementKeyOf(JudgeScoreItem item) { diff --git a/test/score_item_key_matcher_test.dart b/test/score_item_key_matcher_test.dart index 3d6d5f2..c244b02 100644 --- a/test/score_item_key_matcher_test.dart +++ b/test/score_item_key_matcher_test.dart @@ -2,9 +2,32 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:yd_pattern_scoring_system/core/models/deduction_rule_item.dart'; import 'package:yd_pattern_scoring_system/core/models/judge_account.dart'; import 'package:yd_pattern_scoring_system/core/models/elite_scoring_rule.dart'; +import 'package:yd_pattern_scoring_system/core/models/prescribed_execution_rule.dart'; import 'package:yd_pattern_scoring_system/core/network/score_item_key_matcher.dart'; void main() { + test('规定赛完成质量项按稳定编码匹配平板控件', () { + const keys = ['动作准确性', '动作熟练性', '动作合拍性']; + const aliases = PrescribedExecutionRuleCatalog.serverItemAliases; + + expect( + ScoreItemKeyMatcher.match(keys, 'CQ_ACCURACY 动作的准确性', aliases: aliases), + '动作准确性', + ); + expect( + ScoreItemKeyMatcher.match( + keys, + 'CQ_PROFICIENCY 动作的熟练性', + aliases: aliases, + ), + '动作熟练性', + ); + expect( + ScoreItemKeyMatcher.match(keys, 'CQ_SYNCHRONY 动作的合拍性', aliases: aliases), + '动作合拍性', + ); + }); + final keys = DeductionRuleCatalog.forCompetition( CompetitionKind.doubleDutch, ).map((item) => item.key).toList();