<?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.BlockedLuggagePieceDailyMapper">
    
    <resultMap type="BlockedLuggagePieceDaily" id="BlockedLuggagePieceDailyResult">
        <result property="id"    column="id"    />
        <result property="statDate"    column="stat_date"    />
        <result property="brigadeId"    column="brigade_id"    />
        <result property="brigadeName"    column="brigade_name"    />
        <result property="timePeriod"    column="time_period"    />
        <result property="t1WalkBagCount"    column="t1_walk_bag_count"    />
        <result property="t1WalkBlockedCount"    column="t1_walk_blocked_count"    />
        <result property="t2WalkBagCount"    column="t2_walk_bag_count"    />
        <result property="t2WalkBlockedCount"    column="t2_walk_blocked_count"    />
        <result property="t1TravelBagCount"    column="t1_travel_bag_count"    />
        <result property="t1TravelBlockedCount"    column="t1_travel_blocked_count"    />
        <result property="t2TravelBagCount"    column="t2_travel_bag_count"    />
        <result property="t2TravelBlockedCount"    column="t2_travel_blocked_count"    />
        <result property="totalLuggageCount"    column="total_luggage_count"    />
        <result property="totalBlockedCount"    column="total_blocked_count"    />
        <result property="blockedRate"    column="blocked_rate"    />
        <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="selectBlockedLuggagePieceDailyVo">
        select id, stat_date, brigade_id, brigade_name, time_period,
               t1_walk_bag_count, t1_walk_blocked_count, t2_walk_bag_count, t2_walk_blocked_count,
               t1_travel_bag_count, t1_travel_blocked_count, t2_travel_bag_count, t2_travel_blocked_count,
               total_luggage_count, total_blocked_count, blocked_rate,
               create_by, create_time, update_by, update_time, remark, del_flag
        from blocked_luggage_piece_daily
    </sql>

    <select id="selectBlockedLuggagePieceDailyList" parameterType="BlockedLuggagePieceDaily" resultMap="BlockedLuggagePieceDailyResult">
        <include refid="selectBlockedLuggagePieceDailyVo"/>
        <where>  
            del_flag = '0'
            <if test="statDate != null "> and stat_date = #{statDate}</if>
            <if test="brigadeId != null "> and brigade_id = #{brigadeId}</if>
            <if test="brigadeName != null  and brigadeName != ''"> and brigade_name like concat('%', #{brigadeName}, '%')</if>
            <if test="timePeriod != null  and timePeriod != ''"> and time_period = #{timePeriod}</if>
        </where>
        order by stat_date desc, time_period, brigade_id
    </select>
    
    <select id="selectBlockedLuggagePieceDailyById" parameterType="Long" resultMap="BlockedLuggagePieceDailyResult">
        <include refid="selectBlockedLuggagePieceDailyVo"/>
        where id = #{id} and del_flag = '0'
    </select>
        
    <insert id="insertBlockedLuggagePieceDaily" parameterType="BlockedLuggagePieceDaily" useGeneratedKeys="true" keyProperty="id">
        insert into blocked_luggage_piece_daily
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="statDate != null">stat_date,</if>
            <if test="brigadeId != null">brigade_id,</if>
            <if test="brigadeName != null and brigadeName != ''">brigade_name,</if>
            <if test="timePeriod != null and timePeriod != ''">time_period,</if>
            <if test="t1WalkBagCount != null">t1_walk_bag_count,</if>
            <if test="t1WalkBlockedCount != null">t1_walk_blocked_count,</if>
            <if test="t2WalkBagCount != null">t2_walk_bag_count,</if>
            <if test="t2WalkBlockedCount != null">t2_walk_blocked_count,</if>
            <if test="t1TravelBagCount != null">t1_travel_bag_count,</if>
            <if test="t1TravelBlockedCount != null">t1_travel_blocked_count,</if>
            <if test="t2TravelBagCount != null">t2_travel_bag_count,</if>
            <if test="t2TravelBlockedCount != null">t2_travel_blocked_count,</if>
            <if test="totalLuggageCount != null">total_luggage_count,</if>
            <if test="totalBlockedCount != null">total_blocked_count,</if>
            <if test="blockedRate != null">blocked_rate,</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="brigadeId != null">#{brigadeId},</if>
            <if test="brigadeName != null and brigadeName != ''">#{brigadeName},</if>
            <if test="timePeriod != null and timePeriod != ''">#{timePeriod},</if>
            <if test="t1WalkBagCount != null">#{t1WalkBagCount},</if>
            <if test="t1WalkBlockedCount != null">#{t1WalkBlockedCount},</if>
            <if test="t2WalkBagCount != null">#{t2WalkBagCount},</if>
            <if test="t2WalkBlockedCount != null">#{t2WalkBlockedCount},</if>
            <if test="t1TravelBagCount != null">#{t1TravelBagCount},</if>
            <if test="t1TravelBlockedCount != null">#{t1TravelBlockedCount},</if>
            <if test="t2TravelBagCount != null">#{t2TravelBagCount},</if>
            <if test="t2TravelBlockedCount != null">#{t2TravelBlockedCount},</if>
            <if test="totalLuggageCount != null">#{totalLuggageCount},</if>
            <if test="totalBlockedCount != null">#{totalBlockedCount},</if>
            <if test="blockedRate != null">#{blockedRate},</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="updateBlockedLuggagePieceDaily" parameterType="BlockedLuggagePieceDaily">
        update blocked_luggage_piece_daily
        <trim prefix="SET" suffixOverrides=",">
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="brigadeId != null">brigade_id = #{brigadeId},</if>
            <if test="brigadeName != null and brigadeName != ''">brigade_name = #{brigadeName},</if>
            <if test="timePeriod != null and timePeriod != ''">time_period = #{timePeriod},</if>
            <if test="t1WalkBagCount != null">t1_walk_bag_count = #{t1WalkBagCount},</if>
            <if test="t1WalkBlockedCount != null">t1_walk_blocked_count = #{t1WalkBlockedCount},</if>
            <if test="t2WalkBagCount != null">t2_walk_bag_count = #{t2WalkBagCount},</if>
            <if test="t2WalkBlockedCount != null">t2_walk_blocked_count = #{t2WalkBlockedCount},</if>
            <if test="t1TravelBagCount != null">t1_travel_bag_count = #{t1TravelBagCount},</if>
            <if test="t1TravelBlockedCount != null">t1_travel_blocked_count = #{t1TravelBlockedCount},</if>
            <if test="t2TravelBagCount != null">t2_travel_bag_count = #{t2TravelBagCount},</if>
            <if test="t2TravelBlockedCount != null">t2_travel_blocked_count = #{t2TravelBlockedCount},</if>
            <if test="totalLuggageCount != null">total_luggage_count = #{totalLuggageCount},</if>
            <if test="totalBlockedCount != null">total_blocked_count = #{totalBlockedCount},</if>
            <if test="blockedRate != null">blocked_rate = #{blockedRate},</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="deleteBlockedLuggagePieceDailyById" parameterType="Long">
        update blocked_luggage_piece_daily set del_flag = '2' where id = #{id}
    </delete>

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