Merge pull request 'feat: refs #7207 show queue in worker summary' (!3007) from 7207-showPbx into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #3007 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
9a7aa315e5
|
@ -175,6 +175,9 @@
|
||||||
"PrintConfig": {
|
"PrintConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"QueueMember": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"ViaexpressConfig": {
|
"ViaexpressConfig": {
|
||||||
"dataSource": "vn"
|
"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
|
INSERT IGNORE INTO ormConfig
|
||||||
SET id =1,
|
SET id =1,
|
||||||
selectLimit = 1000;
|
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 $$
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
DELETE FROM pbx.queueMember
|
||||||
|
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||||
|
VALUES (vNewQueue, vExtension);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -21,6 +21,8 @@ BEGIN
|
||||||
SET businessFk = vNewBusinessFk
|
SET businessFk = vNewBusinessFk
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
CALL queueMember_updateQueue(vNewBusinessFk);
|
||||||
|
|
||||||
IF vOldBusinessFk IS NULL THEN
|
IF vOldBusinessFk IS NULL THEN
|
||||||
CALL account.account_enable(vSelf);
|
CALL account.account_enable(vSelf);
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,20 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
||||||
AFTER UPDATE ON `business`
|
AFTER UPDATE ON `business`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
DECLARE vIsActive BOOL;
|
||||||
|
DECLARE vExtension VARCHAR(10);
|
||||||
|
|
||||||
CALL worker_updateBusiness(NEW.workerFk);
|
CALL worker_updateBusiness(NEW.workerFk);
|
||||||
|
|
||||||
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
||||||
CALL worker_updateBusiness(OLD.workerFk);
|
CALL worker_updateBusiness(OLD.workerFk);
|
||||||
END IF;
|
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$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -25,7 +25,12 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "user_id"
|
"foreignKey": "user_id"
|
||||||
|
},
|
||||||
|
"queueMember": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "QueueMember",
|
||||||
|
"foreignKey": "extension",
|
||||||
|
"primaryKey": "extension"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,18 @@
|
||||||
"relation": "client"
|
"relation": "client"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relation": "sip"
|
"relation": "sip",
|
||||||
|
"scope": {
|
||||||
|
"include": {
|
||||||
|
"relation": "queueMember",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"queue",
|
||||||
|
"extension"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue