8282-testToMaster #3284

Merged
alexm merged 157 commits from 8282-testToMaster into master 2024-12-10 06:18:52 +00:00
1 changed files with 38 additions and 28 deletions
Showing only changes of commit 22e9a9104a - Show all commits

View File

@ -46,34 +46,44 @@ module.exports = Self => {
const pickingOrderToCompare = parkingItem['pickingOrder']; const pickingOrderToCompare = parkingItem['pickingOrder'];
const result = await Self.rawSql(` const result = await Self.rawSql(`
WITH currentItemShelving AS( WITH currentItemShelving AS (
SELECT is2.created + INTERVAL ? HOUR created, is2.itemFk, sh.code SELECT is2.created, is2.itemFk, sh.code
FROM vn.itemShelving is2 FROM vn.itemShelving is2
JOIN vn.shelving sh ON sh.id = is2.shelvingFk JOIN vn.shelving sh ON sh.id = is2.shelvingFk
LEFT JOIN vn.parking p ON p.id = sh.parkingFk LEFT JOIN vn.parking p ON p.id = sh.parkingFk
LEFT JOIN vn.sector s ON s.id = p.sectorFk LEFT JOIN vn.sector s ON s.id = p.sectorFk
WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?) WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?)
) ),
,itemShelvings AS ( itemShelvings AS (
SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder,p.code parkingFk SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder, p.code AS parkingFk
FROM vn.itemShelving is2 FROM vn.itemShelving is2
JOIN currentItemShelving ai ON is2.itemfk = ai.itemFk JOIN currentItemShelving ai ON is2.itemFk = ai.itemFk
JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk) JOIN vn.sector s ON s.id = p.sectorFk
,parkingDestiny AS ( ),
SELECT ? pickingOrder) parkingDestiny AS (
SELECT ish.*, SELECT ? AS pickingOrder
CASE )
WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created THEN "new" SELECT ish.*,
WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created THEN "old" CASE
END AS itemCreated WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created
FROM itemShelvings ish AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "old"
JOIN parkingDestiny d WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created
JOIN currentItemShelving aish AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "new"
WHERE ish.pickingOrder < d.pickingOrder AND aish.created < ish.created OR END AS itemCreated
ish.pickingOrder > d.pickingOrder AND aish.created > ish.created;`, FROM itemShelvings ish
[hoursToCompare, shelving, itemFk, itemFk, pickingOrderToCompare], myOptions); JOIN parkingDestiny d ON d.pickingOrder IS NOT NULL
JOIN currentItemShelving aish ON ish.itemFk = aish.itemFk
WHERE ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ?
AND (
(ish.pickingOrder < d.pickingOrder AND aish.created < ish.created)
OR
(ish.pickingOrder > d.pickingOrder AND aish.created > ish.created)
);
`,
[shelving, itemFk, itemFk, pickingOrderToCompare,
hoursToCompare, hoursToCompare, hoursToCompare, hoursToCompare], myOptions);
return result; return result;
}; };
}; };