|
@@ -4636,6 +4636,367 @@ class CameraApiController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ public function export62(Request $request){
|
|
|
+
|
|
|
+ $date = $request->query('date', date('Y-m-d'));
|
|
|
+ $coal_washery_id = $request->query('coal_washery_id');
|
|
|
+ $area_id = $request->query('area_id');
|
|
|
+
|
|
|
+ $classes = ['早班','中班','夜班','早班、中夜、夜班','早班、夜班','早班、中夜'];
|
|
|
+ $risk_desc = ['高风险','中风险','低风险'];
|
|
|
+ $risk_describe_dict = [0=>"设备日常检修、维护", 1=>"停产检修", 2=>"大中修", 3=>"计划性检修", 4=>"委外施工"];
|
|
|
+ // 风险类型
|
|
|
+ $risk_type = DB::connection('mysql_fwe10')
|
|
|
+ ->table('field_option as t')
|
|
|
+ ->where('t.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;
|
|
|
+ }
|
|
|
+
|
|
|
+ $risk_list = DB::connection('mysql_fwe10')
|
|
|
+ ->table('uf_xx_risk_assignment as t')
|
|
|
+ ->whereDate('t.create_time', $date)
|
|
|
+ ->where('t.is_delete',0)
|
|
|
+ ->where('t.delete_type',0)
|
|
|
+ ->whereNotNull('t.wwdw')
|
|
|
+ ->whereNotNull('t.sgdd')
|
|
|
+ ->where('t.current_step','结束节点')
|
|
|
+ ->whereNotNull('t.flow_id');
|
|
|
+
|
|
|
+
|
|
|
+ $previousDay = $date->modify('-1 day')->format('Y-m-d');
|
|
|
+
|
|
|
+ $risk_list_previousDay = DB::connection('mysql_fwe10')
|
|
|
+ ->table('uf_xx_risk_assignment as t')
|
|
|
+ ->whereDate('t.create_time', $previousDay)
|
|
|
+ ->where('t.is_delete',0)
|
|
|
+ ->where('t.delete_type',0)
|
|
|
+ ->whereNotNull('t.wwdw')
|
|
|
+ ->whereNotNull('t.sgdd')
|
|
|
+ ->where('t.current_step','结束节点')
|
|
|
+ ->whereNotNull('t.flow_id');
|
|
|
+
|
|
|
+ if (!empty($coal_washery_id)) $risk_list->where('t.coal_washery_id', $coal_washery_id); // 筛选洗煤厂
|
|
|
+ if (!empty($area_id)) {
|
|
|
+ $risk_list->join('uf_xx_coal_washery as t1','t.coal_washery_id','=','t1.id')
|
|
|
+ ->where('t1.is_delete',0)
|
|
|
+ ->where('t1.delete_type',0)
|
|
|
+ ->join('uf_xx_area as t2','t1.area_id','=','t2.id')
|
|
|
+ ->where('t2.is_delete',0)
|
|
|
+ ->where('t2.delete_type',0)
|
|
|
+ ->where('t2.id', $area_id)
|
|
|
+ ->select([
|
|
|
+ 't.*'
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $risk_list = $risk_list->orderBy('risk_level')->get();
|
|
|
+
|
|
|
+
|
|
|
+ // 洗煤厂数据
|
|
|
+ $coal_washery_list = DB::connection('mysql_fwe10')->table('uf_xx_coal_washery as t')->where('t.is_delete',0);
|
|
|
+ if (!empty($coal_washery_id)) $coal_washery_list->where('t.id', $coal_washery_id); // 筛选洗煤厂
|
|
|
+
|
|
|
+ $coal_washery_list = $coal_washery_list->select('t.*')->orderBy('t.sort')->get();
|
|
|
+
|
|
|
+
|
|
|
+ // 存放每个洗煤厂的信息
|
|
|
+ $coal_washery_dict = [];
|
|
|
+ foreach ($coal_washery_list as $key=>$value) {
|
|
|
+ $coal_washery_dict[$value->ID] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $res = [
|
|
|
+ "num" => 0,
|
|
|
+ "gao" => 0,
|
|
|
+ "zhong" => 0,
|
|
|
+ "di" => 0,
|
|
|
+ "risk_info" => "",
|
|
|
+ "risk_list" => [],
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 以下两行统计高风险中的不同风险类型各有几项(中风险同理)
|
|
|
+ $risk_zhong_con = [];
|
|
|
+ $risk_gao_con = [];
|
|
|
+ $coal_washery_risk_list = [];
|
|
|
+
|
|
|
+ // 统计委外单位的数量
|
|
|
+ $outsourcedUnit_total = [];
|
|
|
+ // 统计作业总人数
|
|
|
+ $people_total = 0;
|
|
|
+
|
|
|
+ // 组织字典
|
|
|
+ foreach ($risk_list as $key=>$value) {
|
|
|
+ // 获取洗煤厂ID
|
|
|
+ $coal_washery_id = $value->coal_washery_id;
|
|
|
+
|
|
|
+ if (!in_array($value->wwdw,$outsourcedUnit_total)){
|
|
|
+ $outsourcedUnit_total[] = $value->wwdw;
|
|
|
+ }
|
|
|
+
|
|
|
+ $people_total += $value->work_num;
|
|
|
+
|
|
|
+ // 风险数量统计
|
|
|
+ $risk_level = $value->risk_level; // 风险类型
|
|
|
+ // 当 $risk_type_dict[$value->risk_type] 存在时取对应的值,不存在时取值 未知风险
|
|
|
+ $risk_type = $risk_type_dict[$value->risk_type] ?? "未知风险";
|
|
|
+
|
|
|
+ if($risk_level == 0) {
|
|
|
+ $res['gao']++;
|
|
|
+ if (!isset($risk_gao_con[$risk_type])) {
|
|
|
+ $risk_gao_con[$risk_type] = 1;
|
|
|
+ } else {
|
|
|
+ $risk_gao_con[$risk_type] ++;
|
|
|
+ };
|
|
|
+ } else if($risk_level == 1) {
|
|
|
+ $res['zhong']++;
|
|
|
+ if (!isset($risk_zhong_con[$risk_type])) {
|
|
|
+ $risk_zhong_con[$risk_type] = 1;
|
|
|
+ } else {
|
|
|
+ $risk_zhong_con[$risk_type] ++;
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ $res['di']++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 煤矿风险列表
|
|
|
+ $coal_washery_risk_list[$coal_washery_id][] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $res['num'] = count($risk_list);
|
|
|
+
|
|
|
+
|
|
|
+ if ($res['gao'] > 0) {
|
|
|
+ $risk_gao_info = '(其中:';
|
|
|
+ foreach ($risk_gao_con as $key => $value) {
|
|
|
+ $risk_gao_info .= $key.$value.'项,';
|
|
|
+ }
|
|
|
+ $risk_gao_info = substr($risk_gao_info, 0, -3);
|
|
|
+ $risk_gao_info .= ');';
|
|
|
+ } else {
|
|
|
+ $risk_gao_info = ";";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($res['zhong'] > 0) {
|
|
|
+ $risk_zhong_info = '(其中:';
|
|
|
+ foreach ($risk_zhong_con as $key => $value) {
|
|
|
+ $risk_zhong_info .= $key.$value.'项,';
|
|
|
+ }
|
|
|
+ $risk_zhong_info = substr($risk_zhong_info, 0, -3);
|
|
|
+ $risk_zhong_info .= ');';
|
|
|
+ } else {
|
|
|
+ $risk_zhong_info = ";";
|
|
|
+ }
|
|
|
+
|
|
|
+ $res['risk_info'] = "1.委外施工单位共".count($outsourcedUnit_total)."个,总作业项:".$res['num']."项;高风险:".$res['gao']."项".$risk_gao_info."中风险:".$res['zhong']."项".$risk_zhong_info."低风险:".$res['di']."项;总作业人数:".$people_total."人。";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $total2 = '';
|
|
|
+ $index_1 = 0;
|
|
|
+ foreach ($coal_washery_dict as $key => $value) {
|
|
|
+ $id = $value->ID;
|
|
|
+ if (isset($coal_washery_risk_list[$id])) {
|
|
|
+
|
|
|
+ // 拿出当前id煤矿的所有风险
|
|
|
+ $coal_washery_risk_info_arr = $coal_washery_risk_list[$id];
|
|
|
+ $wwdw = [];
|
|
|
+ $sgdd = [];
|
|
|
+ $zyrs = 0;
|
|
|
+
|
|
|
+ $gao = 0;
|
|
|
+ $zhong = 0;
|
|
|
+ $di = 0;
|
|
|
+
|
|
|
+ foreach ($coal_washery_risk_info_arr as $k => $v) {
|
|
|
+ if(!in_array($v->wwdw,$wwdw)){
|
|
|
+ $wwdw[] = $v->wwdw;
|
|
|
+ }
|
|
|
+ $temp = $coal_washery_dict[$v->sgdd]->title;
|
|
|
+ if (!in_array($temp,$sgdd)){
|
|
|
+ $sgdd[] = $temp;
|
|
|
+ }
|
|
|
+ $zyrs += $v->work_num;
|
|
|
+ if ($v->risk_level == 0){
|
|
|
+ $gao++;
|
|
|
+ } else if ($v->risk_level == 1){
|
|
|
+ $zhong++;
|
|
|
+ }else{
|
|
|
+ $di++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ $level_total = '';
|
|
|
+ if ($gao > 0) $level_total .= '高风险'.$gao."项\n";
|
|
|
+ if ($zhong > 0) $level_total .= '中风险'.$zhong."项\n";
|
|
|
+ if ($di > 0) $level_total .= '低风险'.$di."项\n";
|
|
|
+ $level_total = mb_substr($level_total, 0, mb_strlen($level_total) - 1);
|
|
|
+
|
|
|
+ $wwdw_num = count($wwdw);
|
|
|
+ $sgdd_num = count($sgdd);
|
|
|
+ $var1 = implode('、',$wwdw);
|
|
|
+ $var2 = implode('、',$sgdd);
|
|
|
+
|
|
|
+// $total2 .= ++$index_1.'.'.$value->title.'引进委外单位'.$wwdw_num.'个('.$var1.'),'.'作业单位'.$sgdd_num.'个('.$var2."),作业人数:".$zyrs."人。\n";
|
|
|
+ $total2 .= ++$index_1.'.'.$value->title.'引进委外单位'.$wwdw_num.'个,作业单位'.$sgdd_num.'个,作业人数:'.$zyrs."人。\n";
|
|
|
+
|
|
|
+
|
|
|
+ $line = [
|
|
|
+ 'index' => '',
|
|
|
+ 'fxdj' => '',
|
|
|
+ 'fxlx' => '',
|
|
|
+ 'coal_washery' => '',
|
|
|
+ 'wwdw'=>'',
|
|
|
+ 'wwdw_num'=>'',
|
|
|
+ 'work_place_num' => '',
|
|
|
+ 'level' => "",
|
|
|
+ 'content' => '',
|
|
|
+ 'place' => '',
|
|
|
+ 'dkr' => '',
|
|
|
+ 'zrs' => $zyrs,
|
|
|
+ 'rs' => 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $risk_index = 0;
|
|
|
+ foreach ($coal_washery_risk_info_arr as $k => $v) {
|
|
|
+
|
|
|
+
|
|
|
+ $line['index'] = ++$risk_index;
|
|
|
+ $line['wwdw_num'] = $wwdw_num;
|
|
|
+ $line['coal_washery'] = $value->title;
|
|
|
+// $line['work_place_num'] = $v->sgdsl;
|
|
|
+ $line['work_place_num'] = "Discard";
|
|
|
+ $line['wwdw'] = $v->wwdw;
|
|
|
+ $line['place'] = $coal_washery_dict[$v->sgdd]->title;
|
|
|
+ $line['level'] = $level_total;
|
|
|
+ $line['content'] = $v->risk_name;
|
|
|
+ $line['dkr'] = $v->work_people;
|
|
|
+ $line['rs'] = $v->work_num;
|
|
|
+
|
|
|
+ if ($v->risk_level == 0) {
|
|
|
+ $line['fxdj'] = '高风险';
|
|
|
+ } elseif ($v->risk_level == 1) {
|
|
|
+ $line['fxdj'] = '中风险';
|
|
|
+ } else {
|
|
|
+ $line['fxdj'] = '低风险';
|
|
|
+ }
|
|
|
+ if($v->risk_type != null) {
|
|
|
+ $line['fxlx'] = $risk_type_dict[$v->risk_type];
|
|
|
+ }else{
|
|
|
+ $line['fxlx'] = '未知';
|
|
|
+ }
|
|
|
+
|
|
|
+// $risk_info = '';
|
|
|
+// if ($v->risk_level == 0) {
|
|
|
+// $line['gao'] = 1;
|
|
|
+// $line['zhong'] = '';
|
|
|
+// $line['di'] = '';
|
|
|
+// if($v->risk_type != null) {
|
|
|
+// $risk_info = '(' . $risk_desc[$v->risk_level] . ',' . $risk_type_dict[$v->risk_type] . ')';
|
|
|
+// }else{
|
|
|
+// $risk_info = '('.$risk_desc[$v->risk_level].')';
|
|
|
+// }
|
|
|
+// } else if ($v->risk_level == 1) {
|
|
|
+// $line['gao'] = '';
|
|
|
+// $line['zhong'] = 1;
|
|
|
+// $line['di'] = '';
|
|
|
+// if($v->risk_type != null){
|
|
|
+// $risk_info = '('.$risk_desc[$v->risk_level].','.$risk_type_dict[$v->risk_type].')';
|
|
|
+// }else{
|
|
|
+// $risk_info = '('.$risk_desc[$v->risk_level].')';
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// $line['gao'] = '';
|
|
|
+// $line['zhong'] = '';
|
|
|
+// $line['di'] = 1;
|
|
|
+// }
|
|
|
+
|
|
|
+// $line['content'] = $v->risk_name.$risk_info."盯控人:".$v->work_people;
|
|
|
+
|
|
|
+ $res['risk_list'][] = $line;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $res['risk_info2'] = $total2;
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 以下代码以施工地点为中新统计相关数据
|
|
|
+ */
|
|
|
+ $work_place_list=[];
|
|
|
+ foreach ($risk_list as $key1=>$v1) {
|
|
|
+ // 获取施工地点id
|
|
|
+ $work_place = $v1->sgdd;
|
|
|
+ // 施工地点列表
|
|
|
+ $work_place_list[$work_place][] = $v1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $uniqueKeys = array_keys($work_place_list);
|
|
|
+ $count1 = count($uniqueKeys);
|
|
|
+ $var3 = (int) ($count1 / 2);
|
|
|
+
|
|
|
+
|
|
|
+ $total3 = '';
|
|
|
+ $total4 = '';
|
|
|
+ $index_2 = 0;
|
|
|
+ foreach ($coal_washery_dict as $key=>$value) {
|
|
|
+ $dd_wwdw = [];
|
|
|
+ $dd_sgdsl = 0;
|
|
|
+ $workNumber = 0;
|
|
|
+ $id = $value->ID;
|
|
|
+
|
|
|
+ if (isset($work_place_list[$id])) {
|
|
|
+
|
|
|
+ // 拿出当前施工地点的所有风险
|
|
|
+ $work_place_list_arr = $work_place_list[$id];
|
|
|
+ foreach ($work_place_list_arr as $k => $v) {
|
|
|
+ if (!in_array($v->wwdw,$dd_wwdw)) {
|
|
|
+ $dd_wwdw[] = $v->wwdw;
|
|
|
+ }
|
|
|
+ $dd_sgdsl += $v->sgdsl;
|
|
|
+ $workNumber += $v->work_num;
|
|
|
+ }
|
|
|
+
|
|
|
+// $total3 .= ++$index_2.'.'.$value->title.'委外作业'.count($work_place_list_arr).'项,委外施工单位'.count($dd_wwdw).'个,施工点'.$dd_sgdsl."个;\n";
|
|
|
+ if (++$index_2<=$var3){
|
|
|
+ $total3 .= $index_2.'.'.$value->title.'委外作业'.count($work_place_list_arr).'项,作业人数:'.$workNumber."人;\n";
|
|
|
+ } else{
|
|
|
+ $total4 .= $index_2.'.'.$value->title.'委外作业'.count($work_place_list_arr).'项,作业人数:'.$workNumber."人;\n";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $res['risk_info3'] = $total3;
|
|
|
+ $res['risk_info4'] = $total4;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public function export7(Request $request){
|
|
|
|
|
|
$date = $request->query('date', date('Y-m-d'));
|