|
|
|
@ -288,6 +288,62 @@ |
|
|
|
ORDER BY s.create_date DESC |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="searchSoReceiveCasesDataByPage" resultType="SoReceiveCasesData"> |
|
|
|
SELECT |
|
|
|
s.Id as id, |
|
|
|
s.NotifyNo as notifyNo, |
|
|
|
s.cases_no as casesNo, |
|
|
|
s.roll_no as rollNo, |
|
|
|
s.roll_qty as rollQty, |
|
|
|
s.part_no as partNo, |
|
|
|
s.part_desc as partDesc, |
|
|
|
s.create_date as createDate, |
|
|
|
s.create_by as createBy, |
|
|
|
s.Remark as remark, |
|
|
|
s.site, |
|
|
|
s.bu_no as buNo, |
|
|
|
agg.box_count_cases as boxCountCases, |
|
|
|
agg.box_count_rolls as boxCountRolls, |
|
|
|
agg.total_qty as totalQty |
|
|
|
FROM so_receive_cases s WITH(NOLOCK) |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
site, |
|
|
|
NotifyNo, |
|
|
|
COUNT(DISTINCT cases_no) AS box_count_cases, --盒标签张数 |
|
|
|
COUNT(DISTINCT roll_no) AS box_count_rolls, --卷标签张数 |
|
|
|
SUM(roll_qty) AS total_qty --物料总数 |
|
|
|
FROM so_receive_cases WITH(NOLOCK) |
|
|
|
WHERE site = #{site} and NotifyNo = #{notifyNo} |
|
|
|
GROUP BY site, NotifyNo |
|
|
|
) as agg ON s.site = agg.site AND s.NotifyNo = agg.NotifyNo |
|
|
|
<where> |
|
|
|
s.site = #{site} AND s.bu_no = #{buNo} |
|
|
|
<if test="notifyNo != null and notifyNo != ''"> |
|
|
|
AND s.NotifyNo = #{notifyNo} |
|
|
|
</if> |
|
|
|
<if test="casesNo != null and casesNo != ''"> |
|
|
|
AND s.cases_no = #{casesNo} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
ORDER BY s.create_date DESC |
|
|
|
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="searchSoReceiveCasesDataCount" resultType="int"> |
|
|
|
SELECT COUNT(1) |
|
|
|
FROM so_receive_cases s WITH(NOLOCK) |
|
|
|
<where> |
|
|
|
s.site = #{site} AND s.bu_no = #{buNo} |
|
|
|
<if test="notifyNo != null and notifyNo != ''"> |
|
|
|
AND s.NotifyNo = #{notifyNo} |
|
|
|
</if> |
|
|
|
<if test="casesNo != null and casesNo != ''"> |
|
|
|
AND s.cases_no = #{casesNo} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
</select> |
|
|
|
|
|
|
|
<delete id="deleteSoReceiveCasesData"> |
|
|
|
DELETE FROM so_receive_cases |
|
|
|
WHERE Id = #{id} |
|
|
|
@ -414,20 +470,46 @@ |
|
|
|
b.related_order_no as relatedOrderNo, |
|
|
|
b.related_order_line_no as relatedOrderLineNo, |
|
|
|
<!-- 已扫描数量和未扫描数量 --> |
|
|
|
ISNULL(SUM(e.roll_qty), 0) as rollQty, |
|
|
|
CASE WHEN b.required_qty - ISNULL(SUM(e.roll_qty), 0) > 0 |
|
|
|
THEN ROUND(b.required_qty - ISNULL(SUM(e.roll_qty), 0), 3) |
|
|
|
ISNULL(e_agg.roll_qty, 0) as rollQty, |
|
|
|
CASE WHEN b.required_qty - ISNULL(e_agg.roll_qty, 0) > 0 |
|
|
|
THEN ROUND(b.required_qty - ISNULL(e_agg.roll_qty, 0), 3) |
|
|
|
ELSE 0 |
|
|
|
END as unScanQty , |
|
|
|
ISNULL(SUM(i.qty_on_hand), 0) as availableStock, |
|
|
|
ISNULL(inv_agg.qty_on_hand, 0) as availableStock, |
|
|
|
b.std_packing_qty, |
|
|
|
ISNULL(b.inspection_flag,'N') as inspectionFlag |
|
|
|
FROM outbound_notification_head a |
|
|
|
LEFT JOIN Customer c ON a.site = c.site AND a.customer_id = c.CustomerID |
|
|
|
LEFT JOIN outbound_notification_detail b ON a.site = b.site AND a.bu_no = b.bu_no AND a.order_no = b.order_no |
|
|
|
LEFT JOIN inventory_stock I ON B.site = I.site AND B.part_no = I.part_no AND I.status = '在库' and i.batch_no = b.out_batch_no |
|
|
|
LEFT JOIN so_receive_boxes d ON b.site = d.site AND b.bu_no = d.bu_no AND b.order_no = d.order_no |
|
|
|
LEFT JOIN so_receive_box_rolls e ON b.site = e.site AND b.bu_no = e.bu_no AND d.box_no = e.box_no AND b.part_no = e.part_no |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
site, |
|
|
|
part_no, |
|
|
|
batch_no, |
|
|
|
SUM(qty_on_hand) as qty_on_hand |
|
|
|
FROM inventory_stock |
|
|
|
WHERE status = '在库' |
|
|
|
<if test="site != null and site != ''"> |
|
|
|
AND site = #{site} |
|
|
|
</if> |
|
|
|
GROUP BY site, part_no, batch_no |
|
|
|
) AS inv_agg ON b.site = inv_agg.site AND b.part_no = inv_agg.part_no AND b.out_batch_no = inv_agg.batch_no |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
d.site, |
|
|
|
d.bu_no, |
|
|
|
d.order_no, |
|
|
|
e.part_no, |
|
|
|
SUM(e.roll_qty) as roll_qty |
|
|
|
FROM so_receive_boxes d |
|
|
|
INNER JOIN so_receive_box_rolls e ON d.site = e.site AND d.bu_no = e.bu_no AND d.box_no = e.box_no |
|
|
|
<where> |
|
|
|
<if test="site != null and site != ''"> |
|
|
|
d.site = #{site} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY d.site, d.bu_no, d.order_no, e.part_no |
|
|
|
) AS e_agg ON b.site = e_agg.site AND b.bu_no = e_agg.bu_no AND b.order_no = e_agg.order_no AND b.part_no = e_agg.part_no |
|
|
|
<where> |
|
|
|
<if test="site != null and site != ''"> |
|
|
|
AND a.site = #{site} |
|
|
|
@ -466,16 +548,7 @@ |
|
|
|
AND #{endDate} >= a.required_outbound_date |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY |
|
|
|
a.site, a.bu_no, a.order_no, a.order_type, a.order_status, a.customer_id, c.customerName, |
|
|
|
a.related_order_no, a.related_order_line_no, a.required_outbound_date, a.remarks, |
|
|
|
a.erp_order_no, a.erp_order_line_no, a.erp_order_date, a.created_by, a.created_date, |
|
|
|
a.updated_by, a.updated_date, a.assigned_by, a.assigned_date, a.closed_by, a.closed_date, |
|
|
|
a.archived_by, a.archived_date, a.orderref1, a.orderref2, a.orderref3, a.orderref4, a.orderref5, |
|
|
|
a.order_date, a.close_flag, a.out_warehouse, a.customer_order_no, a.show_in_query_flag, |
|
|
|
b.part_no, b.part_desc, b.unit, b.required_qty, b.out_warehouse, b.out_batch_no, b.order_qty, |
|
|
|
b.related_order_no, b.related_order_line_no, b.std_packing_qty, b.inspection_flag, c.CustomerAbb |
|
|
|
ORDER BY a.created_date DESC, b.part_no |
|
|
|
ORDER BY a.required_outbound_date DESC, b.part_no |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- 分页查询出库通知单主记录(关联明细) --> |
|
|
|
@ -524,20 +597,46 @@ |
|
|
|
b.order_qty as orderQty, |
|
|
|
b.related_order_no as relatedOrderNo, |
|
|
|
b.related_order_line_no as relatedOrderLineNo, |
|
|
|
ISNULL(SUM(e.roll_qty), 0) as rollQty, |
|
|
|
CASE WHEN b.required_qty - ISNULL(SUM(e.roll_qty), 0) > 0 |
|
|
|
THEN ROUND(b.required_qty - ISNULL(SUM(e.roll_qty), 0), 3) |
|
|
|
ISNULL(e_agg.roll_qty, 0) as rollQty, |
|
|
|
CASE WHEN b.required_qty - ISNULL(e_agg.roll_qty, 0) > 0 |
|
|
|
THEN ROUND(b.required_qty - ISNULL(e_agg.roll_qty, 0), 3) |
|
|
|
ELSE 0 |
|
|
|
END as unScanQty, |
|
|
|
ISNULL(SUM(i.qty_on_hand), 0) as availableStock, |
|
|
|
ISNULL(inv_agg.qty_on_hand, 0) as availableStock, |
|
|
|
b.std_packing_qty, |
|
|
|
ISNULL(b.inspection_flag,'N') as inspectionFlag |
|
|
|
FROM outbound_notification_head a |
|
|
|
LEFT JOIN Customer c ON a.site = c.site AND a.customer_id = c.CustomerID |
|
|
|
LEFT JOIN outbound_notification_detail b ON a.site = b.site AND a.bu_no = b.bu_no AND a.order_no = b.order_no |
|
|
|
LEFT JOIN inventory_stock I ON B.site = I.site AND B.part_no = I.part_no AND I.status = '在库' and i.batch_no = b.out_batch_no |
|
|
|
LEFT JOIN so_receive_boxes d ON b.site = d.site AND b.bu_no = d.bu_no AND b.order_no = d.order_no |
|
|
|
LEFT JOIN so_receive_box_rolls e ON b.site = e.site AND b.bu_no = e.bu_no AND d.box_no = e.box_no AND b.part_no = e.part_no |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
site, |
|
|
|
part_no, |
|
|
|
batch_no, |
|
|
|
SUM(qty_on_hand) as qty_on_hand |
|
|
|
FROM inventory_stock |
|
|
|
WHERE status = '在库' |
|
|
|
<if test="query.site != null and query.site != ''"> |
|
|
|
AND site = #{query.site} |
|
|
|
</if> |
|
|
|
GROUP BY site, part_no, batch_no |
|
|
|
) AS inv_agg ON b.site = inv_agg.site AND b.part_no = inv_agg.part_no AND b.out_batch_no = inv_agg.batch_no |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
d.site, |
|
|
|
d.bu_no, |
|
|
|
d.order_no, |
|
|
|
e.part_no, |
|
|
|
SUM(e.roll_qty) as roll_qty |
|
|
|
FROM so_receive_boxes d |
|
|
|
INNER JOIN so_receive_box_rolls e ON d.site = e.site AND d.bu_no = e.bu_no AND d.box_no = e.box_no |
|
|
|
<where> |
|
|
|
<if test="query.site != null and query.site != ''"> |
|
|
|
d.site = #{query.site} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY d.site, d.bu_no, d.order_no, e.part_no |
|
|
|
) AS e_agg ON b.site = e_agg.site AND b.bu_no = e_agg.bu_no AND b.order_no = e_agg.order_no AND b.part_no = e_agg.part_no |
|
|
|
<where> |
|
|
|
<if test="query.site != null and query.site != ''"> |
|
|
|
AND a.site = #{query.site} |
|
|
|
@ -576,79 +675,54 @@ |
|
|
|
AND #{query.endDate} >= a.required_outbound_date |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY |
|
|
|
a.site, a.bu_no, a.order_no, a.order_type, a.order_status, a.customer_id, c.customerName, |
|
|
|
a.related_order_no, a.related_order_line_no, a.required_outbound_date, a.remarks, |
|
|
|
a.erp_order_no, a.erp_order_line_no, a.erp_order_date, a.created_by, a.created_date, |
|
|
|
a.updated_by, a.updated_date, a.assigned_by, a.assigned_date, a.closed_by, a.closed_date, |
|
|
|
a.archived_by, a.archived_date, a.orderref1, a.orderref2, a.orderref3, a.orderref4, a.orderref5, |
|
|
|
a.order_date, a.close_flag, a.out_warehouse, a.customer_order_no, a.show_in_query_flag, |
|
|
|
b.part_no, b.part_desc, b.unit, b.required_qty, b.out_warehouse, b.out_batch_no, b.order_qty, |
|
|
|
b.related_order_no, b.related_order_line_no, b.std_packing_qty, b.inspection_flag, c.CustomerAbb |
|
|
|
ORDER BY a.required_outbound_date DESC, b.part_no |
|
|
|
OFFSET #{query.offset} ROWS FETCH NEXT #{query.limit} ROWS ONLY |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- 分页查询出库通知单主记录(关联明细)- 总数查询 --> |
|
|
|
<select id="searchOutboundNotificationWithDetailCount" resultType="int"> |
|
|
|
SELECT COUNT(1) FROM ( |
|
|
|
SELECT |
|
|
|
a.order_no, |
|
|
|
b.part_no |
|
|
|
FROM outbound_notification_head a |
|
|
|
LEFT JOIN Customer c ON a.site = c.site AND a.customer_id = c.CustomerID |
|
|
|
LEFT JOIN outbound_notification_detail b ON a.site = b.site AND a.bu_no = b.bu_no AND a.order_no = b.order_no |
|
|
|
LEFT JOIN inventory_stock I ON B.site = I.site AND B.part_no = I.part_no AND I.status = '在库' and i.batch_no = b.out_batch_no |
|
|
|
LEFT JOIN so_receive_boxes d ON b.site = d.site AND b.bu_no = d.bu_no AND b.order_no = d.order_no |
|
|
|
LEFT JOIN so_receive_box_rolls e ON b.site = e.site AND b.bu_no = e.bu_no AND d.box_no = e.box_no AND b.part_no = e.part_no |
|
|
|
<where> |
|
|
|
<if test="query.site != null and query.site != ''"> |
|
|
|
AND a.site = #{query.site} |
|
|
|
</if> |
|
|
|
<if test="query.buNo != null and query.buNo != ''"> |
|
|
|
AND a.bu_no = #{query.buNo} |
|
|
|
</if> |
|
|
|
<if test="query.orderNo != null and query.orderNo != ''"> |
|
|
|
AND a.order_no LIKE '%' + #{query.orderNo} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.orderType != null and query.orderType != ''"> |
|
|
|
AND a.order_type = #{query.orderType} |
|
|
|
</if> |
|
|
|
<if test="query.orderStatus != null and query.orderStatus != ''"> |
|
|
|
AND a.order_status in |
|
|
|
<foreach collection="query.statusArr" close=")" open="(" item="item" separator=","> |
|
|
|
#{item} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test="query.orderStatus == null or query.orderStatus == ''"> |
|
|
|
AND a.order_status not in ('待出库', '草稿') |
|
|
|
</if> |
|
|
|
<if test="query.customerId != null and query.customerId != ''"> |
|
|
|
AND a.customer_id LIKE '%' + #{query.customerId} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.customerName != null and query.customerName != ''"> |
|
|
|
AND c.customerName LIKE '%' + #{query.customerName} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.inspectionFlag != null and query.inspectionFlag != ''"> |
|
|
|
AND ISNULL(b.inspection_flag,'N') = #{query.inspectionFlag} |
|
|
|
</if> |
|
|
|
<if test="query.startDate != null"> |
|
|
|
AND a.required_outbound_date >= #{query.startDate} |
|
|
|
</if> |
|
|
|
<if test="query.endDate != null"> |
|
|
|
AND #{query.endDate} >= a.required_outbound_date |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY |
|
|
|
a.site, a.bu_no, a.order_no, a.order_type, a.order_status, a.customer_id, c.customerName, |
|
|
|
a.related_order_no, a.related_order_line_no, a.required_outbound_date, a.remarks, |
|
|
|
a.erp_order_no, a.erp_order_line_no, a.erp_order_date, a.created_by, a.created_date, |
|
|
|
a.updated_by, a.updated_date, a.assigned_by, a.assigned_date, a.closed_by, a.closed_date, |
|
|
|
a.archived_by, a.archived_date, a.orderref1, a.orderref2, a.orderref3, a.orderref4, a.orderref5, |
|
|
|
a.order_date, a.close_flag, a.out_warehouse, a.customer_order_no, a.show_in_query_flag, |
|
|
|
b.part_no, b.part_desc, b.unit, b.required_qty, b.out_warehouse, b.out_batch_no, b.order_qty, |
|
|
|
b.related_order_no, b.related_order_line_no, b.std_packing_qty, b.inspection_flag, c.CustomerAbb |
|
|
|
) T |
|
|
|
SELECT COUNT(1) |
|
|
|
FROM outbound_notification_head a |
|
|
|
LEFT JOIN Customer c ON a.site = c.site AND a.customer_id = c.CustomerID |
|
|
|
LEFT JOIN outbound_notification_detail b ON a.site = b.site AND a.bu_no = b.bu_no AND a.order_no = b.order_no |
|
|
|
<where> |
|
|
|
<if test="query.site != null and query.site != ''"> |
|
|
|
AND a.site = #{query.site} |
|
|
|
</if> |
|
|
|
<if test="query.buNo != null and query.buNo != ''"> |
|
|
|
AND a.bu_no = #{query.buNo} |
|
|
|
</if> |
|
|
|
<if test="query.orderNo != null and query.orderNo != ''"> |
|
|
|
AND a.order_no LIKE '%' + #{query.orderNo} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.orderType != null and query.orderType != ''"> |
|
|
|
AND a.order_type = #{query.orderType} |
|
|
|
</if> |
|
|
|
<if test="query.orderStatus != null and query.orderStatus != ''"> |
|
|
|
AND a.order_status in |
|
|
|
<foreach collection="query.statusArr" close=")" open="(" item="item" separator=","> |
|
|
|
#{item} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
<if test="query.orderStatus == null or query.orderStatus == ''"> |
|
|
|
AND a.order_status not in ('待出库', '草稿') |
|
|
|
</if> |
|
|
|
<if test="query.customerId != null and query.customerId != ''"> |
|
|
|
AND a.customer_id LIKE '%' + #{query.customerId} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.customerName != null and query.customerName != ''"> |
|
|
|
AND c.customerName LIKE '%' + #{query.customerName} + '%' |
|
|
|
</if> |
|
|
|
<if test="query.inspectionFlag != null and query.inspectionFlag != ''"> |
|
|
|
AND ISNULL(b.inspection_flag,'N') = #{query.inspectionFlag} |
|
|
|
</if> |
|
|
|
<if test="query.startDate != null"> |
|
|
|
AND a.required_outbound_date >= #{query.startDate} |
|
|
|
</if> |
|
|
|
<if test="query.endDate != null"> |
|
|
|
AND #{query.endDate} >= a.required_outbound_date |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
</select> |
|
|
|
|
|
|
|
<!-- 更新出库通知单状态 --> |
|
|
|
|