2021-05-21 06:49:32 +00:00
|
|
|
DROP PROCEDURE IF EXISTS `vn`.`ticket_getProblems`;
|
|
|
|
|
|
|
|
DELIMITER $$
|
|
|
|
$$
|
|
|
|
CREATE
|
2021-05-25 08:01:18 +00:00
|
|
|
DEFINER = root@`%` PROCEDURE `vn`.`ticket_getProblems`(IN vIsTodayRelative TINYINT(1))
|
2021-05-21 06:49:32 +00:00
|
|
|
BEGIN
|
2021-05-26 11:05:58 +00:00
|
|
|
/**
|
|
|
|
* Calcula los problemas para un conjunto de tickets.
|
|
|
|
* Agrupados por ticket
|
|
|
|
*
|
|
|
|
* @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
|
|
|
|
* @return tmp.ticket_problems
|
|
|
|
*/
|
2021-05-25 08:01:18 +00:00
|
|
|
CALL sale_getProblems(vIsTodayRelative);
|
2021-05-21 06:49:32 +00:00
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems;
|
2021-05-25 08:01:18 +00:00
|
|
|
CREATE TEMPORARY TABLE tmp.ticket_problems
|
|
|
|
(INDEX (ticketFk))
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT
|
|
|
|
ticketFk,
|
|
|
|
MAX(p.isFreezed) AS isFreezed,
|
|
|
|
MAX(p.risk) AS risk,
|
|
|
|
MAX(p.hasTicketRequest) AS hasTicketRequest,
|
|
|
|
MIN(p.isAvailable) AS isAvailable,
|
|
|
|
MAX(p.itemShortage) AS itemShortage,
|
|
|
|
MIN(p.isTaxDataChecked) AS isTaxDataChecked,
|
|
|
|
MAX(p.hasComponentLack) AS hasComponentLack
|
|
|
|
FROM tmp.sale_problems p
|
|
|
|
GROUP BY ticketFk;
|
2021-05-21 06:49:32 +00:00
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
2021-05-25 08:01:18 +00:00
|
|
|
tmp.sale_problems;
|
2021-05-21 06:49:32 +00:00
|
|
|
END;;$$
|
|
|
|
DELIMITER ;
|