فهرست منبع

Merge branch 'develop' of ssh://gitlab.fuxicarbon.com:1111/client_service/voice-gateway-service into develop

shanghui 2 ماه پیش
والد
کامیت
baf02f2449

BIN
src.tar.gz


+ 1 - 0
src/core/callcenter/agent.py

@@ -298,6 +298,7 @@ class AgentOperService:
                 # self.logger.info('check_agent_live_daemon, members=%s, diff=%s, pre_val=%s', (len(_members) if _members else 0), diff, pre_val)
                 if diff > self.agent_serial_live_expire:
                     self.logger.warn('WARING::live agent count less than 1 serial ten minutes')
+                    self.data_handle_server.create_warning_record(1, '10分钟空岗报警')
                     self.redis_handler.redis.delete(key)
 
                 if _members and len(_members) > 0:

+ 34 - 0
src/core/callcenter/dao.py

@@ -528,4 +528,38 @@ class BotRecords(db.Model):
             'intent': self.intent,
             'contents': self.contents,
             'dialog': self.dialog,
+        }
+
+class WarningRecord(db.Model):
+    __tablename__ = 't_warning_record'
+    __table_args__ = {'comment': '告警记录表'}
+
+    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='主键')
+    type = db.Column(db.SmallInteger, nullable=True, comment='类型(0:连续5个未接  1:10分钟空岗报警  2:连续3个5s内挂断)')
+    desc = db.Column(db.String(500), nullable=True, comment='报警描述')
+    read = db.Column(db.SmallInteger, nullable=False, default=0, comment='是否已读(0否 1是)')
+    del_flag = db.Column(db.SmallInteger, nullable=False, default=0, comment='删除标志(0代表存在 2代表删除)')
+    revision = db.Column(db.Integer, nullable=True, comment='乐观锁')
+    create_by = db.Column(db.String(100), nullable=True, comment='创建人')
+    create_time = db.Column(db.DateTime, nullable=True, comment='创建时间')
+    update_by = db.Column(db.String(100), nullable=True, comment='更新人')
+    update_time = db.Column(db.DateTime, nullable=True, comment='更新时间')
+    remark = db.Column(db.String(500), nullable=True, comment='备注')
+
+    def __repr__(self):
+        return json.dumps(self.to_dict())
+
+    def to_dict(self):
+        return {
+            'id': self.id,
+            'type': self.type,
+            'desc': self.desc,
+            'read': self.read,
+            'del_flag': self.del_flag,
+            'revision': self.revision,
+            'create_by': self.create_by,
+            'create_time': self.create_time.isoformat() if self.create_time else None,
+            'update_by': self.update_by,
+            'update_time': self.update_time.isoformat() if self.update_time else None,
+            'remark': self.remark,
         }

+ 11 - 0
src/core/callcenter/data_handler.py

@@ -35,6 +35,17 @@ class DataHandleServer:
             db.session.rollback()
             raise ValueError(f"创建记录失败: {e}")
 
+    @with_app_context
+    def create_warning_record(self, warning_type, warning_desc):
+        try:
+            warn_record = WarningRecord(type=warning_type, desc=warning_desc, create_time=datetime.now())
+            db.session.add(warn_record)
+            db.session.commit()
+            print("报警记录创建成功")
+        except Exception as e:
+            db.session.rollback()
+            raise ValueError(f"报警创建记录失败: {e}")
+
     @with_app_context
     def update_record(self, session_id, **kwargs):
         self.app.logger.info(f"update_record::session_id:{session_id}")

+ 3 - 1
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -146,10 +146,12 @@ class ChannelHangupHandler(EslEventHandler):
         no_answer_cnt = self.cache.get_serial_no_answer_cnt(call_info)
         if no_answer_cnt >=5:
             self.logger.warn('WARING::serial_no_answer_cnt greater than 5')
+            self.dataHandleServer.create_warning_record(0, '连续5个未接')
 
         no_speed_hangup_cnt = self.cache.get_serial_speed_hangup_cnt(call_info)
         if no_speed_hangup_cnt >=3:
             self.logger.warn('WARING::get_serial_speed_hangup_cnt greater than 3')
+            self.dataHandleServer.create_warning_record(2, '连续3个5s内挂断')
 
     def get_call_id(self, event):
         call_id = EslEventUtil.getCallId(event)
@@ -217,7 +219,7 @@ class ChannelHangupHandler(EslEventHandler):
             return duration
         except Exception as e:
             print(f"获取音频时长失败: {e}")
-            return None
+            return 0
 
     def merge_audio_files(self,audio_files):
         if not audio_files: