|
@@ -72,7 +72,60 @@ class CameraApiController extends BaseController
|
|
|
|
|
|
//高风险区域摄像头
|
|
//高风险区域摄像头
|
|
public function getCameraByMinecode(){
|
|
public function getCameraByMinecode(){
|
|
- return 11;
|
|
|
|
|
|
+ $mine_code = Input::get('mine_code', '');
|
|
|
|
+
|
|
|
|
+ if (!$mine_code) {
|
|
|
|
+ return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $result['status'] = true;
|
|
|
|
+ $result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
|
+
|
|
|
|
+ $mine = DB::table('mine_list')->where('slug','like','%'.$mine_code.'%')->where('parent_id',0)->where('deleted_at',null)->first();
|
|
|
|
+
|
|
|
|
+ if (!$mine) {
|
|
|
|
+ $result['status'] = false;
|
|
|
|
+ $result['msg'] = '矿区名称不存在';
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $mine_list = DB::table('mine_list')->where('degree', 'like', $mine->id . '|' . '%')->where('title','like','%高风险%')->where('deleted_at',null)->get();
|
|
|
|
+
|
|
|
|
+ $mine_array = [];
|
|
|
|
+
|
|
|
|
+ foreach($mine_list as $k=>$v){
|
|
|
|
+ $mine_child = DB::table('mine_list')->where('degree', 'like','%' . $v->id . '%')->where('deleted_at',null)->get();
|
|
|
|
+ if(count($mine_child)>0){
|
|
|
|
+ for($i=0;$i<count($mine_child);$i++){
|
|
|
|
+ $mine_array[] = $mine_child[$i]->id;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $query = DB::table('camera_list')
|
|
|
|
+ ->select('camera_list.*','mine_list.title')
|
|
|
|
+ ->leftJoin('mine_list','camera_list.mine_id','=','mine_list.id')
|
|
|
|
+ ->where('camera_list.deleted_at',null)
|
|
|
|
+ ->whereIn('camera_list.mine_id',$mine_array)
|
|
|
|
+ ->orderBy('sort', 'desc')->get();
|
|
|
|
+
|
|
|
|
+ if (!$query) {
|
|
|
|
+ $result['status'] = false;
|
|
|
|
+ $result['msg'] = '矿区下没有摄像头';
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $result = [];
|
|
|
|
+ foreach($query as $k=>$v){
|
|
|
|
+ $result[$k]['parent_id'] = $mine->id;
|
|
|
|
+ $result[$k]['camera_id'] = $v->id;
|
|
|
|
+ $result[$k]['mine_name'] = $v->title;
|
|
|
|
+ $result[$k]['camera_name'] = $v->camera_name;
|
|
|
|
+ $result[$k]['cover_picture'] = $v->cover_picture;
|
|
|
|
+ $result[$k]['camera_status'] = $v->camera_status;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return self::successResponse($result);
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 作者: qiuzijian
|
|
* 作者: qiuzijian
|