Blame view

cloud/search_independence/src/main/resources/mapper/StudentMapper.xml 9.81 KB
b7ccb8ad   陈杰   学情 排课 嵌入分布式
1
2
<?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" >
e92e5a92   陶汉栋   增加网关负载
3
4
5
6
7
8
9
10
11
12
13
14
<mapper namespace="com.sincere.independence.mapper.StudentMapper">
    <resultMap id="BaseResultMap" type="com.sincere.independence.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>
b7ccb8ad   陈杰   学情 排课 嵌入分布式
15
16

    <insert id="insertBatch" parameterType="java.util.List">
e92e5a92   陶汉栋   增加网关负载
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>
b7ccb8ad   陈杰   学情 排课 嵌入分布式
24
25
    </insert>

e92e5a92   陶汉栋   增加网关负载
26
27
28
    <select id="selectStudent" parameterType="com.sincere.independence.model.Student" resultMap="BaseResultMap">
        select * from sz_learn_student where analyse_id = #{analyseId} and school_name = #{schoolName}
        and student_number = #{studentNumber}
b7ccb8ad   陈杰   学情 排课 嵌入分布式
29
30
    </select>

e92e5a92   陶汉栋   增加网关负载
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    <select id="selectByStudent" parameterType="com.sincere.independence.model.Student" resultMap="BaseResultMap">
        select * from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="className != null">
                and class_name = #{className}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        order by score desc
b7ccb8ad   陈杰   学情 排课 嵌入分布式
51
52
    </select>

e92e5a92   陶汉栋   增加网关负载
53
54
    <select id="selectCountByScore" parameterType="com.sincere.independence.model.Student"
            resultType="java.lang.Integer">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
        select count(1) from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="className != null">
                and class_name = #{className}
            </if>
            <if test="begin != null">
                and score <![CDATA[ >= ]]> #{begin}
            </if>
            <if test="end != null">
                and score <![CDATA[ < ]]> #{end}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
74
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
75
76
77
78
79
80
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

e92e5a92   陶汉栋   增加网关负载
81
82
83
84
    <select id="selectClassNameBySchool" parameterType="com.sincere.independence.model.Student"
            resultType="java.lang.String">
        select DISTINCT(class_name) from sz_learn_student where analyse_id = #{analyseId}
        and school_name = #{schoolName}
b7ccb8ad   陈杰   学情 排课 嵌入分布式
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    </select>

    <select id="selectSchoolNameByAnalyse" parameterType="java.lang.Integer" resultType="java.lang.String">
        select DISTINCT(school_name) from sz_learn_student where analyse_id = #{analyseId}
    </select>

    <select id="selectMaxScore" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        select max(score) from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="className !=null">
                and class_name = #{className}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
105
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectMinScore" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        select min(score) from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
123
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectAvgScore" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        select avg(score) from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
141
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="selectModeNumber" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        SELECT score FROM sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
159
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
                    #{item}
                </foreach>
            </if>
        </where>
        GROUP BY score
        HAVING COUNT ( * ) >= (
        SELECT MAX( cnt ) FROM
        (
        SELECT COUNT ( * ) cnt FROM sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
178
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
179
180
181
182
183
184
185
186
187
188
189
190
                    #{item}
                </foreach>
            </if>
        </where>
        GROUP BY score ) tmp
        )
    </select>

    <select id="selectMedian" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        SELECT
        avg(DISTINCT score)
        FROM (
e92e5a92   陶汉栋   增加网关负载
191
        select T1.score from sz_learn_student T1 , sz_learn_student T2
b7ccb8ad   陈杰   学情 排课 嵌入分布式
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
        <where>
            <if test="analyseId != 0">
                and T1.analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and T1.school_name = #{schoolName}
            </if>
            <if test="analyseId != 0">
                and T2.analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and T2.school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND T1.school_name IN
e92e5a92   陶汉栋   增加网关负载
207
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
208
209
210
211
212
                    #{item}
                </foreach>
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND T2.school_name IN
e92e5a92   陶汉栋   增加网关负载
213
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
214
215
216
217
218
219
220
221
222
223
                    #{item}
                </foreach>
            </if>
        </where>
        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>
e92e5a92   陶汉栋   增加网关负载
224

b7ccb8ad   陈杰   学情 排课 嵌入分布式
225
226
227
228
229
230
231
232
233
234
235
    <select id="selectStdev" parameterType="com.sincere.independence.model.Student" resultType="java.lang.Double">
        select STDEVP(score) from sz_learn_student
        <where>
            <if test="analyseId != 0">
                and analyse_id = #{analyseId}
            </if>
            <if test="schoolName != null">
                and school_name = #{schoolName}
            </if>
            <if test="schoolNames != null and schoolNames.size()>0">
                AND school_name IN
e92e5a92   陶汉栋   增加网关负载
236
                <foreach item="item" index="index" collection="schoolNames" open="(" close=")" separator=",">
b7ccb8ad   陈杰   学情 排课 嵌入分布式
237
238
239
240
241
242
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
</mapper>