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

This commit is contained in:
Robert Ferrús 2024-07-24 07:25:43 +02:00
parent 1c45aef883
commit a7f725a194
1 changed files with 39 additions and 1 deletions

View File

@ -17,6 +17,10 @@ BEGIN
DECLARE vYear INT;
DECLARE vSalesPersonFK INT;
DECLARE vItemPicker INT;
DECLARE vTicketfailed INT;
DECLARE vSubjectsTicketfailed VARCHAR(50);
DECLARE vMessagesTicketfailed TEXT;
DECLARE rsTicket CURSOR FOR
SELECT tt.ticketFk,
@ -185,8 +189,11 @@ BEGIN
IF (vLanding IS NULL) THEN
SELECT e.email INTO vSalesPersonEmail
SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail
FROM client c
JOIN worker w ON w.id = c.salesPersonFk
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
JOIN department d ON d.id = wd.departmentFk
JOIN account.emailUser e ON e.userFk = c.salesPersonFk
WHERE c.id = vClientFk;
@ -213,6 +220,37 @@ BEGIN
END;
END LOOP;
CLOSE rsTicket;
WITH tOrigin AS (
SELECT tt.ticketFk,
t.clientFk,
t.warehouseFk,
t.companyFk,
t.addressFk,
tt.agencyModeFk,
ti.dated
FROM ticketWeekly tt
JOIN ticket t ON tt.ticketFk = t.id
JOIN tmp.time ti
WHERE WEEKDAY(ti.dated) = tt.weekDay
),total AS(
SELECT tor.ticketFk, tc.id
FROM tOrigin tor
JOIN sale so ON tor.ticketFk = so.ticketFk
LEFT JOIN ticket tc ON tc.id = tor.ticketFk
AND DATE(tc.shipped) = tor.dated
LEFT JOIN sale sc ON sc.ticketFk = tc.id
WHERE sc.id IS NULL
GROUP BY tor.ticketFk, tc.id
)SELECT COUNT(DISTINCT ticketFk) INTO vTicketfailed
FROM total;
IF vTicketfailed THEN
SET vSubjectsTicketfailed = 'Turnos - Tickets que no se han clonado ';
SET vMessagesTicketfailed = 'No se ha podido clonar tickets revisar que tickets han sido y mirar por que no se han clonado';
CALL mail_insert('nocontestar@verdnatura.es', NULL, vSubjectsTicketfailed, vMessagesTicketfailed);
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded;
END$$
DELIMITER ;