作者 潘浩文
1 个管道 的构建 通过 耗费 6 秒

XIAOPAN

@@ -30,8 +30,10 @@ class AdminStatisticsController extends AdminBaseController{ @@ -30,8 +30,10 @@ class AdminStatisticsController extends AdminBaseController{
30 public function index(){ 30 public function index(){
31 $param=$this->request->param(); 31 $param=$this->request->param();
32 $where=''; 32 $where='';
  33 + $where1=[];
33 if (!empty($param['hospital'])){ 34 if (!empty($param['hospital'])){
34 $where="hospital='".$param['hospital']."' AND"; 35 $where="hospital='".$param['hospital']."' AND";
  36 + $where1['hospital']=$param['hospital'];
35 } 37 }
36 //医院总体时长统计 38 //医院总体时长统计
37 $data=Db::name('order') 39 $data=Db::name('order')
@@ -77,13 +79,23 @@ class AdminStatisticsController extends AdminBaseController{ @@ -77,13 +79,23 @@ class AdminStatisticsController extends AdminBaseController{
77 $month_interval[$i]=[$month[$i],$month[$i+1]]; 79 $month_interval[$i]=[$month[$i],$month[$i+1]];
78 } 80 }
79 $Month_statistics=array(); 81 $Month_statistics=array();
  82 + $Month_money=array();
80 $Month=array(); 83 $Month=array();
81 for ($i = 0; $i<24; $i++){ 84 for ($i = 0; $i<24; $i++){
82 $Month[]=date('Y-m-d',$month_interval[$i][1]); 85 $Month[]=date('Y-m-d',$month_interval[$i][1]);
83 $Month_statistics[]=Db::name('order')->where('start_time','between',$month_interval[$i])->count(); 86 $Month_statistics[]=Db::name('order')->where('start_time','between',$month_interval[$i])->count();
  87 + $Month_money[]=Db::name('order')
  88 + ->alias('o')
  89 + ->join('equipment e','o.eq_name=e.name')
  90 + ->where($where1)
  91 + ->where('o.start_time','between',$month_interval[$i])
  92 + ->where('o.state',3)
  93 + ->sum('o.price');
84 } 94 }
85 $this->assign('month',json_encode($Month)); 95 $this->assign('month',json_encode($Month));
86 $this->assign('monthData',json_encode($Month_statistics)); 96 $this->assign('monthData',json_encode($Month_statistics));
  97 + $this->assign('monthMoney',json_encode($Month_money));
  98 +
87 99
88 //时间段统计 100 //时间段统计
89 $interval=array(); 101 $interval=array();
@@ -99,6 +111,10 @@ class AdminStatisticsController extends AdminBaseController{ @@ -99,6 +111,10 @@ class AdminStatisticsController extends AdminBaseController{
99 $interval[$k]=$interval[$k][0]['num']; 111 $interval[$k]=$interval[$k][0]['num'];
100 } 112 }
101 113
  114 +
  115 +
  116 +
  117 +
102 $this->assign('interval',json_encode($interval)); 118 $this->assign('interval',json_encode($interval));
103 119
104 $this->assign('hospital', isset($param['hospital']) ? $param['hospital'] : ''); 120 $this->assign('hospital', isset($param['hospital']) ? $param['hospital'] : '');
@@ -49,6 +49,9 @@ @@ -49,6 +49,9 @@
49 <div> 49 <div>
50 <div id="main2" class="my_main" style="width: 380px;"></div> 50 <div id="main2" class="my_main" style="width: 380px;"></div>
51 </div> 51 </div>
  52 + <div>
  53 + <div id="main12" class="my_main" style="width: 380px;"></div>
  54 + </div>
52 </div> 55 </div>
53 56
54 </div> 57 </div>
@@ -131,7 +134,7 @@ @@ -131,7 +134,7 @@
131 //月统计数据 134 //月统计数据
132 var monthDataX = JSON.parse('{$month}'); 135 var monthDataX = JSON.parse('{$month}');
133 var monthDataY = JSON.parse('{$monthData}'); 136 var monthDataY = JSON.parse('{$monthData}');
134 - 137 + var monthMoney = JSON.parse('{$monthMoney}');
135 138
136 139
137 // 路径配置 140 // 路径配置
@@ -156,6 +159,7 @@ @@ -156,6 +159,7 @@
156 var myChart4 = ec.init(document.getElementById('main4'),'macarons'); 159 var myChart4 = ec.init(document.getElementById('main4'),'macarons');
157 var myChart10 = ec.init(document.getElementById('main10'),'macarons'); 160 var myChart10 = ec.init(document.getElementById('main10'),'macarons');
158 var myChart11 = ec.init(document.getElementById('main11'),'macarons'); 161 var myChart11 = ec.init(document.getElementById('main11'),'macarons');
  162 + var myChart12 = ec.init(document.getElementById('main12'),'macarons');
159 163
160 //时间段统计(柱形图) 164 //时间段统计(柱形图)
161 var option = { 165 var option = {
@@ -482,13 +486,65 @@ @@ -482,13 +486,65 @@
482 } 486 }
483 ] 487 ]
484 }; 488 };
  489 + var option12 = {
  490 + backgroundColor : "white",
  491 + color : ["#c05050","#59678c"],
  492 + title:{
  493 + text : '时间段统计',
  494 + y: '15'
  495 + },
  496 + tooltip : {
  497 + trigger: 'axis',
  498 +
  499 + showDelay: 0, // 显示延迟,添加显示延迟可以避免频繁切换,单位ms
  500 + formatter: "{b}</br>{a} : {c}元"
485 501
  502 + },
  503 + dataZoom : {
  504 + show : true,
  505 + realtime: true,
  506 + y : 220,
  507 + height: 20,
  508 + start : 75,
  509 + end : 100
  510 + },
  511 + calculable : true,
  512 + grid: {
  513 + x: 80,
  514 + y: 40,
  515 + x2:60,
  516 + },
  517 + xAxis : [
  518 + {
  519 + type : 'category',
  520 + boundaryGap : true,
  521 + data : monthDataX
  522 + }
  523 + ],
  524 + yAxis : [
  525 + {
  526 + type : 'value',
  527 + scale:true,
  528 +
  529 + }
  530 + ],
  531 + series : [
  532 + {
  533 + name:'月统计',
  534 + type:'line',
  535 + //stack: '人数',
  536 + barWidth : 10,
  537 + data:monthMoney
  538 + }
  539 + ]
  540 + };
486 // 为echarts对象加载数据 541 // 为echarts对象加载数据
487 myChart.setOption(option); 542 myChart.setOption(option);
488 myChart2.setOption(option4); 543 myChart2.setOption(option4);
489 myChart4.setOption(option2); 544 myChart4.setOption(option2);
490 myChart10.setOption(option10); 545 myChart10.setOption(option10);
491 myChart11.setOption(option11); 546 myChart11.setOption(option11);
  547 + myChart12.setOption(option12);
492 } 548 }
493 ); 549 );
494 }); 550 });