select a.site,a.bu_no,a.order_no,a.order_status,b.part_no,b.part_desc,b.po_orderNo,b.po_itemNo,c.SupplierName,c.supplierID as supplierId,
b.inspector_date,b.submit_date,a.order_qty,roll_qty,roll_count,inspection_result,disposal_measures,
B.batch_qualified_qty,b.inspector_no
from inbound_notification_head a
inner join qc_iqc_record b on a.site = b.site and a.bu_no = b.bu_no and a.order_no = b.inspection_no AND A.order_type ='采购入库'
left join Supplier c on a.site = c.Site and a.Supplier_ID = c.supplierID
and A.site=#{query.site,jdbcType=VARCHAR}
and A.bu_no=#{query.buNo,jdbcType=CHAR}
and A.order_no like '%'+ #{query.orderNo,jdbcType=CHAR} +'%'
and b.part_no like '%'+ #{query.partNo,jdbcType=CHAR} +'%'
and b.part_desc like '%'+ #{query.partDesc,jdbcType=CHAR} +'%'
and b.inspector_date > #{query.startDate}
and #{query.endDate} > b.inspector_date
and c.SupplierName like '%'+ #{query.supplierName} +'%'
and b.po_orderNo like '%'+ #{query.poOrderNo} +'%'
and b.po_itemNo = #{query.supplierName}
select ROW_NUMBER() OVER (ORDER BY a.created_date) orderId,a.site,a.bu_no,a.inspection_no,a.order_no,a.item_no,a.roll_no,a.roll_qty,a.part_no,a.part_desc,a.supplier_id,a.supplier_name,
a.order_qty,a.created_by,a.created_date,a.update_by,a.updated_date,a.delflag,a.version,a.print_flag,a.citem_code,
a.citem_class,a.sendto_address,a.hardtag_in_flag,a.batch_no,a.production_date,a.validity_period,a.chip_disk_no,
a.expiration_warning_date,a.expiration_date
from po_order_roll_no a
and A.site=#{site}
and A.bu_no=#{buNo}
and A.inspection_no=#{inspectionNo,jdbcType=VARCHAR}
select top 1 b.expiration_day,b.expiration_flag,b.exceed_in_ratio,b.expiration_warning_day,
isnull(a.batch_qualified_qty,0)-isnull((select sum(roll_qty) from po_order_roll_no where site=#{site} and bu_no=#{buNo} and inspection_no=#{orderNo} ),0) as remainingIssuableQty
from qc_iqc_record a
left join part b on a.site=b.site and a.bu_no=b.bu_No and a.part_no=b.PartNo
and a.inspection_no=#{orderNo} and a.site=#{site} and a.bu_no=#{buNo}
insert into po_order_roll_no
(site,bu_no,inspection_no,order_no,item_no,roll_no,roll_qty,part_no,part_desc,supplier_id,supplier_name,order_qty,
created_by,created_date,delflag,version,print_flag,
hardtag_in_flag,batch_no,production_date,expiration_warning_date,expiration_date
) values
(#{site},#{buNo},#{inspectionNo},#{orderNo},#{itemNo},#{rollNo},#{rollQty},#{partNo},#{partDesc},#{supplierId},#{supplierName},#{orderQty},
#{createdBy},GetDate(),#{delflag},#{version},#{printFlag},
#{hardtagInFlag},#{batchNo},#{productionDate},#{expirationWarningDate},#{expirationDate})
delete from po_order_roll_no where site=#{site} and bu_no=#{buNo} and roll_no=#{rollNo} and inspection_no=#{inspectionNo}
update po_order_roll_no set print_flag=isnull(print_flag,0)+1
WHERE
site = #{site}
and bu_no=#{buNo}
AND roll_no IN
#{item.rollNo}
select site,bu_no,inspection_no,order_no,item_no,roll_no,roll_qty,part_no,part_desc,supplier_id,supplier_name,order_qty,
created_by,created_date,delflag,version,print_flag,
hardtag_in_flag,batch_no,production_date,expiration_warning_date,expiration_date
from po_order_roll_no
WHERE
site = #{site}
and bu_no=#{buNo}
AND roll_no IN
#{item.rollNo}
order by created_date
select a.site,a.bu_no,a.warehouse_id,location_id,roll_no,parent_roll_no,part_no,b.PartDescription,B.part_desc_en,a.status,a.qty_on_hand,label_type,a.orderref1,a.orderref2,a.orderref3,a.manufacture_date,a.expired_date,a.batch_no
from inventory_stock a
left join part b on a.site = b.site and a.bu_no = b.bu_no and a.part_no = b.PartNo
and a.status != '出库'
and A.site=#{query.site,jdbcType=VARCHAR}
and A.bu_no=#{query.buNo}
and A.warehouse_id like '%'+ #{query.warehouseId}+'%'
and A.location_id like '%'+ #{query.locationId}+'%'
and A.roll_no like '%'+ #{query.rollNo}+'%'
and A.parent_roll_no like '%'+ #{query.parentRollNo}+'%'
and A.part_no like '%'+ #{query.partNo}+'%'
and b.part_desc_en like '%'+ #{query.partDescEn}+'%'
and a.status = #{query.status}
and a.label_type = #{query.labelType}
and a.batch_no like '%'+ #{query.batchNo}+'%'