<?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.BaseAreaMapper">
	
	<resultMap type="BaseArea" id="BaseAreaResult">
		<result property="areaId"	column="area_id"	/>
		<result property="areaCode"	column="area_code"	/>
		<result property="areaDesc"	column="area_desc"	/>
		<result property="regionCode"	column="region_code"	/>
		<result property="whCode"	column="wh_code"	/>
		<result property="instockTranLoc"	column="instock_tran_loc"	/>
		<result property="outstockTranLoc"	column="outstock_tran_loc"	/>
		<result property="pickTranLoc"	column="pick_tran_loc"	/>
		<result property="exSignLocNo"	column="ex_sign_loc_no"	/>
		<result property="frozenLocNo"	column="frozen_loc_no"	/>
		<result property="sapSendSpot"	column="sap_send_spot"	/>
		<result property="areaPoint"	column="area_point"	/>
		<result property="useTray"	column="use_tray"	/>
		<result property="trayMix"	column="tray_mix"	/>
		<result property="instorageStrategy"	column="instorage_strategy"	/>
		<result property="outstorageStrategy"	column="outstorage_strategy"	/>
		<result property="forceOutstorage"	column="force_outstorage"	/>
		<result property="locPickFlag"	column="loc_pick_flag"	/>
		<result property="allocationRule"	column="allocation_rule"	/>
		<result property="gatherLocType"	column="gather_loc_type"	/>
		<result property="priority"	column="priority"	/>
		<result property="userDefined1"	column="user_defined1"	/>
		<result property="userDefined2"	column="user_defined2"	/>
		<result property="userDefined3"	column="user_defined3"	/>
		<result property="createBy"	column="create_by"	/>
		<result property="createTime"	column="create_time"	/>
		<result property="updateBy"	column="update_by"	/>
		<result property="updateTime"	column="update_time"	/>
		<result property="activeFlag"	column="active_flag"	/>
		<result property="remark"	column="remark"	/>
		<result property="factoryCode"	column="factory_code"	/>
	</resultMap>

	<sql id="selectBaseAreaVo">
		select area_id, area_code, area_desc, region_code, wh_code, instock_tran_loc, outstock_tran_loc, pick_tran_loc, ex_sign_loc_no, frozen_loc_no, sap_send_spot, area_point, use_tray, tray_mix, instorage_strategy, outstorage_strategy, force_outstorage, loc_pick_flag, allocation_rule, gather_loc_type, priority, user_defined1, user_defined2, user_defined3, create_by, create_time, update_by, update_time, active_flag, remark, factory_code from base_area
	</sql>

	<select id="selectBaseAreaList" parameterType="BaseArea" resultMap="BaseAreaResult">
		<include refid="selectBaseAreaVo"/>
		<where>  
			<if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
			<if test="areaDesc != null  and areaDesc != ''"> and area_desc = #{areaDesc}</if>
			<if test="regionCode != null  and regionCode != ''"> and region_code = #{regionCode}</if>
			<if test="whCode != null  and whCode != ''"> and wh_code = #{whCode}</if>
			<if test="instockTranLoc != null  and instockTranLoc != ''"> and instock_tran_loc = #{instockTranLoc}</if>
			<if test="outstockTranLoc != null  and outstockTranLoc != ''"> and outstock_tran_loc = #{outstockTranLoc}</if>
			<if test="pickTranLoc != null  and pickTranLoc != ''"> and pick_tran_loc = #{pickTranLoc}</if>
			<if test="exSignLocNo != null  and exSignLocNo != ''"> and ex_sign_loc_no = #{exSignLocNo}</if>
			<if test="frozenLocNo != null  and frozenLocNo != ''"> and frozen_loc_no = #{frozenLocNo}</if>
			<if test="sapSendSpot != null  and sapSendSpot != ''"> and sap_send_spot = #{sapSendSpot}</if>
			<if test="areaPoint != null  and areaPoint != ''"> and area_point = #{areaPoint}</if>
			<if test="useTray != null  and useTray != ''"> and use_tray = #{useTray}</if>
			<if test="trayMix != null  and trayMix != ''"> and tray_mix = #{trayMix}</if>
			<if test="instorageStrategy != null  and instorageStrategy != ''"> and instorage_strategy = #{instorageStrategy}</if>
			<if test="outstorageStrategy != null  and outstorageStrategy != ''"> and outstorage_strategy = #{outstorageStrategy}</if>
			<if test="forceOutstorage != null  and forceOutstorage != ''"> and force_outstorage = #{forceOutstorage}</if>
			<if test="locPickFlag != null  and locPickFlag != ''"> and loc_pick_flag = #{locPickFlag}</if>
			<if test="allocationRule != null  and allocationRule != ''"> and allocation_rule = #{allocationRule}</if>
			<if test="gatherLocType != null  and gatherLocType != ''"> and gather_loc_type = #{gatherLocType}</if>
			<if test="priority != null  and priority != ''"> and priority = #{priority}</if>
			<if test="userDefined1 != null  and userDefined1 != ''"> and user_defined1 = #{userDefined1}</if>
			<if test="userDefined2 != null  and userDefined2 != ''"> and user_defined2 = #{userDefined2}</if>
			<if test="userDefined3 != null  and userDefined3 != ''"> and user_defined3 = #{userDefined3}</if>
			<if test="activeFlag != null  and activeFlag != ''"> and active_flag = #{activeFlag}</if>
			<if test="factoryCode != null  and factoryCode != ''"> and factory_code = #{factoryCode}</if>
		</where>
	</select>
	
	<select id="selectBaseAreaByAreaId" parameterType="String" resultMap="BaseAreaResult">
		<include refid="selectBaseAreaVo"/>
		where area_id = #{areaId}
	</select>
		
	<insert id="insertBaseArea" parameterType="BaseArea">
		insert into base_area
		<trim prefix="(" suffix=")" suffixOverrides=",">
