vali vor 6 Jahren
Ursprung
Commit
3de5d59552

+ 60 - 55
application/admin/controller/Report.php

@@ -1,6 +1,10 @@
 <?php
 <?php
+
 namespace app\admin\controller;
 namespace app\admin\controller;
 
 
+
+use  app\admin\model\Countmidtable;
+
 /**
 /**
  * 报表类
  * 报表类
  */
  */
@@ -16,10 +20,11 @@ class Report extends Base
      */
      */
     public function index()
     public function index()
     {
     {
-        $param  = input('param.');
+        $param = input('param.');
         $startTime = isset($param['start']) ? $param['start'] : date('Y-m-d', strtotime("-6 day"));
         $startTime = isset($param['start']) ? $param['start'] : date('Y-m-d', strtotime("-6 day"));
         $endTime = isset($param['end']) ? $param['end'] : date('Y-m-d');
         $endTime = isset($param['end']) ? $param['end'] : date('Y-m-d');
-        $timeInterval = $this->Date_segmentation($startTime,$endTime);
+        $timeInterval = $this->Date_segmentation($startTime, $endTime);
+        $queueData = [];
         $chatData = [];
         $chatData = [];
         $serviceData = [];
         $serviceData = [];
         $xData = [];
         $xData = [];
@@ -32,7 +37,7 @@ class Report extends Base
             $dayBegin = strtotime($value);
             $dayBegin = strtotime($value);
             $dayEnd = strtotime($value) + 24 * 60 * 60;
             $dayEnd = strtotime($value) + 24 * 60 * 60;
             $chatLogCountWhere['start_time'] = ['between', [$dayBegin, $dayEnd]];
             $chatLogCountWhere['start_time'] = ['between', [$dayBegin, $dayEnd]];
-            $join   = [
+            $join = [
                 'alarm b' => 'a.servicelog_id = b.servicelog_id',
                 'alarm b' => 'a.servicelog_id = b.servicelog_id',
             ];
             ];
             $field = ['alarm_count', 'evaluate_id', 'system'];
             $field = ['alarm_count', 'evaluate_id', 'system'];
@@ -69,10 +74,15 @@ class Report extends Base
                 'name' => $k,
                 'name' => $k,
             ];
             ];
         }
         }
