Bläddra i källkod

'修改统计'

Ethan 6 år sedan
förälder
incheckning
d0c168eff8

+ 56 - 5
application/admin/controller/Report.php

@@ -39,8 +39,11 @@ class Report extends Base
         $evaluateSecondary = 0;  // 中评数.
         $evaluateBad = 0;  // 差评数.
         $evaluateNo = 0;  // 未评数.
+        $alllWaitTime = 0;  // 总排队时长.
+        $serviceTime = 0;  // 总会话时长.
+        $cpdTime = 0;  // 总相应时长.
         foreach ($timeInterval['days_list'] as $k => $value) {
-            $allCount = 0;  // 会话总数.
+            $allCount = 0;  // 当天会话总数.
             $dayBegin = strtotime($value);
             $dayEnd = (strtotime($value) + 24 * 60 * 60);
             $chatLogCountWhere['start_time'] = [
@@ -57,11 +60,17 @@ class Report extends Base
                 'alarm_count',
                 'evaluate_id',
                 'system',
+                'alarm_lineTime',
+                'alarm_cvtOvertime',
+                'alarm_corresponding',
             ];
             // 查询当天的工单.
             $serviceLog = model('serviceLog')->selectServiceLog($field, $join, $chatLogCountWhere);
             foreach ($serviceLog as $va) {
                 $allCount += $va['alarm_count'];
+                $alllWaitTime += $va['alarm_lineTime'];
+                $serviceTime += $va['alarm_cvtOvertime'];
+                $cpdTime += $va['alarm_corresponding'];
                 if ($va['evaluate_id'] == 1) {
                     $evaluateGood++;
                 } elseif ($va['evaluate_id'] == 2) {
@@ -86,7 +95,7 @@ class Report extends Base
             // 当天工单总数.
             $serviceData[$k] = model('serviceLog')->countServiceLog($chatLogCountWhere);
         }//end foreach
-
+        $systemCount = [];
         foreach ($system as $k => $v) {
             $systemCount[] = [
                 'value' => $v,
@@ -98,6 +107,41 @@ class Report extends Base
 
         $defaultTime = "$startTime , $endTime";
 
+        $allChat = 0;  // 会话总数.
+        $allService = 0;  // 消息总数.
+        $allQueue = 0;  // 消息总数.
+        foreach ($chatData as $v) {
+            $allChat += $v;
+        }
+        foreach ($serviceData as $v) {
+            $allService += $v;
+        }
+        foreach ($queueData as $v) {
+            $allQueue += $v;
+        }
+
+        // 转接量.
+        $transferWhere['ctime'] = [
+            'between',
+            [
+                $startTime,
+                $endTime,
+            ],
+        ];
+        $transfer = model('ServiceturnLog')->countSlg($transferWhere);
+        // 问答比.
+        $replyWhere['time_line'] = [
+            'between',
+            [
+                strtotime($startTime),
+                strtotime($endTime),
+            ],
+        ];
+        $allChatLog = model('ChatLog')->selectChatLog($replyWhere);
+        $replyWhere['from_id'] = ['like', 'KF%'];
+        $reply = model('ChatLog')->selectChatLog($replyWhere);
+
+
         $this->assign([
             'xData' => json_encode($xData),
             'chatData' => json_encode($chatData),
@@ -105,6 +149,16 @@ class Report extends Base
             'queueData' => json_encode($queueData),
             'systemCount' => json_encode($systemCount),
             'defaultTime' => json_encode($defaultTime),
+            'allChat' => $allChat,
+            'allService' => $allService,
+            'allQueue' => $allQueue,
+            'transfer' => floor($transfer/2),
+            'reply' => sprintf("%.2f",(($reply/($allChatLog-$reply))*100)),
+            'waitTime' => ceil($alllWaitTime/$allService),
+            'serviceTime' => ceil($serviceTime/$allService),
+            'cpdTime' => ceil($cpdTime/$allService),
+            'evaluateGood' => sprintf("%.2f",(($evaluateGood/($evaluateGood+$evaluateSecondary+$evaluateBad))*100)),
+            'evaluateGet' => sprintf("%.2f",((($evaluateGood+$evaluateSecondary+$evaluateBad)/($evaluateNo+$evaluateGood+$evaluateSecondary+$evaluateBad))*100)),
             'evaluate' => json_encode([
                 'evaluateGood' => $evaluateGood,
                 'evaluateSecondary' => $evaluateSecondary,
@@ -267,9 +321,6 @@ class Report extends Base
             $ttt = $start_date;
             $start_date = $end_date;
             $end_date = $ttt;
-        } elseif ($start_date == $end_date) {
-            echo '时间输入错误';
-            die;
         }
 
         $time_s = strtotime($start_date);

+ 1 - 1
application/admin/controller/Sensitivec.php

@@ -18,7 +18,7 @@ class Sensitivec extends Base
             $result = db('sensitivewords')
                 ->field(['sensitivewords_id', 'sensitivewords_word', 'sensitivewords_time', 'sensitivewords_status', 'user_name'])
                 ->alias('a')
-                ->join('admins b', 'a.sensitivewords_uid = b.id')
+                ->join('admins b', 'a.sensitivewords_uid = b.id','left')
                 ->where($where)
                 ->limit($offset, $limit)
                 ->select();

+ 1 - 1
application/admin/controller/Words.php

@@ -26,7 +26,7 @@ class Words extends Base
             $result = db('words')
                 ->field(['a.id', 'title', 'content', 'update_time', 'user_name', 'a.status'])
                 ->alias('a')
-                ->join('admins b', 'a.admin_id = b.id')
+                ->join('admins b', 'a.admin_id = b.id','left')
                 ->where($where)
                 ->limit($offset, $limit)
                 ->select();

+ 1 - 1
application/admin/model/Robot.php

@@ -28,7 +28,7 @@ class Robot extends Model
         if (empty($join) === false) {
             $result = $result->alias('a');
             foreach ($join as $k => $v) {
-                $result = $result->join($k, $v);
+                $result = $result->join($k, $v,'left');
             }
         }
 

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

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

+ 12 - 12
application/admin/view/index/index.html

@@ -29,13 +29,13 @@
                     <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 style="justify-content: center; display: flex">
+                        <div style="text-align: right;">访客次数</div>
+                        <div style="margin-left: 20px; width: 30px" 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 style="justify-content: center; display: flex">
+                        <div style="text-align: right;">客服次数</div>
+                        <div style="margin-left: 20px; width: 30px" id="serverSensitive">0</div>
                     </div>
                 </div>
             </div>
@@ -51,8 +51,8 @@
                     <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="justify-content: center; display: flex">
+                        <div style="text-align: right;">响应超时次数</div>
                         <div style="margin-left: 20px; text-align: right;" id="csdNumber">0</div>
                     </div>
                 </div>
@@ -69,8 +69,8 @@
                     <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="justify-content: center; display: flex">
+                        <div style="text-align: right;">会话超时次数</div>
                         <div style="margin-left: 20px; text-align: right;" id="overtimeNumber">0</div>
                     </div>
                 </div>
@@ -87,8 +87,8 @@
                     <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="justify-content: center; display: flex">
+                        <div style="text-align: right;">不满意次数</div>
                         <div style="margin-left: 20px; text-align: right;" id="evaluateCount2">0</div>
                     </div>
                 </div>

+ 99 - 6
application/admin/view/report/index.html

@@ -9,7 +9,7 @@
     <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">
-    <link href="__JS__/layui/css/layui.css" rel="stylesheet">
+    <link href="__JS__/layui/css/myLayui.css" rel="stylesheet">
 </head>
 <body class="gray-bg">
 <div class="wrapper wrapper-content">
@@ -18,6 +18,98 @@
     </div>
 
     <div class="row">
+        <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>{$allChat}</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="justify-content: center; display: flex">
+                        <div style="text-align: right;">转接量</div>
+                        <div style="margin-left: 20px; text-align: right;">{$transfer}</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>{$allService}</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="justify-content: center; display: flex">
+                        <div style="text-align: right;">问答比</div>
+                        <div style="margin-left: 20px; text-align: right;">{$reply}%</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>{$allQueue}</span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="justify-content: center; display: flex">
+                        <div style="text-align: right;">平均排队时长</div>
+                        <div style="margin-left: 20px; text-align: right;">{$waitTime}</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>{$serviceTime}</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="justify-content: center; display: flex">
+                        <div style="text-align: right;">平均相应时长</div>
+                        <div style="margin-left: 20px; text-align: right;">{$cpdTime}</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>{$evaluateGood}<span style="font-size: 14px; margin-left: 10px">%</span></span></h1>
+                    <small></small>
+                </div>
+                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                    <div style="justify-content: center; display: flex">
+                        <div style="text-align: right;">参评率</div>
+                        <div style="margin-left: 20px; text-align: right;">{$evaluateGet}%</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        </div>
         <div class="col-sm-12">
             <div class="ibox float-e-margins">
                 <div class="ibox-title">
@@ -69,7 +161,7 @@
                         <div class="ibox-title">
                             <h5>访问来源</h5>
                         </div>
-                        <div id="system_data" style="text-align: center; width: 100%; font-size: 16px;">
+                        <div id="system_data" style="text-align: center; width: 100%; font-size: 16px; background: #fff; height: 350px; border-top: 1px solid #e7eaec;">
                             <div class="ibox-content" style="height: 350px" id="pie_system">
 
                             </div>
@@ -92,6 +184,7 @@
     var queueData = {$queueData};
     var evaluate = {$evaluate};
     var systemCount = {$systemCount}.length  ? {$systemCount} : '';
+    var xWidth = (168/xData.length);
     // 基于准备好的dom,初始化echarts实例
     var myChart_bar = echarts.init(document.getElementById('bar'));
     var pie_evaluate = echarts.init(document.getElementById('pie_evaluate'));
@@ -177,21 +270,21 @@
             {
                 name: '会话量',
                 type: 'bar',
-                barWidth: 24,// 柱形的宽度
+                barWidth: xWidth,// 柱形的宽度
                 barGap: 0,
                 data: serviceData
             },
             {
                 name: '消息量',
                 type: 'bar',
-                barWidth: 24,// 柱形的宽度
+                barWidth: xWidth,// 柱形的宽度
                 barGap: 0,
                 data: chatData
             },
             {
                 name: '排队量',
                 type: 'bar',
-                barWidth: 24,// 柱形的宽度
+                barWidth: xWidth,// 柱形的宽度
                 barGap: 0,
                 data: queueData
             }
@@ -350,7 +443,7 @@
         };
         pie_system.setOption(option_PS);
     } else {
-        let pie_system_html = "<div style='margin-top: 150px;'>暂无数据</div>";
+        let pie_system_html = "<div style='line-height: 20;'>暂无数据</div>";
         $("#system_data").html(pie_system_html);
     }
 

+ 2 - 2
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -203,8 +203,8 @@ class Events
             //Gateway::sendToCurrentClient('{"type":"pong"}');
             return;
         } else {
-            echo "onMessage: " . $message . "\r\n";
-            print_r([self::$global->kfList, self::$global->userList, self::$global->uidSimpleList, self::$global->userToKf]);
+            //echo "onMessage: " . $message . "\r\n";
+            //print_r([self::$global->kfList, self::$global->userList, self::$global->uidSimpleList, self::$global->userToKf]);
         }
 
         $message = json_decode($message, true);