|
|
|
@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -51,6 +52,8 @@ public class ExaminationsService extends CoreBaseService<Examinations> {
|
|
|
|
|
private FlowsService flowsService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExaminationFinancialsService examinationFinancialsService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExaminationInstancesService examinationInstancesService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserExaminationsService userExaminationsService;
|
|
|
|
@ -960,18 +963,20 @@ public class ExaminationsService extends CoreBaseService<Examinations> {
|
|
|
|
|
}
|
|
|
|
|
examinationFinancialsService.updateBatchTemplate(updateExFinancList);
|
|
|
|
|
|
|
|
|
|
int teamOrder = 0;
|
|
|
|
|
// 已提交成绩的实训,计算个人排名和团队排名
|
|
|
|
|
final List<UserExaminations> updateUserExFinancList = new ArrayList<>();
|
|
|
|
|
if (examinations.getMode() >= 1) {
|
|
|
|
|
final Map<Long, List<UserExaminations>> collect = userExaminations.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(UserExaminations::getTeamId));
|
|
|
|
|
for (List<UserExaminations> value : collect.values()) {
|
|
|
|
|
setScoreOrder(value, true);
|
|
|
|
|
teamOrder = setScoreOrder(value, true);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.forEach(i -> i.setTeamOrders(1));
|
|
|
|
|
userExaminations.forEach(i -> i.setTeamOrders(null));
|
|
|
|
|
}
|
|
|
|
|
setScoreOrder(userExaminations, false);
|
|
|
|
|
|
|
|
|
|
int classOrder = setScoreOrder(userExaminations, false);
|
|
|
|
|
for (UserExaminations userExamination : userExaminations) {
|
|
|
|
|
final UserExaminations updateUE = new UserExaminations();
|
|
|
|
|
updateUE.setId(userExamination.getId());
|
|
|
|
@ -980,9 +985,43 @@ public class ExaminationsService extends CoreBaseService<Examinations> {
|
|
|
|
|
updateUserExFinancList.add(updateUE);
|
|
|
|
|
}
|
|
|
|
|
userExaminationsService.updateBatchTemplate(updateUserExFinancList);
|
|
|
|
|
|
|
|
|
|
// 未参加实训的学生记零分
|
|
|
|
|
final List<UserExaminations> notParticipatingUsers = userExaminationsService.notParticipatingUsers(examinationId);
|
|
|
|
|
if (notParticipatingUsers.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (UserExaminations u : notParticipatingUsers) {
|
|
|
|
|
final ExaminationInstances nei = ExaminationInstancesService.initInstance(examinationId, examinations.getFlowId());
|
|
|
|
|
nei.setStatus(1);
|
|
|
|
|
nei.setTeamId(u.getTeamId() == null ? 0L : u.getTeamId());
|
|
|
|
|
|
|
|
|
|
final UserExaminations nue = UserExaminationsService.initUserExamination(examinationId, examinations.getFlowId());
|
|
|
|
|
nue.setUserId(u.getUserId());
|
|
|
|
|
nue.setTeamId(u.getTeamId() == null ? 0L : u.getTeamId());
|
|
|
|
|
nue.setStatus(2);
|
|
|
|
|
nue.setFinishTime(new Date());
|
|
|
|
|
nue.setClassId(u.getClassId());
|
|
|
|
|
nue.setTeamOrders(teamOrder);
|
|
|
|
|
nue.setClassOrders(classOrder);
|
|
|
|
|
|
|
|
|
|
final ExaminationFinancials nef = ExaminationFinancialsService.initFinancial();
|
|
|
|
|
nef.setRaiseOrders(orderKey);
|
|
|
|
|
nef.setType(1);
|
|
|
|
|
nef.setUserId(u.getUserId());
|
|
|
|
|
|
|
|
|
|
final KeyHolder nefKey = examinationFinancialsService.insertReturnKey(nef);
|
|
|
|
|
nue.setFinancialId(nefKey.getLong());
|
|
|
|
|
|
|
|
|
|
final KeyHolder neiKey = examinationInstancesService.insertReturnKey(nei);
|
|
|
|
|
nue.setInstanceId(neiKey.getLong());
|
|
|
|
|
|
|
|
|
|
userExaminationsService.insert(nue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setScoreOrder(List<UserExaminations> userExaminations, boolean isTeam) {
|
|
|
|
|
private int setScoreOrder(List<UserExaminations> userExaminations, boolean isTeam) {
|
|
|
|
|
userExaminations.sort(Comparator.comparing(UserExaminations::getTotalScores));
|
|
|
|
|
Collections.reverse(userExaminations);
|
|
|
|
|
int orderKey = 1;
|
|
|
|
@ -997,6 +1036,7 @@ public class ExaminationsService extends CoreBaseService<Examinations> {
|
|
|
|
|
}
|
|
|
|
|
orderKey++;
|
|
|
|
|
}
|
|
|
|
|
return orderKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|