This commit is contained in:
@@ -0,0 +1,736 @@
|
||||
package jnpf.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import jnpf.model.cultivate.po.exam.FtbCultivateExam;
|
||||
import jnpf.model.cultivate.po.exam.FtbCultivateExamUser;
|
||||
import jnpf.model.cultivate.po.exam.FtbCultivateExamUserDetail;
|
||||
import jnpf.model.cultivate.po.paper.FtbCultivateTestPaper;
|
||||
import jnpf.model.cultivate.po.question.FtbCultivateQuestion;
|
||||
import jnpf.model.cultivate.req.paper.PaperConfigReq;
|
||||
import jnpf.model.cultivate.resp.*;
|
||||
import jnpf.model.cultivate.v2.exam.po.CultivateExam;
|
||||
import jnpf.model.cultivate.v2.exam.vo.V2ExamStatisticsForPersonExcelVo;
|
||||
import jnpf.model.cultivate.v2.exam.vo.V2ExamStatisticsForPersonVo;
|
||||
import jnpf.model.enums.CourseEnums;
|
||||
import jnpf.model.personnels.dto.staff.roster.WorkerGroupDataDto;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 题目分析工具类
|
||||
*/
|
||||
public class QuestionAnalysisUtil {
|
||||
/**
|
||||
* 初始化返回值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, PaperConfigReq.QuestionNum> initAnalysQuestionCount() {
|
||||
HashMap<String, PaperConfigReq.QuestionNum> map = new HashMap<>();
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.SINGLE.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.MULTI.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.JUDGE.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.FILL.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.INPUT.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
map.put(String.valueOf(CourseEnums.QuestionType.ONE_OR_MULTI.getCode()), new PaperConfigReq.QuestionNum(0, 0, 0));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析题目数量
|
||||
*
|
||||
* @param map
|
||||
* @param questionList
|
||||
* @return
|
||||
*/
|
||||
public static void analysQuestionCount(Map<String, PaperConfigReq.QuestionNum> map,
|
||||
List<FtbCultivateQuestion> questionList) {
|
||||
if (CollectionUtil.isNotEmpty(questionList)) {
|
||||
for (FtbCultivateQuestion question : questionList) {
|
||||
String type = String.valueOf(question.getType());
|
||||
PaperConfigReq.QuestionNum questionNum = map.get(type);
|
||||
if (question.getDifficulty().equals(CourseEnums.QuestionDifficulty.EASY.getCode())) {
|
||||
questionNum.setSimpleNum(questionNum.getSimpleNum() + 1);
|
||||
} else if (question.getDifficulty().equals(CourseEnums.QuestionDifficulty.MIDDLE.getCode())) {
|
||||
questionNum.setGeneralNum(questionNum.getGeneralNum() + 1);
|
||||
} else if (question.getDifficulty().equals(CourseEnums.QuestionDifficulty.MAX.getCode())) {
|
||||
questionNum.setHardNum(questionNum.getHardNum() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算百分比
|
||||
*
|
||||
* @param score 用户考试分数
|
||||
* @param total 试卷总分数
|
||||
* @return
|
||||
*/
|
||||
public static Integer calculatePercentage(int score, int total) {
|
||||
if (total == 0) {
|
||||
return 0; // 避免除以零的错误
|
||||
}
|
||||
return (int) Math.round((score / (float) total) * 100);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算用户考试的状态
|
||||
*
|
||||
* @param exam 考试信息
|
||||
* @param paper 试卷信息
|
||||
* @param score 用户考试的总分数
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static Integer calculateUserExamStatus(FtbCultivateExam exam, FtbCultivateTestPaper paper, Integer score) {
|
||||
int examTotleScore = paper.getTotalScore();//试卷总分数
|
||||
//合格
|
||||
Integer passType = exam.getPassType();//合格分数类型(1固定分,2百分比
|
||||
Integer passMark = exam.getPassMark();//合格分数
|
||||
if (CourseEnums.ExamScoreCheckType.FIXED.getCode().equals(passType)) {
|
||||
if (score >= passMark) {
|
||||
//已经合格,检测是否优秀
|
||||
if (checkIsVeryPass(examTotleScore, score, exam.getExcellentType(), exam.getExcellentMark())) {
|
||||
return CourseEnums.ExamStatus.VERY_PASS.getCode();
|
||||
}
|
||||
return CourseEnums.ExamStatus.PASS.getCode();
|
||||
} else {
|
||||
///不合格
|
||||
return CourseEnums.ExamStatus.NO_PASS.getCode();
|
||||
}
|
||||
} else {
|
||||
Integer calculateScore = QuestionAnalysisUtil.calculateScore(passMark, examTotleScore);
|
||||
if (score >= calculateScore) {
|
||||
//已经合格 判断是否优秀
|
||||
if (checkIsVeryPass(examTotleScore, score, exam.getExcellentType(), exam.getExcellentMark())) {
|
||||
return CourseEnums.ExamStatus.VERY_PASS.getCode();
|
||||
}
|
||||
return CourseEnums.ExamStatus.PASS.getCode();
|
||||
} else {
|
||||
//不合格
|
||||
return CourseEnums.ExamStatus.NO_PASS.getCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer calculateUserExamStatus(FtbCultivateExam exam, Integer examTotleScore, Integer score) {
|
||||
//合格
|
||||
Integer passType = exam.getPassType();//合格分数类型(1固定分,2百分比
|
||||
Integer passMark = exam.getPassMark();//合格分数
|
||||
if (CourseEnums.ExamScoreCheckType.FIXED.getCode().equals(passType)) {
|
||||
if (score >= passMark) {
|
||||
//已经合格,检测是否优秀
|
||||
if (checkIsVeryPass(examTotleScore, score, exam.getExcellentType(), exam.getExcellentMark())) {
|
||||
return CourseEnums.ExamStatus.VERY_PASS.getCode();
|
||||
}
|
||||
return CourseEnums.ExamStatus.PASS.getCode();
|
||||
} else {
|
||||
///不合格
|
||||
return CourseEnums.ExamStatus.NO_PASS.getCode();
|
||||
}
|
||||
} else {
|
||||
Integer calculateScore = QuestionAnalysisUtil.calculateScore(passMark, examTotleScore);
|
||||
if (score >= calculateScore) {
|
||||
//已经合格 判断是否优秀
|
||||
if (checkIsVeryPass(examTotleScore, score, exam.getExcellentType(), exam.getExcellentMark())) {
|
||||
return CourseEnums.ExamStatus.VERY_PASS.getCode();
|
||||
}
|
||||
return CourseEnums.ExamStatus.PASS.getCode();
|
||||
} else {
|
||||
//不合格
|
||||
return CourseEnums.ExamStatus.NO_PASS.getCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否优秀
|
||||
*
|
||||
* @param totleScore 考试总分数
|
||||
* @param score 用户考试分数
|
||||
* @param excellentType 优秀分数类型(1固定分,2百分比)
|
||||
* @param excellentMark 优秀分数
|
||||
* @return false 不优秀 true 优秀
|
||||
*/
|
||||
public static boolean checkIsVeryPass(Integer totleScore, Integer score, Integer excellentType, Integer excellentMark) {
|
||||
if (CourseEnums.ExamScoreCheckType.FIXED.getCode().equals(excellentType)) {
|
||||
//固定分
|
||||
if (score >= excellentMark) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Integer calculateScore = QuestionAnalysisUtil.calculateScore(excellentMark, totleScore);
|
||||
if (score >= calculateScore) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换试卷题目
|
||||
*
|
||||
* @param questionList
|
||||
* @param examUserDetailList
|
||||
* @return
|
||||
*/
|
||||
public static PaperQuestionVo convertPaperQuestionVo(List<UserQuestionVo> questionList, List<FtbCultivateExamUserDetail> examUserDetailList) {
|
||||
PaperQuestionVo vo = new PaperQuestionVo(new HashMap<>());
|
||||
if (CollectionUtil.isEmpty(questionList)) {
|
||||
return vo;
|
||||
}
|
||||
List<AppQuestionVo> appQuestionVoList = BeanUtil.copyToList(questionList, AppQuestionVo.class);
|
||||
if (CollectionUtil.isNotEmpty(examUserDetailList)) {
|
||||
//examUserDetailList 转换成 题目id 的map
|
||||
Map<String, FtbCultivateExamUserDetail> examUserDetailMap = examUserDetailList.stream().collect(Collectors.toMap(FtbCultivateExamUserDetail::getQuestionId, Function.identity()));
|
||||
//填充用户答案
|
||||
for (AppQuestionVo appQuestionVo : appQuestionVoList) {
|
||||
FtbCultivateExamUserDetail detail = examUserDetailMap.get(appQuestionVo.getQuestionId());
|
||||
if (null != detail) {
|
||||
appQuestionVo.setUserAnswer(examUserDetailMap.get(appQuestionVo.getId()).getUserAnswer());
|
||||
appQuestionVo.setIsComplete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Map<String, List<AppQuestionVo>> questionOptionMap = new HashMap<>();
|
||||
//填充题目选项
|
||||
for (AppQuestionVo appQuestionVo : appQuestionVoList) {
|
||||
String type = String.valueOf(appQuestionVo.getType());
|
||||
List<AppQuestionVo> questionOptionVoList = questionOptionMap.get(type);
|
||||
if (CollectionUtil.isEmpty(questionOptionVoList)) {
|
||||
questionOptionVoList = new ArrayList<>();
|
||||
}
|
||||
questionOptionVoList.add(appQuestionVo);
|
||||
questionOptionMap.put(type, questionOptionVoList);
|
||||
}
|
||||
vo.setQuestionMap(questionOptionMap);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多选题判断是否正确
|
||||
*
|
||||
* @param answer 标准答案
|
||||
* @param userAnswer 用户答案
|
||||
* @return true 正确 false 错误
|
||||
*/
|
||||
public static boolean checkMultiRight(String answer, String userAnswer) {
|
||||
if (StringUtils.isEmpty(answer) || StringUtils.isEmpty(userAnswer)) {
|
||||
return false;
|
||||
}
|
||||
if (answer.equals(userAnswer)) {
|
||||
return true;
|
||||
}
|
||||
List<String> answerList = Arrays.asList(answer.split(","));
|
||||
List<String> userAnswerList = Arrays.asList(userAnswer.split(","));
|
||||
if (answerList.size() != userAnswerList.size()) {
|
||||
return false;
|
||||
}
|
||||
Collections.sort(answerList);
|
||||
Collections.sort(userAnswerList);
|
||||
String answerStr = String.join(",", answerList);
|
||||
String userAnswerStr = String.join(",", userAnswerList);
|
||||
if (answerStr.equals(userAnswerStr)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个日期之间的秒数
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
public static Long differenceSecond(Date start, Date end) {
|
||||
//计算两个日期之间的秒数
|
||||
Calendar calendar1 = Calendar.getInstance();
|
||||
Calendar calendar2 = Calendar.getInstance();
|
||||
|
||||
// 设置Calendar对象的时间为date1和date2
|
||||
calendar1.setTime(start);
|
||||
calendar2.setTime(end);
|
||||
|
||||
// 计算两个日期之间的秒数差
|
||||
return (calendar2.getTimeInMillis() - calendar1.getTimeInMillis()) / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计用户考试总数和已完成数
|
||||
*
|
||||
* @param examUserList
|
||||
* @return
|
||||
*/
|
||||
public static UserExamCount countCompleteAndTotleExamNum(List<FtbCultivateExamUser> examUserList) {
|
||||
Set<String> totle = new HashSet<>();
|
||||
Set<String> complete = new HashSet<>();
|
||||
for (FtbCultivateExamUser examUser : examUserList) {
|
||||
StringBuilder sbTotle = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
totle.add(sbTotle.toString());
|
||||
if (!CourseEnums.ExamStatus.WAIT.getCode().equals(examUser.getStatus()) &&
|
||||
!CourseEnums.ExamStatus.OVERDUE.getCode().equals(examUser.getStatus())) {
|
||||
StringBuilder completeTotle = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
complete.add(completeTotle.toString());
|
||||
}
|
||||
}
|
||||
UserExamCount userExamCount = new UserExamCount();
|
||||
userExamCount.setTotleNum(totle.size());
|
||||
userExamCount.setCompleteNum(complete.size());
|
||||
return userExamCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计开始日期
|
||||
*
|
||||
* @param date 目标日期
|
||||
* @param type 统计类型 1月,2季度,3年
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static Date getStatisticsStartDate(Date date, Integer type) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
|
||||
if (type == 1) {
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
} else if (type == 2) {
|
||||
calendar.add(Calendar.MONTH, -3);
|
||||
} else {
|
||||
calendar.add(Calendar.YEAR, -1);
|
||||
}
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计用户考试合格率
|
||||
*
|
||||
* @param examUserList
|
||||
*/
|
||||
public static StatisticsResultDto statisticeLv(List<FtbCultivateExamUser> examUserList) {
|
||||
StatisticsResultDto dto = new StatisticsResultDto();
|
||||
if (CollectionUtil.isEmpty(examUserList)) {
|
||||
return dto;
|
||||
}
|
||||
int totle = examUserList.size();
|
||||
int pass = 0;
|
||||
int noPass = 0;
|
||||
int excellent = 0;
|
||||
|
||||
for (FtbCultivateExamUser examUser : examUserList) {
|
||||
if (CourseEnums.ExamStatus.PASS.getCode().equals(examUser.getStatus())) {
|
||||
pass++;
|
||||
} else if (CourseEnums.ExamStatus.VERY_PASS.getCode().equals(examUser.getStatus())) {
|
||||
pass++;
|
||||
excellent++;
|
||||
} else if (CourseEnums.ExamStatus.NO_PASS.getCode().equals(examUser.getStatus())) {
|
||||
noPass++;
|
||||
}
|
||||
}
|
||||
|
||||
dto.setPass(pass);
|
||||
dto.setNoPass(noPass);
|
||||
dto.setTotle(totle);
|
||||
dto.setExcellent(excellent);
|
||||
dto.setPassLv(Double.valueOf(Math.round((pass / (float) totle) * 100)));
|
||||
dto.setExcellentLv(Double.valueOf(Math.round((excellent / (float) totle) * 100)));
|
||||
dto.setNoPassLv(Double.valueOf(Math.round((noPass / (float) totle) * 100)));
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static StatisticsResultDto statisticeLvForAppExam(List<AppExamListVo> examUserList) {
|
||||
StatisticsResultDto dto = new StatisticsResultDto();
|
||||
if (CollectionUtil.isEmpty(examUserList)) {
|
||||
return dto;
|
||||
}
|
||||
int totle = examUserList.size();
|
||||
int pass = 0;
|
||||
int noPass = 0;
|
||||
int excellent = 0;
|
||||
|
||||
for (AppExamListVo examUser : examUserList) {
|
||||
if (CourseEnums.ExamStatus.PASS.getCode().equals(examUser.getStatus())) {
|
||||
pass++;
|
||||
} else if (CourseEnums.ExamStatus.VERY_PASS.getCode().equals(examUser.getStatus())) {
|
||||
excellent++;
|
||||
} else if (CourseEnums.ExamStatus.NO_PASS.getCode().equals(examUser.getStatus())) {
|
||||
noPass++;
|
||||
}
|
||||
}
|
||||
|
||||
dto.setPass(pass);
|
||||
dto.setNoPass(noPass);
|
||||
dto.setTotle(totle);
|
||||
dto.setExcellent(excellent);
|
||||
dto.setPassLv(Double.valueOf(Math.round(((pass + excellent) / (float) totle) * 100)));
|
||||
dto.setExcellentLv(Double.valueOf(Math.round((excellent / (float) totle) * 100)));
|
||||
dto.setNoPassLv(Double.valueOf(Math.round((noPass / (float) totle) * 100)));
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计合格数量 和 总数量
|
||||
*
|
||||
* @param examUserList
|
||||
* @return
|
||||
*/
|
||||
public static UserExamCount countPassAndTotleExamNum(List<FtbCultivateExamUser> examUserList) {
|
||||
Set<String> totle = new HashSet<>();
|
||||
Set<String> pass = new HashSet<>();
|
||||
Set<String> noPassNum = new HashSet<>();
|
||||
Set<String> waitNumSet = new HashSet<>();
|
||||
for (FtbCultivateExamUser examUser : examUserList) {
|
||||
StringBuilder sbTotle = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getUserId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
totle.add(sbTotle.toString());
|
||||
if (CourseEnums.ExamStatus.PASS.getCode().equals(examUser.getStatus()) ||
|
||||
CourseEnums.ExamStatus.VERY_PASS.getCode().equals(examUser.getStatus())) {
|
||||
StringBuilder passTotle = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getUserId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
pass.add(passTotle.toString());
|
||||
}
|
||||
|
||||
if (CourseEnums.ExamStatus.NO_PASS.getCode().equals(examUser.getStatus())) {
|
||||
StringBuilder noPassSb = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getUserId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
noPassNum.add(noPassSb.toString());
|
||||
}
|
||||
|
||||
if (CourseEnums.ExamStatus.WAIT_CHECK.getCode().equals(examUser.getStatus())) {
|
||||
StringBuilder waitSb = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getUserId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
waitNumSet.add(waitSb.toString());
|
||||
}
|
||||
}
|
||||
UserExamCount userExamCount = new UserExamCount();
|
||||
userExamCount.setTotleNum(totle.size());
|
||||
userExamCount.setPassTotleNum(pass.size());
|
||||
userExamCount.setNoPassNum(noPassNum.size());
|
||||
userExamCount.setWaitNum(waitNumSet.size());
|
||||
return userExamCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计初试复试合格率
|
||||
*
|
||||
* @param examUserList
|
||||
* @return
|
||||
*/
|
||||
public static StatisticsResultFirstAndRepeatDto statisticeFirstAndRepeatLv(List<FtbCultivateExamUser> examUserList) {
|
||||
|
||||
Set<String> totle = new HashSet<>();
|
||||
Map<String, Integer> pass = new HashMap<>();
|
||||
for (FtbCultivateExamUser examUser : examUserList) {
|
||||
StringBuilder sbTotleKey = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
totle.add(sbTotleKey.toString());
|
||||
if (CourseEnums.ExamStatus.PASS.getCode().equals(examUser.getStatus()) ||
|
||||
CourseEnums.ExamStatus.VERY_PASS.getCode().equals(examUser.getStatus())) {
|
||||
StringBuilder sbPassKey = new StringBuilder()
|
||||
.append(examUser.getExamId())
|
||||
.append(examUser.getExamSource())
|
||||
.append(examUser.getRelationRankId())
|
||||
.append(examUser.getRelationCourseExamId())
|
||||
.append(examUser.getRelationPositionExamId());
|
||||
String key = sbPassKey.toString();
|
||||
Integer num = pass.get(key);
|
||||
if (null == num) {
|
||||
pass.put(key, 1);
|
||||
} else {
|
||||
pass.put(key, num + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
StatisticsResultFirstAndRepeatDto dto = new StatisticsResultFirstAndRepeatDto();
|
||||
dto.setTotle(totle.size());
|
||||
//遍历 pass
|
||||
int firstPass = 0;
|
||||
int repeatPass = 0;
|
||||
for (Map.Entry<String, Integer> entry : pass.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Integer num = entry.getValue();
|
||||
if (num == 1) {
|
||||
firstPass++;
|
||||
} else {
|
||||
repeatPass++;
|
||||
}
|
||||
}
|
||||
dto.setFirstPass(firstPass);
|
||||
dto.setRepeatPass(repeatPass);
|
||||
dto.setFirstPassLv(Double.valueOf(Math.round((firstPass / (float) dto.getTotle()) * 100)));
|
||||
dto.setRepeatPassLv(Double.valueOf(Math.round((repeatPass / (float) dto.getTotle()) * 100)));
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算合格分数
|
||||
*
|
||||
* @param num1
|
||||
* @param num2
|
||||
* @return
|
||||
*/
|
||||
public static Integer calculateScore(Integer num1, Integer num2) {
|
||||
if (num1 == null || num1 == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (num2 == null || num2 == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double lv = (double) num1 / 100 * num2;
|
||||
DecimalFormat df = new DecimalFormat("#");
|
||||
return Integer.valueOf(df.format(lv));
|
||||
}
|
||||
|
||||
public static BigDecimal calculateScoreV2(Integer num1, Integer num2) {
|
||||
if (num1 == null || num1 == 0) {
|
||||
return new BigDecimal(0);
|
||||
}
|
||||
if (num2 == null || num2 == 0) {
|
||||
return new BigDecimal(0);
|
||||
}
|
||||
return new BigDecimal(num1).multiply(new BigDecimal(num2)).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Date date = new Date();
|
||||
Thread.sleep(1000);
|
||||
Date now = new Date();
|
||||
if (now.after(date)) {
|
||||
System.out.println("在之后");
|
||||
} else {
|
||||
System.out.println("不在之后");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最高分
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static UserRankingVo getMaxScore(List<UserRankingVo> list) {
|
||||
UserRankingVo vo = list.get(0);
|
||||
for (UserRankingVo userRankingVo : list) {
|
||||
int score = Integer.parseInt(userRankingVo.getScore());
|
||||
int maxScore = Integer.parseInt(vo.getScore());
|
||||
if (score > maxScore) {
|
||||
vo = userRankingVo;
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
public static ExamStatisticsForPersonExcelVo convertToExcelPersonvo(ExamStatisticsForPersonVo vo) {
|
||||
ExamStatisticsForPersonExcelVo excel = new ExamStatisticsForPersonExcelVo();
|
||||
excel.setUserName(vo.getUserName());
|
||||
excel.setSystemWokerId(vo.getSystemWokerId());
|
||||
List<WorkerGroupDataDto> userOrgList = vo.getUserOrgList();
|
||||
if (CollectionUtil.isNotEmpty(userOrgList)) {
|
||||
List<String> names = userOrgList.stream()
|
||||
.map(WorkerGroupDataDto::getAffiliatedOrgName)
|
||||
.collect(Collectors.toList());
|
||||
excel.setOrgName(String.join(",", names));
|
||||
|
||||
List<String> orgIds = userOrgList.stream()
|
||||
.map(WorkerGroupDataDto::getOrgEncode)
|
||||
.collect(Collectors.toList());
|
||||
excel.setOrgId(String.join(",", orgIds));
|
||||
|
||||
|
||||
List<String> positionAndRanks = new ArrayList<>();
|
||||
for (WorkerGroupDataDto workerGroupDataDto : userOrgList) {
|
||||
positionAndRanks.add(workerGroupDataDto.getAffiliatedPositionName() + "_" + workerGroupDataDto.getAffiliatedRankName());
|
||||
}
|
||||
|
||||
excel.setPositionAndRank(String.join(",", positionAndRanks));
|
||||
|
||||
List<String> positionIds = userOrgList.stream()
|
||||
.map(WorkerGroupDataDto::getPositionEncode)
|
||||
.collect(Collectors.toList());
|
||||
excel.setPositonId(String.join(",", positionIds));
|
||||
|
||||
}
|
||||
if (null != vo.getStudyPostionName()) {
|
||||
excel.setStudyPositionAndRank(vo.getStudyPostionName());
|
||||
}
|
||||
//试卷类型,1岗位学习试卷,2常规试卷
|
||||
if (vo.getExamType() == 0) {
|
||||
excel.setExamType("岗位学习考试");
|
||||
} else if (vo.getExamType() == 1) {
|
||||
excel.setExamType("自定义考试");
|
||||
}
|
||||
if (null != vo.getFinishtime()) {
|
||||
excel.setFinishtime(DateUtil.format(vo.getFinishtime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (null != vo.getDuration()) {
|
||||
excel.setDuration(vo.getDuration() / 60 + "分钟");
|
||||
}
|
||||
if (null != vo.getExamTime()) {
|
||||
excel.setExamTime(vo.getExamTime() + "分钟");
|
||||
}
|
||||
if (null != vo.getScore()) {
|
||||
excel.setScore(vo.getScore() + "");
|
||||
}
|
||||
//(0待考试,1待批阅,2已逾期,3合格,4不合格,5优秀)
|
||||
if (vo.getStatus() == 0 || vo.getStatus() == 2) {
|
||||
excel.setExamStatus("待考");
|
||||
} else {
|
||||
excel.setExamStatus("已考");
|
||||
}
|
||||
|
||||
if (vo.getStatus() == 1) {
|
||||
excel.setExamResult("待批阅");
|
||||
} else if (vo.getStatus() == 3) {
|
||||
excel.setExamResult("合格");
|
||||
} else if (vo.getStatus() == 4) {
|
||||
excel.setExamResult("不合格");
|
||||
} else if (vo.getStatus() == 5) {
|
||||
excel.setExamResult("优秀");
|
||||
}
|
||||
return excel;
|
||||
}
|
||||
|
||||
public static V2ExamStatisticsForPersonExcelVo convertToExcelPersonvoV2(V2ExamStatisticsForPersonVo vo) {
|
||||
V2ExamStatisticsForPersonExcelVo excel = new V2ExamStatisticsForPersonExcelVo();
|
||||
excel.setUserName(vo.getUserName());
|
||||
excel.setSystemWorkerId(vo.getSystemWorkerId());
|
||||
excel.setOrgName(vo.getOrganizeName());
|
||||
excel.setOrgId(vo.getOrganizeId());
|
||||
if (StringUtils.isEmpty(vo.getGradeName())) {
|
||||
excel.setPositionAndRank(vo.getPositionName());
|
||||
} else {
|
||||
excel.setPositionAndRank(vo.getPositionName() + "_" + vo.getGradeName());
|
||||
}
|
||||
excel.setPositionId(vo.getPositionEnCode());
|
||||
if (null != vo.getStudyPositionName()) {
|
||||
excel.setStudyPositionAndRank(vo.getStudyPositionName());
|
||||
}
|
||||
excel.setExamName(vo.getExamName());
|
||||
|
||||
//试卷类型,1岗位学习试卷,2常规试卷
|
||||
if (vo.getExamType() == 0) {
|
||||
excel.setExamType("岗位学习考试");
|
||||
} else if (vo.getExamType() == 1) {
|
||||
excel.setExamType("自定义考试");
|
||||
}
|
||||
if (null != vo.getFinishtime()) {
|
||||
excel.setFinishtime(DateUtil.format(vo.getFinishtime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (null != vo.getDuration()) {
|
||||
excel.setDuration(vo.getDuration() / 60 + "分钟");
|
||||
}
|
||||
if (null != vo.getExamTime()) {
|
||||
excel.setExamTime(vo.getExamTime() + "分钟");
|
||||
}
|
||||
if (null != vo.getScore()) {
|
||||
excel.setScore(vo.getScore() + "");
|
||||
}
|
||||
//(0待考试,1待批阅,2已逾期,3合格,4不合格,5优秀)
|
||||
if (vo.getStatus() == 0 || vo.getStatus() == 2) {
|
||||
excel.setExamStatus("待考");
|
||||
} else {
|
||||
excel.setExamStatus("已考");
|
||||
}
|
||||
|
||||
if (vo.getStatus() == 1) {
|
||||
excel.setExamResult("待批阅");
|
||||
} else if (vo.getStatus() == 3) {
|
||||
excel.setExamResult("合格");
|
||||
} else if (vo.getStatus() == 4) {
|
||||
excel.setExamResult("不合格");
|
||||
} else if (vo.getStatus() == 5) {
|
||||
excel.setExamResult("优秀");
|
||||
}
|
||||
return excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应字符串list去重复
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static List<String> uniqueStringList(List<String> list) {
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> filteredList = list.stream()
|
||||
.filter(str -> !str.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
Set<String> uniqueSet = new HashSet<>(filteredList);
|
||||
return new ArrayList<>(uniqueSet);
|
||||
}
|
||||
|
||||
public static BigDecimal calPassScore(Integer totalScore, CultivateExam exam) {
|
||||
//合格
|
||||
Integer type = exam.getPassType();//合格分数类型(1固定分,2百分比
|
||||
Integer mark = exam.getPassMark();//合格分数
|
||||
if (CourseEnums.ExamScoreCheckType.FIXED.getCode().equals(type)) {
|
||||
return new BigDecimal(mark);
|
||||
} else {
|
||||
return calculateScoreV2(mark, totalScore);
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal calExcellentScore(Integer totalScore, CultivateExam exam) {
|
||||
Integer type = exam.getExcellentType();//优秀分数类型(1固定分,2百分比
|
||||
Integer mark = exam.getExcellentMark();//优秀分数
|
||||
if (CourseEnums.ExamScoreCheckType.FIXED.getCode().equals(type)) {
|
||||
return new BigDecimal(mark);
|
||||
} else {
|
||||
return calculateScoreV2(mark, totalScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user