feat: refs #7266 Requested changes and query optimization
This commit is contained in:
parent
b1a295dca4
commit
4c529da620
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`(
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vWarehouseFk SMALLINT,
|
vWarehouseFk INT,
|
||||||
vDated DATE
|
vDated DATE
|
||||||
)
|
)
|
||||||
RETURNS int(11)
|
RETURNS int(11)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vWarehouseFk SMALLINT,
|
vWarehouseFk INT,
|
||||||
vDated DATE
|
vDated DATE
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -17,12 +17,16 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="right lg-width">
|
<td class="right lg-width">
|
||||||
<div class="overflow-line">
|
<div class="overflow-line">
|
||||||
{{item.comment}}
|
{{
|
||||||
|
(item.longName && item.size && item.subName)
|
||||||
|
? `${item.longName} ${item.size} ${item.subName}`
|
||||||
|
: item.comment
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="center sm-width">
|
<td class="center sm-width">
|
||||||
<div class="overflow-line">
|
<div class="overflow-line">
|
||||||
{{item.producer}}
|
{{item.producerName || item.producerFk}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="center sm-width">
|
<td class="center sm-width">
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
SELECT co.code
|
SELECT co.code
|
||||||
FROM warehouse w
|
FROM warehouse w
|
||||||
JOIN address a ON a.id = w.addressFk
|
JOIN address a ON a.id = w.addressFk
|
||||||
JOIN client c ON c.id = a.clientFk
|
JOIN company co ON co.clientFk = a.clientFk
|
||||||
JOIN company co ON co.clientFk = c.id
|
|
||||||
WHERE w.id = ?
|
WHERE w.id = ?
|
|
@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS (
|
||||||
WHERE n < ?
|
WHERE n < ?
|
||||||
)
|
)
|
||||||
SELECT ROW_NUMBER() OVER() labelNum,
|
SELECT ROW_NUMBER() OVER() labelNum,
|
||||||
b.id buyFk,
|
b.itemFk,
|
||||||
b.itemFk,
|
i.name item,
|
||||||
b.quantity,
|
b.id buyFk,
|
||||||
b.packing,
|
b.quantity,
|
||||||
b.isPickedOff,
|
b.packing,
|
||||||
b.entryFk,
|
b.entryFk,
|
||||||
e.sub,
|
o.code origin,
|
||||||
o.code origin,
|
p.`name` producerName,
|
||||||
COALESCE(p.`name`, p.id, '') producer,
|
p.id producerFk,
|
||||||
i.name item,
|
i.`size`,
|
||||||
i.`size`,
|
i.category,
|
||||||
i.category,
|
i.stems,
|
||||||
i.stems,
|
i.inkFk,
|
||||||
i.inkFk,
|
ig.longName,
|
||||||
IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment,
|
ig.subName,
|
||||||
i.typeFk,
|
i.comment,
|
||||||
i.isLaid,
|
w.code buyerName
|
||||||
w.code buyerName,
|
FROM vn.buy b
|
||||||
w.code,
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
s.company_name companyName,
|
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
||||||
t.shipped
|
JOIN vn.origin o ON o.id = i.originFk
|
||||||
FROM vn.buy b
|
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
JOIN vn.worker w ON w.id = it.workerFk
|
||||||
LEFT JOIN edi.ekt e ON e.id = b.ektFk
|
JOIN numbers num
|
||||||
JOIN vn.origin o ON o.id = i.originFk
|
WHERE b.id = ?
|
||||||
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
|
||||||
JOIN vn.worker w ON w.id = it.workerFk
|
|
||||||
LEFT JOIN edi.supplier s ON s.supplier_id = e.pro
|
|
||||||
JOIN vn.entry e2 ON e2.id = b.entryFk
|
|
||||||
JOIN vn.travel t ON t.id = e2.travelFk
|
|
||||||
JOIN numbers num
|
|
||||||
WHERE b.id = ?
|
|
|
@ -71,7 +71,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="md-width">
|
<td colspan="2" class="md-width">
|
||||||
<div class="overflow-line">
|
<div class="overflow-line">
|
||||||
<i>Productor:</i> {{item.producer}}
|
<i>Productor:</i> {{item.producerName || item.producerFk}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
@ -103,7 +103,11 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="lg-width center cursive bold">
|
<td colspan="3" class="lg-width center cursive bold">
|
||||||
<div class="overflow-line">
|
<div class="overflow-line">
|
||||||
{{item.comment}}
|
{{
|
||||||
|
(item.longName && item.size && item.subName)
|
||||||
|
? `${item.longName} ${item.size} ${item.subName}`
|
||||||
|
: item.comment
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
SELECT co.code
|
SELECT co.code
|
||||||
FROM warehouse w
|
FROM warehouse w
|
||||||
JOIN address a ON a.id = w.addressFk
|
JOIN address a ON a.id = w.addressFk
|
||||||
JOIN client c ON c.id = a.clientFk
|
JOIN company co ON co.clientFk = a.clientFk
|
||||||
JOIN company co ON co.clientFk = c.id
|
|
||||||
WHERE w.id = ?
|
WHERE w.id = ?
|
|
@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS (
|
||||||
WHERE n < ?
|
WHERE n < ?
|
||||||
)
|
)
|
||||||
SELECT ROW_NUMBER() OVER() labelNum,
|
SELECT ROW_NUMBER() OVER() labelNum,
|
||||||
b.id buyFk,
|
b.itemFk,
|
||||||
b.itemFk,
|
i.name item,
|
||||||
b.quantity,
|
b.id buyFk,
|
||||||
b.packing,
|
b.quantity,
|
||||||
b.isPickedOff,
|
b.packing,
|
||||||
b.entryFk,
|
b.entryFk,
|
||||||
e.sub,
|
o.code origin,
|
||||||
o.code origin,
|
p.`name` producerName,
|
||||||
COALESCE(p.`name`, p.id, '') producer,
|
p.id producerFk,
|
||||||
i.name item,
|
i.`size`,
|
||||||
i.`size`,
|
i.category,
|
||||||
i.category,
|
i.stems,
|
||||||
i.stems,
|
i.inkFk,
|
||||||
i.inkFk,
|
ig.longName,
|
||||||
IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment,
|
ig.subName,
|
||||||
i.typeFk,
|
i.comment,
|
||||||
i.isLaid,
|
w.code buyerName
|
||||||
w.code buyerName,
|
FROM vn.buy b
|
||||||
w.code,
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
s.company_name companyName,
|
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
||||||
t.shipped
|
JOIN vn.origin o ON o.id = i.originFk
|
||||||
FROM vn.buy b
|
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
JOIN vn.worker w ON w.id = it.workerFk
|
||||||
LEFT JOIN edi.ekt e ON e.id = b.ektFk
|
JOIN numbers num
|
||||||
JOIN vn.origin o ON o.id = i.originFk
|
WHERE b.id = ?
|
||||||
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
|
||||||
JOIN vn.worker w ON w.id = it.workerFk
|
|
||||||
LEFT JOIN edi.supplier s ON s.supplier_id = e.pro
|
|
||||||
JOIN vn.entry e2 ON e2.id = b.entryFk
|
|
||||||
JOIN vn.travel t ON t.id = e2.travelFk
|
|
||||||
JOIN numbers num
|
|
||||||
WHERE b.id = ?
|
|
Loading…
Reference in New Issue