<?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.PmDemandEngineeringMapper">
    
    <resultMap type="com.ozs.pm.doman.PmDemandEngineering" id="PmDemandEngineeringResult">
        <result property="demandEngineeringId"    column="demand_engineering_id"    />
        <result property="demandId"    column="demand_id"    />
        <result property="engineeringName"    column="engineering_name"    />
        <result property="constructionLocation"    column="construction_location"    />
        <result property="designAssignmenApprovalNumber"    column="design_assignmen_approval_number"    />
        <result property="projectConstructionPlanNumber"    column="project_construction_plan_number"    />
        <result property="tassignmentApprovalScale"    column="tassignment_approval_scale"    />
        <result property="tassignmentApprovalInvestmen"    column="tassignment_approval_investmen"    />
        <result property="planningLicenseNumber"    column="planning_license_number"    />
        <result property="classifiedTreatment"    column="classified_treatment"    />
        <result property="procurementProjectScale"    column="procurement_project_scale"    />
        <result property="procurementProjectInvestment"    column="procurement_project_investment"    />
        <result property="linkman"    column="linkman"    />
        <result property="phone"    column="phone"    />
        <result property="projectCategory"    column="project_category"    />
        <result property="contractingMode"    column="contracting_mode"    />
        <result property="constructionDrawing"    column="construction_drawing"    />
        <result property="designUnit"    column="design_unit"    />
        <result property="ceilingPrice"    column="ceiling_price"    />
        <result property="procurementMethodSuggest"    column="procurement_method_suggest"    />
        <result property="qualificationLevelRequirement"    column="qualification_level_requirement"    />
        <result property="supplierId"    column="supplier_id"    />
        <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="selectPmDemandEngineeringVo">
        select demand_engineering_id, demand_id, engineering_name, construction_location, design_assignmen_approval_number, project_construction_plan_number, tassignment_approval_scale, tassignment_approval_investmen, planning_license_number, classified_treatment, procurement_project_scale, procurement_project_investment, linkman, phone, project_category, contracting_mode, construction_drawing, design_unit, ceiling_price, procurement_method_suggest, qualification_level_requirement, supplier_id, remarks, create_by, create_time, update_by, update_time from pm_demand_engineering
    </sql>

    <select id="selectPmDemandEngineeringList" parameterType="com.ozs.pm.doman.PmDemandEngineering" resultMap="PmDemandEngineeringResult">
        <include refid="selectPmDemandEngineeringVo"/>
        <where>  
            <if test="demandId != null "> and demand_id = #{demandId}</if>
            <if test="engineeringName != null  and engineeringName != ''"> and engineering_name like concat('%', #{engineeringName}, '%')</if>
            <if test="constructionLocation != null  and constructionLocation != ''"> and construction_location = #{constructionLocation}</if>
            <if test="designAssignmenApprovalNumber != null  and designAssignmenApprovalNumber != ''"> and design_assignmen_approval_number = #{designAssignmenApprovalNumber}</if>
            <if test="projectConstructionPlanNumber != null "> and project_construction_plan_number = #{projectConstructionPlanNumber}</if>
            <if test="tassignmentApprovalScale != null "> and tassignment_approval_scale = #{tassignmentApprovalScale}</if>
            <if test="tassignmentApprovalInvestmen != null  and tassignmentApprovalInvestmen != ''"> and tassignment_approval_investmen = #{tassignmentApprovalInvestmen}</if>
            <if test="planningLicenseNumber != null  and planningLicenseNumber != ''"> and planning_license_number = #{planningLicenseNumber}</if>
            <if test="classifiedTreatment != null  and classifiedTreatment != ''"> and classified_treatment = #{classifiedTreatment}</if>
            <if test="procurementProjectScale != null "> and procurement_project_scale = #{procurementProjectScale}</if>
            <if test="procurementProjectInvestment != null "> and procurement_project_investment = #{procurementProjectInvestment}</if>
            <if test="linkman != null "> and linkman = #{linkman}</if>
            <if test="phone != null "> and phone = #{phone}</if>
            <if test="projectCategory != null  and projectCategory != ''"> and project_category = #{projectCategory}</if>
            <if test="contractingMode != null  and contractingMode != ''"> and contracting_mode = #{contractingMode}</if>
            <if test="constructionDrawing != null  and constructionDrawing != ''"> and construction_drawing = #{constructionDrawing}</if>
            <if test="designUnit != null "> and design_unit = #{designUnit}</if>
            <if test="ceilingPrice != null "> and ceiling_price = #{ceilingPrice}</if>
            <if test="procurementMethodSuggest != null  and procurementMethodSuggest != ''"> and procurement_method_suggest = #{procurementMethodSuggest}</if>
            <if test="qualificationLevelRequirement != null  and qualificationLevelRequirement != ''"> and qualification_level_requirement = #{qualificationLevelRequirement}</if>
            <if test="supplierId != null "> and supplier_id = #{supplierId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectPmDemandEngineeringByDemandEngineeringId" parameterType="Long" resultMap="PmDemandEngineeringResult">
        <include refid="selectPmDemandEngineeringVo"/>
        where demand_engineering_id = #{demandEngineeringId}
    </select>
        
    <insert id="insertPmDemandEngineering" parameterType="com.ozs.pm.doman.PmDemandEngineering" useGeneratedKeys="true" keyProperty="demandEngineeringId">
        insert into pm_demand_engineering
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="demandId != null">demand_id,</if>
            <if test="engineeringName != null">engineering_name,</if>
            <if test="constructionLocation != null">construction_location,</if>
            <if test="designAssignmenApprovalNumber != null">design_assignmen_approval_number,</if>
            <if test="projectConstructionPlanNumber != null">project_construction_plan_number,</if>
            <if test="tassignmentApprovalScale != null">tassignment_approval_scale,</if>
            <if test="tassignmentApprovalInvestmen != null">tassignment_approval_investmen,</if>
            <if test="planningLicenseNumber != null">planning_license_number,</if>
            <if test="classifiedTreatment != null">classified_treatment,</if>
            <if test="procurementProjectScale != null">procurement_project_scale,</if>
            <if test="procurementProjectInvestment != null">procurement_project_investment,</if>
            <if test="linkman != null">linkman,</if>
            <if test="phone != null">phone,</if>
            <if test="projectCategory != null">project_category,</if>
            <if test="contractingMode != null">contracting_mode,</if>
            <if test="constructionDrawing != null">construction_drawing,</if>
            <if test="designUnit != null">design_unit,</if>
            <if test="ceilingPrice != null">ceiling_price,</if>
            <if test="procurementMethodSuggest != null">procurement_method_suggest,</if>
            <if test="qualificationLevelRequirement != null">qualification_level_requirement,</if>
            <if test="supplierId != null">supplier_id,</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="engineeringName != null">#{engineeringName},</if>
            <if test="constructionLocation != null">#{constructionLocation},</if>
            <if test="designAssignmenApprovalNumber != null">#{designAssignmenApprovalNumber},</if>
            <if test="projectConstructionPlanNumber != null">#{projectConstructionPlanNumber},</if>
            <if test="tassignmentApprovalScale != null">#{tassignmentApprovalScale},</if>
            <if test="tassignmentApprovalInvestmen != null">#{tassignmentApprovalInvestmen},</if>
            <if test="planningLicenseNumber != null">#{planningLicenseNumber},</if>
            <if test="classifiedTreatment != null">#{classifiedTreatment},</if>
            <if test="procurementProjectScale != null">#{procurementProjectScale},</if>
            <if test="procurementProjectInvestment != null">#{procurementProjectInvestment},</if>
            <if test="linkman != null">#{linkman},</if>
            <if test="phone != null">#{phone},</if>
            <if test="projectCategory != null">#{projectCategory},</if>
            <if test="contractingMode != null">#{contractingMode},</if>
            <if test="constructionDrawing != null">#{constructionDrawing},</if>
            <if test="designUnit != null">#{designUnit},</if>
            <if test="ceilingPrice != null">#{ceilingPrice},</if>
            <if test="procurementMethodSuggest != null">#{procurementMethodSuggest},</if>
            <if test="qualificationLevelRequirement != null">#{qualificationLevelRequirement},</if>
            <if test="supplierId != null">#{supplierId},</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="updatePmDemandEngineering" parameterType="com.ozs.pm.doman.PmDemandEngineering">
        update pm_demand_engineering
        <trim prefix="SET" suffixOverrides=",">
            <if test="demandId != null">demand_id = #{demandId},</if>
            <if test="engineeringName != null">engineering_name = #{engineeringName},</if>
            <if test="constructionLocation != null">construction_location = #{constructionLocation},</if>
            <if test="designAssignmenApprovalNumber != null">design_assignmen_approval_number = #{designAssignmenApprovalNumber},</if>
            <if test="projectConstructionPlanNumber != null">project_construction_plan_number = #{projectConstructionPlanNumber},</if>
            <if test="tassignmentApprovalScale != null">tassignment_approval_scale = #{tassignmentApprovalScale},</if>
            <if test="tassignmentApprovalInvestmen != null">tassignment_approval_investmen = #{tassignmentApprovalInvestmen},</if>
            <if test="planningLicenseNumber != null">planning_license_number = #{planningLicenseNumber},</if>
            <if test="classifiedTreatment != null">classified_treatment = #{classifiedTreatment},</if>
            <if test="procurementProjectScale != null">procurement_project_scale = #{procurementProjectScale},</if>
            <if test="procurementProjectInvestment != null">procurement_project_investment = #{procurementProjectInvestment},</if>
            <if test="linkman != null">linkman = #{linkman},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="projectCategory != null">project_category = #{projectCategory},</if>
            <if test="contractingMode != null">contracting_mode = #{contractingMode},</if>
            <if test="constructionDrawing != null">construction_drawing = #{constructionDrawing},</if>
            <if test="designUnit != null">design_unit = #{designUnit},</if>
            <if test="ceilingPrice != null">ceiling_price = #{ceilingPrice},</if>
            <if test="procurementMethodSuggest != null">procurement_method_suggest = #{procurementMethodSuggest},</if>
            <if test="qualificationLevelRequirement != null">qualification_level_requirement = #{qualificationLevelRequirement},</if>
            <if test="supplierId != null">supplier_id = #{supplierId},</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_engineering_id = #{demandEngineeringId}
    </update>

</mapper>