refs #6964 feat: hasItemOlder

This commit is contained in:
Sergio De la torre 2024-05-22 12:23:33 +02:00
parent a52b9b6d2e
commit 49fed4e51e
2 changed files with 16 additions and 5 deletions

View File

@ -0,0 +1,6 @@
-- Place your SQL code here
USE vn;
ALTER TABLE vn.sector ADD hasItemOlderReview BIGINT DEFAULT false NULL COMMENT 'Indica si el sector se revisa para comprobar si tiene ítems más viejos';
ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.';

View File

@ -46,17 +46,22 @@ module.exports = Self => {
SELECT COUNT(ish.id) countItemOlder
FROM vn.itemShelving ish
JOIN (
SELECT ish.itemFk, created,shelvingFk
SELECT ish.itemFk, created, shelvingFk
FROM vn.itemShelving ish
JOIN vn.shelving s ON ish.shelvingFk = s.code
LEFT JOIN vn.parking p2 ON p2.id = s.parkingFk
WHERE ish.shelvingFk = ?
)sub ON sub.itemFK = ish.itemFk
JOIN vn.shelving s ON s.code = ish.shelvingFk
JOIN vn.parking p ON p.id = s.parkingFk
WHERE sub.created > ish.created
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk <> ? OR ? IS NULL)`,
JOIN vn.sector s2 ON s2.id = p.sectorFk
JOIN vn.productionConfig pc ON pc.itemOlderReviewHours
WHERE ish.created + INTERVAL pc.itemOlderReviewHours HOUR < sub.created
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk = ? OR ? IS NULL)
AND (p.pickingOrder < sub.pickingOrder OR sub.pickingOrder IS NULL)
AND (s2.hasItemOlderReview)`,
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], myOptions);
return result[0]['countItemOlder'] > 0;
};