Browse Source

Merge branch 'master' of http://git.jieweizhineng.com/ushio/video_system into master

任敬轩 2 days ago
parent
commit
29948184b1
3 changed files with 421 additions and 128 deletions
  1. 16 0
      .idea/php.xml
  2. 402 127
      Modules/Camera/Http/Controllers/Api/CameraApiController.php
  3. 3 1
      Modules/Camera/Routes/api.php

+ 16 - 0
.idea/php.xml

@@ -1,5 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="MessDetectorOptionsConfiguration">
+    <option name="transferred" value="true" />
+  </component>
+  <component name="PHPCSFixerOptionsConfiguration">
+    <option name="transferred" value="true" />
+  </component>
+  <component name="PHPCodeSnifferOptionsConfiguration">
+    <option name="highlightLevel" value="WARNING" />
+    <option name="transferred" value="true" />
+  </component>
   <component name="PhpIncludePathManager">
     <include_path>
       <path value="$PROJECT_DIR$/vendor/erusev/parsedown" />
@@ -124,9 +134,15 @@
     </include_path>
   </component>
   <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
+  <component name="PhpStanOptionsConfiguration">
+    <option name="transferred" value="true" />
+  </component>
   <component name="PhpUnit">
     <phpunit_settings>
       <PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
     </phpunit_settings>
   </component>
+  <component name="PsalmOptionsConfiguration">
+    <option name="transferred" value="true" />
+  </component>
 </project>

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

@@ -3034,7 +3034,7 @@ class CameraApiController extends BaseController
 
     //导出总表
     public function export1(Request $request){
-        $params = $request->all();
+//        $params = $request->all();
 
         $date = $request->query('date', date('Y-m-d'));
         $coal_washery_id = $request->query('coal_washery_id');
@@ -3051,7 +3051,7 @@ class CameraApiController extends BaseController
             ->where('t.delete_type',0)
             ->get();
         // 如果上边查到的风险类型还有问题的话,就用下边的维护的,不要去查数据库
-        $risk_type_dict = ['高处坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息','物体打击','淹溺','灼烫','受限空间','坍塌','锅炉爆炸','其他爆炸','其他伤害'];;
+        $risk_type_dict = ['高处坠落','起重伤害','触电','火灾','机械伤害','中毒和窒息','物体打击','淹溺','灼烫','受限空间','坍塌','锅炉爆炸','其他爆炸','其他伤害'];
         foreach ($risk_type as $key=>$value) {
             $risk_type_key = $value->value_key;
             $risk_type_name = $value->NAME;
@@ -3101,7 +3101,10 @@ class CameraApiController extends BaseController
                 ->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);
+                ->where('t2.id', $area_id)
+                ->select([
+                    't.*'
+                ]);
         }
 
         $risk_list = $risk_list->orderBy('risk_level')->get();
@@ -3138,7 +3141,9 @@ class CameraApiController extends BaseController
         $coal_washery_list = $coal_washery_list->select('t.*')->orderBy('t.sort')->get();
 
 
+        // 存放每个洗煤厂的信息
         $coal_washery_dict = [];
+        // 存放每个洗煤厂是自营还是外委的信息,0 自营,1 外委
         $coal_washery_type_dict = [];
         foreach ($coal_washery_list as $key=>$value) {
             $coal_washery_dict[$value->ID] = $value;
@@ -3157,6 +3162,8 @@ class CameraApiController extends BaseController
             "waiwei_list"   => [],
             "table_list"    => [],
         ];
+
+        // 以下两行统计高风险中的不同风险类型各有几项(中风险同理)
         $risk_zhong_con = [];
         $risk_gao_con = [];
         $coal_washery_risk_list = [];
@@ -3168,7 +3175,8 @@ class CameraApiController extends BaseController
 
             // 风险数量统计
             $risk_level = $value->risk_level;  // 风险类型