<!--			<if test="areaId != null">area_id,</if>-->
			<if test="areaCode != null and areaCode != ''">area_code,</if>
			<if test="areaDesc != null">area_desc,</if>
			<if test="regionCode != null">region_code,</if>
			<if test="whCode != null">wh_code,</if>
			<if test="instockTranLoc != null">instock_tran_loc,</if>
			<if test="outstockTranLoc != null">outstock_tran_loc,</if>
			<if test="pickTranLoc != null">pick_tran_loc,</if>
			<if test="exSignLocNo != null">ex_sign_loc_no,</if>
			<if test="frozenLocNo != null">frozen_loc_no,</if>
			<if test="sapSendSpot != null">sap_send_spot,</if>
			<if test="areaPoint != null">area_point,</if>
			<if test="useTray != null">use_tray,</if>
			<if test="trayMix != null">tray_mix,</if>
			<if test="instorageStrategy != null">instorage_strategy,</if>
			<if test="outstorageStrategy != null">outstorage_strategy,</if>
			<if test="forceOutstorage != null">force_outstorage,</if>
			<if test="locPickFlag != null">loc_pick_flag,</if>
			<if test="allocationRule != null">allocation_rule,</if>
			<if test="gatherLocType != null">gather_loc_type,</if>
			<if test="priority != null">priority,</if>
			<if test="userDefined1 != null">user_defined1,</if>
			<if test="userDefined2 != null">user_defined2,</if>
			<if test="userDefined3 != null">user_defined3,</if>
			<if test="createBy != null">create_by,</if>
			<if test="createTime != null">create_time,</if>
			<if test="updateBy != null">update_by,</if>
			<if test="updateTime != null">update_time,</if>
			<if test="activeFlag != null">active_flag,</if>
			<if test="remark != null">remark,</if>
			<if test="factoryCode != null">factory_code,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
