Parcourir la source

更新专场导出功能

sandm il y a 1 an
Parent
commit
35dc09e299
2 fichiers modifiés avec 431 ajouts et 0 suppressions
  1. 430 0
      app/Admin/Controllers/Recruit/SpecialController.php
  2. 1 0
      app/Admin/routes.php

+ 430 - 0
app/Admin/Controllers/Recruit/SpecialController.php

@@ -23,6 +23,9 @@ use Encore\Admin\Layout\Content;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Storage;
+use PhpOffice\PhpSpreadsheet\Cell\DataType;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
 
 class SpecialController extends Controller
 {
@@ -1240,5 +1243,432 @@ class SpecialController extends Controller
         return response(['data' => view('admin.special.ajax_audit')->with($view_data)->render(), 'status' => 1], '200');
     }
 
+    /**
+     * 导出excel汇总表
+     * @param Content $content
+     * @param Request $request
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \PhpOffice\PhpSpreadsheet\Exception
+     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
+     */
+    public function out_excel(Content $content, Request $request)
+    {
+        Permission::check('special_recruit_out_excel');
+        $id = $request->id;
+        $recruit = Recruit::find($id);
+
+        if(!$recruit->special){
+            $this->show();
+        }
+
+        if (empty($recruit)) {
+            return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
+        }
+
+        $data = $request->all();
+        $where = [];
+        $where[] = ['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 == 'id') {
+                    $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
+                } elseif($k == 'print_bs'){
+                    $where[] = ['recruit_ticket.ex_type', '=', 1];
+                    $where[] = ['recruit_ticket.ex_status', '=', $v];
+                } elseif($k == 'print_js'){
+                    $where[] = ['recruit_ticket.ex_type', '=', 2];
+                    $where[] = ['recruit_ticket.ex_status', '=', $v];
+                } elseif($k == 'print_ms'){
+                    $where[] = ['recruit_ticket.ex_type', '=', 3];
+                    $where[] = ['recruit_ticket.ex_status', '=', $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))){
+            $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
+            $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
+            $select = array_merge($select,$special_select);
+        }
+        if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
+            $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
+            $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
+            $select = array_merge($select,$detail_select);
+        }
+
+        $list = $model->select($select)
+            ->orderBy('recruit_appoint_info.updated_at','desc')
+            ->get();
+
+        if(count($list)){
+            $spreadsheet = new Spreadsheet();
+            $sheet = $spreadsheet->getActiveSheet();
+            if(in_array('internship',explode(',', $recruit->forms))){
+                $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
+            }else{
+                $header = ['姓名','性别','生日','头像','民族','籍贯','报考岗位','政治面貌','入党时间','职称或职业资格','现工作单位及职务','户籍所在地','学历','学校','学位','所学专业','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
+            }
+            if(in_array('expand_special',explode(',', $recruit->forms))){
+                $special = ['是否申请加分','符合哪一项加分条件','加分佐证材料'];
+                $header = array_merge($header,$special);
+            }
+            if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
+                $detail = ['个人简历','培训学习经历','奖惩情况','个人介绍'];
+            }else{
+                $detail = ['个人简历'];
+            }
+            $header = array_merge($header,$detail);
+            $header[] = '家庭成员及其社会关系';
+            if(in_array('identification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
+                $header[] = '身份证明';
+            }
+            if(in_array('education_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
+                $header[] = '学历证明';
+            }
+            if(in_array('other_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
+                $header[] = '其他证明';
+            }
+            if(in_array('chengnuoshu',explode(',', $recruit->forms))){
+                $header[] = '诚信承诺书';
+            }
+            if(in_array('shixin',explode(',', $recruit->forms))){
+                $header[] = '失信被执行人查询信息页扫描件';
+            }
+            $header[] = '审核状态';
+            $header[] = '审核意见';
+//            if(in_array('3',explode(',', $recruit->step))){
+//                $header = array_merge($header,['笔试准考证打印','笔试审核状态','笔试结果']);
+//            }
+//            if(in_array('4',explode(',', $recruit->step))){
+//                $header = array_merge($header,['上机准考证打印','上机审核状态','上机结果']);
+//            }
+//            if(in_array('5',explode(',', $recruit->step))){
+//                $header = array_merge($header,['面试准考证打印','面试审核状态','面试结果']);
+//            }
+//            if(in_array('6',explode(',', $recruit->step))){
+//                $header = array_merge($header,['复试准考证打印','复试审核状态','复试结果']);
+//            }
+//            if(in_array('7',explode(',', $recruit->step))){
+//                $header = array_merge($header,['体检审核状态','体检结果']);
+//            }
+//            if(in_array('8',explode(',', $recruit->step))){
+//                $header = array_merge($header,['政审状态','政审结果']);
+//            }
+            $header[] = 'word简历的下载地址';
+
+            foreach ($header as $key => $value) {
+                $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
+            }
+            $row = 2;
+            $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
+            $length = count($list);//算出该数组的长度
+            $last = $list[$length-1];//取出最后一个数组的值,复制给新变量,-1是因为第一个数组元素下表为0
+            unset($list[$length-1]);//将最后一个数组注销
+            $list[] = $last;//再将新变量加入到数组里
+            $data = [];
+            foreach ($list as $k => $v) {
+                switch ($v->political_affiliation) {
+                    case '01':
+                        $political_affiliation = '中共党员';
+                        break;
+                    case '02':
+                        $political_affiliation = '中共预备党员';
+                        break;
+                    case '03':
+                        $political_affiliation = '共青团员';
+                        break;
+                    case '04':
+                        $political_affiliation = '民革党员';
+                        break;
+                    case '05':
+                        $political_affiliation = '民盟盟员';
+                        break;
+                    case '06':
+                        $political_affiliation = '民建会员';
+                        break;
+                    case '07':
+                        $political_affiliation = '民进会员';
+                        break;
+                    case '08':
+                        $political_affiliation = '农工党党员';
+                        break;
+                    case '09':
+                        $political_affiliation = '致公党党员';
+                        break;
+                    case '10':
+                        $political_affiliation = '九三学社社员';
+                        break;
+                    case '11':
+                        $political_affiliation = '台盟盟员';
+                        break;
+                    case '12':
+                        $political_affiliation = '无党派人士';
+                        break;
+                    case '13':
+                        $political_affiliation = '群众';
+                        break;
+                    default:
+                        $political_affiliation = '未知';
+                        break;
+                }
+                if(in_array('internship',explode(',', $recruit->forms))){
+                    $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
+                    $item = [
+                        $v->realname,
+                        $v->sex == 0 ? '女' : '男',
+                        $v->birthday,
+                        "https://www.jucai.gov.cn" . $v->avatar,
+                        $v->nation,
+                        $v->native_place,
+                        $v->code . $v->name,
+                        $political_affiliation,
+                        $v->join_time,
+                        $v->house_register,
+                        $v->education,
+                        $v->school,
+                        $v->pro,
+                        $v->adjust == 0 ? '否' : '是',
+                        $v->address,
+                        '\''.$v->card,
+                        $v->mobile,
+                        $v->email,
+                        $v->concat_name,
+                        $v->concat_mobile
+                    ];
+                }else{
+                    $item = [
+                        $v->realname,
+                        $v->sex == 0 ? '女' : '男',
+                        $v->birthday,
+                        "https://www.jucai.gov.cn" . $v->avatar,
+                        $v->nation,
+                        $v->native_place,
+                        $v->code . $v->name,
+                        $political_affiliation,
+                        $v->join_time,
+                        $v->titles,
+                        $v->work,
+                        $v->house_register,
+                        $v->education,
+                        $v->school,
+                        $v->degree,
+                        $v->pro,
+                        $v->address,
+                        '\''.$v->card,
+                        $v->mobile,
+                        $v->email,
+                        $v->concat_name,
+                        $v->concat_mobile
+                    ];
+                }
+
+                if (in_array('expand_special', explode(',', $recruit->forms))) {
+                    $material = json_decode($v->material, true);
+                    $materials = [];
+                    if($material){
+                        foreach ($material as $key => $value) {
+                            array_push($materials, "https://www.jucai.gov.cn" . $value['response']['path']);
+                        }
+                    }
+                    $special = [
+                        $v->point_apply == 0 ? '否' : '是',
+                        $v->condition,
+                        implode("\r\n", $materials)
+                    ];
+                    $item = array_merge($item, $special);
+                }
+                if (in_array('detail', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
+                    $detail = [
+                        $v->resume,
+                        $v->train,
+                        $v->rewards_and_punishments,
+                        $v->introduce
+                    ];
+                } else {
+                    $detail = [$v->resume];
+                }
+                $item = array_merge($item, $detail);
+                $family = json_decode($v->family, true);
+                $familys = [];
+                foreach ($family as $val){
+                    switch ($val['political_affiliation']) {
+                        case '01':
+                            $political_affiliation = '中共党员';
+                            break;
+                        case '02':
+                            $political_affiliation = '中共预备党员';
+                            break;
+                        case '03':
+                            $political_affiliation = '共青团员';
+                            break;
+                        case '04':
+                            $political_affiliation = '民革党员';
+                            break;
+                        case '05':
+                            $political_affiliation = '民盟盟员';
+                            break;
+                        case '06':
+                            $political_affiliation = '民建会员';
+                            break;
+                        case '07':
+                            $political_affiliation = '民进会员';
+                            break;
+                        case '08':
+                            $political_affiliation = '农工党党员';
+                            break;
+                        case '09':
+                            $political_affiliation = '致公党党员';
+                            break;
+                        case '10':
+                            $political_affiliation = '九三学社社员';
+                            break;
+                        case '11':
+                            $political_affiliation = '台盟盟员';
+                            break;
+                        case '12':
+                            $political_affiliation = '无党派人士';
+                            break;
+                        case '13':
+                            $political_affiliation = '群众';
+                            break;
+                        default:
+                            $political_affiliation = '未知';
+                            break;
+                    }
+                    $familys[] = "称谓:" . $val['relation'] . ";姓名:".$val['realname'] . ';生日:'.$val['birthday'].';政治面貌:'.$political_affiliation.';职业:'.$val['work'];
+                }
+                $item[] = implode("\r\n", $familys);
+                if (in_array('identification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
+                    $identification = json_decode($v->identification, true);
+                    $identifications = [];
+                    foreach ($identification as $val){
+                        if(array_key_exists('path', $val['response'])){
+                            array_push($identifications,"https://www.jucai.gov.cn" . $val['response']['path']);
+                        }
+                    }
+                    array_push($item, implode("\r\n", $identifications));
+                }
+                if (in_array('education_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
+                    $education_certification = json_decode($v->education_certification, true);
+                    $education_certifications = [];
+                    foreach ($education_certification as $val){
+                        if(array_key_exists('path', $val['response'])){
+                            array_push($education_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
+                        }
+                    }
+                    array_push($item, implode("\r\n", $education_certifications));
+                }
+                if (in_array('other_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
+                    $other_certification = json_decode($v->other_certification, true);
+                    $other_certifications = [];
+                    if($other_certification){
+                        foreach ($other_certification as $val){
+                            if(array_key_exists('path', $val['response'])){
+                                array_push($other_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
+                            }
+                        }
+                    }
+
+                    array_push($item, implode("\r\n", $other_certifications));
+                }
+                if (in_array('chengnuoshu', explode(',', $recruit->forms))) {
+                    $chengnuoshu = json_decode($v->chengnuoshu, true);
+                    $chengnuoshu = [];
+                    if($chengnuoshu){
+                        foreach ($chengnuoshu as $val){
+                            if(array_key_exists('path', $val['response'])){
+                                array_push($chengnuoshu,"https://www.jucai.gov.cn" . $val['response']['path']);
+                            }
+                        }
+                    }
+
+                    array_push($item, implode("\r\n", $chengnuoshu));
+                }
+                if (in_array('shixin', explode(',', $recruit->forms))) {
+                    $shixin = json_decode($v->shixin, true);
+                    $shixin = [];
+                    if($shixin){
+                        foreach ($shixin as $val){
+                            if(array_key_exists('path', $val['response'])){
+                                array_push($shixin,"https://www.jucai.gov.cn" . $val['response']['path']);
+                            }
+                        }
+                    }
+
+                    array_push($item, implode("\r\n", $shixin));
+                }
+                switch (intval($v->audit)){
+                    case 1:
+                        $item[] = '审核中';
+                        $item[] = '';
+                        break;
+                    case 2:
+                    case 3:
+                        $log = RecruitAppointLog::where('appoint_id', $v->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
+                        if ($log) {
+                            $log_arr = explode(',',$log->log);
+                            $item[] = $log_arr[0];
+                            $item[] = $log_arr[1];
+                        } else {
+                            $item[] = '';
+                            $item[] = '';
+                        }
+                        break;
+                    default:
+                        $item[] = '';
+                        $item[] = '';
+                        break;
+                }
+
+
+                if(empty($v->word_url)){
+                    $item[] = "暂无";
+                }else{
+                    $item[] = "https://www.jucai.gov.cn/" . $v->word_url;
+                }
+
+                array_push($data,$item);
+            }
+
+            foreach($data as $k => $v){
+                for ($i = 0;$i<count($v);$i++){
+                    if($i == 18 || $i == 19 || $i == 22){
+                        $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
+                    }else{
+                        $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
+                    }
+                }
+                $row++;
+            }
+            $file_name = $recruit->name . date("Y-m-d",time());
+            header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+            header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
+            header('Cache-Control: max-age=0');
+            // If you're serving to IE 9, then the following may be needed
+            header('Cache-Control: max-age=1');
+            // If you're serving to IE over SSL, then the following may be needed
+            header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
+            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
+            header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
+            header('Pragma: public'); // HTTP/1.0
+            $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
+            $writer->save('php://output');
+
+        }else{
+            return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
+        }
+
+    }
 
 }

+ 1 - 0
app/Admin/routes.php

@@ -482,6 +482,7 @@ Route::group([
         $router->get('ajax_audit', 'SpecialController@ajax_audit')->name('special.ajax_audit');
         $router->get('show_log', 'SpecialController@showLog')->name('special.show_log');
         $router->post('appoint_audit', 'SpecialController@appoint_audit')->name('special.appoint_audit');
+        $router->get('out_excel', 'SpecialController@out_excel')->name('special.out_excel');
 
     });