“djh”
5 天以前 99132a43bf344f2aafdd9894b0762d2eedd9767b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?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="com.gkhy.exam.system.mapper.ExExamPaperMapper">
    <resultMap type="com.gkhy.exam.system.domain.ExExamPaper" id="ExamPaperResult">
        <result property="id"       column="id"       />
        <result property="name"    column="name"    />
        <result property="code"     column="code"     />
        <result property="status"  column="status"  />
        <result property="companyId"         column="company_id"          />
        <result property="categoryId"         column="category_id"          />
        <result property="limitTime"         column="limit_time"          />
        <result property="limited"         column="limited"          />
        <result property="singleNum"         column="single_num"          />
        <result property="singleScore"         column="single_score"          />
        <result property="singleBankId"         column="single_bank_id"          />
        <result property="singleMethod"         column="single_method"          />
        <result property="multiNum"         column="multi_num"          />
        <result property="multiScore"         column="multi_score"          />
        <result property="multiBankId"         column="multi_bank_id"          />
        <result property="multiMethod"         column="multi_method"          />
        <result property="judgeNum"         column="judge_num"          />
        <result property="judgeScore"         column="judge_score"          />
        <result property="judgeBankId"         column="judge_bank_id"          />
        <result property="judgeMethod"         column="judge_method"          />
        <result property="easyNum"         column="easy_num"          />
        <result property="easyScore"         column="easy_score"          />
        <result property="easyBankId"         column="easy_bank_id"          />
        <result property="easyMethod"         column="easy_method"          />
        <result property="passScore"         column="pass_score"          />
        <result property="version"         column="version"          />
        <result property="delFlag"         column="del_flag"          />
        <result property="createBy"       column="create_by"       />
        <result property="deadline"     column="deadline"     />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
        <result property="companyName"         column="company_name"          />
        <result property="categoryName"         column="category_name"          />
        <association property="paperStudentInfoVO" javaType="com.gkhy.exam.system.domain.vo.PaperStudentInfoVO"  select="getPaperStudentInfoByPaperId" column="{paperId=id}"/>
    </resultMap>
    <resultMap type="com.gkhy.exam.system.domain.ExExamPaper" id="ExamPaperResult2" extends="ExamPaperResult">
        <collection property="questions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=id}"/>
    </resultMap>
 
 
 
    <sql id="selectExamPaperVo">
        select a.id, a.name, a.code, a.status, a.company_id,a.category_id,a.deadline,a.limit_time,a.limited,a.single_num,a.single_score,a.single_bank_id,
               a.single_method,a.multi_num,a.multi_score,
               a.multi_bank_id,a.multi_method,a.judge_num,a.judge_score,a.judge_bank_id,a.judge_method,a.pass_score,
               a.easy_num,a.easy_score,a.easy_bank_id,a.easy_method,
               a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name,c.name as category_name
        from ex_exam_paper a
        left join sys_company b on b.id=a.company_id
        left join sys_category c on c.id=a.category_id
    </sql>
 
    <update id="deletePaperById">
        update ex_exam_paper set del_flag=1 where id=#{paperId}
    </update>
 
 
    <select id="selectExamPaperList" resultMap="ExamPaperResult">
        <include refid="selectExamPaperVo"/>
        <where>
            and a.del_flag=0
            <if test="name != null and name != ''">
                AND a.name like concat('%', #{name}, '%')
            </if>
            <if test="code != null and code != ''">
                AND a.credit_code like concat('%', #{creditCode}, '%')
            </if>
            <if test="companyId != null and companyId != ''">
                AND a.company_id= #{companyId}
            </if>
            <if test="categoryId != null and categoryId != ''">
                AND a.category_id= #{categoryId}
            </if>
        </where>
        order by a.id desc
    </select>
 
    <select id="selectExamPaperById" resultMap="ExamPaperResult2">
        <include refid="selectExamPaperVo"/>
        where a.id=#{paperId}
    </select>
 
    <select id="selectCountBetweenDay" resultType="java.lang.Long">
        select count(1) from ex_exam_paper where create_time &gt;= #{startTime} and create_time &lt;= #{endTime}
    </select>
 
    <select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExExamPaper">
        select id ,name from ex_exam_paper where name=#{name} and del_flag=0
        <if test="companyId!=null">
            and company_id=#{companyId}
        </if>
        limit 1
    </select>
 
    <select id="getQuestionByPaperId" resultType="com.gkhy.exam.system.domain.ExQuestion">
        select a.* from ex_question a
        inner join ex_paper_question b on a.id=b.question_id
        where b.paper_id=#{paperId}
        order by a.question_type asc,a.id asc
    </select>
 
    <select id="getPaperStudentInfoByPaperId" resultType="com.gkhy.exam.system.domain.vo.PaperStudentInfoVO">
        select count(1) as student_count,ifnull(sum(passed),0) pass_student_count,ROUND(ifnull(avg(score),0),2) as avg_score,
               (select count(1) from ex_paper_student where paper_id=#{paperId} and state!=0) as finish_count
        from ex_paper_student  where paper_id=#{paperId}
    </select>
 
 
 
 
 
 
 
 
</mapper>