Administrator
2021-08-18 4f5952c0082ef451dbf2c7ac4c2fb6055cb02f38
开始考试接口调用修改
9 files modified
166 ■■■■ changed files
src/main/java/org/springblade/modules/apply/controller/ApplyController.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/ApplyService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamSubjectChoicesService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java 52 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamSubjectChoicesVO.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml 40 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -24,7 +24,9 @@
import org.springblade.modules.apply.vo.ApplyPaPerVO;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;
@@ -50,6 +52,8 @@
    private final ExamPaperService examPaperService;
    private final IUserService userService;
    private final ExamScoreService examScoreService;
    /**
     * 自定义分页
@@ -618,8 +622,16 @@
     * @return
     */
    @PostMapping("/updateApplyStatus")
    public void updateApplyStatus(@RequestBody ApplyVO apply){
    public ExamScore updateApplyStatus(@RequestBody ApplyVO apply){
        applyService.updateApplyStatus(apply);
        //新增考试成绩,没有成绩数据,待提交答题后更新数据
        ExamScore examScore = new ExamScore();
        examScore.setExamId(apply.getExamId().toString());
        examScore.setUserId(apply.getUserId().toString());
        examScore.setExamTime(new Date());
        //新增
        examScoreService.save(examScore);
        return examScore;
    }
src/main/java/org/springblade/modules/apply/service/ApplyService.java
@@ -8,6 +8,7 @@
import org.springblade.modules.apply.excel.ApplyInfoExcel;
import org.springblade.modules.apply.vo.ApplyPaPerVO;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springblade.modules.exam.entity.ExamScore;
import java.util.List;
import java.util.Map;
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
@@ -20,7 +20,9 @@
import org.springblade.modules.apply.vo.ApplyPaPerVO;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.training.entity.TrainingRegistration;
@@ -407,9 +409,11 @@
    public void updateApplyStatus(ApplyVO apply) {
        //正式考
        if (apply.getExamType()==1){
            Apply apply1 = new Apply();
            apply1.setId(apply.getId());
            //考试中
            apply.setIsExam(3);
            baseMapper.updateById(apply);
            apply1.setIsExam(3);
            baseMapper.updateById(apply1);
        }
        //模拟考
        if (apply.getExamType()==2){
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java
@@ -146,6 +146,29 @@
    }
    /**
     * 获取下一题的题目,并判断上一题的答案,且返回上一题答题结果
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/getSubjectResultInfo")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoicesVO> getSubjectResultInfo(ExamSubjectChoicesVO examSubjectChoices) {
        //查询下一题题目详情
        ExamSubjectChoicesVO detail = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices);
        //判断当前题目的答题结果
        if (examSubjectChoices.getPreSubJectId()!=null) {
            if (null!=examSubjectChoices.getPreResult() && examSubjectChoices.getPreResult()!="" && !examSubjectChoices.getPreResult().equals("")) {
                detail.setResult(examSubjectChoicesService.getAnswerResult(examSubjectChoices.getPreSubJectId(), examSubjectChoices.getPreResult()));
            }else {
                //无
                detail.setResult(3);
            }
        }
        //返回
        return R.data(detail);
    }
    /**
     * 查询试卷包含的题目
     */
    @GetMapping("/getEexPaperChoices")
src/main/java/org/springblade/modules/exam/service/ExamSubjectChoicesService.java
@@ -54,4 +54,12 @@
     * @param isCovered
     */
    void importSubject(List<ExamSubjectExcel> data, Boolean isCovered);
    /**
     * 判断当前题目的答题结果
     * @param preSubJectId 题目Id
     * @param preResult 提交的结果
     * @return
     */
    Integer getAnswerResult(Long preSubJectId, String preResult);
}
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -185,8 +185,8 @@
            }else {
                examScore.setQualified(1);
            }
            //保存成绩数据
            int i = baseMapper.insert(examScore);
            //修改成绩数据
            int i = baseMapper.updateById(examScore);
            //修改考试状态
            if (i>0){
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
@@ -91,12 +91,6 @@
                });
                return true;
            }
            //内网数据同步
            try {
//                arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else {
            //修改
            ExamSubjectChoices subjectChoices = new ExamSubjectChoices();
@@ -140,12 +134,6 @@
                    examSubjectOptionService.save(examSubjectOption);
                });
                return true;
            }
            //内网数据同步
            try {
//                arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return status;
@@ -302,4 +290,44 @@
        });
    }
    /**
     * 判断当前题目的答题结果
     * @param preSubJectId 题目Id
     * @param preResult 提交的结果
     * @return
     */
    @Override
    public Integer getAnswerResult(Long preSubJectId, String preResult) {
        //查询题目信息
        ExamSubjectChoices choices = this.getById(preSubJectId);
        //对比答案
        if (choices.getChoicesType() == 2 || choices.getChoicesType() == 3){
            //判断题逻辑
            if (preResult.equals(choices.getAnswer())) {
                return 1;
            }else {
                return 2;
            }
        }else if(choices.getChoicesType() == 0 || choices.getChoicesType() == 1){
            //处理多选题的答案排序
            String[] split = preResult.split(",");
            StringBuilder builder = new StringBuilder();
            for (String s : split) {
                builder.append(s);
            }
            char[] arrayCh = builder.toString().toCharArray();
            //利用数组帮助类自动排序
            Arrays.sort(arrayCh);
            String sub0 = Arrays.toString(arrayCh);
            String sub = sub0.substring(1,sub0.length()-1).replaceAll(" ","");
            if (sub.equals(choices.getAnswer())) {
                return 1;
            }else {
                return 2;
            }
        }
        return 2;
    }
}
src/main/java/org/springblade/modules/exam/vo/ExamSubjectChoicesVO.java
@@ -19,4 +19,20 @@
    private List<ExamSubjectOption> examSubjectOptions;
    private String tmid;
    /**
     * 上一题的题目id
     */
    private Long preSubJectId;
    /**
     * 上一题答题提交的结果
     */
    private String preResult;
    /**
     * 上一题的答题结果,对,错  1:对  2:错
     */
    private Integer result;
}
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -159,7 +159,22 @@
    <!--懒加载获取部门树形结构(包含用户数据)app-->
    <select id="lazyTreeUserApp" resultType="org.springblade.modules.system.vo.DeptAndUserVO" >
        select DISTINCT  * from (
        select DISTINCT
            c.id,
            c.parent_id,
            c.title,
            c.value,
            c.key,
            (
            SELECT
            CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
            FROM
            blade_dept
            where
            id = c.parent_id
            and dept_category=1
            ) AS "has_children"
        from (
        (SELECT
        dept.id,
        dept.parent_id,
@@ -201,7 +216,8 @@
        union all
        (select
            (
                select
        bu.id,
        bu.dept_id  parent_id,
        bu.real_name AS label,
@@ -232,7 +248,25 @@
    <!--懒加载获取部门树形结构(包含用户数据)-->
    <select id="lazyTreeUser" resultMap="treeNodeResultMap" >
        select DISTINCT  * from (
        select DISTINCT
            c.id,
            c.parent_id,
            c.title,
            c.value,
            c.key,
            (
            SELECT
            CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
            FROM
            blade_dept
            where
            id = c.parent_id
            <if test="parentId!=null and parentId!=''">
                and dept_category=1
                AND id = #{parentId}
            </if>
            ) AS "has_children"
        from (
            (SELECT
              dept.id,
              dept.parent_id,