|
@@ -32,6 +32,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.vote.system.util.ConstantUtils.IS_DELETED_0;
|
|
|
+
|
|
|
/**
|
|
|
* @author MacBook
|
|
|
* @description 针对表【vote_evaluation_tasks(评选任务表)】的数据库操作Service实现
|
|
@@ -76,53 +78,75 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
@Override
|
|
|
public VoteEvaluationTasksCountVo getStatistics(VoteEvaluationTasksDto voteEvaluationTasksDto) {
|
|
|
VoteEvaluationTasksCountVo evaluationTasksVo = new VoteEvaluationTasksCountVo();
|
|
|
-
|
|
|
+ if (voteEvaluationTasksDto == null || voteEvaluationTasksDto.getEventId() == null || voteEvaluationTasksDto.getWorkSettingsId() == null) {
|
|
|
+ return evaluationTasksVo;
|
|
|
+ }
|
|
|
// 构建查询条件
|
|
|
LambdaQueryWrapper<VoteSubmission> submissionWrapper = new LambdaQueryWrapper<>();
|
|
|
- submissionWrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId()).eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId());
|
|
|
+ submissionWrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
+ .eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
List<VoteSubmission> submissions = voteSubmissionMapper.selectList(submissionWrapper);
|
|
|
evaluationTasksVo.setSubMissionCount(submissions.size()); // 作品数
|
|
|
-
|
|
|
// 统计已完成的总分数
|
|
|
BigDecimal totalScore = BigDecimal.ZERO; // 使用 BigDecimal 来处理可能的浮点数运算
|
|
|
|
|
|
if (!submissions.isEmpty()) {
|
|
|
- // 从 submissions 中提取出所有的 submissionId
|
|
|
- List<Long> submissionIds = submissions.stream().map(VoteSubmission::getId).collect(Collectors.toList());
|
|
|
+ List<Long> submissionIds = submissions.stream()
|
|
|
+ .map(VoteSubmission::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
// 创建查询包装器,用于查询 VoteEventRegistrationWorkScores 表
|
|
|
LambdaQueryWrapper<VoteEventRegistrationWorkScores> scoresWrapper = new LambdaQueryWrapper<>();
|
|
|
- scoresWrapper.in(VoteEventRegistrationWorkScores::getSubmissionId, submissionIds);
|
|
|
-
|
|
|
- // 执行查询,获取所有与 submissionIds 相关的评分记录
|
|
|
- List<VoteEventRegistrationWorkScores> workScores = voteEventRegistrationWorkScoresMapper.selectList(scoresWrapper);
|
|
|
|
|
|
- // 统计所有已完成的评分记录的总分数
|
|
|
- totalScore = workScores.stream().filter(scores -> scores.getScore() != null && scores.getScore().compareTo(BigDecimal.ZERO) > 0).map(VoteEventRegistrationWorkScores::getScore).reduce(BigDecimal.ZERO, BigDecimal::add); // 计算总分数
|
|
|
+ // 检查 submissionIds 是否为空
|
|
|
+ if (!submissionIds.isEmpty()) {
|
|
|
+ scoresWrapper.in(VoteEventRegistrationWorkScores::getSubmissionId, submissionIds)
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
+ // 执行查询,获取所有与 submissionIds 相关的评分记录
|
|
|
+ List<VoteEventRegistrationWorkScores> workScores = voteEventRegistrationWorkScoresMapper.selectList(scoresWrapper);
|
|
|
+ totalScore = workScores.stream()
|
|
|
+ .filter(scores -> scores.getScore() != null && scores.getScore().compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ .map(VoteEventRegistrationWorkScores::getScore)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
}
|
|
|
evaluationTasksVo.setFinishedCount(totalScore);
|
|
|
|
|
|
// 评审专家数量
|
|
|
VoteEventEvaluationRounds evaluationRounds = voteEventEvaluationRoundsMapper.selectById(voteEvaluationTasksDto.getRoundId());
|
|
|
- String[] judgeIds = evaluationRounds.getJudges().split(",");
|
|
|
- evaluationTasksVo.setJudgesCount(judgeIds.length);
|
|
|
-
|
|
|
- // 统计已完成评审的专家数
|
|
|
- int finishedJudgesCount = 0;
|
|
|
- if (judgeIds.length > 0) {
|
|
|
- LambdaQueryWrapper<VoteEvaluationTasks> tasksWrapper = new LambdaQueryWrapper<>();
|
|
|
- tasksWrapper.in(VoteEvaluationTasks::getJudgeId, Arrays.asList(judgeIds)).eq(VoteEvaluationTasks::getStatus, 1);
|
|
|
- List<Long> submissionIds = voteEvaluationTasksMapper.selectList(tasksWrapper).stream().map(VoteEvaluationTasks::getSubmissionId).collect(Collectors.toList());
|
|
|
- //过滤掉不是该活动 该类型 该轮次的作品
|
|
|
- LambdaQueryWrapper<VoteSubmission> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
- .eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
- .eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId())
|
|
|
- .in(VoteSubmission::getId, submissionIds);
|
|
|
- finishedJudgesCount = voteSubmissionMapper.selectList(wrapper).size();
|
|
|
-
|
|
|
+ if (evaluationRounds != null && evaluationRounds.getJudges() != null) {
|
|
|
+ String[] judgeIds = evaluationRounds.getJudges().split(",");
|
|
|
+ evaluationTasksVo.setJudgesCount(judgeIds.length);
|
|
|
+
|
|
|
+ // 统计已完成评审的专家数
|
|
|
+ int finishedJudgesCount = 0;
|
|
|
+ if (judgeIds.length > 0) {
|
|
|
+ LambdaQueryWrapper<VoteEvaluationTasks> tasksWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tasksWrapper.in(VoteEvaluationTasks::getJudgeId, Arrays.asList(judgeIds))
|
|
|
+ .eq(VoteEvaluationTasks::getStatus, 1)
|
|
|
+ .eq(VoteEvaluationTasks::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
+ List<Long> submissionIds = voteEvaluationTasksMapper.selectList(tasksWrapper)
|
|
|
+ .stream()
|
|
|
+ .map(VoteEvaluationTasks::getSubmissionId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!submissionIds.isEmpty()) {
|
|
|
+ LambdaQueryWrapper<VoteSubmission> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
+ .eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId())
|
|
|
+ .in(VoteSubmission::getId, submissionIds);
|
|
|
+ List<VoteSubmission> voteSubmissions = voteSubmissionMapper.selectList(wrapper);
|
|
|
+ finishedJudgesCount = voteSubmissions.size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaluationTasksVo.setFinishedJudgesCount(finishedJudgesCount);
|
|
|
+ } else {
|
|
|
+ evaluationTasksVo.setJudgesCount(0);
|
|
|
+ evaluationTasksVo.setFinishedJudgesCount(0);
|
|
|
}
|
|
|
- evaluationTasksVo.setFinishedJudgesCount(finishedJudgesCount);
|
|
|
+
|
|
|
return evaluationTasksVo;
|
|
|
}
|
|
|
|
|
@@ -135,7 +159,7 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
*/
|
|
|
@Override
|
|
|
public IPage<VoteJudgeTaskInfoVo> selectPage(VoteEvaluationTasksDto voteEvaluationTasksDto) {
|
|
|
- //分页参数
|
|
|
+ // 分页参数
|
|
|
long pageNum = Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L);
|
|
|
long pageSize = Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L);
|
|
|
Page<VoteJudgeTaskInfoVo> page = new Page<>(pageNum, pageSize);
|
|
@@ -144,44 +168,60 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
.eq(VoteEventCompetitionZones::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
.eq(VoteEventCompetitionZones::getRoundId, voteEvaluationTasksDto.getRoundId())
|
|
|
.eq(VoteEventCompetitionZones::getStatus, "1");
|
|
|
+
|
|
|
List<VoteEventCompetitionZones> zones = voteEventCompetitionZonesMapper.selectList(wrapper);
|
|
|
- //获取所有作品id
|
|
|
+
|
|
|
+ // 获取所有作品id
|
|
|
LambdaQueryWrapper<VoteSubmission> submissionWrapper = new LambdaQueryWrapper<>();
|
|
|
submissionWrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
.eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
.eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
- List<Long> submissionIds = voteSubmissionMapper.selectList(submissionWrapper).stream().map(VoteSubmission::getId).collect(Collectors.toList());
|
|
|
- String[] judgeIds = zones.stream()
|
|
|
+
|
|
|
+ List<Long> submissionIds = voteSubmissionMapper.selectList(submissionWrapper)
|
|
|
+ .stream()
|
|
|
+ .map(VoteSubmission::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 构建
|
|
|
+ Set<String> judgeIds = zones.stream()
|
|
|
.map(VoteEventCompetitionZones::getJudges)
|
|
|
- .filter(Objects::nonNull) // 避免空值
|
|
|
- .flatMap(judges -> Arrays.stream(judges.split(","))) // 分割每个 judge 字符串
|
|
|
- .toArray(String[]::new);
|
|
|
- // 获取专家数据和省份数据,避免频繁调用服务
|
|
|
- List<SysPlatformUser> users = Optional.ofNullable(remotePlatformUserService.processExpertList().getData()).orElse(Collections.emptyList());
|
|
|
- List<SysProvince> provinces = Optional.ofNullable(remoteSysProvinceService.getProvince().getData()).orElse(Collections.emptyList());
|
|
|
- // 初始化返回的结果集
|
|
|
- List<VoteJudgeTaskInfoVo> judgeTaskInfoList = new ArrayList<>();
|
|
|
-
|
|
|
- // 遍历每个专家ID,获取任务数、已完成数、专家名称及赛区信息
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .flatMap(judges -> Arrays.stream(judges.split(",")))
|
|
|
+ .collect(Collectors.toSet()); // Use Set to avoid duplicates
|
|
|
+
|
|
|
+ // Get expert and province data
|
|
|
+ List<SysPlatformUser> users = Optional.ofNullable(remotePlatformUserService.processExpertList().getData())
|
|
|
+ .orElse(Collections.emptyList());
|
|
|
+ List<SysProvince> provinces = Optional.ofNullable(remoteSysProvinceService.getProvince().getData())
|
|
|
+ .orElse(Collections.emptyList());
|
|
|
+
|
|
|
+ // Initialize result collection
|
|
|
+ Map<String, VoteJudgeTaskInfoVo> judgeTaskInfoMap = new HashMap<>();
|
|
|
+
|
|
|
+ // Iterate through each unique judge ID
|
|
|
for (String judgeId : judgeIds) {
|
|
|
if (judgeId == null || judgeId.trim().isEmpty()) {
|
|
|
- continue; // 跳过空的专家ID
|
|
|
+ continue; // Skip empty judge IDs
|
|
|
}
|
|
|
|
|
|
- VoteJudgeTaskInfoVo judgeTaskInfo = new VoteJudgeTaskInfoVo();
|
|
|
+ VoteJudgeTaskInfoVo judgeTaskInfo = judgeTaskInfoMap.getOrDefault(judgeId, new VoteJudgeTaskInfoVo());
|
|
|
|
|
|
- // 获取专家名称,设置默认值
|
|
|
- String judgeName = users.stream().filter(user -> judgeId.equals(user.getUserId().toString())).map(SysPlatformUser::getNickName).findFirst().orElse("未知专家");
|
|
|
+ // Get expert name
|
|
|
+ String judgeName = users.stream()
|
|
|
+ .filter(user -> judgeId.equals(user.getUserId().toString()))
|
|
|
+ .map(SysPlatformUser::getNickName)
|
|
|
+ .findFirst()
|
|
|
+ .orElse("未知专家");
|
|
|
|
|
|
- // 计算任务数和已完成任务数
|
|
|
- int taskCount = calculateTaskCount(new String[]{judgeId}, submissionIds, false);
|
|
|
- int doneTaskCount = calculateTaskCount(new String[]{judgeId}, submissionIds, true);
|
|
|
+ // Calculate task counts
|
|
|
+ int taskCount = calculateTaskCount(new String[]{judgeId}, submissionIds, false, voteEvaluationTasksDto.getRoundId());
|
|
|
+ int doneTaskCount = calculateTaskCount(new String[]{judgeId}, submissionIds, true, voteEvaluationTasksDto.getRoundId());
|
|
|
|
|
|
- // 查询专家所在的赛区及相关省份,并设置默认值
|
|
|
- Map<String, String> zonesAndProvinces = findZoneNamesAndProvincesByJudgeId(judgeId);
|
|
|
+ // Query zone and province information
|
|
|
+ Map<String, String> zonesAndProvinces = findZoneNamesAndProvincesByJudgeId(judgeId, voteEvaluationTasksDto);
|
|
|
String provinceNames = getProvinceNames(zonesAndProvinces.get("provinces"), provinces);
|
|
|
|
|
|
- // 填充信息到结果对象
|
|
|
+ // Populate information
|
|
|
judgeTaskInfo.setJudgeName(judgeName);
|
|
|
judgeTaskInfo.setJudgeId(Long.valueOf(judgeId));
|
|
|
judgeTaskInfo.setTaskCount(taskCount);
|
|
@@ -190,15 +230,18 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
judgeTaskInfo.setZonesName(Optional.ofNullable(zonesAndProvinces.get("zoneNames")).orElse("未知赛区"));
|
|
|
judgeTaskInfo.setProvince(Optional.ofNullable(provinceNames).orElse("未知省份"));
|
|
|
|
|
|
- // 加入结果集
|
|
|
- judgeTaskInfoList.add(judgeTaskInfo);
|
|
|
+ // Update the map
|
|
|
+ judgeTaskInfoMap.put(judgeId, judgeTaskInfo);
|
|
|
}
|
|
|
- page.setRecords(judgeTaskInfoList);
|
|
|
- page.setTotal(judgeTaskInfoList.size());
|
|
|
+
|
|
|
+ // Set results to page
|
|
|
+ page.setRecords(new ArrayList<>(judgeTaskInfoMap.values()));
|
|
|
+ page.setTotal(judgeTaskInfoMap.size());
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询详情
|
|
|
*
|
|
@@ -215,11 +258,13 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
// 查询评估任务
|
|
|
LambdaQueryWrapper<VoteEvaluationTasks> taskWrapper = new LambdaQueryWrapper<>();
|
|
|
taskWrapper.eq(VoteEvaluationTasks::getJudgeId, voteEvaluationTasksDto.getJudgeId());
|
|
|
+ taskWrapper.eq(VoteEvaluationTasks::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
if ("1".equals(voteEvaluationTasksDto.getType())) {
|
|
|
taskWrapper.eq(VoteEvaluationTasks::getStatus, "0");
|
|
|
} else if ("2".equals(voteEvaluationTasksDto.getType())) {
|
|
|
taskWrapper.eq(VoteEvaluationTasks::getStatus, "1");
|
|
|
}
|
|
|
+ taskWrapper.eq(VoteEvaluationTasks::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
List<VoteEvaluationTasks> tasks = voteEvaluationTasksMapper.selectList(taskWrapper);
|
|
|
|
|
|
if (tasks.isEmpty()) {
|
|
@@ -234,15 +279,16 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
.eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
.eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
List<VoteSubmission> submissions = voteSubmissionMapper.selectList(wrapper);
|
|
|
-
|
|
|
// 获取所有相关的评分信息
|
|
|
- List<Long> eventIds = submissions.stream().map(VoteSubmission::getEventId).distinct().collect(Collectors.toList());
|
|
|
- List<VoteEventRegistrationWorkScores> scoresList = voteEventRegistrationWorkScoresMapper.selectList(new LambdaQueryWrapper<VoteEventRegistrationWorkScores>().in(VoteEventRegistrationWorkScores::getSubmissionId, submissionIds).in(VoteEventRegistrationWorkScores::getEventId, eventIds).eq(VoteEventRegistrationWorkScores::getJudgeId, voteEvaluationTasksDto.getJudgeId()));
|
|
|
+ List<VoteEventRegistrationWorkScores> scoresList = voteEventRegistrationWorkScoresMapper.selectList(new LambdaQueryWrapper<VoteEventRegistrationWorkScores>()
|
|
|
+ .in(VoteEventRegistrationWorkScores::getSubmissionId, submissionIds)
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getJudgeId, voteEvaluationTasksDto.getJudgeId())
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getRoundId, voteEvaluationTasksDto.getRoundId()));
|
|
|
|
|
|
// 获取所有相关的幼儿园信息
|
|
|
List<Long> locationIds = submissions.stream().map(VoteSubmission::getLocationId).distinct().collect(Collectors.toList());
|
|
|
Map<Long, SysBranchKindergartenDto> branchMap = getBranchMap(locationIds);
|
|
|
-
|
|
|
// 处理任务和评分数据
|
|
|
Map<String, VoteEventRegistrationWorkScores> scoresMap = scoresList.stream().collect(Collectors.toMap(score -> score.getSubmissionId() + "-" + score.getEventId(), Function.identity()));
|
|
|
|
|
@@ -257,8 +303,11 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
|
|
|
// 无论 submission 是否为空,都设置对应的字段
|
|
|
if (submission != null) {
|
|
|
- scoresVo.setSubmissionName(submission.getName())
|
|
|
- .setCommitName(submission.getCommitName());
|
|
|
+ scoresVo.setSubmissionName(submission.getName());
|
|
|
+ LambdaQueryWrapper<VoteRegistrations> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(VoteRegistrations::getUid, submission.getUserId())
|
|
|
+ .eq(VoteRegistrations::getEventId, submission.getEventId());
|
|
|
+ scoresVo.setCommitName(voteRegistrationsMapper.selectList(queryWrapper).get(0).getName());
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
@@ -298,7 +347,11 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
long pageSize = Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L);
|
|
|
// 构建查询条件
|
|
|
LambdaQueryWrapper<VoteEventCompetitionZones> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(VoteEventCompetitionZones::getEventId, voteEvaluationTasksDto.getEventId()).eq(VoteEventCompetitionZones::getRoundId, voteEvaluationTasksDto.getRoundId()).eq(VoteEventCompetitionZones::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId()).orderByDesc(VoteEventCompetitionZones::getCreatedAt);
|
|
|
+ wrapper.eq(VoteEventCompetitionZones::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteEventCompetitionZones::getRoundId, voteEvaluationTasksDto.getRoundId())
|
|
|
+ .eq(VoteEventCompetitionZones::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
+ .eq(VoteEventCompetitionZones::getIsDeleted, IS_DELETED_0)
|
|
|
+ .orderByDesc(VoteEventCompetitionZones::getCreatedAt);
|
|
|
List<VoteEventCompetitionZones> competitionZones = voteEventCompetitionZonesMapper.selectList(wrapper);
|
|
|
// 调用获取所有省份
|
|
|
List<SysProvince> provinces = remoteSysProvinceService.getProvince().getData();
|
|
@@ -387,7 +440,7 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
}
|
|
|
|
|
|
// 获取任务数和已完成数
|
|
|
- private int calculateTaskCount(String[] judgeIds, List<Long> submissionIds, boolean includeJudgeCondition) {
|
|
|
+ private int calculateTaskCount(String[] judgeIds, List<Long> submissionIds, boolean includeJudgeCondition, Long roundId) {
|
|
|
if (judgeIds == null || judgeIds.length == 0 || submissionIds == null || submissionIds.isEmpty()) {
|
|
|
return 0; // 如果 judgeIds 或 submissionIds 为空,直接返回 0
|
|
|
}
|
|
@@ -398,6 +451,8 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
// 根据 submissionIds 查询
|
|
|
queryWrapper.in(VoteEvaluationTasks::getSubmissionId, submissionIds);
|
|
|
|
|
|
+ queryWrapper.eq(VoteEvaluationTasks::getRoundId, roundId);
|
|
|
+
|
|
|
// 如果需要根据任务状态查询,添加相应的条件
|
|
|
if (includeJudgeCondition) {
|
|
|
queryWrapper.eq(VoteEvaluationTasks::getStatus, 1); // 1表示已完成
|
|
@@ -410,26 +465,24 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
|
|
|
|
|
|
//获取赛区名 和 相关的省份
|
|
|
- public Map<String, String> findZoneNamesAndProvincesByJudgeId(String judgeId) {
|
|
|
+ public Map<String, String> findZoneNamesAndProvincesByJudgeId(String judgeId, VoteEvaluationTasksDto voteEvaluationTasksDto) {
|
|
|
if (judgeId == null || judgeId.trim().isEmpty()) {
|
|
|
// 如果 judgeId 为空,返回空的 Map
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
-
|
|
|
LambdaQueryWrapper<VoteEventCompetitionZones> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.like(VoteEventCompetitionZones::getJudges, "," + judgeId + ",").or().like(VoteEventCompetitionZones::getJudges, judgeId + ",").or().like(VoteEventCompetitionZones::getJudges, "," + judgeId).or().eq(VoteEventCompetitionZones::getJudges, judgeId);
|
|
|
-
|
|
|
+ queryWrapper
|
|
|
+ .eq(VoteEventCompetitionZones::getRoundId, voteEvaluationTasksDto.getRoundId())
|
|
|
+ .eq(VoteEventCompetitionZones::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteEventCompetitionZones::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
+ .eq(VoteEventCompetitionZones::getIsDeleted, IS_DELETED_0);
|
|
|
List<VoteEventCompetitionZones> zones = Optional.ofNullable(voteEventCompetitionZonesMapper.selectList(queryWrapper)).orElse(Collections.emptyList());
|
|
|
-
|
|
|
// 提取 name 字段和 provinces 字段,并用逗号拼接成一个字符串
|
|
|
String zoneNames = zones.stream().map(VoteEventCompetitionZones::getName).filter(Objects::nonNull).collect(Collectors.joining(","));
|
|
|
-
|
|
|
String provinces = zones.stream().map(VoteEventCompetitionZones::getProvinces).filter(Objects::nonNull).collect(Collectors.joining(","));
|
|
|
-
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
result.put("zoneNames", zoneNames.isEmpty() ? "暂未分配赛区" : zoneNames);
|
|
|
result.put("provinces", provinces.isEmpty() ? "" : provinces);
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -458,11 +511,44 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
if (voteSubmissions == null || voteSubmissions.isEmpty()) {
|
|
|
throw new RuntimeException("该赛区下暂无作品,分配失败");
|
|
|
}
|
|
|
- //收集主键
|
|
|
- List<Long> submissionIds = voteSubmissions.stream()
|
|
|
- .map(VoteSubmission::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
+ // 获取赛区信息
|
|
|
+ LambdaQueryWrapper<VoteEventCompetitionZones> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(VoteEventCompetitionZones::getEventId, voteEvaluationTasksDto.getEventId())
|
|
|
+ .eq(VoteEventCompetitionZones::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId())
|
|
|
+ .eq(VoteEventCompetitionZones::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
+ List<VoteEventCompetitionZones> voteEventCompetitionZones = voteEventCompetitionZonesMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ // 收集所有作品ID
|
|
|
+ List<Long> submissionIds = new ArrayList<>();
|
|
|
+ for (VoteEventCompetitionZones voteEventCompetitionZone : voteEventCompetitionZones) {
|
|
|
+ String provinces = voteEventCompetitionZone.getProvinces(); // 赛区下省份
|
|
|
+ String[] split = provinces.split(",");
|
|
|
+
|
|
|
+ for (String province : split) {
|
|
|
+ // 获取该省份的报名数据
|
|
|
+ LambdaQueryWrapper<VoteRegistrations> registrationWrapper = new LambdaQueryWrapper<>();
|
|
|
+ registrationWrapper.eq(VoteRegistrations::getProvinceId, province);
|
|
|
+ List<VoteRegistrations> registrations = voteRegistrationsMapper.selectList(registrationWrapper);
|
|
|
+ // 通过报名数据获取作品ID
|
|
|
+ for (VoteRegistrations registration : registrations) {
|
|
|
+ Long uid = registration.getUid(); // 获取用户ID
|
|
|
+ LambdaQueryWrapper<VoteSubmission> submissionWrapper = new LambdaQueryWrapper<>();
|
|
|
+ submissionWrapper.eq(VoteSubmission::getUserId, uid);
|
|
|
+ submissionWrapper.eq(VoteSubmission::getEventId, voteEvaluationTasksDto.getEventId());
|
|
|
+ submissionWrapper.eq(VoteSubmission::getWorkSettingsId, voteEvaluationTasksDto.getWorkSettingsId());
|
|
|
+ submissionWrapper.eq(VoteSubmission::getRoundId, voteEvaluationTasksDto.getRoundId());
|
|
|
+ List<VoteSubmission> userSubmissions = voteSubmissionMapper.selectList(submissionWrapper);
|
|
|
+ submissionIds.addAll(userSubmissions.stream()
|
|
|
+ .map(VoteSubmission::getId)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 继续后续逻辑
|
|
|
+ if (submissionIds.isEmpty()) {
|
|
|
+ throw new RuntimeException("没有找到相关作品,分配失败");
|
|
|
+ }
|
|
|
+ voteSubmissionMapper.updateBatch(submissionIds);
|
|
|
// 获取专家id数组
|
|
|
VoteEventCompetitionZones competitionZones = voteEventCompetitionZonesMapper.selectById(voteEvaluationTasksDto.getZonesId());
|
|
|
String judges = competitionZones.getJudges();
|
|
@@ -499,7 +585,7 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
assignmentMap.get(randomJudgeId).add(submissionIterator.next());
|
|
|
}
|
|
|
}
|
|
|
- List<VoteEvaluationTasks> tasksToInsert = getVoteEvaluationTasks(assignmentMap);
|
|
|
+ List<VoteEvaluationTasks> tasksToInsert = getVoteEvaluationTasks(assignmentMap, voteEvaluationTasksDto.getRoundId());
|
|
|
// 批量插入任务到数据库
|
|
|
if (!tasksToInsert.isEmpty()) {
|
|
|
int i = voteEvaluationTasksMapper.insertBatch(tasksToInsert);
|
|
@@ -517,7 +603,7 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
|
|
|
|
|
|
//构建插入任务
|
|
|
- private List<VoteEvaluationTasks> getVoteEvaluationTasks(Map<String, List<Long>> assignmentMap) {
|
|
|
+ private List<VoteEvaluationTasks> getVoteEvaluationTasks(Map<String, List<Long>> assignmentMap, Long roundId) {
|
|
|
List<VoteEvaluationTasks> tasksToInsert = new ArrayList<>();
|
|
|
for (Map.Entry<String, List<Long>> entry : assignmentMap.entrySet()) {
|
|
|
String judgeId = entry.getKey();
|
|
@@ -527,6 +613,7 @@ public class VoteEvaluationTasksServiceImpl extends ServiceImpl<VoteEvaluationTa
|
|
|
VoteEvaluationTasks task = new VoteEvaluationTasks();
|
|
|
task.setJudgeId(judgeId);
|
|
|
task.setSubmissionId(submissionId);
|
|
|
+ task.setRoundId(roundId);
|
|
|
tasksToInsert.add(task);
|
|
|
}
|
|
|
}
|