feat: refs #7207 add queue on department change
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
0f8db9ee7e
commit
02e837ebb6
|
@ -0,0 +1,32 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
||||
vBusinessFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Replace the queue of a worker with the queue of the new department.
|
||||
*
|
||||
* @param vBusinessFk business id
|
||||
*/
|
||||
DECLARE vNewQueue VARCHAR(10);
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
DECLARE vPrevQueue VARCHAR(10);
|
||||
|
||||
SELECT d.pbxQueue, s.extension, qm.queue INTO vNewQueue, vExtension, vPrevQueue
|
||||
FROM business b
|
||||
JOIN department d ON d.id = b.departmentFk
|
||||
JOIN pbx.sip s ON s.user_id = b.workerFk
|
||||
LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension
|
||||
WHERE b.id = vBusinessFk;
|
||||
|
||||
IF vNewQueue IS NULL THEN
|
||||
DELETE FROM pbx.queueMember WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
ELSE
|
||||
IF vPrevQueue IS NULL THEN
|
||||
INSERT INTO pbx.queueMember (queue, extension) VALUES (vNewQueue, vExtension);
|
||||
ELSE
|
||||
UPDATE pbx.queueMember SET queue = vNewQueue WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -21,6 +21,8 @@ BEGIN
|
|||
SET businessFk = vNewBusinessFk
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL queueMember_updateQueue(vNewBusinessFk);
|
||||
|
||||
IF vOldBusinessFk IS NULL THEN
|
||||
CALL account.account_enable(vSelf);
|
||||
|
||||
|
|
|
@ -3,9 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
|||
AFTER UPDATE ON `business`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vnIsActive INT;
|
||||
DECLARE vnExtension VARCHAR(10);
|
||||
DECLARE vnQueue VARCHAR(10);
|
||||
DECLARE vIsActive BOOL;
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
|
||||
CALL worker_updateBusiness(NEW.workerFk);
|
||||
|
||||
|
@ -13,13 +12,11 @@ BEGIN
|
|||
CALL worker_updateBusiness(OLD.workerFk);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vnIsActive FROM vn.worker WHERE businessFk = NEW.id;
|
||||
|
||||
IF(vnIsActive) THEN
|
||||
SELECT extension INTO vnExtension FROM pbx.sip WHERE user_id = NEW.workerFk COLLATE utf8mb3_general_ci;
|
||||
SELECT pbxQueue INTO vnQueue FROM vn.department WHERE id = NEW.departmentFk COLLATE utf8mb3_general_ci;
|
||||
|
||||
UPDATE pbx.queueMember SET queue = vnQueue WHERE extension = vnExtension;
|
||||
IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
|
||||
SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
|
||||
IF vIsActive THEN
|
||||
CALL queueMember_updateQueue(NEW.id);
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue