|
@@ -4,14 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.vctgo.common.core.exception.ServiceException;
|
|
import com.vctgo.common.core.text.Convert;
|
|
import com.vctgo.common.core.text.Convert;
|
|
import com.vctgo.common.core.utils.ServletUtils;
|
|
import com.vctgo.common.core.utils.ServletUtils;
|
|
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;
|
|
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;
|
|
import com.vctgo.system.api.RemoteBranchKindergartenService;
|
|
import com.vctgo.system.api.RemoteBranchKindergartenService;
|
|
import com.vctgo.system.api.RemoteFileService;
|
|
import com.vctgo.system.api.RemoteFileService;
|
|
import com.vctgo.system.api.RemotePlatformUserService;
|
|
import com.vctgo.system.api.RemotePlatformUserService;
|
|
|
|
+import com.vctgo.system.api.RemoteUserService;
|
|
import com.vctgo.system.api.domain.FileInfo;
|
|
import com.vctgo.system.api.domain.FileInfo;
|
|
import com.vctgo.system.api.domain.SysPlatformUser;
|
|
import com.vctgo.system.api.domain.SysPlatformUser;
|
|
|
|
+import com.vctgo.system.api.domain.SysUser;
|
|
import com.vctgo.system.api.domain.dto.SysBranchKindergartenDto;
|
|
import com.vctgo.system.api.domain.dto.SysBranchKindergartenDto;
|
|
import com.vctgo.system.api.domain.vo.VoteFileVo;
|
|
import com.vctgo.system.api.domain.vo.VoteFileVo;
|
|
import com.vote.system.domain.*;
|
|
import com.vote.system.domain.*;
|
|
@@ -65,9 +68,6 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
private VoteRegistrationsMapper voteRegistrationsMapper;
|
|
private VoteRegistrationsMapper voteRegistrationsMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private VoteRuleMapper voteRuleMapper;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private VoteScoringItemMapper voteScoringItemMapper;
|
|
private VoteScoringItemMapper voteScoringItemMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -86,6 +86,9 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
@Autowired
|
|
@Autowired
|
|
private VoteEventRegistrationWorkScoresMapper voteEventRegistrationWorkScoresMapper;
|
|
private VoteEventRegistrationWorkScoresMapper voteEventRegistrationWorkScoresMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private VoteHistoryScoreMapper voteHistoryScoreMapper;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 分页查询 参赛作品列表
|
|
* 分页查询 参赛作品列表
|
|
@@ -108,16 +111,18 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
//获取工作类型数据
|
|
//获取工作类型数据
|
|
Map<Long, VoteEventWorkSettings> workSettingsMap = voteEventWorkSettingsMapper.selectList(new LambdaQueryWrapper<>())
|
|
Map<Long, VoteEventWorkSettings> workSettingsMap = voteEventWorkSettingsMapper.selectList(new LambdaQueryWrapper<>())
|
|
.stream().collect(Collectors.toMap(VoteEventWorkSettings::getId, Function.identity()));
|
|
.stream().collect(Collectors.toMap(VoteEventWorkSettings::getId, Function.identity()));
|
|
-
|
|
|
|
// 构建返回的VO列表
|
|
// 构建返回的VO列表
|
|
List<VoteSubmissionVo> voList = voteSubmissions.stream()
|
|
List<VoteSubmissionVo> voList = voteSubmissions.stream()
|
|
.map(item -> {
|
|
.map(item -> {
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
vo.setId(item.getId());
|
|
vo.setId(item.getId());
|
|
vo.setName(item.getName());
|
|
vo.setName(item.getName());
|
|
- vo.setCommitName(item.getCommitName());
|
|
|
|
|
|
+ LambdaQueryWrapper<VoteRegistrations> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(VoteRegistrations::getUid, item.getUserId()).eq(VoteRegistrations::getEventId, item.getEventId());
|
|
|
|
+ List<VoteRegistrations> registrations = voteRegistrationsMapper.selectList(wrapper);
|
|
|
|
+ vo.setCommitName(registrations.get(0).getName());
|
|
vo.setCommitTime(item.getCreateAt());
|
|
vo.setCommitTime(item.getCreateAt());
|
|
- vo.setPhone(item.getPhone());
|
|
|
|
|
|
+ vo.setPhone(registrations.get(0).getPhone());
|
|
vo.setStatus(item.getStatus());
|
|
vo.setStatus(item.getStatus());
|
|
//设置类型名称
|
|
//设置类型名称
|
|
VoteEventWorkSettings workSettings = workSettingsMap.get(item.getWorkSettingsId());
|
|
VoteEventWorkSettings workSettings = workSettingsMap.get(item.getWorkSettingsId());
|
|
@@ -142,6 +147,7 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
private List<VoteSubmission> getVoteSubmissions(VoteSubmissionDto voteSubmissionDto) {
|
|
private List<VoteSubmission> getVoteSubmissions(VoteSubmissionDto voteSubmissionDto) {
|
|
List<Long> userIds = new ArrayList<>();
|
|
List<Long> userIds = new ArrayList<>();
|
|
boolean locationFilterApplied = false;
|
|
boolean locationFilterApplied = false;
|
|
|
|
+ boolean keywordFilterApplied = false; // 新增标志
|
|
LambdaQueryWrapper<VoteRegistrations> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<VoteRegistrations> queryWrapper = new LambdaQueryWrapper<>();
|
|
if (voteSubmissionDto.getProvinceId() != null) {
|
|
if (voteSubmissionDto.getProvinceId() != null) {
|
|
queryWrapper.eq(VoteRegistrations::getProvinceId, voteSubmissionDto.getProvinceId());
|
|
queryWrapper.eq(VoteRegistrations::getProvinceId, voteSubmissionDto.getProvinceId());
|
|
@@ -158,19 +164,13 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
.map(VoteRegistrations::getUid)
|
|
.map(VoteRegistrations::getUid)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
locationFilterApplied = true;
|
|
locationFilterApplied = true;
|
|
-
|
|
|
|
- if (userIds.isEmpty()) {
|
|
|
|
- return new ArrayList<>();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
LambdaQueryWrapper<VoteSubmission> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<VoteSubmission> wrapper = new LambdaQueryWrapper<>();
|
|
if (voteSubmissionDto.getEventId() == null) {
|
|
if (voteSubmissionDto.getEventId() == null) {
|
|
throw new RuntimeException("活动id为空 暂时无法查询");
|
|
throw new RuntimeException("活动id为空 暂时无法查询");
|
|
} else {
|
|
} else {
|
|
wrapper.eq(VoteSubmission::getEventId, voteSubmissionDto.getEventId());
|
|
wrapper.eq(VoteSubmission::getEventId, voteSubmissionDto.getEventId());
|
|
}
|
|
}
|
|
-
|
|
|
|
if (voteSubmissionDto.getWorkSettingsId() != null) {
|
|
if (voteSubmissionDto.getWorkSettingsId() != null) {
|
|
wrapper.eq(VoteSubmission::getWorkSettingsId, voteSubmissionDto.getWorkSettingsId());
|
|
wrapper.eq(VoteSubmission::getWorkSettingsId, voteSubmissionDto.getWorkSettingsId());
|
|
}
|
|
}
|
|
@@ -180,10 +180,21 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
if (voteSubmissionDto.getStatus() != null) {
|
|
if (voteSubmissionDto.getStatus() != null) {
|
|
wrapper.eq(VoteSubmission::getStatus, voteSubmissionDto.getStatus());
|
|
wrapper.eq(VoteSubmission::getStatus, voteSubmissionDto.getStatus());
|
|
}
|
|
}
|
|
|
|
+ // 修改关键词查询逻辑
|
|
if (voteSubmissionDto.getKeyword() != null) {
|
|
if (voteSubmissionDto.getKeyword() != null) {
|
|
- wrapper.like(VoteSubmission::getName, voteSubmissionDto.getKeyword())
|
|
|
|
|
|
+ LambdaQueryWrapper<VoteRegistrations> registrationsWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ registrationsWrapper.like(VoteRegistrations::getName, voteSubmissionDto.getKeyword())
|
|
.or()
|
|
.or()
|
|
- .like(VoteSubmission::getPhone, voteSubmissionDto.getKeyword());
|
|
|
|
|
|
+ .like(VoteRegistrations::getPhone, voteSubmissionDto.getKeyword());
|
|
|
|
+
|
|
|
|
+ List<Long> filteredUserIds = voteRegistrationsMapper.selectList(registrationsWrapper).stream()
|
|
|
|
+ .map(VoteRegistrations::getUid)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (!filteredUserIds.isEmpty()) {
|
|
|
|
+ wrapper.in(VoteSubmission::getUserId, filteredUserIds);
|
|
|
|
+ keywordFilterApplied = true; // 标记关键词过滤已应用
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (voteSubmissionDto.getRoundId() != null) {
|
|
if (voteSubmissionDto.getRoundId() != null) {
|
|
wrapper.eq(VoteSubmission::getRoundId, voteSubmissionDto.getRoundId());
|
|
wrapper.eq(VoteSubmission::getRoundId, voteSubmissionDto.getRoundId());
|
|
@@ -195,7 +206,13 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
wrapper.eq(VoteSubmission::getPromoteStatus, voteSubmissionDto.getPromoteStatus());
|
|
wrapper.eq(VoteSubmission::getPromoteStatus, voteSubmissionDto.getPromoteStatus());
|
|
}
|
|
}
|
|
wrapper.orderByDesc(VoteSubmission::getCreateAt);
|
|
wrapper.orderByDesc(VoteSubmission::getCreateAt);
|
|
- return voteSubmissionMapper.selectList(wrapper);
|
|
|
|
|
|
+ // 执行查询
|
|
|
|
+ List<VoteSubmission> submissions = voteSubmissionMapper.selectList(wrapper);
|
|
|
|
+ // 如果查询结果为空且没有其他条件,返回空列表
|
|
|
|
+ if (submissions.isEmpty() && !locationFilterApplied && !keywordFilterApplied) {
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ return submissions;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -208,48 +225,61 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
@Override
|
|
@Override
|
|
public VoteSubmissionVo selectById(Long id) {
|
|
public VoteSubmissionVo selectById(Long id) {
|
|
VoteSubmission submission = voteSubmissionMapper.selectById(id);
|
|
VoteSubmission submission = voteSubmissionMapper.selectById(id);
|
|
|
|
+ if (submission == null) {
|
|
|
|
+ throw new NoSuchElementException("VoteSubmission not found with id: " + id);
|
|
|
|
+ }
|
|
|
|
+
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
- submission.setFile(submission.getFile() + "," + submission.getImages() + "," + submission.getVideo());
|
|
|
|
- List<FileInfo> fileInfoList = remoteFileService.selectUrlByIds(submission.getFile()).getData();//文件集合
|
|
|
|
- // 初始化图片 URL 列表
|
|
|
|
- List<VoteFileVo> imageFiles = new ArrayList<>();
|
|
|
|
- List<VoteFileVo> videoFiles = new ArrayList<>();
|
|
|
|
- List<VoteFileVo> documentFiles = new ArrayList<>();
|
|
|
|
- for (FileInfo fileInfo : fileInfoList) {
|
|
|
|
- VoteFileVo fileVo = new VoteFileVo();
|
|
|
|
- fileVo.setFileUrl(fileInfo.getFileUrl()); // 设置文件URL
|
|
|
|
- fileVo.setFileName(fileInfo.getFileName());
|
|
|
|
- // 根据 fileType 来判断文件类型
|
|
|
|
- String fileType = fileInfo.getFileType();
|
|
|
|
- switch (fileType) {
|
|
|
|
- case "1": // 文件
|
|
|
|
- documentFiles.add(fileVo);
|
|
|
|
- break;
|
|
|
|
- case "2": // 图片类型
|
|
|
|
- imageFiles.add(fileVo);
|
|
|
|
- break;
|
|
|
|
- case "3": // 视频类型
|
|
|
|
- videoFiles.add(fileVo);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
|
|
+ String string = submission.getFile() + "," + submission.getImages() + "," + submission.getVideo();
|
|
|
|
+ List<FileInfo> fileInfoList = remoteFileService.selectUrlByIds(string).getData();
|
|
|
|
+ // 检查 fileInfoList 是否为 null 或者为空
|
|
|
|
+ if (fileInfoList == null || fileInfoList.isEmpty()) {
|
|
|
|
+ // 如果 fileInfoList 为空,可以设置一些默认值或记录日志
|
|
|
|
+ vo.setVideoFiles(Collections.emptyList());
|
|
|
|
+ vo.setDocumentFiles(Collections.emptyList());
|
|
|
|
+ vo.setImageFiles(Collections.emptyList());
|
|
|
|
+ } else {
|
|
|
|
+ // 初始化图片 URL 列表
|
|
|
|
+ List<VoteFileVo> imageFiles = new ArrayList<>();
|
|
|
|
+ List<VoteFileVo> videoFiles = new ArrayList<>();
|
|
|
|
+ List<VoteFileVo> documentFiles = new ArrayList<>();
|
|
|
|
+ for (FileInfo fileInfo : fileInfoList) {
|
|
|
|
+ VoteFileVo fileVo = new VoteFileVo();
|
|
|
|
+ fileVo.setFileUrl(fileInfo.getFilePreviewUrl()); // 设置文件预览URL
|
|
|
|
+ fileVo.setFileName(fileInfo.getFileStorageName());
|
|
|
|
+
|
|
|
|
+ switch (fileInfo.getFileType()) {
|
|
|
|
+ case "1": // 文件
|
|
|
|
+ documentFiles.add(fileVo);
|
|
|
|
+ break;
|
|
|
|
+ case "2": // 图片类型
|
|
|
|
+ imageFiles.add(fileVo);
|
|
|
|
+ break;
|
|
|
|
+ case "3": // 视频类型
|
|
|
|
+ videoFiles.add(fileVo);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ vo.setVideoFiles(videoFiles)
|
|
|
|
+ .setDocumentFiles(documentFiles)
|
|
|
|
+ .setImageFiles(imageFiles);
|
|
}
|
|
}
|
|
- vo.setVideoFiles(videoFiles)
|
|
|
|
- .setDocumentFiles(documentFiles)
|
|
|
|
- .setImageFiles(imageFiles);
|
|
|
|
vo.setName(submission.getName())
|
|
vo.setName(submission.getName())
|
|
.setMainAuthor(submission.getMainAuthor())
|
|
.setMainAuthor(submission.getMainAuthor())
|
|
.setTeamWorker(submission.getTeamWorker());
|
|
.setTeamWorker(submission.getTeamWorker());
|
|
|
|
+
|
|
if (CREATE_TYPE_PERSONAL.equals(submission.getCreateType())) {
|
|
if (CREATE_TYPE_PERSONAL.equals(submission.getCreateType())) {
|
|
vo.setCreateType(CREATE_TYPE_PERSONAL_DESC);
|
|
vo.setCreateType(CREATE_TYPE_PERSONAL_DESC);
|
|
} else {
|
|
} else {
|
|
vo.setCreateType(CREATE_TYPE_TEAM_DESC);
|
|
vo.setCreateType(CREATE_TYPE_TEAM_DESC);
|
|
}
|
|
}
|
|
- if (!submission.getAgeSegment().isEmpty()) {
|
|
|
|
|
|
+
|
|
|
|
+ if (submission.getAgeSegment() != null && !submission.getAgeSegment().isEmpty()) {
|
|
StringBuilder builder = new StringBuilder();
|
|
StringBuilder builder = new StringBuilder();
|
|
- String ageSegment = submission.getAgeSegment();
|
|
|
|
- String[] split = ageSegment.split(",");
|
|
|
|
|
|
+ String[] split = submission.getAgeSegment().split(",");
|
|
for (String s : split) {
|
|
for (String s : split) {
|
|
if (s.equals(ZHONG_BAN_CODE)) {
|
|
if (s.equals(ZHONG_BAN_CODE)) {
|
|
builder.append(ZHONG_BAN_DESC);
|
|
builder.append(ZHONG_BAN_DESC);
|
|
@@ -260,7 +290,10 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
vo.setAgeSegment(builder.toString());
|
|
vo.setAgeSegment(builder.toString());
|
|
|
|
+ } else {
|
|
|
|
+ vo.setAgeSegment("");
|
|
}
|
|
}
|
|
|
|
+
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -275,83 +308,99 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
|
|
|
|
// 获取作品列表和专家数据
|
|
// 获取作品列表和专家数据
|
|
List<VoteSubmission> voteSubmissions = getVoteSubmissions(voteSubmissionDto);
|
|
List<VoteSubmission> voteSubmissions = getVoteSubmissions(voteSubmissionDto);
|
|
|
|
+ if (voteSubmissions == null) {
|
|
|
|
+ voteSubmissions = Collections.emptyList(); // 防止空指针
|
|
|
|
+ }
|
|
|
|
+
|
|
// 将专家列表转换为以judgeId为键,专家姓名为值的Map
|
|
// 将专家列表转换为以judgeId为键,专家姓名为值的Map
|
|
- Map<String, String> judgeMap = remotePlatformUserService.processExpertList().getData().stream()
|
|
|
|
|
|
+ Map<String, String> judgeMap = Optional.ofNullable(remotePlatformUserService.processExpertList().getData())
|
|
|
|
+ .orElse(Collections.emptyList()).stream()
|
|
.collect(Collectors.toMap(
|
|
.collect(Collectors.toMap(
|
|
user -> user.getUserId().toString(),
|
|
user -> user.getUserId().toString(),
|
|
SysPlatformUser::getNickName
|
|
SysPlatformUser::getNickName
|
|
));
|
|
));
|
|
|
|
+
|
|
// 预先生成 submissionId 到 judgeId 的映射
|
|
// 预先生成 submissionId 到 judgeId 的映射
|
|
- Map<Long, String> submissionJudgeMap = voteSubmissions.stream()
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
- VoteSubmission::getId,
|
|
|
|
- submission -> voteEvaluationTasksMapper.selectOne(
|
|
|
|
- new LambdaQueryWrapper<VoteEvaluationTasks>()
|
|
|
|
- .eq(VoteEvaluationTasks::getSubmissionId, submission.getId())
|
|
|
|
- ).getJudgeId()
|
|
|
|
- ));
|
|
|
|
|
|
+ Map<Long, String> submissionJudgeMap = new HashMap<>();
|
|
|
|
+ for (VoteSubmission submission : voteSubmissions) {
|
|
|
|
+ String judgeId = Optional.ofNullable(voteEvaluationTasksMapper.selectOne(
|
|
|
|
+ new LambdaQueryWrapper<VoteEvaluationTasks>()
|
|
|
|
+ .eq(VoteEvaluationTasks::getSubmissionId, submission.getId())
|
|
|
|
+ .eq(VoteEvaluationTasks::getRoundId, submission.getRoundId())
|
|
|
|
+ )).map(VoteEvaluationTasks::getJudgeId).orElse(null);
|
|
|
|
+ submissionJudgeMap.put(submission.getId(), judgeId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
// 预先生成 submissionId 到 score 的映射
|
|
// 预先生成 submissionId 到 score 的映射
|
|
- Map<Long, BigDecimal> submissionScoreMap = voteSubmissions.stream()
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
- VoteSubmission::getId,
|
|
|
|
- submission -> {
|
|
|
|
- try {
|
|
|
|
- VoteEventRegistrationWorkScores score = voteEventRegistrationWorkScoresMapper.selectOne(
|
|
|
|
- new LambdaQueryWrapper<VoteEventRegistrationWorkScores>()
|
|
|
|
- .eq(VoteEventRegistrationWorkScores::getEventId, submission.getEventId())
|
|
|
|
- .eq(VoteEventRegistrationWorkScores::getWorkSettingsId, submission.getWorkSettingsId())
|
|
|
|
- .eq(VoteEventRegistrationWorkScores::getSubmissionId, submission.getId())
|
|
|
|
- );
|
|
|
|
- return (score != null) ? score.getScore() : BigDecimal.ZERO;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- return BigDecimal.ZERO;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Map<Long, BigDecimal> submissionScoreMap = new HashMap<>();
|
|
|
|
+ for (VoteSubmission submission : voteSubmissions) {
|
|
|
|
+ BigDecimal score = BigDecimal.ZERO;
|
|
|
|
+ try {
|
|
|
|
+ VoteEventRegistrationWorkScores workScore = voteEventRegistrationWorkScoresMapper.selectOne(
|
|
|
|
+ new LambdaQueryWrapper<VoteEventRegistrationWorkScores>()
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getEventId, submission.getEventId())
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getWorkSettingsId, submission.getWorkSettingsId())
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getRoundId, submission.getRoundId())
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getSubmissionId, submission.getId())
|
|
|
|
+ );
|
|
|
|
+ score = (workScore != null && workScore.getScore() != null) ? workScore.getScore() : BigDecimal.ZERO;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // 处理异常,记录日志或进行其他处理
|
|
|
|
+ }
|
|
|
|
+ submissionScoreMap.put(submission.getId(), score);
|
|
|
|
+ }
|
|
|
|
|
|
// 将VoteSubmission转换为VoteSubmissionVo
|
|
// 将VoteSubmission转换为VoteSubmissionVo
|
|
List<VoteSubmissionVo> vos = voteSubmissions.stream()
|
|
List<VoteSubmissionVo> vos = voteSubmissions.stream()
|
|
.map(submission -> {
|
|
.map(submission -> {
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
VoteSubmissionVo vo = new VoteSubmissionVo();
|
|
vo.setName(submission.getName())
|
|
vo.setName(submission.getName())
|
|
- .setCommitName(submission.getCommitName())
|
|
|
|
- .setPhone(submission.getPhone())
|
|
|
|
.setId(submission.getId());
|
|
.setId(submission.getId());
|
|
|
|
+ LambdaQueryWrapper<VoteRegistrations> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(VoteRegistrations::getUid, submission.getUserId()).eq(VoteRegistrations::getEventId, submission.getEventId());
|
|
|
|
+ List<VoteRegistrations> registrations = voteRegistrationsMapper.selectList(wrapper);
|
|
|
|
+ vo.setCommitName(registrations.get(0).getName());
|
|
|
|
+ vo.setPhone(registrations.get(0).getPhone());
|
|
|
|
+
|
|
|
|
+ VoteEventWorkSettings eventWorkSettings = voteEventWorkSettingsMapper.selectById(submission.getWorkSettingsId());
|
|
|
|
+ vo.setWorkTypeName(eventWorkSettings.getAlias());
|
|
|
|
+
|
|
// 根据PromoteStatus设置状态
|
|
// 根据PromoteStatus设置状态
|
|
- switch (submission.getPromoteStatus()) {
|
|
|
|
- case PENDING_1:
|
|
|
|
- vo.setPromoteStatus(PENDING_1);
|
|
|
|
- break;
|
|
|
|
- case PROMOTE_0:
|
|
|
|
- vo.setPromoteStatus(PROMOTE_0);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- vo.setPromoteStatus(UNKNOWN);
|
|
|
|
- }
|
|
|
|
- if (submission.getAward() != null && submission.getAward().isEmpty()) {
|
|
|
|
|
|
+ vo.setPromoteStatus(Optional.ofNullable(submission.getPromoteStatus()).orElse(UNKNOWN));
|
|
|
|
+
|
|
|
|
+ if (submission.getAward() != null && !submission.getAward().isEmpty()) {
|
|
vo.setAward(submission.getAward());
|
|
vo.setAward(submission.getAward());
|
|
} else {
|
|
} else {
|
|
vo.setAward(PENDING);
|
|
vo.setAward(PENDING);
|
|
}
|
|
}
|
|
// 设置园所名称
|
|
// 设置园所名称
|
|
SysBranchKindergartenDto data = getSysBranchKindergartenDto(submission);
|
|
SysBranchKindergartenDto data = getSysBranchKindergartenDto(submission);
|
|
- vo.setLocationName(data.getKindergartenName());
|
|
|
|
|
|
+ vo.setLocationName(data != null ? data.getKindergartenName() : null);
|
|
|
|
+
|
|
// 从映射表中获取并设置专家姓名
|
|
// 从映射表中获取并设置专家姓名
|
|
vo.setJudge(judgeMap.get(submissionJudgeMap.get(submission.getId())));
|
|
vo.setJudge(judgeMap.get(submissionJudgeMap.get(submission.getId())));
|
|
|
|
+
|
|
// 从映射表中获取并设置分数
|
|
// 从映射表中获取并设置分数
|
|
vo.setScore(submissionScoreMap.get(submission.getId()));
|
|
vo.setScore(submissionScoreMap.get(submission.getId()));
|
|
return vo;
|
|
return vo;
|
|
})
|
|
})
|
|
- .sorted(Comparator.comparing(VoteSubmissionVo::getScore).reversed()) // 按分数降序排序
|
|
|
|
|
|
+ .sorted(Comparator.comparing(VoteSubmissionVo::getScore, Comparator.nullsLast(Comparator.reverseOrder()))) // 按分数降序排序
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
+
|
|
// 为每个项目分配排序序号
|
|
// 为每个项目分配排序序号
|
|
for (int i = 0; i < vos.size(); i++) {
|
|
for (int i = 0; i < vos.size(); i++) {
|
|
vos.get(i).setSort(i + 1);
|
|
vos.get(i).setSort(i + 1);
|
|
}
|
|
}
|
|
// 进行分页
|
|
// 进行分页
|
|
Page<VoteSubmissionVo> page = new Page<>(pageNum, pageSize);
|
|
Page<VoteSubmissionVo> page = new Page<>(pageNum, pageSize);
|
|
- page.setRecords(vos.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()));
|
|
|
|
|
|
+ List<VoteSubmissionVo> paginatedRecords = vos.stream()
|
|
|
|
+ .skip((pageNum - 1) * pageSize)
|
|
|
|
+ .limit(pageSize)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ page.setRecords(paginatedRecords);
|
|
page.setTotal(vos.size());
|
|
page.setTotal(vos.size());
|
|
|
|
+
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -376,21 +425,58 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public int promote(VoteSubmissionDto voteSubmissionDto) {
|
|
public int promote(VoteSubmissionDto voteSubmissionDto) {
|
|
|
|
+ VoteSubmission submission = voteSubmissionMapper.selectById(voteSubmissionDto.getId());
|
|
|
|
+ if (submission.getPromoteStatus().equals(PROMOTE_0)) {
|
|
|
|
+ throw new ServiceException("已晋级的作品不能继续晋级");
|
|
|
|
+ }
|
|
VoteEventWorkSettings eventWorkSettings = voteEventWorkSettingsMapper.selectById(voteSubmissionDto.getWorkSettingsId());
|
|
VoteEventWorkSettings eventWorkSettings = voteEventWorkSettingsMapper.selectById(voteSubmissionDto.getWorkSettingsId());
|
|
String[] split = eventWorkSettings.getRoundsId().split(",");
|
|
String[] split = eventWorkSettings.getRoundsId().split(",");
|
|
List<Long> roundIds = Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList());
|
|
List<Long> roundIds = Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList());
|
|
//创建修改对象
|
|
//创建修改对象
|
|
VoteSubmission voteSubmission = new VoteSubmission();
|
|
VoteSubmission voteSubmission = new VoteSubmission();
|
|
voteSubmission.setId(voteSubmissionDto.getId())
|
|
voteSubmission.setId(voteSubmissionDto.getId())
|
|
- .setPromoteStatus(PROMOTE_0);
|
|
|
|
|
|
+ .setPromoteStatus(PROMOTE_0)
|
|
|
|
+ .setAppraiseStatus("1");
|
|
|
|
+
|
|
|
|
+ //创建历史评分记录
|
|
|
|
+ VoteHistoryScore historyScore = new VoteHistoryScore();
|
|
if (roundIds.size() > 1) {
|
|
if (roundIds.size() > 1) {
|
|
int currentIndex = roundIds.indexOf(voteSubmissionDto.getRoundId());
|
|
int currentIndex = roundIds.indexOf(voteSubmissionDto.getRoundId());
|
|
if (currentIndex >= 0 && currentIndex < roundIds.size() - 1) {
|
|
if (currentIndex >= 0 && currentIndex < roundIds.size() - 1) {
|
|
//获取当前索引的后一个元素
|
|
//获取当前索引的后一个元素
|
|
Long nextRoundId = roundIds.get(currentIndex + 1);
|
|
Long nextRoundId = roundIds.get(currentIndex + 1);
|
|
voteSubmission.setRoundId(nextRoundId);
|
|
voteSubmission.setRoundId(nextRoundId);
|
|
|
|
+ voteSubmission.setPromoteStatus(PENDING_1);
|
|
|
|
+ historyScore.setRoundId(nextRoundId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ VoteEventEvaluationRounds rounds = voteEventEvaluationRoundsMapper.selectById(submission.getRoundId());
|
|
|
|
+ Integer number = rounds.getRoundNumber();
|
|
|
|
+ Object type = rounds.getType();
|
|
|
|
+ if (type.equals("evaluation")) {
|
|
|
|
+ type = "评选轮";
|
|
|
|
+ } else {
|
|
|
|
+ type = "评奖论";
|
|
|
|
+ }
|
|
|
|
+ historyScore.setAlternately("第" + number + "轮" + "(" + type + ")");
|
|
|
|
+ LambdaQueryWrapper<VoteEventRegistrationWorkScores> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(VoteEventRegistrationWorkScores::getSubmissionId, submission.getId())
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getEventId, submission.getEventId())
|
|
|
|
+ .eq(VoteEventRegistrationWorkScores::getRoundId, submission.getRoundId());
|
|
|
|
+ VoteEventRegistrationWorkScores scores = voteEventRegistrationWorkScoresMapper.selectOne(queryWrapper);
|
|
|
|
+ if (scores == null) {
|
|
|
|
+ historyScore.setScore("暂未评分");
|
|
|
|
+ } else {
|
|
|
|
+ historyScore.setScore(scores.getScore().toString());
|
|
|
|
+ }
|
|
|
|
+ historyScore.setSubmissionId(submission.getId());
|
|
|
|
+ if (rounds.getType().equals("evaluation")) {
|
|
|
|
+ historyScore.setResult(PROMOTE);
|
|
|
|
+ } else {
|
|
|
|
+ historyScore.setResult(submission.getAward());
|
|
|
|
+ }
|
|
|
|
+ historyScore.setRoundId(voteSubmissionDto.getRoundId());
|
|
|
|
+ voteHistoryScoreMapper.insert(historyScore);
|
|
return voteSubmissionMapper.updateById(voteSubmission);
|
|
return voteSubmissionMapper.updateById(voteSubmission);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -449,6 +535,15 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
VoteSubmission voteSubmission = new VoteSubmission();
|
|
VoteSubmission voteSubmission = new VoteSubmission();
|
|
voteSubmission.setId(voteSubmissionDto.getId())
|
|
voteSubmission.setId(voteSubmissionDto.getId())
|
|
.setAward(voteSubmissionDto.getAward());
|
|
.setAward(voteSubmissionDto.getAward());
|
|
|
|
+ VoteSubmission submission = voteSubmissionMapper.selectById(voteSubmissionDto.getId());
|
|
|
|
+ VoteHistoryScore historyScore = new VoteHistoryScore();
|
|
|
|
+ historyScore.setSubmissionId(voteSubmissionDto.getId())
|
|
|
|
+ .setRoundId(submission.getRoundId())
|
|
|
|
+ .setResult(voteSubmissionDto.getAward());
|
|
|
|
+ LambdaQueryWrapper<VoteHistoryScore> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(VoteHistoryScore::getSubmissionId, voteSubmissionDto.getId())
|
|
|
|
+ .eq(VoteHistoryScore::getRoundId, submission.getRoundId());
|
|
|
|
+ voteHistoryScoreMapper.update(historyScore, wrapper);
|
|
return voteSubmissionMapper.updateById(voteSubmission);
|
|
return voteSubmissionMapper.updateById(voteSubmission);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -467,7 +562,8 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
for (VoteSubmissionItem submissionItem : submissionItems) {
|
|
for (VoteSubmissionItem submissionItem : submissionItems) {
|
|
VoteScoringItem scoringItem = voteScoringItemMapper.selectById(submissionItem.getItemId());
|
|
VoteScoringItem scoringItem = voteScoringItemMapper.selectById(submissionItem.getItemId());
|
|
scoringItem.setAggregate(submissionItem.getScore());
|
|
scoringItem.setAggregate(submissionItem.getScore());
|
|
- scoringItem.setItemId(submissionItem.getId());
|
|
|
|
|
|
+ scoringItem.setId(submissionItem.getId());
|
|
|
|
+ scoringItem.setItemId(submissionItem.getItemId());
|
|
items.add(scoringItem);
|
|
items.add(scoringItem);
|
|
totalScore += submissionItem.getScore();
|
|
totalScore += submissionItem.getScore();
|
|
}
|
|
}
|
|
@@ -489,8 +585,7 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
List<VoteScoringItem> itemList = voteSubmissionDto.getItemList();
|
|
List<VoteScoringItem> itemList = voteSubmissionDto.getItemList();
|
|
for (VoteScoringItem voteScoringItem : itemList) {
|
|
for (VoteScoringItem voteScoringItem : itemList) {
|
|
VoteSubmissionItem voteSubmissionItem = new VoteSubmissionItem();
|
|
VoteSubmissionItem voteSubmissionItem = new VoteSubmissionItem();
|
|
- voteSubmissionItem.setSubmissionId(voteSubmissionDto.getId())
|
|
|
|
- .setId(voteScoringItem.getItemId())
|
|
|
|
|
|
+ voteSubmissionItem.setId(voteScoringItem.getId())
|
|
.setScore(voteScoringItem.getAggregate());
|
|
.setScore(voteScoringItem.getAggregate());
|
|
voteSubmissionItemMapper.updateById(voteSubmissionItem);
|
|
voteSubmissionItemMapper.updateById(voteSubmissionItem);
|
|
}
|
|
}
|
|
@@ -509,6 +604,19 @@ public class VoteSubmissionServiceImpl extends ServiceImpl<VoteSubmissionMapper,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 评奖晋级
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public int promoteAward(VoteSubmissionDto voteSubmissionDto) {
|
|
|
|
+ VoteSubmission submission = voteSubmissionMapper.selectById(voteSubmissionDto.getId());
|
|
|
|
+ if (submission.getPromoteStatus().equals(PROMOTE_0)) {
|
|
|
|
+ throw new ServiceException("已晋级的作品不能继续晋级");
|
|
|
|
+ }
|
|
|
|
+ voteSubmissionDto.setAppraiseStatus("2");
|
|
|
|
+ return voteSubmissionMapper.updateById(voteSubmissionDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|