feat: refs #7207 show queue in worker summary #3007
|
@ -175,6 +175,9 @@
|
|||
"PrintConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"QueueMember": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "QueueMember",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "pbx.queueMember"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"queue": {
|
||||
"type": "string"
|
||||
},
|
||||
"extension": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"queueRelation": {
|
||||
|
||||
"type": "belongsTo",
|
||||
"model": "Queue",
|
||||
"foreignKey": "queue",
|
||||
"primaryKey": "name"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"property": "*",
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "employee",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -3988,3 +3988,25 @@ VALUES
|
|||
INSERT IGNORE INTO ormConfig
|
||||
SET id =1,
|
||||
selectLimit = 1000;
|
||||
|
||||
INSERT INTO pbx.queueMultiConfig
|
||||
SET id = 'ring',
|
||||
strategy = 20,
|
||||
timeout = 2,
|
||||
retry = 0,
|
||||
weight = 0,
|
||||
maxLen = 0,
|
||||
ringInUse = 0;
|
||||
|
||||
INSERT INTO pbx.queue (description, name, config)
|
||||
VALUES ('X-men', '1000', 1),
|
||||
('Avengers', '2000', 1);
|
||||
|
||||
INSERT IGNORE INTO pbx.queueMember
|
||||
SET queue = '1000',
|
||||
extension = '1010';
|
||||
|
||||
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
|
||||
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
DELIMITER $$
|
||||
|
||||
jgallego
commented
pon esto pero tienes que transaccionralo ```
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
vBusinessFk INT
)
BEGIN
/**
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
*
* @param vBusinessFk ID del negocio
*/
DECLARE vNewQueue VARCHAR(10);
DECLARE vExtension VARCHAR(10);
-- Obtener la nueva cola y la extensión del trabajador
SELECT d.pbxQueue, s.extension
INTO vNewQueue, vExtension
FROM business b
JOIN department d ON d.id = b.departmentFk
JOIN pbx.sip s ON s.user_id = b.workerFk
WHERE b.id = vBusinessFk;
-- Eliminar cualquier entrada existente en la cola
DELETE FROM pbx.queueMember
WHERE extension = vExtension COLLATE utf8_general_ci
AND queue = vNewQueue;
-- Insertar la nueva entrada en la cola
INSERT INTO pbx.queueMember (queue, extension)
VALUES (vNewQueue, vExtension);
END$$
DELIMITER ;
```
pon esto pero tienes que transaccionralo
jorgep
commented
Este script falla cuando no existe una cola para el nuevo departamento. Este script falla cuando no existe una cola para el nuevo departamento.
Además, no elimina el registro con la cola anterior:
![image](/attachments/0a53872c-9447-4d5d-8ebf-0731352368c7)
jorgep
commented
Creo que así funciona ya bien:
Creo que así funciona ya bien:
```
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
vBusinessFk INT
)
BEGIN
/**
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
*
* @param vBusinessFk ID del negocio
*/
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;
DELETE FROM pbx.queueMember
WHERE extension = vExtension COLLATE utf8_general_ci;
INSERT IGNORE INTO pbx.queueMember (queue, extension)
VALUES (vNewQueue, vExtension);
END$$
DELIMITER ;
```
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
||||
vBusinessFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
|
||||
*
|
||||
* @param vBusinessFk ID del negocio
|
||||
*/
|
||||
DECLARE vNewQueue VARCHAR(10);
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
DECLARE exit handler FOR SQLEXCEPTION
|
||||
|
||||
SELECT d.pbxQueue, s.extension
|
||||
INTO vNewQueue, vExtension
|
||||
FROM business b
|
||||
JOIN department d ON d.id = b.departmentFk
|
||||
JOIN pbx.sip s ON s.user_id = b.workerFk
|
||||
WHERE b.id = vBusinessFk;
|
||||
jgallego
commented
quitar left y variable prev quitar left y variable prev
|
||||
|
||||
DELETE FROM pbx.queueMember
|
||||
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
|
||||
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||
VALUES (vNewQueue, vExtension);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
jgallego
commented
transaccion transaccion
|
|
@ -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,10 +3,20 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
|||
AFTER UPDATE ON `business`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsActive BOOL;
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
|
||||
CALL worker_updateBusiness(NEW.workerFk);
|
||||
|
||||
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
||||
CALL worker_updateBusiness(OLD.workerFk);
|
||||
END IF;
|
||||
|
||||
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 ;
|
||||
|
|
|
@ -25,7 +25,12 @@
|
|||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "user_id"
|
||||
},
|
||||
"queueMember": {
|
||||
"type": "belongsTo",
|
||||
"model": "QueueMember",
|
||||
"foreignKey": "extension",
|
||||
"primaryKey": "extension"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -253,7 +253,18 @@
|
|||
"relation": "client"
|
||||
},
|
||||
{
|
||||
"relation": "sip"
|
||||
"relation": "sip",
|
||||
"scope": {
|
||||
"include": {
|
||||
"relation": "queueMember",
|
||||
"scope": {
|
||||
"fields": [
|
||||
"queue",
|
||||
"extension"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Como tiene un campo llamado queue, no puedo llamar a la relación queue, no funciona.