|
@@ -1487,6 +1487,157 @@ class RecruitController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成word版简历
|
|
|
+ * @param null $data
|
|
|
+ * @throws \PhpOffice\PhpWord\Exception\CopyFileException
|
|
|
+ * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
|
|
+ * @throws \PhpOffice\PhpWord\Exception\Exception
|
|
|
+ */
|
|
|
+ public function fetch_word_internship($data = null)
|
|
|
+ {
|
|
|
+ if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
|
|
|
+ $recruit = Recruit::where('id',$data['recruit_id'])->first();
|
|
|
+ $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
|
|
|
+
|
|
|
+ $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example_internship.docx');
|
|
|
+ //通过setValue 方法给模板赋值
|
|
|
+ $templateProcessor->setValue('title', $recruit->name);
|
|
|
+ $templateProcessor->setValue('realname', $appoint->realname);
|
|
|
+ $templateProcessor->setValue('realname', $appoint->realname);
|
|
|
+ $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
|
|
|
+ $templateProcessor->setValue('birthday', $appoint->birthday);
|
|
|
+ $templateProcessor->setValue('nation', $appoint->nation);
|
|
|
+ $templateProcessor->setValue('native_place', $appoint->native_place);
|
|
|
+ $templateProcessor->setValue('card', $appoint->card);
|
|
|
+ switch ($appoint->political_affiliation){
|
|
|
+ case '01':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '中共党员');
|
|
|
+ break;
|
|
|
+ case '02':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '中共预备党员');
|
|
|
+ break;
|
|
|
+ case '03':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '共青团员');
|
|
|
+ break;
|
|
|
+ case '04':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '民革党员');
|
|
|
+ break;
|
|
|
+ case '05':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '民盟盟员');
|
|
|
+ break;
|
|
|
+ case '06':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '民建会员');
|
|
|
+ break;
|
|
|
+ case '07':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '民进会员');
|
|
|
+ break;
|
|
|
+ case '08':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '农工党党员');
|
|
|
+ break;
|
|
|
+ case '09':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '致公党党员');
|
|
|
+ break;
|
|
|
+ case '10':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '九三学社社员');
|
|
|
+ break;
|
|
|
+ case '11':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '台盟盟员');
|
|
|
+ break;
|
|
|
+ case '12':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '无党派人士');
|
|
|
+ break;
|
|
|
+ case '13':
|
|
|
+ $templateProcessor->setValue('political_affiliation', '群众');
|
|
|
+ }
|
|
|
+ $templateProcessor->setValue('join_time', $appoint->join_time);
|
|
|
+ $templateProcessor->setValue('house_register', $appoint->house_register);
|
|
|
+ $templateProcessor->setValue('education', $appoint->education);
|
|
|
+ $templateProcessor->setValue('school', $appoint->school);
|
|
|
+ $templateProcessor->setValue('pro', $appoint->pro);
|
|
|
+ $templateProcessor->setValue('adjust', $appoint->adjust == 0 ? '否' : '是');
|
|
|
+ $templateProcessor->setValue('mobile', $appoint->mobile);
|
|
|
+ $templateProcessor->setValue('email', $appoint->email);
|
|
|
+ $templateProcessor->setValue('address', $appoint->address);
|
|
|
+ $post_data = RecruitPost::where('id',$appoint->post_id)->first();
|
|
|
+ $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
|
|
|
+ $templateProcessor->setValue('concat_name', $appoint->concat_name);
|
|
|
+ $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
|
|
|
+ $forms = explode(',', $recruit->forms);
|
|
|
+ $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
|
|
|
+ $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
|
|
|
+ $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
|
|
|
+ $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
|
|
|
+ $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
|
|
|
+
|
|
|
+ if($family = json_decode($appoint->family,true)){
|
|
|
+ $templateProcessor->cloneRow('family_relation',count($family));
|
|
|
+ $i = 1;
|
|
|
+ foreach ($family as $k => $v){
|
|
|
+ $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
|
|
|
+ $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
|
|
|
+ $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
|
|
|
+ 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 = '群众';
|
|
|
+ }
|
|
|
+ $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
|
|
|
+ $templateProcessor->setValue('family_work#'.$i, $v['work']);
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
|
|
|
+
|
|
|
+ $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
|
|
|
+
|
|
|
+ if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
|
|
|
+ Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
|
|
|
+ }
|
|
|
+
|
|
|
+ $word_url = "/{$filename}.docx";
|
|
|
+ $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
|
|
|
+ $appoint->save();
|
|
|
+ $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
|
|
|
+ return "/storage/recruit/word/" . $recruit->name_en .$word_url;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 将报名资料导出成ZIP压缩包
|
|
|
* @param Request $request
|
|
@@ -2252,6 +2403,11 @@ class RecruitController extends Controller
|
|
|
|
|
|
public function test(Request $request){
|
|
|
|
|
|
+ $list = RecruitAppointInfo::where('recruit_id',7)->where('audit',3)->get();
|
|
|
+
|
|
|
+ foreach ($list as $k => $v){
|
|
|
+ $this->fetch_word_internship(['recruit_id'=>7,'appoint_id'=>$v->id]);
|
|
|
+ }
|
|
|
|
|
|
// $ids = [6,7,121,47,181,66,108,138,21,212,177,130,114,27,63,31,51];
|
|
|
// $data = RecruitAppointInfo::whereIn('id',$ids)->get();
|