“djh”
3 天以前 9bc1958825de5c9427659a8824a9e86864c2a457
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?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.SysCompanyMapper">
    <resultMap type="com.gkhy.exam.system.domain.SysCompany" id="SysCompanyResult">
        <result property="id"       column="id"       />
        <result property="name"    column="name"    />
        <result property="creditCode"     column="credit_code"     />
        <result property="major"  column="major"  />
        <result property="phone"         column="phone"          />
        <result property="delFlag"         column="del_flag"          />
        <result property="remainPeriod"         column="remain_period"          />
        <result property="totalPeriod"         column="total_period"          />
        <result property="version"         column="version"          />
        <result property="createBy"       column="create_by"       />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
    </resultMap>
 
    <sql id="selectCompanyVo">
        select id, name, credit_code, major, phone,remain_period,total_period,version, create_by, create_time, update_by, update_time, remark
        from sys_company
    </sql>
 
    <select id="selectCompanyList" resultMap="SysCompanyResult">
        <include refid="selectCompanyVo"/>
        <where>
            and del_flag=0
            <if test="name != null and name != ''">
                AND name like concat('%', #{name}, '%')
            </if>
            <if test="creditCode != null and creditCode != ''">
                AND credit_code like concat('%', #{creditCode}, '%')
            </if>
            <if test="id!=null">
                AND id=#{id}
            </if>
        </where>
        order by id desc
    </select>
 
    <select id="selectCompanyById" resultMap="SysCompanyResult">
        <include refid="selectCompanyVo"/>
        where id=#{companyId}
    </select>
 
 
    <update id="delCompanyById">
        update sys_company set del_flag=1 where id=#{companyId}
    </update>
 
 
    <select id="checkNameUnique" resultMap="SysCompanyResult">
        select id,name from sys_company where name=#{name} and del_flag=0 limit 1
    </select>
 
    <select id="getOnlineCompanyPhaseCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPhaseVO">
        select count(a.id) as phase_count,a.level,a.company_id from ex_course_phase a
        inner join sys_company b on b.id=a.company_id
        where a.del_flag=0 and b.del_flag=0 and a.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and a.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and a.create_time &lt;= #{endTime}
        </if>
        group by a.company_id,a.level
    </select>
 
    <select id="getOnlineCompanyPhaseStudentCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPhaseStudentVO">
        select count(1) as phase_student_count,b.company_id,b.level from ex_phase_student a
        inner join ex_course_phase b on b.id=a.phase_id
        where b.del_flag=0 and b.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and b.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and b.create_time &lt;= #{endTime}
        </if>
        group by b.company_id,b.level
    </select>
 
    <select id="getOnlineCompanyPaperStudentCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPaperStudentVO">
        select count(a.id) as paper_student_count,sum(a.passed) as pass_student_count,b.company_id from ex_paper_student a
        inner join ex_exam_paper b on b.id=a.paper_id
        where b.del_flag=0 and b.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and b.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and b.create_time &lt;= #{endTime}
        </if>
        group by b.company_id
    </select>
 
    <select id="getOfflineCompanyPhaseCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPhaseVO">
        select count(f.plan_name)as phase_count,f.company_id,f.level  from (
        select a.plan_name,a.company_id,a.level from ex_exam_record a
        inner join sys_company b on b.id=a.company_id
        where b.del_flag=0 and a.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and a.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and a.create_time &lt;= #{endTime}
        </if>
        group by a.company_id,a.level,a.plan_name
        ) as f group by f.company_id,f.level
    </select>
    <select id="getOfflineCompanyPhaseStudentCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPhaseStudentVO">
        select count(1) as phase_student_count,b.company_id,b.level from ex_exam_record a
        inner join sys_company b on b.id=a.company_id
        where b.del_flag=0 and a.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and a.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and a.create_time &lt;= #{endTime}
        </if>
        group by a.company_id,a.level
    </select>
 
    <select id="getOfflineCompanyPaperStudentCount" resultType="com.gkhy.exam.system.domain.vo.CompanyPaperStudentVO">
        select count(a.id) as paper_student_count,sum(a.passed) as pass_student_count,a.company_id from ex_exam_record a
        inner join sys_company b on b.id=a.paper_id
        where b.del_flag=0 and score is not null and a.company_id in
        <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
            #{companyId}
        </foreach>
        <if test="startTime!=null and startTime!=''">
            and a.create_time &gt;= #{startTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and a.create_time &lt;= #{endTime}
        </if>
        group by a.company_id
    </select>
    <select id="selectCompanyListS" resultType="com.gkhy.exam.system.domain.SysCompany">
        select id, name, credit_code, major, phone,remain_period,total_period,version, create_by, create_time, update_by, update_time, remark
        from sys_company where  del_flag = 0
    </select>
</mapper>