Merge branch 'dev' into 7654-entry_splitByShelvingCreateColumn
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Robert Ferrús 2024-07-04 06:48:29 +00:00
commit e897cdc35b
5 changed files with 44 additions and 29 deletions

View File

@ -47,9 +47,9 @@ BEGIN
INTO vHasTooMuchCollections, INTO vHasTooMuchCollections,
vLockName vLockName
FROM productionConfig pc FROM productionConfig pc
LEFT JOIN tCollection ON TRUE; LEFT JOIN tmp.collection ON TRUE;
DROP TEMPORARY TABLE tCollection; DROP TEMPORARY TABLE tmp.collection;
IF vHasTooMuchCollections THEN IF vHasTooMuchCollections THEN
CALL util.throw('Hay colecciones pendientes'); CALL util.throw('Hay colecciones pendientes');

View File

@ -7,27 +7,32 @@ BEGIN
* @param vWorkerFk id del worker. * @param vWorkerFk id del worker.
* @table Devuelve tabla temporal con las colecciones pendientes * @table Devuelve tabla temporal con las colecciones pendientes
*/ */
DROP TEMPORARY TABLE IF EXISTS tCollection; DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
CREATE TEMPORARY TABLE tCollection CREATE OR REPLACE TEMPORARY TABLE tmp.collection
SELECT c.id collectionFk, ENGINE = MEMORY
date(c.created) created, SELECT c.id collectionFk,
COUNT(DISTINCT tc.ticketFk) ticketTotalCount DATE(c.created) created,
FROM collection c COUNT(DISTINCT tc.ticketFk) ticketTotalCount
JOIN ticketCollection tc ON tc.collectionFk = c.id FROM collection c
JOIN sale s ON s.ticketFk = tc.ticketFk JOIN ticketCollection tc ON tc.collectionFk = c.id
JOIN ticketState ts ON ts.ticketFk = tc.ticketFk JOIN sale s ON s.ticketFk = tc.ticketFk
JOIN state s2 ON s2.id = ts.stateFk JOIN ticketState ts ON ts.ticketFk = tc.ticketFk
JOIN productionConfig pc JOIN state s2 ON s2.id = ts.stateFk
JOIN vn.state ss on ss.code = 'PREPARED' JOIN productionConfig pc
LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id JOIN vn.state ss ON ss.code = 'PREPARED'
WHERE c.workerFk = vWorkerFk LEFT JOIN vn.saleTracking st ON st.saleFk = s.id
AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge AND st.stateFk = ss.id
AND s.quantity != 0 WHERE c.workerFk = vWorkerFk
AND s2.order < pc.pendingCollectionsOrder AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge
GROUP BY c.id AND s.quantity
HAVING COUNT(*) > COUNT(DISTINCT st.id); AND s2.order < pc.pendingCollectionsOrder
GROUP BY c.id
HAVING COUNT(*) > COUNT(DISTINCT st.id);
SELECT * FROM tCollection; SELECT * FROM tmp.collection;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -15,6 +15,11 @@ proc: BEGIN
DECLARE vEndingDate DATETIME; DECLARE vEndingDate DATETIME;
DECLARE vIsTodayRelative BOOLEAN; DECLARE vIsTodayRelative BOOLEAN;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
INTO vEndingDate INTO vEndingDate
FROM productionConfig; FROM productionConfig;
@ -31,7 +36,8 @@ proc: BEGIN
CALL prepareClientList(); CALL prepareClientList();
CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems
(INDEX (ticketFk)) ENGINE = MEMORY (INDEX (ticketFk))
ENGINE = MEMORY
SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped
FROM tmp.productionTicket tt FROM tmp.productionTicket tt
JOIN ticket t ON t.id = tt.ticketFk; JOIN ticket t ON t.id = tt.ticketFk;

View File

@ -278,12 +278,11 @@ BEGIN
-- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra
CALL buyUltimate(vWarehouseFk, vDate); CALL buyUltimate(vWarehouseFk, vDate);
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
SELECT ticketFk, problem, saleFk SELECT ticketFk, problem ,saleFk
FROM ( FROM (
SELECT tl.ticketFk, SELECT tl.ticketFk,
s.id saleFk , s.id saleFk,
LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem, LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem
MOD(s.quantity, b.`grouping`) hasRounding
FROM tmp.ticket_list tl FROM tmp.ticket_list tl
JOIN ticket t ON t.id = tl.ticketFk JOIN ticket t ON t.id = tl.ticketFk
AND t.warehouseFk = vWarehouseFk AND t.warehouseFk = vWarehouseFk
@ -291,9 +290,9 @@ BEGIN
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
JOIN buy b ON b.id = bu.buyFk JOIN buy b ON b.id = bu.buyFk
WHERE MOD(s.quantity, b.`grouping`)
GROUP BY tl.ticketFk GROUP BY tl.ticketFk
HAVING hasRounding )sub
) sub
ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk;
END LOOP; END LOOP;
CLOSE vCursor; CLOSE vCursor;

View File

@ -9,6 +9,11 @@ BEGIN
*/ */
DECLARE vStateFk INT; DECLARE vStateFk INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
INSERT INTO ticket ( INSERT INTO ticket (
clientFk, clientFk,
shipped, shipped,