|
@@ -172,6 +172,104 @@ class CameraApiController extends BaseController
|
|
|
return self::successResponse($data);
|
|
|
}
|
|
|
|
|
|
+ //宁煤摄像头统计
|
|
|
+ public function getTotalNingmeibak(){
|
|
|
+ $result['status'] = true;
|
|
|
+ $result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
+
|
|
|
+ //宁煤集团
|
|
|
+ $ningmei = DB::table('mine_list')->where('title',config('mine_hls'))->get();
|
|
|
+
|
|
|
+ $ydjk = DB::table('mine_list')->where('title','移动监控')->where('deleted_at',null)->get();
|
|
|
+ $ydjk_list = [];
|
|
|
+ if(count($ydjk) > 0){
|
|
|
+ for($i=0;$i<count($ydjk);$i++){
|
|
|
+ array_push($ydjk_list,$ydjk[$i]->id);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $ydjk_son = DB::table('mine_list')->whereIn('parent_id',$ydjk_list)->where('deleted_at',null)->get();
|
|
|
+ if(count($ydjk_son) > 0){
|
|
|
+ for($i=0;$i<count($ydjk_son);$i++){
|
|
|
+ array_push($ydjk_list,$ydjk_son[$i]->id);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $mine_all = DB::table('mine_list')->where('deleted_at',null)->whereNotIn('id',$ydjk_list)->get();//所有区域
|
|
|
+
|
|
|
+ $mine_ningmei = [];//宁煤集团所有区域
|
|
|
+ foreach($mine_all as $k=>$v){
|
|
|
+ if(explode('|',$v->degree)[0] == $ningmei[0]->id){
|
|
|
+ $mine_ningmei[] = $v->id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //宁煤在离线数量
|
|
|
+ $data[0]['title'] = '宁煤公司';
|
|
|
+ $data[0]['mine_code'] = $ningmei[0]->slug;
|
|
|
+ $data[0]['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('deleted_at',null)->count();
|
|
|
+ $data[0]['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('camera_status',1)->where('deleted_at',null)->count();
|
|
|
+ $data[0]['total_offline'] = $data[0]['total'] - $data[0]['total_online'];
|
|
|
+ $data[0]['rate'] = round($data[0]['total_online'] / $data[0]['total'] * 100,2)."%";
|
|
|
+
|
|
|
+ //宁煤下各矿在离线数量
|
|
|
+ $mine_list = DB::table('mine_list')->where('parent_id',$ningmei[0]->id)->where('deleted_at',null)->get();
|
|
|
+ foreach($mine_list as $k => $v){
|
|
|
+ $mine_use = [];//宁煤下每个矿所有区域
|
|
|
+ foreach($mine_all as $key=>$value){
|
|
|
+ if(count(explode('|',$value->degree)) > 1){
|
|
|
+ if(explode('|',$value->degree)[0] == $ningmei[0]->id && explode('|',$value->degree)[1] == $v->id){
|
|
|
+ $mine_use[] = $value->id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $total = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('is_show',1)->where('deleted_at',null)->count();
|
|
|
+ $total_online = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('is_show',1)->where('camera_status',1)->where('deleted_at',null)->count();
|
|
|
+
|
|
|
+ if($total == 0){
|
|
|
+ $rate = "0%";
|
|
|
+ }else{
|
|
|
+ $rate = round($total_online / $total * 100,2)."%";
|
|
|
+ }
|
|
|
+
|
|
|
+ if($v->slug == 'NingXiaMeiYeTeShuZuoYeJianKongShiPin'){
|
|
|
+ $res['title'] = $v->title;
|
|
|
+ $res['mine_code'] = $v->slug."_jituan";
|
|
|
+ $res['total'] = $total;
|
|
|
+ $res['total_online'] = $total_online;
|
|
|
+ $res['total_offline'] = $total - $total_online;
|
|
|
+ $res['rate'] = $rate;
|
|
|
+ }else{
|
|
|
+ if($v->slug == 'ShuiDianFenGongSi'){
|
|
|
+ $v->title = '供电分公司';
|
|
|
+ }
|
|
|
+ array_push($data,[
|
|
|
+ 'title'=>$v->title,
|
|
|
+ 'mine_code'=>$v->slug."_jituan",
|
|
|
+ 'total'=>$total,
|
|
|
+ 'total_online'=>$total_online,
|
|
|
+ 'total_offline'=>$total - $total_online,
|
|
|
+ 'rate'=>$rate
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($res)){
|
|
|
+ array_push($data,[
|
|
|
+ 'title'=>$res['title'],
|
|
|
+ 'mine_code'=>$res['mine_code'],
|
|
|
+ 'total'=>$res['total'],
|
|
|
+ 'total_online'=>$res['total_online'],
|
|
|
+ 'total_offline'=>$res['total_offline'],
|
|
|
+ 'rate'=>$res['rate']
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($data);
|
|
|
+ }
|
|
|
+
|
|
|
//宁煤摄像头统计字符串
|
|
|
public function getTotalString(){
|
|
|
$result['status'] = true;
|
|
@@ -2948,7 +3046,7 @@ class CameraApiController extends BaseController
|
|
|
->where('t2.id', $area_id);
|
|
|
}
|
|
|
|
|
|
- $risk_list = $risk_list->get();
|
|
|
+ $risk_list = $risk_list->orderBy('risk_level')->get();
|
|
|
|
|
|
// 洗煤厂数据
|
|
|
$coal_washery_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery as t')->where('t.is_delete',0);
|