diff --git a/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java b/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java index bfff433..c0aa7c8 100644 --- a/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java +++ b/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java @@ -49,7 +49,7 @@ public class TheoryTestController { @AnonymousAccess public ResultEntity> startTheoryTest(@RequestParam String userId, @RequestParam String schoolId, - @RequestParam("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") String source) { + @ApiParam("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") @RequestParam String source) { List list = null; try { list = theoryTestService.startTheoryTest(userId, schoolId, source); @@ -113,8 +113,11 @@ public class TheoryTestController { @PostMapping("getAuthTestRecord") @ApiOperation("认证考试/获取考试记录") @AnonymousAccess - public ResultEntity getAuthTestRecord(@RequestParam String theoryExamId) { - return theoryTestService.getAuthTestRecord(theoryExamId); + public ResultEntity> getAuthTestRecord(@RequestParam Integer index, + @RequestParam Integer size, + @RequestParam String userId, + @RequestParam String source) { + return theoryTestService.getAuthTestRecord(index, size, userId, source); } diff --git a/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java b/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java index a3f2835..f973feb 100644 --- a/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java +++ b/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java @@ -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 getAuthTestRecord(String theoryExamId); + ResultEntity> getAuthTestRecord(Integer index,Integer size,String userId,String source); } diff --git a/src/main/java/com/sztzjy/money_management/service/impl/TheoryTestServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/TheoryTestServiceImpl.java index 798b1d7..1885092 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/TheoryTestServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/TheoryTestServiceImpl.java @@ -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 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 stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", ")); List 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 stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", ")); List 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 stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", ")); List judgeErrorIds = theoryTestDto.getJudgeErrorIds(); List combinedList = new ArrayList<>(stringList); @@ -211,71 +212,91 @@ public class TheoryTestServiceImpl implements TheoryTestService { * @Date 2024/8/26 */ @Override - public ResultEntity 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 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 errorList = Arrays.asList(data.getErrorIds().split(", ")); - ObjectiveQuestionExample example = new ObjectiveQuestionExample(); - example.createCriteria().andObjectiveIdIn(errorList); - List 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> getAuthTestRecord(Integer index, Integer size, String userId, String source) { + StuTheoryExamExample stuTheoryExamExample = new StuTheoryExamExample(); + stuTheoryExamExample.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo(source); + List dataList = theoryExamMapper.selectByExampleWithBLOBs(stuTheoryExamExample); + + ArrayList 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 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 errorList = Arrays.asList(data.getErrorIds().split(", ")); + ObjectiveQuestionExample example = new ObjectiveQuestionExample(); + example.createCriteria().andObjectiveIdIn(errorList); + List 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(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 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 getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException { + ArrayList idsList = new ArrayList<>(); + StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId); + String singleIds = theoryExam.getSingleIds(); - ArrayList idsList = new ArrayList<>(); - List singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", ")); + if (StringUtils.isNotBlank(singleIds)) { +// List singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", ")); + List singleIdList = Arrays.asList(singleIds.split(", ")); + idsList.addAll(singleIdList); + } + String multipleIds = theoryExam.getMultipleIds(); - List multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", ")); + if (StringUtils.isNotBlank(multipleIds)) { +// List multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", ")); + List multipleIdList = Arrays.asList(multipleIds.split(", ")); + idsList.addAll(multipleIdList); + } + String judgeIds = theoryExam.getJudgeIds(); - List judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", ")); - idsList.addAll(singleIdList); - idsList.addAll(multipleIdList); - idsList.addAll(judgeIdList); + if (StringUtils.isNotBlank(judgeIds)) { +// List judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", ")); + List judgeIdList = Arrays.asList(judgeIds.split(", ")); + idsList.addAll(judgeIdList); + } + ArrayList 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); diff --git a/src/main/resources/mapper/SynthesisPlanClientMapper.xml b/src/main/resources/mapper/SynthesisPlanClientMapper.xml index 54dffb4..750d022 100644 --- a/src/main/resources/mapper/SynthesisPlanClientMapper.xml +++ b/src/main/resources/mapper/SynthesisPlanClientMapper.xml @@ -530,8 +530,8 @@ SELECT * FROM synthesis_plan_client WHERE get_status = 'true' - 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},'%')