feat: add score VO with deduction items and player number assignment

- Add selectScoreVOPage for score list with deduction items text
- Add chiefJudgeScore and scoreStatus fields to MartialScoreVO
- Add player number assignment in saveAndLockSchedule method

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
2026-01-07 14:56:25 +08:00
parent a262ca9279
commit e0d3572e34
7 changed files with 119 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.martial.pojo.entity.MartialScore;
import org.springblade.modules.martial.pojo.vo.MartialScoreVO;
import org.springblade.modules.martial.service.IMartialScoreService;
import org.springframework.web.bind.annotation.*;
@@ -43,8 +44,8 @@ public class MartialScoreController extends BladeController {
*/
@GetMapping("/list")
@Operation(summary = "分页列表", description = "分页查询")
public R<IPage<MartialScore>> list(MartialScore score, Query query) {
IPage<MartialScore> pages = scoreService.page(Condition.getPage(query), Condition.getQueryWrapper(score));
public R<IPage<MartialScoreVO>> list(MartialScore score, Query query) {
IPage<MartialScoreVO> pages = scoreService.selectScoreVOPage(Condition.getPage(query), score);
return R.data(pages);
}

View File

@@ -1,7 +1,10 @@
package org.springblade.modules.martial.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.martial.pojo.entity.MartialScore;
import org.springblade.modules.martial.pojo.vo.MartialScoreVO;
/**
* Score Mapper 接口
@@ -10,4 +13,6 @@ import org.springblade.modules.martial.pojo.entity.MartialScore;
*/
public interface MartialScoreMapper extends BaseMapper<MartialScore> {
IPage<MartialScoreVO> selectScoreVOPage(IPage<MartialScoreVO> page, @Param("score") MartialScore score);
}

View File

@@ -2,4 +2,43 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.martial.mapper.MartialScoreMapper">
<select id="selectScoreVOPage" resultType="org.springblade.modules.martial.pojo.vo.MartialScoreVO">
SELECT
s.*,
a.player_name as playerName,
a.team_name as teamName,
a.id_card as idCard,
a.player_no as playerNo,
p.project_name as projectName,
v.venue_name as venueName,
r.chief_judge_score as chiefJudgeScore,
r.score_status as scoreStatus,
(SELECT GROUP_CONCAT(d.item_name SEPARATOR ', ')
FROM martial_deduction_item d
WHERE FIND_IN_SET(d.id, REPLACE(REPLACE(s.deduction_items, '[', ''), ']', ''))
) as deductionItemsText
FROM martial_score s
LEFT JOIN martial_athlete a ON s.athlete_id = a.id AND a.is_deleted = 0
LEFT JOIN martial_project p ON s.project_id = p.id AND p.is_deleted = 0
LEFT JOIN martial_venue v ON s.venue_id = v.id AND v.is_deleted = 0
LEFT JOIN martial_result r ON s.athlete_id = r.athlete_id AND s.project_id = r.project_id AND r.is_deleted = 0
WHERE s.is_deleted = 0
<if test="score.competitionId != null">
AND s.competition_id = #{score.competitionId}
</if>
<if test="score.athleteId != null">
AND s.athlete_id = #{score.athleteId}
</if>
<if test="score.projectId != null">
AND s.project_id = #{score.projectId}
</if>
<if test="score.judgeId != null">
AND s.judge_id = #{score.judgeId}
</if>
<if test="score.venueId != null">
AND s.venue_id = #{score.venueId}
</if>
ORDER BY s.create_time DESC
</select>
</mapper>

View File

@@ -47,4 +47,35 @@ public class MartialScoreVO extends MartialScore {
@Schema(description = "状态文本")
private String statusText;
/**
* 主裁判确认分数
*/
@Schema(description = "主裁判确认分数")
private java.math.BigDecimal chiefJudgeScore;
/**
* 评分状态 (0-待评分, 1-裁判已评分, 2-主裁判已确认)
*/
@Schema(description = "评分状态")
private Integer scoreStatus;
/**
* 队伍名称
*/
@Schema(description = "队伍名称")
private String teamName;
/**
* 身份证
*/
@Schema(description = "身份证")
private String idCard;
/**
* 选手编号
*/
@Schema(description = "选手编号")
private String playerNo;
}

View File

@@ -1,8 +1,10 @@
package org.springblade.modules.martial.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.martial.pojo.dto.MiniScoreModifyDTO;
import org.springblade.modules.martial.pojo.entity.MartialScore;
import org.springblade.modules.martial.pojo.vo.MartialScoreVO;
import org.springblade.modules.martial.pojo.vo.MiniScoreDetailVO;
import java.math.BigDecimal;
@@ -15,6 +17,11 @@ import java.util.List;
*/
public interface IMartialScoreService extends IService<MartialScore> {
/**
* 分页查询评分记录(包含关联字段)
*/
IPage<MartialScoreVO> selectScoreVOPage(IPage<MartialScoreVO> page, MartialScore score);
/**
* Task 2.2: 分数范围验证
*/
@@ -37,17 +44,11 @@ public interface IMartialScoreService extends IService<MartialScore> {
/**
* 小程序接口:获取评分详情
*
* @param athleteId 选手ID
* @return 评分详情(选手信息+所有评委评分+修改记录)
*/
MiniScoreDetailVO getScoreDetailForMini(Long athleteId);
/**
* 小程序接口:修改评分(主裁判)
*
* @param dto 修改信息
* @return 修改成功/失败
*/
boolean modifyScoreByAdmin(MiniScoreModifyDTO dto);

View File

@@ -6,6 +6,8 @@ import org.springblade.modules.martial.excel.ScheduleExportExcel;
import org.springblade.modules.martial.mapper.MartialScheduleDetailMapper;
import org.springblade.modules.martial.mapper.MartialScheduleGroupMapper;
import org.springblade.modules.martial.mapper.MartialScheduleParticipantMapper;
import org.springblade.modules.martial.mapper.MartialAthleteMapper;
import org.springblade.modules.martial.pojo.entity.MartialAthlete;
import org.springblade.modules.martial.pojo.dto.CompetitionGroupDTO;
import org.springblade.modules.martial.pojo.dto.ParticipantDTO;
import org.springblade.modules.martial.pojo.dto.SaveScheduleDraftDTO;
@@ -53,6 +55,8 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
@Autowired
private MartialScheduleParticipantMapper scheduleParticipantMapper;
@Autowired
private MartialAthleteMapper athleteMapper;
/**
* Task 3.3: 导出赛程表
@@ -456,6 +460,7 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveAndLockSchedule(Long competitionId) {
log.info("=== saveAndLockSchedule 开始 === competitionId: {}", competitionId);
// 1. 查询所有分组
List<MartialScheduleGroup> groups = scheduleGroupMapper.selectList(
new QueryWrapper<MartialScheduleGroup>()
@@ -478,9 +483,32 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
.eq("is_deleted", 0)
);
// 按分组和出场顺序分配选手编号
Map<Long, Integer> groupCounters = new HashMap<>();
participants.sort((a, b) -> {
int groupCompare = a.getScheduleGroupId().compareTo(b.getScheduleGroupId());
if (groupCompare != 0) return groupCompare;
return Integer.compare(a.getPerformanceOrder() != null ? a.getPerformanceOrder() : 0,
b.getPerformanceOrder() != null ? b.getPerformanceOrder() : 0);
});
for (MartialScheduleParticipant participant : participants) {
participant.setScheduleStatus("completed");
scheduleParticipantMapper.updateById(participant);
// 分配选手编号
if (participant.getParticipantId() != null) {
Long groupId = participant.getScheduleGroupId();
int counter = groupCounters.getOrDefault(groupId, 0) + 1;
groupCounters.put(groupId, counter);
// 更新选手编号 (格式: 分组序号-出场序号)
MartialAthlete athlete = athleteMapper.selectById(participant.getParticipantId());
if (athlete != null && (athlete.getPlayerNo() == null || athlete.getPlayerNo().isEmpty())) {
athlete.setPlayerNo(String.format("%03d", counter));
athleteMapper.updateById(athlete);
}
}
}
return true;

View File

@@ -9,6 +9,8 @@ import org.springblade.modules.martial.pojo.dto.MiniScoreModifyDTO;
import org.springblade.modules.martial.pojo.entity.MartialAthlete;
import org.springblade.modules.martial.pojo.entity.MartialJudge;
import org.springblade.modules.martial.pojo.entity.MartialScore;
import org.springblade.modules.martial.pojo.vo.MartialScoreVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.martial.mapper.MartialScoreMapper;
import org.springblade.modules.martial.pojo.vo.MiniScoreDetailVO;
import org.springblade.modules.martial.service.IMartialAthleteService;
@@ -448,4 +450,8 @@ public class MartialScoreServiceImpl extends ServiceImpl<MartialScoreMapper, Mar
return athleteUpdated && recordSaved && resultSaved;
}
@Override
public IPage<MartialScoreVO> selectScoreVOPage(IPage<MartialScoreVO> page, MartialScore score) {
return baseMapper.selectScoreVOPage(page, score);
}
}