<?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.evobms.project.bms.mapper.BmsChargeDetailMapper">
    <resultMap type="com.evobms.project.bms.domain.BmsChargeDetail" id="BmsChargeDetailResult">
        <result property="id" column="id"/>
        <result property="deviceId" column="device_id"/>
        <result property="timestamp" column="timestamp"/>
        <result property="acChargeCurrent" column="ac_charge_current"/>
        <result property="acChargeVoltage" column="ac_charge_voltage"/>
        <result property="dcChargeCurrent" column="dc_charge_current"/>
        <result property="dcChargeVoltage" column="dc_charge_voltage"/>
        <result property="chargeTime" column="charge_time"/>
        <result property="acStopCode" column="ac_stop_code"/>
        <result property="dcStopCode" column="dc_stop_code"/>
        <result property="acCpValue" column="ac_cp_value"/>
        <result property="acGunResistance" column="ac_gun_resistance"/>
        <result property="chargingStage" column="charging_stage"/>
        <result property="acStage" column="ac_stage"/>
        <result property="dcStage" column="dc_stage"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <insert id="insertBmsChargeDetail" parameterType="com.evobms.project.bms.domain.BmsChargeDetail" useGeneratedKeys="true" keyProperty="id">
        insert into bms_charge_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceId != null and deviceId != ''">device_id,</if>
            <if test="timestamp != null">`timestamp`,</if>
            <if test="acChargeCurrent != null">ac_charge_current,</if>
            <if test="acChargeVoltage != null">ac_charge_voltage,</if>
            <if test="dcChargeCurrent != null">dc_charge_current,</if>
            <if test="dcChargeVoltage != null">dc_charge_voltage,</if>
            <if test="chargeTime != null">charge_time,</if>
            <if test="acStopCode != null">ac_stop_code,</if>
            <if test="dcStopCode != null">dc_stop_code,</if>
            <if test="acCpValue != null">ac_cp_value,</if>
            <if test="acGunResistance != null">ac_gun_resistance,</if>
            <if test="chargingStage != null">charging_stage,</if>
            <if test="acStage != null">ac_stage,</if>
            <if test="dcStage != null">dc_stage,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
            <if test="timestamp != null">#{timestamp},</if>
            <if test="acChargeCurrent != null">#{acChargeCurrent},</if>
            <if test="acChargeVoltage != null">#{acChargeVoltage},</if>
            <if test="dcChargeCurrent != null">#{dcChargeCurrent},</if>
            <if test="dcChargeVoltage != null">#{dcChargeVoltage},</if>
            <if test="chargeTime != null">#{chargeTime},</if>
            <if test="acStopCode != null">#{acStopCode},</if>
            <if test="dcStopCode != null">#{dcStopCode},</if>
            <if test="acCpValue != null">#{acCpValue},</if>
            <if test="acGunResistance != null">#{acGunResistance},</if>
            <if test="chargingStage != null">#{chargingStage},</if>
            <if test="acStage != null">#{acStage},</if>
            <if test="dcStage != null">#{dcStage},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>
</mapper>
