You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

308 lines
18 KiB
XML

<?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.WmsRawInstockMapper">
<resultMap type="WmsRawInstock" id="WmsRawInstockResult">
<result property="rawInstockId" column="raw_instock_id" />
<result property="taskCode" column="task_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="locationCode" column="location_code" />
<result property="purchaseOrderId" column="purchase_order_id" />
<result property="poNo" column="po_no" />
<result property="operationType" column="operation_type" />
<result property="instockType" column="instock_type" />
<result property="materialId" column="material_id" />
<result property="materialBarcode" column="material_barcode" />
<result property="materialBatchCode" column="material_batch_code" />
<result property="palletInfoCode" column="pallet_info_code" />
<result property="instockAmount" column="instock_amount" />
<result property="executeStatus" column="execute_status" />
<result property="returnFlag" column="return_flag" />
<result property="planDetailCode" column="plan_detail_code" />
<result property="erpStatus" column="erp_status" />
<result property="erpAmount" column="erp_amount" />
<result property="applyBy" column="apply_by" />
<result property="applyDate" column="apply_date" />
<result property="machineName" column="machine_name" />
<result property="qualityStatus" column="quality_status" />
<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="rawReturnId" column="raw_return_id" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="unitCode" column="unit_code" />
<result property="warehouseCode" column="warehouse_code" />
<result property="specificationParameter" column="specification_parameter" />
<result property="srcBillNo" column="src_bill_no" />
</resultMap>
<sql id="selectWmsRawInstockVo">
select raw_instock_id, task_code, warehouse_id, location_code, po_no, operation_type, instock_type, material_id, material_barcode, material_batch_code, pallet_info_code, instock_amount, execute_status, erp_status, erp_amount, apply_by, apply_date, machine_name, quality_status, update_by, update_date, begin_time, end_time from wms_raw_instock
</sql>
<select id="selectWmsRawInstockList" parameterType="WmsRawInstock" resultMap="WmsRawInstockResult">
<include refid="selectWmsRawInstockVo"/>
<where>
<if test="taskCode != null and taskCode != ''"> and task_code = #{taskCode}</if>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="materialBarcode != null and materialBarcode != ''"> and material_barcode = #{materialBarcode}</if>
<if test="locationCode != null and locationCode != ''"> and location_code = #{locationCode}</if>
<if test="poNo != null and poNo != ''"> and po_no = #{poNo}</if>
<if test="operationType != null and operationType != ''"> and operation_type = #{operationType}</if>
<if test="instockType != null and instockType != ''"> and instock_type = #{instockType}</if>
<if test="executeStatus != null and executeStatus != ''"> and execute_status = #{executeStatus}</if>
<if test="returnFlag != null and returnFlag != ''"> and return_flag = #{returnFlag}</if>
<if test="planDetailCode != null and planDetailCode != ''"> and plan_detail_code = #{planDetailCode}</if>
<if test="applyBy != null and applyBy != ''"> and apply_by = #{applyBy}</if>
<if test="applyDate != null "> and apply_date = #{applyDate}</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="selectWmsRawInstockByRawInstockId" parameterType="Long" resultMap="WmsRawInstockResult">
<include refid="selectWmsRawInstockVo"/>
where raw_instock_id = #{rawInstockId}
</select>
<insert id="insertWmsRawInstock" parameterType="WmsRawInstock" useGeneratedKeys="true" keyProperty="rawInstockId">
insert into wms_raw_instock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskCode != null">task_code,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="locationCode != null">location_code,</if>
<if test="purchaseOrderId != null">purchase_order_id,</if>
<if test="poNo != null">po_no,</if>
<if test="operationType != null and operationType != ''">operation_type,</if>
<if test="instockType != null and instockType != ''">instock_type,</if>
<if test="materialId != null">material_id,</if>
<if test="materialBarcode != null">material_barcode,</if>
<if test="materialBatchCode != null">material_batch_code,</if>
<if test="palletInfoCode != null">pallet_info_code,</if>
<if test="instockAmount != null">instock_amount,</if>
<if test="executeStatus != null and executeStatus != ''">execute_status,</if>
<if test="returnFlag != null and returnFlag != ''">return_flag,</if>
<if test="planDetailCode != null and planDetailCode != ''">plan_detail_code,</if>
<if test="erpStatus != null">erp_status,</if>
<if test="erpAmount != null">erp_amount,</if>
<if test="applyBy != null">apply_by,</if>
<if test="applyDate != null">apply_date,</if>
<if test="machineName != null">machine_name,</if>
<if test="qualityStatus != null">quality_status,</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">#{taskCode},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="locationCode != null">#{locationCode},</if>
<if test="purchaseOrderId != null">#{purchaseOrderId},</if>
<if test="poNo != null">#{poNo},</if>
<if test="operationType != null and operationType != ''">#{operationType},</if>
<if test="instockType != null and instockType != ''">#{instockType},</if>
<if test="materialId != null">#{materialId},</if>
<if test="materialBarcode != null">#{materialBarcode},</if>
<if test="materialBatchCode != null">#{materialBatchCode},</if>
<if test="palletInfoCode != null">#{palletInfoCode},</if>
<if test="instockAmount != null">#{instockAmount},</if>
<if test="executeStatus != null and executeStatus != ''">#{executeStatus},</if>
<if test="returnFlag != null and returnFlag != ''">#{returnFlag},</if>
<if test="planDetailCode != null and planDetailCode != ''">#{planDetailCode},</if>
<if test="erpStatus != null">#{erpStatus},</if>
<if test="erpAmount != null">#{erpAmount},</if>
<if test="applyBy != null">#{applyBy},</if>
<if test="applyDate != null">#{applyDate},</if>
<if test="machineName != null">#{machineName},</if>
<if test="qualityStatus != null">#{qualityStatus},</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="updateWmsRawInstock" parameterType="WmsRawInstock">
update wms_raw_instock
<trim prefix="SET" suffixOverrides=",">
<if test="taskCode != null">task_code = #{taskCode},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="locationCode != null">location_code = #{locationCode},</if>
<if test="poNo != null">po_no = #{poNo},</if>
<if test="operationType != null and operationType != ''">operation_type = #{operationType},</if>
<if test="instockType != null and instockType != ''">instock_type = #{instockType},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="materialBarcode != null">material_barcode = #{materialBarcode},</if>
<if test="materialBatchCode != null">material_batch_code = #{materialBatchCode},</if>
<if test="palletInfoCode != null">pallet_info_code = #{palletInfoCode},</if>
<if test="instockAmount != null">instock_amount = #{instockAmount},</if>
<if test="executeStatus != null and executeStatus != ''">execute_status = #{executeStatus},</if>
<if test="erpStatus != null">erp_status = #{erpStatus},</if>
<if test="erpAmount != null">erp_amount = #{erpAmount},</if>
<if test="applyBy != null">apply_by = #{applyBy},</if>
<if test="applyDate != null">apply_date = #{applyDate},</if>
<if test="machineName != null">machine_name = #{machineName},</if>
<if test="qualityStatus != null">quality_status = #{qualityStatus},</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_instock_id = #{rawInstockId}
</update>
<delete id="deleteWmsRawInstockByRawInstockId" parameterType="Long">
delete from wms_raw_instock where raw_instock_id = #{rawInstockId}
</delete>
<delete id="deleteWmsRawInstockByRawInstockIds" parameterType="String">
delete from wms_raw_instock where raw_instock_id in
<foreach item="rawInstockId" collection="array" open="(" separator="," close=")">
#{rawInstockId}
</foreach>
</delete>
<select id="selectWmsRawInstockByBarcode" parameterType="String" resultMap="WmsRawInstockResult">
<include refid="selectWmsRawInstockVo"/>
where material_barcode = #{materialBarcode}
</select>
<select id="selectWmsRawInstockJoinList" parameterType="WmsRawInstock" resultMap="WmsRawInstockResult">
select wri.task_code, wri.warehouse_id, wri.location_code, wri.po_no, wri.operation_type, wri.instock_type, wri.material_id,
wri.material_barcode, wri.material_batch_code, wri.pallet_info_code, wri.instock_amount, wri.execute_status,
wri.erp_status, wri.erp_amount, wri.apply_by, wri.apply_date, wri.machine_name, wri.quality_status, wri.update_by, wri.update_date,
wri.begin_time, wri.end_time,mbmi.material_code,mbmi.material_name
from wms_raw_instock wri left join mes_base_material_info mbmi on wri.material_id=mbmi.material_id
<where>
<if test="taskCode != null and taskCode != ''"> and wri.task_code = #{taskCode}</if>
<if test="warehouseId != null "> and wri.warehouse_id = #{warehouseId}</if>
<if test="materialBarcode != null and materialBarcode != ''"> and wri.material_barcode like concat('%', #{materialBarcode}, '%')</if>
<if test="palletInfoCode != null and palletInfoCode != ''"> and wri.pallet_info_code like concat('%', #{palletInfoCode}, '%')</if>
<if test="locationCode != null and locationCode != ''"> and wri.location_code = #{locationCode}</if>
<if test="poNo != null and poNo != ''"> and wri.po_no like concat('%', #{poNo}, '%')</if>
<if test="operationType != null and operationType != ''"> and wri.operation_type = #{operationType}</if>
<if test="instockType != null and instockType != ''"> and wri.instock_type = #{instockType}</if>
<if test="executeStatus != null and executeStatus != ''"> and wri.execute_status = #{executeStatus}</if>
<if test="applyBy != null and applyBy != ''"> and wri.apply_by like concat('%', #{applyBy}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and mbmi.material_code like concat('%', #{materialCode}, '%')</if>
<if test="materialName != null and materialName != ''"> and mbmi.material_name like concat('%', #{materialName}, '%')</if>
</where>
order by wri.apply_date desc
</select>
<select id="selectWmsRawInstockERPNotSynchronized" parameterType="WmsRawInstock" resultMap="WmsRawInstockResult">
select wri.raw_instock_id,
wri.task_code,
wri.warehouse_id,
wbw.warehouse_code,
wri.instock_type,
wri.material_id,
wri.po_no,
wri.purchase_order_id,
mpo.specification_parameter,
mpo.src_bill_no,
mbmi.material_code,
mbui.unit_code,
wri.instock_amount,
if(wri.erp_amount is null, 0, wri.erp_amount) erp_amount,
wri.erp_status
from wms_raw_instock wri
left join wms_base_warehouse wbw on wbw.warehouse_id = wri.warehouse_id
left join mes_base_material_info mbmi on mbmi.material_id = wri.material_id
left join mes_base_unit_info mbui on mbui.erp_id = mbmi.material_unit_id
left join mes_purchase_order mpo on wri.purchase_order_id = mpo.purchase_order_id
where wri.execute_status = 2
and (wri.erp_status != 1 or wri.erp_status is null)
and wri.instock_type in (1, 3, 4)
and wri.instock_amount > if(wri.erp_amount is null, 0, wri.erp_amount)
and wri.purchase_order_id is not null and wri.purchase_order_id !=0
and mbmi.material_classfication = '1'
and mbmi.material_unit_id is not null and mbmi.material_unit_id !=''
</select>
<select id="monthRawInAmount" resultType="java.math.BigDecimal">
select sum(instock_amount) inStock from wms_raw_instock where DATE_FORMAT( apply_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) and warehouse_id = 311
</select>
<select id="locationStatus" resultType="com.hw.wms.domain.WmsBaseLocation">
select * from wms_base_location
</select>
<select id="locationCount" resultType="com.hw.wms.domain.WmsProductInstock">
select
warehouse_id warehouse_id,
sum(instock_amount) instock_amount
from
wms_raw_instock
where
apply_date > now() - interval 1 month
and (warehouse_id = 511
or warehouse_id = 512)
group by
warehouse_id
</select>
<select id="selectInAndOutInfo" resultType="com.hw.wms.domain.WmsRawOutstock">
SELECT x.warehouse_id,sum(x.instock_amount) outstock_amount FROM `hwjy-cloud`.wms_raw_instock x where
(x.warehouse_id = 111
or x.warehouse_id = 132) and DATE(x.apply_date) = curdate() group by x.warehouse_id
</select>
<select id="fourthInstockList" resultType="com.hw.wms.domain.WmsRawOutstock">
SELECT x.warehouse_id,sum(x.instock_amount) outstock_amount FROM `hwjy-cloud`.wms_raw_instock x where
x.warehouse_id = 431
and DATE(x.apply_date) = curdate()
</select>
<select id="purchaseInfo" resultType="com.hw.wms.domain.WmsRawInstock">
select
a.*,b.material_name
from
wms_raw_instock a left join mes_base_material_info b on a.material_id = b.material_id
where
a.warehouse_id = 111
and a.apply_date > now() - interval 1 month
and a.instock_type = '1'
</select>
<select id="bomInfo" resultType="com.hw.wms.domain.MesProductOrder">
select
x.*,a.material_name
from
`hwjy-cloud`.mes_product_order x
left join mes_base_material_info a on
x.material_id = a.material_id
where
X.dispatch_id = #{dispatchId}
and X.sale_type = 1 and X.create_time > now() - interval 1 MONTH
</select>
<select id="purchaseFirstInfo" resultType="com.hw.wms.domain.WmsRawInstock">
select
a.*,b.material_name
from
wms_raw_instock a left join mes_base_material_info b on a.material_id = b.material_id
where
a.warehouse_id = 411
and a.apply_date > now() - interval 1 month
and a.instock_type = '1'
</select>
<select id="dayRawInAmount" resultType="java.math.BigDecimal">
select
sum(instock_amount) inStock
from
wms_raw_instock
where
DATE_FORMAT( apply_date, '%Y%m%d' ) = DATE_FORMAT( CURDATE( ) , '%Y%m%d' ) and warehouse_id = 311
</select>
</mapper>