Report.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace catchAdmin\report\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\report\model\Report as ReportModel;
  7. use think\facade\Env;
  8. class Report extends CatchController
  9. {
  10. protected $reportModel;
  11. public function __construct(ReportModel $reportModel)
  12. {
  13. $this->reportModel = $reportModel;
  14. }
  15. /**
  16. * 首页数量数据
  17. * @param Request $request
  18. */
  19. public function homePageCountData(Request $request)
  20. {
  21. // 基站数据
  22. // $station_data = $this->reportModel->getStationCountData() ?: [];
  23. $station_data =[];
  24. // 部门数据
  25. // $department_data = $this->reportModel->getDepartmentCountData() ?: [];
  26. // 用户数据
  27. $user_data = $this->reportModel->getDeviceUserCountData() ?: [];
  28. $data = array_merge($station_data, $user_data);
  29. return CatchResponse::success($data);
  30. }
  31. /**
  32. * 基站增长趋势数据
  33. * @param Request $request
  34. */
  35. public function stationGrowthTrendData(Request $request)
  36. {
  37. $data = $this->reportModel->getStationGrowthTrendData() ?: [];
  38. return CatchResponse::success($data);
  39. }
  40. /**
  41. * 用户设备增长趋势数据
  42. * @param Request $request
  43. */
  44. public function deviceGrowthTrendData(Request $request)
  45. {
  46. $data = $this->reportModel->getDeviceGrowthTrendData() ?: [];
  47. return CatchResponse::success($data);
  48. }
  49. /**
  50. * 过车总量统计
  51. * @param Request $request
  52. */
  53. public function vehiclePassingCount(Request $request){
  54. $params=$request->param();
  55. $start_time=strtotime($params['timeRange'][0]);
  56. $end_time=strtotime($params['timeRange'][1]);
  57. $xAxisData=[];
  58. $yAxisData=[];
  59. for($i=$start_time;$i<$end_time+24*3600;$i+=24*3600){
  60. $time1=date('Y-m-d 00:00:00',$i);
  61. $time2=date('Y-m-d 23:59:59',$i);
  62. $xAxisData[]=date('Y-m-d',$i);
  63. $cond['RF_DATE']=['timeRange',$time1,$time2];
  64. // $count=queryOracleCount('DSSC2.W_DW_RF_RECORD',$cond);
  65. $count=mt_rand(0,99999);
  66. $yAxisData[]=$count;
  67. }
  68. // var_dump($end_time);
  69. return CatchResponse::success(['xAxisData'=>$xAxisData,'yAxisData'=>$yAxisData]);
  70. }
  71. /**
  72. * 区域过车统计
  73. * @param Request $request
  74. */
  75. public function areaDeviceCollect(Request $request){
  76. $params=$request->param();
  77. $start_time=date('Y-m-d 00:00:00',strtotime($params['timeRange'][0]));
  78. $end_time=date('Y-m-d 00:00:00',strtotime($params['timeRange'][1]));
  79. $host= Env::get('oracle.hostname', '127.0.0.1');
  80. $port= Env::get('oracle.hostport', '1521');
  81. $instance_name= Env::get('oracle.instance', 'ORCL');
  82. $username= Env::get('oracle.username', 'root');
  83. $password= Env::get('oracle.password', 'root');
  84. // $conn = oci_connect('dssc3', 'dssc3', '61.175.203.188:6521/DSSC','AL32UTF8');
  85. // if (!$conn) {
  86. // $e = oci_error();
  87. // trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
  88. // }
  89. // $sql='SELECT a.RF_ID,count(a.RF_FLAGID) num,b.DEVICE_NAME FROM DSSC2.W_DW_RF_RECORD a join DSSC2.ADM_DEV b ON a.RF_ID=b.LOGIN_NAME WHERE RF_DATE >= to_date(\''.$start_time.'\', \'yyyy-mm-dd hh24:mi:ss\') AND RF_DATE <= to_date(\''.$end_time.'\', \'yyyy-mm-dd hh24:mi:ss\') GROUP BY a.RF_ID,b.DEVICE_NAME ORDER BY num desc';
  90. // // var_dump($sql);
  91. // // 查询并渲染
  92. // $stid = oci_parse($conn, $sql);
  93. // $r = oci_execute($stid);
  94. // $rows=[];
  95. // while($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
  96. // $rows[]=$row;
  97. // }
  98. // oci_free_statement($stid);
  99. $xAxisData=[];
  100. $yAxisData=[];
  101. // foreach($rows as $val){
  102. // $xAxisData[]=$val['DEVICE_NAME'];
  103. // $yAxisData[]=$val['NUM'];
  104. // }
  105. for($i=0;$i<800;$i++){
  106. $xAxisData[]='测试基站'.$i;
  107. $yAxisData[]=mt_rand(0,99999);
  108. }
  109. // return $rows;
  110. return CatchResponse::success(['xAxisData'=>$xAxisData,'yAxisData'=>$yAxisData]);
  111. }
  112. }