智慧保安后台管理-外网-验收版本
Administrator
2021-08-18 4f5952c0082ef451dbf2c7ac4c2fb6055cb02f38
开始考试接口调用修改
9 files modified
294 ■■■■ 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 3 ●●●● 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 166 ●●●●● 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;
@@ -108,7 +109,7 @@
     * @param apply 报名信息,包含userId,applyid
     * @return
     */
    void updateApplyStatus(ApplyVO apply);
    void updateApplyStatus(ApplyVO apply);
    /**
     * 查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
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,80 +159,114 @@
    <!--懒加载获取部门树形结构(包含用户数据)app-->
    <select id="lazyTreeUserApp" resultType="org.springblade.modules.system.vo.DeptAndUserVO" >
        select DISTINCT  * from (
        (SELECT
        dept.id,
        dept.parent_id,
        dept.dept_name AS label,
        dept.id AS "key",
        dept.id AS "value",
        1 as idCardNo,
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        blade_dept
        WHERE
        parent_id = dept.id and dept.is_deleted = 0
        ) AS "has_children"
        FROM
        blade_dept dept
        left join
        blade_user bu
        on
        bu.dept_id = dept.id
        WHERE
        dept.is_deleted = 0
        and bu.is_deleted = 0
        <if test="type==1">
        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
            AND dept.parent_id = "1413470343230877697"
        </if>
        <if test="type==2 or type==3">
            and dept_category=2
            AND dept.parent_id = "1123598813738675201"
        </if>
        <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
            and dept_category=1
            AND dept.parent_id = "1413470343230877697"
            and bu.jurisdiction = #{jurisdiction}
        </if>
        )
            ) AS "has_children"
        from (
            (SELECT
            dept.id,
            dept.parent_id,
            dept.dept_name AS label,
            dept.id AS "key",
            dept.id AS "value",
            1 as idCardNo,
            (
                SELECT
                CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
                FROM
                blade_dept
                WHERE
                parent_id = dept.id and dept.is_deleted = 0
                ) AS "has_children"
                FROM
                blade_dept dept
                left join
                blade_user bu
                on
                bu.dept_id = dept.id
                WHERE
                dept.is_deleted = 0
                and bu.is_deleted = 0
                <if test="type==1">
                    and dept_category=1
                    AND dept.parent_id = "1413470343230877697"
                </if>
                <if test="type==2 or type==3">
                    and dept_category=2
                    AND dept.parent_id = "1123598813738675201"
                </if>
                <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
                    and dept_category=1
                    AND dept.parent_id = "1413470343230877697"
                    and bu.jurisdiction = #{jurisdiction}
                </if>
            )
        union all
            union all
        (select
        bu.id,
        bu.dept_id  parent_id,
        bu.real_name AS label,
        bu.id AS "key",
        bu.id AS "value",
        bu.cardid as idCardNo,
        0 as "has_children"
        from blade_user bu
        left join
        blade_dept bd
        on
        bd.id = bu.dept_id
        where 1=1
        and bu.is_deleted = 0
        <if test="type==1">
            and dept_category=1
        </if>
        <if test="type==2 or type==3">
            and dept_category=2
        </if>
        <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
            and dept_category=1
            and bu.jurisdiction = #{jurisdiction}
        </if>
        )
            (
                select
                bu.id,
                bu.dept_id  parent_id,
                bu.real_name AS label,
                bu.id AS "key",
                bu.id AS "value",
                bu.cardid as idCardNo,
                0 as "has_children"
                from blade_user bu
                left join
                blade_dept bd
                on
                bd.id = bu.dept_id
                where 1=1
                and bu.is_deleted = 0
                <if test="type==1">
                    and dept_category=1
                </if>
                <if test="type==2 or type==3">
                    and dept_category=2
                </if>
                <if test="type==4 and jurisdiction!=null and jurisdiction!=''">
                    and dept_category=1
                    and bu.jurisdiction = #{jurisdiction}
                </if>
            )
        )c
    </select>
    <!--懒加载获取部门树形结构(包含用户数据)-->
    <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,