<?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.jeeplus.modules.workbidproject.dao.WorkBidProjectDao">
    
	<sql id="workBidProjectColumns">
		a.id AS "id",
		a.project_number AS "projectNumber",
		a.project_name AS "projectName",
		a.project_type AS "projectType",
		a.type_explain AS "typeExplain",
		a.project_source AS "projectSource",
		a.source_explain AS "sourceExplain",
		a.is_ext AS "isExt",
		a.bid_company AS "bidCompany.id",
		a.ext_company AS "extCompany",
		a.contacts AS "contacts",
		a.registration_date AS "registrationDate",
		a.bid_date AS "bidDate",
		a.trial_date AS "trialDate",
		a.trial_type AS "trialType",
		a.document_cost AS "documentCost",
		a.purchase_date AS "purchaseDate",
		a.bind_cost AS "bindCost",
		a.other_cost AS "otherCost",
		a.bid_bond AS "bidBond",
		a.bond_style AS "bondStyle",
		a.refund_date AS "refundDate",
		a.offer AS "offer",
		a.psort AS "psort",
		a.ssort AS "ssort",
		a.is_bid AS "isBid",
		a.is_subcontract AS "isSubcontract",
		a.subcontract_company AS "subcontractCompany",
		a.project_situation AS "projectSituation",
		a.status AS "status",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		bidCompany.name AS "bidCompany.name",
		a.project_master AS "projectMaster",
		a.project_member AS "projectMember",
		u.name AS "createBy.name",
		a.company_id AS "companyId",
		a.office_id AS "officeId",
		o.name AS "officeName",
		a.process_instance_id AS "processInstanceId",
		a.project_scale AS "projectScale",
		a.scale_type AS "scaleType",
		a.scale_unit AS "scaleUnit",
		a.invest_money AS "investMoney",
		a.bid_number AS "bidNumber",
		a.give_date AS "giveDate",
		a.coop_office AS "office.id",
		a.business_type AS "businessType",
		a.service_content AS "serviceContent",
		coop.name AS "office.name",
		a.give_date_sign AS "giveDateSign",
		a.bid_date_sign AS "bidDateSign",
		a.work_project_id AS "workProject.id"
	</sql>
	
	<sql id="workBidProjectJoins">
		LEFT JOIN work_client_info bidCompany ON bidCompany.id = a.bid_company
		left join sys_office coop on coop.id = a.coop_office
		LEFT JOIN sys_user u on u.id = a.create_by
		JOIN sys_office o ON o.id = a.office_id
		JOIN sys_office s ON s.id = a.company_id
	</sql>
	
    
	<select id="get" resultType="WorkBidProject" >
		SELECT 
			<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		WHERE a.id = #{id}
	</select>


	<select id="findList" resultType="WorkBidProject" >
		SELECT 
			<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="projectNumber != null and projectNumber != ''">
				AND a.project_number LIKE 
					<if test="dbName == 'oracle'">'%'||#{projectNumber}||'%'</if>
					<if test="dbName == 'mssql'">'%'+#{projectNumber}+'%'</if>
					<if test="dbName == 'mysql'">concat('%',#{projectNumber},'%')</if>
			</if>
			<if test="bidNumber != null and bidNumber != ''">
				AND a.bid_number LIKE
				<if test="dbName == 'oracle'">'%'||#{bidNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{bidNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{bidNumber},'%')</if>
			</if>
			<if test="projectName != null and projectName != ''">
				AND a.project_name LIKE 
					<if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
					<if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
					<if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
			</if>
			<if test="projectType != null and projectType != ''">
				AND a.project_type = #{projectType}
			</if>
			<if test="projectSource != null and projectSource != ''">
				AND a.project_source = #{projectSource}
			</if>
			<if test="contacts != null and contacts != ''">
				AND a.contacts = #{contacts}
			</if>
			<if test="psort != null and psort != ''">
				AND a.psort = #{psort}
			</if>
			<if test="ssort != null and ssort != ''">
				AND a.ssort = #{ssort}
			</if>
			<if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
				AND a.bid_date BETWEEN #{beginContractDate} AND #{endContractDate}
			</if>
			<if test="min != null and min != '' and max != null and max != ''">
				AND a.invest_money BETWEEN #{min} AND #{max}
				<!--and  a.invest_money >= #{min} a.invest_money <= #{max}-->
			</if>
			<if test="isSubcontract != null and isSubcontract != ''">
				AND a.is_subcontract = #{isSubcontract}
			</if>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
			${sqlMap.dsf}
			<!--<choose>
				<when test="queryCon != null and queryCon != ''">
					AND (
					find_in_set(#{queryCon},a.project_master)
					or
					find_in_set(#{queryCon},a.project_member)
					OR a.create_by = #{queryCon}
					${sqlMap.dsf}
					)
				</when>
				<otherwise>
					${sqlMap.dsf}
				</otherwise>
			</choose>-->
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.bid_date DESC
			</otherwise>
		</choose>
	</select>

	<select id="queryCount" resultType="int" >
		SELECT count(1)
		FROM work_bid_project a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="projectNumber != null and projectNumber != ''">
				AND a.project_number LIKE
				<if test="dbName == 'oracle'">'%'||#{projectNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectNumber},'%')</if>
			</if>
			<if test="bidNumber != null and bidNumber != ''">
				AND a.bid_number LIKE
				<if test="dbName == 'oracle'">'%'||#{bidNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{bidNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{bidNumber},'%')</if>
			</if>
			<if test="projectName != null and projectName != ''">
				AND a.project_name LIKE
				<if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
			</if>
			<if test="projectType != null and projectType != ''">
				AND a.project_type = #{projectType}
			</if>
			<if test="projectSource != null and projectSource != ''">
				AND a.project_source = #{projectSource}
			</if>
			<if test="contacts != null and contacts != ''">
				AND a.contacts = #{contacts}
			</if>
			<if test="psort != null and psort != ''">
				AND a.psort = #{psort}
			</if>
			<if test="ssort != null and ssort != ''">
				AND a.ssort = #{ssort}
			</if>
			<if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
				AND a.bid_date BETWEEN #{beginContractDate} AND #{endContractDate}
			</if>
			<if test="min != null and min != '' and max != null and max != ''">
				AND a.invest_money BETWEEN #{min} AND #{max}
			</if>
			<if test="isSubcontract != null and isSubcontract != ''">
				AND a.is_subcontract = #{isSubcontract}
			</if>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
			${sqlMap.dsf}
		</where>
	</select>

	<select id="findListByGiveDate" resultType="WorkBidProject" >
		SELECT
		<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			and a.status = '5'
			and a.give_date_sign is null
			and a.give_date is not null
			and CURDATE() = DATE_SUB(a.give_date ,INTERVAL 3 DAY)
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.bid_date DESC
			</otherwise>
		</choose>
	</select>
	<select id="findListByBidDate" resultType="WorkBidProject" >
		SELECT
		<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			and a.status = '5'
			and a.bid_date_sign is null
			and a.bid_date is not null
			and a.bid_date = DATE_SUB(CURDATE() ,INTERVAL 30 DAY)
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.bid_date DESC
			</otherwise>
		</choose>
	</select>

	<select id="findAllList" resultType="WorkBidProject" >
		SELECT 
			<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>


	<select id="getByProcessInstanceId" resultType="WorkBidProject">
	SELECT
	<include refid="workBidProjectColumns"/>
	FROM work_bid_project a
	<include refid="workBidProjectJoins"/>
	WHERE a.process_instance_id = #{processInstanceId}
</select>

	<select id="getByPId" resultType="WorkBidProject">
		SELECT
		<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>
		WHERE a.work_project_id = #{id}
	</select>


	<insert id="insert">
		INSERT INTO work_bid_project(
			id,
			project_number,
			project_name,
			project_type,
			type_explain,
			project_source,
			source_explain,
			is_ext,
			bid_company,
			ext_company,
			contacts,
			registration_date,
			bid_date,
			trial_date,
			trial_type,
			document_cost,
			purchase_date,
			psort,
			ssort,
			bind_cost,
			other_cost,
			bid_bond,
			bond_style,
			refund_date,
			offer,
			is_bid,
			implementing_dept,
			project_master,
			project_member,
			is_subcontract,
			subcontract_company,
			project_situation,
			status,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			company_id,
			office_id,

			project_scale,
			scale_type,
			scale_unit,
			invest_money,
			bid_number,
			give_date,
			coop_office,
			business_type,
			service_content,
			give_date_sign,
			bid_date_sign,
			work_project_id
		) VALUES (
			#{id},
			#{projectNumber},
			#{projectName},
			#{projectType},
			#{typeExplain},
			#{projectSource},
			#{sourceExplain},
			#{isExt},
			#{bidCompany.id},
			#{extCompany},
			#{contacts},
			#{registrationDate},
			#{bidDate},
			#{trialDate},
			#{trialType},
			#{documentCost},
			#{purchaseDate},
			#{psort},
			#{ssort},
			#{bindCost},
			#{otherCost},
			#{bidBond},
			#{bondStyle},
			#{refundDate},
			#{offer},
			#{isBid},
			#{implementingDept},
			#{projectMaster},
			#{projectMember},
			#{isSubcontract},
			#{subcontractCompany},
			#{projectSituation},
			#{status},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{companyId},
			#{officeId},

			#{projectScale},
			#{scaleType},
			#{scaleUnit},
			#{investMoney},
			#{bidNumber},
			#{giveDate},
			#{office.id},
			#{businessType},
			#{serviceContent},
			#{giveDateSign},
			#{bidDateSign},
			#{workProject.id}
		)
	</insert>
	
	<update id="update">
		UPDATE work_bid_project SET 	
			project_number = #{projectNumber},
			project_name = #{projectName},
			project_type = #{projectType},
			type_explain = #{typeExplain},
			project_source = #{projectSource},
			source_explain = #{sourceExplain},
			is_ext = #{isExt},
			bid_company = #{bidCompany.id},
			ext_company = #{extCompany},
			contacts = #{contacts},
			registration_date = #{registrationDate},
			bid_date = #{bidDate},
			trial_date = #{trialDate},
			trial_type = #{trialType},
			document_cost = #{documentCost},
			purchase_date = #{purchaseDate},
			bind_cost = #{bindCost},
			other_cost = #{otherCost},
			bid_bond = #{bidBond},
			bond_style = #{bondStyle},
			refund_date = #{refundDate},
			offer = #{offer},
			is_bid = #{isBid},
			implementing_dept = #{implementingDept},
			project_master = #{projectMaster},
			project_member = #{projectMember},
			is_subcontract = #{isSubcontract},
			subcontract_company = #{subcontractCompany},
			project_situation = #{projectSituation},
			status = #{status},
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			company_id = #{companyId},
			office_id = #{officeId},
			status = #{status},
			psort = #{psort},
			ssort = #{ssort},

			project_scale = #{projectScale},
			scale_type = #{scaleType},
			scale_unit = #{scaleUnit},
			invest_money = #{investMoney},
			bid_number = #{bidNumber},
			give_date = #{giveDate},
			coop_office = #{office.id},
			business_type = #{businessType},
			service_content = #{serviceContent},
			work_project_id = #{workProject.id}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_bid_project
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_bid_project SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>

	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkBidProject" statementType="STATEMENT">
		SELECT
		<include refid="workBidProjectColumns"/>
		FROM work_bid_project a
		<include refid="workBidProjectJoins"/>  where ${propertyName} = '${value}'
	</select>
	
	<select id="findListBybidCompany" resultType="WorkClientInfo">
		SELECT 
			*
		FROM work_client_info a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="id != null and id != ''">
				AND a.id LIKE 
				<if test="dbName == 'oracle'">#{id}||'%'</if>
				<if test="dbName == 'mssql'">#{id}+'%'</if>
				<if test="dbName == 'mysql'">concat(#{id},'%')</if>
			</if>
			<if test="companyId != null and companyId != ''">
				AND a.company_id = #{companyId}
			</if>
			<if test="name != null and name != ''">
				AND a.name LIKE
				<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>

	<select id="findListByimplementingDept" resultType="Office">
		SELECT 
			*
		FROM sys_office a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="id != null and id != ''">
				AND a.id LIKE 
				<if test="dbName == 'oracle'">#{id}||'%'</if>
				<if test="dbName == 'mssql'">#{id}+'%'</if>
				<if test="dbName == 'mysql'">concat(#{id},'%')</if>
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>

	<select id="findListByprojectMaster" resultType="User">
		SELECT 
			*
		FROM sys_user a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="id != null and id != ''">
				AND a.id LIKE 
				<if test="dbName == 'oracle'">#{id}||'%'</if>
				<if test="dbName == 'mssql'">#{id}+'%'</if>
				<if test="dbName == 'mysql'">concat(#{id},'%')</if>
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>

				<!-- 取得用户和工程关联表数据 -->
	<select id="getProjectMember" resultType="java.lang.String">
		select user_id FROM work_project_user WHERE project_id = #{id} and is_master <![CDATA[!=]]> '1'
	</select>
	
	<select id="getProjectMaster" resultType="java.lang.String">
		select user_id FROM work_project_user WHERE project_id = #{id} and is_master = '1'
	</select>
	
					<!-- 取得部门和工程关联表数据 -->
	<select id="getImplementingDept" resultType="java.lang.String">
		select office_id FROM work_project_office WHERE project_id = #{id}
	</select>
	
		<!-- 删除用户和资格预审工程关联表数据 -->
	<delete id="deleteProjectUser">
		DELETE FROM work_project_user WHERE project_id = #{id}
	</delete>
	
			<!-- 删除负责人用户和资格预审工程关联表数据 -->
	<delete id="deleteProjectMaster">
		DELETE FROM work_project_user WHERE project_id = #{id} and is_master ='1'
	</delete>
	
			<!-- 删除部门和工程关联表数据 -->
	<delete id="deleteImplementingDept">
		DELETE FROM work_project_office WHERE project_id = #{id}
	</delete>
	
				<!-- 删除成员用户和资格预审工程关联表数据 -->
	<delete id="deleteProjectMember">
		DELETE FROM work_project_user WHERE project_id = #{id} and is_master  <![CDATA[!=]]> '1'
	</delete>
	
	<!-- 插入成员用户和资格预审工程关联表数据 -->
	<insert id="insertProjectMember">
		INSERT INTO work_project_user(project_id,user_id,is_master)
		<foreach collection="memberList" item="user" separator=" union all ">
			SELECT #{id}, #{user.id} ,'0' FROM dual
		</foreach>
	</insert>
	
		<!-- 插入负责人用户和资格预审工程关联表数据 -->
	<insert id="insertProjectMaster">
		INSERT INTO work_project_user(project_id,user_id,is_master)
		<foreach collection="masterList" item="user" separator=" union all ">
			SELECT #{id}, #{user.id},'1' FROM dual
		</foreach>
	</insert>

	<update id="updateProcessInstanceId">
		UPDATE work_bid_project SET
		process_instance_id = #{processInstanceId}
		WHERE id = #{id}
	</update>

	<update id="updateGiveDateSign">
		UPDATE work_bid_project SET
		give_date_sign = '1'
		WHERE id = #{id}
	</update>
	<update id="updateBidDateSign">
		UPDATE work_bid_project SET
		bid_date_sign = '1'
		WHERE id = #{id}
	</update>

			<!-- 插入部门和工程关联表数据 -->
	<insert id="insertImplementingDept">
		INSERT INTO work_project_office(project_id,office_id)
		<foreach collection="deptList" item="office" separator=" union all ">
			SELECT #{id}, #{office.id} FROM dual
		</foreach>
	</insert>

    <update id="updateForTans">
        UPDATE work_bid_project
		SET	update_date = #{updateDate}
		WHERE id = #{id}
    </update>


	<select id="findLists" resultType="WorkBidProjectList" >
		SELECT
			a.id AS "id",
			a.project_number AS "projectNumber",
			a.project_name AS "projectName",
			a.project_type AS "projectType",
			a.type_explain AS "typeExplain",
			a.project_source AS "projectSource",
			a.source_explain AS "sourceExplain",
			a.is_ext AS "isExt",
			a.bid_company AS "bidCompany.id",
			a.ext_company AS "extCompany",
			a.contacts AS "contacts",
			a.registration_date AS "registrationDate",
			a.bid_date AS "bidDate",
			a.trial_date AS "trialDate",
			a.trial_type AS "trialType",
			a.document_cost AS "documentCost",
			a.purchase_date AS "purchaseDate",
			a.bind_cost AS "bindCost",
			a.other_cost AS "otherCost",
			a.bid_bond AS "bidBond",
			a.bond_style AS "bondStyle",
			a.refund_date AS "refundDate",
			a.offer AS "offer",
			a.psort AS "psort",
			a.ssort AS "ssort",
			a.is_bid AS "isBid",
			a.is_subcontract AS "isSubcontract",
			a.subcontract_company AS "subcontractCompany",
			a.project_situation AS "projectSituation",
			a.status AS "status",
			a.create_by AS "createBy.id",
			a.create_date AS "creaDates",
			a.update_by AS "updateBy.id",
			a.update_date AS "updateDate",
			a.remarks AS "remark",
			a.del_flag AS "delFlag",
			bidCompany.name AS "bidCompanyName",
			a.project_master AS "projectMaster",
			a.project_member AS "projectMember",
			u.name AS "createByName",
			a.company_id AS "companyId",
			a.office_id AS "officeId",
			o.name AS "officeName",
			a.process_instance_id AS "processInstanceId",
			a.project_scale AS "projectScale",
			a.scale_type AS "scaleType",
			a.scale_unit AS "scaleUnit",
			a.invest_money AS "investMoney",
			a.bid_number AS "bidNumber",
			a.give_date AS "giveDate",
			a.coop_office AS "office.id",
			a.business_type AS "businessType",
			a.service_content AS "serviceContent",
			coop.name AS "coopName",
			a.give_date_sign AS "giveDateSign",
			a.bid_date_sign AS "bidDateSign",
			a.work_project_id AS "workProject.id"
		FROM work_bid_project a
			LEFT JOIN work_client_info bidCompany ON bidCompany.id = a.bid_company
			left join sys_office coop on coop.id = a.coop_office
			LEFT JOIN sys_user u on u.id = a.create_by
			JOIN sys_office o ON o.id = a.office_id
			JOIN sys_office s ON s.id = a.company_id
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="projectNumber != null and projectNumber != ''">
				AND a.project_number LIKE
				<if test="dbName == 'oracle'">'%'||#{projectNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectNumber},'%')</if>
			</if>
			<if test="projectName != null and projectName != ''">
				AND a.project_name LIKE
				<if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
			</if>
			<if test="projectType != null and projectType != ''">
				AND a.project_type = #{projectType}
			</if>
			<if test="projectSource != null and projectSource != ''">
				AND a.project_source = #{projectSource}
			</if>
			<if test="contacts != null and contacts != ''">
				AND a.contacts = #{contacts}
			</if>
			<if test="psort != null and psort != ''">
				AND a.psort = #{psort}
			</if>
			<if test="ssort != null and ssort != ''">
				AND a.ssort = #{ssort}
			</if>
			<if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
				AND a.bid_date BETWEEN #{beginContractDate} AND #{endContractDate}
			</if>
			<if test="isSubcontract != null and isSubcontract != ''">
				AND a.is_subcontract = #{isSubcontract}
			</if>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
			${sqlMap.dsf}
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.bid_date DESC
			</otherwise>
		</choose>
	</select>
</mapper>