2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-13 07:54:27 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRisk`(
|
2024-04-16 15:01:14 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-05-02 16:13:12 +00:00
|
|
|
* Update the risk problem for a specific ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
*
|
2024-05-02 16:13:12 +00:00
|
|
|
* @param vSelf Id ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
*/
|
|
|
|
DECLARE vHasRisk BOOL;
|
|
|
|
DECLARE vHasHighRisk BOOL;
|
2024-06-27 11:01:42 +00:00
|
|
|
DECLARE vIsProblemCalcNeeded BOOL;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
2024-06-27 11:01:42 +00:00
|
|
|
SELECT t.risk > (c.credit + 10),
|
|
|
|
(t.risk - cc.riskTolerance) > (c.credit + 10),
|
|
|
|
ticket_isProblemCalcNeeded(t.id)
|
|
|
|
INTO vHasRisk, vHasHighRisk, vIsProblemCalcNeeded
|
2024-04-16 15:01:14 +00:00
|
|
|
FROM client c
|
|
|
|
JOIN ticket t ON t.clientFk = c.id
|
|
|
|
JOIN clientConfig cc
|
|
|
|
WHERE t.id = vSelf;
|
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-06-27 11:01:42 +00:00
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT vSelf ticketFk,
|
|
|
|
vHasRisk hasProblem,
|
|
|
|
vIsProblemCalcNeeded isProblemCalcNeeded;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
CALL ticket_setProblem('hasRisk');
|
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-06-27 11:01:42 +00:00
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT vSelf ticketFk,
|
|
|
|
vHasHighRisk hasProblem,
|
|
|
|
vIsProblemCalcNeeded isProblemCalcNeeded;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
CALL ticket_setProblem('hasHighRisk');
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|