<?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.meas.system.mapper.MeasThermalImagerTestDataMapper">

    <resultMap type="MeasThermalImagerTestData" id="MeasThermalImagerTestDataResult">
        <result property="id" column="id"/>
        <result property="measurementBatchId" column="measurement_batch_id"/>
        <result property="engineModel" column="engine_model"/>
        <result property="geometryFiles" column="geometry_files"/>
        <result property="geometryImage" column="geometry_image"/>
        <result property="measurementBatch" column="measurement_batch"/>
        <result property="engineStatus" column="engine_status"/>
        <result property="angle" column="angle"/>
        <result property="model" column="model"/>
        <result property="lensFView" column="lens_f_view"/>
        <result property="filterNo" column="filter_no"/>
        <result property="fps" column="fps"/>
        <result property="spectralBand" column="spectral_band"/>
        <result property="integrationTime" column="integration_time"/>
        <result property="tempCal" column="temp_cal"/>
        <result property="radiance" column="radiance"/>
        <result property="radIllumination" column="rad_illumination"/>
        <result property="radTemp" column="rad_temp"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectMeasThermalImagerTestDataVo">
        SELECT
            mtitd.id,
            med.id measurement_batch_id,
            mem.model engine_model,
            mem.geometry_files,
            mem.geometry_image,
            mb.measurement_batch,
            med.engine_status,
            med.angle,
            mtitd.model,
            mtitd.lens_f_view,
            mtitd.filter_no,
            mtitd.fps,
            mtitd.spectral_band,
            mtitd.integration_time,
            mtitd.temp_cal,
            mtitd.radiance,
            mtitd.rad_illumination,
            mtitd.rad_temp,
            mtitd.create_by,
            mtitd.create_time,
            mtitd.update_by,
            mtitd.update_time
        FROM
            meas_env_data med
        LEFT JOIN meas_thermal_imager_test_data mtitd ON mtitd.measurement_batch_id = med.id
        LEFT JOIN meas_batch mb ON med.measurement_batch_id = mb.id
        LEFT JOIN meas_engine_model mem ON mb.engine_id = mem.id
    </sql>

    <select id="selectMeasThermalImagerTestDataList" parameterType="MeasThermalImagerTestData"
            resultMap="MeasThermalImagerTestDataResult">
        <include refid="selectMeasThermalImagerTestDataVo"/>
        <where>
            <if test="measurementBatchId != null ">and measurement_batch_id = #{measurementBatchId}</if>
            <if test="measurementBatch != null  and measurementBatch != ''">and mb.measurement_batch = #{measurementBatch}</if>
            <if test="engineModel != null  and engineModel != ''">and mem.model =
                #{engineModel}
            </if>
            <if test="engineStatus != null and engineStatus != ''">and med.engine_status = #{engineStatus}</if>
            <if test="angle != null  and angle != ''">and med.angle = #{angle}</if>
            <if test="model != null  and model != ''">and mtitd.model = #{model}</if>
            <if test="lensFView != null  and lensFView != ''">and lens_f_view = #{lensFView}</if>
            <if test="filterNo != null  and filterNo != ''">and filter_no = #{filterNo}</if>
            <if test="fps != null  and fps != ''">and fps = #{fps}</if>
            <if test="spectralBand != null  and spectralBand != ''">and spectral_band = #{spectralBand}</if>
            <if test="integrationTime != null ">and integration_time = #{integrationTime}</if>
            <if test="tempCal != null  and tempCal != ''">and temp_cal = #{tempCal}</if>
            <if test="radiance != null  and radiance != ''">and radiance = #{radiance}</if>
            <if test="radIllumination != null  and radIllumination != ''">and rad_illumination = #{radIllumination}</if>
            <if test="radTemp != null  and radTemp != ''">and rad_temp = #{radTemp}</if>
        </where>
    </select>

    <select id="selectMeasThermalImagerTestDataById" parameterType="Long" resultMap="MeasThermalImagerTestDataResult">
        <include refid="selectMeasThermalImagerTestDataVo"/>
        where mtitd.id = #{id}
    </select>

    <insert id="insertMeasThermalImagerTestData" parameterType="MeasThermalImagerTestData" useGeneratedKeys="true" keyProperty="id">
        insert into meas_thermal_imager_test_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="measurementBatchId != null">measurement_batch_id,</if>
            <if test="model != null">model,</if>
            <if test="lensFView != null">lens_f_view,</if>
            <if test="filterNo != null">filter_no,</if>
            <if test="fps != null">fps,</if>
            <if test="spectralBand != null">spectral_band,</if>
            <if test="integrationTime != null">integration_time,</if>
            <if test="tempCal != null">temp_cal,</if>
            <if test="radiance != null">radiance,</if>
            <if test="radIllumination != null">rad_illumination,</if>
            <if test="radTemp != null">rad_temp,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="measurementBatchId != null">#{measurementBatchId},</if>
            <if test="model != null">#{model},</if>
            <if test="lensFView != null">#{lensFView},</if>
            <if test="filterNo != null">#{filterNo},</if>
            <if test="fps != null">#{fps},</if>
            <if test="spectralBand != null">#{spectralBand},</if>
            <if test="integrationTime != null">#{integrationTime},</if>
            <if test="tempCal != null">#{tempCal},</if>
            <if test="radiance != null">#{radiance},</if>
            <if test="radIllumination != null">#{radIllumination},</if>
            <if test="radTemp != null">#{radTemp},</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>
        </trim>
    </insert>

    <update id="updateMeasThermalImagerTestData" parameterType="MeasThermalImagerTestData">
        update meas_thermal_imager_test_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="measurementBatchId != null">measurement_batch_id = #{measurementBatchId},</if>
            <if test="model != null">model = #{model},</if>
            <if test="lensFView != null">lens_f_view = #{lensFView},</if>
            <if test="filterNo != null">filter_no = #{filterNo},</if>
            <if test="fps != null">fps = #{fps},</if>
            <if test="spectralBand != null">spectral_band = #{spectralBand},</if>
            <if test="integrationTime != null">integration_time = #{integrationTime},</if>
            <if test="tempCal != null">temp_cal = #{tempCal},</if>
            <if test="radiance != null">radiance = #{radiance},</if>
            <if test="radIllumination != null">rad_illumination = #{radIllumination},</if>
            <if test="radTemp != null">rad_temp = #{radTemp},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMeasThermalImagerTestDataById" parameterType="Long">
        delete from meas_thermal_imager_test_data where id = #{id}
    </delete>

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

    <select id="selectResultsByEnvDataId" parameterType="Long" resultMap="MeasThermalImagerTestDataResult">
        <include refid="selectMeasThermalImagerTestDataVo"/>
        where med.id = #{id}
    </select>
</mapper>