Ethan 6 éve
szülő
commit
9688cb550a

+ 164 - 0
application/admin/controller/Report.php

@@ -0,0 +1,164 @@
+<?php
+namespace app\admin\controller;
+
+/**
+ * 报表类
+ */
+class Report extends Base
+{
+
+
+    /**
+     * 工作报表
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function index()
+    {
+        $param  = input('param.');
+        $startTime = isset($param['start']) ? $param['start'] : date('Y-m-d', strtotime("-6 day"));
+        $endTime = isset($param['end']) ? $param['end'] : date('Y-m-d');
+        $timeInterval = $this->Date_segmentation($startTime,$endTime);
+        $chatData = [];
+        $serviceData = [];
+        $xData = [];
+        foreach ($timeInterval['days_list'] as $k => $value) {
+            $allCount = 0;
+            $evaluateGood = 0;
+            $evaluateSecondary = 0;
+            $evaluateBad = 0;
+            $evaluateNo = 0;
+            $dayBegin = strtotime($value);
+            $dayEnd = strtotime($value) + 24 * 60 * 60;
+            $chatLogCountWhere['start_time'] = ['between', [$dayBegin, $dayEnd]];
+            $join   = [
+                'alarm b' => 'a.servicelog_id = b.servicelog_id',
+            ];
+            $field = ['alarm_count', 'evaluate_id'];
+            // 查询当天的工单.
+            $serviceLog = model('serviceLog')->selectServiceLog($field, $join, $chatLogCountWhere);
+            foreach ($serviceLog as $ke => $va) {
+                $allCount += $va['alarm_count'];
+                if ($va['evaluate_id'] == 1) {
+                    $evaluateGood++;
+                } elseif ($va['evaluate_id'] == 2) {
+                    $evaluateSecondary++;
+                } elseif ($va['evaluate_id'] == 3) {
+                    $evaluateBad++;
+                } elseif ($va['evaluate_id'] == 0) {
+                    $evaluateNo++;
+                }
+            }
+            // 会话总数.
+            $xData[] = $value;
+            $chatData[$k] = $allCount;
+            // 当天工单总数.
+            $serviceData[$k] = model('serviceLog')->countServiceLog($chatLogCountWhere);
+        }
+        $this->assign([
+            'xData' => json_encode($xData),
+            'chatData' => json_encode($chatData),
+            'serviceData' => json_encode($serviceData),
+            'evaluate' => json_encode([
+                'evaluateGood' => $evaluateGood,
+                'evaluateSecondary' => $evaluateSecondary,
+                'evaluateBad' => $evaluateBad,
+                'evaluateNo' => $evaluateNo,
+            ]),
+        ]);
+
+        return $this->fetch('index');
+
+    }//end index()
+
+
+    /**
+     * 时间分割
+     *
+     * @access public
+     * @return array JsonString
+     */
+    function Date_segmentation($start_date, $end_date)
+    {
+        //如果为空,则从今天的0点为开始时间
+        if(!empty($start_date))
+            $start_date=date('Y-m-d H:i:s',strtotime($start_date));
+        else {
+            $start_date=date('Y-m-d 00:00:00',time());
+        }
+
+        //如果为空,则以明天的0点为结束时间(不存在24:00:00,只会有00:00:00)
+        if(!empty($end_date))
+            $end_date=date('Y-m-d H:i:s',strtotime($end_date));
+        else
+            $end_date=date('Y-m-d 00:00:00',strtotime('+1 day'));
+
+        //between 查询 要求必须是从低到高
+        if($start_date>$end_date)
+        {
+            $ttt=$start_date;
+            $start_date=$end_date;
+            $end_date=$ttt;
+        }elseif($start_date==$end_date){
+            echo '时间输入错误';die;
+        }
+
+        $time_s=strtotime($start_date);
+        $time_e=strtotime($end_date);
+        $seconds_in_a_day=86400;
+
+        //生成中间时间点数组(时间戳格式、日期时间格式、日期序列)
+        $days_inline_array=array();
+        $times_inline_array=array();
+
+        //日期序列
+        $days_list=array();
+        //判断开始和结束时间是不是在同一天
+        $days_inline_array[0]=$start_date;  //初始化第一个时间点
+        $times_inline_array[0]=$time_s;     //初始化第一个时间点
+        $days_list[]=date('Y-m-d',$time_s);//初始化第一天
+        if(
+            date('Y-m-d',$time_s)
+            ==date('Y-m-d',$time_e)
+        ){
+            $days_inline_array[1]=$end_date;
+            $times_inline_array[1]=$time_e;
+        }
+        else
+        {
+            /**
+             * A.取开始时间的第二天凌晨0点
+             * B.用结束时间减去A
+             * C.用B除86400取商,取余
+             * D.用A按C的商循环+86400,取得分割时间点,如果C没有余数,则最后一个时间点 与 循环最后一个时间点一致
+             */
+            $A_temp=date('Y-m-d 00:00:00',$time_s+$seconds_in_a_day);
+            $A=strtotime($A_temp);
+            $B=$time_e-$A;
+            $C_quotient=floor($B/$seconds_in_a_day);    //商舍去法取整
+            $C_remainder=fmod($B,$seconds_in_a_day);               //余数
+            $days_inline_array[1]=$A_temp;
+            $times_inline_array[1]=$A;
+            $days_list[]=date('Y-m-d',$A);              //第二天
+            for($increase_time=$A,$c_count_t=1;$c_count_t<=$C_quotient;$c_count_t++)
+            {
+                $increase_time+=$seconds_in_a_day;
+                $days_inline_array[]=date('Y-m-d H:i:s',$increase_time);
+                $times_inline_array[]=$increase_time;
+                $days_list[]=date('Y-m-d',$increase_time);
+            }
+            $days_inline_array[]=$end_date;
+            $times_inline_array[]=$time_e;
+        }
+
+        return array(
+            'start_date'=>$start_date,
+            'end_date'=>$end_date,
+            'days_list'=>$days_list,
+            'days_inline'=>$days_inline_array,
+            'times_inline'=>$times_inline_array
+        );
+    }
+
+}//end class

