修改部分接口

master
xiaoCJ 6 months ago
parent c0ca36ead9
commit 649b79b603

@ -49,7 +49,7 @@ public class TheoryTestController {
@AnonymousAccess
public ResultEntity<List<ObjectiveQuestionWithBLOBs>> startTheoryTest(@RequestParam String userId,
@RequestParam String schoolId,
@RequestParam("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") String source) {
@ApiParam("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") @RequestParam String source) {
List<ObjectiveQuestionWithBLOBs> list = null;
try {
list = theoryTestService.startTheoryTest(userId, schoolId, source);
@ -113,8 +113,11 @@ public class TheoryTestController {
@PostMapping("getAuthTestRecord")
@ApiOperation("认证考试/获取考试记录")
@AnonymousAccess
public ResultEntity<StuAuthTestDto> getAuthTestRecord(@RequestParam String theoryExamId) {
return theoryTestService.getAuthTestRecord(theoryExamId);
public ResultEntity<PageInfo<StuAuthTestDto>> getAuthTestRecord(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String userId,
@RequestParam String source) {
return theoryTestService.getAuthTestRecord(index, size, userId, source);
}

@ -23,5 +23,5 @@ public interface TheoryTestService {
Boolean removeError(String userId, String objectiveQuestionId, Integer type);
int endTheoryTest(StuTheoryTestDto theoryTestDto);
Date getStartTime(String userId,String source);
ResultEntity<StuAuthTestDto> getAuthTestRecord(String theoryExamId);
ResultEntity<PageInfo<StuAuthTestDto>> getAuthTestRecord(Integer index,Integer size,String userId,String source);
}

@ -10,6 +10,7 @@ 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.PageUtil;
import com.sztzjy.money_management.util.ResultEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -78,7 +79,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
StuErrorExample errorExample = new StuErrorExample();
errorExample.createCriteria().andUserIdEqualTo(theoryTestDto.getUserId());
List<StuErrorWithBLOBs> stuErrors = errorMapper.selectByExampleWithBLOBs(errorExample);
if (stuErrors.isEmpty()) {
if (stuErrors == null || stuErrors.isEmpty()) {
StuErrorWithBLOBs stuError = new StuErrorWithBLOBs();
stuError.setErrorId(IdUtil.randomUUID());
stuError.setUserId(theoryTestDto.getUserId());
@ -94,7 +95,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
errorMapper.insert(stuError);
} else {
StuErrorWithBLOBs stuError = stuErrors.get(0);
if (stuError.getSingleIds() != null) {
if (StringUtils.isNotBlank(stuError.getSingleIds())) {
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", "));
List<String> singleErrorIds = theoryTestDto.getSingleErrorIds();
@ -108,7 +109,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
String stringError = String.valueOf(theoryTestDto.getSingleErrorIds()).replace("[", "").replace("]", "");
stuError.setSingleIds(stringError);
}
if (stuError.getMultipleIds() != null) {
if (StringUtils.isNotBlank(stuError.getMultipleIds())) {
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", "));
List<String> multipleErrorIds = theoryTestDto.getMultipleErrorIds();
@ -122,7 +123,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
String stringMultipleError = String.valueOf(theoryTestDto.getMultipleErrorIds()).replace("[", "").replace("]", "");
stuError.setMultipleIds(stringMultipleError);
}
if (stuError.getJudgeIds() != null) {
if (StringUtils.isNotBlank(stuError.getJudgeIds())) {
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);
@ -211,71 +212,91 @@ public class TheoryTestServiceImpl implements TheoryTestService {
* @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++;
public ResultEntity<PageInfo<StuAuthTestDto>> getAuthTestRecord(Integer index, Integer size, String userId, String source) {
StuTheoryExamExample stuTheoryExamExample = new StuTheoryExamExample();
stuTheoryExamExample.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo(source);
List<StuTheoryExamWithBLOBs> dataList = theoryExamMapper.selectByExampleWithBLOBs(stuTheoryExamExample);
ArrayList<StuAuthTestDto> stuAuthTestDtoList = new ArrayList<>();
if (dataList != null && !dataList.isEmpty()) {
for (StuTheoryExamWithBLOBs data : dataList) {
StuAuthTestDto dto = new StuAuthTestDto();
BeanUtils.copyProperties(data, dto);
int singleSize = 0;
int multipleSize = 0;
int judgeSize = 0;
if (StringUtils.isNotBlank(data.getSingleIds())) {
singleSize = data.getSingleIds().split(", ").length;
}
if (StringUtils.isNotBlank(data.getMultipleIds())) {
multipleSize = data.getMultipleIds().split(", ").length;
}
if (StringUtils.isNotBlank(data.getJudgeIds())) {
judgeSize = data.getJudgeIds().split(", ").length;
}
int totalSize = singleSize + multipleSize + judgeSize;
String name = userMapper.selectByPrimaryKey(data.getUserId()).getName();
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;
}
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);
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);
stuAuthTestDtoList.add(dto);
}
}
PageInfo pageInfo = PageUtil.pageHelper(stuAuthTestDtoList, index, size);
return new ResultEntity<>(pageInfo);
}
private CalcAuthScore calculateScore(int questionSize, int errorCount, BigDecimal weight, int totalSize) {
@ -487,6 +508,15 @@ public class TheoryTestServiceImpl implements TheoryTestService {
}
List<ObjectiveQuestionWithBLOBs> singleQuestionList = selectBatchByIdList(singleIdList);
returnQuestionList.addAll(singleQuestionList);
// 按照题型排序0:单选1:多选2:判断
returnQuestionList.sort(Comparator.comparingInt(ObjectiveQuestion::getType));
// 设置source字段从1开始
for (int i = 0; i < returnQuestionList.size(); i++) {
int i1 = i + 1;
returnQuestionList.get(i).setSource(String.valueOf(i1)); // source从1开始
}
return returnQuestionList;
}
}
@ -494,20 +524,35 @@ public class TheoryTestServiceImpl implements TheoryTestService {
@Override
public List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException {
ArrayList<String> idsList = new ArrayList<>();
StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId);
String singleIds = theoryExam.getSingleIds();
ArrayList<String> idsList = new ArrayList<>();
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
if (StringUtils.isNotBlank(singleIds)) {
// List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
List<String> singleIdList = Arrays.asList(singleIds.split(", "));
idsList.addAll(singleIdList);
}
String multipleIds = theoryExam.getMultipleIds();
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
if (StringUtils.isNotBlank(multipleIds)) {
// List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
List<String> multipleIdList = Arrays.asList(multipleIds.split(", "));
idsList.addAll(multipleIdList);
}
String judgeIds = theoryExam.getJudgeIds();
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
idsList.addAll(singleIdList);
idsList.addAll(multipleIdList);
idsList.addAll(judgeIdList);
if (StringUtils.isNotBlank(judgeIds)) {
// List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
List<String> judgeIdList = Arrays.asList(judgeIds.split(", "));
idsList.addAll(judgeIdList);
}
ArrayList<String> answerList = new ArrayList<>();
if (theoryExam.getSingleStuAnswer() != null) {
String[] singleSplit = theoryExam.getSingleStuAnswer().substring(1, theoryExam.getSingleStuAnswer().length() - 1).split(",");
if (StringUtils.isNotBlank(theoryExam.getSingleStuAnswer())) {
// String[] singleSplit = theoryExam.getSingleStuAnswer().substring(1, theoryExam.getSingleStuAnswer().length() - 1).split(",");
String[] singleSplit = theoryExam.getSingleStuAnswer().split(",");
for (String str : singleSplit) {
if (str.equals("") || str.equals(" ")) {
answerList.add(null);
@ -516,8 +561,9 @@ public class TheoryTestServiceImpl implements TheoryTestService {
}
}
}
if (theoryExam.getMultipleStuAnswer() != null) {
String[] multipleSplit = theoryExam.getMultipleStuAnswer().substring(1, theoryExam.getMultipleStuAnswer().length() - 1).split(",");
if (StringUtils.isNotBlank(theoryExam.getMultipleStuAnswer())) {
// String[] multipleSplit = theoryExam.getMultipleStuAnswer().substring(1, theoryExam.getMultipleStuAnswer().length() - 1).split(",");
String[] multipleSplit = theoryExam.getMultipleStuAnswer().split(",");
for (String str : multipleSplit) {
if (str.equals("") || str.equals(" ")) {
answerList.add(null);
@ -527,8 +573,9 @@ public class TheoryTestServiceImpl implements TheoryTestService {
}
}
}
if (theoryExam.getJudgeStuAnswer() != null) {
String[] judgeSplit = theoryExam.getJudgeStuAnswer().substring(1, theoryExam.getJudgeStuAnswer().length() - 1).split(",");
if (StringUtils.isNotBlank(theoryExam.getJudgeStuAnswer())) {
// String[] judgeSplit = theoryExam.getJudgeStuAnswer().substring(1, theoryExam.getJudgeStuAnswer().length() - 1).split(",");
String[] judgeSplit = theoryExam.getJudgeStuAnswer().split(",");
for (String str : judgeSplit) {
if (str.equals("") || str.equals(" ")) {
answerList.add(null);

@ -530,8 +530,8 @@
SELECT * FROM synthesis_plan_client
WHERE get_status = 'true'
<if test="keyWord !=null and keyWord !=''">
AND
name LIKE CONCAT ('%',#{keyWord},'%')
AND submit_status is not '已审核'
AND name LIKE CONCAT ('%',#{keyWord},'%')
OR idcard LIKE CONCAT ('%',#{keyWord},'%')
OR client_number LIKE CONCAT ('%',#{keyWord},'%')
</if>

Loading…
Cancel
Save