kongzy
2024-06-26 daf7acb4f107a427e4a83ba1eb26e5e6012cbdaf
exam-system/src/main/resources/mapper/system/SysCompanyMapper.xml
@@ -34,8 +34,11 @@
            <if test="creditCode != null and creditCode != ''">
                AND credit_code like concat('%', #{creditCode}, '%')
            </if>
            <if test="id!=null">
                AND id=#{id}
            </if>
        </where>
        order by create_time desc
        order by id desc
    </select>
    <select id="selectCompanyById" resultMap="SysCompanyResult">
@@ -52,4 +55,101 @@
    <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>
</mapper>