+ 12 - 9
application/admin/controller/Robot.php

@@ -26,11 +26,11 @@ class Robot extends Base
                 $where['robot_name'] = ['like', '%' . $param['searchText'] . '%'];
             }
 
+            $field  = ['robot_id', 'robot_name', 'robot_content', 'robot_host', 'robot_status', 'user_name', 'robot_updateTime'];
             $join   = [
-                'groups b'      => 'a.groups_id = b.id',
-                'robotgroups c' => 'a.robotgroups_id = c.robotgroups_id',
+                'admins b'      => 'a.admin_id = b.id',
             ];
-            $result = model('Robot')->selectJoin($join, $where, $offset, $limit);
+            $result = model('Robot')->selectJoin($field, $join, $where, $offset, $limit);
             foreach ($result as $key => $vo) {
                 // 优化显示状态.
                 if(1 === $vo['robot_status']) {
@@ -59,7 +59,8 @@ class Robot extends Base
         }
 
         return $this->fetch();
-    }
+    }//end index()
+
 
     // 添加智能问答
     public function addWord()
@@ -70,8 +71,6 @@ class Robot extends Base
             $param['robot_content'] = trim($param['robot_content']);
             $robotWhere = [
                 'robot_name' => $param['robot_name'],
-                'groups_id' => $param['groups_id'],
-                'robotgroups_id' => $param['robotgroups_id'],
             ];
 
             $has = db('robot')->field('robot_id')->where($robotWhere)->find();
@@ -79,8 +78,11 @@ class Robot extends Base
                 return json(['code' => -1, 'data' => '', 'msg' => '该智能问答已经存在']);
             }
 
-            $param['robot_addTime'] = date('Y-m-d H:i:s');
+            $param['robot_addTime']    = date('Y-m-d H:i:s');
             $param['robot_updateTime'] = date('Y-m-d H:i:s');
