<?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.managementcenter.privilegePre.mapper.PrivilegePreMapper">

	<select id="findAllList" resultType="PrivilegePre" >
		select id,Uid,Pid from xm_personnel_management
	</select>

	<select id="findListUser" resultType="com.jeeplus.modules.sg.managementcenter.privilegePre.entity.PrivilegePre" >
		select id,Uid,Pid from xm_personnel_management where Uid = #{uid}
	</select>

	<select id="findProcdef"  resultType="com.jeeplus.modules.sg.managementcenter.privilegePre.entity.PrivilegePre">
		select ID_ as id,NAME_ as name,KEY_ as oneKey,VERSION_ as oneVersion from act_re_procdef where ID_ in
		(
			<foreach collection="list" item="item" separator=",">
				#{item}
			</foreach>
		);
	</select>

	<update id="updatePersonal">
		update xm_personnel_management set Pid = #{pid} where uid = #{uid};
	</update>

	<insert id="addPersonal">
		insert into xm_personnel_management
		(id, create_by, create_date, update_by, update_date, del_flag, remarks, Uid, Pid)
		values (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{delFlag},
			#{remarks},
			#{uid},
			#{pid}
		);
		update xm_personnel_management set Pid = #{pid} where uid = #{uid};
	</insert>

	<select id="findAllProcDef" resultType="com.jeeplus.modules.sg.managementcenter.privilegePre.entity.PrivilegePre">
		select ID_ as id,NAME_ as name ,KEY_ as oneKey,VERSION_ as oneVersion from act_re_procdef
	</select>
	
	<insert id="insert">
		INSERT INTO xm_project_details(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			pro_type,
			demand_unit,
			bdz_name,
			line_name,
			require_name,
			project_id,
			project_name,
			project_number,
			project_manage_role,
			distribution_engineering,
			distribution_materials,
			distribution_system,
			distribution_policy,
			management_leader,
			run_unit,
			run_unit_role,
			through_research_role,
			construction_unit,
			construction_unit_role,
			construction_unit_manage,
			construction_unit_leader,
			design_unit,
			design_unit_manage,
			design_unit_leader,
			clarificaiton_type,
			build_classification_resons,
			bulbid_resons,
			asic_equipment,
			run_the_class,
			project_team,
			cost_estimate,
			whether_rhe_upwind,
			sure_da_date,
			text_remark,
			power_line,
			power_scope,
			project_type,
			power_flag_package,
			preliminary_judgment,
			flag_civil_engineering,
			steel_tube_pole,
			flag_approval_planning,
			equ_create_type,
			equ_create_size,
			flag_new_equ_name,
			include_bdz_news,
			flag_no_electrical,
			drawings_work,
			flag_automation,
			two_and_three_remote,
			phone_style,
			stay_open_area,
			ring_network_cabinet,
			station_dtu,
			status,
			acquisition_status,
			construction_status,
			whether_close_status,
			earlyMaterial,
			preConstruction
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{type},
			#{demandUnit},
			#{bdzName},
			#{lineName},
    		#{requireName},
    		#{projectId},
			#{projectName},
			#{projectNumber},
			#{projectManageRole},
			#{distributionEngineering},
			#{distributionMaterials},
			#{distributionSystem},
			#{distributionPolicy},
			#{managementLeader},
			#{runUnit},
			#{runUnitRole},
			#{throughResearchRole},
			#{constructionUnit},
			#{constructionUnitRole},
			#{constructionUnitManage},
			#{constructionUnitLeader},
			#{designUnit},
			#{designUnitManage},
			#{designUnitLeader},
			#{clarificaitonType},
    		#{bulidClassificationResons},
    		#{bulbidResons},
    		#{asicEquipment},
    		#{runTheClass},
    		#{projectTeam},
    		#{costEstimate},
    		#{whetherRheUpwind},
    		#{sureDaDate},
    		#{textRemark},
    		#{powerLine},
    	 	#{powerScope},
    	 	#{projectType},
        	#{powerFlagPackage},
     	 	#{preliminaryJudgment},
    	 	#{flagCivilEngineering},
    	 	#{steelTubePole},
    	 	#{flagApprovalPlanning},
    		#{equCreateType},
    		#{equCreateSize},
    	 	#{flagNewEquName},
    	 	#{includeBdzNews},
    		#{flagNoElectrical},
			#{drawingsWork},
    	 	#{flagAutomation},
    	 	#{twoAndThreeRemote},
     		#{phoneStyle},
    	 	#{stayOpenArea},
    	 	#{ringNetworkCabinet},
    	 	#{stationDtu},
    		#{status},
    		#{acquisitionStatus},
    		#{constructionStatus},
    		#{whetherCloseStatus},
    		#{earlyMaterial},
    		#{preConstruction}
		)
	</insert>



	<update id="update">
		UPDATE xm_project_details SET
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			bdz_name = #{bdzName},
			line_name = #{lineName},
			require_name = #{requireName},
			project_id = #{projectId},
			project_name = #{projectName},
			project_number = #{projectNumber},
			build_classification_resons = #{bulidClassificationResons},
			bulbid_resons = #{bulbidResons},
			asic_equipment = #{asicEquipment},
			run_the_class = #{runTheClass},
			project_team = #{projectTeam},
			cost_estimate = #{costEstimate},
			whether_rhe_upwind = #{whetherRheUpwind},
			sure_da_date = #{sureDaDate},
			text_remark = #{textRemark},
			power_line = #{powerLine},
			power_scope = #{powerScope},
			project_type = #{projectType},
			power_flag_package = #{powerFlagPackage},
			preliminary_judgment = #{preliminaryJudgment},
			flag_civil_engineering = #{flagCivilEngineering},
			steel_tube_pole = #{steelTubePole},
			flag_approval_planning = #{flagApprovalPlanning},
			equ_create_type = #{equCreateType},
			equ_create_size = #{equCreateSize},
			flag_new_equ_name = #{flagNewEquName},
			include_bdz_news = #{includeBdzNews},
			flag_no_electrical = #{flagNoElectrical},
			drawings_work = #{drawingsWork},
			flag_automation = #{flagAutomation},
			two_and_three_remote = #{twoAndThreeRemote},
			phone_style = #{phoneStyle},
			stay_open_area = #{stayOpenArea},
			ring_network_cabinet = #{ringNetworkCabinet},
			station_dtu = #{stationDtu}
		WHERE id = #{id}
	</update>

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

</mapper>