<?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.ztmap.project.zhny.energystoragestatus.mapper.TEnergyStorageStatusMapper">
    
    <resultMap type="TEnergyStorageStatus" id="TEnergyStorageStatusResult">
        <result property="id"    column="id"    />
        <result property="dataTime"    column="data_time"    />
        <result property="faultState"    column="fault_state"    />
        <result property="ssCdl"    column="ss_cdl"    />
        <result property="ssStatus"    column="ss_status"    />
        <result property="jrFd"    column="jr_fd"    />
        <result property="jrfd"    column="jrfd"    />
        <result property="dcwd"    column="dcwd"    />
        <result property="sohCdl"    column="soh_cdl"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectTEnergyStorageStatusVo">
        select id, data_time, fault_state, ss_cdl, ss_status, jr_fd, jrfd, dcwd, soh_cdl, create_time, create_by from t_energy_storage_status
    </sql>

    <select id="selectTEnergyStorageStatusList" parameterType="TEnergyStorageStatus" resultMap="TEnergyStorageStatusResult">
        <include refid="selectTEnergyStorageStatusVo"/>
        <where>  
            <if test="dataTime != null  and dataTime != ''"> and data_time = #{dataTime}</if>
            <if test="faultState != null "> and fault_state = #{faultState}</if>
            <if test="ssCdl != null "> and ss_cdl = #{ssCdl}</if>
            <if test="ssStatus != null  and ssStatus != ''"> and ss_status = #{ssStatus}</if>
            <if test="jrFd != null "> and jr_fd = #{jrFd}</if>
            <if test="jrfd != null "> and jrfd = #{jrfd}</if>
            <if test="dcwd != null "> and dcwd = #{dcwd}</if>
            <if test="sohCdl != null "> and soh_cdl = #{sohCdl}</if>
        </where>
    </select>
    
    <select id="selectTEnergyStorageStatusById" parameterType="Long" resultMap="TEnergyStorageStatusResult">
        <include refid="selectTEnergyStorageStatusVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTEnergyStorageStatus" parameterType="TEnergyStorageStatus" useGeneratedKeys="true" keyProperty="id">
        insert into t_energy_storage_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataTime != null">data_time,</if>
            <if test="faultState != null">fault_state,</if>
            <if test="ssCdl != null">ss_cdl,</if>
            <if test="ssStatus != null">ss_status,</if>
            <if test="jrFd != null">jr_fd,</if>
            <if test="jrfd != null">jrfd,</if>
            <if test="dcwd != null">dcwd,</if>
            <if test="sohCdl != null">soh_cdl,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dataTime != null">#{dataTime},</if>
            <if test="faultState != null">#{faultState},</if>
            <if test="ssCdl != null">#{ssCdl},</if>
            <if test="ssStatus != null">#{ssStatus},</if>
            <if test="jrFd != null">#{jrFd},</if>
            <if test="jrfd != null">#{jrfd},</if>
            <if test="dcwd != null">#{dcwd},</if>
            <if test="sohCdl != null">#{sohCdl},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateTEnergyStorageStatus" parameterType="TEnergyStorageStatus">
        update t_energy_storage_status
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTime != null">data_time = #{dataTime},</if>
            <if test="faultState != null">fault_state = #{faultState},</if>
            <if test="ssCdl != null">ss_cdl = #{ssCdl},</if>
            <if test="ssStatus != null">ss_status = #{ssStatus},</if>
            <if test="jrFd != null">jr_fd = #{jrFd},</if>
            <if test="jrfd != null">jrfd = #{jrfd},</if>
            <if test="dcwd != null">dcwd = #{dcwd},</if>
            <if test="sohCdl != null">soh_cdl = #{sohCdl},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTEnergyStorageStatusById" parameterType="Long">
        delete from t_energy_storage_status where id = #{id}
    </delete>

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

</mapper>