|
@@ -3058,30 +3058,40 @@ class CameraApiController extends BaseController
|
|
|
$risk_type_dict[$risk_type_key] = $risk_type_name;
|
|
|
}
|
|
|
|
|
|
- if(!empty($area_id)){
|
|
|
- // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
- $risk_list = DB::connection('mysql_fwe10')
|
|
|
- ->table('uf_xx_risk_assignment as t')
|
|
|
- ->select('t.*','t1.shr as coal_shr')
|
|
|
- ->whereDate('t.create_time', $date)
|
|
|
- ->where('t.is_delete',0)
|
|
|
- ->where('t.delete_type',0)
|
|
|
- ->where('t.wwdw',null)
|
|
|
- ->where('t.sgdd',null)
|
|
|
- ->where('t.current_step','结束节点')
|
|
|
- ->whereNotNull('t.flow_id');
|
|
|
- }else{
|
|
|
- // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
- $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)
|
|
|
- ->where('t.wwdw',null)
|
|
|
- ->where('t.sgdd',null)
|
|
|
- ->where('t.current_step','结束节点')
|
|
|
- ->whereNotNull('t.flow_id');
|
|
|
- }
|
|
|
+// if(!empty($area_id)){
|
|
|
+// // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
+// $risk_list = DB::connection('mysql_fwe10')
|
|
|
+// ->table('uf_xx_risk_assignment as t')
|
|
|
+// ->select('t.*','t1.shr as coal_shr')
|
|
|
+// ->whereDate('t.create_time', $date)
|
|
|
+// ->where('t.is_delete',0)
|
|
|
+// ->where('t.delete_type',0)
|
|
|
+// ->where('t.wwdw',null)
|
|
|
+// ->where('t.sgdd',null)
|
|
|
+// ->where('t.current_step','结束节点')
|
|
|
+// ->whereNotNull('t.flow_id');
|
|
|
+// }else{
|
|
|
+// // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
+// $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)
|
|
|
+// ->where('t.wwdw',null)
|
|
|
+// ->where('t.sgdd',null)
|
|
|
+// ->where('t.current_step','结束节点')
|
|
|
+// ->whereNotNull('t.flow_id');
|
|
|
+// }
|
|
|
+
|
|
|
+ $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)
|
|
|
+ ->where('t.wwdw',null)
|
|
|
+ ->where('t.sgdd',null)
|
|
|
+ ->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)) {
|
|
@@ -4268,6 +4278,374 @@ class CameraApiController extends BaseController
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ // 导出委外作业
|
|
|
+ public function export6(Request $request){
|
|
|
+ $params = $request->all();
|
|
|
+
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+
|
|
|
+// if(!empty($area_id)){
|
|
|
+// // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
+// $risk_list = DB::connection('mysql_fwe10')
|
|
|
+// ->table('uf_xx_risk_assignment as t')
|
|
|
+// ->select('t.*','t1.shr as coal_shr')
|
|
|
+// ->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');
|
|
|
+// }else{
|
|
|
+// // 风险数据 is_delete = 0 and delete_type = 0 and flow_id is not null
|
|
|
+// $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');
|
|
|
+// }
|
|
|
+
|
|
|
+ $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');
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ $risk_list = $risk_list->orderBy('risk_level')->get();
|
|
|
+ $str2="春检:";
|
|
|
+ // 存放春检数据
|
|
|
+ $temp_list=[];
|
|
|
+ // 存放其他数据
|
|
|
+ $temp_list2=[];
|
|
|
+ foreach ($risk_list as $key=>$value){
|
|
|
+ if (strstr($value->risk_name, $str2)){
|
|
|
+ $temp_list[] = $value;
|
|
|
+ }else{
|
|
|
+ $temp_list2[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unset($risk_list);
|
|
|
+ $risk_list = [];
|
|
|
+ foreach ($temp_list2 as $key=>$value){
|
|
|
+ $risk_list[] = $value;
|
|
|
+ }
|
|
|
+ foreach ($temp_list as $key=>$value){
|
|
|
+ $risk_list[] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 洗煤厂数据
|
|
|
+ $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); // 筛选洗煤厂
|
|
|
+ // 筛选片区
|
|
|
+ if (!empty($area_id)) {
|
|
|
+ $coal_washery_list->leftJoin('uf_xx_area as t1','t1.id','=','t.area_id')
|
|
|
+ ->where('t1.id', $area_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ $coal_washery_list = $coal_washery_list->select('t.*')->orderBy('t.sort')->get();
|
|
|
+
|
|
|
+
|
|
|
+ $coal_washery_dict = [];
|
|
|
+ $coal_washery_type_dict = [];
|
|
|
+ foreach ($coal_washery_list as $key=>$value) {
|
|
|
+ $coal_washery_dict[$value->ID] = $value;
|
|
|
+ $coal_washery_type_dict[$value->ID] = $value->obj_type;
|
|
|
+ }
|
|
|
+
|
|
|
+ $res = [
|
|
|
+ "num" => 0,
|
|
|
+ "gao" => 0,
|
|
|
+ "zhong" => 0,
|
|
|
+ "di" => 0,
|
|
|
+ "ziying" => 0,
|
|
|
+ "waiwei" => 0,
|
|
|
+ "risk_info" => "",
|
|
|
+ "ziying_list" => [],
|
|
|
+ "waiwei_list" => [],
|
|
|
+ "table_list" => [],
|
|
|
+ ];
|
|
|
+ $risk_zhong_con = [];
|
|
|
+ $risk_gao_con = [];
|
|
|
+ $coal_washery_risk_list = [];
|
|
|
+
|
|
|
+ // 组织字典
|
|
|
+ foreach ($risk_list as $key=>$value) {
|
|
|
+ // 获取洗煤厂ID
|
|
|
+ $coal_washery_id = $value->coal_washery_id;
|
|
|
+
|
|
|
+ // 风险数量统计
|
|
|
+ $risk_level = $value->risk_level; // 风险类型
|
|
|
+ $risk_type = $risk_type_dict[$value->risk_type] ?? 2;
|
|
|
+
|
|
|
+ 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_type = $coal_washery_dict[$coal_washery_id]->obj_type ?? "<请检查洗煤厂是否已被删除!>";
|
|
|
+ if($coal_washery_type == 0) {
|
|
|
+ $res['ziying']++;
|
|
|
+ } else if ($coal_washery_type == 1) {
|
|
|
+ $res['waiwei']++;
|
|
|
+ }
|
|
|
+ // 煤矿风险列表
|
|
|
+ $coal_washery_risk_list[$coal_washery_id][] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $res['num'] = count($risk_list);
|
|
|
+
|
|
|
+ $coal_list = [];
|
|
|
+ $index = 0;
|
|
|
+ $index_ziying = 0;
|
|
|
+ $index_waiwei = 0;
|
|
|
+ foreach ($coal_washery_dict as $key => $value) {
|
|
|
+ $id = $value->ID;
|
|
|
+ if (isset($coal_washery_risk_list[$id])) {
|
|
|
+ $index++;
|
|
|
+ $people = 0;//计划人数
|
|
|
+ $gao = 0;
|
|
|
+ $zhong = 0;
|
|
|
+ $di = 0;
|
|
|
+ $content = '';//工作内容
|
|
|
+ $place = '';//作业地点
|
|
|
+ $leader = '';//负责人
|
|
|
+ $reviewer = [];//审核人
|
|
|
+ $coal_washery_risk_info_arr = $coal_washery_risk_list[$id];
|
|
|
+
|
|
|
+ // 如果修改后的代码可以正常运行一段时间,以下注释的代码都可以删除,修改时间2025/1/9
|
|
|
+ $risk_index = 0;
|
|
|
+ if (isset($coal_washery_type_dict[$id])) {
|
|
|
+ $coal_washery_type = $coal_washery_type_dict[$id];
|
|
|
+ if ($coal_washery_type == 0) {
|
|
|
+ foreach ($coal_washery_risk_info_arr as $k => $v) {
|
|
|
+ $people += $v->work_num;
|
|
|
+ $risk_info = '';
|
|
|
+ if ($v->risk_level == 0) {
|
|
|
+ $gao++;
|
|
|
+ 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) {
|
|
|
+ $zhong++;
|
|
|
+ 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 {
|
|
|
+ $di++;
|
|
|
+ }
|
|
|
+
|
|
|
+ $content .= ++$risk_index.".".$v->risk_name.$risk_info.";\n";
|
|
|
+
|
|
|
+
|
|
|
+ $place .= $risk_index.".".$v->risk_location.";\n";
|
|
|
+ $leader .= $risk_index.".".$v->work_people.";\n";
|
|
|
+
|
|
|
+ if (isset($v->shr) && !empty($v->shr)) {
|
|
|
+ $reviewer[] = $v->shr;
|
|
|
+ }
|
|
|
+ $reviewer = array_unique($reviewer);
|
|
|
+ }
|
|
|
+// $line['index'] = ++ $index_ziying;
|
|
|
+// $res["ziying_list"][] = $line;
|
|
|
+ } else {
|
|
|
+ foreach ($coal_washery_risk_info_arr as $k => $v) {
|
|
|
+ $people += $v->work_num;
|
|
|
+ $risk_info = '';
|
|
|
+ if ($v->risk_level == 0) {
|
|
|
+ $gao++;
|
|
|
+ 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].')';
|
|
|
+ }
|
|
|
+// $risk_info = '('.$risk_desc[$v->risk_level].','.$risk_type_dict[$v->risk_type].')';
|
|
|
+ } else if ($v->risk_level == 1) {
|
|
|
+ $zhong++;
|
|
|
+ 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].')';
|
|
|
+ }
|
|
|
+// $risk_info = '('.$risk_desc[$v->risk_level].','.$risk_type_dict[$v->risk_type].')';
|
|
|
+ } else {
|
|
|
+ $di++;
|
|
|
+ }
|
|
|
+
|
|
|
+ $content .= ++$risk_index.".".$v->risk_name.$risk_info.";\n";
|
|
|
+
|
|
|
+ $place .= $risk_index.".".$v->risk_location.";\n";
|
|
|
+ $leader .= $risk_index.".".$v->work_people.";\n";
|
|
|
+
|
|
|
+ if (isset($v->shr) && !empty($v->shr)) {
|
|
|
+ $reviewer[] = $v->shr;
|
|
|
+ }
|
|
|
+ $reviewer = array_unique($reviewer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $level_total = '';
|
|
|
+ if ($gao > 0) $level_total .= '高风险'.$gao."项\n";
|
|
|
+ if ($zhong > 0) $level_total .= '中风险'.$zhong."项\n";
|
|
|
+ if ($di > 0) $level_total .= '低风险'.$di.'项';
|
|
|
+ $line = [
|
|
|
+ 'index' => $index,
|
|
|
+ 'unit' => $v->unit,
|
|
|
+ 'coal_washery' => $value->title,
|
|
|
+ 'classes' => $classes[$v->classes],
|
|
|
+ 'work_num' => $people,
|
|
|
+ 'level' => $level_total,
|
|
|
+ 'content' => $content,
|
|
|
+ 'place' => $place,
|
|
|
+ 'leader' => $leader,
|
|
|
+ 'risk_dexcribe' => $risk_describe_dict[$v->risk_describe],
|
|
|
+ 'reviewer' => implode(',', $reviewer),
|
|
|
+ 'id' => $value->ID,
|
|
|
+ ];
|
|
|
+// $coal_list[] = $line;
|
|
|
+
|
|
|
+ // 自营、外委
|
|
|
+ if (isset($coal_washery_type_dict[$id])) {
|
|
|
+ $coal_washery_type = $coal_washery_type_dict[$id];
|
|
|
+ if ($coal_washery_type == 0) {
|
|
|
+ $line['index'] = ++ $index_ziying;
|
|
|
+ $res["ziying_list"][] = $line;
|
|
|
+ } else {
|
|
|
+ $line['index'] = ++ $index_waiwei;
|
|
|
+ $res["waiwei_list"][] = $line;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+// $res['table_list'] = $coal_list;
|
|
|
+// foreach($res["ziying_list"] as $key => $value){
|
|
|
+// $content = substr($value["content"], 0, -3);
|
|
|
+// $res["ziying_list"][$key]["content"] =$content;
|
|
|
+// }
|
|
|
+ $ziying_people = 0;
|
|
|
+ $waiwei_people = 0;
|
|
|
+ for ($i = 0; $i < count($res["ziying_list"]); $i++) {
|
|
|
+ $content = $res["ziying_list"][$i]['content'];
|
|
|
+// $content = substr($content, 0, -1);
|
|
|
+ $content = "\n".$content;
|
|
|
+ $res["ziying_list"][$i]['content'] = $content;
|
|
|
+ $place = $res["ziying_list"][$i]['place'];
|
|
|
+ $place = substr($place, 0, -1);
|
|
|
+ $res["ziying_list"][$i]['place'] = $place;
|
|
|
+ $leader = $res["ziying_list"][$i]['leader'];
|
|
|
+ $leader = substr($leader, 0, -1);
|
|
|
+ $res["ziying_list"][$i]['leader'] = $leader;
|
|
|
+ $ziying_people = $ziying_people + $res["ziying_list"][$i]['work_num'];
|
|
|
+
|
|
|
+ }
|
|
|
+ for ($i = 0; $i < count($res["waiwei_list"]); $i++) {
|
|
|
+ $content = $res["waiwei_list"][$i]['content'];
|
|
|
+// $content = substr($content, 0, -1);
|
|
|
+ $content = "\n".$content;
|
|
|
+ $res["waiwei_list"][$i]['content'] = $content;
|
|
|
+ $place = $res["waiwei_list"][$i]['place'];
|
|
|
+ $place = substr($place, 0, -1);
|
|
|
+ $res["waiwei_list"][$i]['place'] = $place;
|
|
|
+ $leader = $res["waiwei_list"][$i]['leader'];
|
|
|
+ $leader = substr($leader, 0, -1);
|
|
|
+ $res["waiwei_list"][$i]['leader'] = $leader;
|
|
|
+ $waiwei_people = $waiwei_people + $res["waiwei_list"][$i]['work_num'];
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($area_id == 1055262899082551297){
|
|
|
+ $res['people_info'] = "太西片区作业人数:" . ($ziying_people + $waiwei_people) ."人;其中:内部:".$ziying_people."人,外委施工:".$waiwei_people."人";
|
|
|
+ } else{
|
|
|
+ $res['people_info'] = "作业人数:" . ($ziying_people + $waiwei_people) ."人;其中:内部:".$ziying_people."人,外委施工:".$waiwei_people."人";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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'] = "总作业项:".$res['num']."项;高风险:".$res['gao']."项".$risk_gao_info."中风险:".$res['zhong']."项".$risk_zhong_info."低风险:".$res['di']."项。";
|
|
|
+
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//图片上传
|
|
|
public function uploadImg(Request $request){
|
|
|
$file = $request->file('file');
|