-            $risk_type = $risk_type_dict[$value->risk_type] ?? 2;
+            // 当 $risk_type_dict[$value->risk_type] 存在时取对应的值,不存在时取值 未知风险
+            $risk_type = $risk_type_dict[$value->risk_type] ?? "未知风险";
 
             if($risk_level == 0) {
                 $res['gao']++;
@@ -3217,12 +3225,14 @@ class CameraApiController extends BaseController
                 $place = '';//作业地点
                 $leader = '';//负责人
                 $reviewer = [];//审核人
+                // 拿出当前id煤矿的所有风险
                 $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分支 无论是自营还是委外,处理的逻辑和步骤都是一样的,所以可以优化掉分支结构
                     if ($coal_washery_type == 0) {
                         foreach ($coal_washery_risk_info_arr as $k => $v) {
                             $people += $v->work_num;
@@ -3298,6 +3308,12 @@ class CameraApiController extends BaseController
                 if ($gao   > 0) $level_total .= '高风险'.$gao."项\n";
                 if ($zhong > 0) $level_total .= '中风险'.$zhong."项\n";
                 if ($di    > 0) $level_total .= '低风险'.$di.'项';
+                /**
+                 * 在下文中的¥line中,'unit' 、'classes' 和 'risk_dexcribe' 中的 $v 可能未定义
+                 * (如果能取到值应该是上文定义的 $v 中的遍历的最后一个的对应值)
+                 * 这两个的值是不合理的,但是目前系统中 unit 的值总是 洗选中心,
+                 * classes 和 risk_dexcribe 的值的准确性也没有要求
+                 */
                 $line = [
                     'index' => $index,
                     'unit' => $v->unit,
@@ -4282,7 +4298,6 @@ class CameraApiController extends BaseController
 
     // 导出委外作业
     public function export6(Request $request){
-        $params = $request->all();
 
         $date = $request->query('date', date('Y-m-d'));
         $coal_washery_id = $request->query('coal_washery_id');
@@ -4306,31 +4321,6 @@ 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)
-//                ->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)
@@ -4349,10 +4339,332 @@ class CameraApiController extends BaseController
                 ->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);
+                ->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); // 筛选洗煤厂
+        // 不要按片区筛选洗煤厂,因为有可能宁东片区的洗煤厂的施工地点在太西洗煤厂,反之亦然
+//        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 = [];
+        // 存放每个洗煤厂是自营还是外委的信息,0 自营,1 外委
+//        $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,
+            "risk_info" => "",
+            "risk_list"   => [],
+        ];
+
+        // 以下两行统计高风险中的不同风险类型各有几项(中风险同理)
+        $risk_zhong_con = [];
+        $risk_gao_con = [];
+        $coal_washery_risk_list = [];
+
+        // 统计委外单位的数量
+        $outsourcedUnit_total = [];
+
+        // 组织字典
+        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;
+            }
+
+            // 风险数量统计
+            $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']."项。\n";
+
+
+
+
+
+        $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 = [];
+
+                $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;
+                    }
+                    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.'项';
+
+                $wwdw_num = count($wwdw);
+                $sgdd_num = count($sgdd);
+                $var1 = implode('、',$wwdw);
+                $var2 = implode('、',$sgdd);
+
+                if (++$index_1==1){
+                    $total2 .= '2.'.$index_1.'.'.$value->title.'引进委外单位'.$wwdw_num.'个('.$var1.'),'.'作业厂点'.$sgdd_num.'个('.$var2.");\n";
+                } else{
+                    $total2 .= '  '.$index_1.'.'.$value->title.'引进委外单位'.$wwdw_num.'个('.$var1.'),'.'作业厂点'.$sgdd_num.'个('.$var2.");\n";
+                }
+
+
+                $line = [
+                    'index' => '',
+                    'gao' => '',
+                    'zhong' => '',
+                    'di' => '',
+                    'coal_washery' => '',
+                    'wwdw'=>'',
+                    'wwdw_num'=>'',
+                    'work_place_num' => '',
+                    'level' => "",
+                    'content' => '',
+                    'place' => '',
+                ];
+
+                foreach ($coal_washery_risk_info_arr as $k => $v) {
+
+                    $risk_index = 0;
+                    $line['index'] = $index_1;
+                    $line['wwdw_num'] = $wwdw_num;
+                    $line['coal_washery'] = $value->title;
+                    $line['work_place_num'] = $v->sgdsl;
+                    $line['wwdw'] = $v->wwdw;
+                    $line['place'] = $temp;
+                    $line['level'] = $level_total;
+
+                    $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'] = ++$risk_index.".".$v->risk_name.$risk_info."盯控人:".$v->work_people;
+
+                    $res['risk_list'][] = $line;
+
+
+
+                }
+
+            }
+        }
+
+        $res['risk_info'] .= $total2;
+
+        /**
+         *
+         * 以下代码以施工地点为中新统计相关数据
+         */
+        $work_place_list=[];
+        foreach ($risk_list as $key1=>$v1) {
+            // 获取施工地点id
+            $work_place = $v1->sgdd;
+            // 施工地点列表
+            $work_place_list[$work_place][] = $v1;
+
+        }
+
+
+        $total3 = '';
+        foreach ($coal_washery_dict as $key=>$value) {
+            $dd_wwdw = [];
+            $dd_sgdsl = 0;
+            $id = $value->ID;
+            $index_2 = 0;
+            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;
+                }
+
+                if (++$index_2 == 1) {
+                    $total3 .= $index_2.'.'.$value->title.'委外作业'.count($work_place_list_arr).'项,委外施工单位'.count($dd_wwdw).'个,施工点'.$dd_sgdsl."个;\n";
+                }else{
+                    $total3 .= '    '.++$index_2.'.'.$value->title.'委外作业'.count($work_place_list_arr).'项,委外施工单位'.count($dd_wwdw).'个,施工点'.$dd_sgdsl."个;\n";
+                }
+
+
+            }
+        }
+
+        $res['risk_info'] .= $total3;
+
+
+
+
+        return $res;
+    }
+
+
+    public function export7(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)
+            ->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)) {
+            $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();
+        // 下文代码将春检的作业放在其他作业的后边
         $str2="春检:";
         // 存放春检数据
         $temp_list=[];
@@ -4386,7 +4698,9 @@ class CameraApiController extends BaseController
         $coal_washery_list = $coal_washery_list->select('t.*')->orderBy('t.sort')->get();
 
 
+        // 存放每个洗煤厂的信息
         $coal_washery_dict = [];
+        // 存放每个洗煤厂是自营还是外委的信息,0 自营,1 外委
         $coal_washery_type_dict = [];
         foreach ($coal_washery_list as $key=>$value) {
             $coal_washery_dict[$value->ID] = $value;
@@ -4405,6 +4719,8 @@ class CameraApiController extends BaseController
             "waiwei_list"   => [],
             "table_list"    => [],
         ];
+
+        // 以下两行统计高风险中的不同风险类型各有几项(中风险同理)
         $risk_zhong_con = [];
         $risk_gao_con = [];
         $coal_washery_risk_list = [];
@@ -4416,7 +4732,8 @@ class CameraApiController extends BaseController
 
             // 风险数量统计
             $risk_level = $value->risk_level;  // 风险类型
-            $risk_type = $risk_type_dict[$value->risk_type] ?? 2;
+            // 当 $risk_type_dict[$value->risk_type] 存在时取对应的值,不存在时取值 未知风险
+            $risk_type = $risk_type_dict[$value->risk_type] ?? "未知风险";
 
             if($risk_level == 0) {
                 $res['gao']++;
@@ -4449,14 +4766,11 @@ class CameraApiController extends BaseController
 
         $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;
@@ -4465,106 +4779,71 @@ class CameraApiController extends BaseController
                 $place = '';//作业地点
                 $leader = '';//负责人
                 $reviewer = [];//审核人
+                // 拿出当前id煤矿的所有风险
                 $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++;
+                    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].')';
                             }