+
+        $queueData =(new  Countmidtable())->getQueryDay($timeInterval['days_list']);
+
+
         $this->assign([
         $this->assign([
             'xData' => json_encode($xData),
             'xData' => json_encode($xData),
             'chatData' => json_encode($chatData),
             'chatData' => json_encode($chatData),
             'serviceData' => json_encode($serviceData),
             'serviceData' => json_encode($serviceData),
+            'queueData' => json_encode($queueData),
             'systemCount' => json_encode($systemCount),
             'systemCount' => json_encode($systemCount),
             'evaluate' => json_encode([
             'evaluate' => json_encode([
                 'evaluateGood' => $evaluateGood,
                 'evaluateGood' => $evaluateGood,
@@ -96,83 +106,78 @@ class Report extends Base
     function Date_segmentation($start_date, $end_date)
     function Date_segmentation($start_date, $end_date)
     {
     {
         //如果为空,则从今天的0点为开始时间
         //如果为空,则从今天的0点为开始时间
-        if(!empty($start_date))
-            $start_date=date('Y-m-d H:i:s',strtotime($start_date));
+        if (!empty($start_date))
+            $start_date = date('Y-m-d H:i:s', strtotime($start_date));
         else {
         else {
-            $start_date=date('Y-m-d 00:00:00',time());
+            $start_date = date('Y-m-d 00:00:00', time());
         }
         }
 
 
         //如果为空,则以明天的0点为结束时间(不存在24:00:00,只会有00:00:00)
         //如果为空,则以明天的0点为结束时间(不存在24:00:00,只会有00:00:00)
-        if(!empty($end_date))
-            $end_date=date('Y-m-d H:i:s',strtotime($end_date));
+        if (!empty($end_date))
+            $end_date = date('Y-m-d H:i:s', strtotime($end_date));
         else
         else
-            $end_date=date('Y-m-d 00:00:00',strtotime('+1 day'));
+            $end_date = date('Y-m-d 00:00:00', strtotime('+1 day'));
 
 
         //between 查询 要求必须是从低到高
         //between 查询 要求必须是从低到高
-        if($start_date>$end_date)
-        {
-            $ttt=$start_date;
-            $start_date=$end_date;
-            $end_date=$ttt;
-        }elseif($start_date==$end_date){
-            echo '时间输入错误';die;
+        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;
+        $time_s = strtotime($start_date);
+        $time_e = strtotime($end_date);
+        $seconds_in_a_day = 86400;
 
 
         //生成中间时间点数组(时间戳格式、日期时间格式、日期序列)
         //生成中间时间点数组(时间戳格式、日期时间格式、日期序列)
-        $days_inline_array=array();
-        $times_inline_array=array();
+        $days_inline_array = array();
+        $times_inline_array = array();
 
 
         //日期序列
         //日期序列
-        $days_list=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
-        {
+        $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点
              * A.取开始时间的第二天凌晨0点
              * B.用结束时间减去A
              * B.用结束时间减去A
              * C.用B除86400取商,取余
              * C.用B除86400取商,取余
              * D.用A按C的商循环+86400,取得分割时间点,如果C没有余数,则最后一个时间点 与 循环最后一个时间点一致
              * 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);
+            $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;
+            $days_inline_array[] = $end_date;
+            $times_inline_array[] = $time_e;
         }
         }
 
 
         return array(
         return array(
-            'start_date'=>$start_date,
-            'end_date'=>$end_date,
-            'days_list'=>$days_list,
-            'days_inline'=>$days_inline_array,
-            'times_inline'=>$times_inline_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
 }//end class

+ 34 - 0
application/admin/model/Countmidtable.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * 分组模型
+ */
+class Countmidtable extends Model
+{
+    public function getQueryDay($dayarray, $key = 0)
+    {
+        // $dayarray => ['2019-07-07','2019-07-08'....];
+
+        $ret = $this->where(['dtype' => 'user.queue.day.length', 'mdate' => ['IN', $dayarray]])->select();
+        $tmpData = [];
+        if (count($ret) > 0) {
+            foreach ($ret as $val) {
+                $tmpData[$val['mdate']] = intval($val['dcontent']);
+            }
+        }
+        $return = [];
+        foreach ($dayarray as $sval) {
+            if ($key) {
+                $return[$sval] = isset($tmpData[$sval]) ? $tmpData[$sval] : 0;
+            } else {
+                $return[] = isset($tmpData[$sval]) ? $tmpData[$sval] : 0;
+            }
+        }
+        return $return;
+    }
+
+}

+ 9 - 1
application/admin/view/report/index.html

@@ -67,6 +67,7 @@
     var xData = {$xData};
     var xData = {$xData};
     var chatData = {$chatData};
     var chatData = {$chatData};
     var serviceData = {$serviceData};
     var serviceData = {$serviceData};
+    var queueData = {$queueData};
     var evaluate = {$evaluate};
     var evaluate = {$evaluate};
     var systemCount = {$systemCount};
     var systemCount = {$systemCount};
     // 基于准备好的dom,初始化echarts实例
     // 基于准备好的dom,初始化echarts实例
@@ -91,7 +92,7 @@
             top: 'top',
             top: 'top',
             icon: 'rect',
             icon: 'rect',
             //selectedMode: false, //取消图例上的点击事件
             //selectedMode: false, //取消图例上的点击事件
-            data: ['会话量', '消息量'],
+            data: ['会话量', '消息量','排队量'],
         },
         },
         grid: {
         grid: {
             left: '30',
             left: '30',
@@ -164,6 +165,13 @@
                 barWidth: 24,// 柱形的宽度
                 barWidth: 24,// 柱形的宽度
                 barGap: 0,
                 barGap: 0,
                 data: chatData
                 data: chatData
+            },
+            {
+                name: '排队量',
+                type: 'bar',
+                barWidth: 24,// 柱形的宽度
+                barGap: 0,
+                data: queueData
             }
             }
         ]
         ]
     };
     };