Blame view

src/main/resources/mapping/StudentMapper.xml 5.58 KB
ef5c16a0   陈杰   试卷导入
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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.jevon.mapper.StudentMapper" >
  <resultMap id="BaseResultMap" type="com.jevon.model.Student" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="open_id" property="analyseId" jdbcType="INTEGER" />
    <result column="school_name" property="schoolName" jdbcType="VARCHAR" />
    <result column="class_name" property="className" jdbcType="VARCHAR" />
    <result column="student_name" property="studentName" jdbcType="VARCHAR" />
    <result column="student_number" property="studentNumber" jdbcType="VARCHAR" />
    <result column="analyse_id" property="analyseId" jdbcType="INTEGER" />
    <result column="score" property="score" jdbcType="FLOAT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

e6e6895d   陈杰   学科考试概况
16
    <insert id="insertBatch" parameterType="java.util.List">
ef5c16a0   陈杰   试卷导入
17
18
19
20
21
22
23
    insert into sz_learn_student (school_name, class_name,student_name,
    student_number,analyse_id,score,create_time)
    values
     <foreach collection="list" item="emp" separator=",">
       (#{emp.schoolName},#{emp.className},#{emp.studentName},
       #{emp.studentNumber},#{emp.analyseId},#{emp.score},#{emp.createTime})
     </foreach>
e6e6895d   陈杰   学科考试概况
24
    </insert>
ef5c16a0   陈杰   试卷导入
25

5cba275e   陈杰   个人学情
26
27
28
29
30
    <select id="selectByStudent" parameterType="com.jevon.model.Student"  resultMap="BaseResultMap">
    select * from sz_learn_student where 1=1
    <if test="analyseId != 0">
      and analyse_id = #{analyseId}
    </if>
e6e6895d   陈杰   学科考试概况
31
    <if test="schoolName != null">
a923e3fe   陈杰   四维诊断
32
33
      and school_name = #{schoolName}
    </if>
e6e6895d   陈杰   学科考试概况
34
    <if test="className != null">
a923e3fe   陈杰   四维诊断
35
      and class_name = #{className}
e6e6895d   陈杰   学科考试概况
36
37
    </if>
    order by score desc
a923e3fe   陈杰   四维诊断
38
    </select>
e6e6895d   陈杰   学科考试概况
39
40

    <select id="selectCountByScore" parameterType="com.jevon.model.Student"  resultType="java.lang.Integer">
a923e3fe   陈杰   四维诊断
41
42
43
44
45
46
47
        select count(1) from sz_learn_student where 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
            and school_name = #{schoolName}
        </if>
e6e6895d   陈杰   学科考试概况
48
        <if test="className != null">
a923e3fe   陈杰   四维诊断
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
            and class_name = #{className}
        </if>
        and score <![CDATA[ >= ]]> #{begin} and score <![CDATA[ < ]]> #{end}
    </select>

    <select id="selectClassNameBySchool" parameterType="com.jevon.model.Student" resultType="java.lang.String">
    select DISTINCT(class_name) from sz_learn_student where 1=1
      and analyse_id = #{analyseId}
      and school_name = #{schoolName}
    </select>

    <select id="selectMaxScore" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
        select max(score) from sz_learn_student where 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
            and school_name = #{schoolName}
        </if>
    </select>

    <select id="selectMinScore" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
        select min(score) from sz_learn_student where 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
            and school_name = #{schoolName}
        </if>
e6e6895d   陈杰   学科考试概况
78
79
80
    </select>

    <select id="selectAvgScore" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
a923e3fe   陈杰   四维诊断
81
        select avg(score) from sz_learn_student where 1=1
e6e6895d   陈杰   学科考试概况
82
83
84
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
a923e3fe   陈杰   四维诊断
85
86
87
88
        <if test="schoolName != null">
            and school_name = #{schoolName}
        </if>
    </select>
e6e6895d   陈杰   学科考试概况
89

a923e3fe   陈杰   四维诊断
90
91
92
93
94
95
96
97
    <select id="selectModeNumber" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
        SELECT score FROM sz_learn_student
        WHERE 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
            and school_name = #{schoolName}
5cba275e   陈杰   个人学情
98
99
100
        </if>
        GROUP BY score
        HAVING COUNT ( * ) >= (
a923e3fe   陈杰   四维诊断
101
102
103
104
105
106
107
        SELECT MAX( cnt ) FROM
        (
        SELECT COUNT ( * ) cnt FROM sz_learn_student WHERE 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
e6e6895d   陈杰   学科考试概况
108
109
110
            and school_name = #{schoolName}
        </if>
        GROUP BY score ) tmp
a923e3fe   陈杰   四维诊断
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        )
    </select>

    <select id="selectMedian" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
        SELECT
        avg(DISTINCT score)
        FROM (
        select T1.score from  sz_learn_student T1 , sz_learn_student T2
        WHERE 1=1
        <if test="analyseId != 0">
            and T1.analyse_id = #{analyseId}
        </if>
        <if test="schoolName != null">
            and T1.school_name = #{schoolName}
        </if>
e6e6895d   陈杰   学科考试概况
126
127
128
        <if test="analyseId != 0">
            and T2.analyse_id = #{analyseId}
        </if>
a923e3fe   陈杰   四维诊断
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
        <if test="schoolName != null">
            and T2.school_name = #{schoolName}
        </if>
        GROUP BY
        T1.score
        HAVING
        sum(case when T2.score <![CDATA[ >= ]]> T1.score then 1 else 0 end) >= count(*)/2
        and sum(case when T2.score <![CDATA[ <= ]]> T1.score then 1 else 0 end)>= count(*)/2) tmp
    </select>
    
    <select id="selectStdev" parameterType="com.jevon.model.Student" resultType="java.lang.Double">
            select STDEV(score) from sz_learn_student where 1=1
        <if test="analyseId != 0">
            and analyse_id = #{analyseId}
        </if>
e6e6895d   陈杰   学科考试概况
144
145
146
147
        <if test="schoolName != null">
            and school_name = #{schoolName}
        </if>
    </select>
a923e3fe   陈杰   四维诊断
148
</mapper>
e6e6895d   陈杰   学科考试概况

a923e3fe   陈杰   四维诊断

e6e6895d   陈杰   学科考试概况

ef5c16a0   陈杰   试卷导入

e6e6895d   陈杰   学科考试概况

a923e3fe   陈杰   四维诊断

e6e6895d   陈杰   学科考试概况

a923e3fe   陈杰   四维诊断

e6e6895d   陈杰   学科考试概况

ef5c16a0   陈杰   试卷导入