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 4f7b086..bfff433 100644 --- a/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java +++ b/src/main/java/com/sztzjy/money_management/controller/TheoryTestController.java @@ -3,13 +3,11 @@ package com.sztzjy.money_management.controller; import com.github.pagehelper.PageInfo; import com.sztzjy.money_management.annotation.AnonymousAccess; import com.sztzjy.money_management.entity.*; +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.entity.dto.StuTheoryTestRecordDto; -import com.sztzjy.money_management.mapper.CaseRiskIndexMapper; -import com.sztzjy.money_management.mapper.ObjectiveQuestionMapper; -import com.sztzjy.money_management.mapper.StuTheoryRecordMapper; -import com.sztzjy.money_management.mapper.UserInfoMapper; +import com.sztzjy.money_management.mapper.*; import com.sztzjy.money_management.service.TheoryTestService; import com.sztzjy.money_management.util.ResultEntity; import io.swagger.annotations.Api; @@ -21,12 +19,7 @@ import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.util.*; /** * @Author xcj @@ -46,15 +39,20 @@ public class TheoryTestController { private UserInfoMapper userMapper; @Autowired private CaseRiskIndexMapper caseRiskIndexMapper; + @Autowired + private StuTheoryExamMapper stuTheoryExamMapper; + //开始考试 选择 35道单选,每题2分,5道多选每题4分,10道判断每题1分 @PostMapping("startTheoryTest") - @ApiOperation("开始考试") + @ApiOperation("理论考试/认证考试 开始考试") @AnonymousAccess - public ResultEntity<List<ObjectiveQuestionWithBLOBs>> startTheoryTest(@RequestParam String userId, @RequestParam String schoolId) { + public ResultEntity<List<ObjectiveQuestionWithBLOBs>> startTheoryTest(@RequestParam String userId, + @RequestParam String schoolId, + @RequestParam("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") String source) { List<ObjectiveQuestionWithBLOBs> list = null; try { - list = theoryTestService.startTheoryTest(userId, schoolId); + list = theoryTestService.startTheoryTest(userId, schoolId, source); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "服务器异常,请联系管理员"); } @@ -66,17 +64,18 @@ public class TheoryTestController { //获取理论考试开始时间 @GetMapping("getStartTime") - @ApiOperation("获取理论考试开始时间") + @ApiOperation("理论考试/认证考试 获取考试开始时间") @AnonymousAccess - public ResultEntity<Date> getStartTime(@RequestParam String userId) { - Date date = theoryTestService.getStartTime(userId); + public ResultEntity<Date> getStartTime(@RequestParam String userId, + @RequestParam String source) { + Date date = theoryTestService.getStartTime(userId, source); return new ResultEntity<>(HttpStatus.OK, "获取理论考试开始时间成功", date); } //结束考试 @PostMapping("endTheoryTest") - @ApiOperation("结束考试 学生自动点击交卷、前端检查时间到了也发送请求") + @ApiOperation("理论考试/认证考试 结束考试 学生自动点击交卷,前端检查时间到了也发送请求") @AnonymousAccess public ResultEntity<HttpStatus> endTheoryTest(@RequestBody StuTheoryTestDto theoryTestDto) { int flag = theoryTestService.endTheoryTest(theoryTestDto); @@ -88,11 +87,43 @@ public class TheoryTestController { } + //获取理论考试开始时间 + @PostMapping("getAuthTestDropDown") + @ApiOperation("认证考试/考试记录下拉框") + @AnonymousAccess + public ResultEntity<Map<Date, String>> getAuthTestDropDown(@RequestParam String userId, + @RequestParam String source) { + StuTheoryExamExample example = new StuTheoryExamExample(); + example.createCriteria().andUserIdEqualTo(userId).andSourceEqualTo(source); + example.setOrderByClause("exam_time desc"); + List<StuTheoryExamWithBLOBs> stuTheoryExamWithBLOBs = stuTheoryExamMapper.selectByExampleWithBLOBs(example); + if (stuTheoryExamWithBLOBs == null || stuTheoryExamWithBLOBs.isEmpty()) { + return null; + } + Map<Date, String> map = new HashMap(); + for (int i = 0; i < stuTheoryExamWithBLOBs.size(); i++) { + StuTheoryExamWithBLOBs data = stuTheoryExamWithBLOBs.get(i); + map.put(data.getExamTime(), data.getTheoryExamId()); + } + return new ResultEntity<>(map); + } + + + //获取理论考试开始时间 + @PostMapping("getAuthTestRecord") + @ApiOperation("认证考试/获取考试记录") + @AnonymousAccess + public ResultEntity<StuAuthTestDto> getAuthTestRecord(@RequestParam String theoryExamId) { + return theoryTestService.getAuthTestRecord(theoryExamId); + } + + //错题集展示 @GetMapping("selectErrors") - @ApiOperation("错题集展示") + @ApiOperation("理论考试/错题集展示") @AnonymousAccess - public ResultEntity<List<ObjectiveQuestionWithBLOBs>> selectErrors(@RequestParam String userId, @RequestParam String schoolId) { + public ResultEntity<List<ObjectiveQuestionWithBLOBs>> selectErrors(@RequestParam String userId, + @RequestParam String schoolId) { List<ObjectiveQuestionWithBLOBs> list = null; list = theoryTestService.selectErrors(userId, schoolId); if (list == null) { @@ -107,7 +138,7 @@ public class TheoryTestController { //移除错题集 @GetMapping("removeError") - @ApiOperation("移除错题集") + @ApiOperation("理论考试/移除错题集") @AnonymousAccess public ResultEntity<HttpStatus> removeError(@RequestParam String userId, @ApiParam("客观题id") @RequestParam String objectiveQuestionId, @@ -123,23 +154,24 @@ public class TheoryTestController { //考试记录查询 @PostMapping("getTheoryTestList") - @ApiOperation("获取理论考试数据集") + @ApiOperation("理论考试/获取理论考试数据集") @AnonymousAccess - public ResultEntity<PageInfo<StuTheoryExam>> getTheoryTestList(@RequestParam String userId, - @RequestParam Integer index, - @RequestParam Integer size) { - PageInfo<StuTheoryExam> pageInfo = theoryTestService.getTheoryTestList(userId, index, size); + public ResultEntity<PageInfo<StuTheoryExamWithBLOBs>> getTheoryTestList(@RequestParam String userId, + @RequestParam Integer index, + @RequestParam Integer size) { + PageInfo<StuTheoryExamWithBLOBs> pageInfo = theoryTestService.getTheoryTestList(userId, index, size); return new ResultEntity<>(HttpStatus.OK, "获取理论考试数据集成功", pageInfo); } //考试记录详情查询 @GetMapping("getTheoryTestDetail") - @ApiOperation("获取理论考试数据详情") + @ApiOperation("理论考试/获取考试数据详情") @AnonymousAccess public ResultEntity<List<StuTheoryExamDetailDto>> getTheoryTestDetail(@ApiParam("理论考试id") @RequestParam String theoryExamId, @RequestParam Integer index, - @RequestParam Integer size, @RequestParam String schoolId) { + @RequestParam Integer size, + @RequestParam String schoolId) { List<StuTheoryExamDetailDto> detailDtoList = null; try { detailDtoList = theoryTestService.getTheoryTestDetail(theoryExamId, index, size); @@ -152,7 +184,7 @@ public class TheoryTestController { //答题次数、平均正确率、排名(理论考试记录) ************ @GetMapping("getTheoryRecord") - @ApiOperation("获取理论考试记录数据") + @ApiOperation("理论考试/获取考试记录") @AnonymousAccess public ResultEntity<StuTheoryTestRecordDto> getTheoryRecord(String userId) { //先根据userid查询是否有记录 没有记录返回null @@ -197,7 +229,7 @@ public class TheoryTestController { //获取题库全部数据 @PostMapping("getObjQuestionCount") - @ApiOperation("获取客观题库数量") + @ApiOperation("理论考试/获取客观题库数量") @AnonymousAccess public ResultEntity<HashMap<String, Long>> getObjQuestionCount(@RequestParam String schoolId) { HashMap<String, Long> hashMap = new HashMap<>(); diff --git a/src/main/java/com/sztzjy/money_management/entity/StuTheoryExam.java b/src/main/java/com/sztzjy/money_management/entity/StuTheoryExam.java index c7fb8b2..c5ec730 100644 --- a/src/main/java/com/sztzjy/money_management/entity/StuTheoryExam.java +++ b/src/main/java/com/sztzjy/money_management/entity/StuTheoryExam.java @@ -32,6 +32,9 @@ public class StuTheoryExam { @ApiModelProperty("正确率") private BigDecimal accuracy; + @ApiModelProperty("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") + private String source; + public String getTheoryExamId() { return theoryExamId; } @@ -87,4 +90,12 @@ public class StuTheoryExam { public void setAccuracy(BigDecimal accuracy) { this.accuracy = accuracy; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source == null ? null : source.trim(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/money_management/entity/StuTheoryExamExample.java b/src/main/java/com/sztzjy/money_management/entity/StuTheoryExamExample.java index 8136435..2643368 100644 --- a/src/main/java/com/sztzjy/money_management/entity/StuTheoryExamExample.java +++ b/src/main/java/com/sztzjy/money_management/entity/StuTheoryExamExample.java @@ -545,6 +545,76 @@ public class StuTheoryExamExample { addCriterion("accuracy not between", value1, value2, "accuracy"); return (Criteria) this; } + + public Criteria andSourceIsNull() { + addCriterion("source is null"); + return (Criteria) this; + } + + public Criteria andSourceIsNotNull() { + addCriterion("source is not null"); + return (Criteria) this; + } + + public Criteria andSourceEqualTo(String value) { + addCriterion("source =", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotEqualTo(String value) { + addCriterion("source <>", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThan(String value) { + addCriterion("source >", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThanOrEqualTo(String value) { + addCriterion("source >=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThan(String value) { + addCriterion("source <", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThanOrEqualTo(String value) { + addCriterion("source <=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLike(String value) { + addCriterion("source like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotLike(String value) { + addCriterion("source not like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceIn(List<String> values) { + addCriterion("source in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotIn(List<String> values) { + addCriterion("source not in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceBetween(String value1, String value2) { + addCriterion("source between", value1, value2, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotBetween(String value1, String value2) { + addCriterion("source not between", value1, value2, "source"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/money_management/entity/dto/CalcAuthScore.java b/src/main/java/com/sztzjy/money_management/entity/dto/CalcAuthScore.java new file mode 100644 index 0000000..b6d1f66 --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/entity/dto/CalcAuthScore.java @@ -0,0 +1,22 @@ +package com.sztzjy.money_management.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author xcj + * @Date 2024/8/26 + */ +@Data +public class CalcAuthScore { + @ApiModelProperty("题型") + private String type; + + @ApiModelProperty("正确率") + private String accuracy; + + @ApiModelProperty("得分") + private BigDecimal score; +} diff --git a/src/main/java/com/sztzjy/money_management/entity/dto/StuAuthTestDto.java b/src/main/java/com/sztzjy/money_management/entity/dto/StuAuthTestDto.java new file mode 100644 index 0000000..f0a914a --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/entity/dto/StuAuthTestDto.java @@ -0,0 +1,53 @@ +package com.sztzjy.money_management.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @Author xcj + * @Date 2024/8/26 + */ +@Data +public class StuAuthTestDto{ + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("考试时间") + private Date examTime; + + @ApiModelProperty("考试用时") + private Integer examDuration; + + @ApiModelProperty("单选题ID列表") + private String singleIds; + + @ApiModelProperty("多选题ID列表") + private String multipleIds; + + @ApiModelProperty("判断题ID列表") + private String judgeIds; + + @ApiModelProperty("单选题学生答案") + private String singleStuAnswer; + + @ApiModelProperty("多选题学生答案") + private String multipleStuAnswer; + + @ApiModelProperty("判断题学生答案") + private String judgeStuAnswer; + + @ApiModelProperty("错误题目ID列表") + private String errorIds; + + @ApiModelProperty("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") + private String source; + + private List<CalcAuthScore> calcAuthScoreList; + + @ApiModelProperty("总分") + private BigDecimal totalScore; +} diff --git a/src/main/java/com/sztzjy/money_management/entity/dto/StuTheoryTestDto.java b/src/main/java/com/sztzjy/money_management/entity/dto/StuTheoryTestDto.java index db107fa..ae9df00 100644 --- a/src/main/java/com/sztzjy/money_management/entity/dto/StuTheoryTestDto.java +++ b/src/main/java/com/sztzjy/money_management/entity/dto/StuTheoryTestDto.java @@ -22,7 +22,7 @@ public class StuTheoryTestDto { @ApiModelProperty("正确率") BigDecimal accuracy; - @ApiModelProperty("是否打完") + @ApiModelProperty("是否答完") Boolean answered; @ApiModelProperty("单选题学生答案集合") @@ -42,4 +42,7 @@ public class StuTheoryTestDto { @ApiModelProperty("判断错误题目id集合") List<String> judgeErrorIds; + + @ApiModelProperty("理论考试/理论知识/专业能力/公共基础/个人理财/风险管理/公司信贷/个人贷款") + private String source; } diff --git a/src/main/java/com/sztzjy/money_management/mapper/ObjectiveQuestionMapper.java b/src/main/java/com/sztzjy/money_management/mapper/ObjectiveQuestionMapper.java index 464509c..6fc18f6 100644 --- a/src/main/java/com/sztzjy/money_management/mapper/ObjectiveQuestionMapper.java +++ b/src/main/java/com/sztzjy/money_management/mapper/ObjectiveQuestionMapper.java @@ -43,7 +43,6 @@ public interface ObjectiveQuestionMapper { List<TopicDto> getObjectiveCountByChapterId(@Param("outLine") String outLine, @Param("chapterId") String chapterId); - List<ObjectiveQuestionWithBLOBs> getObjectiveByType(@Param("type") int type, @Param("outLine") String outLine, @Param("subClass") String subClass, @@ -57,5 +56,7 @@ public interface ObjectiveQuestionMapper { List<ObjectiveQuestionWithBLOBs> getObjectiveByRandom(@Param("type") int type, @Param("count") int count, + @Param("outLine") String outLine, + @Param("subClass") String subclass, @Param("schoolId") String schoolId); } \ No newline at end of file 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 a23ce26..a3f2835 100644 --- a/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java +++ b/src/main/java/com/sztzjy/money_management/service/TheoryTestService.java @@ -1,12 +1,11 @@ package com.sztzjy.money_management.service; import com.github.pagehelper.PageInfo; -import com.sztzjy.money_management.entity.ObjectiveQuestion; -import com.sztzjy.money_management.entity.ObjectiveQuestionWithBLOBs; -import com.sztzjy.money_management.entity.StuTheoryExam; -import com.sztzjy.money_management.entity.StuTheoryRecord; +import com.sztzjy.money_management.entity.*; +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.util.ResultEntity; import java.io.IOException; import java.util.Date; @@ -17,11 +16,12 @@ import java.util.List; * @Date 2024/8/22 */ public interface TheoryTestService { - PageInfo<StuTheoryExam> getTheoryTestList(String userId, Integer index, Integer size); - List<ObjectiveQuestionWithBLOBs> startTheoryTest(String userId, String schoolId)throws IOException; + PageInfo<StuTheoryExamWithBLOBs> getTheoryTestList(String userId, Integer index, Integer size); + List<ObjectiveQuestionWithBLOBs> startTheoryTest(String userId, String schoolId,String source)throws IOException; List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException; List<ObjectiveQuestionWithBLOBs> selectErrors(String userId,String schoolId); Boolean removeError(String userId, String objectiveQuestionId, Integer type); int endTheoryTest(StuTheoryTestDto theoryTestDto); - Date getStartTime(String userId); + Date getStartTime(String userId,String source); + ResultEntity<StuAuthTestDto> getAuthTestRecord(String theoryExamId); } diff --git a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java index e462d05..678bb6f 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java @@ -8,7 +8,6 @@ import com.sztzjy.money_management.entity.dto.CaseDistributionOfPropertyFamilyDt import com.sztzjy.money_management.mapper.*; import com.sztzjy.money_management.service.CaseService; import com.sztzjy.money_management.util.ResultEntity; -import jdk.nashorn.internal.runtime.options.LoggingOption; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -205,7 +204,6 @@ public class CaseServiceImpl implements CaseService { } } - if (type.equals("财务分析-资产负债表")) { CaseFinanceLiability caseFinanceLiability = gson.fromJson(json, CaseFinanceLiability.class); @@ -1681,7 +1679,6 @@ public class CaseServiceImpl implements CaseService { if (stuRiskIndex.getLossScore() == null || rightRiskIndex.getLossScore().compareTo(stuRiskIndex.getLossScore()) != 0) { wrongCount += 1; } - } return wrongCount; } 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 455516d..cc56edd 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 @@ -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); } diff --git a/src/main/resources/mapper/ObjectiveQuestionMapper.xml b/src/main/resources/mapper/ObjectiveQuestionMapper.xml index 81d0713..445018b 100644 --- a/src/main/resources/mapper/ObjectiveQuestionMapper.xml +++ b/src/main/resources/mapper/ObjectiveQuestionMapper.xml @@ -546,9 +546,14 @@ SELECT objective_id, chapter_id, chapter_name, source, type, score, question_a, question_b, question_c, question_d, question_e, outline, subclass,content FROM objective_question - WHERE type = #{type} - AND outline = '普通题库' - AND source IN ('999999999',#{schoolId}) + <where> + type = #{type} + AND outline = #{outLine} + <if test="subClass !=null"> + subClass = #{subClass} + </if> + AND source IN ('999999999',#{schoolId}) + </where> ORDER BY RAND() LIMIT #{count}; </select> diff --git a/src/main/resources/mapper/StuTheoryExamMapper.xml b/src/main/resources/mapper/StuTheoryExamMapper.xml index e5e73b0..2f53727 100644 --- a/src/main/resources/mapper/StuTheoryExamMapper.xml +++ b/src/main/resources/mapper/StuTheoryExamMapper.xml @@ -9,6 +9,7 @@ <result column="score" jdbcType="DECIMAL" property="score" /> <result column="answered" jdbcType="BIT" property="answered" /> <result column="accuracy" jdbcType="DECIMAL" property="accuracy" /> + <result column="source" jdbcType="VARCHAR" property="source" /> </resultMap> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.sztzjy.money_management.entity.StuTheoryExamWithBLOBs"> <result column="single_ids" jdbcType="LONGVARCHAR" property="singleIds" /> @@ -78,7 +79,7 @@ </where> </sql> <sql id="Base_Column_List"> - theory_exam_id, user_id, exam_time, exam_duration, score, answered, accuracy + theory_exam_id, user_id, exam_time, exam_duration, score, answered, accuracy, source </sql> <sql id="Blob_Column_List"> single_ids, multiple_ids, judge_ids, single_stu_answer, multiple_stu_answer, judge_stu_answer, @@ -135,14 +136,16 @@ <insert id="insert" parameterType="com.sztzjy.money_management.entity.StuTheoryExamWithBLOBs"> insert into stu_theory_exam (theory_exam_id, user_id, exam_time, exam_duration, score, answered, - accuracy, single_ids, multiple_ids, - judge_ids, single_stu_answer, multiple_stu_answer, - judge_stu_answer, error_ids) + accuracy, source, single_ids, + multiple_ids, judge_ids, single_stu_answer, + multiple_stu_answer, judge_stu_answer, + error_ids) values (#{theoryExamId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{examTime,jdbcType=TIMESTAMP}, #{examDuration,jdbcType=INTEGER}, #{score,jdbcType=DECIMAL}, #{answered,jdbcType=BIT}, - #{accuracy,jdbcType=DECIMAL}, #{singleIds,jdbcType=LONGVARCHAR}, #{multipleIds,jdbcType=LONGVARCHAR}, - #{judgeIds,jdbcType=LONGVARCHAR}, #{singleStuAnswer,jdbcType=LONGVARCHAR}, #{multipleStuAnswer,jdbcType=LONGVARCHAR}, - #{judgeStuAnswer,jdbcType=LONGVARCHAR}, #{errorIds,jdbcType=LONGVARCHAR}) + #{accuracy,jdbcType=DECIMAL}, #{source,jdbcType=VARCHAR}, #{singleIds,jdbcType=LONGVARCHAR}, + #{multipleIds,jdbcType=LONGVARCHAR}, #{judgeIds,jdbcType=LONGVARCHAR}, #{singleStuAnswer,jdbcType=LONGVARCHAR}, + #{multipleStuAnswer,jdbcType=LONGVARCHAR}, #{judgeStuAnswer,jdbcType=LONGVARCHAR}, + #{errorIds,jdbcType=LONGVARCHAR}) </insert> <insert id="insertSelective" parameterType="com.sztzjy.money_management.entity.StuTheoryExamWithBLOBs"> insert into stu_theory_exam @@ -168,6 +171,9 @@ <if test="accuracy != null"> accuracy, </if> + <if test="source != null"> + source, + </if> <if test="singleIds != null"> single_ids, </if> @@ -212,6 +218,9 @@ <if test="accuracy != null"> #{accuracy,jdbcType=DECIMAL}, </if> + <if test="source != null"> + #{source,jdbcType=VARCHAR}, + </if> <if test="singleIds != null"> #{singleIds,jdbcType=LONGVARCHAR}, </if> @@ -265,6 +274,9 @@ <if test="record.accuracy != null"> accuracy = #{record.accuracy,jdbcType=DECIMAL}, </if> + <if test="record.source != null"> + source = #{record.source,jdbcType=VARCHAR}, + </if> <if test="record.singleIds != null"> single_ids = #{record.singleIds,jdbcType=LONGVARCHAR}, </if> @@ -300,6 +312,7 @@ score = #{record.score,jdbcType=DECIMAL}, answered = #{record.answered,jdbcType=BIT}, accuracy = #{record.accuracy,jdbcType=DECIMAL}, + source = #{record.source,jdbcType=VARCHAR}, single_ids = #{record.singleIds,jdbcType=LONGVARCHAR}, multiple_ids = #{record.multipleIds,jdbcType=LONGVARCHAR}, judge_ids = #{record.judgeIds,jdbcType=LONGVARCHAR}, @@ -319,7 +332,8 @@ exam_duration = #{record.examDuration,jdbcType=INTEGER}, score = #{record.score,jdbcType=DECIMAL}, answered = #{record.answered,jdbcType=BIT}, - accuracy = #{record.accuracy,jdbcType=DECIMAL} + accuracy = #{record.accuracy,jdbcType=DECIMAL}, + source = #{record.source,jdbcType=VARCHAR} <if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" /> </if> @@ -345,6 +359,9 @@ <if test="accuracy != null"> accuracy = #{accuracy,jdbcType=DECIMAL}, </if> + <if test="source != null"> + source = #{source,jdbcType=VARCHAR}, + </if> <if test="singleIds != null"> single_ids = #{singleIds,jdbcType=LONGVARCHAR}, </if> @@ -377,6 +394,7 @@ score = #{score,jdbcType=DECIMAL}, answered = #{answered,jdbcType=BIT}, accuracy = #{accuracy,jdbcType=DECIMAL}, + source = #{source,jdbcType=VARCHAR}, single_ids = #{singleIds,jdbcType=LONGVARCHAR}, multiple_ids = #{multipleIds,jdbcType=LONGVARCHAR}, judge_ids = #{judgeIds,jdbcType=LONGVARCHAR}, @@ -393,7 +411,8 @@ exam_duration = #{examDuration,jdbcType=INTEGER}, score = #{score,jdbcType=DECIMAL}, answered = #{answered,jdbcType=BIT}, - accuracy = #{accuracy,jdbcType=DECIMAL} + accuracy = #{accuracy,jdbcType=DECIMAL}, + source = #{source,jdbcType=VARCHAR} where theory_exam_id = #{theoryExamId,jdbcType=VARCHAR} </update> </mapper> \ No newline at end of file