|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.jlw.Exception.GlobalException;
|
|
|
|
|
import cn.jlw.util.BusinessUtils;
|
|
|
|
|
import cn.jlw.util.JsonMergeUtil;
|
|
|
|
@ -443,75 +444,66 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
* @param classId 学生班级ID
|
|
|
|
|
* @return classOrder班级排名 integral积分
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Integer> practiceModeIntegral(Long userId, Long classId) {
|
|
|
|
|
Map<String, Integer> result = new HashMap<>();
|
|
|
|
|
result.put("integral", 0);
|
|
|
|
|
final List<UserExaminations> ues = userExaminationsDao.practiceModeIntegralStatistics(classId);
|
|
|
|
|
|
|
|
|
|
final Map<Long, List<UserExaminations>> collect = ues.stream().collect(Collectors.groupingBy(UserExaminations::getUserId));
|
|
|
|
|
if (!collect.containsKey(userId)) {
|
|
|
|
|
// 没有成绩
|
|
|
|
|
result.put("classOrder", collect.keySet().size() + 1);
|
|
|
|
|
return result;
|
|
|
|
|
public UserExaminations userPracticeModeIntegral(Long userId, Long classId) {
|
|
|
|
|
final List<UserExaminations> ues = userExaminationsDao.classPracticeModeIntegral(classId);
|
|
|
|
|
if (ues.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<UserExaminations> integrals = new ArrayList<>();
|
|
|
|
|
for (Long sid : collect.keySet()) {
|
|
|
|
|
final UserExaminations ue = new UserExaminations();
|
|
|
|
|
ue.setUserId(sid);
|
|
|
|
|
ue.setClassOrders(getStudentIntegral(collect.get(sid)));
|
|
|
|
|
integrals.add(ue);
|
|
|
|
|
}
|
|
|
|
|
integrals.sort(Comparator.comparing(UserExaminations::getClassOrders));
|
|
|
|
|
Collections.reverse(integrals);
|
|
|
|
|
|
|
|
|
|
int classOrder = 1;
|
|
|
|
|
for (UserExaminations integral : integrals) {
|
|
|
|
|
if (Objects.equals(integral.getUserId(), userId)) {
|
|
|
|
|
result.put("classOrder", classOrder);
|
|
|
|
|
result.put("integral", integral.getClassOrders());
|
|
|
|
|
break;
|
|
|
|
|
for (UserExaminations ue : ues) {
|
|
|
|
|
if (Objects.equals(userId, ue.getUserId())) {
|
|
|
|
|
return ue;
|
|
|
|
|
}
|
|
|
|
|
classOrder++;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getStudentIntegral(List<UserExaminations> userExaminations) {
|
|
|
|
|
if (userExaminations == null || userExaminations.isEmpty()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
final Map<Integer, List<UserExaminations>> collect =
|
|
|
|
|
userExaminations.stream().filter(i -> i.getMode() != null)
|
|
|
|
|
.collect(Collectors.groupingBy(UserExaminations::getMode));
|
|
|
|
|
int totalIntegral = 0;
|
|
|
|
|
for (Integer mode : collect.keySet()) {
|
|
|
|
|
final List<UserExaminations> modeUEs = collect.get(mode);
|
|
|
|
|
Set<Long> flowIds = new HashSet<>();
|
|
|
|
|
for (UserExaminations modeUE : modeUEs) {
|
|
|
|
|
flowIds.add(modeUE.getFlowId());
|
|
|
|
|
}
|
|
|
|
|
// 完成全部五条流程
|
|
|
|
|
boolean allFlow = flowIds.size() > 4;
|
|
|
|
|
if (mode == 0) {
|
|
|
|
|
// 个人模式20积分
|
|
|
|
|
totalIntegral += modeUEs.size() * 20;
|
|
|
|
|
// 走完全部五个流程的个人练习模式,奖励100积分;
|
|
|
|
|
if (allFlow) {
|
|
|
|
|
totalIntegral += 100;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 团队模式50积分
|
|
|
|
|
totalIntegral += modeUEs.size() * 50;
|
|
|
|
|
// 走完全部五个流程的团队模式,奖励200积分
|
|
|
|
|
if (allFlow) {
|
|
|
|
|
totalIntegral += 200;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 练习模式设置积分,完成一个流程的个人或者团队练习,给积分。五个流程,每走完一遍个人练习流程得20积分,
|
|
|
|
|
* 每走完一遍团队练习团队中每人得50积分,走完全部五个流程的个人练习模式,奖励100积分;
|
|
|
|
|
* 走完全部五个流程的团队模式,奖励200积分。学生端界面显示学生的练习积分及班级排名。
|
|
|
|
|
*/
|
|
|
|
|
public PageQuery<UserIntegerExcel> practiceModeIntegralOrder(UserExaminationsQuery userExaminationsQuery) {
|
|
|
|
|
if (!StringUtils.isEmpty(userExaminationsQuery.getUsername())) {
|
|
|
|
|
userExaminationsQuery.setClassId(null);
|
|
|
|
|
}
|
|
|
|
|
return totalIntegral;
|
|
|
|
|
return userExaminationsDao.practiceModeIntegralOrder(userExaminationsQuery.getPageQuery(), userExaminationsQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private int getStudentIntegral(List<UserExaminations> userExaminations) {
|
|
|
|
|
// if (userExaminations == null || userExaminations.isEmpty()) {
|
|
|
|
|
// return 0;
|
|
|
|
|
// }
|
|
|
|
|
// final Map<Integer, List<UserExaminations>> collect =
|
|
|
|
|
// userExaminations.stream().filter(i -> i.getMode() != null)
|
|
|
|
|
// .collect(Collectors.groupingBy(UserExaminations::getMode));
|
|
|
|
|
// int totalIntegral = 0;
|
|
|
|
|
// for (Integer mode : collect.keySet()) {
|
|
|
|
|
// final List<UserExaminations> modeUEs = collect.get(mode);
|
|
|
|
|
// Set<Long> flowIds = new HashSet<>();
|
|
|
|
|
// for (UserExaminations modeUE : modeUEs) {
|
|
|
|
|
// flowIds.add(modeUE.getFlowId());
|
|
|
|
|
// }
|
|
|
|
|
// // 完成全部五条流程
|
|
|
|
|
// boolean allFlow = flowIds.size() > 4;
|
|
|
|
|
// if (mode == 0) {
|
|
|
|
|
// // 个人模式20积分
|
|
|
|
|
// totalIntegral += modeUEs.size() * 20;
|
|
|
|
|
// // 走完全部五个流程的个人练习模式,奖励100积分;
|
|
|
|
|
// if (allFlow) {
|
|
|
|
|
// totalIntegral += 100;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // 团队模式50积分
|
|
|
|
|
// totalIntegral += modeUEs.size() * 50;
|
|
|
|
|
// // 走完全部五个流程的团队模式,奖励200积分
|
|
|
|
|
// if (allFlow) {
|
|
|
|
|
// totalIntegral += 200;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return totalIntegral;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化没有成绩的学生实训考核
|
|
|
|
|
*/
|
|
|
|
|