You can not 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
12 KiB

<?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.gaotao.modules.wms.dao.WmsPrintDao">
<select id="getInboundQcResultData" resultType="InboundQcResultData">
SELECT
a.site,
a.bu_no,
A.order_no AS notifyNo,
d.inspection_no AS order_no,
a.order_status,
d.part_no,
d.part_desc,
D.related_order_no AS po_orderNo,
D.related_order_line_no AS po_itemNo,
c.SupplierName,
c.supplierID AS supplierId,
b.inspector_date,
b.submit_date,
d.required_qty as order_qty,
roll_qty,
roll_count,
inspection_result,
disposal_measures,
B.batch_qualified_qty,
b.inspector_no
from inbound_notification_head a
inner join inbound_notification_detail D on a.site = D.site and a.bu_no = D.bu_no and a.order_no = D.order_no AND A.order_type ='采购入库'
left join qc_iqc_record b on D.site = b.site and D.bu_no = b.bu_no and D.inspection_no = b.inspection_no
inner join Supplier c on a.site = c.Site and a.Supplier_ID = c.supplierID
<where>
<if test="query.site != null and query.site != ''">
and A.site=#{query.site,jdbcType=VARCHAR}
</if>
<if test="query.buNo != null and query.buNo != ''">
and A.bu_no=#{query.buNo,jdbcType=CHAR}
</if>
<if test="query.orderNo != null and query.orderNo != ''">
and d.inspection_no like '%'+ #{query.orderNo} +'%'
</if>
<if test="query.notifyNo != null and query.notifyNo != ''">
and a.order_no like '%'+ #{query.notifyNo} +'%'
</if>
<if test="query.partNo != null and query.partNo != ''">
and b.part_no like '%'+ #{query.partNo,jdbcType=CHAR} +'%'
</if>
<if test="query.partDesc != null and query.partDesc != ''">
and b.part_desc like '%'+ #{query.partDesc,jdbcType=CHAR} +'%'
</if>
<if test="query.startDate != null">
and b.inspector_date > #{query.startDate}
</if>
<if test="query.endDate != null">
and #{query.endDate} > b.inspector_date
</if>
<if test="query.orderStatus != null and query.orderStatus != ''">
and a.order_status = #{query.orderStatus,jdbcType=VARCHAR}
</if>
<if test="query.supplierName != null and query.supplierName != ''">
and c.SupplierName like '%'+ #{query.supplierName} +'%'
</if>
<if test="query.poOrderNo != null and query.poOrderNo != ''">
and d.related_order_no like '%'+ #{query.poOrderNo} +'%'
</if>
<if test="query.poItemNo != null and query.poItemNo != ''">
and d.related_order_line_no = #{query.supplierName}
</if>
</where>
</select>
<select id="getPoOrderRollNoOutData" resultType="PoOrderRollNoOutData">
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
where
A.site = #{site} and A.bu_no = #{buNo}
and A.inspection_no = #{inspectionNo,jdbcType=VARCHAR}
</select>
<select id="getInboundQcResultOtherData" resultType="PoOrderRollNoOutData">
SELECT
b.expiration_day,
ISNULL(b.expiration_flag ,'N') AS expiration_flag,
b.exceed_in_ratio,
b.expiration_warning_day,
ISNULL(a.batch_qualified_qty, 0) * (1 + ISNULL(b.exceed_in_ratio, 0) / 100.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
where a.inspection_no = #{orderNo} and a.site = #{site} and a.bu_no = #{buNo}
</select>
<insert id="savePoOrderRollNo">
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})
</insert>
<delete id="deletePoPartLabelData">
delete from po_order_roll_no where site=#{site} and bu_no=#{buNo} and roll_no=#{rollNo} and inspection_no=#{inspectionNo}
</delete>
<update id="updatePrintFlag">
update po_order_roll_no set print_flag=isnull(print_flag,0)+1
WHERE
site = #{site} <!-- 先过滤 site -->
and bu_no=#{buNo}
AND roll_no IN
<foreach item="item" collection="rollList" open="(" separator="," close=")">
#{item.rollNo}
</foreach>
</update>
<select id="getPoPartLabelData" resultType="PoOrderRollNoOutData">
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} <!-- 先过滤 site -->
and bu_no=#{buNo}
AND roll_no IN
<foreach item="item" collection="rollList" open="(" separator="," close=")">
#{item.rollNo}
</foreach>
order by created_date
</select>
<select id="getKuCunLabelData" resultType="InventoryStockOutData">
select
a.site,
a.bu_no,--事业部
a.roll_no,--标签条码
a.qty_on_hand,--标签数量
a.status,--状态
a.part_no,--物料编码
b.PartDescription,--物料名称
b.Spec,--规格型号
b.UMID,
UM.UMName,--单位名称
a.label_type,--标签类型
a.parent_roll_no, --上级标签号
a.parent_roll_type,--上级标签类型
a.warehouse_id,
W.WareHouseName,--仓库名称
a.location_id,
L.LocationName,--货位名称
a.first_in_date,--入库日期
a.manufacture_date,--生产日期
a.expired_date, --有效期
a.orderref0,--来源单据类型
a.orderref1,--来源单据号
a.orderref2,--来源单据行号
a.batch_no, --合约号码
a.wdr, --批次号
a.remark, --备注说明
SUM(a.qty_on_hand) OVER() AS total_qty
from inventory_stock a
LEFT JOIN PART b ON a.site = b.Site AND a.part_no = b.PartNo
LEFT JOIN UM ON b.Site = UM.Site AND b.UMID = UM.UMID
LEFT JOIN WareHouse W ON a.site = W.Site AND a.warehouse_id = W.WareHouseID
LEFT JOIN Location L ON a.site = L.Site AND a.location_id = L.LocationID
<where>
a.site in (select site from AccessSite where userID = #{query.userName})
and a.status != '出库'
<if test="query.warehouseIdList != null and query.warehouseIdList.size() > 0">
and A.warehouse_id in
<foreach collection="query.warehouseIdList" item="warehouseId" open="(" separator="," close=")">
#{warehouseId}
</foreach>
</if>
<if test="query.orderref0 != null and query.orderref0 != ''">
and A.orderref0 like '%'+#{query.orderref0}+'%'
</if>
<if test="query.orderref1 != null and query.orderref1 != ''">
and A.orderref1 like '%'+ #{query.orderref1}+'%'
</if>
<if test="query.remark != null and query.remark != ''">
and A.remark like '%'+ #{query.remark}+'%'
</if>
<if test="query.locationId != null and query.locationId != ''">
and A.location_id like '%'+ #{query.locationId}+'%'
</if>
<if test="query.rollNo != null and query.rollNo != ''">
and A.roll_no like '%'+ #{query.rollNo}+'%'
</if>
<if test="query.parentRollNo != null and query.parentRollNo != ''">
and A.parent_roll_no like '%'+ #{query.parentRollNo}+'%'
</if>
<if test="query.partNo != null and query.partNo != ''">
and A.part_no like '%'+ #{query.partNo}+'%'
</if>
<if test="query.partDescription != null and query.partDescription != ''">
and b.PartDescription like '%'+ #{query.partDescription}+'%'
</if>
<if test="query.statusList != null and query.statusList.size() > 0">
and A.status in
<foreach collection="query.statusList" item="status" open="(" separator="," close=")">
#{status}
</foreach>
</if>
<if test="query.labelType != null and query.labelType != ''">
and a.label_type = #{query.labelType}
</if>
<if test="query.batchNo != null and query.batchNo != ''">
and a.batch_no like '%'+ #{query.batchNo}+'%'
</if>
</where>
</select>
<!-- 查询物料有效期信息 -->
<select id="getPartExpirationInfo" resultType="PoOrderRollNoOutData">
SELECT
expiration_flag as expirationFlag,
expiration_day as expirationDay,
expiration_warning_day as expirationWarningDay
FROM part
WHERE site = #{site}
AND bu_no = #{buNo}
AND PartNo = #{partNo}
</select>
<!-- 查询文件信息 -->
<select id="queryFileId" resultType="java.util.HashMap">
SELECT
id,
file_name as fileName
FROM sys_oss
WHERE order_ref1 = #{orderRef1}
AND order_ref2 = #{orderRef2}
</select>
<!-- 检查标签条码是否已存在 -->
<select id="checkRollNoExists" resultType="int">
SELECT COUNT(1)
FROM po_order_roll_no
WHERE site = #{site}
AND roll_no = #{rollNo}
</select>
<!-- 更新库存标签属性 -->
<update id="updateInventoryStockAttribute">
UPDATE inventory_stock
SET
batch_no = #{batchNo,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}
WHERE site = #{site,jdbcType=VARCHAR}
AND bu_no = #{buNo,jdbcType=VARCHAR}
AND roll_no = #{rollNo,jdbcType=VARCHAR}
</update>
<update id="freezeStatusInventoryStock">
update inventory_stock set status = '冻结',status_tb = 'F' where site = #{site} and bu_no = #{buNo} and roll_no = #{rollNo}
</update>
<!-- 获取仓库列表 -->
<select id="getWarehouseList" resultType="InventoryStockOutData">
SELECT DISTINCT
WareHouseID as warehouseId,
WareHouseName as warehouseName
FROM WareHouse
WHERE site in (select site from AccessSite where userID = #{userName})
ORDER BY WareHouseID
</select>
</mapper>