<?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.yijia.station.mapper.StationClassesSummaryMapper">
    
    <resultMap type="StationClassesSummary" id="StationClassesSummaryResult">
        <result property="id"    column="id"    />
        <result property="classesNo"    column="classes_no"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="stationId"    column="station_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="orderNum"    column="order_num"    />
        <result property="printNum"    column="print_num"    />
        <result property="saleLiters"    column="sale_liters"    />
        <result property="saleAmt"    column="sale_amt"    />
        <result property="wxAmt"    column="wx_amt"    />
        <result property="zfbAmt"    column="zfb_amt"    />
        <result property="dzkAmt"    column="dzk_amt"    />
        <result property="classesMan"    column="classes_man"    />
    </resultMap>

    <sql id="selectStationClassesSummaryVo">
        select id, classes_no, start_date, end_date, station_id, station_name, order_num, print_num, sale_liters, sale_amt, wx_amt, zfb_amt, dzk_amt, classes_man from station_classes_summary
    </sql>

    <select id="selectStationClassesSummaryList" parameterType="StationClassesSummary" resultMap="StationClassesSummaryResult">
        <include refid="selectStationClassesSummaryVo"/>
        <where>  
            <if test="classesNo != null  and classesNo != ''"> and classes_no = #{classesNo}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
            <if test="stationId != null "> and station_id = #{stationId}</if>
            <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
            <if test="orderNum != null "> and order_num = #{orderNum}</if>
            <if test="printNum != null "> and print_num = #{printNum}</if>
            <if test="saleLiters != null  and saleLiters != ''"> and sale_liters = #{saleLiters}</if>
            <if test="saleAmt != null "> and sale_amt = #{saleAmt}</if>
            <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
            <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
            <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
            <if test="classesMan != null  and classesMan != ''"> and classes_man = #{classesMan}</if>
        </where>
    </select>
    
    <select id="selectStationClassesSummaryById" parameterType="Long" resultMap="StationClassesSummaryResult">
        <include refid="selectStationClassesSummaryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertStationClassesSummary" parameterType="StationClassesSummary" useGeneratedKeys="true" keyProperty="id">
        insert into station_classes_summary
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="classesNo != null">classes_no,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="stationId != null">station_id,</if>
            <if test="stationName != null">station_name,</if>
            <if test="orderNum != null">order_num,</if>
            <if test="printNum != null">print_num,</if>
            <if test="saleLiters != null">sale_liters,</if>
            <if test="saleAmt != null">sale_amt,</if>
            <if test="wxAmt != null">wx_amt,</if>
            <if test="zfbAmt != null">zfb_amt,</if>
            <if test="dzkAmt != null">dzk_amt,</if>
            <if test="classesMan != null">classes_man,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="classesNo != null">#{classesNo},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="stationId != null">#{stationId},</if>
            <if test="stationName != null">#{stationName},</if>
            <if test="orderNum != null">#{orderNum},</if>
            <if test="printNum != null">#{printNum},</if>
            <if test="saleLiters != null">#{saleLiters},</if>
            <if test="saleAmt != null">#{saleAmt},</if>
            <if test="wxAmt != null">#{wxAmt},</if>
            <if test="zfbAmt != null">#{zfbAmt},</if>
            <if test="dzkAmt != null">#{dzkAmt},</if>
            <if test="classesMan != null">#{classesMan},</if>
         </trim>
    </insert>

    <update id="updateStationClassesSummary" parameterType="StationClassesSummary">
        update station_classes_summary
        <trim prefix="SET" suffixOverrides=",">
            <if test="classesNo != null">classes_no = #{classesNo},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="stationName != null">station_name = #{stationName},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="printNum != null">print_num = #{printNum},</if>
            <if test="saleLiters != null">sale_liters = #{saleLiters},</if>
            <if test="saleAmt != null">sale_amt = #{saleAmt},</if>
            <if test="wxAmt != null">wx_amt = #{wxAmt},</if>
            <if test="zfbAmt != null">zfb_amt = #{zfbAmt},</if>
            <if test="dzkAmt != null">dzk_amt = #{dzkAmt},</if>
            <if test="classesMan != null">classes_man = #{classesMan},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteStationClassesSummaryById" parameterType="Long">
        delete from station_classes_summary where id = #{id}
    </delete>

    <delete id="deleteStationClassesSummaryByIds" parameterType="String">
        delete from station_classes_summary where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>