瀏覽代碼

更新导出zip

sandm 1 年之前
父節點
當前提交
3d45ea6930
共有 1 個文件被更改,包括 77 次插入76 次删除
  1. 77 76
      app/Admin/Controllers/Recruit/RecruitController.php

+ 77 - 76
app/Admin/Controllers/Recruit/RecruitController.php

@@ -2077,7 +2077,7 @@ class RecruitController extends Controller
      * @throws \Exception
      */
     public function out_zip(Request $request)
-    {//TODO 数据太大,无法压缩,得做成异步
+    {//TODO 数据太大,无法压缩,得做成异步,现阶段指定导出人员
         Permission::check('recruit_out_excel');
         $recruit_id = $request->id;
         $recruit = Recruit::find($recruit_id);
@@ -2085,22 +2085,23 @@ class RecruitController extends Controller
             return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
         }
 
-        $data = $request->all();
+        //$data = $request->all();
         $where = [];
-        $where[] = ['recruit_appoint_info.audit','>',0];
-        $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
-        $param = parse_url($data['where']);
-        parse_str($param['query'],$param);
-        if (is_array($param)) {
-            unset($param['id']);
-            foreach ($param as $k => $v) {
-                if ($k == 'realname') {
-                    $where[] = [$k, 'like', "%$v%"];
-                } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
-                    $where[] = [$k, '=', $v];
-                }
-            }
-        }
+        $where[] = ['recruit_appoint_info.audit','=',3];
+        $where[] = ['recruit_appoint_info.recruit_id', '=', $recruit_id];
+        $where[] = ['recruit_appoint_info.realname', 'in', ['廖赐艺','吴鑫','庄惠阳','傅承恩','游美','吴维灵','许世芳','林非余','黄其森','徐阳雍','郑金埭','王俊龙','张询','吴晓瑜','王传晔','许宏焱','李焕金','许雅玲','陈月超']];
+//        $param = parse_url($data['where']);
+//        parse_str($param['query'],$param);
+//        if (is_array($param)) {
+//            unset($param['id']);
+//            foreach ($param as $k => $v) {
+//                if ($k == 'realname') {
+//                    $where[] = [$k, 'like', "%$v%"];
+//                } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
+//                    $where[] = [$k, '=', $v];
+//                }
+//            }
+//        }
         $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
         $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')->join('recruit_ticket','recruit_ticket.appoint_id','=','recruit_appoint_info.id','left');
         if(in_array('expand_special',explode(',', $recruit->forms))){
@@ -2127,66 +2128,66 @@ class RecruitController extends Controller
         }
 
         if($list){
-//            foreach ($list as $key => $value){
-//                $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
-//                if(!is_dir($path)){
-//                    Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
-//                }
-//                if(in_array('expand_special',explode(',', $recruit->forms))){
-//                    $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
-//                    $material = json_decode($special['material'],true);
-//                    if($material){
-//                        foreach ($material as $k => $v){
-//                            $old_path = base_path() . "/public/" . $v['url'];
-//                            if (file_exists($old_path)) {
-//                                $basename = basename($old_path);
-//                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
-//                                copy($old_path, $new_path); //拷贝到新目录
-//                            }
-//                        }
-//                    }
-//                }
-//                if(in_array('identification',explode(',', $recruit->forms))){
-//                    $identification = json_decode($value->identification,true);
-//                    if($identification){
-//                        foreach ($identification as $k => $v){
-//                            $old_path = base_path() . "/public/"  . $v['url'];
-//                            if (file_exists($old_path)) {
-//                                $basename = basename($old_path);
-//                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
-//                                copy($old_path, $new_path); //拷贝到新目录
-//                            }
-//                        }
-//                    }
-//                }
-//                if(in_array('education_certification',explode(',', $recruit->forms))){
-//                    $education_certification = json_decode($value->education_certification,true);
-//                    if($education_certification){
-//                        foreach ($education_certification as $k => $v){
-//                            $old_path = base_path() . "/public/"  . $v['url'];
-//                            if (file_exists($old_path)) {
-//                                $basename = basename($old_path);
-//                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
-//                                copy($old_path, $new_path); //拷贝到新目录
-//                            }
-//                        }
-//                    }
-//                }
-//                if(in_array('other_certification',explode(',', $recruit->forms))){
-//                    $other_certification = json_decode($value->other_certification,true);
-//                    if($other_certification){
-//                        foreach ($other_certification as $k => $v){
-//                            $old_path = base_path() . "/public/"  . $v['url'];
-//                            if (file_exists($old_path)) {
-//                                $basename = basename($old_path);
-//                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
-//                                copy($old_path, $new_path); //拷贝到新目录
-//                            }
-//                        }
-//                    }
-//                }
-//                copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
-//            }
+            foreach ($list as $key => $value){
+                $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
+                if(!is_dir($path)){
+                    Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
+                }
+                if(in_array('expand_special',explode(',', $recruit->forms))){
+                    $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
+                    $material = json_decode($special['material'],true);
+                    if($material){
+                        foreach ($material as $k => $v){
+                            $old_path = base_path() . "/public/" . $v['url'];
+                            if (file_exists($old_path)) {
+                                $basename = basename($old_path);
+                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
+                                copy($old_path, $new_path); //拷贝到新目录
+                            }
+                        }
+                    }
+                }
+                if(in_array('identification',explode(',', $recruit->forms))){
+                    $identification = json_decode($value->identification,true);
+                    if($identification){
+                        foreach ($identification as $k => $v){
+                            $old_path = base_path() . "/public/"  . $v['url'];
+                            if (file_exists($old_path)) {
+                                $basename = basename($old_path);
+                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
+                                copy($old_path, $new_path); //拷贝到新目录
+                            }
+                        }
+                    }
+                }
+                if(in_array('education_certification',explode(',', $recruit->forms))){
+                    $education_certification = json_decode($value->education_certification,true);
+                    if($education_certification){
+                        foreach ($education_certification as $k => $v){
+                            $old_path = base_path() . "/public/"  . $v['url'];
+                            if (file_exists($old_path)) {
+                                $basename = basename($old_path);
+                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
+                                copy($old_path, $new_path); //拷贝到新目录
+                            }
+                        }
+                    }
+                }
+                if(in_array('other_certification',explode(',', $recruit->forms))){
+                    $other_certification = json_decode($value->other_certification,true);
+                    if($other_certification){
+                        foreach ($other_certification as $k => $v){
+                            $old_path = base_path() . "/public/"  . $v['url'];
+                            if (file_exists($old_path)) {
+                                $basename = basename($old_path);
+                                $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
+                                copy($old_path, $new_path); //拷贝到新目录
+                            }
+                        }
+                    }
+                }
+                copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
+            }
 
             $savename = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}.zip";
             $zipper = new Zipper();