<?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.op.wms.mapper.BaseTeamTMapper">
	
	<resultMap type="BaseTeamT" id="BaseTeamTResult">
		<result property="teamId"	column="Team_Id"	/>
		<result property="orgId"	column="ORG_Id"	/>
		<result property="teamCode"	column="Team_Code"	/>
		<result property="teamDesc"	column="Team_Desc"	/>
		<result property="teamDescGlobal"	column="Team_Desc_Global"	/>
		<result property="teamDescExtended"	column="Team_Desc_Extended"	/>
		<result property="createBy"	column="Create_By"	/>
		<result property="createDate"	column="Create_Date"	/>
		<result property="lastUpdateBy"	column="Last_Update_By"	/>
		<result property="lastUpdateDate"	column="Last_Update_Date"	/>
		<result property="Active"	column="Active"	/>
		<result property="enterpriseId"	column="Enterprise_Id"	/>
		<result property="enterpriseCode"	column="Enterprise_Code"	/>
		<result property="siteId"	column="Site_Id"	/>
		<result property="siteCode"	column="Site_Code"	/>
		<result property="productionLineCode"	column="production_line_code"	/>
		<result property="teamLeaderCode"	column="team_leader_code"	/>
		<result property="planPostQuantity"	column="plan_post_quantity"	/>
		<result property="actualPostQuantity"	column="actual_post_quantity"	/>
		<result property="salaryType"	column="salary_type"	/>
		<result property="teamProperties"	column="team_properties"	/>
		<result property="attendanceQuantity"	column="attendance_quantity"	/>
		<result property="assignedQuantity"	column="assigned_quantity"	/>
		<result property="teamType"	column="team_type"	/>
	</resultMap>

	<sql id="selectBaseTeamTVo">
		select Team_Id, ORG_Id, Team_Code, Team_Desc, Team_Desc_Global, Team_Desc_Extended, Create_By, Create_Date, Last_Update_By, Last_Update_Date, Active, Enterprise_Id, Enterprise_Code, Site_Id, Site_Code, production_line_code, team_leader_code, plan_post_quantity, actual_post_quantity, salary_type, team_properties, attendance_quantity, assigned_quantity ,team_type from base_team_t
	</sql>

	<select id="selectBaseTeamTList" parameterType="BaseTeamT" resultMap="BaseTeamTResult">
		<include refid="selectBaseTeamTVo"/>
		<where>  
			<if test="orgId != null  and orgId != ''"> and ORG_Id = #{orgId}</if>
			<if test="teamCode != null  and teamCode != ''"> and Team_Code = #{teamCode}</if>
			<if test="teamDesc != null  and teamDesc != ''"> and Team_Desc = #{teamDesc}</if>
			<if test="teamDescGlobal != null  and teamDescGlobal != ''"> and Team_Desc_Global = #{teamDescGlobal}</if>
			<if test="teamDescExtended != null  and teamDescExtended != ''"> and Team_Desc_Extended = #{teamDescExtended}</if>
			<if test="createBy != null  and createBy != ''"> and Create_By = #{createBy}</if>
			<if test="createDate != null "> and Create_Date = #{createDate}</if>
			<if test="lastUpdateBy != null  and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
			<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
			<if test="Active != null  and Active != ''"> and Active = #{Active}</if>
			<if test="enterpriseId != null  and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
			<if test="enterpriseCode != null  and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
			<if test="siteId != null  and siteId != ''"> and Site_Id = #{siteId}</if>
			<if test="siteCode != null  and siteCode != ''"> and Site_Code = #{siteCode}</if>
			<if test="productionLineCode != null  and productionLineCode != ''"> and production_line_code = #{productionLineCode}</if>
			<if test="teamLeaderCode != null  and teamLeaderCode != ''"> and team_leader_code = #{teamLeaderCode}</if>
			<if test="planPostQuantity != null "> and plan_post_quantity = #{planPostQuantity}</if>
			<if test="actualPostQuantity != null "> and actual_post_quantity = #{actualPostQuantity}</if>
			<if test="salaryType != null  and salaryType != ''"> and salary_type = #{salaryType}</if>
			<if test="teamProperties != null  and teamProperties != ''"> and team_properties = #{teamProperties}</if>
			<if test="attendanceQuantity != null "> and attendance_quantity = #{attendanceQuantity}</if>
			<if test="assignedQuantity != null "> and assigned_quantity = #{assignedQuantity}</if>
			<if test="teamType != null "> and team_type = #{teamType}</if>
		</where>
	</select>
	
	<select id="selectBaseTeamTByTeamId" parameterType="String" resultMap="BaseTeamTResult">
		<include refid="selectBaseTeamTVo"/>
		where Team_Id = #{teamId}
	</select>
		
	<insert id="insertBaseTeamT" parameterType="BaseTeamT">
		insert into base_team_t
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="teamId != null">Team_Id,</if>
			<if test="orgId != null">ORG_Id,</if>
			<if test="teamCode != null">Team_Code,</if>
			<if test="teamDesc != null">Team_Desc,</if>
			<if test="teamDescGlobal != null">Team_Desc_Global,</if>
			<if test="teamDescExtended != null">Team_Desc_Extended,</if>
			<if test="createBy != null">Create_By,</if>
			<if test="createDate != null">Create_Date,</if>
			<if test="lastUpdateBy != null">Last_Update_By,</if>
			<if test="lastUpdateDate != null">Last_Update_Date,</if>
			<if test="Active != null">Active,</if>
			<if test="enterpriseId != null">Enterprise_Id,</if>
			<if test="enterpriseCode != null">Enterprise_Code,</if>
			<if test="siteId != null">Site_Id,</if>
			<if test="siteCode != null">Site_Code,</if>
			<if test="productionLineCode != null">production_line_code,</if>
			<if test="teamLeaderCode != null">team_leader_code,</if>
			<if test="planPostQuantity != null">plan_post_quantity,</if>
			<if test="actualPostQuantity != null">actual_post_quantity,</if>
			<if test="salaryType != null">salary_type,</if>
			<if test="teamProperties != null">team_properties,</if>
			<if test="attendanceQuantity != null">attendance_quantity,</if>
			<if test="assignedQuantity != null">assigned_quantity,</if>
			<if test="teamType != null">team_type,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="teamId != null">#{teamId},</if>
			<if test="orgId != null">#{orgId},</if>
			<if test="teamCode != null">#{teamCode},</if>
			<if test="teamDesc != null">#{teamDesc},</if>
			<if test="teamDescGlobal != null">#{teamDescGlobal},</if>
			<if test="teamDescExtended != null">#{teamDescExtended},</if>
			<if test="createBy != null">#{createBy},</if>
			<if test="createDate != null">#{createDate},</if>
			<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
			<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
			<if test="Active != null">#{Active},</if>
			<if test="enterpriseId != null">#{enterpriseId},</if>
			<if test="enterpriseCode != null">#{enterpriseCode},</if>
			<if test="siteId != null">#{siteId},</if>
			<if test="siteCode != null">#{siteCode},</if>
			<if test="productionLineCode != null">#{productionLineCode},</if>
			<if test="teamLeaderCode != null">#{teamLeaderCode},</if>
			<if test="planPostQuantity != null">#{planPostQuantity},</if>
			<if test="actualPostQuantity != null">#{actualPostQuantity},</if>
			<if test="salaryType != null">#{salaryType},</if>
			<if test="teamProperties != null">#{teamProperties},</if>
			<if test="attendanceQuantity != null">#{attendanceQuantity},</if>
			<if test="assignedQuantity != null">#{assignedQuantity},</if>
			<if test="teamType != null">#{teamType},</if>
		 </trim>
	</insert>

	<update id="updateBaseTeamT" parameterType="BaseTeamT">
		update base_team_t
		<trim prefix="SET" suffixOverrides=",">
			<if test="orgId != null">ORG_Id = #{orgId},</if>
			<if test="teamCode != null">Team_Code = #{teamCode},</if>
			<if test="teamDesc != null">Team_Desc = #{teamDesc},</if>
			<if test="teamDescGlobal != null">Team_Desc_Global = #{teamDescGlobal},</if>
			<if test="teamDescExtended != null">Team_Desc_Extended = #{teamDescExtended},</if>
			<if test="createBy != null">Create_By = #{createBy},</if>
			<if test="createDate != null">Create_Date = #{createDate},</if>
			<if test="lastUpdateBy != null">Last_Update_By = #{lastUpdateBy},</if>
			<if test="lastUpdateDate != null">Last_Update_Date = #{lastUpdateDate},</if>
			<if test="Active != null">Active = #{Active},</if>
			<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
			<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
			<if test="siteId != null">Site_Id = #{siteId},</if>
			<if test="siteCode != null">Site_Code = #{siteCode},</if>
			<if test="productionLineCode != null">production_line_code = #{productionLineCode},</if>
			<if test="teamLeaderCode != null">team_leader_code = #{teamLeaderCode},</if>
			<if test="planPostQuantity != null">plan_post_quantity = #{planPostQuantity},</if>
			<if test="actualPostQuantity != null">actual_post_quantity = #{actualPostQuantity},</if>
			<if test="salaryType != null">salary_type = #{salaryType},</if>
			<if test="teamProperties != null">team_properties = #{teamProperties},</if>
			<if test="attendanceQuantity != null">attendance_quantity = #{attendanceQuantity},</if>
			<if test="assignedQuantity != null">assigned_quantity = #{assignedQuantity},</if>
			<if test="teamType != null ">team_type = #{teamType},</if>
		</trim>
		where Team_Id = #{teamId}
	</update>

	<delete id="deleteBaseTeamTByTeamId" parameterType="String">
		delete from base_team_t where Team_Id = #{teamId}
	</delete>

	<delete id="deleteBaseTeamTByTeamIds" parameterType="String">
		delete from base_team_t where Team_Id in 
		<foreach item="teamId" collection="array" open="(" separator="," close=")">
			#{teamId}
		</foreach>
	</delete>
</mapper>