<?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.blocked.mapper.BlockedLuggageStatisticsDailyMapper">
    
    <resultMap type="BlockedLuggageStatisticsDaily" id="BlockedLuggageStatisticsDailyResult">
        <result property="id"    column="id"    />
        <result property="statDate"    column="stat_date"    />
        <result property="shiftType"    column="shift_type"    />
        <result property="brigadeId"    column="brigade_id"    />
        <result property="brigadeName"    column="brigade_name"    />
        <result property="t1TravelLuggageCount"    column="t1_travel_luggage_count"    />
        <result property="t1WalkLuggageCount"    column="t1_walk_luggage_count"    />
        <result property="t2TravelLuggageCount"    column="t2_travel_luggage_count"    />
        <result property="t2WalkLuggageCount"    column="t2_walk_luggage_count"    />
        <result property="t1TravelBlockedCount"    column="t1_travel_blocked_count"    />
        <result property="t2TravelBlockedCount"    column="t2_travel_blocked_count"    />
        <result property="t1WalkBlockedCount"    column="t1_walk_blocked_count"    />
        <result property="t2WalkBlockedCount"    column="t2_walk_blocked_count"    />
        <result property="t1ReviewImageTotal"    column="t1_review_image_total"    />
        <result property="t1AiMarkTotal"    column="t1_ai_mark_total"    />
        <result property="t1AiErrorTotal"    column="t1_ai_error_total"    />
        <result property="t1AiMissTotal"    column="t1_ai_miss_total"    />
        <result property="t2ReviewImageTotal"    column="t2_review_image_total"    />
        <result property="t2AiMarkTotal"    column="t2_ai_mark_total"    />
        <result property="t2AiErrorTotal"    column="t2_ai_error_total"    />
        <result property="t2AiMissTotal"    column="t2_ai_miss_total"    />
        <result property="otherVipCount"    column="other_vip_count"    />
        <result property="t1TravelBlockRate"    column="t1_travel_block_rate"    />
        <result property="t2TravelBlockRate"    column="t2_travel_block_rate"    />
        <result property="t1WalkBlockRate"    column="t1_walk_block_rate"    />
        <result property="t2WalkBlockRate"    column="t2_walk_block_rate"    />
        <result property="totalBlockRate"    column="total_block_rate"    />
        <result property="dailyBlockRate"    column="daily_block_rate"    />
        <result property="totalLuggageCount"    column="total_luggage_count"    />
        <result property="totalBlockedCount"    column="total_blocked_count"    />
        <result property="dailyBlockedCount"    column="daily_blocked_count"    />
        <result property="aiReviewImageTotal"    column="ai_review_image_total"    />
        <result property="aiMarkTotal"    column="ai_mark_total"    />
        <result property="aiErrorImageTotal"    column="ai_error_image_total"    />
        <result property="aiMissImageTotal"    column="ai_miss_image_total"    />
        <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"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectBlockedLuggageStatisticsDailyVo">
        select id, stat_date, shift_type, brigade_id, brigade_name, 
               t1_travel_luggage_count, t1_walk_luggage_count, t2_travel_luggage_count, t2_walk_luggage_count,
               t1_travel_blocked_count, t2_travel_blocked_count, t1_walk_blocked_count, t2_walk_blocked_count,
               t1_review_image_total, t1_ai_mark_total, t1_ai_error_total, t1_ai_miss_total,
               t2_review_image_total, t2_ai_mark_total, t2_ai_error_total, t2_ai_miss_total,
               other_vip_count,
               t1_travel_block_rate, t2_travel_block_rate, t1_walk_block_rate, t2_walk_block_rate,
               total_block_rate, daily_block_rate,
               total_luggage_count, total_blocked_count, daily_blocked_count,
               ai_review_image_total, ai_mark_total, ai_error_image_total, ai_miss_image_total,
               create_by, create_time, update_by, update_time, remark, del_flag
        from blocked_luggage_statistics_daily
    </sql>

    <select id="selectBlockedLuggageStatisticsDailyList" parameterType="BlockedLuggageStatisticsDaily" resultMap="BlockedLuggageStatisticsDailyResult">
        <include refid="selectBlockedLuggageStatisticsDailyVo"/>
        <where>  
            del_flag = '0'
            <if test="statDate != null "> and stat_date = #{statDate}</if>
            <if test="shiftType != null  and shiftType != ''"> and shift_type = #{shiftType}</if>
            <if test="brigadeId != null "> and brigade_id = #{brigadeId}</if>
            <if test="brigadeName != null  and brigadeName != ''"> and brigade_name like concat('%', #{brigadeName}, '%')</if>
        </where>
        order by stat_date desc, shift_type, brigade_id
    </select>
    
    <select id="selectBlockedLuggageStatisticsDailyById" parameterType="Long" resultMap="BlockedLuggageStatisticsDailyResult">
        <include refid="selectBlockedLuggageStatisticsDailyVo"/>
        where id = #{id} and del_flag = '0'
    </select>
        
    <insert id="insertBlockedLuggageStatisticsDaily" parameterType="BlockedLuggageStatisticsDaily" useGeneratedKeys="true" keyProperty="id">
        insert into blocked_luggage_statistics_daily
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="statDate != null">stat_date,</if>
            <if test="shiftType != null and shiftType != ''">shift_type,</if>
            <if test="brigadeId != null">brigade_id,</if>
            <if test="brigadeName != null and brigadeName != ''">brigade_name,</if>
            <if test="t1TravelLuggageCount != null">t1_travel_luggage_count,</if>
            <if test="t1WalkLuggageCount != null">t1_walk_luggage_count,</if>
            <if test="t2TravelLuggageCount != null">t2_travel_luggage_count,</if>
            <if test="t2WalkLuggageCount != null">t2_walk_luggage_count,</if>
            <if test="t1TravelBlockedCount != null">t1_travel_blocked_count,</if>
            <if test="t2TravelBlockedCount != null">t2_travel_blocked_count,</if>
            <if test="t1WalkBlockedCount != null">t1_walk_blocked_count,</if>
            <if test="t2WalkBlockedCount != null">t2_walk_blocked_count,</if>
            <if test="t1ReviewImageTotal != null">t1_review_image_total,</if>
            <if test="t1AiMarkTotal != null">t1_ai_mark_total,</if>
            <if test="t1AiErrorTotal != null">t1_ai_error_total,</if>
            <if test="t1AiMissTotal != null">t1_ai_miss_total,</if>
            <if test="t2ReviewImageTotal != null">t2_review_image_total,</if>
            <if test="t2AiMarkTotal != null">t2_ai_mark_total,</if>
            <if test="t2AiErrorTotal != null">t2_ai_error_total,</if>
            <if test="t2AiMissTotal != null">t2_ai_miss_total,</if>
            <if test="otherVipCount != null">other_vip_count,</if>
            <if test="t1TravelBlockRate != null">t1_travel_block_rate,</if>
            <if test="t2TravelBlockRate != null">t2_travel_block_rate,</if>
            <if test="t1WalkBlockRate != null">t1_walk_block_rate,</if>
            <if test="t2WalkBlockRate != null">t2_walk_block_rate,</if>
            <if test="totalBlockRate != null">total_block_rate,</if>
            <if test="dailyBlockRate != null">daily_block_rate,</if>
            <if test="totalLuggageCount != null">total_luggage_count,</if>
            <if test="totalBlockedCount != null">total_blocked_count,</if>
            <if test="dailyBlockedCount != null">daily_blocked_count,</if>
            <if test="aiReviewImageTotal != null">ai_review_image_total,</if>
            <if test="aiMarkTotal != null">ai_mark_total,</if>
            <if test="aiErrorImageTotal != null">ai_error_image_total,</if>
            <if test="aiMissImageTotal != null">ai_miss_image_total,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="statDate != null">#{statDate},</if>
            <if test="shiftType != null and shiftType != ''">#{shiftType},</if>
            <if test="brigadeId != null">#{brigadeId},</if>
            <if test="brigadeName != null and brigadeName != ''">#{brigadeName},</if>
            <if test="t1TravelLuggageCount != null">#{t1TravelLuggageCount},</if>
            <if test="t1WalkLuggageCount != null">#{t1WalkLuggageCount},</if>
            <if test="t2TravelLuggageCount != null">#{t2TravelLuggageCount},</if>
            <if test="t2WalkLuggageCount != null">#{t2WalkLuggageCount},</if>
            <if test="t1TravelBlockedCount != null">#{t1TravelBlockedCount},</if>
            <if test="t2TravelBlockedCount != null">#{t2TravelBlockedCount},</if>
            <if test="t1WalkBlockedCount != null">#{t1WalkBlockedCount},</if>
            <if test="t2WalkBlockedCount != null">#{t2WalkBlockedCount},</if>
            <if test="t1ReviewImageTotal != null">#{t1ReviewImageTotal},</if>
            <if test="t1AiMarkTotal != null">#{t1AiMarkTotal},</if>
            <if test="t1AiErrorTotal != null">#{t1AiErrorTotal},</if>
            <if test="t1AiMissTotal != null">#{t1AiMissTotal},</if>
            <if test="t2ReviewImageTotal != null">#{t2ReviewImageTotal},</if>
            <if test="t2AiMarkTotal != null">#{t2AiMarkTotal},</if>
            <if test="t2AiErrorTotal != null">#{t2AiErrorTotal},</if>
            <if test="t2AiMissTotal != null">#{t2AiMissTotal},</if>
            <if test="otherVipCount != null">#{otherVipCount},</if>
            <if test="t1TravelBlockRate != null">#{t1TravelBlockRate},</if>
            <if test="t2TravelBlockRate != null">#{t2TravelBlockRate},</if>
            <if test="t1WalkBlockRate != null">#{t1WalkBlockRate},</if>
            <if test="t2WalkBlockRate != null">#{t2WalkBlockRate},</if>
            <if test="totalBlockRate != null">#{totalBlockRate},</if>
            <if test="dailyBlockRate != null">#{dailyBlockRate},</if>
            <if test="totalLuggageCount != null">#{totalLuggageCount},</if>
            <if test="totalBlockedCount != null">#{totalBlockedCount},</if>
            <if test="dailyBlockedCount != null">#{dailyBlockedCount},</if>
            <if test="aiReviewImageTotal != null">#{aiReviewImageTotal},</if>
            <if test="aiMarkTotal != null">#{aiMarkTotal},</if>
            <if test="aiErrorImageTotal != null">#{aiErrorImageTotal},</if>
            <if test="aiMissImageTotal != null">#{aiMissImageTotal},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateBlockedLuggageStatisticsDaily" parameterType="BlockedLuggageStatisticsDaily">
        update blocked_luggage_statistics_daily
        <trim prefix="SET" suffixOverrides=",">
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="shiftType != null and shiftType != ''">shift_type = #{shiftType},</if>
            <if test="brigadeId != null">brigade_id = #{brigadeId},</if>
            <if test="brigadeName != null and brigadeName != ''">brigade_name = #{brigadeName},</if>
            <if test="t1TravelLuggageCount != null">t1_travel_luggage_count = #{t1TravelLuggageCount},</if>
            <if test="t1WalkLuggageCount != null">t1_walk_luggage_count = #{t1WalkLuggageCount},</if>
            <if test="t2TravelLuggageCount != null">t2_travel_luggage_count = #{t2TravelLuggageCount},</if>
            <if test="t2WalkLuggageCount != null">t2_walk_luggage_count = #{t2WalkLuggageCount},</if>
            <if test="t1TravelBlockedCount != null">t1_travel_blocked_count = #{t1TravelBlockedCount},</if>
            <if test="t2TravelBlockedCount != null">t2_travel_blocked_count = #{t2TravelBlockedCount},</if>
            <if test="t1WalkBlockedCount != null">t1_walk_blocked_count = #{t1WalkBlockedCount},</if>
            <if test="t2WalkBlockedCount != null">t2_walk_blocked_count = #{t2WalkBlockedCount},</if>
            <if test="t1ReviewImageTotal != null">t1_review_image_total = #{t1ReviewImageTotal},</if>
            <if test="t1AiMarkTotal != null">t1_ai_mark_total = #{t1AiMarkTotal},</if>
            <if test="t1AiErrorTotal != null">t1_ai_error_total = #{t1AiErrorTotal},</if>
            <if test="t1AiMissTotal != null">t1_ai_miss_total = #{t1AiMissTotal},</if>
            <if test="t2ReviewImageTotal != null">t2_review_image_total = #{t2ReviewImageTotal},</if>
            <if test="t2AiMarkTotal != null">t2_ai_mark_total = #{t2AiMarkTotal},</if>
            <if test="t2AiErrorTotal != null">t2_ai_error_total = #{t2AiErrorTotal},</if>
            <if test="t2AiMissTotal != null">t2_ai_miss_total = #{t2AiMissTotal},</if>
            <if test="otherVipCount != null">other_vip_count = #{otherVipCount},</if>
            <if test="t1TravelBlockRate != null">t1_travel_block_rate = #{t1TravelBlockRate},</if>
            <if test="t2TravelBlockRate != null">t2_travel_block_rate = #{t2TravelBlockRate},</if>
            <if test="t1WalkBlockRate != null">t1_walk_block_rate = #{t1WalkBlockRate},</if>
            <if test="t2WalkBlockRate != null">t2_walk_block_rate = #{t2WalkBlockRate},</if>
            <if test="totalBlockRate != null">total_block_rate = #{totalBlockRate},</if>
            <if test="dailyBlockRate != null">daily_block_rate = #{dailyBlockRate},</if>
            <if test="totalLuggageCount != null">total_luggage_count = #{totalLuggageCount},</if>
            <if test="totalBlockedCount != null">total_blocked_count = #{totalBlockedCount},</if>
            <if test="dailyBlockedCount != null">daily_blocked_count = #{dailyBlockedCount},</if>
            <if test="aiReviewImageTotal != null">ai_review_image_total = #{aiReviewImageTotal},</if>
            <if test="aiMarkTotal != null">ai_mark_total = #{aiMarkTotal},</if>
            <if test="aiErrorImageTotal != null">ai_error_image_total = #{aiErrorImageTotal},</if>
            <if test="aiMissImageTotal != null">ai_miss_image_total = #{aiMissImageTotal},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBlockedLuggageStatisticsDailyById" parameterType="Long">
        update blocked_luggage_statistics_daily set del_flag = '2' where id = #{id}
    </delete>

    <delete id="deleteBlockedLuggageStatisticsDailyByIds" parameterType="String">
        update blocked_luggage_statistics_daily set del_flag = '2' where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
