server_commit

This commit is contained in:
zhengziru
2025-11-03 13:57:23 +08:00
parent 9bbfade412
commit ba6debb4de
9 changed files with 99 additions and 21 deletions
@@ -22,7 +22,9 @@ import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zhf
@@ -165,7 +167,56 @@ public class ClientGroupController {
@At("/list-group-rank/?")
@SaCheckLogin(type = StpClientUtil.TYPE)
public Result listGroupRank(Long activityId) {
List<ActGroup> groupList = dao.query(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", activityId).desc(ActGroup::getTotalScore));
return Result.success(groupList);
if (activityId == null) {
return Result.error("活动ID不能为空");
}
Sql sql = Sqls.create("""
SELECT
t1.itemId,
t1.groupId,
t1.score,
t1.ranking,
t2.groupName\s
FROM
act_item_group_score t1
LEFT JOIN act_group t2 ON t2.id = t1.groupId\s
WHERE
t1.activityId = @activityId
""");
sql.setParam("activityId", activityId);
List<NutMap> list = clientActivityService.listMap(sql);
// 2. 按 groupId 分组
Map<String, List<NutMap>> groupMap = list.stream()
.collect(Collectors.groupingBy(v -> v.getString("groupId")));
// 3. 把每组封装成 VO,算总分,排序,填总排名
List<ActGroup> rankList = new ArrayList<>();
groupMap.forEach((groupIdStr, rows) -> {
// 3.1 组总分
BigDecimal totalScore = rows.stream()
.map(r -> r.getDouble("score", 0d)) // 先拿 double
.map(BigDecimal::valueOf)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 3.2 基本信息
ActGroup vo = new ActGroup();
vo.setActivityId(activityId);
vo.setId(Long.valueOf(groupIdStr));
vo.setGroupName(rows.get(0).getString("groupName"));
vo.setTotalScore(totalScore);
rankList.add(vo);
});
// 3.3 排序:总分降序 → groupId 升序(总分相同按 groupId 升序)
rankList.sort(
Comparator.comparing(ActGroup::getTotalScore).reversed()
.thenComparing(ActGroup::getId)
);
// List<ActGroup> groupList = dao.query(ActGroup.class, Cnd.where(ActGroup::getActivityId, "=", activityId).desc(ActGroup::getTotalScore));
return Result.success(rankList);
}
}
@@ -106,7 +106,7 @@ public class ActBigScreenController {
itemScores.add(scoreItem);
}
ArrayList<Map<String, Object>> groupScores = new ArrayList<>(groupMap.values());
List<Map<String, Object>> groupScores = new ArrayList<>(groupMap.values());
return Result.success(groupScores);
}
@@ -23,6 +23,7 @@ import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
@IocBean
@At("/platform/activity/scoreEntry")
@@ -106,7 +107,8 @@ public class ActScoreEntryController {
//在找出这个队伍下面所有的分数
List<ActItemGroupScore> groupScoreList = scoreList.stream().filter(itemScore -> itemScore.getGroupId().equals(groupId)).toList();
BigDecimal totalScore = groupScoreList.stream()
.map(ActItemGroupScore::getScore) // 提取每个 score(BigDecimal)
.map(ActItemGroupScore::getScore)
.filter(Objects::nonNull) // 把 null 踢掉
.reduce(BigDecimal.ZERO, BigDecimal::add);
dao.update(ActGroup.class, Chain.make("totalScore", totalScore), Cnd.where(ActGroup::getId, "=", groupId));
}
@@ -242,6 +242,7 @@ public class ActUserController {
add(new ExcelExportEntity("所属单位", "unitName", 20));
add(new ExcelExportEntity("报名时间", "signUpTime2", 20));
add(new ExcelExportEntity("是否签到", "isSignInDesc", 20));
add(new ExcelExportEntity("是否住宿", "isStayDesc", 20));
// add(new ExcelExportEntity("是否展示才艺", "isShowSkillDesc", 20));
// add(new ExcelExportEntity("才艺名称", "skillName", 20));
// add(new ExcelExportEntity("所需器材", "equip", 20));
@@ -251,6 +252,7 @@ public class ActUserController {
add(new ExcelExportEntity("接站地址", "stationAddress", 20));
add(new ExcelExportEntity("是否参加茶叙会", "isPartyDesc", 20));
add(new ExcelExportEntity("是否联络人", "isSIgnUpUser", 20));
}};
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String((activity.getTitle() + "报名数据表.xlsx").getBytes(StandardCharsets.UTF_8), "ISO8859-1"));
@@ -59,6 +59,10 @@ public class ActUserServiceImpl extends BaseServiceImpl<ActUser> implements ActU
WHEN 1 THEN '是'
WHEN 0 THEN ''
END AS isPartyDesc,
CASE
WHEN u.signUpUserId = u.userId THEN
'是' ELSE ''
END AS isSIgnUpUser,
act.`title` AS activityName
FROM
act_user u
@@ -75,6 +79,7 @@ public class ActUserServiceImpl extends BaseServiceImpl<ActUser> implements ActU
}
cnd.andEX("u.isSignIn", "=", pageForm.getIsSignIn());
cnd.andEX("u.unitId", "=", pageForm.getUnitId());
cnd.asc("u.unitName");
sql.setCondition(cnd);
return sql;
}
@@ -263,7 +263,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<Sys_user> implements Sys
}
String hashedPassword = PwdUtil.getPassword(passowrd, user.getSalt());
if (!Strings.sNull(hashedPassword).equalsIgnoreCase(user.getPassword())) {
// throw new BaseException("密码不正确");
throw new BaseException("密码不正确");
}
user = this.fetchLinks(user, "unit");
return user;
@@ -1646,8 +1646,14 @@
computed: {
sortedTeams() {
if (!this.teamScores) return []
// 根据总分排序
return [...this.teamScores].sort((a, b) => this.calculateTotalScore(b) - this.calculateTotalScore(a))
return [...this.teamScores].sort((a, b) => {
const scoreA = this.calculateTotalScore(a);
const scoreB = this.calculateTotalScore(b);
if (scoreB !== scoreA) {
return scoreB - scoreA; // 总分降序
}
return a.groupId - b.groupId; // 总分相同按 groupId 升序
});
}
},
created() {
@@ -83,7 +83,7 @@ layout("/layouts/platform_1.html"){
<el-table-column label="性别" prop="sex" width="60px" fixed="left"></el-table-column>
<el-table-column label="体重(kg)" prop="weight" width="100px"></el-table-column>
<el-table-column label="职务" prop="position" width="150px"></el-table-column>
<el-table-column label="身份证号码" prop="idCard" width="180px"></el-table-column>
<!-- <el-table-column label="身份证号码" prop="idCard" width="180px"></el-table-column>-->
<el-table-column label="联系方式" prop="phone" width="130px"></el-table-column>
<el-table-column label="单位" prop="unitName" width="150px"></el-table-column>
<el-table-column label="报名时间" prop="signUpTime" width="150px"></el-table-column>
@@ -112,6 +112,11 @@ layout("/layouts/platform_1.html"){
{{row.isParty ? '是':''}}
</template>
</el-table-column>
<el-table-column label="是否联络人" prop="isSIgnUpUser">
<template slot-scope="{row}">
{{row.isSIgnUpUser ? '是':''}}
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200">
<template #default="scope">
<el-button type="text" @click="openModify(scope.row)">修改</el-button>
@@ -131,7 +136,8 @@ layout("/layouts/platform_1.html"){
</el-form-item>
<el-form-item label="参加单位" prop="unitName">
<el-select placeholder="请选择所属单位"
style="width: 100%;" clearable
style="width: 100%;"
clearable filterable
@change="setFormDataUnit"
v-model="formData.unitId">
<el-option :label="item.name" :value="item.id"
@@ -173,12 +179,15 @@ layout("/layouts/platform_1.html"){
show-word-limit placeholder="请输入联系方式"></el-input>
</template>
</el-table-column>
<el-table-column label="身份证件号" prop="idCard" width="250">
<template slot-scope="{row}">
<el-input v-model="row.idCard" maxlength="18" type="text"
show-word-limit placeholder="请输入身份证件号"></el-input>
</template>
</el-table-column>
<el-form-item label="体重(kg)" prop="weight">
<el-input-number v-model="modifyForm.weight"></el-input-number>
</el-form-item>
<!-- <el-table-column label="身份证件号" prop="idCard" width="250">-->
<!-- <template slot-scope="{row}">-->
<!-- <el-input v-model="row.idCard" maxlength="18" type="text"-->
<!-- show-word-limit placeholder="请输入身份证件号"></el-input>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="职务" prop="position" width="200">
<template slot-scope="{row}">
<el-input v-model="row.position" maxlength="100"
@@ -229,9 +238,12 @@ layout("/layouts/platform_1.html"){
<el-form-item label="联系方式" prop="phone">
<el-input v-model="modifyForm.phone"></el-input>
</el-form-item>
<el-form-item label="身份证件号" prop="idCard">
<el-input v-model="modifyForm.idCard"></el-input>
<el-form-item label="体重(kg)" prop="weight">
<el-input-number v-model="modifyForm.weight"></el-input-number>
</el-form-item>
<!-- <el-form-item label="身份证件号" prop="idCard">-->
<!-- <el-input v-model="modifyForm.idCard"></el-input>-->
<!-- </el-form-item>-->
<el-form-item label="职务" prop="position">
<el-input v-model="modifyForm.position"></el-input>
</el-form-item>
@@ -415,7 +427,7 @@ layout("/layouts/platform_1.html"){
{ key: 'userName', message: '姓名不能为空' },
{ key: 'sex', message: '性别不能为空' },
{ key: 'phone', message: '联系方式不能为空' },
{ key: 'idCard', message: '身份证件号不能为空' },
// { key: 'idCard', message: '身份证件号不能为空' },
{ key: 'position', message: '职务不能为空' }
];
@@ -90,8 +90,8 @@
</t-radio-group>
</t-form-item>
<t-form-item label="体重(KG)" :name="`userList[${index}].weight`"
:rules="[{required:true,message: '请输入体重'}]">
<t-input placeholder="0.00" suffix="拔河比赛分组需要" type="number" borderless v-model="user.weight"></t-input>
:rules="[{required:true,message: '请输入体重拔河比赛分组需要'}]">
<t-input placeholder="拔河比赛分组需要" type="number" borderless v-model="user.weight"></t-input>
</t-form-item>
<t-form-item label="单位名称">
<t-input v-model="user.unitName" borderless placeholder="请输入单位名称" readonly></t-input>