<?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.exec.mapper.DBPatrolPointMapper">

    <resultMap type="DBPatrolPoint" id="DBPatrolPointResult">
        <result property="patrolPointId" column="patrol_point_id"/>
        <result property="patrolPointCode" column="patrol_point_code"/>
        <result property="patrolPointName" column="patrol_point_name"/>
        <result property="deviceTypeId" column="device_type_id"/>
        <result property="mainDeviceId" column="main_device_id"/>
        <result property="deviceId" column="device_id"/>
        <result property="patrolContent" column="patrol_content"/>
        <result property="purpose" column="purpose"/>
        <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="deleteFlag" column="delete_flag"/>
        <result property="stdParolPointId" column="std_parol_point_id"/>
        <result property="areaId" column="area_id"/>
        <result property="pointImptLevel" column="point_impt_level"/>
        <result property="patrolTypeId" column="patrol_type_id"/>
        <result property="alarmThreshold" column="alarm_threshold"/>
        <result property="algSubtypeId" column="alg_subtype_id"/>
        <result property="algSubtypeName" column="alg_subtype_name"/>
        <result property="lowerValue" column="lower_value"/>
        <result property="upperValue" column="upper_value"/>
        <result property="positionX" column="position_x"/>
        <result property="positionY" column="position_y"/>
        <result property="positionZ" column="position_z"/>
        <result property="algSubtypeIds" column="alg_subtype_ids"/>
        <result property="originalAlgSubtypeIds" column="original_alg_subtype_ids"/>
        <result property="originalDeviceId" column="original_device_id"/>
        <result property="disRefPicturePath" column="dis_ref_picture_path"/>
        <result property="originalMainDeviceId" column="original_main_device_id"/>
    </resultMap>

    <sql id="selectBasedataPatrolPointVo">
        select patrol_point_id,
               patrol_point_code,
               patrol_point_name,
               device_type_id,
               main_device_id,
               device_id,
               area_id,
               patrol_content,
               purpose,
               create_by,
               create_time,
               update_by,
               update_time,
               delete_flag,
               std_parol_point_id,
               point_impt_level,
               patrol_type_id,
               lower_value,
               upper_value,
               position_x,
               position_y,
               position_z,
               alg_subtype_ids,
               original_alg_subtype_ids,
               original_device_id,
               dis_ref_picture_path,
               original_main_device_id,
               alarm_threshold
        from basedata_patrolpoint
    </sql>

    <select id="selectBasedataPatrolPointList" parameterType="DBPatrolPoint" resultMap="DBPatrolPointResult">
        <include refid="selectBasedataPatrolPointVo"/>
        <where>
            <if test="patrolPointCode != null  and patrolPointCode != ''">and patrol_point_code = #{patrolPointCode}
            </if>
            <if test="patrolPointName != null  and patrolPointName != ''">and patrol_point_name like concat('%',
                #{patrolPointName}, '%')
            </if>
            <if test="deviceTypeId != null ">and device_type_id = #{deviceTypeId}</if>
            <if test="mainDeviceId != null ">and main_device_id = #{mainDeviceId}</if>
            <if test="deviceId != null ">and device_id = #{deviceId}</if>
            <if test="areaId != null ">and area_id = #{areaId}</if>
            <if test="patrolContent != null  and patrolContent != ''">and patrol_content = #{patrolContent}</if>
            <if test="purpose != null  and purpose != ''">and purpose = #{purpose}</if>
            <if test="deleteFlag != null  and deleteFlag != ''">and delete_flag = #{deleteFlag}</if>
            <if test="stdParolPointId != null ">and std_parol_point_id = #{stdParolPointId}</if>
            <if test="pointImptLevel != null  and pointImptLevel != ''">and point_impt_level = #{pointImptLevel}</if>
            <if test="patrolTypeId != null  and patrolTypeId != ''">and patrol_type_id = #{patrolTypeId}</if>
            <if test="lowerValue != null  and lowerValue != ''">and lower_value = #{lowerValue}</if>
            <if test="upperValue != null  and upperValue != ''">and upper_value = #{upperValue}</if>
            <if test="positionX != null  and positionX != ''">and position_x = #{positionX}</if>
            <if test="positionY != null  and positionY != ''">and position_y = #{positionY}</if>
            <if test="positionZ != null  and positionZ != ''">and position_z = #{positionZ}</if>
            <if test="algSubtypeIds != null  and algSubtypeIds != ''">and alg_subtype_ids = #{algSubtypeIds}</if>
            <if test="originalAlgSubtypeIds != null  and originalAlgSubtypeIds != ''">and original_alg_subtype_ids =
                #{originalAlgSubtypeIds}
            </if>
            <if test="originalDeviceId != null  and originalDeviceId != ''">and original_device_id =
                #{originalDeviceId}
            </if>
            <if test="disRefPicturePath != null  and disRefPicturePath != ''">and dis_ref_picture_path =
                #{disRefPicturePath}
            </if>
            <if test="originalMainDeviceId != null  and originalMainDeviceId != ''">and original_main_device_id =
                #{originalMainDeviceId}
            </if>
            <if test="alarmThreshold != null  and alarmThreshold != ''">and alarm_threshold = #{alarmThreshold}</if>
        </where>
    </select>

    <select id="selectBasedataPatrolPointByPatrolPointId" parameterType="Long" resultMap="DBPatrolPointResult">
        <include refid="selectBasedataPatrolPointVo"/>
        where patrol_point_id = #{patrolPointId}
    </select>
</mapper>