143 lines
7.0 KiB
XML
143 lines
7.0 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.foreverwin.iep.wip.mapper.LotMaterialMapper">
|
|
|
|
<resultMap id="lotMaterialMap" type="com.foreverwin.iep.wip.entity.LotMaterial">
|
|
<id property="sid" column="SID"/>
|
|
<result property="lotStateBo" column="LOT_STATE_BO"/>
|
|
<result property="lotSerial" column="LOT_SERIAL"/>
|
|
<result property="itemBo" column="ITEM_BO"/>
|
|
<result property="feedingQty" column="FEEDING_QTY"/>
|
|
<result property="consumeQty" column="CONSUME_QTY"/>
|
|
<result property="qty" column="QTY"/>
|
|
<result property="materialLot" column="MATERIAL_LOT"/>
|
|
<result property="invBasisBo" column="INV_BASIS_BO"/>
|
|
<result property="storageNo" column="STORAGE_NO"/>
|
|
<result property="supplierNo" column="SUPPLIER_NO"/>
|
|
<result property="supplierBatch" column="SUPPLIER_BATCH"/>
|
|
<result property="erpFlag" column="ERP_FLAG"/>
|
|
<result property="parentSid" column="PARENT_SID"/>
|
|
<result property="dateCreate" column="DATE_CREATE"/>
|
|
<result property="creator" column="CREATOR"/>
|
|
<result property="dateMfg" column="DATE_MFG"/>
|
|
<result property="dateExp" column="DATE_EXP"/>
|
|
</resultMap>
|
|
<resultMap id="fullMap" type="com.foreverwin.iep.wip.dto.LotMaterialDTO" extends="lotMaterialMap">
|
|
<result property="itemBo" column="item_bo"/>
|
|
<result property="item" column="ITEM"/>
|
|
<result property="erpItem" column="ERP_ITEM"/>
|
|
<result property="itemDesc" column="ITEM_DESC"/>
|
|
<result property="itemType" column="ITEM_TYPE"/>
|
|
<result property="uom" column="UNIT_OF_MEASURE"/>
|
|
<result property="totalQty" column="total_qty"/>
|
|
<result property="operation" column="operation"/>
|
|
<result property="bomBo" column="bom_bo"/>
|
|
<result property="shopOrder" column="SHOP_ORDER"/>
|
|
<result property="warehouse" column="WAREHOUSE"/>
|
|
<result property="storageBin" column="STORAGE_BIN"/>
|
|
<result property="storageLocation" column="STORAGE_LOCATION"/>
|
|
<result property="resrce" column="RESRCE"/>
|
|
<result property="fabNo" column="FAB_NO"/>
|
|
<result property="workCenter" column="WORK_CENTER"/>
|
|
<result property="unitAuxiliary" column="UNIT_AUXILIARY"/>
|
|
</resultMap>
|
|
<select id="selectByMaterialLot" resultMap="lotMaterialMap">
|
|
select a.*
|
|
from lot_material a
|
|
join lot_state b on a.LOT_STATE_BO = b.HANDLE
|
|
join lot_basis c on b.LOT_BASIS_BO = c.HANDLE
|
|
<where>
|
|
and c.SITE = #{site}
|
|
and a.MATERIAL_LOT = #{materialLot}
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectLotMaterialByErp" resultMap="fullMap">
|
|
select b.ITEM, b.UNIT_OF_MEASURE, sum(a.CONSUME_QTY) as CONSUME_QTY, a.INV_BASIS_BO, a.MATERIAL_LOT
|
|
from lot_material a
|
|
join item b on (a.item_bo = concat('ItemBO:', concat(b.SITE, concat(',', concat(b.ITEM, ',#')))) and b.CURRENT_REVISION = 'Y') or a.ITEM_BO = b.HANDLE
|
|
where a.LOT_STATE_BO = #{lotStateBo}
|
|
and a.ERP_FLAG != 'Y'
|
|
group by b.ITEM, b.UNIT_OF_MEASURE, a.INV_BASIS_BO, a.MATERIAL_LOT
|
|
</select>
|
|
|
|
<select id="selectLotMaterial" resultMap="fullMap">
|
|
SELECT a.*,B.ITEM, B.DESCRIPTION ITEM_DESC, case when d.operation is null then h.operation else d.operation end as operation, case when e.sub_qty is not null then A.CONSUME_QTY + e.sub_qty else A.CONSUME_QTY end total_qty
|
|
FROM LOT_MATERIAL a
|
|
join ITEM b on (a.ITEM_BO = concat('ItemBO:', concat(b.SITE, concat(',', concat(b.ITEM,',#')))) and b.CURRENT_REVISION = 'Y') or a.ITEM_BO = b.HANDLE
|
|
left join lot_log c on c.LOT_SERIAL = a.LOT_SERIAL and a.LOT_STATE_BO = c.LOT_STATE_BO
|
|
left join operation d on c.OPERATION_BO = d.HANDLE
|
|
left join (
|
|
select x.PARENT_SID, sum(x.CONSUME_QTY) sub_qty
|
|
from lot_material x
|
|
where x.PARENT_SID is not null
|
|
group by x.PARENT_SID
|
|
) e on a.SID = e.PARENT_SID
|
|
left join lot_state f on f.LOT_SERIAL = a.LOT_SERIAL and a.LOT_STATE_BO = f.HANDLE
|
|
left join router_step g on f.ROUTER_STEP_BO = g.HANDLE
|
|
left join operation h on g.OPERATION_BO = h.HANDLE
|
|
where a.PARENT_SID is null
|
|
and a.LOT_STATE_BO = #{lotStateBo}
|
|
order by ITEM, material_lot, OPERATION
|
|
</select>
|
|
|
|
|
|
<select id="selectLotMaterialByLot" resultMap="fullMap">
|
|
select c.material_lot, d.handle item_bo, d.item, d.DESCRIPTION ITEM_DESC, d.item_type, e.operation, f.field_value input_sn, i.handle bom_bo, sum(c.qty) qty
|
|
from LOT_STATE a
|
|
join LOT_LOG b on a.handle = b.lot_state_bo
|
|
join LOT_MATERIAL c on b.lot_serial = c.lot_serial and a.handle = c.lot_state_bo
|
|
join item d on (c.ITEM_BO = concat('ItemBO:', concat(d.SITE, concat(',', concat(d.ITEM,',#')))) and d.CURRENT_REVISION = 'Y') or c.ITEM_BO = d.HANDLE
|
|
join operation e on b.operation_bo = e.handle
|
|
left join custom_fields f on d.item_type_bo = f.handle and f.table_name = 'ITEM_TYPE' and f.field_name = 'INPUT_SN'
|
|
join lot_basis g on a.lot_basis_bo = g.handle
|
|
join shop_order h on g.shop_order_bo = h.handle
|
|
join bom i on h.bom_bo = i.handle or (concat('BOMBO:', concat(i.SITE, concat(',', concat(i."bom",',U,#')))) = h.bom_bo and i.CURRENT_REVISION = 'Y')
|
|
where a.lot_no in
|
|
<foreach collection="lotNoList" item="lotNo" index="index" open="(" separator="," close=")">
|
|
#{lotNo}
|
|
</foreach>
|
|
group by c.material_lot, d.handle, d.item, d.DESCRIPTION, d.item_type, e.operation, f.field_value, i.handle
|
|
</select>
|
|
|
|
<select id="selectLotMaterialOpByLot" resultMap="fullMap">
|
|
select c.*, d.operation
|
|
from LOT_STATE a
|
|
join LOT_LOG b on a.handle = b.lot_state_bo
|
|
join LOT_MATERIAL c on b.lot_serial = c.lot_serial and a.handle = c.lot_state_bo
|
|
join operation d on b.operation_bo = d.handle
|
|
where
|
|
a.lot_no in
|
|
<foreach collection="lotNoList" item="lotNo" open="(" separator="," close=")">
|
|
#{lotNo}
|
|
</foreach>
|
|
and c.item_bo = #{itemBo}
|
|
and c.material_lot = #{materialLot}
|
|
and d.operation = #{operation}
|
|
and c.qty > 0
|
|
order by b.end_time
|
|
</select>
|
|
|
|
<select id="selectLotMaterialByLotBasisBo" resultMap="fullMap">
|
|
select lm.SID,lm.LOT_STATE_BO,lm.LOT_SERIAL,lm.ITEM_BO,lm.CONSUME_QTY,lm.MATERIAL_LOT,lm.RESERVED,lm.RESERVED_SEQ,
|
|
lm.SUPPLIER_NO,lm.SUPPLIER_BATCH,lm.ERP_FLAG ,lm.SHOP_ORDER_BO,lm.WMS_WAREHOUSE_BO ,lm.WMS_STORAGE_BIN_BO,lm.DATE_CREATE,
|
|
so.SHOP_ORDER,ww.WAREHOUSE,wsb.STORAGE_BIN,wsl.STORAGE_LOCATION,i.ITEM,i.UNIT_OF_MEASURE,cf.FIELD_VALUE UNIT_AUXILIARY,i.ERP_ITEM,r.RESRCE,fb.FAB_NO,wc.WORK_CENTER
|
|
from lot_material lm
|
|
left join item i on lm.ITEM_BO = i.HANDLE
|
|
left join custom_fields cf on cf.TABLE_NAME = 'ITEM' and cf.FIELD_NAME = 'UNIT_AUXILIARY' and i.HANDLE = cf.HANDLE
|
|
left join shop_order so on so.HANDLE = lm.SHOP_ORDER_BO
|
|
left join wms.wms_warehouse ww on ww.HANDLE = lm.WMS_WAREHOUSE_BO
|
|
left join wms.wms_storage_bin wsb on wsb.HANDLE = lm.WMS_STORAGE_BIN_BO
|
|
left join wms.wms_storage_location wsl on wsl.HANDLE = wsb.STORAGE_LOCATION_BO
|
|
left join fab_basis fb on fb.HANDLE = wsl.FAB_NO_BO
|
|
left join resrce r on r.HANDLE = lm.RESOURCE_BO
|
|
left join work_center wc on wc.HANDLE = wsl.WORK_CENTER_BO
|
|
where lm.LOT_STATE_BO IN(
|
|
select HANDLE from lot_state ls where ls.LOT_BASIS_BO = #{lotBasisBo}
|
|
)
|
|
and ifnull(lm.REMOVED,'0') != '1'
|
|
</select>
|
|
</mapper>
|