<?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.inspect.metadata.patrolpointmnt.mapper.BasedataStdPatrolPointMapper">

    <resultMap type="BasedataStdPatrolPoint" id="BasedataStdPatrolPointResult">
        <result property="stdPatrolPointId" column="std_patrol_point_id"/>
        <result property="stdPatrolPointName" column="std_patrol_point_name"/>
        <result property="areaId" column="area_id"/>
        <result property="mainDeviceTypeId" column="main_device_type_id"/>
        <result property="componentDeviceTypeId" column="component_device_type_id"/>
        <result property="patrolContent" column="patrol_content"/>
        <result property="patrolType" column="patrol_type"/>
        <result property="pointImptLevel" column="point_impt_level"/>
        <result property="dataFormat" column="data_format"/>
        <result property="algSubtypeId" column="alg_subtype_id"/>
        <result property="alarmThreshold" column="alarm_threshold"/>
        <result property="lowerValue" column="lower_value"/>
        <result property="upperValue" column="upper_value"/>
        <result property="delFlag" column="del_flag"/>
        <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="algSubtypeIds" column="alg_subtype_ids"/>
    </resultMap>

    <sql id="selectBasedataStdPatrolPointVo">
        select std_patrol_point_id,
               std_patrol_point_name,
               area_id,
               main_device_type_id,
               component_device_type_id,
               patrol_content,
               patrol_type,
               point_impt_level,
               data_format,
               alg_subtype_id,
               alarm_threshold,
               lower_value,
               upper_value,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               alg_subtype_ids
        from basedata_stdpatrol_point
    </sql>

    <select id="selectBasedataStdPatrolPointList" parameterType="BasedataStdPatrolPoint"
            resultMap="BasedataStdPatrolPointResult">
        <include refid="selectBasedataStdPatrolPointVo"/>
        <where>
            <if test="stdPatrolPointName != null  and stdPatrolPointName != ''">and std_patrol_point_name like
                concat('%', #{stdPatrolPointName}, '%')
            </if>
            <if test="areaId != null">and area_id = #{areaId}</if>
            <if test="mainDeviceTypeId != null">and main_device_type_id = #{mainDeviceTypeId}</if>
            <if test="componentDeviceTypeId != null">and component_device_type_id = #{componentDeviceTypeId}</if>
            <if test="patrolContent != null  and patrolContent != ''">and patrol_content = #{patrolContent}</if>
            <if test="patrolType != null  and patrolType != ''">and patrol_type = #{patrolType}</if>
            <if test="pointImptLevel != null  and pointImptLevel != ''">and point_impt_level = #{pointImptLevel}</if>
            <if test="dataFormat != null  and dataFormat != ''">and data_format = #{dataFormat}</if>
            <if test="algSubtypeId != null  and algSubtypeId != ''">and alg_subtype_id = #{algSubtypeId}</if>
            <if test="alarmThreshold != null  and alarmThreshold != ''">and alarm_threshold = #{alarmThreshold}</if>
            <if test="lowerValue != null  and lowerValue != ''">and lower_value = #{lowerValue}</if>
            <if test="upperValue != null  and upperValue != ''">and upper_value = #{upperValue}</if>
        </where>
    </select>

    <select id="selectBasedataStdPatrolPointByStdPatrolPointId" parameterType="Long"
            resultMap="BasedataStdPatrolPointResult">
        <include refid="selectBasedataStdPatrolPointVo"/>
        where std_patrol_point_id = #{stdPatrolPointId}
    </select>

    <insert id="insertBasedataStdPatrolPoint" parameterType="BasedataStdPatrolPoint" useGeneratedKeys="true"
            keyProperty="stdPatrolPointId">
        insert into basedata_stdpatrol_point
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stdPatrolPointName != null">std_patrol_point_name,</if>
            <if test="areaId != null">area_id,</if>
            <if test="mainDeviceTypeId != null">main_device_type_id,</if>
            <if test="componentDeviceTypeId != null">component_device_type_id,</if>
            <if test="patrolContent != null">patrol_content,</if>
            <if test="patrolType != null">patrol_type,</if>
            <if test="pointImptLevel != null">point_impt_level,</if>
            <if test="dataFormat != null">data_format,</if>
            <if test="algSubtypeId != null">alg_subtype_id,</if>
            <if test="alarmThreshold != null">alarm_threshold,</if>
            <if test="lowerValue != null">lower_value,</if>
            <if test="upperValue != null">upper_value,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="algSubtypeIds != null">alg_subtype_ids,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stdPatrolPointName != null">#{stdPatrolPointName},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="mainDeviceTypeId != null">#{mainDeviceTypeId},</if>
            <if test="componentDeviceTypeId != null">#{componentDeviceTypeId},</if>
            <if test="patrolContent != null">#{patrolContent},</if>
            <if test="patrolType != null">#{patrolType},</if>
            <if test="pointImptLevel != null">#{pointImptLevel},</if>
            <if test="dataFormat != null">#{dataFormat},</if>
            <if test="algSubtypeId != null">#{algSubtypeId},</if>
            <if test="alarmThreshold != null">#{alarmThreshold},</if>
            <if test="lowerValue != null">#{lowerValue},</if>
            <if test="upperValue != null">#{upperValue},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="algSubtypeIds != null">#{algSubtypeIds},</if>
        </trim>
    </insert>

    <update id="updateBasedataStdPatrolPoint" parameterType="BasedataStdPatrolPoint">
        update basedata_stdpatrol_point
        <trim prefix="SET" suffixOverrides=",">
            <if test="stdPatrolPointName != null">std_patrol_point_name = #{stdPatrolPointName},</if>
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="mainDeviceTypeId != null">main_device_type_id = #{mainDeviceTypeId},</if>
            <if test="componentDeviceTypeId != null">component_device_type_id = #{componentDeviceTypeId},</if>
            <if test="patrolContent != null">patrol_content = #{patrolContent},</if>
            <if test="patrolType != null">patrol_type = #{patrolType},</if>
            <if test="pointImptLevel != null">point_impt_level = #{pointImptLevel},</if>
            <if test="dataFormat != null">data_format = #{dataFormat},</if>
            <if test="algSubtypeId != null">alg_subtype_id = #{algSubtypeId},</if>
            <if test="alarmThreshold != null">alarm_threshold = #{alarmThreshold},</if>
            <if test="lowerValue != null">lower_value = #{lowerValue},</if>
            <if test="upperValue != null">upper_value = #{upperValue},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="algSubtypeIds != null">alg_subtype_ids = #{algSubtypeIds},</if>
        </trim>
        where std_patrol_point_id = #{stdPatrolPointId}
    </update>

    <delete id="deleteBasedataStdPatrolPointByStdPatrolPointId" parameterType="Long">
        delete
        from basedata_stdpatrol_point
        where std_patrol_point_id = #{stdPatrolPointId}
    </delete>

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