<?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.BaseLocationMapper">
	
	<resultMap type="BaseLocation" id="BaseLocationResult">
		<result property="locationId"	column="location_id"	/>
		<result property="locationCode"	column="location_code"	/>
		<result property="shelfOrder"	column="shelf_order"	/>
		<result property="checkOrder"	column="check_order"	/>
		<result property="pickOrder"	column="pick_order"	/>
		<result property="locationUse"	column="location_use"	/>
		<result property="pickFlag"	column="pick_flag"	/>
		<result property="isOpenKnFlag"	column="is_open_kn_flag"	/>
		<result property="locationType"	column="location_type"	/>
		<result property="locationScrapType"	column="location_scrap_type"	/>
		<result property="locationAttr"	column="location_attr"	/>
		<result property="turnDemand"	column="turn_demand"	/>
		<result property="stockEnv"	column="stock_env"	/>
		<result property="warehouseCode"	column="warehouse_code"	/>
		<result property="regionCode"	column="region_code"	/>
		<result property="areaCode"	column="area_code"	/>
		<result property="checkCode"	column="check_code"	/>
		<result property="workArea"	column="work_area"	/>
		<result property="port1"	column="port1"	/>
		<result property="port2"	column="port2"	/>
		<result property="port3"	column="port3"	/>
		<result property="volumeLimit"	column="volume_limit"	/>
		<result property="weightLimit"	column="weight_limit"	/>
		<result property="boxLimit"	column="box_limit"	/>
		<result property="qtyLimit"	column="qty_limit"	/>
		<result property="palletLimit"	column="pallet_limit"	/>
		<result property="length"	column="length"	/>
		<result property="width"	column="width"	/>
		<result property="height"	column="height"	/>
		<result property="xCoordinate"	column="x_coordinate"	/>
		<result property="yCoordinate"	column="y_coordinate"	/>
		<result property="zCoordinate"	column="z_coordinate"	/>
		<result property="xPixels"	column="x_pixels"	/>
		<result property="yPixels"	column="y_pixels"	/>
		<result property="zPixels"	column="z_pixels"	/>
		<result property="locRow"	column="loc_row"	/>
		<result property="layerNum"	column="layer_num"	/>
		<result property="locColumn"	column="loc_column"	/>
		<result property="bord"	column="bord"	/>
		<result property="productMix"	column="product_mix"	/>
		<result property="batchMix"	column="batch_mix"	/>
		<result property="ignoreId"	column="ignore_id"	/>
		<result property="activeFlag"	column="active_flag"	/>
		<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="remark"	column="remark"	/>
		<result property="factoryCode"	column="factory_code"	/>
		<result property="syntozk"	column="syntozk"	/>
	</resultMap>

	<sql id="selectBaseLocationVo">
		select location_id, location_code, shelf_order, check_order, pick_order, location_use, pick_flag, is_open_kn_flag, location_type, location_scrap_type, location_attr, turn_demand, stock_env, warehouse_code, region_code, area_code, check_code, work_area, port1, port2, port3, volume_limit, weight_limit, box_limit, qty_limit, pallet_limit, length, width, height, x_coordinate, y_coordinate, z_coordinate, x_pixels, y_pixels, z_pixels, loc_row, layer_num, loc_column, bord, product_mix, batch_mix, ignore_id, active_flag, user_defined1, user_defined2, user_defined3, create_by, create_time, update_by, update_time, remark, factory_code, syntozk from base_location
	</sql>

	<select id="selectBaseLocationList" parameterType="BaseLocation" resultMap="BaseLocationResult">
		<include refid="selectBaseLocationVo"/>
		<where>  
			<if test="locationCode != null  and locationCode != ''"> and location_code = #{locationCode}</if>
			<if test="shelfOrder != null  and shelfOrder != ''"> and shelf_order = #{shelfOrder}</if>
			<if test="checkOrder != null  and checkOrder != ''"> and check_order = #{checkOrder}</if>
			<if test="pickOrder != null  and pickOrder != ''"> and pick_order = #{pickOrder}</if>
			<if test="locationUse != null  and locationUse != ''"> and location_use = #{locationUse}</if>
			<if test="pickFlag != null  and pickFlag != ''"> and pick_flag = #{pickFlag}</if>
			<if test="isOpenKnFlag != null  and isOpenKnFlag != ''"> and is_open_kn_flag = #{isOpenKnFlag}</if>
			<if test="locationType != null  and locationType != ''"> and location_type = #{locationType}</if>
			<if test="locationScrapType != null  and locationScrapType != ''"> and location_scrap_type = #{locationScrapType}</if>
			<if test="locationAttr != null  and locationAttr != ''"> and location_attr = #{locationAttr}</if>
			<if test="turnDemand != null  and turnDemand != ''"> and turn_demand = #{turnDemand}</if>
			<if test="stockEnv != null  and stockEnv != ''"> and stock_env = #{stockEnv}</if>
			<if test="warehouseCode != null  and warehouseCode != ''"> and warehouse_code = #{warehouseCode}</if>
			<if test="regionCode != null  and regionCode != ''"> and region_code = #{regionCode}</if>
			<if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
			<if test="checkCode != null  and checkCode != ''"> and check_code = #{checkCode}</if>
			<if test="workArea != null  and workArea != ''"> and work_area = #{workArea}</if>
			<if test="port1 != null  and port1 != ''"> and port1 = #{port1}</if>
			<if test="port2 != null  and port2 != ''"> and port2 = #{port2}</if>
			<if test="port3 != null  and port3 != ''"> and port3 = #{port3}</if>
			<if test="volumeLimit != null "> and volume_limit = #{volumeLimit}</if>
			<if test="weightLimit != null "> and weight_limit = #{weightLimit}</if>
			<if test="boxLimit != null "> and box_limit = #{boxLimit}</if>
			<if test="qtyLimit != null "> and qty_limit = #{qtyLimit}</if>
			<if test="palletLimit != null "> and pallet_limit = #{palletLimit}</if>
			<if test="length != null "> and length = #{length}</if>
			<if test="width != null "> and width = #{width}</if>
			<if test="height != null "> and height = #{height}</if>
			<if test="xCoordinate != null "> and x_coordinate = #{xCoordinate}</if>
			<if test="yCoordinate != null "> and y_coordinate = #{yCoordinate}</if>
			<if test="zCoordinate != null "> and z_coordinate = #{zCoordinate}</if>
			<if test="xPixels != null "> and x_pixels = #{xPixels}</if>
			<if test="yPixels != null "> and y_pixels = #{yPixels}</if>
			<if test="zPixels != null "> and z_pixels = #{zPixels}</if>
			<if test="locRow != null  and locRow != ''"> and loc_row = #{locRow}</if>
			<if test="layerNum != null "> and layer_num = #{layerNum}</if>
			<if test="locColumn != null  and locColumn != ''"> and loc_column = #{locColumn}</if>
			<if test="bord != null  and bord != ''"> and bord = #{bord}</if>
			<if test="productMix != null  and productMix != ''"> and product_mix = #{productMix}</if>
			<if test="batchMix != null  and batchMix != ''"> and batch_mix = #{batchMix}</if>
			<if test="ignoreId != null  and ignoreId != ''"> and ignore_id = #{ignoreId}</if>
			<if test="activeFlag != null  and activeFlag != ''"> and active_flag = #{activeFlag}</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="factoryCode != null  and factoryCode != ''"> and factory_code = #{factoryCode}</if>
			<if test="syntozk != null  and syntozk != ''"> and syntozk = #{syntozk}</if>
		</where>
	</select>
	
	<select id="selectBaseLocationByLocationId" parameterType="String" resultMap="BaseLocationResult">
		<include refid="selectBaseLocationVo"/>
		where location_id = #{locationId}
	</select>
		
	<insert id="insertBaseLocation" parameterType="BaseLocation">
		insert into base_location
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="locationId != null">location_id,</if>
			<if test="locationCode != null and locationCode != ''">location_code,</if>
			<if test="shelfOrder != null">shelf_order,</if>
			<if test="checkOrder != null">check_order,</if>
			<if test="pickOrder != null">pick_order,</if>
			<if test="locationUse != null">location_use,</if>
			<if test="pickFlag != null">pick_flag,</if>
			<if test="isOpenKnFlag != null">is_open_kn_flag,</if>
			<if test="locationType != null">location_type,</if>
			<if test="locationScrapType != null">location_scrap_type,</if>
			<if test="locationAttr != null">location_attr,</if>
			<if test="turnDemand != null">turn_demand,</if>
			<if test="stockEnv != null">stock_env,</if>
			<if test="warehouseCode != null">warehouse_code,</if>
			<if test="regionCode != null">region_code,</if>
			<if test="areaCode != null">area_code,</if>
			<if test="checkCode != null">check_code,</if>
			<if test="workArea != null">work_area,</if>
			<if test="port1 != null">port1,</if>
			<if test="port2 != null">port2,</if>
			<if test="port3 != null">port3,</if>
			<if test="volumeLimit != null">volume_limit,</if>
			<if test="weightLimit != null">weight_limit,</if>
			<if test="boxLimit != null">box_limit,</if>
			<if test="qtyLimit != null">qty_limit,</if>
			<if test="palletLimit != null">pallet_limit,</if>
			<if test="length != null">length,</if>
			<if test="width != null">width,</if>
			<if test="height != null">height,</if>
			<if test="xCoordinate != null">x_coordinate,</if>
			<if test="yCoordinate != null">y_coordinate,</if>
			<if test="zCoordinate != null">z_coordinate,</if>
			<if test="xPixels != null">x_pixels,</if>
			<if test="yPixels != null">y_pixels,</if>
			<if test="zPixels != null">z_pixels,</if>
			<if test="locRow != null">loc_row,</if>
			<if test="layerNum != null">layer_num,</if>
			<if test="locColumn != null">loc_column,</if>
			<if test="bord != null">bord,</if>
			<if test="productMix != null">product_mix,</if>
			<if test="batchMix != null">batch_mix,</if>
			<if test="ignoreId != null">ignore_id,</if>
			<if test="activeFlag != null and activeFlag != ''">active_flag,</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="remark != null">remark,</if>
			<if test="factoryCode != null">factory_code,</if>
			<if test="syntozk != null">syntozk,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="locationId != null">#{locationId},</if>
			<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
			<if test="shelfOrder != null">#{shelfOrder},</if>
			<if test="checkOrder != null">#{checkOrder},</if>
			<if test="pickOrder != null">#{pickOrder},</if>
			<if test="locationUse != null">#{locationUse},</if>
			<if test="pickFlag != null">#{pickFlag},</if>
			<if test="isOpenKnFlag != null">#{isOpenKnFlag},</if>
			<if test="locationType != null">#{locationType},</if>
			<if test="locationScrapType != null">#{locationScrapType},</if>
			<if test="locationAttr != null">#{locationAttr},</if>
			<if test="turnDemand != null">#{turnDemand},</if>
			<if test="stockEnv != null">#{stockEnv},</if>
			<if test="warehouseCode != null">#{warehouseCode},</if>
			<if test="regionCode != null">#{regionCode},</if>
			<if test="areaCode != null">#{areaCode},</if>
			<if test="checkCode != null">#{checkCode},</if>
			<if test="workArea != null">#{workArea},</if>
			<if test="port1 != null">#{port1},</if>
			<if test="port2 != null">#{port2},</if>
			<if test="port3 != null">#{port3},</if>
			<if test="volumeLimit != null">#{volumeLimit},</if>
			<if test="weightLimit != null">#{weightLimit},</if>
			<if test="boxLimit != null">#{boxLimit},</if>
			<if test="qtyLimit != null">#{qtyLimit},</if>
			<if test="palletLimit != null">#{palletLimit},</if>
			<if test="length != null">#{length},</if>
			<if test="width != null">#{width},</if>
			<if test="height != null">#{height},</if>
			<if test="xCoordinate != null">#{xCoordinate},</if>
			<if test="yCoordinate != null">#{yCoordinate},</if>
			<if test="zCoordinate != null">#{zCoordinate},</if>
			<if test="xPixels != null">#{xPixels},</if>
			<if test="yPixels != null">#{yPixels},</if>
			<if test="zPixels != null">#{zPixels},</if>
			<if test="locRow != null">#{locRow},</if>
			<if test="layerNum != null">#{layerNum},</if>
			<if test="locColumn != null">#{locColumn},</if>
			<if test="bord != null">#{bord},</if>
			<if test="productMix != null">#{productMix},</if>
			<if test="batchMix != null">#{batchMix},</if>
			<if test="ignoreId != null">#{ignoreId},</if>
			<if test="activeFlag != null and activeFlag != ''">#{activeFlag},</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="remark != null">#{remark},</if>
			<if test="factoryCode != null">#{factoryCode},</if>
			<if test="syntozk != null">#{syntozk},</if>
		 </trim>
	</insert>

	<update id="updateBaseLocation" parameterType="BaseLocation">
		update base_location
		<trim prefix="SET" suffixOverrides=",">
			<if test="locationCode != null and locationCode != ''">location_code = #{locationCode},</if>
			<if test="shelfOrder != null">shelf_order = #{shelfOrder},</if>
			<if test="checkOrder != null">check_order = #{checkOrder},</if>
			<if test="pickOrder != null">pick_order = #{pickOrder},</if>
			<if test="locationUse != null">location_use = #{locationUse},</if>
			<if test="pickFlag != null">pick_flag = #{pickFlag},</if>
			<if test="isOpenKnFlag != null">is_open_kn_flag = #{isOpenKnFlag},</if>
			<if test="locationType != null">location_type = #{locationType},</if>
			<if test="locationScrapType != null">location_scrap_type = #{locationScrapType},</if>
			<if test="locationAttr != null">location_attr = #{locationAttr},</if>
			<if test="turnDemand != null">turn_demand = #{turnDemand},</if>
			<if test="stockEnv != null">stock_env = #{stockEnv},</if>
			<if test="warehouseCode != null">warehouse_code = #{warehouseCode},</if>
			<if test="regionCode != null">region_code = #{regionCode},</if>
			<if test="areaCode != null">area_code = #{areaCode},</if>
			<if test="checkCode != null">check_code = #{checkCode},</if>
			<if test="workArea != null">work_area = #{workArea},</if>
			<if test="port1 != null">port1 = #{port1},</if>
			<if test="port2 != null">port2 = #{port2},</if>
			<if test="port3 != null">port3 = #{port3},</if>
			<if test="volumeLimit != null">volume_limit = #{volumeLimit},</if>
			<if test="weightLimit != null">weight_limit = #{weightLimit},</if>
			<if test="boxLimit != null">box_limit = #{boxLimit},</if>
			<if test="qtyLimit != null">qty_limit = #{qtyLimit},</if>
			<if test="palletLimit != null">pallet_limit = #{palletLimit},</if>
			<if test="length != null">length = #{length},</if>
			<if test="width != null">width = #{width},</if>
			<if test="height != null">height = #{height},</if>
			<if test="xCoordinate != null">x_coordinate = #{xCoordinate},</if>
			<if test="yCoordinate != null">y_coordinate = #{yCoordinate},</if>
			<if test="zCoordinate != null">z_coordinate = #{zCoordinate},</if>
			<if test="xPixels != null">x_pixels = #{xPixels},</if>
			<if test="yPixels != null">y_pixels = #{yPixels},</if>
			<if test="zPixels != null">z_pixels = #{zPixels},</if>
			<if test="locRow != null">loc_row = #{locRow},</if>
			<if test="layerNum != null">layer_num = #{layerNum},</if>
			<if test="locColumn != null">loc_column = #{locColumn},</if>
			<if test="bord != null">bord = #{bord},</if>
			<if test="productMix != null">product_mix = #{productMix},</if>
			<if test="batchMix != null">batch_mix = #{batchMix},</if>
			<if test="ignoreId != null">ignore_id = #{ignoreId},</if>
			<if test="activeFlag != null and activeFlag != ''">active_flag = #{activeFlag},</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="remark != null">remark = #{remark},</if>
			<if test="factoryCode != null">factory_code = #{factoryCode},</if>
			<if test="syntozk != null">syntozk = #{syntozk},</if>
		</trim>
		where location_id = #{locationId}
	</update>

	<delete id="deleteBaseLocationByLocationId" parameterType="String">
		delete from base_location where location_id = #{locationId}
	</delete>

	<delete id="deleteBaseLocationByLocationIds" parameterType="String">
		delete from base_location where location_id in 
		<foreach item="locationId" collection="array" open="(" separator="," close=")">
			#{locationId}
		</foreach>
	</delete>
</mapper>