Przeglądaj źródła

风险作业接口

任敬轩 5 miesięcy temu
rodzic
commit
0b6d3a6d05

+ 46 - 0
Modules/Camera/Http/Controllers/Api/CameraApiController.php

@@ -3706,7 +3706,53 @@ class CameraApiController extends BaseController
             $end_time = date('Y-m-d 00:00:00', strtotime('+1 day'));
         }
 
+        $res = [];
 
+        $coal_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery as c')
+            ->select('c.*','a.title as area')
+            ->leftJoin('uf_xx_area as a','a.id','=','c.area_id')
+            ->where('c.is_delete',0)
+            ->orderBy('c.sort')->get();
+
+        if(count($coal_list) > 0){
+            for($i=0;$i<count($coal_list);$i++){
+                $risk_list = DB::connection('mysql_fwe10')->table('uf_xx_risk_assignment')
+                    ->whereBetween('create_time', [$start_time, $end_time])
+                    ->where('is_delete',0)
+                    ->where('coal_washery_id',$coal_list[$i]->ID)
+                    ->get();
+                if(count($risk_list) > 0){
+                    $control_num = 0;
+                    $people_list = [];
+                    for($j=0;$j<count($risk_list);$j++){
+                        $people = explode('、',$risk_list[$j]->work_people);
+                        $control_num = $control_num + count($people);
+                        for($x=0;$x<count($people);$x++){
+                            array_push($people_list,$people[$x]);
+                        }
+                    }
+                    $people_list = array_unique($people_list);
+
+                    $res[$i]['area'] = $coal_list[$i]->area;
+                    $res[$i]['unit'] = $coal_list[$i]->title;
+                    $res[$i]['work_num'] = count($risk_list);
+                    $res[$i]['control_num'] = $control_num;
+                    $res[$i]['people_num'] = count($people_list);
+                    $res[$i]['people_avg_count'] = number_format($control_num/count($people_list), 2);
+                }else{
+                    $res[$i]['area'] = $coal_list[$i]->area;
+                    $res[$i]['unit'] = $coal_list[$i]->title;
+                    $res[$i]['work_num'] = 0;
+                    $res[$i]['control_num'] = 0;
+                    $res[$i]['people_num'] = 0;
+                    $res[$i]['people_avg_count'] = 0;
+                }
+            }
+
+        }
+
+        $result['control_list'] = $res;
+        return $result;
     }
 
     //图片上传