<?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.fidms.web.mapper.FlowFieldInputMapper">
    
    <resultMap type="FlowFieldInput" id="FlowFieldInputResult">
        <result property="id"    column="id"    />
        <result property="model3dId"    column="model_3d_id"    />
        <result property="machNumber"    column="mach_number"    />
        <result property="flowDirectionX" column="flow_direction_x"/>
        <result property="flowDirectionY" column="flow_direction_y"/>
        <result property="flowDirectionZ" column="flow_direction_z"/>
        <result property="flowVelocityX"    column="flow_velocity_x"    />
        <result property="flowVelocityY"    column="flow_velocity_y"    />
        <result property="flowVelocityZ"    column="flow_velocity_z"    />
        <result property="infraredBand" column="infrared_band" />
        <result property="flowTemperature" column="flow_temperature" />
        <result property="flowPressure"    column="flow_pressure"    />
        <result property="flowDensity"    column="flow_density"    />
        <result property="flightAltitude" column="flight_altitude"/>
        <result property="co2MassFraction"    column="co2_mass_fraction"    />
        <result property="coMassFraction"    column="co_mass_fraction"    />
        <result property="h2oMassFraction"    column="h2o_mass_fraction"    />
        <result property="fluentGridFile"    column="fluent_grid_file"    />
        <result property="fluentGridFilePath"    column="fluent_grid_file_path"    />
        <result property="fluentCasFile"    column="fluent_cas_file"    />
        <result property="fluentCasFilePath"    column="fluent_cas_file_path"    />
        <result property="fluentDatFile"    column="fluent_dat_file"    />
        <result property="fluentDatFilePath"    column="fluent_dat_file_path"    />
        <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="selectFlowFieldInputVo">
        SELECT
            ffi.id,
            ffi.model_3d_id,
            m3.`name` model3dName,
            ffi.mach_number,
            ffi.flow_velocity_x,
            ffi.flow_velocity_y,
            ffi.flow_velocity_z,
            ffi.flow_direction_x,
            ffi.flow_direction_y,
            ffi.flow_direction_z,
            ffi.infrared_band,
            ffi.flow_temperature,
            ffi.flow_pressure,
            ffi.flow_density,
            ffi.flight_altitude,
            ffi.co2_mass_fraction,
            ffi.co_mass_fraction,
            ffi.h2o_mass_fraction,
            ffi.fluent_grid_file,
            ffi.fluent_grid_file_path,
            ffi.fluent_cas_file,
            ffi.fluent_cas_file_path,
            ffi.fluent_dat_file,
            ffi.fluent_dat_file_path,
            ffi.create_by,
            ffi.create_time,
            ffi.update_by,
            ffi.update_time
        FROM
            bz_flow_field_input_t ffi
            LEFT JOIN bz_model_3d_t m3 ON ffi.model_3d_id = m3.id
    </sql>

    <select id="selectFlowFieldInputList" parameterType="FlowFieldInput" resultMap="FlowFieldInputResult">
        <include refid="selectFlowFieldInputVo"/>
        <where>  
            <if test="model3dId != null "> and model_3d_id = #{model3dId}</if>
            <if test="machNumber != null "> and mach_number = #{machNumber}</if>
            <if test="flowDirectionX != null "> and flow_direction_x = #{flowDirectionX}</if>
            <if test="flowDirectionY != null "> and flow_direction_y = #{flowDirectionY}</if>
            <if test="flowDirectionZ != null "> and flow_direction_z = #{flowDirectionZ}</if>
            <if test="flowVelocityX != null "> and flow_velocity_x = #{flowVelocityX}</if>
            <if test="flowVelocityY != null "> and flow_velocity_y = #{flowVelocityY}</if>
            <if test="flowVelocityZ != null "> and flow_velocity_z = #{flowVelocityZ}</if>
            <if test="infraredBand != null">and infrared_band = #{infraredBand}</if>
            <if test="flowTemperature != null"> and flow_temperature = #{flowTemperaure}</if>
            <if test="flowPressure != null" > and flow_pressure = #{flowPressure}</if>
            <if test="flowDensity != null"> and flow_density = #{flowDensity}</if>
            <if test="flightAltitude != null"> and flight_altitude= #{flightAltitude}</if>
            <if test="co2MassFraction != null "> and co2_mass_fraction = #{co2MassFraction}</if>
            <if test="coMassFraction != null "> and co_mass_fraction = #{coMassFraction}</if>
            <if test="h2oMassFraction != null "> and h2o_mass_fraction = #{h2oMassFraction}</if>
            <if test="fluentGridFile != null  and fluentGridFile != ''"> and fluent_grid_file = #{fluentGridFile}</if>
            <if test="fluentGridFilePath != null  and fluentGridFilePath != ''"> and fluent_grid_file_path = #{fluentGridFilePath}</if>
            <if test="fluentCasFile != null  and fluentCasFile != ''"> and fluent_cas_file = #{fluentCasFile}</if>
            <if test="fluentCasFilePath != null  and fluentCasFilePath != ''"> and fluent_cas_file_path = #{fluentCasFilePath}</if>
            <if test="fluentDatFile != null  and fluentDatFile != ''"> and fluent_dat_file = #{fluentDatFile}</if>
            <if test="fluentDatFilePath != null  and fluentDatFilePath != ''"> and fluent_dat_file_path = #{fluentDatFilePath}</if>
        </where>
    </select>
    
    <select id="selectFlowFieldInputById" parameterType="Long" resultMap="FlowFieldInputResult">
        <include refid="selectFlowFieldInputVo"/>
        where ffi.id = #{id}
    </select>
        
    <insert id="insertFlowFieldInput" parameterType="FlowFieldInput" useGeneratedKeys="true" keyProperty="id">
        insert into bz_flow_field_input_t
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="model3dId != null">model_3d_id,</if>
            <if test="machNumber != null">mach_number,</if>
            <if test="flowDirectionX != null" >flow_direction_x,</if>
            <if test="flowDirectionY != null" >flow_direction_y,</if>
            <if test="flowDirectionZ != null" >flow_direction_z,</if>
            <if test="flowVelocityX != null">flow_velocity_x,</if>
            <if test="flowVelocityY != null">flow_velocity_y,</if>
            <if test="flowVelocityZ != null">flow_velocity_z,</if>
            <if test="infraredBand != null">infrared_band,</if>
            <if test="flowTemperature != null">flow_temperature,</if>
            <if test="flowPressure != null">flow_pressure,</if>
            <if test="flowDensity != null">flow_density,</if>
            <if test="flightAltitude !=null">flight_altitude,</if>
            <if test="co2MassFraction != null">co2_mass_fraction,</if>
            <if test="coMassFraction != null">co_mass_fraction,</if>
            <if test="h2oMassFraction != null">h2o_mass_fraction,</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">fluent_grid_file,</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">fluent_grid_file_path,</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">fluent_cas_file,</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">fluent_cas_file_path,</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">fluent_dat_file,</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">fluent_dat_file_path,</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="model3dId != null">#{model3dId},</if>
            <if test="machNumber != null">#{machNumber},</if>
            <if test="flowDirectionX != null">#{flowDirectionX},</if>
            <if test="flowDirectionY != null">#{flowDirectionY},</if>
            <if test="flowDirectionZ != null">#{flowDirectionZ},</if>
            <if test="flowVelocityX != null">#{flowVelocityX},</if>
            <if test="flowVelocityY != null">#{flowVelocityY},</if>
            <if test="flowVelocityZ != null">#{flowVelocityZ},</if>
            <if test="infraredBand != null">#{infraredBand},</if>
            <if test="flowTemperature != null">#{flowTemperature},</if>
            <if test="flowPressure != null">#{flowPressure},</if>
            <if test="flowDensity!= null">#{flowDensity},</if>
            <if test="flightAltitude != null">#{flightAltitude},</if>
            <if test="co2MassFraction != null">#{co2MassFraction},</if>
            <if test="coMassFraction != null">#{coMassFraction},</if>
            <if test="h2oMassFraction != null">#{h2oMassFraction},</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">#{fluentGridFile},</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">#{fluentGridFilePath},</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">#{fluentCasFile},</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">#{fluentCasFilePath},</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">#{fluentDatFile},</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">#{fluentDatFilePath},</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="updateFlowFieldInput" parameterType="FlowFieldInput">
        update bz_flow_field_input_t
        <trim prefix="SET" suffixOverrides=",">
            <if test="model3dId != null">model_3d_id = #{model3dId},</if>
            <if test="machNumber != null">mach_number = #{machNumber},</if>
            <if test="flowDirectionX != null">flow_direction_x = #{flowDirectionX},</if>
            <if test="flowDirectionY != null">flow_direction_y = #{flowDirectionY},</if>
            <if test="flowDirectionZ != null">flow_direction_z = #{flowDirectionZ},</if>
            <if test="flowVelocityX != null">flow_velocity_x = #{flowVelocityX},</if>
            <if test="flowVelocityY != null">flow_velocity_y = #{flowVelocityY},</if>
            <if test="flowVelocityZ != null">flow_velocity_z = #{flowVelocityZ},</if>
            <if test="infraredBand != null">infrared_band = #{infraredBand},</if>
            <if test="flowTemperature != null">flow_temperature = #{flowTemperature},</if>
            <if test="flowPressure != null">flow_pressure =#{flowPressure},</if>
            <if test="flowDensity != null">flow_density =#{flowDensity},</if>
            <if test="flightAltitude != null">flight_altitude =#{flightAltitude},</if>
            <if test="co2MassFraction != null">co2_mass_fraction = #{co2MassFraction},</if>
            <if test="coMassFraction != null">co_mass_fraction = #{coMassFraction},</if>
            <if test="h2oMassFraction != null">h2o_mass_fraction = #{h2oMassFraction},</if>
            <if test="fluentGridFile != null and fluentGridFile != ''">fluent_grid_file = #{fluentGridFile},</if>
            <if test="fluentGridFilePath != null and fluentGridFilePath != ''">fluent_grid_file_path = #{fluentGridFilePath},</if>
            <if test="fluentCasFile != null and fluentCasFile != ''">fluent_cas_file = #{fluentCasFile},</if>
            <if test="fluentCasFilePath != null and fluentCasFilePath != ''">fluent_cas_file_path = #{fluentCasFilePath},</if>
            <if test="fluentDatFile != null and fluentDatFile != ''">fluent_dat_file = #{fluentDatFile},</if>
            <if test="fluentDatFilePath != null and fluentDatFilePath != ''">fluent_dat_file_path = #{fluentDatFilePath},</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="deleteFlowFieldInputById" parameterType="Long">
        delete from bz_flow_field_input_t where id = #{id}
    </delete>

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

    <select id="getFlowFieldInputList" resultType="Map">
        select id from bz_flow_field_input_t order by id desc
    </select>
</mapper>