Administrator
2021-07-21 ce1bed041480dd3a4f1bab977ba7e02a2e055462
报名考试接口模块合并
39 files added
2712 ■■■■■ changed files
src/main/java/org/springblade/modules/apply/controller/ApplyController.java 199 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/entity/Apply.java 161 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml 78 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/ApplyService.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java 48 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java 60 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java 182 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java 129 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java 144 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamSubjectOptionController.java 105 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamExaminationSubject.java 73 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamPaper.java 102 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamScore.java 111 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamSubjectChoices.java 117 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamSubjectOption.java 95 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java 50 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml 102 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml 43 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectChoicesMapper.java 44 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectChoicesMapper.xml 87 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectOptionMapper.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectOptionMapper.xml 33 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java 57 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamScoreService.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamSubjectChoicesService.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamSubjectOptionService.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java 72 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java 123 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectOptionServiceImpl.java 32 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamPaperSubjectVO.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamResultVO.java 28 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamScoreVO.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamSubjectChoicesVO.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamSubjectOptionVO.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java 44 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/controller/ApplyController.java
New file
@@ -0,0 +1,199 @@
package org.springblade.modules.apply.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.service.ApplyService;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springframework.web.bind.annotation.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
/**
 * @author zhongrj
 * @time 2021-07-17
 * @desc 考试报名管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/apply")
public class ApplyController {
    private final ApplyService applyService;
    private final ExamPaperService examPaperService;
    /**
     * 自定义分页
     * @param query page,size
     * @param apply 考试报名信息对象
     */
    @GetMapping("/page")
    public R<IPage<ApplyVO>> page(ApplyVO apply, Query query) {
        IPage<ApplyVO> pages = applyService.selectApplyPage(Condition.getPage(query), apply);
        return R.data(pages);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    public R<IPage<Apply>> list(Apply apply, Query query) {
        IPage<Apply> pages = applyService.page(Condition.getPage(query), Condition.getQueryWrapper(apply));
        return R.data(pages);
    }
    /**
     * 新增
     * @param apply 考试报名信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入apply")
    public R save(@RequestBody Apply apply) {
        return R.status(applyService.save(apply));
    }
    /**
     * 修改
     * @param apply 考试报名信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody Apply apply) {
        return R.status(applyService.updateById(apply));
    }
    /**
     * 新增或修改
     * @param apply 考试报名信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Apply apply) {
        if (null==apply.getId()){
            //去生成准考证号码
            apply.setCandidateNo(getCandidateNo(apply));
            //默认通过
            apply.setApplyStatus(2);
        }
        return R.status(applyService.saveOrUpdate(apply));
    }
    /**
     * 生成准考证号码
     * @param apply 考试报名信息对象
     */
    private String getCandidateNo(Apply apply) {
        //获取考试信息
        ExamPaper examPaper = examPaperService.getById(apply.getExamId());
        if (null!=examPaper.getStartTime()){
            String format = new SimpleDateFormat("yyyy-MM-dd").format(examPaper.getStartTime());
            String year = format.substring(2,4);
            String quarter  = null;
            String months = null;
            String days = null;
            int month = Integer.parseInt(format.substring(5,7));
            int day = Integer.parseInt(format.substring(8,10));
            if (month>0 && month<=3){
                quarter = "C";
            }
            if (month>3 && month<=6){
                quarter = "X";
            }
            if (month>6 && month<=9){
                quarter = "Q";
            }
            if (month>9 && month<=12){
                quarter = "D";
            }
            if (month<=9){
                months = "0" + month;
            }
            if (day<=9){
                days = "0" + day;
            }
            //获取考试名称前缀,去除数字,字母
            String examName
                = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1);
            //前缀 = 年的最后两位  + 月份(两位) + 考试名称(中文拼音)首字母(去除数字,字母) + 考试类型 + 季度拼音首字母大写(春季就是 C)
            String result = year
                            + months
                            + toFirstChar(examName).toUpperCase()
                            + examPaper.getExamType()
                            + quarter;
            //查询是当前前缀已生成的数量
            int count = applyService.getCandidateNoCount(result);
            if (count==0){
                return result + "0000";
            }
            //格式化
            DecimalFormat decimalFormat = new DecimalFormat("0000");
            //返回
            return result + (decimalFormat.format(count++));
        }
        return null;
    }
    /**
     * 获取字符串拼音的第一个字母
     * @param chinese
     * @return
     */
    private String toFirstChar(String chinese){
        String pinyinStr = "";
        char[] newChar = chinese.toCharArray();
        //转为单个字符
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        for (int i = 0; i < newChar.length; i++) {
            if (newChar[i] > 128) {
                try {
                    pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            }else{
                pinyinStr += newChar[i];
            }
        }
        return pinyinStr;
    }
    /**
     * 删除
     * @param ids 考试报名信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(applyService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     * @param apply 考试报名信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入apply")
    public R<ApplyVO> details(Apply apply) {
        //查询考试报名详情
        ApplyVO detail = applyService.selectApplyInfo(apply);
        //返回
        return R.data(detail);
    }
}
src/main/java/org/springblade/modules/apply/entity/Apply.java
New file
@@ -0,0 +1,161 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.apply.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 考试报名实体类
 *
 * @author zhongrj
 * @since 2021-07-17
 */
@Data
@TableName("sys_apply")
public class Apply implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 用户id
     */
    @TableField("user_id")
    private Long userId;
    /**
     * 姓名
     */
    private String name;
    /**
     * 身高
     */
    private String height;
    /**
     * 体重
     */
    private String weight;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 电子头像,用于打印准考证
     */
    private String avatar;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 手机
     */
    private String phone;
    /**
     * 性别
     */
    private Integer sex;
    /**
     * 身份证
     */
    @TableField("id_card_no")
    private String idCardNo;
    /**
     * 准考证号,通过审核后生成
     */
    @TableField("candidate_no")
    private String candidateNo;
    /**
     * 报名时间
     */
    @TableField("apply_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date applyTime;
    /**
     * 审核时间
     */
    @TableField("audit_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date auditTime;
    /**
     * 考试类型
     */
    @TableField("apply_exam_type")
    private Integer applyExamType;
    /**
     * 报名状态
     */
    @TableField("apply_status")
    private Integer applyStatus;
    /**
     * 审核失败原因
     */
    @TableField("fail_reason")
    private String failReason;
    /**
     * 考试id
     */
    @TableField("exam_id")
    private Long examId;
    /**
     * 考试时间
     */
    @TableField("exam_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date examTime;
    private String examinationType;
    private String examinationMx;
}
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.java
New file
@@ -0,0 +1,40 @@
package org.springblade.modules.apply.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.vo.ApplyVO;
import java.util.List;
/**
 * 考试报名Mapper 接口
 * @author zhongrj
 */
public interface ApplyMapper extends BaseMapper<Apply> {
    /**
     * 自定义分页
     *
     * @param page  分页
     * @param apply 实体
     * @return
     */
    List<ApplyVO> selectApplyPage(IPage page, @Param("apply") ApplyVO apply);
    /**
     * 详情
     *
     * @param apply 考试报名信息对象
     */
    ApplyVO selectApplyInfo(@Param("apply") Apply apply);
    /**
     * 获取准考证前缀相同的数量
     * @param result 前缀
     * @return
     */
    int getCandidateNoCount(@Param("result")String result);
}
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
New file
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.apply.mapper.ApplyMapper">
    <!--考试报名分页信息-->
    <select id="selectApplyPage" resultType="org.springblade.modules.apply.vo.ApplyVO">
        SELECT
            sa.id,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
            ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
            bu.real_name name,sa.examination_type,sa.examination_mx,
            bd.dept_name deptName
        FROM
            sys_apply sa
        left join
            ksxt_exam ke
        on
            sa.exam_id = ke.id
        left join
            blade_user bu
        on
            sa.user_id = bu.id
        left join
            blade_dept bd
        on
            bd.id = bu.dept_id
        WHERE
            1=1
        <if test="apply.name!=null and  apply.name!=''">
            and sa.name like concat('%', #{apply.name},'%')
        </if>
        <if test="apply.applyStatus!=null">
            and apply_status = #{apply.applyStatus}
        </if>
        <if test="apply.applyExamType!=null">
            and apply_exam_type = #{apply.applyExamType}
        </if>
        <if test="apply.examId!=null">
            and sa.exam_id = #{apply.examId}
        </if>
    </select>
    <!--考试报名详情信息-->
    <select id="selectApplyInfo" resultType="org.springblade.modules.apply.vo.ApplyVO">
        SELECT
            sa.id,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
            ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
            bu.real_name name,sa.examination_type,sa.examination_mx,
            bd.dept_name deptName
        FROM
            sys_apply sa
        left join
            ksxt_exam ke
        on
            sa.exam_id = ke.id
        left join
            blade_user bu
        on
            sa.user_id = bu.id
        left join
            blade_dept bd
        on
            bd.id = bu.dept_id
        WHERE
            1=1
        <if test="apply.id!=null">
            and sa.id = #{apply.id}
        </if>
    </select>
    <!--获取准考证前缀相同的数量-->
    <select id="getCandidateNoCount" resultType="java.lang.Integer">
        select count(*) from sys_apply
        where 1=1
        <if test="result!=null and result!=''">
            and candidate_no like concat('%', #{result},'%')
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/apply/service/ApplyService.java
New file
@@ -0,0 +1,35 @@
package org.springblade.modules.apply.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.vo.ApplyVO;
/**
 * 考试报名服务类
 * @author zhongrj
 */
public interface ApplyService extends IService<Apply> {
    /**
     * 自定义分页
     * @param page
     * @param apply
     * @return
     */
    IPage<ApplyVO> selectApplyPage(IPage<ApplyVO> page, ApplyVO apply);
    /**
     * 详情
     * @param apply 考试报名信息对象
     * @return
     */
    ApplyVO selectApplyInfo(Apply apply);
    /**
     * 获取准考证前缀相同的数量
     * @param result 前缀
     * @return
     */
    int getCandidateNoCount(String result);
}
src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
New file
@@ -0,0 +1,48 @@
package org.springblade.modules.apply.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.apply.mapper.ApplyMapper;
import org.springblade.modules.apply.service.ApplyService;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springframework.stereotype.Service;
/**
 * 考试报名服务实现类
 * @author zhongrj
 */
@Service
public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements ApplyService {
    /**
     * 自定义分页数据
     * @param page 分页条件
     * @param apply 考试报名对象
     * @return
     */
    @Override
    public IPage<ApplyVO> selectApplyPage(IPage<ApplyVO> page, ApplyVO apply) {
        return page.setRecords(baseMapper.selectApplyPage(page, apply));
    }
    /**
     * 详情
     * @param apply 考试报名信息对象
     */
    @Override
    public ApplyVO selectApplyInfo(Apply apply) {
        return baseMapper.selectApplyInfo(apply);
    }
    /**
     * 获取准考证前缀相同的数量
     * @param result 前缀
     * @return
     */
    @Override
    public int getCandidateNoCount(String result) {
        return baseMapper.getCandidateNoCount(result);
    }
}
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java
New file
@@ -0,0 +1,60 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.apply.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springblade.modules.apply.entity.Apply;
import java.io.Serializable;
/**
 * 考试报名实体类
 *
 * @author zhongrj
 * @since 2021-07-17
 */
@Data
@TableName("sys_apply")
public class ApplyVO extends Apply implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 试卷分数
     */
    private Integer paperScore;
    /**
     * 考试类型
     */
    private Integer examType;
    /**
     * 考试名称
     */
    private String examName;
    /**
     * 保安单位名称
     */
    private String deptName;
}
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
New file
@@ -0,0 +1,182 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright exam,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  exam, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
import org.springblade.modules.exam.vo.ExamPaperVO;
import org.springblade.modules.exam.wrapper.ExamPaperWrapper;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 控制器
 *
 * @author Chill
 */
@RestController
@RequestMapping("/exampaper")
@AllArgsConstructor
public class ExamPaperController extends BladeController {
    private final ExamPaperService examPaperService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入exam")
    public R<ExamPaperVO> detail(ExamPaper exam) {
        ExamPaper detail = examPaperService.getOne(Condition.getQueryWrapper(exam));
        return R.data(ExamPaperWrapper.build().entityVO(detail));
    }
    /**
     * 分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入exam")
    public R<IPage<ExamPaperVO>> list(@ApiIgnore @RequestParam Map<String, Object> exam, Query query) {
        IPage<ExamPaper> pages = examPaperService.page(Condition.getPage(query), Condition.getQueryWrapper(exam, ExamPaper.class));
        return R.data(ExamPaperWrapper.build().pageVO(pages));
    }
    /**
     * 分页
     */
    @GetMapping("/pages")
    public R<IPage<ExamPaperVO>> page(ExamPaperVO exam, Query query) {
        IPage<ExamPaperVO> pages = examPaperService.selectExamPaperPage(Condition.getPage(query), exam);
        return R.data(pages);
    }
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入exam")
    public R save(@RequestBody ExamPaper exam) {
        return R.status(examPaperService.save(exam));
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入exam")
    public R update(@RequestBody ExamPaper exam) {
        return R.status(examPaperService.updateById(exam));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入exam")
    public R submit(@RequestBody ExamPaper exam) {
        return R.status(examPaperService.saveOrUpdate(exam));
    }
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入exam")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        boolean temp = examPaperService.removeByIds(Func.toLongList(ids));
        return R.status(temp);
    }
    /**
     * 考试题目绑定
     */
    @GetMapping("/setPagerSubject")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "考试题目绑定", notes = "传入exam")
    public R setPagerSubject(@ApiParam(value = "主键集合") ExamPaper exam) {
        return R.status(true);
    }
    /**
     * 查询考试题目
     */
    @GetMapping("/queryPagerSubject")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "考试题目绑定", notes = "传入exam")
    public R<ExamPaperSubjectVO> queryPagerSubject(@ApiParam(value = "主键集合") ExamPaper exam) {
        ExamPaperSubjectVO subject = examPaperService.queryPagerSubject(exam);
        return R.data(subject);
    }
    /**
     * 返回当前时间
     */
    @GetMapping("/getdate")
    @ApiOperationSupport(order = 9)
    public R getdate() {
        Date date = new Date();
        String strDateFormat = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
        System.out.println(sdf.format(date));
        return R.data(sdf.format(date));
    }
    /**
     * 自定义树
     * @param examPaper
     * @return
     */
    @GetMapping("/page-tree")
    public R pageTree(ExamPaper examPaper) {
        List<ExamPaper> pages = examPaperService.selectExamPaperPageTree(examPaper);
        return R.data(pages);
    }
    /**
     * 解除绑定
     */
    @GetMapping("/UnbindSubject")
    public R UnbindSubject(String paperid,String subjectid){
        return R.status(examPaperService.UnbindSubject(paperid,subjectid));
    }
}
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
New file
@@ -0,0 +1,129 @@
package org.springblade.modules.exam.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springframework.web.bind.annotation.*;
/**
 * @author zhongrj
 * @time 2021-07-16
 * @desc 考试成绩管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/examScore")
public class ExamScoreController {
    private final ExamScoreService examScoreService;
    /**
     * 自定义分页
     * @param query page,size
     * @param examScore 考试成绩信息对象
     */
    @GetMapping("/page")
    public R<IPage<ExamScoreVO>> page(ExamScoreVO examScore, Query query) {
        IPage<ExamScoreVO> pages = examScoreService.selectExamScorePage(Condition.getPage(query), examScore);
        return R.data(pages);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    public R<IPage<ExamScore>> list(ExamScore examScore, Query query) {
        IPage<ExamScore> pages = examScoreService.page(Condition.getPage(query), Condition.getQueryWrapper(examScore));
        return R.data(pages);
    }
    /**
     * 新增
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入examScore")
    public R save(@RequestBody ExamScore examScore) {
        return R.status(examScoreService.save(examScore));
    }
    /**
     * 保存考试成绩
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/saveExamScore")
    public R saveExamScore(@RequestBody ExamScoreVO examScore) {
        return R.status(examScoreService.saveExamScore(examScore));
    }
    /**
     * 修改
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody ExamScore examScore) {
        return R.status(examScoreService.updateById(examScore));
    }
    /**
     * 修改总成绩
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/updateExamScore")
    public R updateExamScore(@RequestBody ExamScore examScore) {
        if (null!=examScore.getLearnGrade() && null!=examScore.getTheoryGrade()){
            if (examScore.getTheoryGrade()>=60 && examScore.getLearnGrade()>=60){
                //合格
                examScore.setQualified(0);
            }else {
                //不合格
                examScore.setQualified(1);
            }
            int totalSocre = examScore.getLearnGrade()+examScore.getTheoryGrade();
            examScore.setAllGrade(Math.round(totalSocre/2));
        }
        return R.status(examScoreService.updateById(examScore));
    }
    /**
     * 新增或修改
     * @param examScore 考试成绩信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody ExamScore examScore) {
        return R.status(examScoreService.saveOrUpdate(examScore));
    }
    /**
     * 删除
     * @param ids 考试成绩信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(examScoreService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     * @param examScore 考试成绩信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入examScore")
    public R<ExamScoreVO> details(ExamScore examScore) {
        //查询考试成绩详情
        ExamScoreVO detail = examScoreService.selectExamScoreInfo(examScore);
        //返回
        return R.data(detail);
    }
}
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java
New file
@@ -0,0 +1,144 @@
package org.springblade.modules.exam.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.service.ExamSubjectChoicesService;
import org.springblade.modules.exam.vo.ExamSubjectChoicesVO;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
/**
 * @author zhongrj
 * @time 2021-07-16
 * @desc 选择题管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/examSubjectChoices")
public class ExamSubjectChoicesController {
    private final ExamSubjectChoicesService examSubjectChoicesService;
    /**
     * 自定义分页
     *
     * @param query              page,size
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/page")
    public R<IPage<ExamSubjectChoicesVO>> page(ExamSubjectChoicesVO examSubjectChoices, Query query) {
        IPage<ExamSubjectChoicesVO> pages = examSubjectChoicesService.selectExamSubjectChoicesPage(Condition.getPage(query), examSubjectChoices);
        return R.data(pages);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    public R<IPage<ExamSubjectChoices>> list(ExamSubjectChoices examSubjectChoices, Query query) {
        IPage<ExamSubjectChoices> pages = examSubjectChoicesService.page(Condition.getPage(query), Condition.getQueryWrapper(examSubjectChoices));
        return R.data(pages);
    }
    /**
     * 新增
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入examSubjectChoices")
    public R save(@RequestBody ExamSubjectChoices examSubjectChoices) {
        return R.status(examSubjectChoicesService.save(examSubjectChoices));
    }
    /**
     * 修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody ExamSubjectChoices examSubjectChoices) {
        return R.status(examSubjectChoicesService.updateById(examSubjectChoices));
    }
    /**
     * 新增或修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody ExamSubjectChoices examSubjectChoices) {
        if (null != examSubjectChoices.getId()) {
            examSubjectChoices.setCreateDate(new Date());
        } else {
            examSubjectChoices.setModifyDate(new Date());
        }
        return R.status(examSubjectChoicesService.saveOrUpdate(examSubjectChoices));
    }
    /**
     * 删除
     *
     * @param ids 选择题信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(examSubjectChoicesService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoices> detail(ExamSubjectChoices examSubjectChoices) {
        //查询选择题详情
        ExamSubjectChoices detail = examSubjectChoicesService.getOne(Condition.getQueryWrapper(examSubjectChoices));
        //返回
        return R.data(detail);
    }
    /**
     * 详情(包含选项信息)
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/details")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoicesVO> details(ExamSubjectChoices examSubjectChoices) {
        //查询选择题详情
        ExamSubjectChoicesVO detail = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices);
        //返回
        return R.data(detail);
    }
    /**
     * 查询试卷包含的题目
     */
    @GetMapping("/getEexPaperChoices")
    public R<IPage<ExamSubjectChoicesVO>> getEexPaperChoices(ExamSubjectChoicesVO examSubjectChoices, Query query) {
        IPage<ExamSubjectChoicesVO> pages = examSubjectChoicesService.getEexPaperChoices(Condition.getPage(query), examSubjectChoices);
        return R.data(pages);
    }
    /**
     * 修改单项题目分值
     */
    @PostMapping("/updateChoicesValue")
    public R updateChoicesValue(String id,String value) {
        return R.status(examSubjectChoicesService.updateChoicesValue(id,value));
    }
}
src/main/java/org/springblade/modules/exam/controller/ExamSubjectOptionController.java
New file
@@ -0,0 +1,105 @@
package org.springblade.modules.exam.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import org.springblade.modules.exam.service.ExamSubjectOptionService;
import org.springblade.modules.exam.vo.ExamSubjectOptionVO;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
/**
 * @author zhongrj
 * @time 2021-07-16
 * @desc 选择题选项管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/examSubjectOption")
public class ExamSubjectOptionController {
    private final ExamSubjectOptionService examSubjectOptionService;
    /**
     * 自定义分页
     * @param query page,size
     * @param examSubjectOption 选择题选项信息对象
     */
    @GetMapping("/page")
    public R<IPage<ExamSubjectOptionVO>> page(ExamSubjectOptionVO examSubjectOption, Query query) {
        IPage<ExamSubjectOptionVO> pages = examSubjectOptionService.selectExamSubjectOptionPage(Condition.getPage(query), examSubjectOption);
        return R.data(pages);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    public R<IPage<ExamSubjectOption>> list(ExamSubjectOption examSubjectOption, Query query) {
        IPage<ExamSubjectOption> pages = examSubjectOptionService.page(Condition.getPage(query), Condition.getQueryWrapper(examSubjectOption));
        return R.data(pages);
    }
    /**
     * 新增
     * @param examSubjectOption 选择题选项信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入examSubjectOption")
    public R save(@RequestBody ExamSubjectOption examSubjectOption) {
        return R.status(examSubjectOptionService.save(examSubjectOption));
    }
    /**
     * 修改
     * @param examSubjectOption 选择题选项信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody ExamSubjectOption examSubjectOption) {
        return R.status(examSubjectOptionService.updateById(examSubjectOption));
    }
    /**
     * 新增或修改
     * @param examSubjectOption 选择题选项信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody ExamSubjectOption examSubjectOption) {
        if (null!=examSubjectOption.getId()){
            examSubjectOption.setCreateDate(new Date());
        }else {
            examSubjectOption.setModifyDate(new Date());
        }
        return R.status(examSubjectOptionService.saveOrUpdate(examSubjectOption));
    }
    /**
     * 删除
     * @param ids 选择题选项信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(examSubjectOptionService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 详情
     * @param examSubjectOption 选择题选项信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入examSubjectOption")
    public R<ExamSubjectOptionVO> details(ExamSubjectOption examSubjectOption) {
        //查询选择题选项详情
        ExamSubjectOptionVO detail = examSubjectOptionService.selectExamSubjectOptionInfo(examSubjectOption);
        //返回
        return R.data(detail);
    }
}
src/main/java/org/springblade/modules/exam/entity/ExamExaminationSubject.java
New file
@@ -0,0 +1,73 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
 *  试卷分类实体类
 *
 * @author Chill
 */
@Data
@TableName("exam_examination_subject")
public class ExamExaminationSubject implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 试卷id
     */
    @TableField("examination_id")
    private String examinationId;
    /**
     * 分类
     */
    @TableField("category_id")
    private Integer categoryId;
    /**
     * 题目id
     */
    @TableField("subject_id")
    private String subjectId;
    /**
     * 题目对象
     */
    private ExamSubjectChoices examSubjectChoices;
}
src/main/java/org/springblade/modules/exam/entity/ExamPaper.java
New file
@@ -0,0 +1,102 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * 实体类
 *
 * @author Chill
 */
@Data
@TableName("ksxt_exam")
public class ExamPaper implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 考试名称
     */
    private String examName;
    /**
     * 考试类型
     */
    private Integer examType;
    /**
     * 注意事项
     */
    private String examAttention;
    /**
     * 考试开始时间
     */
    private Date startTime;
    /**
     * 考试结束时间
     */
    private Date endTime;
    /**
     * 时间区间
     */
    private String examTime;
    /**
     * 总分
     */
    private String totalScore;
    /**
     * 状态
     */
    private Integer examStatus;
    /**
     * 创建人
     */
    private String creator;
    /**
     * 创建时间
     */
    private Date creatorDate;
    /**
     * 备注
     */
    private String remark;
}
src/main/java/org/springblade/modules/exam/entity/ExamScore.java
New file
@@ -0,0 +1,111 @@
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 考试成绩实体类
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
@TableName("exam_score")
public class ExamScore implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 考试成绩主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 准考证号
     */
    @TableField("candidate_no")
    private String candidateNo;
    /**
     * 理论成绩
     */
    @TableField("theory_grade")
    private Integer theoryGrade;
    /**
     * 实操成绩
     */
    @TableField("learn_grade")
    private Integer learnGrade;
    /**
     * 总成绩
     */
    @TableField("all_grade")
    private Integer allGrade;
    /**
     * 考试类型 0:正式考试  1: 模拟考试  2:在线联系  3:调查问卷
     */
//    @TableField("exam_type")
//    private Integer examType;
    /**
     * 考试人员所属公司名称
     */
    private String company;
    /**
     * 考试开始时间
     */
    @TableField("exam_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date examTime;
    /**
     * 考试结束时间
     */
    @TableField("exam_end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date examEndTime;
    /**
     * 考试名称
     */
    @TableField("exam_name")
    private String examName;
    /**
     * 考试人员姓名
     */
    @TableField("security_name")
    private String securityName;
    /**
     * 试卷总分值
     */
    @TableField("all_score")
    private Integer allScore;
    /**
     * 是否合格  0:合格  1:不合格  2: 暂未录入实操成绩
     */
    private Integer qualified;
}
src/main/java/org/springblade/modules/exam/entity/ExamSubjectChoices.java
New file
@@ -0,0 +1,117 @@
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 选择题实体类
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
@TableName("exam_subject_choices")
public class ExamSubjectChoices implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 选择题主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 题目 ID
     */
    @TableField("category_id")
    private Long categoryId;
    /**
     * 题目名称
     */
    @TableField("subject_name")
    private String subjectName;
    /**
     * 题目类型
     */
    @TableField("choices_type")
    private Integer choicesType;
    /**
     * 参考答案
     */
    private String answer;
    /**
     * 题目分值
     */
    private Integer score;
    /**
     * 解析
     */
    private String analysis;
    /**
     * 难度等级
     */
    private Integer level;
    /**
     * 创建人
     */
    private String creator;
    /**
     * 创建时间
     */
    @TableField("create_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    /**
     * 修改人
     */
    private String modifier;
    /**
     * 修改时间
     */
    @TableField("modify_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date modifyDate;
    /**
     * 删除标记 0:正常;1:删除
     */
    @TableField("del_flag")
    private Integer delFlag;
    /**
     * 系统编号
     */
    @TableField("application_code")
    private String applicationCode;
    /**
     *
     */
    @TableField("tenant_code")
    private String tenantCode;
}
src/main/java/org/springblade/modules/exam/entity/ExamSubjectOption.java
New file
@@ -0,0 +1,95 @@
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 选择题选项实体类
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
@TableName("exam_subject_option")
public class ExamSubjectOption implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 选择题主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 选择题ID
     */
    @TableField("subject_choices_id")
    private Long subjectChoicesId;
    /**
     * 选项名称
     */
    @TableField("option_name")
    private String optionName;
    /**
     * 选项内容
     */
    @TableField("option_content")
    private String optionContent;
    /**
     * 创建人
     */
    private String creator;
    /**
     * 创建时间
     */
    @TableField("create_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    /**
     * 修改人
     */
    private String modifier;
    /**
     * 修改时间
     */
    @TableField("modify_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date modifyDate;
    /**
     * 删除标记 0:正常;1:删除
     */
    @TableField("del_flag")
    private Integer delFlag;
    /**
     * 系统编号
     */
    @TableField("application_code")
    private String applicationCode;
    /**
     * 租户编号
     */
    @TableField("tenant_code")
    private String tenantCode;
}
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
New file
@@ -0,0 +1,50 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
import org.springblade.modules.exam.vo.ExamPaperVO;
import java.util.List;
/**
 * Mapper 接口
 *
 * @author Chill
 */
public interface ExamPaperMapper extends BaseMapper<ExamPaper> {
    IPage<ExamPaperVO> selectExamPaperPage(IPage page, ExamPaperVO exam);
    ExamPaperSubjectVO queryPagerSubject(@Param("paper") ExamPaper paper);
    ExamPaperSubjectVO PagerSubject(@Param("paper") ExamPaper paper);
    /**
     * 自定义树
     *
     * @param examPaper 试卷对象
     * @return
     */
    List<ExamPaper> selectExamPaperPageTree(@Param("paper") ExamPaper examPaper);
    boolean UnbindSubject(String paperid, String subjectid);
}
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
New file
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.exam.mapper.ExamPaperMapper">
    <resultMap id="PagerSubject" type="org.springblade.modules.exam.vo.ExamPaperSubjectVO"
               autoMapping="true">
        <id property="id" column="id"/>
        <collection property="examExaminationSubjects" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamExaminationSubject" autoMapping="true">
            <id property="id" column="tid"/>
            <association property="examSubjectChoices" javaType="org.springblade.modules.exam.entity.ExamSubjectChoices" resultMap="brakesResult" autoMapping="true">
            </association>
        </collection>
    </resultMap>
    <resultMap id="PagerSubjectAnswer" type="org.springblade.modules.exam.vo.ExamPaperSubjectVO"
               autoMapping="true">
        <id property="id" column="id"/>
        <collection property="examExaminationSubjects" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamExaminationSubject" autoMapping="true">
            <id property="id" column="tid"/>
            <association property="examSubjectChoices" javaType="org.springblade.modules.exam.entity.ExamSubjectChoices" autoMapping="true">
                <id property="id" column="sid"/>
            </association>
        </collection>
    </resultMap>
    <resultMap id="brakesResult" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        <id property="id" column="sid"/>
        <id property="categoryId" column="category_id"/>
        <id property="subjectName" column="subject_name"/>
        <id property="choicesType" column="choices_type"/>
        <id property="score" column="score"/>
        <id property="analysis" column="analysis"/>
        <id property="level" column="level"/>
        <id property="creator" column="creator"/>
        <id property="createDate" column="create_date"/>
        <id property="modifier" column="modifier"/>
        <id property="modifyDate" column="modify_date"/>
        <id property="delFlag" column="del_flag"/>
        <id property="applicationCode" column="application_code"/>
        <id property="tenantCode" column="tenant_code"/>
    </resultMap>
    <select id="queryPagerSubject" resultMap="PagerSubject">
        SELECT
        sj.*,
        tm.id tid,
        tmxq.id as sid,tmxq.*
        FROM
        ksxt_exam sj
        LEFT JOIN exam_examination_subject tm ON sj.id = tm.examination_id
        LEFT JOIN exam_subject_choices tmxq ON tm.subject_id = tmxq.id
        WHERE
        1 = 1
        <if test="paper.id !=null">
        and sj.id = #{paper.id}
        </if>
    </select>
    <select id="selectExamPaperPage" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
        SELECT
            *
        FROM
            (SELECT
                sj.*,
                ( SELECT CASE WHEN COUNT ( * ) > 0 THEN 1 ELSE 0 END FROM sys_apply WHERE user_id = 11 ) AS show
            FROM
                ksxt_exam sj ) as s
        WHERE
            show = 1
    </select>
    <select id="PagerSubject" resultMap="PagerSubjectAnswer">
        SELECT
        sj.*,
        tm.id tid,
        tmxq.id as sid,tmxq.*
        FROM
        ksxt_exam sj
        LEFT JOIN exam_examination_subject tm ON sj.id = tm.examination_id
        LEFT JOIN exam_subject_choices tmxq ON tm.subject_id = tmxq.id
        WHERE
        1 = 1
        <if test="paper.id !=null">
        and sj.id = #{paper.id}
        </if>
    </select>
    <!--自定义树-->
    <select id="selectExamPaperPageTree" resultType="org.springblade.modules.exam.entity.ExamPaper">
        select id,exam_name examName from ksxt_exam
        where
        1=1
        <if test="paper.examName!=null and paper.examName!=''">
            and exam_name like concat('%', #{paper.examName},'%')
        </if>
    </select>
    <delete id="UnbindSubject">
       delete from exam_examination_subject where examination_id = #{paperid} and subject_id = #{subjectid}
    </delete>
</mapper>
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.java
New file
@@ -0,0 +1,34 @@
package org.springblade.modules.exam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.vo.ExamScoreVO;
import java.util.List;
/**
 * 考试成绩Mapper 接口
 * @author zhongrj
 */
public interface ExamScoreMapper extends BaseMapper<ExamScore> {
    /**
     * 自定义分页
     *
     * @param page  分页
     * @param examScore 实体
     * @return
     */
    List<ExamScoreVO> selectExamScorePage(IPage page, @Param("examScore") ExamScoreVO examScore);
    /**
     * 详情
     *
     * @param examScore 考试成绩信息对象
     */
    ExamScoreVO selectExamScoreInfo(@Param("examScore") ExamScore examScore);
}
src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
New file
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.exam.mapper.ExamScoreMapper">
    <!--考试成绩分页信息-->
    <select id="selectExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
         id,candidate_no candidateNo,theory_grade theoryGrade,isnull(learn_grade,-1) learnGrade,all_grade,
         exam_name examName,security_name securityName,exam_type examType,company,exam_time examTime,
         all_score allScore,exam_end_time examEndTime,qualified
        FROM
            exam_score
        WHERE
            1=1
        <if test="examScore.examName!=null and  examScore.examName!=''">
            and exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.company!=null and  examScore.company!=''">
            and company like concat('%', #{examScore.company},'%')
        </if>
        <if test="examScore.securityName!=null and  examScore.securityName!=''">
            and security_name like concat('%', #{examScore.securityName},'%')
        </if>
<!--        <if test="examScore.examType!=null">-->
<!--            and exam_type = #{examScore.examType}-->
<!--        </if>-->
    </select>
    <!--考试成绩详情信息-->
    <select id="selectExamScoreInfo" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
            id,candidate_no candidateNo,theory_grade theoryGrade,isnull(learn_grade,-1) learnGrade,all_grade,
            exam_name examName,security_name securityName,exam_type examType,company,exam_time examTime,
            all_score allScore,exam_end_time examEndTime,qualified
        FROM
            exam_score
        WHERE
            1=1
        <if test="examScore.id!=null">
            and id = #{examScore.id}
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectChoicesMapper.java
New file
@@ -0,0 +1,44 @@
package org.springblade.modules.exam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.vo.ExamSubjectChoicesVO;
import java.util.List;
/**
 * 选择题Mapper 接口
 * @author zhongrj
 */
public interface ExamSubjectChoicesMapper extends BaseMapper<ExamSubjectChoices> {
    /**
     * 自定义分页
     *
     * @param page               分页
     * @param examSubjectChoices 实体
     * @return
     */
    List<ExamSubjectChoicesVO> selectExamSubjectChoicesPage(IPage page, @Param("examSubjectChoices") ExamSubjectChoicesVO examSubjectChoices);
    /**
     * 查询试卷题目
     * @param page
     * @param examSubjectChoices
     * @return
     */
    List<ExamSubjectChoicesVO> getEexPaperChoices(IPage page, ExamSubjectChoicesVO examSubjectChoices);
    /**
     * 详情
     *
     * @param examSubjectChoices 选择题信息对象
     */
    ExamSubjectChoicesVO selectExamSubjectChoicesInfo(@Param("examSubjectChoices") ExamSubjectChoices examSubjectChoices);
    boolean updateChoicesValue(String id,String value);
}
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectChoicesMapper.xml
New file
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.exam.mapper.ExamSubjectChoicesMapper">
    <!--选择题分页信息-->
    <select id="selectExamSubjectChoicesPage" resultType="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        SELECT
            esc.*
        FROM
            exam_subject_choices esc
        WHERE
            1=1
        <if test="examSubjectChoices.subjectName!=null and  examSubjectChoices.subjectName!=''">
            and esc.subject_name like concat('%', #{examSubjectChoices.subjectName},'%')
        </if>
        <if test="examSubjectChoices.choicesType!=null and  examSubjectChoices.choicesType!=''">
            and choices_type = #{examSubjectChoices.choicesType}
        </if>
    </select>
    <!--查询试卷绑定的题目-->
    <select id="getEexPaperChoices" resultType="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        SELECT
            esc.*
        FROM
            exam_subject_choices esc
        LEFT JOIN exam_examination_subject exa ON esc.id = exa.subject_id
        WHERE
            1=1
        <if test="examSubjectChoices.id!=null and  examSubjectChoices.id!=''">
            and exa.examination_id = #{examSubjectChoices.id}
        </if>
        <if test="examSubjectChoices.subjectName!=null and  examSubjectChoices.subjectName!=''">
            and esc.subject_name like concat('%', #{examSubjectChoices.subjectName},'%')
        </if>
        <if test="examSubjectChoices.choicesType!=null and  examSubjectChoices.choicesType!=''">
            and esc.choices_type = #{examSubjectChoices.choices_type}
        </if>
    </select>
    <!--ExamSubjectChoicesInfoMap 多表联查 一对多查询 -->
    <resultMap id="ExamSubjectChoicesInfoMap" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        <id property="id" column="id"/>
        <id property="categoryId" column="category_id"/>
        <id property="subjectName" column="subject_name"/>
        <id property="choicesType" column="choices_type"/>
        <id property="score" column="score"/>
        <id property="analysis" column="analysis"/>
        <id property="level" column="level"/>
        <id property="creator" column="creator"/>
        <id property="createDate" column="create_date"/>
        <id property="modifier" column="modifier"/>
        <id property="modifyDate" column="modify_date"/>
        <id property="delFlag" column="del_flag"/>
        <id property="applicationCode" column="application_code"/>
        <id property="tenantCode" column="tenant_code"/>
        <result column="id" property="id"/>
        <collection property="examSubjectOptions" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamSubjectOption" autoMapping="true">
            <id property="id" column="eso_id"/>
        </collection>
    </resultMap>
    <!--选择题详情信息-->
    <select id="selectExamSubjectChoicesInfo" resultMap="ExamSubjectChoicesInfoMap">
        SELECT
        esc.*,
        eso.id eso_id,eso.subject_choices_id,eso.option_name,eso.option_content,eso.creator,
        eso.create_date,eso.modifier,eso.modify_date,eso.del_flag,eso.application_code,eso.tenant_code
        FROM
        exam_subject_choices esc
        left join
        exam_subject_option eso
        on
        esc.id = eso.subject_choices_id
        WHERE
        1=1
        <if test="examSubjectChoices.id!=null">
            and esc.id = #{examSubjectChoices.id}
        </if>
    </select>
    <update id="updateChoicesValue">
        update exam_subject_choices set score = #{value} where id = #{id}
    </update>
</mapper>
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectOptionMapper.java
New file
@@ -0,0 +1,34 @@
package org.springblade.modules.exam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import org.springblade.modules.exam.vo.ExamSubjectOptionVO;
import java.util.List;
/**
 * 选择题选项Mapper 接口
 * @author zhongrj
 */
public interface ExamSubjectOptionMapper extends BaseMapper<ExamSubjectOption> {
    /**
     * 自定义分页
     *
     * @param page               分页
     * @param examSubjectOption 实体
     * @return
     */
    List<ExamSubjectOptionVO> selectExamSubjectOptionPage(IPage page, @Param("examSubjectOption") ExamSubjectOptionVO examSubjectOption);
    /**
     * 详情
     *
     * @param examSubjectOption 选择题选项信息对象
     */
    ExamSubjectOptionVO selectExamSubjectOptionInfo(@Param("examSubjectOption") ExamSubjectOption examSubjectOption);
}
src/main/java/org/springblade/modules/exam/mapper/ExamSubjectOptionMapper.xml
New file
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.exam.mapper.ExamSubjectOptionMapper">
    <!--选择题选项分页信息-->
    <select id="selectExamSubjectOptionPage" resultType="org.springblade.modules.exam.vo.ExamSubjectOptionVO">
        SELECT
        *
        FROM
        exam_subject_option
        WHERE
        1=1
        <if test="examSubjectOption.optionName!=null and  examSubjectOption.optionName!=''">
            and option_name like concat('%', #{examSubjectOption.optionName},'%')
        </if>
    </select>
    <!--选择题选项详情信息-->
    <select id="selectExamSubjectOptionInfo" resultType="org.springblade.modules.exam.vo.ExamSubjectOptionVO">
        SELECT
            *
        FROM
        exam_subject_option
        WHERE
        1=1
        <if test="examSubjectOption.id!=null">
            and id = #{examSubjectOption.id}
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
New file
@@ -0,0 +1,57 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright exam,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  exam, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
import org.springblade.modules.exam.vo.ExamPaperVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
import java.util.List;
/**
 * 服务类
 *
 * @author Chill
 */
public interface ExamPaperService extends IService<ExamPaper> {
    IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamScoreVO> page, ExamPaperVO exam);
    ExamPaperSubjectVO queryPagerSubject(ExamPaper paper);
    /**
     * 计算成绩返回答案接口
     * @param paper
     * @return
     */
    ExamPaperSubjectVO PagerSubject(ExamPaper paper);
    /**
     * 自定义树
     * @param examPaper
     * @return
     */
    List<ExamPaper> selectExamPaperPageTree(ExamPaper examPaper);
    /**
     * 解除试卷和题目的绑定
     */
    boolean UnbindSubject(String paperid,String subjectid);
}
src/main/java/org/springblade/modules/exam/service/ExamScoreService.java
New file
@@ -0,0 +1,35 @@
package org.springblade.modules.exam.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.vo.ExamScoreVO;
/**
 * 考试成绩服务类
 * @author zhongrj
 */
public interface ExamScoreService extends IService<ExamScore> {
    /**
     * 自定义分页
     * @param page
     * @param examScore
     * @return
     */
    IPage<ExamScoreVO> selectExamScorePage(IPage<ExamScoreVO> page, ExamScoreVO examScore);
    /**
     * 详情
     * @param examScore 考试成绩信息对象
     * @return
     */
    ExamScoreVO selectExamScoreInfo(ExamScore examScore);
    /**
     * 保存考试成绩
     * @param examScore 考试成绩信息对象
     * @return
     */
    Boolean saveExamScore(ExamScoreVO examScore);
}
src/main/java/org/springblade/modules/exam/service/ExamSubjectChoicesService.java
New file
@@ -0,0 +1,40 @@
package org.springblade.modules.exam.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.vo.ExamSubjectChoicesVO;
/**
 * 选择题服务类
 * @author zhongrj
 */
public interface ExamSubjectChoicesService extends IService<ExamSubjectChoices> {
    /**
     * 自定义分页
     * @param page
     * @param examSubjectChoices
     * @return
     */
    IPage<ExamSubjectChoicesVO> selectExamSubjectChoicesPage(IPage<ExamSubjectChoicesVO> page, ExamSubjectChoicesVO examSubjectChoices);
    /**
     * 查询试卷题目
     * @param page
     * @param examSubjectChoices
     * @return
     */
    IPage<ExamSubjectChoicesVO> getEexPaperChoices(IPage<ExamSubjectChoicesVO> page, ExamSubjectChoicesVO examSubjectChoices);
    /**
     * 详情
     * @param examSubjectChoices 选择题信息对象
     */
    ExamSubjectChoicesVO selectExamSubjectChoicesInfo(ExamSubjectChoices examSubjectChoices);
    /**
     *    修改分值
     */
    boolean updateChoicesValue(String id , String value);
}
src/main/java/org/springblade/modules/exam/service/ExamSubjectOptionService.java
New file
@@ -0,0 +1,27 @@
package org.springblade.modules.exam.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import org.springblade.modules.exam.vo.ExamSubjectOptionVO;
/**
 * 选择题选项服务类
 * @author zhongrj
 */
public interface ExamSubjectOptionService extends IService<ExamSubjectOption> {
    /**
     * 自定义分页
     * @param page
     * @param examSubjectOption
     * @return
     */
    IPage<ExamSubjectOptionVO> selectExamSubjectOptionPage(IPage<ExamSubjectOptionVO> page, ExamSubjectOptionVO examSubjectOption);
    /**
     * 详情
     * @param examSubjectOption 选择题选项信息对象
     */
    ExamSubjectOptionVO selectExamSubjectOptionInfo(ExamSubjectOption examSubjectOption);
}
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
New file
@@ -0,0 +1,72 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.mapper.ExamPaperMapper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
import org.springblade.modules.exam.vo.ExamPaperVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 服务实现类
 *
 * @author Chill
 */
@Service
public class ExamPaperServiceImpl extends ServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
    @Override
    public IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamScoreVO> page, ExamPaperVO exam) {
        return baseMapper.selectExamPaperPage(page,exam);
    }
    @Override
    public ExamPaperSubjectVO queryPagerSubject(ExamPaper paper) {
        //查询试卷分类信息
        return baseMapper.queryPagerSubject(paper);
    }
    @Override
    public ExamPaperSubjectVO PagerSubject(ExamPaper paper) {
        //查询试卷分类信息
        return baseMapper.PagerSubject(paper);
    }
    /**
     * 自定义树
     * @param examPaper 试卷对象
     * @return
     */
    @Override
    public List<ExamPaper> selectExamPaperPageTree(ExamPaper examPaper) {
        return baseMapper.selectExamPaperPageTree(examPaper);
    }
    @Override
    public boolean UnbindSubject(String paperid, String subjectid) {
        return baseMapper.UnbindSubject(paperid,subjectid);
    }
}
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
New file
@@ -0,0 +1,123 @@
package org.springblade.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.modules.exam.entity.ExamExaminationSubject;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.mapper.ExamScoreMapper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.vo.ExamResultVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
/**
 * 考试成绩服务实现类
 * @author zhongrj
 */
@Service
@AllArgsConstructor
public class ExamScoreServiceImpl extends ServiceImpl<ExamScoreMapper, ExamScore> implements ExamScoreService {
    private final ExamPaperService examPaperService;
    /**
     * 自定义分页数据
     * @param page 分页条件
     * @param examScore 考试成绩对象
     * @return
     */
    @Override
    public IPage<ExamScoreVO> selectExamScorePage(IPage<ExamScoreVO> page, ExamScoreVO examScore) {
        return page.setRecords(baseMapper.selectExamScorePage(page, examScore));
    }
    /**
     * 详情
     * @param examScore 考试成绩信息对象
     */
    @Override
    public ExamScoreVO selectExamScoreInfo(ExamScore examScore) {
        return baseMapper.selectExamScoreInfo(examScore);
    }
    /**
     * 保存考试成绩
     * @param examScore 考试成绩信息对象
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveExamScore(ExamScoreVO examScore) {
        //取出考试结果
        if (examScore.getExamResultVOS().size()>0){
            List<ExamResultVO> examResultVOS = examScore.getExamResultVOS();
            //获取试卷的内容(题号,答案)
            ExamPaper examPaper = new ExamPaper();
            examPaper.setId(examScore.getPapersId());
            List<ExamExaminationSubject> examExaminationSubjects
                = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects();
            //比对考试结果
            //声明理论得分
            int theoryGrade = 0;
            for (ExamResultVO examResultVO : examResultVOS) {
                for (ExamExaminationSubject examExaminationSubject : examExaminationSubjects) {
                    //对比题目id
                    if (examResultVO.getSubjectChoicesId().equals(examExaminationSubject.getExamSubjectChoices().getId())) {
                        //对比答案
                        if (examExaminationSubject.getExamSubjectChoices().getChoicesType() == 2 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 3){
                            //判断题逻辑
                            if (examResultVO.getValue().equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) {
                                theoryGrade += examResultVO.getGrade();
                            }
                        }else if(examExaminationSubject.getExamSubjectChoices().getChoicesType() == 0 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 1){
                            //处理多选题的答案排序
                            String[] split = examResultVO.getValue().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(examExaminationSubject.getExamSubjectChoices().getAnswer())) {
                                theoryGrade += examResultVO.getGrade();
                            }
                        }
                        //移除当前试卷题目答案对象
                        examExaminationSubjects.remove(examExaminationSubject);
                        break;
                    }
                }
            }
            //设置理论得分
            examScore.setTheoryGrade(theoryGrade);
            //计算总成绩,此时没有实操成绩,总成绩为实操成绩和理论成绩和的一半
            examScore.setAllGrade(Math.round(theoryGrade/2));
            //设置状态
            if (theoryGrade>=60){
                examScore.setQualified(2);
            }else {
                examScore.setQualified(1);
            }
            //保存成绩数据
            int i = baseMapper.insert(examScore);
            if (i>0){
                //返回结果
                return true;
            }
        }
        //返回结果
        return false;
    }
}
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectChoicesServiceImpl.java
New file
@@ -0,0 +1,42 @@
package org.springblade.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.mapper.ExamSubjectChoicesMapper;
import org.springblade.modules.exam.service.ExamSubjectChoicesService;
import org.springblade.modules.exam.vo.ExamSubjectChoicesVO;
import org.springframework.stereotype.Service;
/**
 * 选择题服务实现类
 * @author zhongrj
 */
@Service
public class ExamSubjectChoicesServiceImpl extends ServiceImpl<ExamSubjectChoicesMapper, ExamSubjectChoices> implements ExamSubjectChoicesService {
    @Override
    public IPage<ExamSubjectChoicesVO> selectExamSubjectChoicesPage(IPage<ExamSubjectChoicesVO> page, ExamSubjectChoicesVO examSubjectChoices) {
        return page.setRecords(baseMapper.selectExamSubjectChoicesPage(page, examSubjectChoices));
    }
    @Override
    public IPage<ExamSubjectChoicesVO> getEexPaperChoices(IPage<ExamSubjectChoicesVO> page, ExamSubjectChoicesVO examSubjectChoices) {
        return page.setRecords(baseMapper.getEexPaperChoices(page, examSubjectChoices));
    }
    /**
     * 详情
     * @param examSubjectChoices 选择题信息对象
     */
    @Override
    public ExamSubjectChoicesVO selectExamSubjectChoicesInfo(ExamSubjectChoices examSubjectChoices) {
        return baseMapper.selectExamSubjectChoicesInfo(examSubjectChoices);
    }
    @Override
    public boolean updateChoicesValue(String id, String value) {
        return baseMapper.updateChoicesValue(id,value);
    }
}
src/main/java/org/springblade/modules/exam/service/impl/ExamSubjectOptionServiceImpl.java
New file
@@ -0,0 +1,32 @@
package org.springblade.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import org.springblade.modules.exam.mapper.ExamSubjectOptionMapper;
import org.springblade.modules.exam.service.ExamSubjectOptionService;
import org.springblade.modules.exam.vo.ExamSubjectOptionVO;
import org.springframework.stereotype.Service;
/**
 * 选择题选项服务实现类
 * @author zhongrj
 */
@Service
public class ExamSubjectOptionServiceImpl extends ServiceImpl<ExamSubjectOptionMapper, ExamSubjectOption> implements ExamSubjectOptionService {
    @Override
    public IPage<ExamSubjectOptionVO> selectExamSubjectOptionPage(IPage<ExamSubjectOptionVO> page, ExamSubjectOptionVO examSubjectOption) {
        return page.setRecords(baseMapper.selectExamSubjectOptionPage(page, examSubjectOption));
    }
    /**
     * 详情
     * @param examSubjectOption 选择题选项信息对象
     */
    @Override
    public ExamSubjectOptionVO selectExamSubjectOptionInfo(ExamSubjectOption examSubjectOption) {
        return baseMapper.selectExamSubjectOptionInfo(examSubjectOption);
    }
}
src/main/java/org/springblade/modules/exam/vo/ExamPaperSubjectVO.java
New file
@@ -0,0 +1,23 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.exam.entity.ExamExaminationSubject;
import org.springblade.modules.exam.entity.ExamPaper;
import java.util.List;
/**
 * 考试类目视图类
 *
 * @author Chill
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ExamPaperSubjectVO extends ExamPaper {
    /**
     * 考试类目
     */
    private List<ExamExaminationSubject> examExaminationSubjects;
}
src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
New file
@@ -0,0 +1,16 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.exam.entity.ExamPaper;
/**
 * 通知公告视图类
 *
 * @author Chill
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ExamPaperVO extends ExamPaper {
}
src/main/java/org/springblade/modules/exam/vo/ExamResultVO.java
New file
@@ -0,0 +1,28 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import java.io.Serializable;
/**
 * @author zhongrj
 */
@Data
public class ExamResultVO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 题目id
     */
    private Long subjectChoicesId;
    /**
     * 提交的答案
     */
    private String value;
    /**
     * 每道题的分数
     */
    private Integer grade;
}
src/main/java/org/springblade/modules/exam/vo/ExamScoreVO.java
New file
@@ -0,0 +1,27 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import org.springblade.modules.exam.entity.ExamScore;
import java.io.Serializable;
import java.util.List;
/**
 * 选择题选项实体类vo
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
public class ExamScoreVO extends ExamScore implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 试卷id
     */
    private Long papersId;
    /**
     * 考勤提交的结果
     */
    private List<ExamResultVO> examResultVOS;
}
src/main/java/org/springblade/modules/exam/vo/ExamSubjectChoicesVO.java
New file
@@ -0,0 +1,22 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import java.io.Serializable;
import java.util.List;
/**
 * 选择题实体类vo
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
public class ExamSubjectChoicesVO extends ExamSubjectChoices implements Serializable {
    private static final long serialVersionUID = 1L;
    private List<ExamSubjectOption> examSubjectOptions;
}
src/main/java/org/springblade/modules/exam/vo/ExamSubjectOptionVO.java
New file
@@ -0,0 +1,18 @@
package org.springblade.modules.exam.vo;
import lombok.Data;
import org.springblade.modules.exam.entity.ExamSubjectOption;
import java.io.Serializable;
/**
 * 选择题选项实体类vo
 * @author zhongrj
 * @time 2021-07-16
 */
@Data
public class ExamSubjectOptionVO extends ExamSubjectOption implements Serializable {
    private static final long serialVersionUID = 1L;
}
src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java
New file
@@ -0,0 +1,44 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright exam,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  exam, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperVO;
import java.util.Objects;
/**
 * Notice包装类,返回视图层所需的字段
 *
 * @author Chill
 */
public class ExamPaperWrapper extends BaseEntityWrapper<ExamPaper, ExamPaperVO> {
    public static ExamPaperWrapper build() {
        return new ExamPaperWrapper();
    }
    @Override
    public ExamPaperVO entityVO(ExamPaper exam) {
        ExamPaperVO examVO = Objects.requireNonNull(BeanUtil.copy(exam, ExamPaperVO.class));
//        String dictValue = DictCache.getValue(DictEnum.NOTICE, examVO.getCategory());
        return examVO;
    }
}