|
@@ -3334,24 +3334,10 @@ class CameraApiController extends BaseController
|
|
|
//导出分类表
|
|
|
public function export2Type(Request $request){
|
|
|
$params = $request->all();
|
|
|
- $result['type_list'] = [];
|
|
|
+ $type_list = [];
|
|
|
$index = 0;
|
|
|
|
|
|
- // 风险类型
|
|
|
- $risk_type = DB::connection('mysql_fwe10')
|
|
|
- ->table('field_option as t')
|
|
|
- ->where('field_id', '1055270106096394246')
|
|
|
- ->where('t.is_delete',0)
|
|
|
- ->where('t.delete_type',0)
|
|
|
- ->get();
|
|
|
- $risk_type_dict = [];
|
|
|
- foreach ($risk_type as $key=>$value) {
|
|
|
- $risk_type_key = $value->value_key;
|
|
|
- $risk_type_name = $value->NAME;
|
|
|
- $risk_type_dict[$risk_type_key] = $risk_type_name;
|
|
|
- }
|
|
|
-
|
|
|
- // $type_list = ['高空坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息'];
|
|
|
+ $risk_type = ['高空坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息','物体打击','淹溺','灼烫','受限空间','坍塌','锅炉爆炸','其他爆炸','其他伤害'];
|
|
|
|
|
|
if(isset($params['date'])){
|
|
|
$date = $params['date'];
|
|
@@ -3359,85 +3345,109 @@ class CameraApiController extends BaseController
|
|
|
$date = date('Y-m-d');
|
|
|
}
|
|
|
|
|
|
- $coal_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery as t')
|
|
|
- ->select('t.*','t1.title as area_title')
|
|
|
- ->leftJoin('uf_xx_area as t1','t1.id','=','t.area_id')
|
|
|
- ->where('t.is_delete',0)
|
|
|
- ->where('t.delete_type',0)
|
|
|
- ->orderBy('t1.create_time')
|
|
|
- ->orderBy('t.sort')
|
|
|
+ $risk_list = DB::connection('mysql_fwe10')->table('uf_xx_risk_assignment as risk')
|
|
|
+ ->select('risk.risk_type','risk.risk_level','risk.risk_name','risk.work_num','risk.risk_location','risk.work_people','coal.title as coal_title','area.title as area_title','area.id as area_id')
|
|
|
+ ->leftJoin('uf_xx_coal_washery as coal','coal.id','=','risk.coal_washery_id')
|
|
|
+ ->leftJoin('uf_xx_area as area','area.id','=','coal.area_id')
|
|
|
+ ->where('risk.is_delete',0)
|
|
|
+ ->where('risk.delete_type',0)
|
|
|
+ ->whereDate('risk.create_time', $date)
|
|
|
+ ->whereIn('risk.risk_level',[0,1])
|
|
|
+ ->where('risk.current_step','结束节点')
|
|
|
+ ->whereNotNull('risk.flow_id')
|
|
|
+ ->orderBy('coal.area_id')
|
|
|
+ ->orderBy('risk.risk_level')
|
|
|
->get();
|
|
|
|
|
|
- for($i=0;$i<count($risk_type_dict);$i++){
|
|
|
- for($j=0;$j<count($coal_list);$j++){
|
|
|
- $risk_level = '';
|
|
|
-
|
|
|
- $risk_gao_list = DB::connection('mysql_fwe10')
|
|
|
- ->table('uf_xx_risk_assignment')
|
|
|
- ->where('risk_level',0)
|
|
|
- ->whereDate('create_time', $date)
|
|
|
- ->where('coal_washery_id',$coal_list[$j]->ID)
|
|
|
- ->where('risk_type',$i)
|
|
|
- ->where('is_delete',0)
|
|
|
- ->where('delete_type',0)
|
|
|
- ->where('current_step','结束节点')
|
|
|
- ->whereNotNull('flow_id')
|
|
|
- ->orderBy('create_time')->get();
|
|
|
- $risk_zhong_list = DB::connection('mysql_fwe10')
|
|
|
- ->table('uf_xx_risk_assignment')
|
|
|
- ->where('risk_level',1)
|
|
|
- ->whereDate('create_time', $date)
|
|
|
- ->where('coal_washery_id',$coal_list[$j]->ID)
|
|
|
- ->where('risk_type',$i)
|
|
|
- ->where('is_delete',0)
|
|
|
- ->where('current_step','结束节点')
|
|
|
- ->where('delete_type',0)
|
|
|
- ->whereNotNull('flow_id')
|
|
|
- ->orderBy('create_time')->get();
|
|
|
-
|
|
|
- if(count($risk_gao_list) > 0){
|
|
|
- $risk_level = '高风险'.count($risk_gao_list).'项,';
|
|
|
- }
|
|
|
- if(count($risk_zhong_list) > 0){
|
|
|
- $risk_level = $risk_level . '中风险'.count($risk_zhong_list).'项';
|
|
|
- }
|
|
|
-
|
|
|
- $risk_level = rtrim($risk_level, ",");
|
|
|
-
|
|
|
- if(count($risk_gao_list) > 0){
|
|
|
- for($x=0;$x<count($risk_gao_list);$x++){
|
|
|
+ for($i=0;$i<count($risk_type);$i++){
|
|
|
+ $count_gao = 0;
|
|
|
+ $count_zhong = 0;
|
|
|
+ $data = [];
|
|
|
+ if(count($risk_list) > 0){
|
|
|
+ for($j=0;$j<count($risk_list);$j++){
|
|
|
+ if($risk_list[$j]->area_id == '1055262869143609349' && $risk_list[$j]->risk_type == $i){
|
|
|
+ if($risk_list[$j]->risk_level == 0){
|
|
|
+ $count_gao++;
|
|
|
+ }
|
|
|
+ if($risk_list[$j]->risk_level == 1){
|
|
|
+ $count_zhong++;
|
|
|
+ }
|
|
|
$index++;
|
|
|
- array_push($result['type_list'],[
|
|
|
+ array_push($data,[
|
|
|
+ 'area'=>$risk_list[$j]->area_title,
|
|
|
'index'=>$index,
|
|
|
- 'risk_type'=>$risk_type_dict[$i],
|
|
|
- 'risk_level'=>$risk_level,
|
|
|
- 'unit'=>$coal_list[$j]->title,
|
|
|
- 'content'=>$risk_gao_list[$x]->risk_name,
|
|
|
- 'people_count'=>$risk_gao_list[$x]->work_num,
|
|
|
- 'work_location'=>$risk_gao_list[$x]->risk_location,
|
|
|
- 'leader'=>$risk_gao_list[$x]->work_people
|
|
|
+ 'risk_type'=>$risk_type[$i],
|
|
|
+ 'risk_level'=>$risk_list[$j]->risk_level,
|
|
|
+ 'unit'=>$risk_list[$j]->coal_title,
|
|
|
+ 'content'=>$risk_list[$j]->risk_name,
|
|
|
+ 'people_count'=>$risk_list[$j]->work_num,
|
|
|
+ 'work_location'=>$risk_list[$j]->risk_location,
|
|
|
+ 'leader'=>$risk_list[$j]->work_people
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ if(count($data) > 0){
|
|
|
+ for($x=0;$x<count($data);$x++){
|
|
|
+ if($data[$x]['risk_level'] == 0){
|
|
|
+ $data[$x]['risk_level'] = '高风险'.$count_gao.'项';
|
|
|
+ }
|
|
|
+ if($data[$x]['risk_level'] == 1){
|
|
|
+ $data[$x]['risk_level'] = '中风险'.$count_zhong.'项';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for($x=0;$x<count($data);$x++){
|
|
|
+ array_push($type_list,$data[$x]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(count($risk_zhong_list) > 0){
|
|
|
- for($x=0;$x<count($risk_zhong_list);$x++){
|
|
|
+ for($i=0;$i<count($risk_type);$i++){
|
|
|
+ $count_gao = 0;
|
|
|
+ $count_zhong = 0;
|
|
|
+ $data = [];
|
|
|
+ if(count($risk_list) > 0){
|
|
|
+ for($j=0;$j<count($risk_list);$j++){
|
|
|
+ if($risk_list[$j]->area_id == '1055262899082551297' && $risk_list[$j]->risk_type == $i){
|
|
|
+ if($risk_list[$j]->risk_level == 0){
|
|
|
+ $count_gao++;
|
|
|
+ }
|
|
|
+ if($risk_list[$j]->risk_level == 1){
|
|
|
+ $count_zhong++;
|
|
|
+ }
|
|
|
$index++;
|
|
|
- array_push($result['type_list'],[
|
|
|
- 'area'=>$coal_list[$j]->area_title,
|
|
|
+ array_push($data,[
|
|
|
+ 'area'=>$risk_list[$j]->area_title,
|
|
|
'index'=>$index,
|
|
|
- 'risk_type'=>$risk_type_dict[$i],
|
|
|
- 'risk_level'=>$risk_level,
|
|
|
- 'unit'=>$coal_list[$j]->title,
|
|
|
- 'content'=>$risk_zhong_list[$x]->risk_name,
|
|
|
- 'people_count'=>$risk_zhong_list[$x]->work_num,
|
|
|
- 'work_location'=>$risk_zhong_list[$x]->risk_location,
|
|
|
- 'leader'=>$risk_zhong_list[$x]->work_people
|
|
|
+ 'risk_type'=>$risk_type[$i],
|
|
|
+ 'risk_level'=>$risk_list[$j]->risk_level,
|
|
|
+ 'unit'=>$risk_list[$j]->coal_title,
|
|
|
+ 'content'=>$risk_list[$j]->risk_name,
|
|
|
+ 'people_count'=>$risk_list[$j]->work_num,
|
|
|
+ 'work_location'=>$risk_list[$j]->risk_location,
|
|
|
+ 'leader'=>$risk_list[$j]->work_people
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(count($data) > 0){
|
|
|
+ for($x=0;$x<count($data);$x++){
|
|
|
+ if($data[$x]['risk_level'] == 0){
|
|
|
+ $data[$x]['risk_level'] = '高风险'.$count_gao.'项';
|
|
|
+ }
|
|
|
+ if($data[$x]['risk_level'] == 1){
|
|
|
+ $data[$x]['risk_level'] = '中风险'.$count_zhong.'项';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for($x=0;$x<count($data);$x++){
|
|
|
+ array_push($type_list,$data[$x]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ $result['type_list'] = $type_list;
|
|
|
+
|
|
|
return $result;
|
|
|
}
|
|
|
|