|
|
|
@ -4,18 +4,21 @@ import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.sztzjy.money_management.entity.*;
|
|
|
|
|
import com.sztzjy.money_management.entity.dto.CalcAuthScore;
|
|
|
|
|
import com.sztzjy.money_management.entity.dto.StuAuthTestDto;
|
|
|
|
|
import com.sztzjy.money_management.entity.dto.StuTheoryExamDetailDto;
|
|
|
|
|
import com.sztzjy.money_management.entity.dto.StuTheoryTestDto;
|
|
|
|
|
import com.sztzjy.money_management.mapper.*;
|
|
|
|
|
import com.sztzjy.money_management.service.TheoryTestService;
|
|
|
|
|
import com.sztzjy.money_management.util.ResultEntity;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -40,9 +43,12 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
@Override
|
|
|
|
|
public int endTheoryTest(StuTheoryTestDto theoryTestDto) {
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(theoryTestDto.getUserId());
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(theoryTestDto.getUserId()).andSourceEqualTo(theoryTestDto.getSource());
|
|
|
|
|
example.setOrderByClause("exam_time DESC");
|
|
|
|
|
List<StuTheoryExamWithBLOBs> stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
if (stuTheoryExams == null || stuTheoryExams.isEmpty()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
StuTheoryExamWithBLOBs stuTheoryExam = stuTheoryExams.get(0);
|
|
|
|
|
stuTheoryExam.setExamDuration(theoryTestDto.getExamDuration());
|
|
|
|
|
stuTheoryExam.setScore(theoryTestDto.getScore());
|
|
|
|
@ -56,60 +62,63 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
stuTheoryExam.setJudgeStuAnswer(String.valueOf(theoryTestDto.getJudgeStuAnswer()));
|
|
|
|
|
stuTheoryExam.setErrorIds(list.toString());
|
|
|
|
|
stuTheoryExam.setAnswered(true);
|
|
|
|
|
stuTheoryExam.setSource(theoryTestDto.getSource());
|
|
|
|
|
int i = theoryExamMapper.updateByPrimaryKeyWithBLOBs(stuTheoryExam);
|
|
|
|
|
|
|
|
|
|
//更新错题集
|
|
|
|
|
StuErrorExample errorExample = new StuErrorExample();
|
|
|
|
|
errorExample.createCriteria().andUserIdEqualTo(theoryTestDto.getUserId());
|
|
|
|
|
List<StuErrorWithBLOBs> stuErrors = errorMapper.selectByExampleWithBLOBs(errorExample);
|
|
|
|
|
if (stuErrors.isEmpty()) {
|
|
|
|
|
StuErrorWithBLOBs stuError = new StuErrorWithBLOBs();
|
|
|
|
|
stuError.setErrorId(IdUtil.randomUUID());
|
|
|
|
|
stuError.setUserId(theoryTestDto.getUserId());
|
|
|
|
|
stuError.setSingleIds(String.valueOf(theoryTestDto.getSingleErrorIds()));
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(theoryTestDto.getMultipleErrorIds()));
|
|
|
|
|
stuError.setJudgeIds(String.valueOf(theoryTestDto.getJudgeErrorIds()));
|
|
|
|
|
errorMapper.insert(stuError);
|
|
|
|
|
} else {
|
|
|
|
|
StuErrorWithBLOBs stuError = stuErrors.get(0);
|
|
|
|
|
if (stuError.getSingleIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> singleErrorIds = theoryTestDto.getSingleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(singleErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setSingleIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
if (theoryTestDto.getSource().equals("理论考试")) {
|
|
|
|
|
//更新错题集
|
|
|
|
|
StuErrorExample errorExample = new StuErrorExample();
|
|
|
|
|
errorExample.createCriteria().andUserIdEqualTo(theoryTestDto.getUserId());
|
|
|
|
|
List<StuErrorWithBLOBs> stuErrors = errorMapper.selectByExampleWithBLOBs(errorExample);
|
|
|
|
|
if (stuErrors.isEmpty()) {
|
|
|
|
|
StuErrorWithBLOBs stuError = new StuErrorWithBLOBs();
|
|
|
|
|
stuError.setErrorId(IdUtil.randomUUID());
|
|
|
|
|
stuError.setUserId(theoryTestDto.getUserId());
|
|
|
|
|
stuError.setSingleIds(String.valueOf(theoryTestDto.getSingleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getMultipleIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> multipleErrorIds = theoryTestDto.getMultipleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(multipleErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(theoryTestDto.getMultipleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getJudgeIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", "));
|
|
|
|
|
List<String> judgeErrorIds = theoryTestDto.getJudgeErrorIds();
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(judgeErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setJudgeIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
stuError.setJudgeIds(String.valueOf(theoryTestDto.getJudgeErrorIds()));
|
|
|
|
|
errorMapper.insert(stuError);
|
|
|
|
|
} else {
|
|
|
|
|
StuErrorWithBLOBs stuError = stuErrors.get(0);
|
|
|
|
|
if (stuError.getSingleIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> singleErrorIds = theoryTestDto.getSingleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(singleErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setSingleIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
stuError.setSingleIds(String.valueOf(theoryTestDto.getSingleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getMultipleIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> multipleErrorIds = theoryTestDto.getMultipleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(multipleErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(theoryTestDto.getMultipleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getJudgeIds() != null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", "));
|
|
|
|
|
List<String> judgeErrorIds = theoryTestDto.getJudgeErrorIds();
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(judgeErrorIds);
|
|
|
|
|
Set<String> uniqueSet = new HashSet<>(combinedList);
|
|
|
|
|
List<String> uniqueList = new ArrayList<>(uniqueSet);
|
|
|
|
|
stuError.setJudgeIds(String.valueOf(uniqueList));
|
|
|
|
|
} else {
|
|
|
|
|
stuError.setJudgeIds(String.valueOf(theoryTestDto.getJudgeErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
errorMapper.updateByPrimaryKeySelective(stuError);
|
|
|
|
|
}
|
|
|
|
|
errorMapper.updateByPrimaryKeySelective(stuError);
|
|
|
|
|
UpdateTheoryRecord(theoryTestDto.getUserId(), theoryTestDto.getScore(), theoryTestDto.getExamDuration());
|
|
|
|
|
}
|
|
|
|
|
UpdateTheoryRecord(theoryTestDto.getUserId(), theoryTestDto.getScore(), theoryTestDto.getExamDuration());
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -153,9 +162,9 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Date getStartTime(String userId) {
|
|
|
|
|
public Date getStartTime(String userId, String source) {
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo(source);
|
|
|
|
|
example.setOrderByClause("exam_time DESC");
|
|
|
|
|
List<StuTheoryExamWithBLOBs> stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
if (stuTheoryExams.isEmpty()) { //之前没有进行考试
|
|
|
|
@ -175,14 +184,238 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**返回认证考试记录
|
|
|
|
|
* @author xcj
|
|
|
|
|
* @Date 2024/8/26
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ResultEntity<StuAuthTestDto> getAuthTestRecord(String theoryExamId) {
|
|
|
|
|
StuAuthTestDto dto = new StuAuthTestDto();
|
|
|
|
|
StuTheoryExamWithBLOBs data = theoryExamMapper.selectByPrimaryKey(theoryExamId);
|
|
|
|
|
BeanUtils.copyProperties(data, dto);
|
|
|
|
|
String source = data.getSource();
|
|
|
|
|
int singleSize = data.getSingleIds().split(",").length;
|
|
|
|
|
int multipleSize = data.getMultipleIds().split(",").length;
|
|
|
|
|
int judgeSize = data.getJudgeIds().split(",").length;
|
|
|
|
|
String name = userMapper.selectByPrimaryKey(data.getUserId()).getName();
|
|
|
|
|
int totalSize = singleSize + multipleSize + judgeSize;
|
|
|
|
|
List<CalcAuthScore> list = new ArrayList<>();
|
|
|
|
|
CalcAuthScore singleScore = new CalcAuthScore();
|
|
|
|
|
singleScore.setType("单选题");
|
|
|
|
|
CalcAuthScore multipleScore = new CalcAuthScore();
|
|
|
|
|
multipleScore.setType("多选题");
|
|
|
|
|
CalcAuthScore judgeScore = new CalcAuthScore();
|
|
|
|
|
judgeScore.setType("判断题");
|
|
|
|
|
|
|
|
|
|
int singleCount = 0;
|
|
|
|
|
int multipleCount = 0;
|
|
|
|
|
int judgeCount = 0;
|
|
|
|
|
if (!StringUtils.isBlank(data.getErrorIds())) {
|
|
|
|
|
List<String> errorList = Arrays.asList(data.getErrorIds().split(","));
|
|
|
|
|
ObjectiveQuestionExample example = new ObjectiveQuestionExample();
|
|
|
|
|
example.createCriteria().andObjectiveIdIn(errorList);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> dataErrors = objectiveQuestionMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
|
|
|
|
|
for (ObjectiveQuestionWithBLOBs dataError : dataErrors) {
|
|
|
|
|
if (dataError.getType() == 0) {
|
|
|
|
|
singleCount++;
|
|
|
|
|
} else if (dataError.getType() == 1) {
|
|
|
|
|
multipleCount++;
|
|
|
|
|
} else if (dataError.getType() == 2) {
|
|
|
|
|
judgeCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (source) {
|
|
|
|
|
case "理论知识":
|
|
|
|
|
singleScore = calculateScore(singleSize, singleCount, BigDecimal.valueOf(0.6), totalSize);
|
|
|
|
|
multipleScore = calculateScore(multipleSize, multipleCount, BigDecimal.valueOf(0.3), totalSize);
|
|
|
|
|
judgeScore = calculateScore(judgeSize, judgeCount, BigDecimal.valueOf(0.1), totalSize);
|
|
|
|
|
break;
|
|
|
|
|
case "专业能力":
|
|
|
|
|
singleScore = calculateScore(singleSize, singleCount, BigDecimal.ONE, totalSize);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
singleScore = calculateScore(singleSize, singleCount, BigDecimal.valueOf(0.9), totalSize);
|
|
|
|
|
multipleScore = calculateScore(multipleSize, multipleCount, BigDecimal.valueOf(0.4), totalSize);
|
|
|
|
|
judgeScore = calculateScore(judgeSize, judgeCount, BigDecimal.valueOf(0.15), totalSize);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BigDecimal totalScore = singleScore.getScore()
|
|
|
|
|
.add(multipleScore.getScore())
|
|
|
|
|
.add(judgeScore.getScore());
|
|
|
|
|
dto.setTotalScore(totalScore.setScale(0, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
|
|
|
list.add(singleScore);
|
|
|
|
|
list.add(multipleScore);
|
|
|
|
|
list.add(judgeScore);
|
|
|
|
|
dto.setCalcAuthScoreList(list);
|
|
|
|
|
dto.setName(name);
|
|
|
|
|
return new ResultEntity<StuAuthTestDto>(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CalcAuthScore calculateScore(int questionSize, int errorCount, BigDecimal weight, int totalSize) {
|
|
|
|
|
CalcAuthScore score = new CalcAuthScore();
|
|
|
|
|
if (questionSize == 0) {
|
|
|
|
|
score.setAccuracy("0");
|
|
|
|
|
score.setScore(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal accuracy = BigDecimal.valueOf(questionSize - errorCount)
|
|
|
|
|
.divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
.multiply(BigDecimal.valueOf(100))
|
|
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
score.setAccuracy(String.valueOf(questionSize - errorCount));
|
|
|
|
|
score.setScore(accuracy.multiply(weight).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
}
|
|
|
|
|
return score;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override //原始写法
|
|
|
|
|
// public ResultEntity<StuAuthTestDto> getAuthTestRecord(String theoryExamId) {
|
|
|
|
|
// StuAuthTestDto dto = new StuAuthTestDto();
|
|
|
|
|
// StuTheoryExamWithBLOBs data = theoryExamMapper.selectByPrimaryKey(theoryExamId);
|
|
|
|
|
// BeanUtils.copyProperties(data, dto);
|
|
|
|
|
// String source = data.getSource();
|
|
|
|
|
// int singleSize = data.getSingleIds().split(",").length;
|
|
|
|
|
// int multipleSize = data.getMultipleIds().split(",").length;
|
|
|
|
|
// int judgeSize = data.getJudgeIds().split(",").length;
|
|
|
|
|
// String name = userMapper.selectByPrimaryKey(data.getUserId()).getName();
|
|
|
|
|
//
|
|
|
|
|
// int totalSize = singleSize + multipleSize + judgeSize;
|
|
|
|
|
// List<CalcAuthScore> list = new ArrayList<>();
|
|
|
|
|
// CalcAuthScore singleScore = new CalcAuthScore();
|
|
|
|
|
// singleScore.setType("单选题");
|
|
|
|
|
// CalcAuthScore multipleScore = new CalcAuthScore();
|
|
|
|
|
// multipleScore.setType("多选题");
|
|
|
|
|
// CalcAuthScore judgeScore = new CalcAuthScore();
|
|
|
|
|
// judgeScore.setType("判断题");
|
|
|
|
|
// if (StringUtils.isBlank(data.getErrorIds())) { //没有错题全对的情况
|
|
|
|
|
// if (source.equals("理论知识")) { //60 30 10
|
|
|
|
|
// singleScore.setAccuracy("60");
|
|
|
|
|
// singleScore.setScore(BigDecimal.valueOf(60));
|
|
|
|
|
// multipleScore.setAccuracy("30");
|
|
|
|
|
// multipleScore.setScore(BigDecimal.valueOf(30));
|
|
|
|
|
// judgeScore.setAccuracy("10");
|
|
|
|
|
// judgeScore.setScore(BigDecimal.valueOf(10));
|
|
|
|
|
// }
|
|
|
|
|
// if (source.equals("专业能力")) { // 100
|
|
|
|
|
// singleScore.setAccuracy("100");
|
|
|
|
|
// singleScore.setScore(BigDecimal.valueOf(100));
|
|
|
|
|
// } else { //90 40 15
|
|
|
|
|
// singleScore.setAccuracy("90");
|
|
|
|
|
// singleScore.setScore(BigDecimal.valueOf(90));
|
|
|
|
|
// multipleScore.setAccuracy("40");
|
|
|
|
|
// multipleScore.setScore(BigDecimal.valueOf(40));
|
|
|
|
|
// judgeScore.setAccuracy("15");
|
|
|
|
|
// judgeScore.setScore(BigDecimal.valueOf(15));
|
|
|
|
|
// dto.setTotalScore(BigDecimal.valueOf(100));
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// List<String> errorList = Arrays.asList(data.getErrorIds().split(","));
|
|
|
|
|
// ObjectiveQuestionExample example = new ObjectiveQuestionExample();
|
|
|
|
|
// example.createCriteria().andObjectiveIdIn(errorList);
|
|
|
|
|
// List<ObjectiveQuestionWithBLOBs> dataErrors = objectiveQuestionMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
// int singleCount = 0;
|
|
|
|
|
// int multipleCount = 0;
|
|
|
|
|
// int judgeCount = 0;
|
|
|
|
|
// for (ObjectiveQuestionWithBLOBs dataError : dataErrors) {
|
|
|
|
|
// Integer type = dataError.getType();
|
|
|
|
|
// if (type == 0) {
|
|
|
|
|
// singleCount++;
|
|
|
|
|
// }
|
|
|
|
|
// if (type == 1) {
|
|
|
|
|
// multipleCount++;
|
|
|
|
|
// }
|
|
|
|
|
// if (type == 2) {
|
|
|
|
|
// judgeCount++;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (source.equals("理论知识")) { //60 30 10
|
|
|
|
|
// BigDecimal bigDecimal = BigDecimal.valueOf(singleSize - singleCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// singleScore.setAccuracy(String.valueOf(singleSize - singleCount));
|
|
|
|
|
// singleScore.setScore(bigDecimal);
|
|
|
|
|
//
|
|
|
|
|
// BigDecimal bigDecimal2 = BigDecimal.valueOf(multipleSize - multipleCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// multipleScore.setAccuracy(String.valueOf(multipleSize - multipleCount));
|
|
|
|
|
// multipleScore.setScore(bigDecimal2);
|
|
|
|
|
//
|
|
|
|
|
// BigDecimal bigDecimal3 = BigDecimal.valueOf(judgeSize - judgeCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// judgeScore.setAccuracy(String.valueOf(judgeSize - judgeCount));
|
|
|
|
|
// judgeScore.setScore(bigDecimal3);
|
|
|
|
|
// BigDecimal tatol = bigDecimal.add(bigDecimal2.add(bigDecimal3))
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize))
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(0, RoundingMode.HALF_UP); //保留整数 四舍五入
|
|
|
|
|
// dto.setTotalScore(tatol);
|
|
|
|
|
// }
|
|
|
|
|
// if (source.equals("专业能力")) { // 100
|
|
|
|
|
// BigDecimal bigDecimal = BigDecimal.valueOf(singleSize - singleCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// singleScore.setAccuracy(String.valueOf(singleSize - singleCount));
|
|
|
|
|
// singleScore.setScore(bigDecimal);
|
|
|
|
|
// BigDecimal tatol = bigDecimal.divide(BigDecimal.valueOf(totalSize))
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(0, RoundingMode.HALF_UP); //保留整数 四舍五入
|
|
|
|
|
// dto.setTotalScore(tatol);
|
|
|
|
|
// } else { //90 40 15
|
|
|
|
|
// BigDecimal bigDecimal = BigDecimal.valueOf(singleSize - singleCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// singleScore.setAccuracy(String.valueOf(singleSize - singleCount));
|
|
|
|
|
// singleScore.setScore(bigDecimal);
|
|
|
|
|
//
|
|
|
|
|
// BigDecimal bigDecimal2 = BigDecimal.valueOf(multipleSize - multipleCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// multipleScore.setAccuracy(String.valueOf(multipleSize - multipleCount));
|
|
|
|
|
// multipleScore.setScore(bigDecimal2);
|
|
|
|
|
//
|
|
|
|
|
// BigDecimal bigDecimal3 = BigDecimal.valueOf(judgeSize - judgeCount)
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize), RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// judgeScore.setAccuracy(String.valueOf(judgeSize - judgeCount));
|
|
|
|
|
// judgeScore.setScore(bigDecimal3);
|
|
|
|
|
// BigDecimal tatol = bigDecimal.add(bigDecimal2.add(bigDecimal3))
|
|
|
|
|
// .divide(BigDecimal.valueOf(totalSize))
|
|
|
|
|
// .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
// .setScale(0, RoundingMode.HALF_UP); //保留整数 四舍五入
|
|
|
|
|
// dto.setTotalScore(tatol);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// list.add(singleScore);
|
|
|
|
|
// list.add(multipleScore);
|
|
|
|
|
// list.add(judgeScore);
|
|
|
|
|
// dto.setCalcAuthScoreList(list);
|
|
|
|
|
// dto.setName(name);
|
|
|
|
|
// return new ResultEntity<StuAuthTestDto>(dto);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<StuTheoryExam> getTheoryTestList(String userId, Integer index, Integer size) {
|
|
|
|
|
public PageInfo<StuTheoryExamWithBLOBs> getTheoryTestList(String userId, Integer index, Integer size) {
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo("理论考试");
|
|
|
|
|
example.setOrderByClause("exam_time desc");
|
|
|
|
|
List<StuTheoryExam> stuTheoryExams = theoryExamMapper.selectByExample(example);
|
|
|
|
|
PageInfo<StuTheoryExam> pageInfo = new PageInfo<>(stuTheoryExams);
|
|
|
|
|
List<StuTheoryExamWithBLOBs> stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
PageInfo<StuTheoryExamWithBLOBs> pageInfo = new PageInfo<>(stuTheoryExams);
|
|
|
|
|
return pageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -191,46 +424,53 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
// 之前没有进行考试 从客观题库表中查询 35道单选,每题2分,5道多选每题4分,10道判断每题1分 并将id保存至理论考试表中
|
|
|
|
|
// 注意 开始考试后 要生成理论记录表基础数据
|
|
|
|
|
@Override
|
|
|
|
|
public List<ObjectiveQuestionWithBLOBs> startTheoryTest(String userId, String schoolId) throws IOException {
|
|
|
|
|
public List<ObjectiveQuestionWithBLOBs> startTheoryTest(String userId, String schoolId, String source) throws IOException {
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo(source);
|
|
|
|
|
example.setOrderByClause("exam_time DESC");
|
|
|
|
|
List<StuTheoryExamWithBLOBs> stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
if (stuTheoryExams.isEmpty()) { //之前没有进行考试
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId);
|
|
|
|
|
GenerateTheoryRecordFirst(userId);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId, source);
|
|
|
|
|
//理论考试需要额外增加一张记录表
|
|
|
|
|
if (source.equals("理论考试")) {
|
|
|
|
|
GenerateTheoryRecordFirst(userId);
|
|
|
|
|
}
|
|
|
|
|
return objectiveQuestionList;
|
|
|
|
|
} else { //根据考试时间排序 查询最近的一条
|
|
|
|
|
StuTheoryExamWithBLOBs stuTheoryExam = stuTheoryExams.get(0);
|
|
|
|
|
Date currentTime = new Date();
|
|
|
|
|
Date twoHoursAgo = new Date(currentTime.getTime() - (2 * 60 * 60 * 1000)); // 当前时间减去两个小时
|
|
|
|
|
if (stuTheoryExam.getAnswered()) {
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId, source);
|
|
|
|
|
return objectiveQuestionList;
|
|
|
|
|
}
|
|
|
|
|
if (stuTheoryExam.getExamTime().before(twoHoursAgo)) { //已超出两个小时 从新生成新试卷
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = GenerateTest(userId, schoolId, source);
|
|
|
|
|
return objectiveQuestionList;
|
|
|
|
|
} else { //在两个小时内 返回最近的一条试卷
|
|
|
|
|
String singleIds = stuTheoryExam.getSingleIds();
|
|
|
|
|
String multipleIds = stuTheoryExam.getMultipleIds();
|
|
|
|
|
String multipleIds = stuTheoryExam.getMultipleIds(); //todo 测试考试中心只有单选题的考试 是否会报错
|
|
|
|
|
String judgeIds = stuTheoryExam.getJudgeIds();
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> singleQuestionList = selectBatchByIdList(singleIdList);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> mulQuestionList = selectBatchByIdList(multipleIdList);
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> judgeQuestionList = selectBatchByIdList(judgeIdList);
|
|
|
|
|
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> returnQuestionList = new ArrayList<>();
|
|
|
|
|
if (StringUtils.isNotBlank(multipleIds)) {
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> mulQuestionList = selectBatchByIdList(multipleIdList);
|
|
|
|
|
returnQuestionList.addAll(mulQuestionList);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(judgeIds)) {
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> judgeQuestionList = selectBatchByIdList(judgeIdList);
|
|
|
|
|
returnQuestionList.addAll(judgeQuestionList);
|
|
|
|
|
}
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> singleQuestionList = selectBatchByIdList(singleIdList);
|
|
|
|
|
returnQuestionList.addAll(singleQuestionList);
|
|
|
|
|
returnQuestionList.addAll(mulQuestionList);
|
|
|
|
|
returnQuestionList.addAll(judgeQuestionList);
|
|
|
|
|
return returnQuestionList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException {
|
|
|
|
|
StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId);
|
|
|
|
@ -348,10 +588,27 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//随机生成100分题目
|
|
|
|
|
public List<ObjectiveQuestionWithBLOBs> GenerateTest(String userId, String schoolId) throws IOException {
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList1 = objectiveQuestionMapper.getObjectiveByRandom(0, 35, schoolId); //单选
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList2 = objectiveQuestionMapper.getObjectiveByRandom(1, 5, schoolId); //多选
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList3 = objectiveQuestionMapper.getObjectiveByRandom(2, 10, schoolId); //判断
|
|
|
|
|
public List<ObjectiveQuestionWithBLOBs> GenerateTest(String userId, String schoolId, String source) throws IOException {
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList1 = new ArrayList<>();
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList2 = new ArrayList<>();
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList3 = new ArrayList<>();
|
|
|
|
|
if (source.equals("理论考试")) {
|
|
|
|
|
objectiveQuestionList1 = objectiveQuestionMapper.getObjectiveByRandom(0, 35, "普通题库", null, schoolId); //单选
|
|
|
|
|
objectiveQuestionList2 = objectiveQuestionMapper.getObjectiveByRandom(1, 5, "普通题库", null, schoolId); //多选
|
|
|
|
|
objectiveQuestionList3 = objectiveQuestionMapper.getObjectiveByRandom(2, 10, "普通题库", null, schoolId); //判断
|
|
|
|
|
}
|
|
|
|
|
if (source.equals("理论知识")) {
|
|
|
|
|
objectiveQuestionList1 = objectiveQuestionMapper.getObjectiveByRandom(0, 60, "金融智能", source, schoolId); //单选
|
|
|
|
|
objectiveQuestionList2 = objectiveQuestionMapper.getObjectiveByRandom(1, 30, "金融智能", source, schoolId); //多选
|
|
|
|
|
objectiveQuestionList3 = objectiveQuestionMapper.getObjectiveByRandom(2, 10, "金融智能", source, schoolId); //判断
|
|
|
|
|
}
|
|
|
|
|
if (source.equals("专业能力")) {
|
|
|
|
|
objectiveQuestionList1 = objectiveQuestionMapper.getObjectiveByRandom(0, 100, "金融智能", source, schoolId); //单选
|
|
|
|
|
} else {
|
|
|
|
|
objectiveQuestionList1 = objectiveQuestionMapper.getObjectiveByRandom(0, 90, "银行从业", source, schoolId); //单选
|
|
|
|
|
objectiveQuestionList2 = objectiveQuestionMapper.getObjectiveByRandom(1, 40, "银行从业", source, schoolId); //多选
|
|
|
|
|
objectiveQuestionList3 = objectiveQuestionMapper.getObjectiveByRandom(2, 15, "银行从业", source, schoolId); //判断
|
|
|
|
|
}
|
|
|
|
|
List<ObjectiveQuestionWithBLOBs> objectiveQuestionList = new ArrayList<>();
|
|
|
|
|
objectiveQuestionList.addAll(objectiveQuestionList1);
|
|
|
|
|
objectiveQuestionList.addAll(objectiveQuestionList2);
|
|
|
|
@ -377,8 +634,13 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
stuTheoryExam.setExamDuration(120);
|
|
|
|
|
stuTheoryExam.setAnswered(false);
|
|
|
|
|
stuTheoryExam.setSingleIds(String.valueOf(singleIdList));
|
|
|
|
|
stuTheoryExam.setMultipleIds(String.valueOf(manyIdList));
|
|
|
|
|
stuTheoryExam.setJudgeIds(String.valueOf(judgeIdList));
|
|
|
|
|
if (!manyIdList.isEmpty()) {
|
|
|
|
|
stuTheoryExam.setMultipleIds(String.valueOf(manyIdList));
|
|
|
|
|
}
|
|
|
|
|
if (!judgeIdList.isEmpty()) {
|
|
|
|
|
stuTheoryExam.setMultipleIds(String.valueOf(judgeIdList));
|
|
|
|
|
}
|
|
|
|
|
stuTheoryExam.setSource(source);
|
|
|
|
|
theoryExamMapper.insert(stuTheoryExam);
|
|
|
|
|
return objectiveQuestionList;
|
|
|
|
|
}
|
|
|
|
@ -401,7 +663,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
allIds.addAll(extractIds(stuError.getMultipleIds()));
|
|
|
|
|
allIds.addAll(extractIds(stuError.getJudgeIds()));
|
|
|
|
|
|
|
|
|
|
ObjectiveQuestionExample example1 =new ObjectiveQuestionExample();
|
|
|
|
|
ObjectiveQuestionExample example1 = new ObjectiveQuestionExample();
|
|
|
|
|
example1.createCriteria().andObjectiveIdIn(allIds);
|
|
|
|
|
return objectiveQuestionMapper.selectByExampleWithBLOBs(example1);
|
|
|
|
|
}
|
|
|
|
|