<?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.sundot.airport.item.mapper.ItemLargeScreenMapper">

    <!--查获总数-->
    <select id="getTotalSum" resultType="java.math.BigDecimal">
        select ifnull(sum(isi.quantity), 0) totalSum
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice == '1' or isPolice == 1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal == 1">and isi.is_active_concealment = 1</if>
    </select>

    <!--移交公安情况-->
    <select id="police" resultType="com.sundot.airport.item.domain.ItemLargeScreenInfoDto">
        select isr.id mId,
        isi.id dId,
        isr.inspect_user_id inspectUserId,
        isr.inspect_user_name inspectUserName,
        isr.seizure_time seizureTime,
        isr.terminl_code terminlCode,
        isr.terminl_name terminlName,
        isr.regional_code regionalCode,
        isr.regional_name regionalName,
        isr.channel_code channelCode,
        isr.channel_name channelName,
        isr.check_method checkMethod,
        isr.check_method_desc checkMethodDesc,
        isi.category_code_one categoryCodeOne,
        isi.category_name_one categoryNameOne,
        isi.category_code_two categoryCodeTwo,
        isi.category_name_two categoryNameTwo,
        isi.item_code itemCode,
        isi.item_name itemName,
        isi.quantity quantity,
        isi.unit unit,
        isi.unit_desc unitDesc,
        isi.handling_method handlingMethod,
        isi.handling_method_desc handlingMethodDesc,
        isi.is_active_concealment isActiveConcealment,
        isi.check_position_code_one checkPositionCodeOne,
        isi.check_position_name_one checkPositionNameOne,
        isi.check_position_code_two checkPositionCodeOne,
        isi.check_position_name_two checkPositionNameTwo,
        isi.check_position_specific checkPositionSpecific,
        su.nick_name nackName
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        left join sys_user su on isr.inspect_user_id = su.user_id
        where 1 = 1
        and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        and isr.process_status=3
        order by isr.seizure_time desc
    </select>

    <!--故意隐匿情况-->
    <select id="conceal" resultType="com.sundot.airport.item.domain.ItemLargeScreenInfoDto">
        select isr.id mId,
        isi.id dId,
        isr.inspect_user_id inspectUserId,
        isr.inspect_user_name inspectUserName,
        isr.seizure_time seizureTime,
        isr.terminl_code terminlCode,
        isr.terminl_name terminlName,
        isr.regional_code regionalCode,
        isr.regional_name regionalName,
        isr.channel_code channelCode,
        isr.channel_name channelName,
        isr.check_method checkMethod,
        isr.check_method_desc checkMethodDesc,
        isi.category_code_one categoryCodeOne,
        isi.category_name_one categoryNameOne,
        isi.category_code_two categoryCodeTwo,
        isi.category_name_two categoryNameTwo,
        isi.item_code itemCode,
        isi.item_name itemName,
        isi.quantity quantity,
        isi.unit unit,
        isi.unit_desc unitDesc,
        isi.handling_method handlingMethod,
        isi.handling_method_desc handlingMethodDesc,
        isi.is_active_concealment isActiveConcealment,
        isi.check_position_code_one checkPositionCodeOne,
        isi.check_position_name_one checkPositionNameOne,
        isi.check_position_code_two checkPositionCodeOne,
        isi.check_position_name_two checkPositionNameTwo,
        isi.check_position_specific checkPositionSpecific
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where 1 = 1
        and isi.is_active_concealment = 1
        and isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        order by isr.seizure_time desc
    </select>

    <!--查获类别分布-->
    <select id="category" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select
        <!--判断参数里的级别类型，根据级别类型，查询对应级别-->
        <if test="levelType == 1">
            isi.category_code_one code,
            isi.category_name_one name,
            sum(isi.quantity) total
        </if>
        <if test="levelType == 2">
            isi.category_code_two code,
            isi.category_name_two name,
            sum(isi.quantity) total
        </if>
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="levelType == 2  and categoryCode != null and  categoryCode != ''">
            and isi.category_code_one = #{categoryCode}
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice=='1' or isPolice==1">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1">and isi.is_active_concealment = 1</if>
        group by
        <if test="levelType == 1">
            isi.category_code_one,
            isi.category_name_one
        </if>
        <if test="levelType == 2">
            isi.category_code_two,
            isi.category_name_two
        </if>
        order by total desc
    </select>

    <!--查获岗位分布-->
    <select id="post" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select isr.check_method code,
        isr.check_method_desc name,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice=='1' or isPolice==1">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1">and isi.is_active_concealment = 1</if>
        group by isr.check_method,
        isr.check_method_desc
        order by total desc
    </select>

    <!--查获总数量+移交公安数量+故意隐匿数量-->
    <select id="getTotalSome" resultType="com.sundot.airport.item.domain.ItemLargeScreenTotalSomeDto">
        select ifnull(sum(isi.quantity), 0) total,
        ifnull(sum(case when isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE' then isi.quantity else 0 end),
        0) as policeTotal,
        ifnull(sum(case when isi.is_active_concealment = 1 then isi.quantity else 0 end), 0) as concealTotal
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.attendance_team_id = #{inspectTeamId}</if>
    </select>

    <!--查获排名-按大队-->
    <select id="rankByBrigade" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select isr.inspect_brigade_id id,
        isr.inspect_brigade_name name,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="categoryCodeOne != null and  categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and  categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="isPolice=='1' or isPolice==1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1 ">and isi.is_active_concealment = 1</if>
        group by isr.inspect_brigade_id,
        isr.inspect_brigade_name
        order by total desc
    </select>

    <!--查获排名-按科室-->
    <select id="rankByDepartment" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select isr.inspect_department_id id,
        isr.inspect_department_name name,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="categoryCodeOne != null and  categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and  categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="isPolice=='1' or isPolice==1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1 ">and isi.is_active_concealment = 1</if>
        group by isr.inspect_department_id,
        isr.inspect_department_name
        order by total desc
    </select>

    <!--查获排名-按班组-->
    <select id="rankByTeam" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select isr.attendance_team_id id,
        isr.attendance_team_name name,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="categoryCodeOne != null and  categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and  categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="isPolice=='1' or isPolice==1">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or  isConceal==1">and isi.is_active_concealment = 1</if>
        group by isr.attendance_team_id,
        isr.attendance_team_name
        order by total desc
    </select>

    <!--查获排名-按个人-->
    <select id="rankByIndividual" resultType="com.sundot.airport.item.domain.ItemLargeScreenCommonDto">
        select isr.inspect_user_id id,
        isr.inspect_user_name name,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="categoryCodeOne != null and  categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and  categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="isPolice=='1' or isPolice==1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1 ">and isi.is_active_concealment = 1</if>
        group by isr.inspect_user_id,
        isr.inspect_user_name
        order by total desc
    </select>

    <!--查获时段分布-->
    <select id="timeSpan" resultType="com.sundot.airport.item.domain.ItemLargeScreenTimeSpanDto">
        select hours.hour as hourOfDay,
        ifnull(sum(isi.quantity), 0) as total
        from (select 0 as hour
        union
        select 1
        union
        select 2
        union
        select 3
        union
        select 4
        union
        select 5
        union
        select 6
        union
        select 7
        union
        select 8
        union
        select 9
        union
        select 10
        union
        select 11
        union
        select 12
        union
        select 13
        union
        select 14
        union
        select 15
        union
        select 16
        union
        select 17
        union
        select 18
        union
        select 19
        union
        select 20
        union
        select 21
        union
        select 22
        union
        select 23) as hours
        left join item_seizure_record isr
        on hours.hour = hour (isr.seizure_time)
        <if test="specifiedDate != null and specifiedDate != null">
            and date (isr.seizure_time) = #{specifiedDate}
        </if>
        left join item_seizure_items isi
        on isr.id = isi.record_id
        where isr.process_status=3
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="categoryCodeOne != null and  categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and  categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice=='1' or isPolice==1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or  isConceal==1 ">and isi.is_active_concealment = 1</if>
        group by hours.hour
        order by hours.hour
    </select>

    <!--按天统计趋势数据-->
    <select id="dailyTrend" resultType="com.sundot.airport.item.domain.ItemLargeScreenDailyTrendDto">
        select DATE(isr.seizure_time) as date,
        ifnull(sum(isi.quantity), 0) as total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status = 3
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="categoryCodeOne != null and categoryCodeOne != ''">
            and isi.category_code_one = #{categoryCodeOne}
        </if>
        <if test="categoryCodeTwo != null and categoryCodeTwo != ''">
            and isi.category_code_two = #{categoryCodeTwo}
        </if>
        <if test="isPolice=='1' or isPolice==1 ">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1 ">and isi.is_active_concealment = 1</if>
        group by DATE(isr.seizure_time)
        order by date
    </select>

    <!--查获位置分布-->
    <select id="position" resultType="com.sundot.airport.item.domain.ItemLargeScreenPositionDto">
        select isi.check_position_code_one checkPositionCodeOne,
        isi.check_position_name_one checkPositionNameOne,
        isi.check_position_code_two checkPositionCodeTwo,
        isi.check_position_name_two checkPositionNameTwo,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice=='1' or isPolice==1">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1">and isi.is_active_concealment = 1</if>
        group by isi.check_position_code_one,
        isi.check_position_name_one,
        isi.check_position_code_two,
        isi.check_position_name_two
        order by checkPositionCodeOne, checkPositionCodeTwo, total desc
    </select>

    <!--查获通道分布-->
    <select id="channel" resultType="com.sundot.airport.item.domain.ItemLargeScreenChannelDto">
        select isr.regional_code channelCode,
        isr.regional_name channelName,
        isi.category_code_one categoryCode,
        isi.category_name_one categoryName,
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        group by isr.regional_code,
        isr.regional_name,
        isi.category_code_one,
        isi.category_name_one
        order by channelCode, categoryCode, total desc
    </select>

    <select id="appPosition" resultType="com.sundot.airport.item.domain.ItemLargeScreenPositionAppDto">
        select
        <if test="levelType == 1">
            isi.check_position_code_one code,
            isi.check_position_name_one name,
        </if>
        <if test="levelType == 2">
            isi.check_position_code_two code,
            isi.check_position_name_two name,
        </if>
        sum(isi.quantity) total
        from item_seizure_record isr
        left join item_seizure_items isi on isr.id = isi.record_id
        where isr.process_status=3
        <if test="specifiedDate != null">and date(isr.seizure_time) = #{specifiedDate}</if>
        <if test="startDate != null and endDate != null">
            and (isr.seizure_time >= #{startDate}
            and isr.seizure_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day))
        </if>
        <if test="inspectBrigadeId != null">and isr.inspect_brigade_id = #{inspectBrigadeId}</if>
        <if test="inspectDepartmentId != null">and isr.inspect_department_id = #{inspectDepartmentId}</if>
        <if test="inspectTeamId != null">and isr.inspect_team_id = #{inspectTeamId}</if>
        <if test="isPolice=='1' or isPolice==1">and isi.handling_method = 'TRANSFER_TO_AIRPORT_POLICE'</if>
        <if test="isConceal=='1' or isConceal==1">and isi.is_active_concealment = 1</if>
        <if test="levelType == 2 and positionCode!=null and positionCode!=''">and isi.check_position_code_one =
            #{positionCode}
        </if>
        group by
        <if test="levelType == 1">
            isi.check_position_code_one,
            isi.check_position_name_one
        </if>
        <if test="levelType == 2">
            isi.check_position_code_two,
            isi.check_position_name_two
        </if>
        order by total desc
    </select>

</mapper>