+            $param['groups_id']        = 1;
+            $param['robotgroups_id']   = 1;
+            $param['admin_id']         = session('user_id');
             try{
                 db('robot')->insert($param);
             }catch(\Exception $e){
@@ -111,8 +113,6 @@ class Robot extends Base
             $param['robot_updateTime'] = date('Y-m-d H:i:s');
             $robotWhere = [
                 'robot_name' => $param['robot_name'],
-                'groups_id' => $param['groups_id'],
-                'robotgroups_id' => $param['robotgroups_id'],
             ];
 
             // 检测用户修改的智能问答是否重复
@@ -120,6 +120,9 @@ class Robot extends Base
             if($has>1){
                 return json(['code' => -1, 'data' => '', 'msg' => '该智能问答已经存在']);
             }
+            $param['groups_id'] = 1;
+            $param['robotgroups_id'] = 1;
+            $param['admin_id']   = session('user_id');
 
             try{
                 db('robot')->where('robot_id', $param['robot_id'])->update($param);

+ 11 - 2
application/admin/controller/Words.php

@@ -23,7 +23,13 @@ class Words extends Base
                 $where['content'] = $param['searchText'];
             }
 
-            $result = db('words')->where($where)->limit($offset, $limit)->select();
+            $result = db('words')
+                ->field(['a.id', 'title', 'content', 'update_time', 'user_name', 'a.status'])
+                ->alias('a')
+                ->join('admins b', 'a.admin_id = b.id')
+                ->where($where)
+                ->limit($offset, $limit)
+                ->select();
             foreach($result as $key=>$vo){
                 // 优化显示状态
                 if(1 == $vo['status']){
@@ -61,7 +67,8 @@ class Words extends Base
                 return json(['code' => -1, 'data' => '', 'msg' => '该常用语已经存在']);
             }
 
-            $param['add_time'] = date('Y-m-d H:i:s');
+            $param['update_time'] = date('Y-m-d H:i:s');
+            $param['admin_id'] = session('user_id');
             try{
                 db('words')->insert($param);
             }catch(\Exception $e){
@@ -86,6 +93,8 @@ class Words extends Base
             $param = input('post.');
             $param['content'] = trim($param['content']);
 
+            $param['update_time'] = date('Y-m-d H:i:s');
+            $param['admin_id'] = session('user_id');
             // 检测用户修改的常用语是否重复
             $has = db('words')->where(['title' => $param['title'], 'user_id' => 0])->where('id', '<>', $param['id'])->find();
             if(!empty($has)){

+ 29 - 0
application/admin/model/ChatLog.php

@@ -0,0 +1,29 @@
+<?php
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * 会话记录模型
+ */
+class ChatLog extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function selectChatLog($where=[])
+    {
+        $result = $this->where($where)->count();
+
+        return $result;
+
+    }//end selectChatLog()
+
+
+}

+ 3 - 2
application/admin/model/Robot.php

@@ -14,6 +14,7 @@ class Robot extends Model
      * select数据筛选
      *
      * @access public
+     * @param mixed $field 字段
      * @param mixed $join 关联
      * @param mixed $where 条件
      * @param mixed $offset 分页开始
@@ -21,9 +22,9 @@ class Robot extends Model
      * @param mixed $order 排序
      * @return array 返回类型
      */
-    public function selectJoin($join, $where=[], $offset='', $limit='', $order=['robot_updateTime'=>'desc'])
+    public function selectJoin($field, $join, $where=[], $offset='', $limit='', $order=['robot_updateTime'=>'desc'])
     {
-        $result = $this;
+        $result = $this->field($field);
         if (empty($join) === false) {
             $result = $result->alias('a');
             foreach ($join as $k => $v) {

+ 54 - 0
application/admin/model/ServiceLog.php

@@ -0,0 +1,54 @@
+<?php
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * 工单模型
+ */
+class ServiceLog extends Model
+{
+
+
+    /**
+     * 数据统计
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function countServiceLog($where=[])
+    {
+        $result = $this->where($where)->count();
+
+        return $result;
+
+    }//end countServiceLog()
+
+
+    /**
+     * 数据查询
+     *
+     * @access public
+     * @param mixed $join 关联表
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function selectServiceLog($field, $join, $where=[])
+    {
+        $result = $this->field($field);
+        if (empty($join) === false) {
+            $result = $result->alias('a');
+            foreach ($join as $k => $v) {
+                $result = $result->join($k, $v);
+            }
+        }
+
+        $result = $result->where($where)->select();
+
+        return $result;
+
+    }//end selectServiceLog()
+
+
+}

+ 0 - 0
application/admin/view/kfonitoring/kfjiankong.html → application/admin/view/kfonitoring/cpkfjiankong.html


+ 237 - 0
application/admin/view/report/index.html

@@ -0,0 +1,237 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>后台首页</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
+    <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
+    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content">
+    <div class="row">
+
+    </div>
+
+    <div class="row">
+        <div class="col-sm-8">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>今日数据分析</h5>
+                </div>
+                <div class="ibox-content no-padding">
+                    <div class="ibox-content" style="height: 350px" id="bar">
+
+                    </div>
+                </div>
+                <div class="ibox-content no-padding" style="display: flex;">
+                    <div class="ibox-content" style="width: 50%;height: 350px" id="pie_evaluate">
+
+                    </div>
+                    <div class="ibox-content" style="width: 50%;height: 350px" id="pie_luate">
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
+<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
+<script src="/static/admin/js/plugins/echarts/echarts.min.js"></script>
+<script type="text/javascript">
+    var xData = {$xData};
+    var chatData = {$chatData};
+    var serviceData = {$serviceData};
+    var evaluate = {$evaluate};
+    // 基于准备好的dom,初始化echarts实例
+    var myChart_bar = echarts.init(document.getElementById('bar'));
+    var pie_evaluate = echarts.init(document.getElementById('pie_evaluate'));
+    var pie_evalu = echarts.init(document.getElementById('pie_luate'));
+
+    // 指定图表的配置项和数据
+    var option_bar = {
+        color: ['#1da1f2', '#fa7070', '#fcbb07', '#90dd75', '#8fa6ec', '#157efb'],
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'shadow'
+            }
+        },
+        legend: {
+            itemWidth: 20, //图例的宽度
+            itemHeight: 8, //图例的高度
+            itemGap: 40,
+            left: '55',
+            top: 'top',
+            icon: 'rect',
+            //selectedMode: false, //取消图例上的点击事件
+            data: ['会话量', '消息量'],
+        },
+        grid: {
+            left: '30',
+            right: '30',
+            bottom: '20',
+            containLabel: true
+        },
+        toolbox: {
+            show: true,
+            orient: 'vertical',
+            left: 'right',
+            top: 'center',
+        },
+        calculable: true,
+        xAxis: [{
+            splitLine: {
+                show: false
+            }, //去除网格线
+            splitArea: {
+                show: false
+            }, //保留网格区域
+            axisLine: {
+                show: true,
+                lineStyle: { //轴上的线样式
+                    color: '#979797',
+                    width: 0.6, //这里是为了突出显示加上的
+                },
+            },
+            axisTick: {
+                show: false
+            },
+            axisLabel: { //轴上的数据样式
+                color: '#393C40',
+            },
+            data: xData,
+        }],
+        yAxis: [{
+            // type: 'value',
+            splitLine: {
+                show: false
+            }, //去除网格线
+            splitArea: {
+                show: false
+            }, //保留网格区域
+            axisLine: {
+                show: true,
+                lineStyle: { //轴上的线样式
+                    color: '#979797',
+                    width: 0.6, //这里是为了突出显示加上的
+                },
+            },
+            axisTick: {
+                show: false
+            },
+            axisLabel: { //轴上的数据样式
+                color: '#393C40',
+            }
+        }],
+        series: [
+            {
+                name: '会话量',
+                type: 'bar',
+                barWidth: 12,// 柱形的宽度
+                barGap: 0,
+                data: serviceData
+            },
+            {
+                name: '消息量',
+                type: 'bar',
+                barWidth: 12,// 柱形的宽度
+                barGap: 0,
+                data: chatData
+            }
+        ]
+    };
+
+    // 使用刚指定的配置项和数据显示图表。
+    myChart_bar.setOption(option_bar);
+
+    // 指定图表的配置项和数据
+    var option_PE = {
+        backgroundColor: '#fff',
+
+        tooltip: {
+            trigger: 'item',
+            formatter: "{b} : {c} ({d}%)"
+        },
+
+        visualMap: {
+            show: false,
+            min: 500,
+            max: 600,
+            inRange: {
+                //colorLightness: [0, 1]
+            }
+        },
+        series: [{
+            name: '满意度',
+            type: 'pie',
+            radius: '50%',
+            center: ['50%', '50%'],
+            color: ['rgb(131,249,103)', '#FBFE27', '#FE5050', '#1DB7E5'], //'#FBFE27','rgb(11,228,96)','#FE5050'
+            data: [{
+                value: evaluate['evaluateGood'],
+                name: '满意'
+                }, {
+                    value: evaluate['evaluateSecondary'],
+                    name: '一般'
+                }, {
+                    value: evaluate['evaluateBad'],
+                    name: '不满意'
+                }, {
+                    value: evaluate['evaluateNo'],
+                    name: '未评价'
+                }
+            ].sort(function(a, b) {
+                return a.value - b.value
+            }),
+            roseType: 'radius',
+
+            label: {
+                normal: {
+                    formatter: ['{c|{c}次}', '{b|{b}}'].join('\n'),
+                    rich: {
+                        c: {
+                            color: 'rgb(241,246,104)',
+                            fontSize: 20,
+                            fontWeight:'bold',
+                            lineHeight: 5
+                        },
+                        b: {
+                            color: 'rgb(98,137,169)',
+                            fontSize: 15,
+                            height: 40
+                        },
+                    },
+                }
+            },
+            labelLine: {
+                normal: {
+                    lineStyle: {
+                        color: 'rgb(98,137,169)',
+                    },
+                    smooth: 0.2,
+                    length: 10,
+                    length2: 20,
+
+                }
+            },
+            itemStyle: {
+                normal: {
+                    shadowColor: 'rgba(0, 0, 0, 0.8)',
+                    shadowBlur: 50,
+                }
+            }
+        }]
+    };
+
+    // 使用刚指定的配置项和数据显示图表。
+    pie_evaluate.setOption(option_PE);
+    pie_evalu.setOption(option_PE);
+</script>
+</body>
+</html>

+ 488 - 0
application/admin/view/reportForm/index.html

@@ -0,0 +1,488 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>后台首页</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
+    <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
+    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+    <link href="__JS__/layui/css/myLayui.css" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content">
+    <div class="row">
+        <div class="col-sm-2">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title" style="display: flex; justify-content: center;">
+                    <!--<span class="label label-primary pull-right">今天</span>-->
+                    <h3>敏感词报警</h3>
+                </div>
+                <div class="ibox-content" style="text-align: center">
+                    <h1 class="no-margins"><span id="allSensitive">0</span><span style="font-size: 14px; margin-left: 10px">次</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px;">
+                    <div style="display: flex">
+                        <div style="width: 80px; text-align: right;">访客次数</div>
+                        <div style="margin-left: 20px; text-align: right;" id="userSensitive">0</div>
+                    </div>
+                    <div style="display: flex">
+                        <div style="width: 80px; text-align: right;">客服次数</div>
+                        <div style="margin-left: 20px; text-align: right;" id="serverSensitive">0</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-sm-2">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title" style="display: flex; justify-content: center;">
+                    <!--<span class="label label-primary pull-right">今天</span>-->
+                    <h3>平均响应超时</h3>
+                </div>
+                <div class="ibox-content" style="text-align: center">
+                    <h1 class="no-margins"><span id="csdTime">0</span><span style="font-size: 14px; margin-left: 10px">秒</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="display: flex">
+                        <div style="width: 80px; text-align: right;">响应超时次数</div>
+                        <div style="margin-left: 20px; text-align: right;" id="csdNumber">0</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-sm-2">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title" style="display: flex; justify-content: center;">
+                    <!--<span class="label label-primary pull-right">今天</span>-->
+                    <h3>平均会话超时</h3>
+                </div>
+                <div class="ibox-content" style="text-align: center">
+                    <h1 class="no-margins"><span id="overtimeTime">0</span><span style="font-size: 14px; margin-left: 10px">秒</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="display: flex">
+                        <div style="width: 80px; text-align: right;">会话超时次数</div>
+                        <div style="margin-left: 20px; text-align: right;" id="overtimeNumber">0</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-sm-2">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title" style="display: flex; justify-content: center;">
+                    <!--<span class="label label-primary pull-right">今天</span>-->
+                    <h3>满意度报警</h3>
+                </div>
+                <div class="ibox-content" style="text-align: center">
+                    <h1 class="no-margins"><span id="evaluateCount1">0</span><span style="font-size: 14px; margin-left: 10px">次</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="display: flex">
+                        <div style="width: 80px; text-align: right;">不满意次数</div>
+                        <div style="margin-left: 20px; text-align: right;" id="evaluateCount2">0</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="ibox float-e-margins">
+        <input style="display:none;" type="text" value="1" id="type">
+        <div style="display: flex;">
+            <div class="ibox-title" style="width: 100px; cursor:pointer;" id="current1" onclick="current(1)">
+                <h5>当前会话</h5>
+            </div>
+            <div class="ibox-title" id="current2" style="width: 100px; cursor:pointer; background: #eee" onclick="current(2)">
+                <h5>在线客服</h5>
+            </div>
+            <div class="ibox-title" style="width: calc(100% - 200px); background: #eee;">
+            </div>
+        </div>
+        <div class="ibox-content">
+            <!--搜索框开始-->
+            <form id="realTimeForm"  role="form" method="post" class="form-inline">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <label>分组名称:</label>
+                        <div class="input-group col-sm-4 layui-form" style="width: 120px;">
+                            <input type="hidden" id="group_id"/>
+                            <select lay-verify="required" lay-filter="group">
+                                <option value="">全部客服组</option>
+                                {if !empty($groups)}
+                                {foreach name="groups" item="vo"}
+                                <option value="{$vo['id']}">{$vo['name']}</option>
+                                {/foreach}
+                                {/if}
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group" style="margin-left: 40px">
+                        <label>报警状态:</label>
+                        <div class="input-group col-sm-4 layui-form" style="width: 120px;">
+                            <input type="hidden" id="alarm_id"/>
+                            <select lay-verify="required" lay-filter="alarm">
+                                <option value="">所有会话</option>
+                                <option value="1">正常会话</option>
+                                <option value="2">报警会话</option>
+                            </select>
+                        </div>
+                    </div>
+                </div>
+            </form>
+            <!--搜索框结束-->
+            <div id="realTimeTable" class="example-wrap">
+                <div class="example">
+                    <table class="table table-hover table-striped">
+                        <thead>
+                        <tr>
+                            <th>会话ID</th>
+                            <th>访客进线时间</th>
+                            <th>接待客服</th>
+                            <th>访客名</th>
+                            <th>会话开始时间</th>
+                            <th>报警次数</th>
+                            <th>操作</th>
+                        </tr>
+                        </thead>
+                        <tbody id="table">
+                        <tr>
+                            <td colspan="999" style="text-align: center">暂无数据</td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+            <!-- End Example Pagination -->
+
+
+            <!--搜索框开始-->
+            <form id='commentForm' style="display: none" role="form" method="get" class="form-inline">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <label>分组名称:</label>
+                        <div class="input-group col-sm-4 layui-form" style="width: 120px;">
+                            <input type="hidden" name="type1" id="type1"/>
+                            <select lay-verify="required" lay-filter="group">
+                                <option value="">全部客服组</option>
+                                {if !empty($groups)}
+                                {foreach name="groups" item="vo"}
+                                <option value="{$vo['id']}">{$vo['name']}</option>
+                                {/foreach}
+                                {/if}
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group" style="margin-left: 40px">
+                        <label>报警状态:</label>
+                        <div class="input-group col-sm-4 layui-form" style="width: 120px;">
+                            <input type="hidden" name="type2" id="type2"/>
+                            <select lay-verify="required" lay-filter="alarm">
+                                <option value="">所有状态</option>
+                                <option value="1">在线状态</option>
+                                <option value="2">休息状态</option>
+                                <option value="3">隐身状态</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <lable>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</lable>
+                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜
+                            索</strong>
+                        </button>
+                    </div>
+                </div>
+            </form>
+            <!--搜索框结束-->
+            <div id="commentTable" style="display: none" class="example-wrap">
+                <div class="example">
+                    <table id="cusTable">
+                        <thead>
+                        <th data-field="uidname">客服</th>
+                        <th data-field="hhl">会话量</th>
+                        <th data-field="jdl">接待量</th>
+                        <th data-field="pjhysc">平均会话时长</th>
+                        <th data-field="cpl">参评率</th>
+                        <th data-field="mydl">满意度率</th>
+                        <th data-field="pjxysc">平均响应时长</th>
+                        <th data-field="jrxxsc">今日休息时长</th>
+                        <th data-field="fxx">发消息</th>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <!-- End Example Pagination -->
+
+
+        </div>
+    </div>
+</div>
+
+<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
+<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
+<script src="/static/admin/js/plugins/echarts/echarts.min.js"></script>
+<script src="/static/customer/js/md5.js"></script>
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
+<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
+<script type="text/javascript">
+    function current(id) {
+        $("#type").val(id);
+        if (id == 1) {
+            $("#current1").css("background","#fff");
+            $("#current2").css("background","#eee");
+            $("#realTimeForm").css("display","block");
+            $("#realTimeTable").css("display","block");
+            $("#commentForm").css("display","none");
+            $("#commentTable").css("display","none");
+        } else if (id == 2) {
+            $("#current2").css({"background":"#fff"});
+            $("#current1").css({"background":"#eee"});
+            $("#realTimeForm").css({"display":"none"});
+            $("#realTimeTable").css({"display":"none"});
+            $("#commentForm").css({"display":"block"});
+            $("#commentTable").css({"display":"block"});
+        }
+        initTable()
+    }
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#group_id").val(value.value);
+            onSearch()
+        });
+
+        form.on('select(alarm)', function(value){
+            $("#alarm_id").val(value.value);
+            onSearch()
+        });
+    });
+    function initTable() {
+        //先销毁表格
+        $('#cusTable').bootstrapTable('destroy');
+        //初始化表格,动态从服务器加载数据
+        $("#cusTable").bootstrapTable({
+            method: "get",  //使用get请求到服务器获取数据
+            url: "{:url('kfonitoring/kfjiankong')}", //获取数据的地址
+            striped: true,  //表格显示条纹
+            pagination: true, //启动分页
+            pageSize: 50,  //每页显示的记录数
+            pageNumber: 1, //当前第几页
+            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
+            sidePagination: "server", //表示服务端请求
+            paginationFirstText: "首页",
+            paginationPreText: "上一页",
+            paginationNextText: "下一页",
+            paginationLastText: "尾页",
+            queryParamsType: "undefined",
+            queryParams: function queryParams(params) {   //设置查询参数
+                var param = {
+                    pageNumber: params.pageNumber,
+                    pageSize: params.pageSize,
+                    searchText: $('#type1').val() + ',' + $('#type2').val() + ',' + $('#type3').val()
+                };
+                return param;
+            },
+            onLoadSuccess: function (res) {  //加载成功时执行
+                if (111 == res.code) {
+                    window.location.reload();
+                }
+                layer.msg("加载成功", {time: 1000});
+            },
+            onLoadError: function () {  //加载失败时执行
+                layer.msg("加载数据失败");
+            }
+        });
+    }
+    $(document).ready(function () {
+        //调用函数,初始化表格
+        initTable();
+
+        //当点击查询按钮的时候执行
+        $("#search").bind("click", initTable);
+    });
+</script>
+<!--webSocket-->
+<script>
+    let config = {
+        socket: '{$socket}',
+        token: '{$token}',
+    };
+    let myData = [];
+    let date = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
+    let getLocation = window.location.href;
+    let host = getLocation.split('/admin')[0];
+    let apiToken = hex_md5('customer-service'+date+host);
+    let socket = new WebSocket('ws://' + config.socket+'?apiToken=' + apiToken);
+    socket.onopen = function(res) {
+        console.log('握手成功');
+        // 登录
+        let login_data = JSON.stringify({
+            type: 'adminInit',
+            token:  config.token
+        });
+        socket.send(login_data);
+    };
+    socket.onmessage = function(res) {
+        var data = eval("("+res.data+")");
+        switch(data['message_type']){
+            // 服务端ping客户端
+            case 'monitor':
+                myData = data.data.cvtList;
+                putMonitor(data.data);
+                break;
+        }
+    };
+    /**
+     * 时间戳转化为年 月 日 时 分 秒
+     * time: 传入时间戳
+     * format:返回格式,支持自定义,但参数必须与formateArr里保持一致
+     */
+    function customFormatDateTime(timeStamp,custom,isDtae) {
+        var date = new Date();
+        date.setTime(timeStamp * 1000);
+        var y = date.getFullYear();
+        var m = date.getMonth() + 1;
+        m = m < 10 ? ('0' + m) : m;
+        var d = date.getDate();
+        d = d < 10 ? ('0' + d) : d;
+        var h = date.getHours();
+        h = h < 10 ? ('0' + h) : h;
+        var minute = date.getMinutes();
+        var second = date.getSeconds();
+        minute = minute < 10 ? ('0' + minute) : minute;
+        second = second < 10 ? ('0' + second) : second;
+        if (isDtae == 0){
+            return y + custom + m //+'student';
+        }else if (isDtae ==1){
+            return y + custom + m + custom + d;
+        } else if (isDtae ==2) {
+            return h + ':' + minute;
+        } else {
+            return y + '-' + m + '-' + d + '-' + h + ':' + minute + ':' + second;
+        }
+    };
+    function onSearch() {
+        let table = "";
+        let cvtList = searchData();
+        for(key in cvtList){
+            let start_time = cvtList[key].start_time;
+            let intime = cvtList[key].intime
+            if (key != "length") {
+                table += "<tr>" +
+                            "<td>"+cvtList[key].servicelog_id+"</td>" +
+                            "<td>"+customFormatDateTime(intime,'',2)+"</td>" +
+                            "<td>"+cvtList[key].server_name+"</td>" +
+                            "<td>"+cvtList[key].user_name+"</td>" +
+                            "<td>"+customFormatDateTime(start_time,'',2)+"</td>" +
+                            "<td>"+cvtList[key].allCount+"</td>" +
+                            "<td>" +
+                                "<a href='/admin/system/detail/id/"+cvtList[key].servicelog_id+".html'>" +
+                                    "<button type='button' class='btn btn-primary btn-sm'>" +
+                                        "<i class='fa fa-paste'></i> 详情" +
+                                    "</button>" +
+                                "</a>" +
+                            "</td>" +
+                        "</tr>"
+            }
+        }
+        if (table) {
+            $("#table").html(table);
+        } else {
+            $("#table").html("<tr>" +
+                                    "<td colspan='6' style='text-align: center'>暂无数据</td>" +
+                            "</tr>");
+        }
+    }
+    function searchData() {
+        let group_id = $("#group_id").val();
+        let alarm_id = $("#alarm_id").val();
+        let newData = [];
+        if (group_id && alarm_id) {
+            if (alarm_id == 1) {
+                for (keys in myData) {
+                    if (group_id == myData[key].group_id && !myData[key].allCount) {
+                        newData.push(myData[key])
+                    }
+                }
+            } else if (alarm_id == 2) {
+                for (keys in myData) {
+                    if (group_id == myData[key].group_id && myData[key].allCount) {
+                        newData.push(myData[key])
+                    }
+                }
+            }
+        } else if(group_id) {
+            for (keys in myData) {
+                if (group_id == myData[key].group_id) {
+                    newData.push(myData[key])
+                }
+            }
+        } else if(alarm_id) {
+            if (alarm_id == 1) {
+                for (keys in myData) {
+                    if (!myData[key].allCount) {
+                        newData.push(myData[key])
+                    }
+                }
+            } else if (alarm_id == 2) {
+                for (keys in myData) {
+                    if (myData[key].allCount) {
+                        newData.push(myData[key])
+                    }
+                }
+            }
+        } else {
+            newData = myData
+        }
+        return newData;
+    }
+    // 渲染
+    function putMonitor(data) {
+        $("#allSensitive").html(data.userSensitive + data.serverSensitive);
+        $("#userSensitive").html(data.userSensitive);
+        $("#serverSensitive").html(data.serverSensitive);
+        $("#csdNumber").html(data.csdNumber);
+        $("#overtimeNumber").html(data.overtimeNumber);
+        $("#evaluateCount1").html(data.evaluateCount);
+        $("#evaluateCount2").html(data.evaluateCount);
+        // 响应超时.
+        let n = data.csdTime.length;
+        let csdTime = 0;
+        for(keys in data.csdTime){
+            csdTime += data.csdTime[keys]
+        }
+        csdTime = csdTime ? Math.ceil(csdTime/n) : 0;
+        $("#csdTime").html(csdTime);
+        // 会话超时.
+        let m = data.overtimeTime.length;
+        let overtimeTime = 0;
+        for(keys in data.overtimeTime){
+            overtimeTime += data.overtimeTime[keys]
+        }
+        overtimeTime = overtimeTime ? Math.ceil(overtimeTime/m) : 0;
+        $("#overtimeTime").html(overtimeTime);
+        onSearch();
+    }
+</script>
+</body>
+</html>

+ 2 - 2
application/admin/view/robot/addword.html

@@ -34,7 +34,7 @@
                                 <textarea class="form-control" name="robot_content" required="" aria-required="true" style="width: 400px;height: 150px;resize:none"></textarea>
                             </div>
                         </div>
-                        <div class="form-group">
+                        <!--<div class="form-group">
                             <label class="col-sm-3 control-label">选择分组:</label>
                             <input type="hidden" id="groups_id" name="groups_id"/>
                             <div class="input-group col-sm-4 layui-form">
@@ -61,7 +61,7 @@
                                     {/if}
                                 </select>
                             </div>
-                        </div>
+                        </div>-->
                         <div class="form-group layui-form-item">
                             <label class="col-sm-3 control-label">是否为热点问题:</label>
                             <div class="input-group col-sm-6">

+ 2 - 2
application/admin/view/robot/editword.html

@@ -34,7 +34,7 @@
                                 <textarea class="form-control" name="robot_content" required="" aria-required="true" style="width: 400px;height: 150px;resize:none">{$info['robot_content']}</textarea>
                             </div>
                         </div>
-                        <div class="form-group">
+                        <!--<div class="form-group">
                             <label class="col-sm-3 control-label">选择分组:</label>
                             <input type="hidden" id="groups_id" name="groups_id" value="{$info['groups_id']}"/>
                             <div class="input-group col-sm-4 layui-form">
@@ -61,7 +61,7 @@
                                     {/if}
                                 </select>
                             </div>
-                        </div>
+                        </div>-->
                         <div class="form-group layui-form-item">
                             <label class="col-sm-3 control-label">是否为热点问题:</label>
                             <div class="input-group col-sm-6">

+ 4 - 2
application/admin/view/robot/index.html

@@ -44,10 +44,12 @@
                         <th data-field="robot_id">问题ID</th>
                         <th data-field="robot_name">问题</th>
                         <th data-field="robot_content">答案</th>
-                        <th data-field="robotgroups_name">智能分组</th>
-                        <th data-field="name">所属</th>
+                        <!--<th data-field="robotgroups_name">智能分组</th>
+                        <th data-field="name">所属</th>-->
                         <th data-field="robot_host">是否为热点问题</th>
                         <th data-field="robot_status">状态</th>
+                        <th data-field="robot_updateTime">修订时间</th>
+                        <th data-field="user_name">修订人</th>
                         <th data-field="operate">操作</th>
                         </thead>
                     </table>

+ 2 - 2
application/admin/view/sensitivec/index.html

@@ -51,8 +51,8 @@
                         <thead>
                         <th data-field="sensitivewords_id">ID</th>
                         <th data-field="sensitivewords_word">内容</th>
-                        <th data-field="sensitivewords_time">时间</th>
-                        <th data-field="user_name">操作人</th>
+                        <th data-field="sensitivewords_time">修订时间</th>
+                        <th data-field="user_name">修订人</th>
                         <th data-field="sensitivewords_status">状态</th>
                         <th data-field="operate">操作</th>
                         </thead>

+ 2 - 1
application/admin/view/words/index.html

@@ -55,7 +55,8 @@
                         <th data-field="id">内容ID</th>
                         <th data-field="title">快捷</th>
                         <th data-field="content">内容</th>
-                        <th data-field="add_time">添加时间</th>
+                        <th data-field="update_time">修订时间</th>
+                        <th data-field="user_name">修订人</th>
                         <th data-field="status">状态</th>
                         <th data-field="operate">操作</th>
                         </thead>

+ 6 - 5
application/service/controller/Words.php

@@ -74,6 +74,7 @@ class Words extends Common
             $content        = input('post.content');
             $status         = input('post.status');
             $title          = input('post.title');
+            $userWordsData['update_time'] = date('Y-m-d H:i:s');
             // 更新内容.
             if (empty($content) === false) {
                 $userWordsData['content'] = input('post.content');
@@ -177,11 +178,11 @@ class Words extends Common
             }
 
             $userWordsData = [
-                'user_id'  => $getUserInfo->id,
-                'title'    => input('post.title'),
-                'content'  => input('post.content'),
-                'status'   => input('post.status'),
-                'add_time' => date('Y-m-d H:i:s'),
+                'user_id'     => $getUserInfo->id,
+                'title'       => input('post.title'),
+                'content'     => input('post.content'),
+                'status'      => input('post.status'),
+                'update_time' => date('Y-m-d H:i:s'),
             ];
             $deleteResult  = model('Words')->addWords($userWordsData);
 

+ 32 - 10
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -104,7 +104,7 @@ class Events
             });
 
             // 检查对话时效给出.
-            Timer::add(60, function () {
+            Timer::add(6, function () {
                 self::overTime();
             });
 
@@ -221,6 +221,7 @@ class Events
                     break;
                 // 顾客初始化
                 case 'userInit';
+                print_r([self::$global->kfList,$message['data']]);
                     $data = $message['data'];
                     self::userInitEnt($client_id, $data);
                     break;
@@ -255,6 +256,10 @@ class Events
                         ];
 
                         self::$db->insert('ws_chat_log')->cols($serviceLog)->query();
+                        if ($message['data']['sensitiveNumber']) {
+
+                        }
+                        self::$db->query("update `ws_alarm` set `alarm_corresponding` = '$corresponding',alarm_respond=2 where `servicelog_id`= '$servicelog_id'");
                         unset($serviceLog);
                     }
                     if (isset($message['data']['isFirst']) && $message['data']['isFirst']) {
@@ -287,9 +292,13 @@ class Events
                     self::$db->query("update `ws_service_log` set `end_time` = " . time() . " , `status` = '2' where `servicelog_id`= '" . $servicelog_id . "'");
 
                     // 修改会话时长
-                    $serviceLog = self::$db->query("select `start_time` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+                    $serviceLog = self::$db->query("select `start_time`,`intime` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+                    $logCount = self::$db->query("select count(*) as `count` from `ws_chat_log` where `servicelog_id`= '$servicelog_id'");
+                    $alarmCount = $logCount[0]['count'];
                     $cvtOvertime = time() - $serviceLog[0]['start_time'];
-                    self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime' where `servicelog_id`= '$servicelog_id'");
+                    $alarmLineTime = $serviceLog[0]['start_time'] - $serviceLog[0]['intime'];
+                    self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime',`alarm_lineTime` = '$alarmLineTime',`alarm_count` = '$alarmCount'
+                                      where `servicelog_id`= '$servicelog_id'");
 
                     // 从当前客服的服务表中删除这个会员
                     $old = $kfList = self::$global->kfList;
@@ -519,9 +528,13 @@ class Events
 
         // 修改会话时长
         $servicelog_id = $oldlog['servicelog_id'];
-        $serviceLog = self::$db->query("select `start_time` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+        $serviceLog = self::$db->query("select `start_time`,`intime` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+        $logCount = self::$db->query("select count(*) as `count` from `ws_chat_log` where `servicelog_id`= '$servicelog_id'");
+        $alarmCount = $logCount[0]['count'];
         $cvtOvertime = time() - $serviceLog[0]['start_time'];
-        self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime' where `servicelog_id`= '$servicelog_id'");
+        $alarmLineTime = $serviceLog[0]['start_time'] - $serviceLog[0]['intime'];
+        self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime',`alarm_lineTime` = '$alarmLineTime',`alarm_count` = '$alarmCount'
+                          where `servicelog_id`= '$servicelog_id'");
 
         $oldlog = array_merge($oldlog, ['kf_id' => intval(trim($toukfid, 'KF')), 'start_time' => time(), 'end_time' => 0, 'status' => 1, 'evaluate_id' => 0]);
         $new_id = self::$db->insert('ws_service_log')->cols($oldlog)->query();
@@ -799,10 +812,14 @@ class Events
                     self::$db->query("update `ws_service_log` set `status` = '2',end_time=$now  where `user_id`= '$simpliUsersID_UID_Arr[$val]' and  kf_id='$uid' and  group_id=$group  and  `status`!=2 ");
 
                     // 修改会话时长
-                    $serviceLog = self::$db->query("select `start_time`,`servicelog_id` from `ws_service_log` where `user_id`= '$simpliUsersID_UID_Arr[$val]' and  kf_id='$uid' and  group_id=$group  and  `status`!=2");
+                    $serviceLog = self::$db->query("select `start_time`,`servicelog_id`,`intime` from `ws_service_log` where `user_id`= '$simpliUsersID_UID_Arr[$val]' and  kf_id='$uid' and  group_id=$group  and  `status`!=2");
+                    $logCount = self::$db->query("select count(*) as `count` from `ws_chat_log` where `servicelog_id`= '$servicelog_id'");
+                    $alarmCount = $logCount[0]['count'];
                     $servicelog_id = $serviceLog[0]['servicelog_id'];
                     $cvtOvertime = time() - $serviceLog[0]['start_time'];
-                    self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime' where `servicelog_id`= '$servicelog_id'");
+                    $alarmLineTime = $serviceLog[0]['start_time'] - $serviceLog[0]['intime'];
+                    self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime',`alarm_lineTime` = '$alarmLineTime',`alarm_count` = '$alarmCount'
+                                      where `servicelog_id`= '$servicelog_id'");
                 }
                 Gateway::closeClient($val);
             }
@@ -934,9 +951,13 @@ class Events
         $isServiceUserOut = false;
 
         // 修改会话时长
-        $serviceLog = self::$db->query("select `start_time` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+        $serviceLog = self::$db->query("select `start_time`,`intime` from `ws_service_log` where `servicelog_id`= '$servicelog_id'");
+        $logCount = self::$db->query("select count(*) as `count` from `ws_chat_log` where `servicelog_id`= '$servicelog_id'");
+        $alarmCount = $logCount[0]['count'];
         $cvtOvertime = time() - $serviceLog[0]['start_time'];
-        self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime' where `servicelog_id`= '$servicelog_id'");
+        $alarmLineTime = $serviceLog[0]['start_time'] - $serviceLog[0]['intime'];
+        self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime',`alarm_lineTime` = '$alarmLineTime',`alarm_count` = '$alarmCount'
+                          where `servicelog_id`= '$servicelog_id'");
         // 将会员服务信息,从客服的服务列表中移除
         $old = $kfList = self::$global->kfList;
         foreach ($kfList as $k => $v) {
@@ -1645,7 +1666,7 @@ class Events
         $setUnoperated = strtotime('-' . (self::$global->unoperated['systemconfig_data'] - 60) . ' second');
         $unoperated = strtotime('-' . (self::$global->unoperated['systemconfig_data']) . ' second');
         $noResponse = strtotime('-' . (self::$global->noResponse['systemconfig_data']) . ' second');
-        foreach ($serviceLog as $k => $v) {//注意该循环时间
+        foreach ($serviceLog as $k => $v) {
             if (!strlen(array_search($v['servicelog_id'], array_column($chatLog, 'servicelog_id')))) {
                 // 如果小于设定时间则关闭会话.
                 if ($v['start_time'] <= $unoperated) {
@@ -1668,6 +1689,7 @@ class Events
             // 如果对话为客服的最后一次对话且时间小于设定时间则结束工单.
             if ($v['time_line'] <= $overtime) {
                 $found_key = array_search($v['servicelog_id'], array_column($serviceLog, 'servicelog_id'));
+                print_r([1,$serviceLog[$found_key]['client_id']]);
                 self::serverClose($serviceLog[$found_key]['client_id'], $v['servicelog_id']);
                 // 如果对话为客服的最后一次对话且时间小于设定时间前一分钟则给出提示.
             } elseif ($v['time_line'] <= $setOvertime) {