Explorar el Código

洗选风险作业导出接口

任敬轩 hace 7 meses
padre
commit
ca0eae46c4
Se han modificado 1 ficheros con 127 adiciones y 3 borrados
  1. 127 3
      Modules/Camera/Http/Controllers/Api/CameraApiController.php

+ 127 - 3
Modules/Camera/Http/Controllers/Api/CameraApiController.php

@@ -3035,7 +3035,7 @@ class CameraApiController extends BaseController
             ->leftJoin('uf_xx_area', 'uf_xx_coal_washery.area_id', '=', 'uf_xx_area.id')
             ->whereDate('uf_xx_risk_assignment.create_time', $date)
             ->where('uf_xx_risk_assignment.is_delete',0)
-            ->where('uf_xx_risk_assignment.wcqk',1)
+            ->where('uf_xx_risk_assignment.wcqk',0)
             ->where('uf_xx_risk_assignment.risk_level',0)
             ->get();
 
@@ -3141,7 +3141,7 @@ class CameraApiController extends BaseController
     //导出完成情况表自营列表
     public function export3ListZiying(Request $request){
         $params = $request->all();
-        $result = [];
+        $result['ziying_list'] = [];
 
         if(isset($params['date'])){
             $date = $params['date'];
@@ -3149,13 +3149,75 @@ class CameraApiController extends BaseController
             $date = date('Y-m-d');
         }
 
+        $coal_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery')->where('is_delete',0)->where('obj_type',0)->orderBy('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')->whereDate('create_time', $date)->where('IS_DELETE', 0)->where('coal_washery_id',$coal_list[$i]->ID)->where('wcqk',0)->orderBy('create_time')->get();
+                if(count($risk_list) > 0){
+                    $gao = 0;
+                    $zhong = 0;
+                    $di = 0;
+                    for($j=0;$j<count($risk_list);$j++){
+                        if($risk_list[$j]->risk_level == 0){
+                            $gao = $gao + 1;
+                        }
+                        if($risk_list[$j]->risk_level == 1){
+                            $zhong = $zhong + 1;
+                        }
+                        if($risk_list[$j]->risk_level == 2){
+                            $di = $di + 1;
+                        }
+                    }
+                    if($gao > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 0){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '高风险'.$gao.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                    if($zhong > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 1){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '中风险'.$zhong.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                    if($di > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 2){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '低风险'.$di.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
         return $result;
     }
 
     //导出完成情况表委外列表
     public function export3ListWeiwai(Request $request){
         $params = $request->all();
-        $result = [];
+        $result['ziying_list'] = [];
 
         if(isset($params['date'])){
             $date = $params['date'];
@@ -3163,6 +3225,68 @@ class CameraApiController extends BaseController
             $date = date('Y-m-d');
         }
 
+        $coal_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery')->where('is_delete',0)->where('obj_type',1)->orderBy('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')->whereDate('create_time', $date)->where('IS_DELETE', 0)->where('coal_washery_id',$coal_list[$i]->ID)->where('wcqk',0)->orderBy('create_time')->get();
+                if(count($risk_list) > 0){
+                    $gao = 0;
+                    $zhong = 0;
+                    $di = 0;
+                    for($j=0;$j<count($risk_list);$j++){
+                        if($risk_list[$j]->risk_level == 0){
+                            $gao = $gao + 1;
+                        }
+                        if($risk_list[$j]->risk_level == 1){
+                            $zhong = $zhong + 1;
+                        }
+                        if($risk_list[$j]->risk_level == 2){
+                            $di = $di + 1;
+                        }
+                    }
+                    if($gao > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 0){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '高风险'.$gao.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                    if($zhong > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 1){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '中风险'.$zhong.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                    if($di > 0){
+                        for($j=0;$j<count($risk_list);$j++){
+                            if($risk_list[$j]->risk_level == 2){
+                                array_push($result['ziying_list'],[
+                                    'unit' => $coal_list[$i]->title,
+                                    'risk_level' => '低风险'.$di.'项',
+                                    'content' => $risk_list[$j]->risk_name,
+                                    'reason' => '按计划施工',
+                                    'people' => $risk_list[$j]->work_people
+                                ]);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
         return $result;
     }