<?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.hw.wms.mapper.WmsRawOutstockMapper" >
<resultMap type= "WmsRawOutstock" id= "WmsRawOutstockResult" >
<result property= "rawOutstockId" column= "raw_outstock_id" />
<result property= "taskCode" column= "task_code" />
<result property= "warehouseId" column= "warehouse_id" />
<result property= "locationCode" column= "location_code" />
<result property= "orderId" column= "order_id" />
<result property= "planId" column= "plan_id" />
<result property= "planDetailId" column= "plan_detail_id" />
<result property= "stationId" column= "station_id" />
<result property= "productId" column= "product_id" />
<result property= "operationType" column= "operation_type" />
<result property= "taskType" column= "task_type" />
<result property= "applyReason" column= "apply_reason" />
<result property= "auditReason" column= "audit_reason" />
<result property= "auditStatus" column= "audit_status" />
<result property= "executeStatus" column= "execute_status" />
<result property= "applyBy" column= "apply_by" />
<result property= "applyDate" column= "apply_date" />
<result property= "auditBy" column= "audit_by" />
<result property= "auditDate" column= "audit_date" />
<result property= "updateBy" column= "update_by" />
<result property= "updateDate" column= "update_date" />
<result property= "beginTime" column= "begin_time" />
<result property= "endTime" column= "end_time" />
<result property= "warehouseName" column= "warehouse_name" />
</resultMap>
<resultMap id= "WmsRawOutstockWmsRawOutstockDetailResult" type= "WmsRawOutstock" extends= "WmsRawOutstockResult" >
<collection property= "wmsRawOutstockDetailList" notNullColumn= "sub_raw_outstock_detail_id" javaType= "java.util.List" resultMap= "WmsRawOutstockDetailResult" />
</resultMap>
<resultMap type= "WmsRawOutstockDetail" id= "WmsRawOutstockDetailResult" >
<result property= "rawOutstockDetailId" column= "sub_raw_outstock_detail_id" />
<result property= "rawOutstockId" column= "sub_raw_outstock_id" />
<result property= "locationCode" column= "sub_location_code" />
<result property= "materialBarcode" column= "sub_material_barcode" />
<result property= "materialId" column= "sub_material_id" />
<result property= "instockBatch" column= "sub_instock_batch" />
<result property= "materialProductionDate" column= "sub_material_production_Date" />
<result property= "planAmount" column= "sub_plan_amount" />
<result property= "outstockAmount" column= "sub_outstock_amount" />
<result property= "executeStatus" column= "sub_execute_status" />
<result property= "erpStatus" column= "sub_erp_status" />
<result property= "outstockPerson" column= "sub_outstock_person" />
<result property= "outstockTime" column= "sub_outstock_time" />
<result property= "outstockWay" column= "sub_outstock_way" />
<result property= "machineName" column= "sub_machine_name" />
<result property= "qualityStatus" column= "sub_quality_status" />
<result property= "createBy" column= "sub_create_by" />
<result property= "createDate" column= "sub_create_date" />
<result property= "updateBy" column= "sub_update_by" />
<result property= "updateDate" column= "sub_update_date" />
<result property= "stackAmount" column= "sub_stack_amount" />
</resultMap>
<sql id= "selectWmsRawOutstockVo" >
select raw_outstock_id, task_code, warehouse_id, location_code, order_id, plan_id, plan_detail_id, station_id, product_id, operation_type, task_type, apply_reason, audit_reason, audit_status, execute_status, apply_by, apply_date, audit_by, audit_date, update_by, update_date, begin_time, end_time from wms_raw_outstock
</sql>
<select id= "selectWmsRawOutstockList" parameterType= "WmsRawOutstock" resultMap= "WmsRawOutstockResult" >
<include refid= "selectWmsRawOutstockVo" />
<where >
<if test= "taskCode != null and taskCode != ''" > and task_code = #{taskCode}</if>
<if test= "warehouseId != null " > and warehouse_id = #{warehouseId}</if>
<if test= "locationCode != null and locationCode != ''" > and location_code = #{locationCode}</if>
<if test= "orderId != null " > and order_id = #{orderId}</if>
<if test= "planId != null " > and plan_id = #{planId}</if>
<if test= "planDetailId != null " > and plan_detail_id = #{planDetailId}</if>
<if test= "stationId != null " > and station_id = #{stationId}</if>
<if test= "productId != null " > and product_id = #{productId}</if>
<if test= "operationType != null and operationType != ''" > and operation_type = #{operationType}</if>
<if test= "taskType != null and taskType != ''" > and task_type = #{taskType}</if>
<if test= "applyReason != null and applyReason != ''" > and apply_reason = #{applyReason}</if>
<if test= "auditReason != null and auditReason != ''" > and audit_reason = #{auditReason}</if>
<if test= "auditStatus != null and auditStatus != ''" > and audit_status = #{auditStatus}</if>
<if test= "executeStatus != null and executeStatus != ''" > and execute_status = #{executeStatus}</if>
<if test= "applyBy != null and applyBy != ''" > and apply_by = #{applyBy}</if>
<if test= "applyDate != null " > and apply_date = #{applyDate}</if>
<if test= "auditBy != null and auditBy != ''" > and audit_by = #{auditBy}</if>
<if test= "auditDate != null " > and audit_date = #{auditDate}</if>
<if test= "updateDate != null " > and update_date = #{updateDate}</if>
<if test= "beginTime != null " > and begin_time = #{beginTime}</if>
<if test= "endTime != null " > and end_time = #{endTime}</if>
</where>
</select>
<select id= "selectWmsRawOutstockByRawOutstockId" parameterType= "Long" resultMap= "WmsRawOutstockWmsRawOutstockDetailResult" >
select a.raw_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.order_id, a.plan_id, a.plan_detail_id, a.station_id, a.product_id, a.operation_type, a.task_type, a.apply_reason, a.audit_reason, a.audit_status, a.execute_status, a.apply_by, a.apply_date, a.audit_by, a.audit_date, a.update_by, a.update_date, a.begin_time, a.end_time,
b.raw_outstock_detail_id as sub_raw_outstock_detail_id, b.raw_outstock_id as sub_raw_outstock_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.material_id as sub_material_id, b.instock_batch as sub_instock_batch, b.material_production_Date as sub_material_production_Date, b.plan_amount as sub_plan_amount, b.outstock_amount as sub_outstock_amount, b.execute_status as sub_execute_status, b.erp_status as sub_erp_status, b.outstock_person as sub_outstock_person, b.outstock_time as sub_outstock_time, b.outstock_way as sub_outstock_way, b.machine_name as sub_machine_name, b.quality_status as sub_quality_status, b.create_by as sub_create_by, b.create_date as sub_create_date, b.update_by as sub_update_by, b.update_date as sub_update_date, b.stack_amount as sub_stack_amount
from wms_raw_outstock a
left join wms_raw_outstock_detail b on b.raw_outstock_id = a.raw_outstock_id
where a.raw_outstock_id = #{rawOutstockId}
</select>
<insert id= "insertWmsRawOutstock" parameterType= "WmsRawOutstock" useGeneratedKeys= "true" keyProperty= "rawOutstockId" >
insert into wms_raw_outstock
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "taskCode != null and taskCode != ''" > task_code,</if>
<if test= "warehouseId != null" > warehouse_id,</if>
<if test= "locationCode != null" > location_code,</if>
<if test= "orderId != null" > order_id,</if>
<if test= "planId != null" > plan_id,</if>
<if test= "planDetailId != null" > plan_detail_id,</if>
<if test= "stationId != null" > station_id,</if>
<if test= "productId != null" > product_id,</if>
<if test= "operationType != null" > operation_type,</if>
<if test= "taskType != null" > task_type,</if>
<if test= "applyReason != null" > apply_reason,</if>
<if test= "auditReason != null" > audit_reason,</if>
<if test= "auditStatus != null" > audit_status,</if>
<if test= "executeStatus != null" > execute_status,</if>
<if test= "applyBy != null" > apply_by,</if>
<if test= "applyDate != null" > apply_date,</if>
<if test= "auditBy != null" > audit_by,</if>
<if test= "auditDate != null" > audit_date,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateDate != null" > update_date,</if>
<if test= "beginTime != null" > begin_time,</if>
<if test= "endTime != null" > end_time,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "taskCode != null and taskCode != ''" > #{taskCode},</if>
<if test= "warehouseId != null" > #{warehouseId},</if>
<if test= "locationCode != null" > #{locationCode},</if>
<if test= "orderId != null" > #{orderId},</if>
<if test= "planId != null" > #{planId},</if>
<if test= "planDetailId != null" > #{planDetailId},</if>
<if test= "stationId != null" > #{stationId},</if>
<if test= "productId != null" > #{productId},</if>
<if test= "operationType != null" > #{operationType},</if>
<if test= "taskType != null" > #{taskType},</if>
<if test= "applyReason != null" > #{applyReason},</if>
<if test= "auditReason != null" > #{auditReason},</if>
<if test= "auditStatus != null" > #{auditStatus},</if>
<if test= "executeStatus != null" > #{executeStatus},</if>
<if test= "applyBy != null" > #{applyBy},</if>
<if test= "applyDate != null" > #{applyDate},</if>
<if test= "auditBy != null" > #{auditBy},</if>
<if test= "auditDate != null" > #{auditDate},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateDate != null" > #{updateDate},</if>
<if test= "beginTime != null" > #{beginTime},</if>
<if test= "endTime != null" > #{endTime},</if>
</trim>
</insert>
<update id= "updateWmsRawOutstock" parameterType= "WmsRawOutstock" >
update wms_raw_outstock
<trim prefix= "SET" suffixOverrides= "," >
<if test= "taskCode != null and taskCode != ''" > task_code = #{taskCode},</if>
<if test= "warehouseId != null" > warehouse_id = #{warehouseId},</if>
<if test= "locationCode != null" > location_code = #{locationCode},</if>
<if test= "orderId != null" > order_id = #{orderId},</if>
<if test= "planId != null" > plan_id = #{planId},</if>
<if test= "planDetailId != null" > plan_detail_id = #{planDetailId},</if>
<if test= "stationId != null" > station_id = #{stationId},</if>
<if test= "productId != null" > product_id = #{productId},</if>
<if test= "operationType != null" > operation_type = #{operationType},</if>
<if test= "taskType != null" > task_type = #{taskType},</if>
<if test= "applyReason != null" > apply_reason = #{applyReason},</if>
<if test= "auditReason != null" > audit_reason = #{auditReason},</if>
<if test= "auditStatus != null" > audit_status = #{auditStatus},</if>
<if test= "executeStatus != null" > execute_status = #{executeStatus},</if>
<if test= "applyBy != null" > apply_by = #{applyBy},</if>
<if test= "applyDate != null" > apply_date = #{applyDate},</if>
<if test= "auditBy != null" > audit_by = #{auditBy},</if>
<if test= "auditDate != null" > audit_date = #{auditDate},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateDate != null" > update_date = #{updateDate},</if>
<if test= "beginTime != null" > begin_time = #{beginTime},</if>
<if test= "endTime != null" > end_time = #{endTime},</if>
</trim>
where raw_outstock_id = #{rawOutstockId}
</update>
<delete id= "deleteWmsRawOutstockByRawOutstockId" parameterType= "Long" >
delete from wms_raw_outstock where raw_outstock_id = #{rawOutstockId}
</delete>
<delete id= "deleteWmsRawOutstockByRawOutstockIds" parameterType= "String" >
delete from wms_raw_outstock where raw_outstock_id in
<foreach item= "rawOutstockId" collection= "array" open= "(" separator= "," close= ")" >
#{rawOutstockId}
</foreach>
</delete>
<delete id= "deleteWmsRawOutstockDetailByRawOutstockIds" parameterType= "String" >
delete from wms_raw_outstock_detail where raw_outstock_id in
<foreach item= "rawOutstockId" collection= "array" open= "(" separator= "," close= ")" >
#{rawOutstockId}
</foreach>
</delete>
<delete id= "deleteWmsRawOutstockDetailByRawOutstockId" parameterType= "Long" >
delete from wms_raw_outstock_detail where raw_outstock_id = #{rawOutstockId}
</delete>
<insert id= "batchWmsRawOutstockDetail" >
insert into wms_raw_outstock_detail( raw_outstock_detail_id, raw_outstock_id, location_code, material_barcode, material_id, instock_batch, material_production_Date, plan_amount, outstock_amount, execute_status, erp_status, outstock_person, outstock_time, outstock_way, machine_name, quality_status, create_by, create_date, update_by, update_date, stack_amount) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.rawOutstockDetailId}, #{item.rawOutstockId}, #{item.locationCode}, #{item.materialBarcode}, #{item.materialId}, #{item.instockBatch}, #{item.materialProductionDate}, #{item.planAmount}, #{item.outstockAmount}, #{item.executeStatus}, #{item.erpStatus}, #{item.outstockPerson}, #{item.outstockTime}, #{item.outstockWay}, #{item.machineName}, #{item.qualityStatus}, #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate}, #{item.stackAmount})
</foreach>
</insert>
<select id= "selectWmsRawOutstockJoinList" parameterType= "WmsRawOutstock" resultMap= "WmsRawOutstockResult" >
select wro.raw_outstock_id, wro.task_code, wro.warehouse_id, wro.location_code, wro.order_id, wro.plan_id, wro.plan_detail_id, wro.station_id,
wro.product_id, wro.operation_type, wro.task_type, wro.apply_reason, wro.audit_reason, wro.audit_status, wro.execute_status, wro.apply_by, wro.apply_date,
wro.audit_by, wro.audit_date, wro.update_by, wro.update_date, wro.begin_time, wro.end_time,wbw.warehouse_name
from wms_raw_outstock wro left join wms_base_warehouse wbw on wro.warehouse_id = wbw.warehouse_id
<where >
<if test= "auditStatus != null and auditStatus != ''" > and wro.audit_status = #{auditStatus}</if>
</where>
</select>
</mapper>