From 80e9bb65214597727631d9e77f5126cdfe3a6889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A3=E4=BA=9B=E8=8A=B1=E5=84=BF?= <1156921458@qq.com> Date: Tue, 13 May 2025 19:09:52 +0800 Subject: [PATCH] .. --- .../controller/ActScoreEnterController.java | 68 +++++++++---------- .../activity/models/ActItemGroupScore.java | 3 +- .../views/platform/activity/group/index.html | 9 ++- .../views/platform/activity/group/viewInfo.js | 2 +- .../platform/activity/scoreEntry/index.html | 49 ++----------- 5 files changed, 46 insertions(+), 85 deletions(-) diff --git a/backend/src/main/java/com/budwk/app/module/activity/controller/ActScoreEnterController.java b/backend/src/main/java/com/budwk/app/module/activity/controller/ActScoreEnterController.java index 52724f7..0e68f3c 100644 --- a/backend/src/main/java/com/budwk/app/module/activity/controller/ActScoreEnterController.java +++ b/backend/src/main/java/com/budwk/app/module/activity/controller/ActScoreEnterController.java @@ -101,40 +101,40 @@ public class ActScoreEnterController { @Aop(TransAop.READ_COMMITTED) @ApiOperation(value = "保存成绩", nickname = "/save-score", httpMethod = "POST") public Result saveScore(ActItemScoreVo actItemScoreVo) { - List itemList = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", actItemScoreVo.getActivityId())); -// dao.clear(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getActivityId, "=", actItemScoreVo.getActivityId())); - List activityItemScores = new ArrayList<>(); - actItemScoreVo.getData().forEach(item -> { - itemList.forEach(i -> { - ActItemGroupScore score = new ActItemGroupScore(); - NutMap data = item.getAs(i.getId().toString(), NutMap.class); - if (Lang.isNotEmpty(data)) { - String totalScore = StrUtil.isNotEmpty(data.getString("totalScore")) ? data.getString("totalScore") : "0"; - score.setScore(new BigDecimal(totalScore)); - int totalRank = data.getInt("totalRank", 0); - score.setRanking(totalRank); - score.setId(data.getLong("id")); - } else { - score.setScore(new BigDecimal(0)); - score.setRanking(0); - } - score.setItemId(i.getId()); - score.setActivityId(actItemScoreVo.getActivityId()); - score.setGroupId(item.getLong("groupId")); - activityItemScores.add(score); - }); - }); - dao.update(activityItemScores); - - // 更新队伍得分及排名 - List groups = dao.query(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", actItemScoreVo.getActivityId())); - for (ActGroup group : groups) { - List groupScores = activityItemScores.stream().filter(item -> item.getGroupId().equals(group.getId())).collect(Collectors.toList()); - groupScores.stream().map(v -> v.getScore()).reduce(BigDecimal::add).ifPresent(group::setTotalScore); - } - groups.sort(Comparator.comparing(ActGroup::getTotalScore).reversed()); - IntStream.range(0, groups.size()).forEach(i -> groups.get(i).setTotalRank(i + 1)); - dao.update(groups, "totalScore|totalRank"); +// List itemList = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", actItemScoreVo.getActivityId())); +//// dao.clear(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getActivityId, "=", actItemScoreVo.getActivityId())); +// List activityItemScores = new ArrayList<>(); +// actItemScoreVo.getData().forEach(item -> { +// itemList.forEach(i -> { +// ActItemGroupScore score = new ActItemGroupScore(); +// NutMap data = item.getAs(i.getId().toString(), NutMap.class); +// if (Lang.isNotEmpty(data)) { +// String totalScore = StrUtil.isNotEmpty(data.getString("totalScore")) ? data.getString("totalScore") : "0"; +// score.setScore(new BigDecimal(totalScore)); +// int totalRank = data.getInt("totalRank", 0); +// score.setRanking(totalRank); +// score.setId(data.getLong("id")); +// } else { +// score.setScore(new BigDecimal(0)); +// score.setRanking(0); +// } +// score.setItemId(i.getId()); +// score.setActivityId(actItemScoreVo.getActivityId()); +// score.setGroupId(item.getLong("groupId")); +// activityItemScores.add(score); +// }); +// }); +// dao.update(activityItemScores); +// +// // 更新队伍得分及排名 +// List groups = dao.query(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", actItemScoreVo.getActivityId())); +// for (ActGroup group : groups) { +// List groupScores = activityItemScores.stream().filter(item -> item.getGroupId().equals(group.getId())).collect(Collectors.toList()); +// groupScores.stream().map(v -> v.getScore()).reduce(BigDecimal::add).ifPresent(group::setTotalScore); +// } +// groups.sort(Comparator.comparing(ActGroup::getTotalScore).reversed()); +// IntStream.range(0, groups.size()).forEach(i -> groups.get(i).setTotalRank(i + 1)); +// dao.update(groups, "totalScore|totalRank"); return Result.success(); } diff --git a/backend/src/main/java/com/budwk/app/module/activity/models/ActItemGroupScore.java b/backend/src/main/java/com/budwk/app/module/activity/models/ActItemGroupScore.java index 2a1c91d..ff4bab3 100644 --- a/backend/src/main/java/com/budwk/app/module/activity/models/ActItemGroupScore.java +++ b/backend/src/main/java/com/budwk/app/module/activity/models/ActItemGroupScore.java @@ -45,5 +45,6 @@ public class ActItemGroupScore extends BaseModel { @Column @Comment("队伍排名") - private Integer ranking; + @ColDefine(type = ColType.VARCHAR, width = 50) + private String ranking; } diff --git a/backend/src/main/resources/views/platform/activity/group/index.html b/backend/src/main/resources/views/platform/activity/group/index.html index 7b33168..57901a1 100644 --- a/backend/src/main/resources/views/platform/activity/group/index.html +++ b/backend/src/main/resources/views/platform/activity/group/index.html @@ -78,18 +78,17 @@ layout("/layouts/platform_1.html"){ - - - + + + - + diff --git a/backend/src/main/resources/views/platform/activity/group/viewInfo.js b/backend/src/main/resources/views/platform/activity/group/viewInfo.js index 49615b6..c2648f8 100644 --- a/backend/src/main/resources/views/platform/activity/group/viewInfo.js +++ b/backend/src/main/resources/views/platform/activity/group/viewInfo.js @@ -9,7 +9,7 @@ const VIEW_INFO = { diff --git a/backend/src/main/resources/views/platform/activity/scoreEntry/index.html b/backend/src/main/resources/views/platform/activity/scoreEntry/index.html index f9b3dcb..73e02f7 100644 --- a/backend/src/main/resources/views/platform/activity/scoreEntry/index.html +++ b/backend/src/main/resources/views/platform/activity/scoreEntry/index.html @@ -95,7 +95,7 @@ layout("/layouts/platform_1.html"){ @@ -236,51 +236,14 @@ layout("/layouts/platform_1.html"){ let record = this.itemScoreList.find(score => score.itemId === itemId && score.groupId === groupId ) - - // 如果没有找到,创建一个新记录 - if (!record) { - record = { - activityId: this.pageForm.activityId, - itemId: itemId, - groupId: groupId, - score: null, - ranking: null, - rankingObj: null, - remark: "" - } - this.itemScoreList.push(record) - } - - // 确保remark字段存在 - if (!record.hasOwnProperty("remark")) { - record.remark = "" - } - - // 确保rankingObj字段存在 - if (!record.hasOwnProperty("rankingObj")) { - record.rankingObj = record.ranking - } - return record }, // 更新分数 updateScore(itemId, groupId) { const record = this.getScoreRecord(itemId, groupId) - const rankingValue = record.rankingObj - - // 同步ranking字段和rankingObj字段 - record.ranking = rankingValue - - if (rankingValue) { - // 查找对应名次的分数 - const rankScore = this.rankScoreOptions[rankingValue - 1] - if (rankScore) { - record.score = rankScore.score - } - } else { - record.score = null - } + const score = this.rankScoreOptions.find(v=>v.ranking === record.ranking)?.score + record.score = score }, // 保存单个项目的分数 @@ -335,9 +298,9 @@ layout("/layouts/platform_1.html"){ async activityChange() { this.loading = true try { + await this.listItemScore() await this.listGroup() await this.listItem() - await this.listItemScore() } catch (error) { console.error(error) } finally { @@ -364,9 +327,7 @@ layout("/layouts/platform_1.html"){