fix: refs #8087 refs#8087 errores travel_moveRaids
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
d6a849727e
commit
fc1e0672a4
|
@ -1,17 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`(
|
|
||||||
vIsRaid BOOL,
|
|
||||||
vDaysInForward INT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Check if the values of isRaid and daysInforward are correct
|
|
||||||
*
|
|
||||||
* @param vIsRaid idRaid value
|
|
||||||
* @param vDaysInForward daysInForward value
|
|
||||||
*/
|
|
||||||
IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
|
|
||||||
CALL util.throw('The raid information is not correct');
|
|
||||||
END IF;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -8,22 +8,16 @@ BEGIN
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vBuyerEmail VARCHAR(40);
|
DECLARE vBuyerEmail VARCHAR(40);
|
||||||
DECLARE vTravelLink TEXT;
|
DECLARE vTravelLink TEXT;
|
||||||
DECLARE vMailBody TEXT DEFAULT '';
|
DECLARE vMailBody TEXT;
|
||||||
|
DECLARE vIsMovible BOOL;
|
||||||
|
DECLARE vSubject VARCHAR(30);
|
||||||
|
|
||||||
DECLARE vCur CURSOR FOR
|
DECLARE vTravels CURSOR FOR
|
||||||
SELECT GROUP_CONCAT(DISTINCT
|
SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'),
|
||||||
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
buyerEmail,
|
||||||
ttm.travelFk,
|
isMovable
|
||||||
'/summary ')
|
FROM tTravelToMove
|
||||||
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
|
GROUP BY isMovable, buyerEmail;
|
||||||
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
|
||||||
FROM tTravelToMove ttm
|
|
||||||
JOIN entry e ON e.travelFk = ttm.travelFk
|
|
||||||
JOIN buy b ON b.entryFk = e.id
|
|
||||||
JOIN item i ON i.id = b.itemFk
|
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
|
||||||
JOIN account.user u ON u.id = it.workerFk
|
|
||||||
GROUP BY u.name;
|
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
@ -34,35 +28,54 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
||||||
SELECT id travelFk,
|
WITH travels AS (
|
||||||
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
|
SELECT id ,
|
||||||
|
CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink,
|
||||||
|
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded,
|
||||||
|
shipped <= util.VN_CURDATE() + INTERVAL daysInForward DAY isMovable
|
||||||
FROM travel
|
FROM travel
|
||||||
WHERE isRaid
|
WHERE isRaid
|
||||||
AND daysInForward;
|
AND daysInForward
|
||||||
|
)SELECT t.*,
|
||||||
|
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
||||||
|
FROM travels t
|
||||||
|
STRAIGHT_JOIN entry e ON e.travelFk = t.id
|
||||||
|
JOIN buy b ON b.entryFk = e.id
|
||||||
|
JOIN item i ON i.id = b.itemFk
|
||||||
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
|
JOIN account.user u ON u.id = it.workerFk
|
||||||
|
GROUP BY t.id;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE travel tr
|
UPDATE travel tr
|
||||||
JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
|
JOIN tTravelToMove ttm ON ttm.id = tr.id
|
||||||
SET tr.landed = ttm.newLanded;
|
SET tr.landed = ttm.newLanded
|
||||||
|
WHERE ttm.isMovable;
|
||||||
|
|
||||||
OPEN vCur;
|
OPEN vTravels;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vCur INTO vTravelLink, vBuyerEmail;
|
FETCH vTravels INTO vTravelLink, vBuyerEmail, vIsMovible;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL `vn`.`mail_insert`(
|
IF vIsMovible THEN
|
||||||
vBuyerEmail,
|
SET vSubject = 'Cambio de fecha en Redadas';
|
||||||
'noreply@verdnatura.es',
|
SET vMailBody = 'Se ha movido los siguientes travels';
|
||||||
'Cambio de fecha en Redadas',
|
ELSE
|
||||||
CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
|
SET vSubject = 'ERROR al cambiar la fecha en Redadas';
|
||||||
|
SET vMailBody = 'Ha ocurrido un error con las fechas al mover los siguiente travels';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET vMailBody = CONCAT(vMailBody, ': \n\r ', vTravelLink);
|
||||||
|
|
||||||
|
CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vCur;
|
CLOSE vTravels;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
DROP TEMPORARY TABLE tTravelToMove;
|
DROP TEMPORARY TABLE tTravelToMove;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -9,10 +9,6 @@ BEGIN
|
||||||
|
|
||||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||||
|
|
||||||
IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
|
|
||||||
CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF NEW.awbFk IS NOT NULL THEN
|
IF NEW.awbFk IS NOT NULL THEN
|
||||||
CALL travel_throwAwb(NEW.id);
|
CALL travel_throwAwb(NEW.id);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
Loading…
Reference in New Issue