<?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.ozs.pm.mapper.PmDemandEquipMapper">
    
    <resultMap type="com.ozs.pm.doman.PmDemandEquip" id="PmDemandEquipResult">
        <result property="demandEquipId"    column="demand_equip_id"    />
        <result property="demandId"    column="demand_id"    />
        <result property="typeAndName"    column="type_and_name"    />
        <result property="specification"    column="specification"    />
        <result property="qualityTechnicalStandard"    column="quality_technical_standard"    />
        <result property="measurementUnit"    column="measurement_unit"    />
        <result property="procurementQuantity"    column="procurement_quantity"    />
        <result property="price"    column="price"    />
        <result property="budgetAmount"    column="budget_amount"    />
        <result property="demandCommitTime"    column="demand_commit_time"    />
        <result property="procurementMethodSuggest"    column="procurement_method_suggest"    />
        <result property="remarks"    column="remarks"    />
        <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="selectPmDemandEquipVo">
        select demand_equip_id, demand_id, type_and_name, specification, quality_technical_standard, measurement_unit, procurement_quantity, price, budget_amount, demand_commit_time, procurement_method_suggest, remarks, create_by, create_time, update_by, update_time from pm_demand_equip
    </sql>

    <select id="selectPmDemandEquipList" parameterType="com.ozs.pm.doman.PmDemandEquip" resultMap="PmDemandEquipResult">
        <include refid="selectPmDemandEquipVo"/>
        <where>  
            <if test="demandId != null "> and demand_id = #{demandId}</if>
            <if test="typeAndName != null  and typeAndName != ''"> and type_and_name like concat('%', #{typeAndName}, '%')</if>
            <if test="specification != null  and specification != ''"> and specification = #{specification}</if>
            <if test="qualityTechnicalStandard != null  and qualityTechnicalStandard != ''"> and quality_technical_standard = #{qualityTechnicalStandard}</if>
            <if test="measurementUnit != null  and measurementUnit != ''"> and measurement_unit = #{measurementUnit}</if>
            <if test="procurementQuantity != null "> and procurement_quantity = #{procurementQuantity}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="budgetAmount != null "> and budget_amount = #{budgetAmount}</if>
            <if test="demandCommitTime != null "> and demand_commit_time = #{demandCommitTime}</if>
            <if test="procurementMethodSuggest != null  and procurementMethodSuggest != ''"> and procurement_method_suggest = #{procurementMethodSuggest}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectPmDemandEquipByDemandEquipId" parameterType="Long" resultMap="PmDemandEquipResult">
        <include refid="selectPmDemandEquipVo"/>
        where demand_equip_id = #{demandEquipId}
    </select>
        
    <insert id="insertPmDemandEquip" parameterType="com.ozs.pm.doman.PmDemandEquip" useGeneratedKeys="true" keyProperty="demandEquipId">
        insert into pm_demand_equip
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="demandId != null">demand_id,</if>
            <if test="typeAndName != null">type_and_name,</if>
            <if test="specification != null">specification,</if>
            <if test="qualityTechnicalStandard != null">quality_technical_standard,</if>
            <if test="measurementUnit != null and measurementUnit != ''">measurement_unit,</if>
            <if test="procurementQuantity != null">procurement_quantity,</if>
            <if test="price != null">price,</if>
            <if test="budgetAmount != null">budget_amount,</if>
            <if test="demandCommitTime != null">demand_commit_time,</if>
            <if test="procurementMethodSuggest != null">procurement_method_suggest,</if>
            <if test="remarks != null">remarks,</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="demandId != null">#{demandId},</if>
            <if test="typeAndName != null">#{typeAndName},</if>
            <if test="specification != null">#{specification},</if>
            <if test="qualityTechnicalStandard != null">#{qualityTechnicalStandard},</if>
            <if test="measurementUnit != null and measurementUnit != ''">#{measurementUnit},</if>
            <if test="procurementQuantity != null">#{procurementQuantity},</if>
            <if test="price != null">#{price},</if>
            <if test="budgetAmount != null">#{budgetAmount},</if>
            <if test="demandCommitTime != null">#{demandCommitTime},</if>
            <if test="procurementMethodSuggest != null">#{procurementMethodSuggest},</if>
            <if test="remarks != null">#{remarks},</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="updatePmDemandEquip" parameterType="com.ozs.pm.doman.PmDemandEquip">
        update pm_demand_equip
        <trim prefix="SET" suffixOverrides=",">
            <if test="demandId != null">demand_id = #{demandId},</if>
            <if test="typeAndName != null">type_and_name = #{typeAndName},</if>
            <if test="specification != null">specification = #{specification},</if>
            <if test="qualityTechnicalStandard != null">quality_technical_standard = #{qualityTechnicalStandard},</if>
            <if test="measurementUnit != null and measurementUnit != ''">measurement_unit = #{measurementUnit},</if>
            <if test="procurementQuantity != null">procurement_quantity = #{procurementQuantity},</if>
            <if test="price != null">price = #{price},</if>
            <if test="budgetAmount != null">budget_amount = #{budgetAmount},</if>
            <if test="demandCommitTime != null">demand_commit_time = #{demandCommitTime},</if>
            <if test="procurementMethodSuggest != null">procurement_method_suggest = #{procurementMethodSuggest},</if>
            <if test="remarks != null">remarks = #{remarks},</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 demand_equip_id = #{demandEquipId}
    </update>

</mapper>