Преглед изворни кода

feat: 完善sdk接口服务

余尚辉 пре 4 месеци
родитељ
комит
faf60c049d

+ 0 - 2
docker-compose.yml

@@ -4,8 +4,6 @@ services:
     container_name: pjsua
     restart: always
     network_mode: host
-    ports:
-      - "8000:8000"
     volumes:
       - /home/hongshan/voice-gateway-service:/code
     environment:

+ 224 - 0
sql/_localhost-2024_10_26_17_20_04-dump.sql

@@ -0,0 +1,224 @@
+-- MySQL dump 10.13  Distrib 8.0.28, for macos11 (x86_64)
+--
+-- Host: 127.0.0.1    Database: libra_bot
+-- ------------------------------------------------------
+-- Server version	8.0.28
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `c_agent`
+--
+
+DROP TABLE IF EXISTS `c_agent`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `agent_name` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席姓名',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `agent_pwd` varchar(64) NOT NULL DEFAULT '' COMMENT '坐席密码',
+  `agent_type` tinyint NOT NULL DEFAULT '0' COMMENT '坐席类型 0:普通坐席 ;1:组长:2:主管',
+  `phone_num` varchar(32) NOT NULL DEFAULT '0' COMMENT '分机号',
+  `distribute` tinyint NOT NULL DEFAULT '1' COMMENT '分配标志  0:不参与排队;1:参与排队',
+  `agent_state` tinyint NOT NULL DEFAULT '0' COMMENT '账号状态 0:可用;1:禁用',
+  `identity_type` tinyint NOT NULL DEFAULT '0' COMMENT '身份标识',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uniq_vcc_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_vcc_id_out_id` (`saas_id`,`out_id`),
+  KEY `idx_vcc_id_phone_num` (`saas_id`,`phone_num`)
+) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席信息表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent`
+--
+
+LOCK TABLES `c_agent` WRITE;
+/*!40000 ALTER TABLE `c_agent` DISABLE KEYS */;
+INSERT INTO `c_agent` VALUES (1,'mdj','1000','user0','1000','123456',0,'1000',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:46:31'),(3,'mdj','1001','user1','1001','123456',0,'1001',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(4,'mdj','1002','user2','1002','123456',0,'1002',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(5,'mdj','1003','user3','1003','123456',0,'1003',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(6,'mdj','1004','user4','1004','123456',0,'1004',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(7,'mdj','1005','user5','1005','123456',0,'1005',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(8,'mdj','1006','user6','1006','123456',0,'1006',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(9,'mdj','1007','user7','1007','123456',0,'1007',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(10,'mdj','1008','user8','1008','123456',0,'1008',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(11,'mdj','1009','user9','1009','123456',0,'1009',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10');
+/*!40000 ALTER TABLE `c_agent` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_action_log`
+--
+
+DROP TABLE IF EXISTS `c_agent_action_log`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_action_log` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `action_type` tinyint NOT NULL DEFAULT '0' COMMENT '行为类型',
+  `check_state` tinyint NOT NULL DEFAULT '-1' COMMENT '签入或签出',
+  `pre_check_state` tinyint NOT NULL DEFAULT '-1' COMMENT '签入或签出',
+  `service_state` tinyint NOT NULL DEFAULT '-1' COMMENT '坐席状态',
+  `pre_service_state` tinyint NOT NULL DEFAULT '-1' COMMENT '坐席状态',
+  `check_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '签入或签出时间',
+  `pre_check_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '上一次签入或签出时间',
+  `service_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '坐席状态变更时间',
+  `pre_service_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '上一次坐席状态变更时间',
+  `check_state_duration` bigint NOT NULL DEFAULT '0' COMMENT '行为持续时间',
+  `service_state_duration` bigint NOT NULL DEFAULT '0' COMMENT '状态持续时间',
+  `task_id` varchar(32) NOT NULL DEFAULT '' COMMENT '任务Id',
+  `service_id` varchar(32) NOT NULL DEFAULT '' COMMENT '人工组id',
+  `event_type` int NOT NULL DEFAULT '0' COMMENT '日志事件类型',
+  `event_desc` varchar(100) NOT NULL DEFAULT '' COMMENT '日志事件描述',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_create_time` (`create_time`),
+  KEY `idx_update_time` (`update_time`),
+  KEY `idx_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`),
+  KEY `idx_saas_id_task_id` (`saas_id`,`task_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席行为日志表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_action_log`
+--
+
+LOCK TABLES `c_agent_action_log` WRITE;
+/*!40000 ALTER TABLE `c_agent_action_log` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_action_log` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_log`
+--
+
+DROP TABLE IF EXISTS `c_agent_log`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_log` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `flow_id` varchar(64) NOT NULL DEFAULT '' COMMENT '人工外呼流程ID',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `event_type` tinyint NOT NULL DEFAULT '0' COMMENT '事件类型',
+  `event` varchar(32) NOT NULL DEFAULT '0' COMMENT '事件',
+  `content` varchar(64) NOT NULL DEFAULT '' COMMENT '描述',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席日志表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_log`
+--
+
+LOCK TABLES `c_agent_log` WRITE;
+/*!40000 ALTER TABLE `c_agent_log` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_log` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_monitor`
+--
+
+DROP TABLE IF EXISTS `c_agent_monitor`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_monitor` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `identity_type` tinyint NOT NULL DEFAULT '0' COMMENT '身份标识',
+  `check_state` tinyint NOT NULL DEFAULT '1' COMMENT '是否签入 0:是 1: 否  默认未签入',
+  `check_scene` varchar(16) NOT NULL DEFAULT '' COMMENT '迁入场景',
+  `check_in_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签入时间',
+  `check_out_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签出时间',
+  `service_state` tinyint NOT NULL DEFAULT '0' COMMENT '坐席服务状态 0: 未登录(签出) 1: 置忙 2: 置闲 3: 通话中 4: 后处理 5: 拨号中',
+  `busy_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '置忙时间',
+  `idle_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '置闲时间',
+  `call_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '接通时间',
+  `hang_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '挂断时间',
+  `heart_state` tinyint NOT NULL DEFAULT '0' COMMENT '心跳状态 0: 默认 1:正常  2: 异常',
+  `heart_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '正常心跳时间',
+  `session_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'sessionId',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uniq_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席监控表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_monitor`
+--
+
+LOCK TABLES `c_agent_monitor` WRITE;
+/*!40000 ALTER TABLE `c_agent_monitor` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_monitor` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_phone`
+--
+
+DROP TABLE IF EXISTS `c_phone`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_phone` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
+  `saas_id` varchar(16) NOT NULL DEFAULT '',
+  `phone_num` varchar(32) NOT NULL DEFAULT '0',
+  `phone_pwd` varchar(32) NOT NULL DEFAULT '',
+  `sip_server` varchar(64) NOT NULL DEFAULT '',
+  `wss_server` varchar(64) NOT NULL DEFAULT '',
+  `ice_server` varchar(64) NOT NULL DEFAULT '',
+  `is_delete` tinyint NOT NULL DEFAULT '0',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  KEY `idx_vcc_id_phone_num` (`saas_id`,`phone_num`)
+) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分机信息表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_phone`
+--
+
+LOCK TABLES `c_phone` WRITE;
+/*!40000 ALTER TABLE `c_phone` DISABLE KEYS */;
+INSERT INTO `c_phone` VALUES (1,'mdj','1000','slibra@#123456','sip:1000@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(2,'mdj','1001','slibra@#123456','sip:1001@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(3,'mdj','1002','slibra@#123456','sip:1002@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(4,'mdj','1003','slibra@#123456','sip:1003@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(5,'mdj','1004','slibra@#123456','sip:1004@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(6,'mdj','1005','slibra@#123456','sip:1005@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(7,'mdj','1006','slibra@#123456','sip:1006@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(8,'mdj','1007','slibra@#123456','sip:1007@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(9,'mdj','1008','slibra@#123456','sip:1008@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(10,'mdj','1009','slibra@#123456','sip:1009@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56');
+/*!40000 ALTER TABLE `c_phone` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-10-26 17:20:05

+ 304 - 0
sql/_localhost-2024_10_27_16_08_25-dump.sql

@@ -0,0 +1,304 @@
+-- MySQL dump 10.13  Distrib 8.0.28, for macos11 (x86_64)
+--
+-- Host: 127.0.0.1    Database: libra_bot
+-- ------------------------------------------------------
+-- Server version	8.0.28
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `c_agent`
+--
+
+DROP TABLE IF EXISTS `c_agent`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `agent_name` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席姓名',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `agent_pwd` varchar(64) NOT NULL DEFAULT '' COMMENT '坐席密码',
+  `agent_type` tinyint NOT NULL DEFAULT '0' COMMENT '坐席类型 0:普通坐席 ;1:组长:2:主管',
+  `phone_num` varchar(32) NOT NULL DEFAULT '0' COMMENT '分机号',
+  `distribute` tinyint NOT NULL DEFAULT '1' COMMENT '分配标志  0:不参与排队;1:参与排队',
+  `agent_state` tinyint NOT NULL DEFAULT '0' COMMENT '账号状态 0:可用;1:禁用',
+  `identity_type` tinyint NOT NULL DEFAULT '0' COMMENT '身份标识',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uniq_vcc_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_vcc_id_out_id` (`saas_id`,`out_id`),
+  KEY `idx_vcc_id_phone_num` (`saas_id`,`phone_num`)
+) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席信息表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent`
+--
+
+LOCK TABLES `c_agent` WRITE;
+/*!40000 ALTER TABLE `c_agent` DISABLE KEYS */;
+INSERT INTO `c_agent` VALUES (1,'mdj','1000','user0','1000','123456',0,'1000',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:46:31'),(3,'mdj','1001','user1','1001','123456',0,'1001',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(4,'mdj','1002','user2','1002','123456',0,'1002',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(5,'mdj','1003','user3','1003','123456',0,'1003',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(6,'mdj','1004','user4','1004','123456',0,'1004',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(7,'mdj','1005','user5','1005','123456',0,'1005',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(8,'mdj','1006','user6','1006','123456',0,'1006',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(9,'mdj','1007','user7','1007','123456',0,'1007',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(10,'mdj','1008','user8','1008','123456',0,'1008',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10'),(11,'mdj','1009','user9','1009','123456',0,'1009',1,0,0,0,'2024-10-08 08:50:08','2024-10-08 08:49:10');
+/*!40000 ALTER TABLE `c_agent` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_action_log`
+--
+
+DROP TABLE IF EXISTS `c_agent_action_log`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_action_log` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `action_type` tinyint NOT NULL DEFAULT '0' COMMENT '行为类型',
+  `check_state` tinyint NOT NULL DEFAULT '-1' COMMENT '签入或签出',
+  `pre_check_state` tinyint NOT NULL DEFAULT '-1' COMMENT '签入或签出',
+  `service_state` tinyint NOT NULL DEFAULT '-1' COMMENT '坐席状态',
+  `pre_service_state` tinyint NOT NULL DEFAULT '-1' COMMENT '坐席状态',
+  `check_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '签入或签出时间',
+  `pre_check_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '上一次签入或签出时间',
+  `service_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '坐席状态变更时间',
+  `pre_service_state_time` timestamp NOT NULL DEFAULT '1999-12-31 16:00:00' COMMENT '上一次坐席状态变更时间',
+  `check_state_duration` bigint NOT NULL DEFAULT '0' COMMENT '行为持续时间',
+  `service_state_duration` bigint NOT NULL DEFAULT '0' COMMENT '状态持续时间',
+  `task_id` varchar(32) NOT NULL DEFAULT '' COMMENT '任务Id',
+  `service_id` varchar(32) NOT NULL DEFAULT '' COMMENT '人工组id',
+  `event_type` int NOT NULL DEFAULT '0' COMMENT '日志事件类型',
+  `event_desc` varchar(100) NOT NULL DEFAULT '' COMMENT '日志事件描述',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_create_time` (`create_time`),
+  KEY `idx_update_time` (`update_time`),
+  KEY `idx_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`),
+  KEY `idx_saas_id_task_id` (`saas_id`,`task_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席行为日志表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_action_log`
+--
+
+LOCK TABLES `c_agent_action_log` WRITE;
+/*!40000 ALTER TABLE `c_agent_action_log` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_action_log` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_log`
+--
+
+DROP TABLE IF EXISTS `c_agent_log`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_log` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `flow_id` varchar(64) NOT NULL DEFAULT '' COMMENT '人工外呼流程ID',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `event_type` tinyint NOT NULL DEFAULT '0' COMMENT '事件类型',
+  `event` varchar(32) NOT NULL DEFAULT '0' COMMENT '事件',
+  `content` varchar(64) NOT NULL DEFAULT '' COMMENT '描述',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席日志表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_log`
+--
+
+LOCK TABLES `c_agent_log` WRITE;
+/*!40000 ALTER TABLE `c_agent_log` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_log` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_agent_monitor`
+--
+
+DROP TABLE IF EXISTS `c_agent_monitor`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_agent_monitor` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `agent_num` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `out_id` varchar(32) NOT NULL DEFAULT '' COMMENT '外部id',
+  `identity_type` tinyint NOT NULL DEFAULT '0' COMMENT '身份标识',
+  `check_state` tinyint NOT NULL DEFAULT '1' COMMENT '是否签入 0:是 1: 否  默认未签入',
+  `check_scene` varchar(16) NOT NULL DEFAULT '' COMMENT '迁入场景',
+  `check_in_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签入时间',
+  `check_out_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签出时间',
+  `service_state` tinyint NOT NULL DEFAULT '0' COMMENT '坐席服务状态 0: 未登录(签出) 1: 置忙 2: 置闲 3: 通话中 4: 后处理 5: 拨号中',
+  `busy_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '置忙时间',
+  `idle_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '置闲时间',
+  `call_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '接通时间',
+  `hang_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '挂断时间',
+  `heart_state` tinyint NOT NULL DEFAULT '0' COMMENT '心跳状态 0: 默认 1:正常  2: 异常',
+  `heart_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '正常心跳时间',
+  `session_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'sessionId',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uniq_saas_id_agent_num` (`saas_id`,`agent_num`),
+  KEY `idx_saas_id_out_id` (`saas_id`,`out_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='坐席监控表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_agent_monitor`
+--
+
+LOCK TABLES `c_agent_monitor` WRITE;
+/*!40000 ALTER TABLE `c_agent_monitor` DISABLE KEYS */;
+/*!40000 ALTER TABLE `c_agent_monitor` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_human_service`
+--
+
+DROP TABLE IF EXISTS `c_human_service`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_human_service` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `service_id` varchar(32) NOT NULL DEFAULT '' COMMENT '人工组编号',
+  `service_name` varchar(32) NOT NULL DEFAULT '' COMMENT '人工组名称',
+  `schedule_key` varchar(32) NOT NULL DEFAULT '' COMMENT '日程编号',
+  `effective` varchar(32) NOT NULL DEFAULT '0' COMMENT '状态 0:启用(可以或正在进行外呼)1:暂停',
+  `service_start` varchar(32) NOT NULL DEFAULT '' COMMENT '任务开始时间 yyyyMMddHHmmss',
+  `service_end` varchar(32) NOT NULL DEFAULT '22200101000000' COMMENT '任务结束时间 yyyyMMddHHmmss',
+  `distribute` varchar(32) NOT NULL DEFAULT '3' COMMENT '分配策略',
+  `call_in_limit` varchar(32) NOT NULL DEFAULT '0' COMMENT '呼入线数 限制 固定值0',
+  `record_type` varchar(32) NOT NULL DEFAULT '1' COMMENT '录音方式 默认0 0:服务器不录 1:服务器录 4:按间隔抽样录 5:按百分比抽样录 固定值 1',
+  `queue_length` varchar(32) NOT NULL DEFAULT '100' COMMENT '排队长度 固定值 100',
+  `queue_warning` varchar(32) NOT NULL DEFAULT '100' COMMENT '排队告警 长度 固定值 100',
+  `queue_timeout` varchar(32) NOT NULL DEFAULT '60' COMMENT '排队超时 时间 固定值 60',
+  `sum_queue_time` varchar(32) NOT NULL DEFAULT '90' COMMENT '所有排队 时间  单位:秒;默认300: 固定值 90',
+  `connect_type` varchar(32) NOT NULL DEFAULT '0' COMMENT '连接坐席 类型 默认0 0盲转连接 1桥接连接并超时重排 固定值 0',
+  `queue_music` varchar(32) NOT NULL DEFAULT '' COMMENT '排队音 全局配置',
+  `direct_queue_type` varchar(32) NOT NULL DEFAULT '' COMMENT '直接连接 媒体类型 默认1 接入码直接转人工服务能听到排队音 0:直接排队不连接媒体; 1:直接排队连接媒体 全局配置',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_create_time` (`create_time`),
+  KEY `idx_update_time` (`update_time`),
+  KEY `idx_saas_id_service_id` (`saas_id`,`service_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='人工服务组信息';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_human_service`
+--
+
+LOCK TABLES `c_human_service` WRITE;
+/*!40000 ALTER TABLE `c_human_service` DISABLE KEYS */;
+INSERT INTO `c_human_service` VALUES (1,'mdj','00000000000000000','默认坐席组','mdj','0','22200101000000','22200101000000','3','0','1','100','100','60','90','0','','',0,'2024-10-27 06:51:07','2023-03-28 09:29:28');
+/*!40000 ALTER TABLE `c_human_service` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_human_service_map`
+--
+
+DROP TABLE IF EXISTS `c_human_service_map`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_human_service_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `saas_id` varchar(16) NOT NULL DEFAULT '' COMMENT '租户隔离',
+  `service_id` varchar(32) NOT NULL DEFAULT '' COMMENT '人工组编号',
+  `service_type` varchar(32) NOT NULL DEFAULT '0' COMMENT '服务类型',
+  `agent_id` varchar(32) NOT NULL DEFAULT '' COMMENT '坐席工号',
+  `state` tinyint NOT NULL DEFAULT '0' COMMENT '状态 1激活(签入)',
+  `is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '删除标识',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`id`),
+  KEY `idx_create_time` (`create_time`),
+  KEY `idx_update_time` (`update_time`),
+  KEY `idx_saas_id_service_id_agent_id` (`saas_id`,`service_id`,`agent_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='人工服务组与坐席关系';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_human_service_map`
+--
+
+LOCK TABLES `c_human_service_map` WRITE;
+/*!40000 ALTER TABLE `c_human_service_map` DISABLE KEYS */;
+INSERT INTO `c_human_service_map` VALUES (1,'mdj','00000000000000000','0','1000',0,0,'2024-10-27 06:50:55','2023-03-28 09:34:52'),(2,'mdj','00000000000000000','0','1001',0,0,'2024-10-27 06:50:55','2023-03-28 09:35:49'),(3,'mdj','00000000000000000','0','1002',0,0,'2024-10-27 06:50:55','2023-04-06 11:16:34'),(4,'mdj','00000000000000000','0','1003',0,0,'2024-10-27 06:50:55','2023-04-06 11:16:57'),(5,'mdj','00000000000000000','1','1004',0,0,'2024-10-27 06:50:55','2023-04-12 09:44:38'),(6,'mdj','00000000000000000','0','1005',0,0,'2024-10-27 06:50:55','2023-04-12 09:58:27'),(7,'mdj','00000000000000000','0','1006',0,0,'2024-10-27 06:50:55','2023-04-12 11:15:34'),(8,'mdj','00000000000000000','0','1007',0,0,'2024-10-27 06:50:55','2023-04-13 03:01:22'),(9,'mdj','00000000000000000','0','1008',0,0,'2024-10-27 06:50:55','2023-04-13 03:01:26'),(10,'mdj','00000000000000000','0','1009',0,0,'2024-10-27 06:50:55','2023-04-13 03:01:30');
+/*!40000 ALTER TABLE `c_human_service_map` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `c_phone`
+--
+
+DROP TABLE IF EXISTS `c_phone`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `c_phone` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
+  `saas_id` varchar(16) NOT NULL DEFAULT '',
+  `phone_num` varchar(32) NOT NULL DEFAULT '0',
+  `phone_pwd` varchar(32) NOT NULL DEFAULT '',
+  `sip_server` varchar(64) NOT NULL DEFAULT '',
+  `wss_server` varchar(64) NOT NULL DEFAULT '',
+  `ice_server` varchar(64) NOT NULL DEFAULT '',
+  `is_delete` tinyint NOT NULL DEFAULT '0',
+  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  KEY `idx_vcc_id_phone_num` (`saas_id`,`phone_num`)
+) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分机信息表';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `c_phone`
+--
+
+LOCK TABLES `c_phone` WRITE;
+/*!40000 ALTER TABLE `c_phone` DISABLE KEYS */;
+INSERT INTO `c_phone` VALUES (1,'mdj','1000','slibra@#123456','sip:1000@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(2,'mdj','1001','slibra@#123456','sip:1001@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(3,'mdj','1002','slibra@#123456','sip:1002@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(4,'mdj','1003','slibra@#123456','sip:1003@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(5,'mdj','1004','slibra@#123456','sip:1004@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(6,'mdj','1005','slibra@#123456','sip:1005@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(7,'mdj','1006','slibra@#123456','sip:1006@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(8,'mdj','1007','slibra@#123456','sip:1007@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(9,'mdj','1008','slibra@#123456','sip:1008@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56'),(10,'mdj','1009','slibra@#123456','sip:1009@pbx.fuxicarbon.com:5060','wss://pbx.fuxicarbon.com:7443','stun:pbx.fuxicarbon.com:3478',1,'2024-10-08 08:43:56','2024-10-08 08:43:56');
+/*!40000 ALTER TABLE `c_phone` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-10-27 16:08:26

+ 2 - 2
src/core/callcenter/agent.py

@@ -216,10 +216,10 @@ class AgentService:
         return phone.to_dict()
 
     def watch_agent_state(self, req: HumanServiceQueryRequest):
-        pos = HumanServiceMap.query.filter(HumanServiceMap.is_delete == 0, HumanServiceMap.saas_id == req.saasId,
+        pos = HumanServiceMap.query.filter(HumanServiceMap.is_delete == 0, HumanServiceMap.saas_id == req.saas_id,
                                            HumanServiceMap.service_id == req.serviceId).all()
         agent_ids = [x.agent_id for x in pos]
-        monitors = self.agent_monitor_service.detail_monitor_out_ids(req.saasId, agent_ids)
+        monitors = self.agent_monitor_service.detail_monitor_out_ids(req.saas_id, agent_ids)
         return monitors
 
     def add(self, req: AgentRequest):

+ 5 - 2
src/core/callcenter/api.py

@@ -120,11 +120,14 @@ class AgentActionRequest(BaseApi):
 class HumanServiceQueryRequest(BaseApi):
     """人工组查询"""
 
-    def __init__(self, saas_id, service_id, agent_state, agent_ids: Dict[str, Any] = {}):
-        self.saasId = saas_id
+    def __init__(self, saas_id, service_id=None, agent_state=None, agent_ids: Dict[str, Any] = {}, **kwargs):
+        self.saas_id = saas_id
         self.serviceId = service_id
         self.agentState = agent_state
         self.agentIds = agent_ids
+        # 处理多余的参数
+        for key, value in kwargs.items():
+            setattr(self, key, value)
 
 
 class AgentMonitorData(BaseApi):

+ 5 - 1
src/core/callcenter/config.py

@@ -19,7 +19,11 @@ class BaseConfig(object):
     SQLALCHEMY_DATABASE_URI = f"{DIALCT}+{DRITVER}://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}?charset=utf8"
     SQLALCHEMY_TRACK_MODIFICATIONS = True   # Disable track modifications
     SQLALCHEMY_ECHO = True  # Optional: Log SQL queries
-
+    SQLALCHEMY_ENGINE_OPTIONS= {
+        'connect_args': {
+            'init_command': "SET time_zone = 'Asia/Shanghai'"
+        }
+    }
 
 # dictConfig({
 #         "version": 1,

+ 74 - 1
src/core/callcenter/push.py

@@ -39,4 +39,77 @@ class PushHandler:
             }
         }
         self.logger.info("OnAgentReport event triger:", json.dumps(data))
-        common_down_data(out_id, data)
+        common_down_data(out_id, data)
+
+    def push_on_call_ring(self, saas_id, flow_id, user_id,scene, call_id, file_name, calling_no, called_no, human_service_id):
+        data = {
+            'eventName': DownEvent.ON_CALLRING.code,
+            'ext': {
+                'callId':call_id,
+                'ctiFlowId':flow_id,
+                'scene': scene.code,
+                'fileName': file_name,
+                'serviceDirect':'',
+                'callingNo': calling_no,
+                'calledNo': called_no,
+                'serviceTaskId': human_service_id
+            }
+        }
+        self.logger.info("flowId:[%s] OnAgentWorkReport push:[%s].", flow_id, json.dumps(data))
+        new_data = {'data': json.dumps(data)}
+        common_down_data(user_id, json.dumps(new_data))
+
+    def push_on_call_end(self, saas_id, flow_id, user_id,  scene, service_direct=None, disconnect_type=0):
+        data = {
+            'eventName': DownEvent.ON_CALL_END.code,
+            'ext': {
+                'ctiFlowId': flow_id,
+                'scene': scene.code,
+                'disconnectType': disconnect_type,
+                'serviceDirect': service_direct
+            }
+        }
+        self.logger.info("flowId:[%s] OnAgentWorkReport push:[%s].", flow_id, json.dumps(data))
+        new_data = {'data': json.dumps(data)}
+        common_down_data(user_id, json.dumps(new_data))
+
+    def push_on_ring_start(self, saas_id, flow_id, user_id, scene, call_id=None):
+        data = {
+            'eventName': DownEvent.ON_RING_Start.code,
+            'ext': {
+                'ctiFlowId': flow_id,
+                'scene': scene.code,
+                'callId': call_id
+            }
+        }
+        self.logger.info("flowId:[%s] push_on_ring_start push:[%s].", flow_id, json.dumps(data))
+        new_data = {'data': json.dumps(data)}
+        common_down_data(user_id, json.dumps(new_data))
+
+    def push_on_ring_end(self, saas_id, flow_id, user_id, scene, call_id):
+        data = {
+            'eventName': DownEvent.ON_RING_END.code,
+            'ext': {
+                'ctiFlowId': flow_id,
+                'scene': scene.code,
+                'callId': call_id,
+            }
+        }
+        self.logger.info("flowId:[%s] push_on_ring_end push:[%s].", flow_id, json.dumps(data))
+        new_data = {'data': json.dumps(data)}
+        common_down_data(user_id, json.dumps(new_data))
+
+    def push_answer_call(self, saas_id,flow_id, out_id, call_id, scene, service_direct,work_status,user_id ):
+        data = {
+            'eventName': DownEvent.ANSWER_CALL.code,
+            'ext': {
+                'ctiFlowId': flow_id,
+                'scene': scene.code,
+                'callId': call_id,
+                'serviceDirect':service_direct,
+                'workStatus':work_status
+            }
+        }
+        self.logger.info("flowId:[%s] push_on_ring_end push:[%s].", flow_id, json.dumps(data))
+        new_data = {'data': json.dumps(data)}
+        common_down_data(user_id, json.dumps(new_data))

+ 5 - 5
src/core/callcenter/views.py

@@ -16,13 +16,13 @@ from flask import Flask, request, render_template_string
 from src.core.callcenter.call import CallService
 from src.core.callcenter.api import AgentCallRequest, AgentActionRequest, HangupCallRequest, \
     HumanServiceQueryRequest
-# from src.core.voip.bot import BotAgent
+from src.core.voip.bot import BotAgent
 
 
-# agent = BotAgent(app.logger)
-agent = None
+agent = BotAgent(app.logger)
+# agent = None
 inbound_client = InboundClient(agent, app.logger)
-# outbound_client = OutboundClient(agent, app.logger)
+outbound_client = OutboundClient(agent, app.logger)
 call_service = CallService(inbound_client, app.logger)
 agent_service = AgentService(inbound_client, app.logger)
 agent_oper_service = AgentOperService(inbound_client, app.logger)
@@ -180,7 +180,7 @@ def manual_call():
     # callId: string
     data = request.get_json()
     req = AgentCallRequest(saas_id=data.get('saas_id'), call_type=CallType.OUTBOUND_CALL, caller=data.get('caller'),
-                           agent_id=data.get('caller'), called=data.get('called'))
+                           agent_id=data.get('agent_id'), called=data.get('called'))
     res = call_service.call(req)
     return success_response(res)
 

+ 4 - 3
src/core/datasource.py

@@ -15,12 +15,13 @@ from src.core import singleton
 from redis import StrictRedis, ConnectionPool
 
 SERVE_HOST = os.environ.get("SERVE_HOST")
-SERVE_HOST = "192.168.124.6"
+# SERVE_HOST = "192.168.110.203"
 MYSQL_PASSWORD = 'EKoAe3H8xybQKrFPApXM'
 
 if SERVE_HOST != "192.168.100.159":
-    SIP_SERVER = SERVE_HOST
-    MYSQL_PASSWORD = "12345678"
+    # SIP_SERVER = SERVE_HOST
+    # MYSQL_PASSWORD = "12345678"
+    SIP_SERVER = "pbx.fuxicarbon.com"
 else:
     SIP_SERVER = "pbx.fuxicarbon.com"