<?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.workengineeringproject.dao.WorkEngineeringProjectDao">
    
	<sql id="workEngineeringProjectColumns">
		a.id AS "id",
		a.report_number AS "reportNumber",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.del_flag AS "delFlag",
		a.remarks AS "remarks",
		a.contract_id AS "contractId.id",
		a.project_id AS "projectId.id",
		a.business_type AS "businessType",
		a.pre_trial_amount AS "preTrialAmount",
		a.work_start_date AS "workStartDate",
		a.work_end_date AS "workEndDate",
		a.emploper_require AS "emploperRequire",
		a.project_area AS "area.id",
		a.office_id AS "office.id",
		a.host_office AS "hostOffice",
		a.jointly_office AS "jointlyOffice",
		a.host_office_master AS "hostOfficeMaster",
		a.jointly_office_master AS "jointlyOfficeMaster",
		a.host_office_member AS "hostOfficeMember",
		a.jointly_office_member AS "jointlyOfficeMember",
		a.status AS "status",
		a.psort AS "psort",
			a.ssort AS "ssort",
		a.process_instance_id AS "processInstanceId",
		a.company_id AS "companyId",
		u.name AS "createBy.name",
		contractId.name AS "contractId.name",
		projectId.number AS "projectId.number",
		projectId.name AS "projectId.name",
		client.name AS "workClientInfo.name",
		client.id AS "workClientInfo.id",
		o.name AS "office.name",
		a.is_ext AS "isExt",
		a.contract_info_name  AS "contractInfoName",
		area.name AS "area.name",
		a.master_id AS "masterId",
		a.is_total AS "isTotal",
		a.total_project_id AS "totalProjectId",
		a.total_project_ids AS "totalProjectIds",
		a.is_total_name AS "isTotalName",
		a.common_flag AS "commonFlag",
		a.sort AS "sort",
		(select name from work_project where id = (select project_id from work_engineering_project where id = a.total_project_id)) AS "totalProjectName"
	</sql>
	
	<sql id="workEngineeringProjectJoins">
		LEFT JOIN work_contract_info contractId ON contractId.id = a.contract_id
		LEFT JOIN work_project projectId ON projectId.id = a.project_id
		LEFT JOIN work_client_info client ON client.id = a.client_id
		LEFT JOIN sys_area area ON area.id = a.project_area
		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="WorkEngineeringProject" >
		SELECT 
			<include refid="workEngineeringProjectColumns"/>
		,
		contractId.contract_num AS "contractId.contractNum",
		contractId.client_id AS "workClientInfo.id",
		process_instance_proofread_id AS "processInstanceProofreadId",
		proofread_status AS "proofreadStatus",
		proofread_master AS "proofreadMaster",
		proofread_total AS "proofreadTotal"
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		WHERE a.id = #{id}
	</select>

	<select id="getProjectPlan" resultType="WorkProjectPlan" >
		SELECT
			id AS "id",
			task_count AS "taskCount",
			project_id AS "projectId",
			task_name AS "taskName",
			start_time AS "startTime",
			end_time AS "endTime",
			remind_user AS "remindUser.id",
			remind_date AS "remindDate",
			complete_user AS "completeUser.id",
			complete_date AS "completeDate",
			status AS "status",
			type AS "type"
		FROM work_project_plan
		WHERE id = #{id}
	</select>

	<select id="findList" resultType="WorkEngineeringProject" >
		SELECT 
			<include refid="workEngineeringProjectColumns"/>,proofread_status AS "proofreadStatus"
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="reportNumber != null and reportNumber != ''">
				AND a.report_number LIKE
				<if test="dbName == 'oracle'">'%'||#{reportNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{reportNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{reportNumber},'%')</if>
			</if>
			<if test="projectId != null and projectId.name != null and projectId.name != ''">
				AND projectId.name LIKE
				<if test="dbName == 'oracle'">'%'||#{projectId.name}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectId.name}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectId.name},'%')</if>
			</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="isTotal != null and isTotal != ''">
				AND a.is_total = #{isTotal}
			</if>
			<if test="contractName != null and contractName != ''">
				AND a.contract_id = #{contractName}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="area != null and area.id != null and area.id != ''">
				AND (a.project_area = #{area.id} OR find_in_set(#{area.id},a.area_parent_ids))
			</if>
			<if test="projectName != null and projectName != ''">
				AND a.project_id = #{projectName}
			</if>
			<if test="businessType != null and businessType != ''">
				AND a.business_type = #{businessType}
			</if>
			<if test="totalProjectIds != null and totalProjectIds != ''">
				AND a.total_project_ids LIKE
				<if test="dbName == 'oracle'">'%'||#{totalProjectIds}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{totalProjectIds}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{totalProjectIds},'%')</if>
			</if>
			<if test="totalProjectId != null and totalProjectId != ''">
				AND a.total_project_id =#{totalProjectId}
			</if>
			<choose>
			<when test="queryCon != null and queryCon != ''">
				AND (
				find_in_set(#{queryCon},a.host_office_master)
				or
				find_in_set(#{queryCon},a.jointly_office_master)
				or
				find_in_set(#{queryCon},a.host_office_member)
				or
				find_in_set(#{queryCon},a.jointly_office_member)
				or
				find_in_set(#{queryCon},a.master_id)
				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.sort DESC
			</otherwise>
		</choose>
	</select>

	<select id="findProjectManagementList" resultType="WorkEngineeringProject" >
		SELECT
		a.id AS "id",
		a.report_number AS "reportNumber",
		a.create_date AS "createDate",
		a.business_type AS "businessType",
		contractId.name AS "contractId.name",
		a.status AS "status",
		a.host_office_master AS "hostOfficeMaster",
		projectId.number AS "projectId.number",
		projectId.name AS "projectId.name",
		client.name AS "workClientInfo.name",
		client.id AS "workClientInfo.id",
		a.contract_id AS "contractId.id",
		a.project_id AS "projectId.id",
		a.company_id AS "companyId",
		u.name AS "createBy.name",
		u.id AS "createBy.id",
		proofread_status AS "proofreadStatus",
		proofread_master AS "proofreadMaster",
		proofread_total AS "proofreadTotal",
		process_instance_proofread_id AS "processInstanceProofreadId",
		a.is_total AS "isTotal",
		a.total_project_id AS "totalProjectId",
		(select name from work_project where id = (select project_id from work_engineering_project where id = a.total_project_id)) AS "totalProjectName"
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="reportNumber != null and reportNumber != ''">
				AND a.report_number LIKE
				<if test="dbName == 'oracle'">'%'||#{reportNumber}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{reportNumber}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{reportNumber},'%')</if>
			</if>
			<if test="projectId != null and projectId.name != null and projectId.name != ''">
				AND projectId.name LIKE
				<if test="dbName == 'oracle'">'%'||#{projectId.name}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{projectId.name}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{projectId.name},'%')</if>
			</if>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="contractName != null and contractName != ''">
				AND a.contract_id = #{contractName}
			</if>
			<if test="projectName != null and projectName != ''">
				AND a.project_id = #{projectName}
			</if>
			<if test="businessType != null and businessType != ''">
				AND a.business_type = #{businessType}
			</if>
			<if test="status != null and status != ''">
				AND a.status = #{status}
			</if>
			<if test="area != null and area.id != null and area.id != ''">
				AND (a.project_area = #{area.id} OR find_in_set(#{area.id},a.area_parent_ids))
			</if>
			<if test="totalProjectIds != null and totalProjectIds != ''">
				AND a.total_project_ids LIKE
				<if test="dbName == 'oracle'">'%'||#{totalProjectIds}||'%'</if>
				<if test="dbName == 'mssql'">'%'+#{totalProjectIds}+'%'</if>
				<if test="dbName == 'mysql'">concat('%',#{totalProjectIds},'%')</if>
			</if>
			<if test="totalProjectId != null and totalProjectId != ''">
				AND a.total_project_id =#{totalProjectId}
			</if>
			<choose>
				<when test="queryCon != null and queryCon != ''">
					AND (
						find_in_set(#{queryCon},a.host_office_master)
						or
						find_in_set(#{queryCon},a.jointly_office_master)
						or
						find_in_set(#{queryCon},a.host_office_member)
						or
						find_in_set(#{queryCon},a.jointly_office_member)
						or
						find_in_set(#{queryCon},a.master_id)
						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.create_date ASC
			</otherwise>
		</choose>
	</select>

	<select id="findAllList" resultType="WorkEngineeringProject" >
		SELECT 
			<include refid="workEngineeringProjectColumns"/>
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		<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>
	
	<insert id="insert">
		INSERT INTO work_engineering_project(
			id,
			report_number,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag,
			remarks,
			contract_id,
			client_id,
			project_id,
			business_type,
			pre_trial_amount,
			work_start_date,
			work_end_date,
			emploper_require,
			project_area,
			area_parent_ids,
			office_id,
			host_office,
			jointly_office,
			host_office_master,
			jointly_office_master,
			host_office_member,
			jointly_office_member,
			status,
			company_id,
			is_ext,
			contract_info_name,
			master_id,
			is_total,
			psort,
			ssort,
			total_project_id,
			is_total_name,
			total_project_ids,
			common_flag,
			sort
		) VALUES (
			#{id},
			#{reportNumber},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{delFlag},
			#{remarks},
			#{contractId.id},
			#{workClientInfo.id},
			#{projectId.id},
			#{businessType},
			#{preTrialAmount},
			#{workStartDate},
			#{workEndDate},
			#{emploperRequire},
			#{area.id},
			#{area.parentIds},
			#{office.id},
			#{hostOffice},
			#{jointlyOffice},
			#{hostOfficeMaster},
			#{jointlyOfficeMaster},
			#{hostOfficeMember},
			#{jointlyOfficeMember},
			#{status},
			#{companyId},
			#{isExt},
			#{contractInfoName},
			#{masterId},
			#{isTotal},
			#{psort},
			#{ssort},
			#{totalProjectId},
			#{isTotalName},
			#{totalProjectIds},
			#{commonFlag},
			#{sort}
		)
	</insert>
	
	<update id="update">
		UPDATE work_engineering_project SET 	
			report_number = #{reportNumber},
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			del_flag = #{delFlag},
			contract_id = #{contractId.id},
			client_id = #{workClientInfo.id},
			project_id = #{projectId.id},
			business_type = #{businessType},
			pre_trial_amount = #{preTrialAmount},
			work_start_date = #{workStartDate},
			work_end_date = #{workEndDate},
			emploper_require = #{emploperRequire},
			project_area = #{area.id},
			office_id = #{office.id},
			host_office = #{hostOffice},
			jointly_office = #{jointlyOffice},
			host_office_master = #{hostOfficeMaster},
			jointly_office_master = #{jointlyOfficeMaster},
			host_office_member = #{hostOfficeMember},
			jointly_office_member = #{jointlyOfficeMember},
			status = #{status},
			proofread_status = #{proofreadStatus},
			proofread_master = #{proofreadMaster},
			proofread_total = #{proofreadTotal},
			master_id = #{masterId},
			is_ext = #{isExt},
			psort = #{psort},
			ssort = #{ssort},
			contract_info_name = #{contractInfoName},
			company_id = #{companyId},
			is_total_name = #{isTotalName},
			total_project_ids = #{totalProjectIds},
			common_flag = #{commonFlag},
			area_parent_ids = #{area.parentIds},
			sort = #{sort}
		WHERE id = #{id}
	</update>

	<update id="updateProjectPlan">
		UPDATE work_project_plan SET
			task_count = #{taskCount},
			project_id = #{projectId},
			task_name = #{taskName},
			start_time = #{startTime},
			end_time = #{endTime},
			remind_user = #{remindUser.id},
			remind_date = #{remindDate},
			complete_user = #{completeUser.id},
			complete_date = #{completeDate},
			status = #{status},
			type = #{type}
		WHERE id = #{id}
	</update>

	<select id="getByProcessInstanceId" resultType="WorkEngineeringProject">
		SELECT
		<include refid="workEngineeringProjectColumns"/>
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		WHERE a.process_instance_id = #{processInstanceId}
	</select>

	<select id="getByProcessInstanceProofreadId" resultType="WorkEngineeringProject">
		SELECT
		<include refid="workEngineeringProjectColumns"/>,
		process_instance_proofread_id AS "processInstanceProofreadId",
		proofread_status AS "proofreadStatus"
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		WHERE a.process_instance_proofread_id = #{processInstanceProofreadId}
	</select>

	<update id="updateProcessInstanceId">
		UPDATE work_engineering_project SET
		process_instance_id = #{processInstanceId}
		WHERE id = #{id}
	</update>
	<update id="updateProcessInstanceProofreadId">
		UPDATE work_engineering_project SET
		process_instance_proofread_id = #{processInstanceProofreadId}
		WHERE id = #{id}
	</update>

	<insert id="updateRemakes">
		INSERT INTO work_project_plan_edit(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag,
			remarks,
			project_id
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{delFlag},
			#{remarks},
			#{name}
		)
	</insert>

	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_engineering_project
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_engineering_project SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>

	<insert id="insertPlan">
		INSERT INTO work_project_plan(id,task_count,project_id,task_name,start_time,end_time,remind_user,remind_date,complete_user,complete_date,type,status)
		<foreach collection="workProjectPlans" item="plan" separator=" union all ">
			SELECT #{plan.id},#{plan.taskCount},#{plan.projectId}, #{plan.taskName}  , #{plan.startTime}, #{plan.endTime}, #{plan.remindUser.id}, #{plan.remindDate}, #{plan.completeUser.id}, #{plan.completeDate}, #{plan.type} ,#{plan.status} FROM dual
		</foreach>
	</insert>

	<delete id="deletePlan">
		DELETE FROM work_project_plan WHERE id in
		<foreach collection="workProjectPlans" item="plan" open="(" separator="," close=")">
			#{plan.id}
		</foreach>
	</delete>

	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="WorkEngineeringProject" statementType="STATEMENT">
		SELECT
		<include refid="workEngineeringProjectColumns"/>
		,
		contractId.contract_num AS "contractId.contractNum",
		contractId.client_id AS "workClientInfo.id",
		linkman.name AS "workClientLinkman.name",
		linkman.position AS "workClientLinkman.position",
		linkman.link_phone AS "workClientLinkman.linkPhone",
		linkman.email AS "workClientLinkman.email",
		process_instance_proofread_id AS "processInstanceProofreadId",
		proofread_status AS "proofreadStatus",
		proofread_master AS "proofreadMaster",
		proofread_total AS "proofreadTotal"
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		LEFT JOIN work_client_linkman linkman on linkman.client_id = client.id  where ${propertyName} = '${value}'
	</select>
	
	<select id="findListBycontractId" resultType="WorkContractInfo">
		SELECT 
			*
		FROM work_contract_info a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL} and (a.alter_state = 4 or a.alter_state is null)
			<!--<if test="name != null and name != ''">
				AND a.name LIKE concat('%',#{name},'%')
			</if>
			<if test="companyId != null and companyId != ''">
				AND (a.company_id = #{companyId} or find_in_set(a.company_id ,#{parentIds}))
			</if>
			<if test="contractState != null and contractState != ''">
				AND a.contract_state = #{contractState}
			</if>
			<if test="contractType != null and contractType != ''">
				AND find_in_set(a.contract_type,#{contractType})
			</if>
			<if test="isTotal != null and isTotal != ''">
				and a.is_total = #{isTotal}
			</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="findProjectPlans" resultType="WorkProjectPlan">
		SELECT
			a.id as "id",
			a.project_id as "projectId",
			a.task_name as "taskName",
			a.task_count as "taskCount",
			a.start_time as "startTime",
			a.end_time as "endTime",
			a.remind_user as "remindUser.id",
			a.remind_date as "remindDate",
			a.complete_user as "completeUser.id",
			a.complete_date as "completeDate",
			remindUser.name as "remindUser.name",
			completeUser.name as "completeUser.name",
			a.type as "type",
			a.status as "status"
		FROM work_project_plan a
		LEFT JOIN sys_user remindUser on remindUser.id = remind_user
		LEFT JOIN sys_user completeUser on completeUser.id = complete_user
		<where>
			<if test="name != null and name != ''">
				AND a.type = #{name}
			</if>
			<if test="projectId != null and id != ''">
				AND a.project_id = #{id}
			</if>

		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.task_count DESC
			</otherwise>
		</choose>
	</select>

	<select id="findProjectPlanEdit" resultType="WorkProjectPlanEdit">
		SELECT
		a.id as "id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.del_flag AS "delFlag",
		a.remarks AS "remarks",
		user.name AS "updateBy.name"
		FROM work_project_plan_edit a
		LEFT JOIN sys_user user on user.id = a.update_by
		<where>
			<if test="id != null and id != ''">
				AND a.project_id = #{id}
			</if>

		</where>
	</select>

	<select id="findListByprojectId" resultType="WorkBidProject">
		SELECT
			*
		FROM work_project a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<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="getByPId" resultType="WorkEngineeringProject">
		SELECT
		<include refid="workEngineeringProjectColumns"/>
		FROM work_engineering_project a
		<include refid="workEngineeringProjectJoins"/>
		WHERE a.project_id = #{id}
	</select>


	<select id="findListByprojectt" resultType="WorkEngineeringProject">
		SELECT
		a.id AS "id",
		a.report_number AS "reportNumber",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.del_flag AS "delFlag",
		a.remarks AS "remarks",
		a.contract_id AS "contractId.id",
		a.project_id AS "projectId.id",
		a.business_type AS "businessType",
		a.pre_trial_amount AS "preTrialAmount",
		a.work_start_date AS "workStartDate",
		a.work_end_date AS "workEndDate",
		a.emploper_require AS "emploperRequire",
		a.project_area AS "area.id",
		a.office_id AS "office.id",
		a.host_office AS "hostOffice",
		a.jointly_office AS "jointlyOffice",
		a.host_office_master AS "hostOfficeMaster",
		a.jointly_office_master AS "jointlyOfficeMaster",
		a.host_office_member AS "hostOfficeMember",
		a.jointly_office_member AS "jointlyOfficeMember",
		a.status AS "status",
		a.process_instance_id AS "processInstanceId",
		a.company_id AS "companyId",
		a.is_ext AS "isExt",
		a.contract_info_name  AS "contractInfoName",
		a.master_id AS "masterId",
		a.is_total AS "isTotal",
		a.total_project_id AS "totalProjectId",
		(select name from work_project where id = a.project_id) AS "totalProjectName"
		FROM work_engineering_project a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="companyId != null and companyId != ''">
				AND a.company_id = #{companyId}
			</if>
			<if test="isTotal != null and isTotal != ''">
				AND a.is_total = #{isTotal}
			</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="findByList" resultType="WorkEngineeringProject">
		SELECT
		a.id,a.sort
		FROM work_engineering_project a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			AND (
			a.total_project_Id = #{totalProjectId} OR a.id= #{totalProjectId})
		</where>
		ORDER BY a.sort DESC
	</select>
</mapper>