<!--			<if test="areaId != null">#{areaId},</if>-->
			<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
			<if test="areaDesc != null">#{areaDesc},</if>
			<if test="regionCode != null">#{regionCode},</if>
			<if test="whCode != null">#{whCode},</if>
			<if test="instockTranLoc != null">#{instockTranLoc},</if>
			<if test="outstockTranLoc != null">#{outstockTranLoc},</if>
			<if test="pickTranLoc != null">#{pickTranLoc},</if>
			<if test="exSignLocNo != null">#{exSignLocNo},</if>
			<if test="frozenLocNo != null">#{frozenLocNo},</if>
			<if test="sapSendSpot != null">#{sapSendSpot},</if>
			<if test="areaPoint != null">#{areaPoint},</if>
			<if test="useTray != null">#{useTray},</if>
			<if test="trayMix != null">#{trayMix},</if>
			<if test="instorageStrategy != null">#{instorageStrategy},</if>
			<if test="outstorageStrategy != null">#{outstorageStrategy},</if>
			<if test="forceOutstorage != null">#{forceOutstorage},</if>
			<if test="locPickFlag != null">#{locPickFlag},</if>
			<if test="allocationRule != null">#{allocationRule},</if>
			<if test="gatherLocType != null">#{gatherLocType},</if>
			<if test="priority != null">#{priority},</if>
			<if test="userDefined1 != null">#{userDefined1},</if>
			<if test="userDefined2 != null">#{userDefined2},</if>
			<if test="userDefined3 != null">#{userDefined3},</if>
			<if test="createBy != null">#{createBy},</if>
			<if test="createTime != null">#{createTime},</if>
			<if test="updateBy != null">#{updateBy},</if>
			<if test="updateTime != null">#{updateTime},</if>
			<if test="activeFlag != null">#{activeFlag},</if>
			<if test="remark != null">#{remark},</if>
			<if test="factoryCode != null">#{factoryCode},</if>
		 </trim>
	</insert>

	<update id="updateBaseArea" parameterType="BaseArea">
		update base_area
		<trim prefix="SET" suffixOverrides=",">
			<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
			<if test="areaDesc != null">area_desc = #{areaDesc},</if>
			<if test="regionCode != null">region_code = #{regionCode},</if>
			<if test="whCode != null">wh_code = #{whCode},</if>
			<if test="instockTranLoc != null">instock_tran_loc = #{instockTranLoc},</if>
			<if test="outstockTranLoc != null">outstock_tran_loc = #{outstockTranLoc},</if>
			<if test="pickTranLoc != null">pick_tran_loc = #{pickTranLoc},</if>
			<if test="exSignLocNo != null">ex_sign_loc_no = #{exSignLocNo},</if>
			<if test="frozenLocNo != null">frozen_loc_no = #{frozenLocNo},</if>
			<if test="sapSendSpot != null">sap_send_spot = #{sapSendSpot},</if>
			<if test="areaPoint != null">area_point = #{areaPoint},</if>
			<if test="useTray != null">use_tray = #{useTray},</if>
			<if test="trayMix != null">tray_mix = #{trayMix},</if>
			<if test="instorageStrategy != null">instorage_strategy = #{instorageStrategy},</if>
			<if test="outstorageStrategy != null">outstorage_strategy = #{outstorageStrategy},</if>
			<if test="forceOutstorage != null">force_outstorage = #{forceOutstorage},</if>
			<if test="locPickFlag != null">loc_pick_flag = #{locPickFlag},</if>
			<if test="allocationRule != null">allocation_rule = #{allocationRule},</if>
			<if test="gatherLocType != null">gather_loc_type = #{gatherLocType},</if>
			<if test="priority != null">priority = #{priority},</if>
			<if test="userDefined1 != null">user_defined1 = #{userDefined1},</if>
			<if test="userDefined2 != null">user_defined2 = #{userDefined2},</if>
			<if test="userDefined3 != null">user_defined3 = #{userDefined3},</if>
			<if test="createBy != null">create_by = #{createBy},</if>
			<if test="createTime != null">create_time = #{createTime},</if>
			<if test="updateBy != null">update_by = #{updateBy},</if>
			<if test="updateTime != null">update_time = #{updateTime},</if>
			<if test="activeFlag != null">active_flag = #{activeFlag},</if>
			<if test="remark != null">remark = #{remark},</if>
			<if test="factoryCode != null">factory_code = #{factoryCode},</if>
		</trim>
		where area_id = #{areaId}
	</update>

	<delete id="deleteBaseAreaByAreaId" parameterType="String">
		delete from base_area where area_id = #{areaId}
	</delete>

	<delete id="deleteBaseAreaByAreaIds" parameterType="String">
		delete from base_area where area_id in 
		<foreach item="areaId" collection="array" open="(" separator="," close=")">
			#{areaId}
		</foreach>
	</delete>
    <!--查询总数-->
	<select id="queryCount" parameterType="BaseArea" resultType="java.lang.Integer">
		select count(*)
		from base_area
	</select>

</mapper>