tongshanglei 2 years ago
parent
commit
fb8ee4365d

+ 27 - 4
catch/alarm/controller/ControlAlarm.php

@@ -67,20 +67,41 @@ class ControlAlarm extends CatchController
         return CatchResponse::success($this->controlAlarmModel->deleteBy($id));
     }
 
+    /**
+     * 获取今日告警列
+     * @param Request $request 
+     */
+    public function getTodayAlarmlist(Request $request){
+        $start_time = date('Y-m-d 00:00:00',time());
+        $end_time = date('Y-m-d 23:59:59',time());
+        $xAxisData=[];
+        $yAxisData=[];
+        $list=$this->controlAlarmModel
+            ->catchSearch()
+            ->append(['state_text'])
+            ->whereBetweenTime('created_at', $start_time,$end_time)
+            ->order('created_at', 'desc')
+            ->select();
+       
+      
+        // return $rows;
+        return CatchResponse::success($list);
+    }
+
      /**
      * 报警点统计
      * @param Request $request 
      */
     public function totalAlarmAddress(Request $request){
-        // $params=$request->param();
-        // $start_time=date('Y-m-d 00:00:00',strtotime($params['timeRange'][0]));
-        // $end_time=date('Y-m-d 00:00:00',strtotime($params['timeRange'][1]));
+        $start_time = date('Y-m-d 00:00:00',time());
+        $end_time = date('Y-m-d 23:59:59',time());
         $xAxisData=[];
         $yAxisData=[];
         
-        $list=Db::table('control_alarm')
+        $list=$this->controlAlarmModel
             ->field('address,count(*) as num')
             ->group('address')
+            ->whereBetweenTime('created_at', $start_time,$end_time)
             ->order('num desc')
             ->select();
         foreach($list as $val){
@@ -90,4 +111,6 @@ class ControlAlarm extends CatchController
         // return $rows;
         return CatchResponse::success(['xAxisData'=>$xAxisData,'yAxisData'=>$yAxisData]);
     }
+
+    
 }

+ 1 - 0
catch/alarm/route.php

@@ -33,6 +33,7 @@ $router->group(function () use ($router){
 	// controlAalrm路由
 	$router->resource('controlAlarm', '\catchAdmin\alarm\controller\ControlAlarm');
 	$router->get('totalAlarmAddress', '\catchAdmin\alarm\controller\ControlAlarm@totalAlarmAddress');
+	$router->get('getTodayAlarmlist', '\catchAdmin\alarm\controller\ControlAlarm@getTodayAlarmlist');
 })->middleware('auth');
 
 $router->group('alarmReport', function () use ($router){

+ 1 - 1
catch/map/controller/RouteMap.php

@@ -588,7 +588,7 @@ class RouteMap extends CatchController
         }
         // var_dump($rows);
         oci_free_statement($stid);
-
+        oci_close($conn);
         // $conn = new PDO("oci:dbname=//".$host.":".$port."/".$instance_name,$username,$password);// PDO方式
         // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 

+ 30 - 8
catch/report/controller/Report.php

@@ -24,15 +24,37 @@ class Report extends CatchController
      */
     public function homePageCountData(Request $request)
     {
-        // 基站数据
-        // $station_data = $this->reportModel->getStationCountData() ?: [];
-        $station_data =[];
-        // 部门数据
-        // $department_data = $this->reportModel->getDepartmentCountData() ?: [];
-        // 用户数据
-        $user_data = $this->reportModel->getDeviceUserCountData() ?: [];
+        $start_time = date('Y-m-d 00:00:00',time());
+        $end_time = date('Y-m-d 23:59:59',time());
 
-        $data = array_merge($station_data, $user_data);
+        
+        $host=    Env::get('oracle.hostname',  '127.0.0.1');
+        $port=    Env::get('oracle.hostport',  '1521');
+        $instance_name=    Env::get('oracle.instance',  'ORCL');
+        $username=    Env::get('oracle.username',  'root');
+        $password=    Env::get('oracle.password',  'root');
+        $conn = oci_connect($username, $password, $host.':'.$port.'/'.$instance_name,'AL32UTF8');
+
+        if (!$conn) {
+            $e = oci_error();
+            trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
+        }
+
+        $sql='SELECT count(*) as TOTAL FROM DSSC2.W_DW_RF_RECORD   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\')   ORDER BY RF_DATE DESC';
+        // 查询并渲染
+    
+        $stid = oci_parse($conn, $sql);
+        oci_define_by_name($stid, 'TOTAL', $passCount);
+        oci_execute($stid);
+        oci_fetch($stid);
+
+        oci_free_statement($stid);
+        oci_close($conn);
+        $alarmCount=Db::table('control_alarm')->whereBetweenTime('created_at', $start_time,$end_time)->count();
+        $data = array(
+            'passCount'=>(string)$passCount,
+            'alarmCount'=>(string)$alarmCount,
+        );
         return CatchResponse::success($data);
     }
 

+ 1 - 1
catch/report/route.php

@@ -14,7 +14,7 @@ $router->group('total', function () use ($router){
     $router->get('getHomePageCountData','\catchAdmin\report\controller\Report@homePageCountData'); // 获取首页数量统计数据
     $router->get('getStationGrowthTrendData','\catchAdmin\report\controller\Report@stationGrowthTrendData'); // 获取设备增长趋势数据
     $router->get('getDeviceGrowthTrendData','\catchAdmin\report\controller\Report@deviceGrowthTrendData'); // 获取设备增长趋势数据
-})->middleware('auth');
+});
 $router->get('report/areaDeviceCollect','\catchAdmin\report\controller\Report@areaDeviceCollect'); // 获取区域过车统计
 $router->get('report/vehiclePassingCount','\catchAdmin\report\controller\Report@vehiclePassingCount'); // 过车总量统计