<?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.sg.advence.activiti.mapper.AdvanceMapper">
    
	<sql id="projectColumns">
		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.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.pro_type As "type",
		a.demand_unit AS "demandUnit",
		a.bdz_name As "bdzName",
	  	a.line_name As "lineName",
	  	a.require_name AS "requireName",
	  	a.project_id AS "projectId",
	  	a.project_name AS "projectName",
	  	a.project_number AS "projectNumber",
		a.project_manage_role AS "projectManageRole",
		a.distribution_engineering AS "distributionEngineering",
		a.distribution_materials AS "distributionMaterials",
		a.distribution_system AS "distributionSystem",
		a.distribution_policy AS "distributionPolicy",
		a.management_leader AS "managementLeader",
		a.run_unit AS "runUnit",
		a.run_unit_role AS "runUnitRole",
		a.through_research_role AS "throughResearchRole",
		a.construction_unit AS "constructionUnit",
		a.construction_unit_role AS "constructionUnitRole",
		a.construction_unit_manage AS "constructionUnitManage",
		a.construction_unit_leader AS "constructionUnitLeader",
    	a.design_unit AS "design_unit",
		a.design_unit_manage AS "designUnitManage",
		a.design_unit_leader AS "designUnitLeader",
		a.clarificaiton_type AS "clarificaitonType",
		a.build_classification_resons As "bulidClassificationResons",
		a.bulbid_resons As "bulbidResons",
		a.asic_equipment AS "asicEquipment",
		a.run_the_class As "runTheClass",
		a.project_team AS "projectTeam",
		a.cost_estimate As "costEstimate",
		a.whether_rhe_upwind AS "whetherRheUpwind",
		a.sure_da_date AS "sureDaDate",
		a.text_remark AS "textRemark",
		a.power_line AS "powerLine",
    	a.power_scope AS "powerScope",
    	a.project_type AS "projectType",
        a.power_flag_package AS "powerFlagPackage",
     	a.preliminary_judgment AS "preliminaryJudgment",
    	a.flag_civil_engineering AS "flagCivilEngineering",
    	a.steel_tube_pole AS "steelTubePole",
    	a.flag_approval_planning AS "flagApprovalPlanning",
    	a.equ_create_type AS "equCreateType",
    	a.equ_create_size AS "equCreateSize",
    	a.flag_new_equ_name AS "flagNewEquName",
    	a.include_bdz_news AS "includeBdzNews",
    	a.flag_no_electrical AS "flagNoElectrical",
		a.drawings_work AS "drawingsWork",
    	a.flag_automation AS "flagAutomation",
    	a.two_and_three_remote AS "twoAndThreeRemote",
    	a.phone_style AS "phoneStyle",
    	a.stay_open_area AS "stayOpenArea",
    	a.ring_network_cabinet AS "ringNetworkCabinet",
    	a.station_dtu AS "stationDtu",
		a.status As "status",
		a.acquisition_status AS "acquisitionStatus",
		a.construction_status AS "constructionStatus",
		a.whether_close_status AS "whetherCloseStatus",
		a.earlyMaterial AS "earlyMaterial",
		a.preConstruction AS "preConstruction"
	</sql>
    
	<select id="get" resultType="Advance" >
		SELECT 
			<include refid="projectColumns"/>
		FROM xm_project_details a
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="Advance" >
		SELECT
		<include refid="projectColumns"/>
		FROM xm_project_details a
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			${dataScope}
			<if test="status != null and  status != ''">
				AND a.status = #{status}
			</if>
			<if test="whetherCloseStatus != null and  whetherCloseStatus != ''">
				AND a.whether_close_status = #{whetherCloseStatus}
			</if>
			<if test="id != null and  id != ''">
				AND a.id = #{id}
			</if>
			<if test="requireName != null and  requireName != ''">
				AND a.require_name LIKE CONCAT(CONCAT('%',#{requireName},'%'))
			</if>
			<if test="constructionUnitRole != null and  constructionUnitRole != ''">
				AND a.construction_unit_role = #{constructionUnitRole}
			</if>
			<if test="earlyMaterial != null and  earlyMaterial != ''">
				or a.earlyMaterial = #{earlyMaterial}
			</if>
			<if test="preConstruction != null and  preConstruction != ''">
				or a.preConstruction = #{preConstruction}
			</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>
	<!--修改提前施工状态0未提前施工，1提前施工-->
	<update id="updatePreConstruction">
		update xm_material_project set preConstruction = #{preConstruction} where id = #{id};
	</update>


</mapper>