<?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.ho.business.mapper.MaintenanceDataMapper">

    <resultMap id="BaseResultMap" type="com.ho.business.entity.MaintenanceData">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="stationId" column="station_id" jdbcType="INTEGER"/>
        <result property="alarmStatus" column="alarm_status" jdbcType="INTEGER"/>
        <result property="alarmNum" column="alarm_num" jdbcType="VARCHAR"/>
        <result property="alarmUnresolvedNum" column="alarm_unresolved_num" jdbcType="VARCHAR"/>
        <result property="pcsConversion" column="pcs_conversion" jdbcType="VARCHAR"/>
        <result property="time" column="time" jdbcType="VARCHAR"/>
        <result property="totalCharge" column="total_charge" jdbcType="DECIMAL"/>
        <result property="totalDischarge" column="total_discharge" jdbcType="DECIMAL"/>
        <result property="minTemperature" column="min_temperature" jdbcType="DECIMAL"/>
        <result property="maxTemperature" column="max_temperature" jdbcType="DECIMAL"/>
        <result property="pcsMaxTemperature" column="pcs_max_temperature" jdbcType="VARCHAR"/>
        <result property="cpuUseProportion" column="cpu_use_proportion" jdbcType="DECIMAL"/>
        <result property="memUseProportion" column="mem_use_proportion" jdbcType="DECIMAL"/>
        <result property="hardUseProportion" column="hard_use_proportion" jdbcType="DECIMAL"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,station_id,alarm_status,
        alarm_num,alarm_unresolved_num,pcs_conversion,
        `time`,total_charge,total_discharge,
        min_temperature,max_temperature,pcs_max_temperature,
        cpu_use_proportion,mem_use_proportion,hard_use_proportion,
        create_time
    </sql>

    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.MaintenanceData"
            useGeneratedKeys="true">
        insert into maintenance_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stationId != null">station_id,</if>
            <if test="alarmStatus != null">alarm_status,</if>
            <if test="alarmNum != null">alarm_num,</if>
            <if test="alarmUnresolvedNum != null">alarm_unresolved_num,</if>
            <if test="pcsConversion != null">pcs_conversion,</if>
            <if test="time != null">`time`,</if>
            <if test="totalCharge != null">total_charge,</if>
            <if test="totalDischarge != null">total_discharge,</if>
            <if test="minTemperature != null">min_temperature,</if>
            <if test="maxTemperature != null">max_temperature,</if>
            <if test="pcsMaxTemperature != null">pcs_max_temperature,</if>
            <if test="cpuUseProportion != null">cpu_use_proportion,</if>
            <if test="memUseProportion != null">mem_use_proportion,</if>
            <if test="hardUseProportion != null">hard_use_proportion,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="stationId != null">#{stationId},</if>
            <if test="alarmStatus != null">#{alarmStatus},</if>
            <if test="alarmNum != null">#{alarmNum},</if>
            <if test="alarmUnresolvedNum != null">#{alarmUnresolvedNum},</if>
            <if test="pcsConversion != null">#{pcsConversion},</if>
            <if test="time != null">#{time},</if>
            <if test="totalCharge != null">#{totalCharge},</if>
            <if test="totalDischarge != null">#{totalDischarge},</if>
            <if test="minTemperature != null">#{minTemperature},</if>
            <if test="maxTemperature != null">#{maxTemperature},</if>
            <if test="pcsMaxTemperature != null">#{pcsMaxTemperature},</if>
            <if test="cpuUseProportion != null">#{cpuUseProportion},</if>
            <if test="memUseProportion != null">#{memUseProportion},</if>
            <if test="hardUseProportion != null">#{hardUseProportion},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <select id="selectByParam" resultType="com.ho.business.entity.MaintenanceData">
        SELECT
        <include refid="Base_Column_List"/>
        FROM maintenance_data
        <where>
            <if test="stationId != null">and station_id = #{stationId}</if>
            <if test="alarmStatus != null">and alarm_status = #{alarmStatus}</if>
        </where>
    </select>

    <delete id="deleteByList">
        delete
        from maintenance_data
        <where>
            <if test="ids != null and ids.size() != 0">
                and id in
                <foreach collection="ids" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </delete>
</mapper>
