feat: refs #7774 #7774 Changes ticket_cloneWeekly
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-08-12 08:53:24 +02:00
parent 5b2200a134
commit c4e8202261
1 changed files with 33 additions and 35 deletions

View File

@ -17,9 +17,12 @@ BEGIN
DECLARE vYear INT;
DECLARE vSalesPersonFK INT;
DECLARE vItemPicker INT;
DECLARE vTicketfailed INT;
DECLARE vEmail VARCHAR(150);
DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
DECLARE rsTicket CURSOR FOR
DECLARE vTickets CURSOR FOR
SELECT tt.ticketFk,
t.clientFk,
t.warehouseFk,
@ -34,18 +37,13 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
CALL `util`.`time_generate`(vDateFrom,vDateTo);
CALL `util`.`time_generate`(vDateFrom, vDateTo);
OPEN rsTicket;
myLoop: LOOP
BEGIN
DECLARE vSalesPersonEmail VARCHAR(150);
DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
OPEN vTickets;
l: LOOP
SET vIsDone = FALSE;
FETCH rsTicket INTO
FETCH vTickets INTO
vTicketFk,
vClientFk,
vWarehouseFk,
@ -55,10 +53,10 @@ BEGIN
vShipment;
IF vIsDone THEN
LEAVE myLoop;
LEAVE l;
END IF;
-- busca si el ticket ya ha sido clonado
-- Busca si el ticket ya ha sido clonado
IF EXISTS (SELECT TRUE FROM ticket tOrig
JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk
JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id
@ -68,7 +66,7 @@ BEGIN
AND tClon.isDeleted = FALSE
AND DATE(tClon.shipped) = vShipment)
THEN
ITERATE myLoop;
ITERATE l;
END IF;
IF vAgencyModeFk IS NULL THEN
@ -184,9 +182,9 @@ BEGIN
ON DUPLICATE KEY UPDATE description =
CONCAT(ticketObservation.description,VALUES(description),' ');
IF (vLanding IS NULL) THEN
IF vLanding IS NULL THEN
SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail
SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail
FROM client c
JOIN worker w ON w.id = c.salesPersonFk
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
@ -203,21 +201,21 @@ BEGIN
SELECT COUNT(*) INTO vIsDuplicateMail
FROM mail
WHERE receiver = vSalesPersonEmail
WHERE receiver = vEmail
AND subject = vSubject;
IF NOT vIsDuplicateMail THEN
CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage);
CALL mail_insert(vEmail, NULL, vSubject, vMessage);
END IF;
CALL ticket_setState(vNewTicket, 'FIXING');
ELSE
CALL ticketCalculateClon(vNewTicket, vTicketFk);
END IF;
END;
END LOOP;
CLOSE rsTicket;
CLOSE vTickets;
DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded;
DROP TEMPORARY TABLE IF EXISTS
tmp.time,
tmp.zoneGetLanded;
END$$
DELIMITER ;