-
-                            $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;
+                        } 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].')';
                             }
-                            $reviewer = array_unique($reviewer);
+                        } else {
+                            $di++;
                         }
-//                        $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";
+                        $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);
+                        $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];
+                    $level_total = '';
+                    if ($gao   > 0) $level_total .= '高风险'.$gao."项\n";
+                    if ($zhong > 0) $level_total .= '中风险'.$zhong."项\n";
+                    if ($di    > 0) $level_total .= '低风险'.$di.'项';
+                    /**
+                     * 在下文中的¥line中,'unit' 、'classes' 和 'risk_dexcribe' 中的 $v 可能未定义
+                     * (如果能取到值应该是上文定义的 $v 中的遍历的最后一个的对应值)
+                     * 这两个的值是不合理的,但是目前系统中 unit 的值总是 洗选中心,
+                     * classes 和 risk_dexcribe 的值的准确性也没有要求
+                     */
+                    $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,
+                    ];
+
                     if ($coal_washery_type == 0) {
                         $line['index'] = ++ $index_ziying;
                         $res["ziying_list"][] = $line;
@@ -4572,14 +4851,10 @@ class CameraApiController extends BaseController
                         $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++) {

+ 3 - 1
Modules/Camera/Routes/api.php

@@ -91,7 +91,8 @@ Route::namespace('Api')->group(function () {
     Route::post('task_xixuan/home_v2', 'CameraApiController@taskHomeV2');//首頁接口
     Route::post('task_xixuan/work_search_v2', 'CameraApiController@workSearchV2');//首頁作业查询
     Route::post('task_xixuan/area_work_search_v2', 'CameraApiController@areaWorkSearchV2');//首頁片区作业查询
-    Route::post('task_xixuan/export1', 'CameraApiController@export1');//导出总表
+    Route::post('task_xixuan/export1', 'CameraApiController@export7');//导出总表
+    Route::post('task_xixuan/export7', 'CameraApiController@export1');//export1的备份 export7 是 export1的行能优化(代码重构)
     Route::post('task_xixuan/export2_type', 'CameraApiController@export2Type');//导出分类表
     Route::post('task_xixuan/export2_camera', 'CameraApiController@export2Camera');//导出摄像头表
     Route::post('task_xixuan/export3_total', 'CameraApiController@export3Total');//导出完成情况表统计
@@ -101,6 +102,7 @@ Route::namespace('Api')->group(function () {
     Route::post('task_xixuan/export5', 'CameraApiController@export5');//导出人均盯控次数统计
     Route::post('task_xixuan/export6', 'CameraApiController@export6');//导出委外作业清单
 
+
     //大华视频接口
     Route::post('task_xixuan/dahua_camera','TdwyController@dahuaCamera');//大华手动同步
     Route::post('task_xixuan/dahua_talk','CameraApiController@dahuaTalk');//大华语音对讲