|
@@ -168,12 +168,14 @@ class CameraApiController extends BaseController
|
|
}
|
|
}
|
|
|
|
|
|
//宁煤在离线数量
|
|
//宁煤在离线数量
|
|
- $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)."%";
|
|
|
|
|
|
+ $nm['title'] = '宁煤公司';
|
|
|
|
+ $nm['mine_code'] = $ningmei[0]->slug;
|
|
|
|
+ $nm['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('deleted_at',null)->count();
|
|
|
|
+ $nm['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('camera_status',1)->where('deleted_at',null)->count();
|
|
|
|
+ $nm['total_offline'] = $nm['total'] - $nm['total_online'];
|
|
|
|
+ $nm['rate'] = round($nm['total_online'] / $nm['total'] * 100,2);
|
|
|
|
+
|
|
|
|
+ $data = [];
|
|
|
|
|
|
//宁煤下各矿在离线数量
|
|
//宁煤下各矿在离线数量
|
|
$mine_list = DB::table('mine_list')->where('parent_id',$ningmei[0]->id)->where('deleted_at',null)->get();
|
|
$mine_list = DB::table('mine_list')->where('parent_id',$ningmei[0]->id)->where('deleted_at',null)->get();
|
|
@@ -191,9 +193,9 @@ class CameraApiController extends BaseController
|
|
$total_online = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('is_show',1)->where('camera_status',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){
|
|
if($total == 0){
|
|
- $rate = "0%";
|
|
|
|
|
|
+ $rate = "0";
|
|
}else{
|
|
}else{
|
|
- $rate = round($total_online / $total * 100,2)."%";
|
|
|
|
|
|
+ $rate = round($total_online / $total * 100,2);
|
|
}
|
|
}
|
|
|
|
|
|
if($v->slug == 'NingXiaMeiYeTeShuZuoYeJianKongShiPin'){
|
|
if($v->slug == 'NingXiaMeiYeTeShuZuoYeJianKongShiPin'){
|
|
@@ -226,7 +228,116 @@ class CameraApiController extends BaseController
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
- return self::successResponse($data);
|
|
|
|
|
|
+ $timestamp = strtotime(date('Y-m-d H:i:s'));
|
|
|
|
+ $hour = date('G', $timestamp);
|
|
|
|
+ $minute = date('i', $timestamp);
|
|
|
|
+ $month = date('n', $timestamp);
|
|
|
|
+ $day = date('j', $timestamp);
|
|
|
|
+ if($minute == '00'){
|
|
|
|
+ $minute = '';
|
|
|
|
+ }
|
|
|
|
+ if ($hour < 12) {
|
|
|
|
+ $time = $month."月".$day."号上午".$hour."时".$minute;
|
|
|
|
+ } elseif ($hour >= 12 && $hour < 18) {
|
|
|
|
+ $time = $month."月".$day."号下午".$hour."时".$minute;
|
|
|
|
+ } else {
|
|
|
|
+ $time = $month."月".$day."号晚上".$hour."时".$minute;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $unit_max_name = '';
|
|
|
|
+ $unit_max_rate = 0;
|
|
|
|
+ $unit_min_name = '';
|
|
|
|
+ $unit_min_rate = 100;
|
|
|
|
+
|
|
|
|
+ $mzy_max_name = '';
|
|
|
|
+ $mzy_max_rate = 0;
|
|
|
|
+ $mzy_min_name = '';
|
|
|
|
+ $mzy_min_rate = 100;
|
|
|
|
+
|
|
|
|
+ $other_max_name = '';
|
|
|
|
+ $other_max_rate = 0;
|
|
|
|
+ $other_min_name = '';
|
|
|
|
+ $other_min_rate = 100;
|
|
|
|
+
|
|
|
|
+ if(count($data)>0){
|
|
|
|
+ for($i=0;$i<count($data);$i++){
|
|
|
|
+ if (strpos($data[$i]['title'], '煤矿') !== false || strpos($data[$i]['title'], '洗选') !== false) {
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] > $unit_max_rate){
|
|
|
|
+ $unit_max_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] < $unit_min_rate){
|
|
|
|
+ $unit_min_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }elseif(strpos($data[$i]['title'], '煤制油') !== false || strpos($data[$i]['title'], '烯烃') !== false || strpos($data[$i]['title'], '甲醇') !== false || strpos($data[$i]['title'], '精蜡') !== false){
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] > $mzy_max_rate){
|
|
|
|
+ $mzy_max_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] < $mzy_min_rate){
|
|
|
|
+ $mzy_min_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] > $other_max_rate){
|
|
|
|
+ $other_max_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] < $other_min_rate){
|
|
|
|
+ $other_min_rate = $data[$i]['rate'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for($i=0;$i<count($data);$i++){
|
|
|
|
+ if (strpos($data[$i]['title'], '煤矿') !== false || strpos($data[$i]['title'], '洗选') !== false) {
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] == $unit_max_rate){
|
|
|
|
+ $unit_max_name = $unit_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] == $unit_min_rate){
|
|
|
|
+ $unit_min_name = $unit_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }elseif(strpos($data[$i]['title'], '煤制油') !== false || strpos($data[$i]['title'], '烯烃') !== false || strpos($data[$i]['title'], '甲醇') !== false || strpos($data[$i]['title'], '精蜡') !== false){
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] == $mzy_max_rate){
|
|
|
|
+ $mzy_max_name = $mzy_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] == $mzy_min_rate){
|
|
|
|
+ $mzy_min_name = $mzy_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ if($data[$i]['rate'] == $other_max_rate){
|
|
|
|
+ $other_max_name = $other_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+ if($data[$i]['rate'] == $other_min_rate){
|
|
|
|
+ $other_min_name = $other_max_name.'、'.$data[$i]['title'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $unit_max_name = mb_substr($unit_max_name, 1);
|
|
|
|
+ $unit_min_name = mb_substr($unit_min_name, 1);
|
|
|
|
+ $mzy_max_name = mb_substr($mzy_max_name, 1);
|
|
|
|
+ $mzy_min_name = mb_substr($mzy_min_name, 1);
|
|
|
|
+ $other_max_name = mb_substr($other_max_name, 1);
|
|
|
|
+ $other_min_name = mb_substr($other_min_name, 1);
|
|
|
|
+
|
|
|
|
+ $result['data'] = '本周公司视频摄像头在线数'.$nm['total_online'].'个,'.'在线率为'.$nm['rate'].'%('.$time
|
|
|
|
+ .'统计)。其中:①煤炭生产建设单位在线率排名第一的单位是'.$unit_max_name.',在线率达到'.$unit_max_rate
|
|
|
|
+ .'%;排名末位的单位是'.$unit_min_name.',在线率达到'.$unit_min_rate
|
|
|
|
+ .'%。②煤制油化工单位在线率排名第一的单位是'.$mzy_max_name.',在线率达到'.$mzy_max_rate.'%;排名末位的单位是'
|
|
|
|
+ .$mzy_min_name.',在线率达到'.$mzy_min_rate.'%。③其他单位在线率排名第一的单位是'.$other_max_name
|
|
|
|
+ .',在线率达到'.$other_max_rate.'%;排名末位的单位是'.$other_min_name.',在线率达到'.$other_min_rate.'%。';
|
|
|
|
+
|
|
|
|
+ return self::successResponse($result);
|
|
}
|
|
}
|
|
|
|
|
|
//宁煤不在线摄像头列表
|
|
//宁煤不在线摄像头列表
|
|
@@ -1126,4 +1237,47 @@ class CameraApiController extends BaseController
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //摄像头访问记录入库
|
|
|
|
+ public function cameraRecordInsert(Request $request){
|
|
|
|
+ $params = $request->all();
|
|
|
|
+
|
|
|
|
+ if(isset($params['staff_num']) && isset($params['name']) && isset($params['department']) && isset($params['post']) && isset($params['camera_id']) && isset($params['start_time'])){
|
|
|
|
+ $camera = DB::table('camera_list')->where('id',$params['camera_id'])->get();
|
|
|
|
+ $mine = DB::table('mine_list')->where('id',$camera[0]->mine_id)->get();
|
|
|
|
+ $degree = explode('|',$mine[0]->degree);
|
|
|
|
+ $unit = DB::table('mine_list')->where('id',$degree[0])->get();
|
|
|
|
+
|
|
|
|
+ $data['staff_num'] = $params['staff_num'];
|
|
|
|
+ $data['name'] = $params['name'];
|
|
|
|
+ $data['department'] = $params['department'];
|
|
|
|
+ $data['post'] = $params['post'];
|
|
|
|
+ $data['mine_id'] = $camera[0]->mine_id;
|
|
|
|
+ $data['camera_id'] = $params['camera_id'];
|
|
|
|
+ $data['camera_name'] = $camera[0]->camera_name;
|
|
|
|
+ $data['unit_name'] = $unit[0]->title;
|
|
|
|
+ if(isset($params['base64']) && $params['base64'] != null && $params['base64'] != ''){
|
|
|
|
+ $data['base64'] = $params['base64'];
|
|
|
|
+ }
|
|
|
|
+ $data['start_time'] = date('Y-m-d').' '.$params['start_time'];
|
|
|
|
+ // $data['start_time'] = date('Y-m-d').' '.$params['end_time'];
|
|
|
|
+ $data['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
+ $data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
+
|
|
|
|
+ DB::table('camera_record')->insert($data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //摄像头访问记录列表
|
|
|
|
+ public function cameraRecordList(Request $request){
|
|
|
|
+ $params = $request->all();
|
|
|
|
+
|
|
|
|
+ if (!isset($params['camera_id'])) {
|
|
|
|
+ return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $camera_record = DB::table('camera_record')->where('camera_id',$params['camera_id'])->where('deleted_at',null)->orderBy('created_at','desc')->limit(20)->get();
|
|
|
|
+
|
|
|
|
+ return self::successResponse($camera_record);
|
|
|
|
+ }
|
|
}
|
|
}
|