create table c_agent_monitor
(
    id             bigint unsigned auto_increment comment '主键'
        primary key,
    saas_id        varchar(16) default ''                not null comment '租户隔离',
    agent_num      varchar(32) default ''                not null comment '坐席工号',
    out_id         varchar(32) default ''                not null comment '外部id',
    identity_type  tinyint     default 0                 not null comment '身份标识',
    check_state    tinyint     default 1                 not null comment '是否签入 0:是 1: 否  默认未签入',
    check_scene    varchar(16) default ''                not null comment '迁入场景',
    check_in_time  timestamp   default CURRENT_TIMESTAMP not null comment '签入时间',
    check_out_time timestamp   default CURRENT_TIMESTAMP not null comment '签出时间',
    service_state  tinyint     default 0                 not null comment '坐席服务状态 0: 未登录(签出) 1: 置忙 2: 置闲 3: 通话中 4: 后处理 5: 拨号中',
    busy_time      timestamp   default CURRENT_TIMESTAMP not null comment '置忙时间',
    idle_time      timestamp   default CURRENT_TIMESTAMP not null comment '置闲时间',
    call_time      timestamp   default CURRENT_TIMESTAMP not null comment '接通时间',
    hang_time      timestamp   default CURRENT_TIMESTAMP not null comment '挂断时间',
    heart_state    tinyint     default 0                 not null comment '心跳状态 0: 默认 1：正常  2: 异常',
    heart_time     timestamp   default CURRENT_TIMESTAMP not null comment '正常心跳时间',
    session_id     varchar(64) default ''                not null comment 'sessionId',
    is_delete      tinyint     default 0                 not null comment '删除标识',
    update_time    timestamp   default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    create_time    timestamp   default CURRENT_TIMESTAMP not null comment '创建时间',
    constraint uniq_saas_id_agent_num
        unique (saas_id, agent_num)
)
    comment '坐席监控表';

create index idx_saas_id_out_id
    on c_agent_monitor (saas_id, out_id);

