|
@@ -1349,6 +1349,380 @@ class CameraApiController extends BaseController
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ //主屏幕
|
|
|
+ public function mainHome(Request $request){
|
|
|
+ $gao = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',0)->count();
|
|
|
+ $zhong = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',1)->count();
|
|
|
+ $di = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',2)->count();
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ [
|
|
|
+ 'number' => $gao,
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '高风险作业',
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'number' => $zhong,
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '中风险作业',
|
|
|
+ 'color' => '#FFBA00'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'number' => $di,
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '低风险作业',
|
|
|
+ 'color' => '#2BB200'
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //风险作业占比
|
|
|
+ public function riskWorkPercent(Request $request){
|
|
|
+ $gao = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',0)->count();
|
|
|
+ $zhong = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',1)->count();
|
|
|
+ $di = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', today())->where('risk_level',2)->count();
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ [
|
|
|
+ 'value' => $gao,
|
|
|
+ 'name' => '高风险',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'value' => $zhong,
|
|
|
+ 'name' => '高风险',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'value' => $di,
|
|
|
+ 'name' => '高风险',
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //片区占比
|
|
|
+ public function areaPercent(Request $request){
|
|
|
+ $area = DB::connection('task_xixuan')->table('xx_area')->get();
|
|
|
+
|
|
|
+ if(count($area) > 0){
|
|
|
+ for($i=0;$i<count($area);$i++){
|
|
|
+ $coal_washery_id_list = DB::connection('task_xixuan')->table('xx_coal_washery')->where('area_id',$area[$i]->id)->pluck('id');
|
|
|
+ $result[$i]['value'] = DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', today())->count();
|
|
|
+ $result[$i]['name'] = $area[$i]->name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //地图数据
|
|
|
+ public function mapData(Request $request){
|
|
|
+ $coal_washery = DB::connection('task_xixuan')->table('xx_coal_washery')->get();
|
|
|
+
|
|
|
+ if(count($coal_washery) > 0){
|
|
|
+ for($i=0;$i<count($coal_washery);$i++){
|
|
|
+ $result[$i]['title'] = $coal_washery[$i]->name;
|
|
|
+ $result[$i]['data'] = [
|
|
|
+ [
|
|
|
+ 'name' => '高风险作业',
|
|
|
+ 'value'=> DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',0)->whereDate('optdt', today())->count()
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '中风险作业',
|
|
|
+ 'value'=> DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',1)->whereDate('optdt', today())->count()
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '低风险作业',
|
|
|
+ 'value'=> DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',2)->whereDate('optdt', today())->count()
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间段作业数
|
|
|
+ public function timeWorkCount(Request $request){
|
|
|
+ $params = $request->all();
|
|
|
+
|
|
|
+ if(isset($params['start_date']) && isset($params['end_date'])){
|
|
|
+ $start_date = $params['start_date'];
|
|
|
+ $end_date = $params['end_date'];
|
|
|
+ }else{
|
|
|
+ $start_date = date('Y-m-d', strtotime(date('Y-m-d') . ' -6 day'));
|
|
|
+ $end_date = date('Y-m-d');
|
|
|
+ }
|
|
|
+
|
|
|
+ $current_date = $start_date;
|
|
|
+ $i = 0;
|
|
|
+ $result = [];
|
|
|
+ $result['xAxis']['type'] = 'category';
|
|
|
+ $result['xAxis']['data'] = [];
|
|
|
+ $result['series'] = [
|
|
|
+ [
|
|
|
+ 'name' => '高风险作业',
|
|
|
+ 'type' => 'bar',
|
|
|
+ 'stack'=> 'bar_1',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#DA0000',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '中风险作业',
|
|
|
+ 'type' => 'bar',
|
|
|
+ 'stack'=> 'bar_1',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#FFBA00',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '低风险作业',
|
|
|
+ 'type' => 'bar',
|
|
|
+ 'stack'=> 'bar_1',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#2BB200',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ while ($current_date <= $end_date) {
|
|
|
+ array_push($result['xAxis']['data'],$current_date);
|
|
|
+ array_push($result['series'][0]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', $current_date)->where('risk_level',0)->count());
|
|
|
+ array_push($result['series'][1]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', $current_date)->where('risk_level',1)->count());
|
|
|
+ array_push($result['series'][2]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereDate('optdt', $current_date)->where('risk_level',2)->count());
|
|
|
+ $current_date = date('Y-m-d', strtotime($current_date . ' +1 day'));
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间段片区统计
|
|
|
+ public function timeAreaTotal(Request $request){
|
|
|
+ $params = $request->all();
|
|
|
+
|
|
|
+ if (isset($params['area_id'])) {
|
|
|
+ $area_id = $params['area_id'];
|
|
|
+ }else{
|
|
|
+ $area_id = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($params['start_date']) && isset($params['end_date'])){
|
|
|
+ $start_date = $params['start_date'];
|
|
|
+ $end_date = $params['end_date'];
|
|
|
+ }else{
|
|
|
+ $start_date = date('Y-m-d', strtotime(date('Y-m-d') . ' -6 day'));
|
|
|
+ $end_date = date('Y-m-d');
|
|
|
+ }
|
|
|
+
|
|
|
+ $coal_washery_id_list = DB::connection('task_xixuan')->table('xx_coal_washery')->where('area_id',$area_id)->pluck('id');
|
|
|
+ $result = [];
|
|
|
+ $current_date = $start_date;
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+ //当日片区数
|
|
|
+ $result['data'] = [
|
|
|
+ [
|
|
|
+ 'number' => DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', date('Y-m-d'))->where('risk_level',0)->count(),
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '高风险作业',
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'number' => DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', date('Y-m-d'))->where('risk_level',1)->count(),
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '中风险作业',
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'number' => DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', date('Y-m-d'))->where('risk_level',2)->count(),
|
|
|
+ 'unit' => '项',
|
|
|
+ 'title' => '低风险作业',
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $result['xAxis']['type'] = 'category';
|
|
|
+ $result['xAxis']['data'] = [];
|
|
|
+ $result['series'] = [
|
|
|
+ [
|
|
|
+ 'name' => '高风险作业',
|
|
|
+ 'type' => 'line',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#DA0000',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '中风险作业',
|
|
|
+ 'type' => 'line',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#FFBA00',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'name' => '低风险作业',
|
|
|
+ 'type' => 'line',
|
|
|
+ 'data' => [],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => '#2BB200',
|
|
|
+ 'borderRadius' => [10,10,10,10]
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ while ($current_date <= $end_date) {
|
|
|
+ array_push($result['xAxis']['data'],$current_date);
|
|
|
+ array_push($result['series'][0]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', $current_date)->where('risk_level',0)->count());
|
|
|
+ array_push($result['series'][1]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', $current_date)->where('risk_level',1)->count());
|
|
|
+ array_push($result['series'][2]['data'],DB::connection('task_xixuan')->table('xx_risk_assignment')->whereIn('coal_washery_id',$coal_washery_id_list)->whereDate('optdt', $current_date)->where('risk_level',2)->count());
|
|
|
+ $current_date = date('Y-m-d', strtotime($current_date . ' +1 day'));
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //洗煤厂统计
|
|
|
+ public function coalWasheryTotal(Request $request){
|
|
|
+ $coal_washery = DB::connection('task_xixuan')->table('xx_coal_washery')->get();
|
|
|
+ if(count($coal_washery) > 0){
|
|
|
+ for($i=0;$i<count($coal_washery);$i++){
|
|
|
+ $result[$i]['unit_name'] = $coal_washery[$i]->name;
|
|
|
+ $result[$i]['data'] = [
|
|
|
+ [
|
|
|
+ 'label' => '高',
|
|
|
+ 'value' => DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',0)->whereDate('optdt', today())->count(),
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '中',
|
|
|
+ 'value' => DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',1)->whereDate('optdt', today())->count(),
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '低',
|
|
|
+ 'value' => DB::connection('task_xixuan')->table('xx_risk_assignment')->where('coal_washery_id',$coal_washery[$i]->id)->where('risk_level',2)->whereDate('optdt', today())->count(),
|
|
|
+ 'color' => '#DA0000'
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //风险作业列表
|
|
|
+ public function riskWorkList(Request $request){
|
|
|
+ $params = $request->all();
|
|
|
+
|
|
|
+ if(isset($params['type'])){
|
|
|
+ $type = $params['type'];
|
|
|
+ }else{
|
|
|
+ $type = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $coal_washery_list = DB::connection('task_xixuan')->table('xx_coal_washery')->get();
|
|
|
+ if(count($coal_washery_list) > 0){
|
|
|
+ for($i=0;$i<count($coal_washery_list);$i++){
|
|
|
+ $result['unit_list'][$i]['text'] = $coal_washery_list[$i]->name;
|
|
|
+ $result['unit_list'][$i]['value'] = $coal_washery_list[$i]->id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $risk = DB::connection('task_xixuan')->table('xx_risk_assignment');
|
|
|
+ $risk = $risk->select('xx_risk_assignment.*','xx_coal_washery.name as coal_washery');
|
|
|
+ $risk = $risk->leftJoin('xx_coal_washery','xx_coal_washery.id','=','xx_risk_assignment.coal_washery_id');
|
|
|
+ $risk = $risk->whereDate('xx_risk_assignment.optdt', today());
|
|
|
+ if(isset($params['id'])){
|
|
|
+ $risk = $risk->where('xx_coal_washery.id',$params['id']);
|
|
|
+ }
|
|
|
+ $risk = $risk->where('risk_level',$type)->get();
|
|
|
+
|
|
|
+ $result['data'] = [];
|
|
|
+ if(count($risk) > 0){
|
|
|
+ for($i=0;$i<count($risk);$i++){
|
|
|
+ $result['data'][$i]['id'] = $risk[$i]->id;
|
|
|
+ $result['data'][$i]['unit_name'] = $risk[$i]->coal_washery;
|
|
|
+ $result['data'][$i]['place'] = $risk[$i]->work_location;
|
|
|
+ $result['data'][$i]['content'] = $risk[$i]->risk_name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //风险作业详情
|
|
|
+ public function riskWorkDetail(Request $request){
|
|
|
+ $params = $request->all();
|
|
|
+
|
|
|
+ if (!isset($params['id'])) {
|
|
|
+ return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ $risk_type = ['高空坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息'];
|
|
|
+ $risk_level = ['高风险','中风险','低风险'];
|
|
|
+
|
|
|
+ $risk = DB::connection('task_xixuan')->table('xx_risk_assignment')
|
|
|
+ ->select('xx_risk_assignment.*','xx_coal_washery.name as coal_washery')
|
|
|
+ ->leftJoin('xx_coal_washery','xx_coal_washery.id','=','xx_risk_assignment.coal_washery_id')
|
|
|
+ ->where('xx_risk_assignment.id',$params['id'])->get();
|
|
|
+
|
|
|
+ if(count($risk) > 0){
|
|
|
+ $camera_info = explode('|',$risk[0]->camera_id);
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ [
|
|
|
+ 'label' => '风险类型:',
|
|
|
+ 'value' => $risk_type[$risk[0]->risk_type]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '风险等级:',
|
|
|
+ 'value' => $risk_level[$risk[0]->risk_level]
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '单位:',
|
|
|
+ 'value' => $risk[0]->coal_washery
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '风险作业内容:',
|
|
|
+ 'value' => $risk[0]->risk_name
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '人数:',
|
|
|
+ 'value' => $risk[0]->work_num
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '地点:',
|
|
|
+ 'value' => $risk[0]->work_location
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '现场负责人:',
|
|
|
+ 'value' => $risk[0]->work_people
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'label' => '摄像头类型:',
|
|
|
+ 'value' => CameraEnum::CAMERA_TYPE_EXCHANGE[$camera_info[3]]
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::successResponse($result);
|
|
|
+ }
|
|
|
+
|
|
|
//首頁信息
|
|
|
public function taskHome(Request $request){
|
|
|
$risk_type = ['高空坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息'];
|