RecruitController.php 128 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651
  1. <?php
  2. namespace App\Admin\Controllers\Recruit;
  3. use App\Http\Controllers\Controller;
  4. use App\Admin\Extensions\Form\ValidateForm;
  5. use App\Models\Member;
  6. use App\Models\Pms;
  7. use App\Models\Recruit;
  8. use App\Models\RecruitAppointDetail;
  9. use App\Models\RecruitAppointExpandSpecial;
  10. use App\Models\RecruitPost;
  11. use App\Models\RecruitAppointInfo;
  12. use App\Models\RecruitSubjoin;
  13. use App\Models\RecruitAppointLog;
  14. use App\Models\RecruitTicketField;
  15. use App\Models\RecruitSupplement;
  16. use dir\Dir;
  17. use Encore\Admin\Grid;
  18. use Encore\Admin\Form;
  19. use Encore\Admin\Show;
  20. use Encore\Admin\Layout\Content;
  21. use Encore\Admin\Facades\Admin;
  22. use Encore\Admin\Auth\Permission;
  23. use Illuminate\Http\Request;
  24. use Illuminate\Support\Facades\DB;
  25. use Illuminate\Support\Facades\Storage;
  26. use App\Models\Admin\AdminUser;
  27. use PhpOffice\PhpWord\TemplateProcessor;
  28. use Chumper\Zipper\Zipper;
  29. use App\Models\RecruitTicket;
  30. use App\Services\Common\SmsService;
  31. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  32. use PhpOffice\PhpSpreadsheet\IOFactory;
  33. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  34. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  35. use PhpOffice\PhpWord\Settings;
  36. use App\Jobs\TicketJob;
  37. class RecruitController extends Controller
  38. {
  39. private $smsService;
  40. public function __construct(SmsService $smsService)
  41. {
  42. $this->smsService = $smsService;
  43. }
  44. /**
  45. * 招考报名首页
  46. * @param Content $content
  47. * @return Content
  48. */
  49. public function index(Content $content)
  50. {
  51. return $content
  52. ->header('招考报名管理')
  53. ->description('')
  54. ->body($this->grid());
  55. }
  56. /**
  57. * 新增招考报名表单页.
  58. *
  59. * @param Content $content
  60. * @return Content
  61. */
  62. public function create(Content $content)
  63. {
  64. Permission::check('recruit_manager_create');
  65. return $content
  66. ->header('新增招聘场次')
  67. ->description('新增')
  68. ->body(view('admin.recruit.index')->with(['grid' => $this->form()->render(), 'id' => '0']));
  69. }
  70. /**
  71. * Edit interface.
  72. *
  73. * @param mixed $id
  74. * @param Content $content
  75. * @return Content
  76. */
  77. public function edit($id, Content $content)
  78. {
  79. Permission::check('recruit_manager_edit');
  80. $grid = $this->form()->edit($id)->render();
  81. return $content
  82. ->header('招考管理')
  83. ->description('编辑')
  84. ->body(view('admin.recruit.index')->with(['grid' => $grid, 'id' => $id]));
  85. }
  86. /**
  87. * Show interface.
  88. *
  89. * @param mixed $id
  90. * @param Content $content
  91. * @return Content
  92. */
  93. public function show($id, Content $content)
  94. {
  95. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/index');
  96. }
  97. public function detail($id)
  98. {
  99. $show = new Show(Recruit::findOrFail($id));
  100. // $recruit = Recruit::findOrFail($id);
  101. $show->title('标题');
  102. $show->created_at('创建时间');
  103. return $show;
  104. }
  105. /**
  106. * 获得招考场次的岗位
  107. * @param Request $request
  108. * @return \Illuminate\Http\JsonResponse
  109. */
  110. public function getRecruitPost(Request $request)
  111. {
  112. $id = $request->id;
  113. $recruit = Recruit::find($id);
  114. $post = RecruitPost::where('recruit_id', $id)->get();
  115. return response()->json(['post' => $post, 'recruit' => $recruit], '200');
  116. }
  117. /**
  118. * Make a grid builder.
  119. *
  120. * @return Grid
  121. */
  122. protected function grid()
  123. {
  124. $grid = new Grid(new Recruit);
  125. $grid->model()->orderBy('created_at', 'DESC');
  126. $grid->model()->paginate(20);
  127. if (Admin::user()->can('recruit_manager_create')) {
  128. $grid->disableCreateButton(false);
  129. }
  130. $grid->perPages([10, 20, 30, 40, 50, 100]);
  131. $grid->id('ID');
  132. $grid->name('招考场次名称');
  133. $grid->column('current','当前阶段')->display(function ($current) {
  134. switch ($current){
  135. case '1':
  136. return '报名';
  137. break;
  138. case '2':
  139. return '审核';
  140. break;
  141. case '3':
  142. return '笔试';
  143. break;
  144. case '4':
  145. return '上机测试';
  146. break;
  147. case '5':
  148. return '面试';
  149. break;
  150. case '6':
  151. return '复试';
  152. break;
  153. case '7':
  154. return '体检';
  155. break;
  156. case '8':
  157. return '政审';
  158. break;
  159. case '9':
  160. return '公示';
  161. break;
  162. case '0':
  163. return '已结束';
  164. break;
  165. }
  166. });
  167. $grid->column('status','状态')->display(function ($status) {
  168. return $status ? '显示' : '隐藏';
  169. });
  170. $grid->filter(function ($filter) {
  171. $filter->disableIdFilter();
  172. $filter->where(function ($query) {
  173. $query->where('simple', '=', "{$this->input}");
  174. }, '类型', 'simple')->radio([0 => '招考',1 => '招聘']);
  175. });
  176. $grid->created_at('创建时间');
  177. $grid->actions(function ($actions) {
  178. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  179. $actions->disableEdit(false);
  180. $actions->disableDelete(false);
  181. $actions->disableView();
  182. });
  183. return $grid;
  184. }
  185. /**
  186. * 新增/修改招考场次的表单
  187. *
  188. * @return Form
  189. */
  190. protected function form()
  191. {
  192. $form = new ValidateForm(new Recruit);
  193. $form->tab('基础信息', function ($form) {
  194. $form->text('name', '招考场次名称')->rules('required|between:4,61', [
  195. 'required' => '请填写招考场次名称',
  196. 'between' => '招考场次名称长度为2~30个字符'
  197. ])->setWidth(5)->setMustMark();
  198. $form->text('company', '招聘主体')->rules('required|between:4,61', [
  199. 'required' => '请填写招聘主体',
  200. 'between' => '招聘主体长度为2~30个字符'
  201. ])->setWidth(5)->setMustMark();
  202. $form->text('name_en', '英文标识')->setWidth(5)->help('同一个招聘单位,发布的招聘场次若不在同一天,允许一样,若为空则自动生成');
  203. $form->image('small_img', '缩略图')->uniqueName()->setWidth(3);
  204. $form->radio('simple', '类型')->options([0 => '招聘', 1 => '招考'])->default(0)->setMustMark();
  205. $form->switch('status', '状态')->default(1)->setMustMark();
  206. $form->switch('show_report', '显示报名人数')->default(0)->setMustMark();
  207. $form->radio('current', '当前进展')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示',0 => '已结束'])->default(1)->setMustMark();
  208. $form->checkbox('step', '招考流程')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示'])->default([1, 2])->setMustMark();
  209. $form->datetimeRange('apply_start', 'apply_end', '报名日期')->rules('required', array('required' => '报名日期必须设置'))->setMustMark();
  210. $form->datetimeRange('audit_start', 'audit_end', '审核日期');
  211. $form->datetimeRange('preliminary_start', 'preliminary_end', '笔试时间');
  212. $form->datetimeRange('computer_start', 'computer_end', '上机时间');
  213. $form->datetimeRange('interview_start', 'interview_end', '面试时间');
  214. $form->datetimeRange('reexamine_start', 'reexamine_end', '复试时间');
  215. $form->datetimeRange('health_start', 'health_end', '体检时间');
  216. $form->datetimeRange('political_start', 'political_end', '政审时间');
  217. $form->datetimeRange('publicity_start', 'publicity_end', '公示时间');
  218. $form->editor('introduction', '招考正文')->rules('required', array('required' => '招考正文不能为空。'))->setMustMark();
  219. $form->text('contact', '联系人');
  220. $form->text('phone', '联系电话');
  221. $form->text('host_address', '联系地址');
  222. //$form->switch('predetermined_status', '是否允许报名')->states($display_option)->default(1)->setMustMark();
  223. $form->number('ordid', '排序')->default(0);
  224. $form->multipleFile('addFile', '附件')->move('storage/app/public/recruit/' . time());
  225. })->tab('报名表单与条件', function ($form) {
  226. $form->checkbox('forms', '报名表单模块')->options(['basic' => '基础信息模块','expand_special' => '扩展模块-加分','detail' => '详情介绍模块','identification' => '身份证明上传模块','education_certification' => '学历证明上传模块','other_certification' => '其他证明上传模块', 'remark' => '备注模块','internship' => '实习专场'])->default(['basic'])->setMustMark();
  227. $form->text('limit_times', '报名次数限制')->rules('required|regex:/^\d+$/', [
  228. 'required' => '报名限制次数必须填写',
  229. 'regex' => '次数必须为数字'
  230. ])->default(1)->help('同一个场次允许同时报名几个岗位,直接输入数字即可');
  231. $form->text('post_times', '审核次数限制')->rules('required|regex:/^\d+$/', [
  232. 'required' => '审核限制次数必须填写',
  233. 'regex' => '次数必须为数字'
  234. ])->default(1)->help('允许提交审核的次数,直接输入数字即可');
  235. $form->datetimeRange('supplement_start', 'supplement_end', '材料补登时间');
  236. $form->radio('pay_switch', '缴费报名')->options([0 => '否', 1 => '是'])->default(0);
  237. })->tab('笔试', function ($form) {
  238. $form->radio('pen_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  239. $form->text('pen_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  240. $form->listbox('pen_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('pen'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  241. $form->switch('pen_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  242. $form->switch('pen_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  243. $form->datetimeRange('pen_health_start', 'pen_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  244. })->tab('上机', function ($form) {
  245. $form->radio('computer_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  246. $form->text('computer_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  247. $form->listbox('computer_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('computer'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  248. $form->switch('computer_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  249. $form->switch('computer_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  250. $form->datetimeRange('computer_health_start', 'computer_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  251. })->tab('面试', function ($form) {
  252. $form->radio('face_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  253. $form->text('face_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  254. $form->listbox('face_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('face'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  255. $form->switch('face_epidemic', '两码上传')->help("下列依赖两码设置,须此项打开才可生效")->default(0)->setMustMark();
  256. $form->switch('face_health', '健康状态')->help('当两码上传打开且该选项打开时,打印准考证必须通过两码审核')->default(0)->setMustMark();
  257. $form->datetimeRange('face_health_start', 'face_health_end', '两码时间')->help("设置该时间后,仅在该时间段内上传该时段内的两码截图才可以");
  258. })->tab('复试', function ($form) {
  259. $form->radio('reexamine_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信', 3 => '模板'])->default(-1);
  260. $form->text('reexamine_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识,当类型为模板时,输入模板ID');
  261. $form->listbox('reexamine_field', '模板字段')->options(RecruitTicketField::ticketFieldData('reexamine'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  262. });
  263. return $form;
  264. }
  265. /**
  266. * Make a form builder.
  267. *
  268. * @return Form
  269. */
  270. public function store(Request $request)
  271. {
  272. $verify = $this->form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  273. $postCode = $request->input('postcode', []);
  274. $postName = $request->input('postname', []);
  275. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  276. return admin_toastr('请填写招考岗位', 'error');
  277. }
  278. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  279. return admin_toastr('请填写招考岗位名称', 'error');
  280. }
  281. $data = [];
  282. $data['name'] = $verify['name'];
  283. $data['company'] = $verify['company'];
  284. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  285. if(array_key_exists('small_img',$verify)){
  286. $data['small_img'] = $verify['small_img'];
  287. }else{
  288. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  289. }
  290. $data['status'] = $verify['status'];
  291. $data['show_report'] = $verify['show_report'];
  292. $data['current'] = $verify['current'];
  293. $data['step'] = implode(',',array_filter($verify['step']));
  294. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  295. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  296. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  297. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  298. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  299. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  300. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  301. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  302. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  303. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  304. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  305. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  306. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  307. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  308. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  309. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  310. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  311. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  312. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  313. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  314. $data['introduction'] = $verify['introduction'];
  315. $data['host_address'] = $verify['host_address'];
  316. $data['contact'] = $verify['contact'];
  317. $data['phone'] = $verify['phone'];
  318. $data['ordid'] = $verify['ordid'];
  319. $data['limit_times'] = $verify['limit_times'];
  320. $data['post_times'] = $verify['post_times'];
  321. $data['pay_switch'] = $verify['pay_switch'];
  322. $data['forms'] = implode(',',array_filter($verify['forms']));
  323. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  324. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  325. $data['pen_ticket_status'] = 0;
  326. $data['pen_epidemic'] = $verify['pen_epidemic'];
  327. $data['pen_health'] = $verify['pen_health'];
  328. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  329. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  330. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  331. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  332. $data['computer_ticket_status'] = 0;
  333. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  334. $data['face_ticket_type'] = $verify['face_ticket_type'];
  335. $data['face_ticket_content'] = $verify['face_ticket_content'];
  336. $data['face_ticket_status'] = 0;
  337. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  338. $fileCharater = $request->input('addFile');
  339. DB::beginTransaction();//检查数据库事务
  340. try {
  341. $recruit = Recruit::create($data);
  342. $recruit_id = $recruit->id;
  343. //添加招聘岗位
  344. $postcode_array = $request->postcode;
  345. $postname_array = $request->postname;
  346. $postnumber_array = $request->postnumber;
  347. $limit_array = $request->postlimit;
  348. $countnum = count($postcode_array);
  349. for ($i = 0; $i < $countnum; $i++) {
  350. $data = array();
  351. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  352. $data['code'] = $postcode_array[$i];
  353. $data['name'] = $postname_array[$i];
  354. $data['number'] = $postnumber_array[$i];
  355. $data['limit'] = $limit_array[$i];
  356. $data['status'] = 1;
  357. $data['recruit_id'] = $recruit_id;
  358. RecruitPost::create($data);
  359. }
  360. }
  361. if (!empty($fileCharater)) {
  362. foreach ($fileCharater as $f => $fv) {
  363. $picpath = 'recruit/' . date('Ymd', time()) . '/';
  364. //获取文件的扩展名
  365. $ext = $fv->getClientOriginalExtension();
  366. //获取文件的绝对路径
  367. $path = $fv->getRealPath();
  368. //定义文件名
  369. $filename = time() . rand(100, 999) . '.' . $ext;
  370. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  371. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  372. $data = $picpath . $filename;
  373. $create_arr = [
  374. 'recruit_id' => $recruit_id,
  375. 'subjoin_name' => $fv->getClientOriginalName(),
  376. 'subjoin_path' => $data,
  377. 'subjoin_addtime' => time()
  378. ];
  379. RecruitSubjoin::create($create_arr);
  380. }
  381. }
  382. DB::commit();//检查数据库事务
  383. } catch (\Exception $e) {
  384. DB::rollback();
  385. return admin_toastr($e->getMessage(), 'error');
  386. }
  387. }
  388. /**
  389. * 更新报名场次信息
  390. * @param $id
  391. * @param Request $request
  392. */
  393. public function update($id, Request $request)
  394. {
  395. $verify = $this->Form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  396. $postCode = $request->input('postcode', []);
  397. $postName = $request->input('postname', []);
  398. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  399. return admin_toastr('请填写招考岗位', 'error');
  400. }
  401. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  402. return admin_toastr('请填写招考岗位名称', 'error');
  403. }
  404. $recruit_id = $id;
  405. $data = [];
  406. $data['name'] = $verify['name'];
  407. $data['company'] = $verify['company'];
  408. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  409. if(array_key_exists('small_img',$verify)){
  410. $data['small_img'] = $verify['small_img'];
  411. }else{
  412. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  413. }
  414. $data['status'] = $verify['status'];
  415. $data['show_report'] = $verify['show_report'];
  416. $data['current'] = $verify['current'];
  417. $data['step'] = implode(',',array_filter($verify['step']));
  418. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  419. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  420. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  421. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  422. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  423. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  424. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  425. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  426. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  427. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  428. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  429. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  430. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  431. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  432. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  433. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  434. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  435. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  436. $data['supplement_start'] = $verify['supplement_start'] ? $verify['supplement_start'] : null;
  437. $data['supplement_end'] = $verify['supplement_end'] ? $verify['supplement_end'] : null;
  438. $data['introduction'] = $verify['introduction'];
  439. $data['host_address'] = $verify['host_address'];
  440. $data['contact'] = $verify['contact'];
  441. $data['phone'] = $verify['phone'];
  442. $data['ordid'] = $verify['ordid'];
  443. $data['limit_times'] = $verify['limit_times'];
  444. $data['post_times'] = $verify['post_times'];
  445. $data['pay_switch'] = $verify['pay_switch'];
  446. $data['forms'] = implode(',',array_filter($verify['forms']));
  447. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  448. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  449. $data['pen_ticket_status'] = 0;
  450. $data['pen_ticket_field'] = implode(',',$verify['pen_ticket_field']);
  451. $data['pen_epidemic'] = $verify['pen_epidemic'];
  452. $data['pen_health'] = $verify['pen_health'];
  453. $data['pen_health_start'] = $verify['pen_health_start'] ? $verify['pen_health_start'] : null;
  454. $data['pen_health_end'] = $verify['pen_health_end'] ? $verify['pen_health_end'] : null;
  455. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  456. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  457. $data['computer_ticket_status'] = 0;
  458. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  459. $data['face_ticket_type'] = $verify['face_ticket_type'];
  460. $data['face_ticket_content'] = $verify['face_ticket_content'];
  461. $data['face_ticket_status'] = 0;
  462. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  463. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  464. $fileCharater = $request->input('addFile');
  465. DB::beginTransaction();//检查数据库事务
  466. try {
  467. $res = Recruit::where('id', $recruit_id)->update($data);
  468. $postcode_array = $request->postcode;
  469. $postname_array = $request->postname;
  470. $postnumber_array = $request->postnumber;
  471. $limit_array = $request->postlimit;
  472. $postid_arr = $request->postid_arr;
  473. $countnum = count($postcode_array);
  474. if ($countnum > 0) {
  475. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  476. if (count($postid_arr) == 0) {//没有提交岗位代表删除岗位
  477. RecruitPost::where('recruit_id', $recruit_id)->delete();
  478. } else {
  479. foreach ($ids as $key => $value) {
  480. if (!in_array($value, $postid_arr)) {
  481. $post_is_create = RecruitAppointInfo::where('post_id', $value)->first();
  482. if (empty($post_is_create)) {
  483. //有报名信息的岗位不能删除
  484. RecruitPost::destroy($value);
  485. }
  486. }
  487. }
  488. }
  489. for ($i = 0; $i < $countnum; $i++) {
  490. $data = array();
  491. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  492. if (isset($postid_arr[$i])) {
  493. $post_id = $postid_arr[$i];
  494. $data['code'] = $postcode_array[$i];
  495. $data['name'] = $postname_array[$i];
  496. $data['number'] = $postnumber_array[$i];
  497. $data['limit'] = $limit_array[$i];
  498. $data['recruit_id'] = $recruit_id;
  499. RecruitPost::where('id', $post_id)->update($data);
  500. } else {
  501. $data['code'] = $postcode_array[$i];
  502. $data['name'] = $postname_array[$i];
  503. $data['number'] = $postnumber_array[$i];
  504. $data['limit'] = $limit_array[$i];
  505. $data['recruit_id'] = $recruit_id;
  506. RecruitPost::create($data);
  507. }
  508. }
  509. }
  510. } else {
  511. RecruitPost::where('recruit_id', $recruit_id)->delete();
  512. }
  513. $fileCharater = $request->file('addFile');
  514. if (!empty($fileCharater)) {
  515. RecruitSubjoin::where('recruit_id', $recruit_id)->delete();
  516. foreach ($fileCharater as $f => $fv) {
  517. $picpath = 'zhaokaopic/' . date('Ymd', time()) . '/';
  518. //获取文件的扩展名
  519. $ext = $fv->getClientOriginalExtension();
  520. //获取文件的绝对路径
  521. $path = $fv->getRealPath();
  522. //定义文件名
  523. $filename = time() . rand(100, 999) . '.' . $ext;
  524. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  525. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  526. $data = $picpath . $filename;
  527. $create_arr = [
  528. 'recruit_id' => $recruit_id,
  529. 'subjoin_name' => $fv->getClientOriginalName(),
  530. 'subjoin_path' => $data,
  531. 'subjoin_addtime' => time()
  532. ];
  533. RecruitSubjoin::create($create_arr);
  534. }
  535. }
  536. DB::commit();
  537. return admin_toastr('操作成功!', 'success');
  538. } catch (\Exception $e) {
  539. DB::rollback();
  540. return admin_toastr($e->getMessage(), 'error');
  541. }
  542. }
  543. /**
  544. * 删掉指定招考场次
  545. * @param $id
  546. */
  547. public function destroy($id)
  548. {
  549. Permission::check('recruit_manager_del');
  550. $info = Recruit::find($id);
  551. if($info){
  552. if($info->delete()){
  553. //RecruitAppointInfo::where('recruit_id', $id)->delete(); //todo保留
  554. return response()->json(['status' => 1, 'message' => '删除成功!'], '200');
  555. }else{
  556. return response()->json(['status' => 0, 'message' => '删除失败!'], '200');
  557. }
  558. }else{
  559. return response()->json(['status' => 0, 'message' => '找不到记录!'], '200');
  560. }
  561. //Recruit::find($id)->delete();
  562. }
  563. /**
  564. * 报名管理
  565. * @param Content $content
  566. * @param Request $request
  567. * @return Content|\Illuminate\Http\RedirectResponse
  568. */
  569. public function appointList(Content $content, Request $request)
  570. {
  571. Permission::check('recruit_appoint_list');
  572. $id = $request->id;
  573. $recruit = Recruit::find($id);
  574. if (empty($recruit)) {
  575. return back();
  576. }
  577. $search_data = $request->all();
  578. $where = [];
  579. $where[] = ['audit','>',0];
  580. if (isset($search_data['id']) || session('manage_search_data')['id']) {
  581. if (isset($search_data['page'])) {
  582. if (session('search_data')) {
  583. $where = session('managewhere');
  584. unset($search_data['page']);
  585. $search_data = session('manage_search_data');
  586. }
  587. }
  588. foreach ($search_data as $k => $v) {
  589. if ($k == 'realname') {
  590. $where[] = [$k, 'like', "%$v%"];
  591. } elseif ($k == 'id') {
  592. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  593. } elseif($k == 'print_bs'){
  594. $where[] = ['recruit_ticket.ex_type', '=', 1];
  595. $where[] = ['recruit_ticket.ex_status', '=', $v];
  596. } elseif($k == 'print_js'){
  597. $where[] = ['recruit_ticket.ex_type', '=', 2];
  598. $where[] = ['recruit_ticket.ex_status', '=', $v];
  599. } elseif($k == 'print_ms'){
  600. $where[] = ['recruit_ticket.ex_type', '=', 3];
  601. $where[] = ['recruit_ticket.ex_status', '=', $v];
  602. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  603. $where[] = [$k, '=', $v];
  604. }
  605. }
  606. session(['managewhere' => $where]);
  607. session(['manage_search_data' => $search_data]);
  608. session()->save();
  609. }
  610. $session_data = session('search_data');
  611. if(isset($session_data['perpage'])){
  612. $perpage = $session_data['perpage'];
  613. }else{
  614. $perpage = 20;
  615. }
  616. $list = RecruitAppointInfo::where($where)
  617. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  618. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  619. ->select('recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  620. ->orderBy('recruit_appoint_info.updated_at','desc')
  621. ->paginate($perpage);
  622. foreach ($list as $k => $v){
  623. if($v->sex == 0){
  624. $list[$k]['sex'] = '女';
  625. }else{
  626. $list[$k]['sex'] = '男';
  627. }
  628. switch ($v->political_affiliation){
  629. case '01':
  630. $list[$k]['political_affiliation'] = '中共党员';
  631. break;
  632. case '02':
  633. $list[$k]['political_affiliation'] = '中共预备党员';
  634. break;
  635. case '03':
  636. $list[$k]['political_affiliation'] = '共青团员';
  637. break;
  638. case '04':
  639. $list[$k]['political_affiliation'] = '民革党员';
  640. break;
  641. case '05':
  642. $list[$k]['political_affiliation'] = '民盟盟员';
  643. break;
  644. case '06':
  645. $list[$k]['political_affiliation'] = '民建会员';
  646. break;
  647. case '07':
  648. $list[$k]['political_affiliation'] = '民进会员';
  649. break;
  650. case '08':
  651. $list[$k]['political_affiliation'] = '农工党党员';
  652. break;
  653. case '09':
  654. $list[$k]['political_affiliation'] = '致公党党员';
  655. break;
  656. case '10':
  657. $list[$k]['political_affiliation'] = '九三学社社员';
  658. break;
  659. case '11':
  660. $list[$k]['political_affiliation'] = '台盟盟员';
  661. break;
  662. case '12':
  663. $list[$k]['political_affiliation'] = '无党派人士';
  664. break;
  665. case '13':
  666. $list[$k]['political_affiliation'] = '群众';
  667. break;
  668. }
  669. $list[$k]['pen_print'] = 0;
  670. $list[$k]['computer_print'] = 0;
  671. $list[$k]['face_print'] = 0;
  672. $list[$k]['reexamine_print'] = 0;
  673. $tickets = RecruitTicket::where('appoint_id',$v->id)->get();
  674. if($tickets){
  675. foreach ($tickets as $tk => $tv){
  676. if($tv->ex_type == 1){
  677. $list[$k]['pen_print'] = $tv->ex_status;
  678. }
  679. if($tv->ex_type == 2){
  680. $list[$k]['computer_print'] = $tv->ex_status;
  681. }
  682. if($tv->ex_type == 3){
  683. $list[$k]['face_print'] = $tv->ex_status;
  684. }
  685. if($tv->ex_type == 4){
  686. $list[$k]['reexamine_print'] = $tv->ex_status;
  687. }
  688. }
  689. }
  690. }
  691. $post_data = RecruitPost::where('recruit_id',$id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  692. return $content
  693. ->header('报名管理')
  694. ->description('招考人员信息列表')
  695. ->body(view('admin.recruit.appoint_list')->with([
  696. 'list' => $list,
  697. 'search_data' => $search_data,
  698. 'recruit' => $recruit,
  699. 'post' => $post_data
  700. ]));
  701. }
  702. /**
  703. * 查看报名详细信息
  704. * @param Request $request
  705. * @return \Illuminate\Http\JsonResponse
  706. * @throws \Throwable
  707. */
  708. public function getUserinfo(Request $request)
  709. {
  710. Permission::check('recruit_getUserinfo');
  711. $id = $request->id;
  712. $data = RecruitAppointInfo::where('recruit_appoint_info.id',$id)
  713. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  714. ->join('recruit_appoint_expand_special', 'recruit_appoint_info.id', '=', 'recruit_appoint_expand_special.recruit_appoint_id', 'left')
  715. ->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left')
  716. ->select('recruit_appoint_info.*', 'recruit_post.name', 'recruit_post.code', 'recruit_appoint_detail.train', 'recruit_appoint_detail.rewards_and_punishments', 'recruit_appoint_detail.introduce', 'recruit_appoint_expand_special.point_apply', 'recruit_appoint_expand_special.condition', 'recruit_appoint_expand_special.material')
  717. ->first();
  718. $recruit = Recruit::where('id',$data->recruit_id)->first();
  719. $recruit->forms = explode(',', $recruit->forms);
  720. $data->family = json_decode($data->family);
  721. if ($data->family) {
  722. foreach ($data->family as $k => $v) {
  723. $v->political_affiliation = RecruitAppointInfo::$political_affiliation[$v->political_affiliation];
  724. }
  725. }
  726. //layer相册层
  727. $photos = [
  728. 'material'=>[],
  729. 'identification'=>[],
  730. 'education_certification'=>[],
  731. 'other_certification'=>[],
  732. ];
  733. if(in_array('expand_special',$recruit->forms)){
  734. if(json_decode($data->material)){
  735. $data->material = json_decode($data->material);
  736. $photo_data = [];
  737. foreach ($data->material as $k => $v) {
  738. if($v->status){
  739. $photo_data[] = [
  740. 'alt' => $v->name,
  741. 'pid' => $v->uid,
  742. 'src' => $v->response->path,
  743. ];
  744. }
  745. }
  746. $photos['material'] = [
  747. 'title' => '申请加分佐证材料',
  748. 'id' => 1,
  749. 'start' => 0,
  750. 'data' =>$photo_data
  751. ];
  752. }else{
  753. $data->material = [];
  754. }
  755. }
  756. if(in_array('identification',$recruit->forms) || in_array('internship',$recruit->forms)){
  757. if(json_decode($data->identification)){
  758. $data->identification = json_decode($data->identification);
  759. $photo_data = [];
  760. foreach ($data->identification as $k => $v) {
  761. if($v->status){
  762. $photo_data[] = [
  763. 'alt' => $v->name,
  764. 'pid' => $v->uid,
  765. 'src' => $v->response->path,
  766. ];
  767. }
  768. }
  769. $photos['identification'] = [
  770. 'title' => '身份证明',
  771. 'id' => 1,
  772. 'start' => 0,
  773. 'data' =>$photo_data
  774. ];
  775. }else{
  776. $data->identification = [];
  777. }
  778. }
  779. if(in_array('education_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  780. if(json_decode($data->education_certification)){
  781. $data->education_certification = json_decode($data->education_certification);
  782. $photo_data = [];
  783. foreach ($data->education_certification as $k => $v) {
  784. if($v->status){
  785. $photo_data[] = [
  786. 'alt' => $v->name,
  787. 'pid' => $v->uid,
  788. 'src' => $v->response->path,
  789. ];
  790. }
  791. }
  792. $photos['education_certification'] = [
  793. 'title' => '学历证明',
  794. 'id' => 1,
  795. 'start' => 0,
  796. 'data' =>$photo_data
  797. ];
  798. }else{
  799. $data->education_certification = [];
  800. }
  801. }
  802. if(in_array('other_certification',$recruit->forms) || in_array('internship',$recruit->forms)){
  803. if(json_decode($data->other_certification)){
  804. $data->other_certification = json_decode($data->other_certification);
  805. $photo_data = [];
  806. foreach ($data->other_certification as $k => $v) {
  807. if($v->status){
  808. $photo_data[] = [
  809. 'alt' => $v->name,
  810. 'pid' => $v->uid,
  811. 'src' => $v->response->path,
  812. ];
  813. }
  814. }
  815. $photos['other_certification'] = [
  816. 'title' => '其他证明',
  817. 'id' => 1,
  818. 'start' => 0,
  819. 'data' =>$photo_data
  820. ];
  821. }else{
  822. $data->other_certification = [];
  823. }
  824. }
  825. $html = view('admin.recruit.manageajax_userinfo')->with(['appointinfo' => $data,'recruit' => $recruit,'photos'=>$photos])->render();
  826. return response()->json(['code' => 1, 'data' => $html]);
  827. }
  828. /**
  829. * 第一阶段(报名审核)
  830. * @param Request $request
  831. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  832. * @throws \Throwable
  833. */
  834. public function ajax_audit(Request $request)
  835. {
  836. Permission::check('recruit_ajax_audit');
  837. $ids = $request->ids;
  838. $view_data['ids'] = $ids;
  839. return response(['data' => view('admin.recruit.ajax_audit')->with($view_data)->render(), 'status' => 1], '200');
  840. }
  841. /**
  842. * 材料补登审核
  843. * @param Request $request
  844. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  845. * @throws \Throwable
  846. */
  847. public function ajax_supplement(Request $request)
  848. {
  849. Permission::check('recruit_ajax_supplement');
  850. $ids = $request->ids;
  851. $view_data['ids'] = $ids;
  852. $info = RecruitSupplement::where('appoint_id',$ids)->first();
  853. if(!$info){
  854. $view_data['switch'] = 0;
  855. }else{
  856. $view_data['switch'] = 1;
  857. $photos = [
  858. 'identification'=>[],
  859. 'household_register' => [],
  860. 'education_certification'=>[],
  861. 'family_planning'=>[],
  862. 'manage' => []
  863. ];
  864. $info->identification = json_decode($info->identification);
  865. $photo_data = [];
  866. foreach ($info->identification as $k => $v) {
  867. if($v->status){
  868. $photo_data[] = [
  869. 'alt' => $v->name,
  870. 'pid' => $v->uid,
  871. 'src' => $v->response->path,
  872. ];
  873. }
  874. }
  875. $photos['identification'] = [
  876. 'title' => '身份证明',
  877. 'id' => 1,
  878. 'start' => 0,
  879. 'data' =>$photo_data
  880. ];
  881. $info->household_register = json_decode($info->household_register);
  882. $photo_data = [];
  883. foreach ($info->household_register as $k => $v) {
  884. if($v->status){
  885. $photo_data[] = [
  886. 'alt' => $v->name,
  887. 'pid' => $v->uid,
  888. 'src' => $v->response->path,
  889. ];
  890. }
  891. }
  892. $photos['household_register'] = [
  893. 'title' => '户口簿',
  894. 'id' => 1,
  895. 'start' => 0,
  896. 'data' =>$photo_data
  897. ];
  898. $info->education_certification = json_decode($info->education_certification);
  899. $photo_data = [];
  900. foreach ($info->education_certification as $k => $v) {
  901. if($v->status){
  902. $photo_data[] = [
  903. 'alt' => $v->name,
  904. 'pid' => $v->uid,
  905. 'src' => $v->response->path,
  906. ];
  907. }
  908. }
  909. $photos['education_certification'] = [
  910. 'title' => '教育证明',
  911. 'id' => 1,
  912. 'start' => 0,
  913. 'data' =>$photo_data
  914. ];
  915. // $info->family_planning = json_decode($info->family_planning);
  916. // $photo_data = [];
  917. // foreach ($info->family_planning as $k => $v) {
  918. // if($v->status){
  919. // $photo_data[] = [
  920. // 'alt' => $v->name,
  921. // 'pid' => $v->uid,
  922. // 'src' => $v->response->path,
  923. // ];
  924. // }
  925. // }
  926. // $photos['family_planning'] = [
  927. // 'title' => '计生证明',
  928. // 'id' => 1,
  929. // 'start' => 0,
  930. // 'data' =>$photo_data
  931. // ];
  932. $info->manage = json_decode($info->manage);
  933. $photo_data = [];
  934. foreach ($info->manage as $k => $v) {
  935. if($v->status){
  936. $photo_data[] = [
  937. 'alt' => $v->name,
  938. 'pid' => $v->uid,
  939. 'src' => $v->response->path,
  940. ];
  941. }
  942. }
  943. $photos['manage'] = [
  944. 'title' => '综治证明',
  945. 'id' => 1,
  946. 'start' => 0,
  947. 'data' =>$photo_data
  948. ];
  949. $view_data['info'] = $info;
  950. $view_data['photos'] = $photos;
  951. }
  952. return response(['data' => view('admin.recruit.ajax_supplement')->with($view_data)->render(), 'status' => 1], '200');
  953. }
  954. /**
  955. * 健康信息审核
  956. * @param Request $request
  957. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  958. * @throws \Throwable
  959. */
  960. public function ajax_health(Request $request)
  961. {
  962. Permission::check('recruit_ajax_health');
  963. $ids = $request->ids;
  964. $type = $request->type;
  965. $view_data['ids'] = $ids;
  966. $info = RecruitSupplement::where('appoint_id',$ids)->where("type",$type)->first();
  967. if(!$info){
  968. $view_data['switch'] = 0;
  969. $view_data['photos'] = [];
  970. }else{
  971. $view_data['switch'] = 1;
  972. $photos = [
  973. 'health_code'=>[],
  974. 'trip_code' => []
  975. ];
  976. $info->health_code = json_decode($info->health_code);
  977. $photo_data = [];
  978. if(is_array($info->health_code)){
  979. foreach ($info->health_code as $k => $v) {
  980. if($v->status){
  981. $photo_data[] = [
  982. 'alt' => $v->name,
  983. 'pid' => $v->uid,
  984. 'src' => $v->response->path,
  985. ];
  986. }
  987. }
  988. }
  989. $photos['health_code'] = [
  990. 'title' => '健康码',
  991. 'id' => 1,
  992. 'start' => 0,
  993. 'data' =>$photo_data
  994. ];
  995. $info->trip_code = json_decode($info->trip_code);
  996. $photo_data = [];
  997. if(is_array($info->trip_code)){
  998. foreach ($info->trip_code as $k => $v) {
  999. if($v->status){
  1000. $photo_data[] = [
  1001. 'alt' => $v->name,
  1002. 'pid' => $v->uid,
  1003. 'src' => $v->response->path,
  1004. ];
  1005. }
  1006. }
  1007. }
  1008. $photos['trip_code'] = [
  1009. 'title' => '行程码',
  1010. 'id' => 1,
  1011. 'start' => 0,
  1012. 'data' =>$photo_data
  1013. ];
  1014. $view_data['info'] = $info;
  1015. $view_data['photos'] = $photos;
  1016. }
  1017. return response(['data' => view('admin.recruit.ajax_health')->with($view_data)->render(), 'status' => 1], '200');
  1018. }
  1019. /**
  1020. * 报名记录审核处理
  1021. * @param Request $request
  1022. * @return \Illuminate\Http\JsonResponse
  1023. */
  1024. public function appoint_audit(Request $request)
  1025. {
  1026. $ids = $request->ids;
  1027. if (!is_array($ids)) {
  1028. $ids = explode(",", $ids);
  1029. }
  1030. if (empty($ids)) {
  1031. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1032. }
  1033. $audit = $request->audit;
  1034. $exam_flow_path = $request->exam_flow_path;
  1035. $reason = $request->reason;
  1036. if(empty($audit)){
  1037. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1038. }
  1039. if($audit == '3' && empty($exam_flow_path)){
  1040. return response()->json(['status' => 0, 'msg' => '请选择审核后的考试流程!'], '200');
  1041. }
  1042. if($audit != '3' && empty($reason)){
  1043. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1044. }
  1045. $message = [];
  1046. switch ($audit){
  1047. case '1':
  1048. //撤回至未审核
  1049. foreach ($ids as $k => $v){
  1050. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1051. if(!$appointinfo || intval($appointinfo->audit) === 1){
  1052. continue;
  1053. }
  1054. //设置该报名的各个状态
  1055. $appointinfo_data = [
  1056. 'current' => 1,
  1057. 'audit' => 1,
  1058. 'pen_audit' => -1,
  1059. 'computer_audit' => -1,
  1060. 'face_audit' => -1,
  1061. 'reexamine_audit' => -1,
  1062. 'inspect_audit' => -1,
  1063. 'political_audit' => -1,
  1064. 'employ_audit' => -1
  1065. ];
  1066. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1067. //写日志
  1068. $log = [
  1069. 'type' => 2,
  1070. 'step' => 1,
  1071. 'appoint_id' => $v,
  1072. 'uid' => Admin::user()->id,
  1073. 'log' => '撤回至未审核状态,原因是:'.$reason
  1074. ];
  1075. RecruitAppointLog::create($log);
  1076. $message[$v] = '您此次的报名需要重新审核,原因是:'.$reason;
  1077. }
  1078. break;
  1079. case '2':
  1080. //审核未通过
  1081. foreach ($ids as $k => $v){
  1082. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1083. if(!$appointinfo || intval($appointinfo->audit) === 2){
  1084. continue;
  1085. }
  1086. //设置该报名的各个状态
  1087. $appointinfo_data = [
  1088. 'current' => 1,
  1089. 'audit' => 2,
  1090. 'pen_audit' => -1,
  1091. 'computer_audit' => -1,
  1092. 'face_audit' => -1,
  1093. 'reexamine_audit' => -1,
  1094. 'inspect_audit' => -1,
  1095. 'political_audit' => -1,
  1096. 'employ_audit' => -1
  1097. ];
  1098. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1099. //写日志
  1100. $log = [
  1101. 'type' => 2,
  1102. 'step' => 1,
  1103. 'appoint_id' => $v,
  1104. 'uid' => Admin::user()->id,
  1105. 'log' => '审核未通过,原因是:'.$reason
  1106. ];
  1107. RecruitAppointLog::create($log);
  1108. $message[$v] = '您此次报名审核未通过,原因是:'.$reason;
  1109. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1110. }
  1111. break;
  1112. case '3':
  1113. //审核通过
  1114. foreach ($ids as $k => $v){
  1115. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1116. if(!$appointinfo || intval($appointinfo->audit) === 3){
  1117. continue;
  1118. }
  1119. $recruit = Recruit::where('id',$appointinfo->recruit_id)->first();
  1120. $step = explode(',',$recruit->step);
  1121. $step_str = [
  1122. 'pen' => '未设置此条报名记录的笔试信息',
  1123. ];
  1124. if(in_array('3',$step)){
  1125. //场次有设置笔试
  1126. if(in_array('pen',$exam_flow_path)){
  1127. $step_str['pen'] = '该场次需要笔试,已设置此条报考需要参与笔试';
  1128. $pen_audit = -1;
  1129. }else{
  1130. $step_str['pen'] = '该场次需要笔试,此条报考可跳过笔试';
  1131. $pen_audit = 3;
  1132. }
  1133. }else{
  1134. $step_str['pen'] = '该场次不需要笔试';
  1135. $pen_audit = 3;
  1136. }
  1137. if(in_array('4',$step)){
  1138. //场次有设置上机
  1139. if(in_array('computer',$exam_flow_path)){
  1140. $step_str['computer'] = '该场次需要上机,已设置此条报考需要参与上机';
  1141. $computer_audit = -1;
  1142. }else{
  1143. $step_str['computer'] = '该场次需要上机,此条报考可跳过上机';
  1144. $computer_audit = 3;
  1145. }
  1146. }else{
  1147. $step_str['computer'] = '该场次不需要上机';
  1148. $computer_audit = 3;
  1149. }
  1150. if(in_array('5',$step)){
  1151. //场次有设置上机
  1152. if(in_array('face',$exam_flow_path)){
  1153. $step_str['face'] = '该场次需要面试,已设置此条报考需要参与面试';
  1154. $face_audit = -1;
  1155. }else{
  1156. $step_str['face'] = '该场次需要面试,此条报考可跳过面试';
  1157. $face_audit = 3;
  1158. }
  1159. }else{
  1160. $step_str['face'] = '该场次不需要面试';
  1161. $face_audit = 3;
  1162. }
  1163. if(in_array('6',$step)){
  1164. //场次有设置复试
  1165. if(in_array('reexamine',$exam_flow_path)){
  1166. $step_str['reexamine'] = '该场次需要复试,已设置此条报考需要参与复试';
  1167. $reexamine_audit = -1;
  1168. }else{
  1169. $step_str['reexamine'] = '该场次需要复试,此条报考可跳过复试';
  1170. $reexamine_audit = 3;
  1171. }
  1172. }else{
  1173. $step_str['reexamine'] = '该场次不需要复试';
  1174. $reexamine_audit = 3;
  1175. }
  1176. //设置该报名的各个状态
  1177. $appointinfo_data = [
  1178. 'current' => 2,//审核成功后进入考试流程
  1179. 'audit' => 3,
  1180. 'pen_audit' => $pen_audit,
  1181. 'computer_audit' => $computer_audit,
  1182. 'face_audit' => $face_audit,
  1183. 'reexamine_audit' => $reexamine_audit,
  1184. 'inspect_audit' => -1,
  1185. 'political_audit' => -1,
  1186. 'employ_audit' => -1
  1187. ];
  1188. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1189. $reason = $reason ?? '符合报考条件';
  1190. //写日志
  1191. $log = [
  1192. 'type' => 2,
  1193. 'step' => 1,
  1194. 'appoint_id' => $v,
  1195. 'uid' => Admin::user()->id,
  1196. 'log' => '审核通过,原因是:' . $reason,
  1197. 'admin_log' => implode(';',$step_str)
  1198. ];
  1199. RecruitAppointLog::create($log);
  1200. $message[$v] = '您此次报名审核已通过,原因是:' . $reason;
  1201. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1202. $this->fetch_word(['recruit_id'=>$appointinfo->recruit_id,'appoint_id'=>$appointinfo->id]);
  1203. }
  1204. break;
  1205. }
  1206. //站内信
  1207. foreach ($ids as $key => $val) {
  1208. if(array_key_exists($val,$message)){
  1209. $user_info = Member::where('id', $appointinfo->uid)->first();
  1210. Pms::write_pmsnotice($user_info->id, $user_info->username, $message[$val]);
  1211. }else{
  1212. continue;
  1213. }
  1214. }
  1215. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1216. }
  1217. /**
  1218. * 材料补登审核处理
  1219. * @param Request $request
  1220. * @return \Illuminate\Http\JsonResponse
  1221. */
  1222. public function supplement(Request $request)
  1223. {
  1224. Permission::check('ajax_supplement');
  1225. $ids = $request->ids;
  1226. if (empty($ids)) {
  1227. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1228. }
  1229. $status = $request->status;
  1230. $reason = $request->reason;
  1231. if(empty($status)){
  1232. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1233. }
  1234. if($status == -1 && empty($reason)){
  1235. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1236. }
  1237. if($status == -1){
  1238. $info = RecruitSupplement::where('appoint_id', $ids)->first();
  1239. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1240. //写日志
  1241. $log = [
  1242. 'type' => 2,
  1243. 'step' => 1,
  1244. 'appoint_id' => $ids,
  1245. 'uid' => Admin::user()->id,
  1246. 'log' => '材料补登审核未通过,原因是:'.$reason
  1247. ];
  1248. RecruitAppointLog::create($log);
  1249. $info->status = -1;
  1250. $info->msg = $reason;
  1251. $info->save();
  1252. $appointinfo->political_audit = 0;
  1253. $appointinfo->save();
  1254. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1255. }
  1256. if($status == 1){
  1257. $reason = $reason ?? '符合报考条件';
  1258. $info = RecruitSupplement::where('appoint_id', $ids)->first();
  1259. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1260. //写日志
  1261. $log = [
  1262. 'type' => 2,
  1263. 'step' => 1,
  1264. 'appoint_id' => $ids,
  1265. 'uid' => Admin::user()->id,
  1266. 'log' => '审核通过,原因是:' . $reason
  1267. ];
  1268. RecruitAppointLog::create($log);
  1269. $info->status = 1;
  1270. $info->msg = $reason;
  1271. $info->save();
  1272. $appointinfo->political_audit = 1;
  1273. $appointinfo->save();
  1274. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1275. }
  1276. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1277. }
  1278. /**
  1279. * 健康信息处理
  1280. * @param Request $request
  1281. * @return \Illuminate\Http\JsonResponse
  1282. */
  1283. public function health(Request $request)
  1284. {
  1285. Permission::check('ajax_health');
  1286. $ids = $request->ids;
  1287. if (empty($ids)) {
  1288. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1289. }
  1290. $status = $request->h_status;
  1291. $reason = $request->reason;
  1292. if(empty($status)){
  1293. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1294. }
  1295. if($status == -1 && empty($reason)){
  1296. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1297. }
  1298. if($status == -1){
  1299. $info = RecruitSupplement::where('appoint_id', $ids)->first();
  1300. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1301. //写日志
  1302. $log = [
  1303. 'type' => 2,
  1304. 'step' => 1,
  1305. 'appoint_id' => $ids,
  1306. 'uid' => Admin::user()->id,
  1307. 'log' => '健康信息审核未通过,原因是:'.$reason
  1308. ];
  1309. RecruitAppointLog::create($log);
  1310. $info->h_status = -1;
  1311. $info->h_msg = $reason;
  1312. $info->save();
  1313. $appointinfo->health_audit = 0;
  1314. $appointinfo->save();
  1315. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1316. }
  1317. if($status == 1){
  1318. $reason = $reason ?? '符合报考条件';
  1319. $info = RecruitSupplement::where('appoint_id', $ids)->first();
  1320. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1321. //写日志
  1322. $log = [
  1323. 'type' => 2,
  1324. 'step' => 1,
  1325. 'appoint_id' => $ids,
  1326. 'uid' => Admin::user()->id,
  1327. 'log' => '审核通过,原因是:' . $reason
  1328. ];
  1329. RecruitAppointLog::create($log);
  1330. $info->h_status = 1;
  1331. $info->h_msg = $reason;
  1332. $info->save();
  1333. $appointinfo->health_audit = 1;
  1334. $appointinfo->save();
  1335. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>"健康信息审核通过,请及时打印准考证"));
  1336. }
  1337. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1338. }
  1339. public function fetchWord(Request $request)
  1340. {
  1341. $recruit_id = $request->recruit_id;
  1342. $appoint_id = $request->appoint_id;
  1343. if(!empty($recruit_id) && !empty($appoint_id)){
  1344. $url = $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  1345. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok', 'url' => $url]);
  1346. }else{
  1347. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  1348. }
  1349. }
  1350. /**
  1351. * 查看审核日志
  1352. * @param Request $request
  1353. * @return \Illuminate\Http\JsonResponse
  1354. */
  1355. public function showLog(Request $request)
  1356. {
  1357. Permission::check('recruit_show_log');
  1358. $id = $request->id;
  1359. $logs = RecruitAppointLog::where('appoint_id', $id)->orderBy('created_at', 'desc')->get()->toArray();
  1360. $str = "";
  1361. if ($logs) {
  1362. $str .= "<table class='table'><tr style='background:#F0F8FD'><td>审核时间</td><td>操作级别</td><td>记录类型</td><td>触发操作的人员</td><td>审核描述</td></tr>";
  1363. foreach ($logs as $k => $v) {
  1364. switch ($v['type']){
  1365. case '1':
  1366. $level = '系统级操作';
  1367. $user = '系统';
  1368. break;
  1369. case '2':
  1370. $level = '审核系列操作';
  1371. $admin = AdminUser::where('id',$v['uid'])->first();
  1372. $user = $admin->name;
  1373. break;
  1374. case '3':
  1375. $level = '用户自行操作';
  1376. $member = Member::where('id',$v['uid'])->first();
  1377. $user = $member->username;
  1378. break;
  1379. }
  1380. switch ($v['step']){
  1381. case '1':
  1382. $step = '报名及审核';
  1383. break;
  1384. case '2':
  1385. $step = '笔试';
  1386. break;
  1387. case '3':
  1388. $step = '面试';
  1389. break;
  1390. case '4':
  1391. $step = '上机';
  1392. break;
  1393. case '5':
  1394. $step = '复审';
  1395. break;
  1396. case '6':
  1397. $step = '体检';
  1398. break;
  1399. case '7':
  1400. $step = '政审';
  1401. break;
  1402. case '8':
  1403. $step = '录用';
  1404. break;
  1405. }
  1406. $str .= "<tr><td>" . $v['created_at'] . "</td><td>" . $level . "</td><td>" . $step . "</td><td>" . $user . "</td><td>" . $v['log'] . "</td></tr>\r\n";
  1407. }
  1408. $str .= "</table>";
  1409. } else {
  1410. $str = "抱歉,暂未有审核记录";
  1411. }
  1412. return response()->json(['code' => 1, 'data' => $str]);
  1413. }
  1414. /**
  1415. * 生成word版简历
  1416. * @param null $data
  1417. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1418. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1419. * @throws \PhpOffice\PhpWord\Exception\Exception
  1420. */
  1421. public function fetch_word($data = null)
  1422. {
  1423. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1424. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1425. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1426. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example.docx');
  1427. //通过setValue 方法给模板赋值
  1428. $templateProcessor->setValue('title', $recruit->name);
  1429. $templateProcessor->setValue('realname', $appoint->realname);
  1430. $templateProcessor->setValue('realname', $appoint->realname);
  1431. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1432. $templateProcessor->setValue('birthday', $appoint->birthday);
  1433. $templateProcessor->setValue('nation', $appoint->nation);
  1434. $templateProcessor->setValue('native_place', $appoint->native_place);
  1435. $templateProcessor->setValue('card', $appoint->card);
  1436. switch ($appoint->political_affiliation){
  1437. case '01':
  1438. $templateProcessor->setValue('political_affiliation', '中共党员');
  1439. break;
  1440. case '02':
  1441. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1442. break;
  1443. case '03':
  1444. $templateProcessor->setValue('political_affiliation', '共青团员');
  1445. break;
  1446. case '04':
  1447. $templateProcessor->setValue('political_affiliation', '民革党员');
  1448. break;
  1449. case '05':
  1450. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1451. break;
  1452. case '06':
  1453. $templateProcessor->setValue('political_affiliation', '民建会员');
  1454. break;
  1455. case '07':
  1456. $templateProcessor->setValue('political_affiliation', '民进会员');
  1457. break;
  1458. case '08':
  1459. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1460. break;
  1461. case '09':
  1462. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1463. break;
  1464. case '10':
  1465. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1466. break;
  1467. case '11':
  1468. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1469. break;
  1470. case '12':
  1471. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1472. break;
  1473. case '13':
  1474. $templateProcessor->setValue('political_affiliation', '群众');
  1475. }
  1476. $templateProcessor->setValue('join_time', $appoint->join_time);
  1477. $templateProcessor->setValue('house_register', $appoint->house_register);
  1478. switch ($appoint->edu_type){
  1479. case '1':
  1480. $templateProcessor->setValue('edu_type', '全日制');
  1481. break;
  1482. case '2':
  1483. $templateProcessor->setValue('edu_type', '在职教育');
  1484. break;
  1485. }
  1486. $templateProcessor->setValue('education', $appoint->education);
  1487. $templateProcessor->setValue('school', $appoint->school);
  1488. $templateProcessor->setValue('degree', $appoint->degree);
  1489. $templateProcessor->setValue('pro', $appoint->pro);
  1490. $templateProcessor->setValue('mobile', $appoint->mobile);
  1491. $templateProcessor->setValue('email', $appoint->email);
  1492. $templateProcessor->setValue('address', $appoint->address);
  1493. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1494. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1495. $templateProcessor->setValue('work', $appoint->work);
  1496. $templateProcessor->setValue('titles', $appoint->titles);
  1497. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1498. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1499. $forms = explode(',', $recruit->forms);
  1500. if(in_array('expand_special',$forms)){
  1501. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint->id)->first();
  1502. $templateProcessor->cloneBlock('special_block',1);
  1503. $templateProcessor->setValue('point_apply', $special->point_apply == 0 ? '否' : '是');
  1504. $templateProcessor->setValue('condition', $special->condition);
  1505. if($material = json_decode($special->material)){
  1506. foreach ($material as $k => $v){
  1507. $templateProcessor->setImageValue('material#'.($k+1),['src' => 'https://www.jucai.gov.cn/'.$v->url]);
  1508. }
  1509. }
  1510. }else{
  1511. $templateProcessor->cloneBlock('special_block',0);
  1512. }
  1513. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1514. if(in_array('detail',$forms)){
  1515. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1516. $templateProcessor->cloneBlock('detail_block',1);
  1517. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1518. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1519. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1520. }else{
  1521. $templateProcessor->cloneBlock('detail_block',0);
  1522. }
  1523. if($family = json_decode($appoint->family,true)){
  1524. $templateProcessor->cloneRow('family_relation',count($family));
  1525. $i = 1;
  1526. foreach ($family as $k => $v){
  1527. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1528. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1529. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1530. switch ($v['political_affiliation']){
  1531. case '01':
  1532. $political_affiliation = '中共党员';
  1533. break;
  1534. case '02':
  1535. $political_affiliation = '中共预备党员';
  1536. break;
  1537. case '03':
  1538. $political_affiliation = '共青团员';
  1539. break;
  1540. case '04':
  1541. $political_affiliation = '民革党员';
  1542. break;
  1543. case '05':
  1544. $political_affiliation = '民盟盟员';
  1545. break;
  1546. case '06':
  1547. $political_affiliation = '民建会员';
  1548. break;
  1549. case '07':
  1550. $political_affiliation = '民进会员';
  1551. break;
  1552. case '08':
  1553. $political_affiliation = '农工党党员';
  1554. break;
  1555. case '09':
  1556. $political_affiliation = '致公党党员';
  1557. break;
  1558. case '10':
  1559. $political_affiliation = '九三学社社员';
  1560. break;
  1561. case '11':
  1562. $political_affiliation = '台盟盟员';
  1563. break;
  1564. case '12':
  1565. $political_affiliation = '无党派人士';
  1566. break;
  1567. case '13':
  1568. $political_affiliation = '群众';
  1569. }
  1570. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1571. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1572. $i++;
  1573. }
  1574. }
  1575. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1576. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1577. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1578. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1579. }
  1580. $word_url = "/{$filename}.docx";
  1581. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1582. $appoint->save();
  1583. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1584. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1585. }
  1586. }
  1587. /**
  1588. * 生成word版简历
  1589. * @param null $data
  1590. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1591. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1592. * @throws \PhpOffice\PhpWord\Exception\Exception
  1593. */
  1594. public function fetch_word_internship($data = null)
  1595. {
  1596. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1597. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1598. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1599. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example_internship.docx');
  1600. //通过setValue 方法给模板赋值
  1601. $templateProcessor->setValue('title', $recruit->name);
  1602. $templateProcessor->setValue('realname', $appoint->realname);
  1603. $templateProcessor->setValue('realname', $appoint->realname);
  1604. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1605. $templateProcessor->setValue('birthday', $appoint->birthday);
  1606. $templateProcessor->setValue('nation', $appoint->nation);
  1607. $templateProcessor->setValue('native_place', $appoint->native_place);
  1608. $templateProcessor->setValue('card', $appoint->card);
  1609. switch ($appoint->political_affiliation){
  1610. case '01':
  1611. $templateProcessor->setValue('political_affiliation', '中共党员');
  1612. break;
  1613. case '02':
  1614. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1615. break;
  1616. case '03':
  1617. $templateProcessor->setValue('political_affiliation', '共青团员');
  1618. break;
  1619. case '04':
  1620. $templateProcessor->setValue('political_affiliation', '民革党员');
  1621. break;
  1622. case '05':
  1623. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1624. break;
  1625. case '06':
  1626. $templateProcessor->setValue('political_affiliation', '民建会员');
  1627. break;
  1628. case '07':
  1629. $templateProcessor->setValue('political_affiliation', '民进会员');
  1630. break;
  1631. case '08':
  1632. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1633. break;
  1634. case '09':
  1635. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1636. break;
  1637. case '10':
  1638. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1639. break;
  1640. case '11':
  1641. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1642. break;
  1643. case '12':
  1644. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1645. break;
  1646. case '13':
  1647. $templateProcessor->setValue('political_affiliation', '群众');
  1648. }
  1649. $templateProcessor->setValue('join_time', $appoint->join_time);
  1650. $templateProcessor->setValue('house_register', $appoint->house_register);
  1651. $templateProcessor->setValue('education', $appoint->education);
  1652. $templateProcessor->setValue('school', $appoint->school);
  1653. $templateProcessor->setValue('pro', $appoint->pro);
  1654. $templateProcessor->setValue('adjust', $appoint->adjust == 0 ? '否' : '是');
  1655. $templateProcessor->setValue('mobile', $appoint->mobile);
  1656. $templateProcessor->setValue('email', $appoint->email);
  1657. $templateProcessor->setValue('address', $appoint->address);
  1658. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1659. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1660. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1661. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1662. $forms = explode(',', $recruit->forms);
  1663. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1664. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1665. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1666. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1667. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1668. if($family = json_decode($appoint->family,true)){
  1669. $templateProcessor->cloneRow('family_relation',count($family));
  1670. $i = 1;
  1671. foreach ($family as $k => $v){
  1672. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1673. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1674. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1675. switch ($v['political_affiliation']){
  1676. case '01':
  1677. $political_affiliation = '中共党员';
  1678. break;
  1679. case '02':
  1680. $political_affiliation = '中共预备党员';
  1681. break;
  1682. case '03':
  1683. $political_affiliation = '共青团员';
  1684. break;
  1685. case '04':
  1686. $political_affiliation = '民革党员';
  1687. break;
  1688. case '05':
  1689. $political_affiliation = '民盟盟员';
  1690. break;
  1691. case '06':
  1692. $political_affiliation = '民建会员';
  1693. break;
  1694. case '07':
  1695. $political_affiliation = '民进会员';
  1696. break;
  1697. case '08':
  1698. $political_affiliation = '农工党党员';
  1699. break;
  1700. case '09':
  1701. $political_affiliation = '致公党党员';
  1702. break;
  1703. case '10':
  1704. $political_affiliation = '九三学社社员';
  1705. break;
  1706. case '11':
  1707. $political_affiliation = '台盟盟员';
  1708. break;
  1709. case '12':
  1710. $political_affiliation = '无党派人士';
  1711. break;
  1712. case '13':
  1713. $political_affiliation = '群众';
  1714. }
  1715. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1716. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1717. $i++;
  1718. }
  1719. }
  1720. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1721. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1722. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1723. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1724. }
  1725. $word_url = "/{$filename}.docx";
  1726. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1727. $appoint->save();
  1728. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1729. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1730. }
  1731. }
  1732. /**
  1733. * 将报名资料导出成ZIP压缩包
  1734. * @param Request $request
  1735. * @return \Illuminate\Http\JsonResponse
  1736. * @throws \Exception
  1737. */
  1738. public function out_zip(Request $request)
  1739. {//TODO 数据太大,无法压缩,得做成异步
  1740. Permission::check('recruit_out_excel');
  1741. $recruit_id = $request->id;
  1742. $recruit = Recruit::find($recruit_id);
  1743. if (empty($recruit)) {
  1744. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1745. }
  1746. $data = $request->all();
  1747. $where = [];
  1748. $where[] = ['audit','>',0];
  1749. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1750. $param = parse_url($data['where']);
  1751. parse_str($param['query'],$param);
  1752. if (is_array($param)) {
  1753. unset($param['id']);
  1754. foreach ($param as $k => $v) {
  1755. if ($k == 'realname') {
  1756. $where[] = [$k, 'like', "%$v%"];
  1757. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1758. $where[] = [$k, '=', $v];
  1759. }
  1760. }
  1761. }
  1762. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1763. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1764. if(in_array('expand_special',explode(',', $recruit->forms))){
  1765. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1766. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1767. $select = array_merge($select,$special_select);
  1768. }
  1769. if(in_array('detail',explode(',', $recruit->forms))){
  1770. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1771. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1772. $select = array_merge($select,$detail_select);
  1773. }
  1774. $list = $model->select($select)
  1775. ->orderBy('recruit_appoint_info.updated_at','desc')
  1776. ->get();
  1777. if(!is_dir(base_path() . "/storage/app/public/recruit/zip")){
  1778. Storage::makeDirectory("public/recruit/zip");
  1779. }
  1780. if (file_exists(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip')) {
  1781. unlink(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip');
  1782. }
  1783. if($list){
  1784. // foreach ($list as $key => $value){
  1785. // $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
  1786. // if(!is_dir($path)){
  1787. // Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
  1788. // }
  1789. // if(in_array('expand_special',explode(',', $recruit->forms))){
  1790. // $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
  1791. // $material = json_decode($special['material'],true);
  1792. // if($material){
  1793. // foreach ($material as $k => $v){
  1794. // $old_path = base_path() . "/public/" . $v['url'];
  1795. // if (file_exists($old_path)) {
  1796. // $basename = basename($old_path);
  1797. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1798. // copy($old_path, $new_path); //拷贝到新目录
  1799. // }
  1800. // }
  1801. // }
  1802. // }
  1803. // if(in_array('identification',explode(',', $recruit->forms))){
  1804. // $identification = json_decode($value->identification,true);
  1805. // if($identification){
  1806. // foreach ($identification as $k => $v){
  1807. // $old_path = base_path() . "/public/" . $v['url'];
  1808. // if (file_exists($old_path)) {
  1809. // $basename = basename($old_path);
  1810. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1811. // copy($old_path, $new_path); //拷贝到新目录
  1812. // }
  1813. // }
  1814. // }
  1815. // }
  1816. // if(in_array('education_certification',explode(',', $recruit->forms))){
  1817. // $education_certification = json_decode($value->education_certification,true);
  1818. // if($education_certification){
  1819. // foreach ($education_certification as $k => $v){
  1820. // $old_path = base_path() . "/public/" . $v['url'];
  1821. // if (file_exists($old_path)) {
  1822. // $basename = basename($old_path);
  1823. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1824. // copy($old_path, $new_path); //拷贝到新目录
  1825. // }
  1826. // }
  1827. // }
  1828. // }
  1829. // if(in_array('other_certification',explode(',', $recruit->forms))){
  1830. // $other_certification = json_decode($value->other_certification,true);
  1831. // if($other_certification){
  1832. // foreach ($other_certification as $k => $v){
  1833. // $old_path = base_path() . "/public/" . $v['url'];
  1834. // if (file_exists($old_path)) {
  1835. // $basename = basename($old_path);
  1836. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1837. // copy($old_path, $new_path); //拷贝到新目录
  1838. // }
  1839. // }
  1840. // }
  1841. // }
  1842. // copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
  1843. // }
  1844. $savename = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}.zip";
  1845. $zipper = new Zipper();
  1846. $folder = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/";//$public_path 被压缩的文件名
  1847. $zipper->make($savename)->add($folder)->close();//public_path($reduce_path) 压缩之后的文件名
  1848. // header("Content-Type: application/zip");
  1849. // header("Content-Transfer-Encoding: Binary");
  1850. // header("Content-Length: " . filesize($savename));
  1851. // header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
  1852. //
  1853. // readfile($savename);
  1854. // exit;
  1855. return response()->json(['status' => 1, 'msg' => "/zip/{$recruit->name}.zip" ], 200);
  1856. }else{
  1857. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  1858. }
  1859. }
  1860. /**
  1861. * 准考证生成界面
  1862. *
  1863. * @param Content $content
  1864. * @param Request $request
  1865. * @return Content
  1866. */
  1867. public function ticket(Content $content, Request $request)
  1868. {
  1869. $recruit_id = $request->id;
  1870. $recruit = Recruit::find($recruit_id);
  1871. return $content
  1872. ->header('准考证管理')
  1873. ->description('')
  1874. ->body(view('admin.recruit.ticket')->with(['recruit'=>$recruit]));
  1875. }
  1876. /**
  1877. * 导出excel汇总表
  1878. * @param Content $content
  1879. * @param Request $request
  1880. * @return \Illuminate\Http\JsonResponse
  1881. * @throws \PhpOffice\PhpSpreadsheet\Exception
  1882. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  1883. */
  1884. public function out_excel(Content $content, Request $request)
  1885. {
  1886. Permission::check('recruit_out_excel');
  1887. $id = $request->id;
  1888. $recruit = Recruit::find($id);
  1889. if (empty($recruit)) {
  1890. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1891. }
  1892. $data = $request->all();
  1893. $where = [];
  1894. $where[] = ['audit','>',0];
  1895. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1896. $param = parse_url($data['where']);
  1897. parse_str($param['query'],$param);
  1898. if (is_array($param)) {
  1899. unset($param['id']);
  1900. foreach ($param as $k => $v) {
  1901. if ($k == 'realname') {
  1902. $where[] = [$k, 'like', "%$v%"];
  1903. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1904. $where[] = [$k, '=', $v];
  1905. }
  1906. }
  1907. }
  1908. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1909. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1910. if(in_array('expand_special',explode(',', $recruit->forms))){
  1911. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1912. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1913. $select = array_merge($select,$special_select);
  1914. }
  1915. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1916. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1917. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1918. $select = array_merge($select,$detail_select);
  1919. }
  1920. $list = $model->select($select)
  1921. ->orderBy('recruit_appoint_info.updated_at','desc')
  1922. ->get();
  1923. if(count($list)){
  1924. $spreadsheet = new Spreadsheet();
  1925. $sheet = $spreadsheet->getActiveSheet();
  1926. if(in_array('internship',explode(',', $recruit->forms))){
  1927. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1928. }else{
  1929. $header = ['姓名','性别','生日','头像','民族','籍贯','报考岗位','政治面貌','入党时间','职称或职业资格','现工作单位及职务','户籍所在地','学历','学校','学位','所学专业','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1930. }
  1931. if(in_array('expand_special',explode(',', $recruit->forms))){
  1932. $special = ['是否申请加分','符合哪一项加分条件','加分佐证材料'];
  1933. $header = array_merge($header,$special);
  1934. }
  1935. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1936. $detail = ['个人简历','培训学习经历','奖惩情况','个人介绍'];
  1937. }else{
  1938. $detail = ['个人简历'];
  1939. }
  1940. $header = array_merge($header,$detail);
  1941. $header[] = '家庭成员及其社会关系';
  1942. if(in_array('identification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1943. $header[] = '身份证明';
  1944. }
  1945. if(in_array('education_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1946. $header[] = '学历证明';
  1947. }
  1948. if(in_array('other_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1949. $header[] = '其他证明';
  1950. }
  1951. $header[] = '审核状态';
  1952. $header[] = '审核意见';
  1953. // if(in_array('3',explode(',', $recruit->step))){
  1954. // $header = array_merge($header,['笔试准考证打印','笔试审核状态','笔试结果']);
  1955. // }
  1956. // if(in_array('4',explode(',', $recruit->step))){
  1957. // $header = array_merge($header,['上机准考证打印','上机审核状态','上机结果']);
  1958. // }
  1959. // if(in_array('5',explode(',', $recruit->step))){
  1960. // $header = array_merge($header,['面试准考证打印','面试审核状态','面试结果']);
  1961. // }
  1962. // if(in_array('6',explode(',', $recruit->step))){
  1963. // $header = array_merge($header,['复试准考证打印','复试审核状态','复试结果']);
  1964. // }
  1965. // if(in_array('7',explode(',', $recruit->step))){
  1966. // $header = array_merge($header,['体检审核状态','体检结果']);
  1967. // }
  1968. // if(in_array('8',explode(',', $recruit->step))){
  1969. // $header = array_merge($header,['政审状态','政审结果']);
  1970. // }
  1971. $header[] = 'word简历的下载地址';
  1972. foreach ($header as $key => $value) {
  1973. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  1974. }
  1975. $row = 2;
  1976. $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  1977. $length = count($list);//算出该数组的长度
  1978. $last = $list[$length-1];//取出最后一个数组的值,复制给新变量,-1是因为第一个数组元素下表为0
  1979. unset($list[$length-1]);//将最后一个数组注销
  1980. $list[] = $last;//再将新变量加入到数组里
  1981. $data = [];
  1982. foreach ($list as $k => $v) {
  1983. switch ($v->political_affiliation) {
  1984. case '01':
  1985. $political_affiliation = '中共党员';
  1986. break;
  1987. case '02':
  1988. $political_affiliation = '中共预备党员';
  1989. break;
  1990. case '03':
  1991. $political_affiliation = '共青团员';
  1992. break;
  1993. case '04':
  1994. $political_affiliation = '民革党员';
  1995. break;
  1996. case '05':
  1997. $political_affiliation = '民盟盟员';
  1998. break;
  1999. case '06':
  2000. $political_affiliation = '民建会员';
  2001. break;
  2002. case '07':
  2003. $political_affiliation = '民进会员';
  2004. break;
  2005. case '08':
  2006. $political_affiliation = '农工党党员';
  2007. break;
  2008. case '09':
  2009. $political_affiliation = '致公党党员';
  2010. break;
  2011. case '10':
  2012. $political_affiliation = '九三学社社员';
  2013. break;
  2014. case '11':
  2015. $political_affiliation = '台盟盟员';
  2016. break;
  2017. case '12':
  2018. $political_affiliation = '无党派人士';
  2019. break;
  2020. case '13':
  2021. $political_affiliation = '群众';
  2022. break;
  2023. default:
  2024. $political_affiliation = '未知';
  2025. break;
  2026. }
  2027. if(in_array('internship',explode(',', $recruit->forms))){
  2028. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  2029. $item = [
  2030. $v->realname,
  2031. $v->sex == 0 ? '女' : '男',
  2032. $v->birthday,
  2033. "https://www.jucai.gov.cn" . $v->avatar,
  2034. $v->nation,
  2035. $v->native_place,
  2036. $v->code . $v->name,
  2037. $political_affiliation,
  2038. $v->join_time,
  2039. $v->house_register,
  2040. $v->education,
  2041. $v->school,
  2042. $v->pro,
  2043. $v->adjust == 0 ? '否' : '是',
  2044. $v->address,
  2045. '\''.$v->card,
  2046. $v->mobile,
  2047. $v->email,
  2048. $v->concat_name,
  2049. $v->concat_mobile
  2050. ];
  2051. }else{
  2052. $item = [
  2053. $v->realname,
  2054. $v->sex == 0 ? '女' : '男',
  2055. $v->birthday,
  2056. "https://www.jucai.gov.cn" . $v->avatar,
  2057. $v->nation,
  2058. $v->native_place,
  2059. $v->code . $v->name,
  2060. $political_affiliation,
  2061. $v->join_time,
  2062. $v->titles,
  2063. $v->work,
  2064. $v->house_register,
  2065. $v->education,
  2066. $v->school,
  2067. $v->degree,
  2068. $v->pro,
  2069. $v->address,
  2070. '\''.$v->card,
  2071. $v->mobile,
  2072. $v->email,
  2073. $v->concat_name,
  2074. $v->concat_mobile
  2075. ];
  2076. }
  2077. if (in_array('expand_special', explode(',', $recruit->forms))) {
  2078. $material = json_decode($v->material, true);
  2079. $materials = [];
  2080. if($material){
  2081. foreach ($material as $key => $value) {
  2082. array_push($materials, "https://www.jucai.gov.cn" . $value['response']['path']);
  2083. }
  2084. }
  2085. $special = [
  2086. $v->point_apply == 0 ? '否' : '是',
  2087. $v->condition,
  2088. implode("\r\n", $materials)
  2089. ];
  2090. $item = array_merge($item, $special);
  2091. }
  2092. if (in_array('detail', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2093. $detail = [
  2094. $v->resume,
  2095. $v->train,
  2096. $v->rewards_and_punishments,
  2097. $v->introduce
  2098. ];
  2099. } else {
  2100. $detail = [$v->resume];
  2101. }
  2102. $item = array_merge($item, $detail);
  2103. $family = json_decode($v->family, true);
  2104. $familys = [];
  2105. foreach ($family as $val){
  2106. switch ($val['political_affiliation']) {
  2107. case '01':
  2108. $political_affiliation = '中共党员';
  2109. break;
  2110. case '02':
  2111. $political_affiliation = '中共预备党员';
  2112. break;
  2113. case '03':
  2114. $political_affiliation = '共青团员';
  2115. break;
  2116. case '04':
  2117. $political_affiliation = '民革党员';
  2118. break;
  2119. case '05':
  2120. $political_affiliation = '民盟盟员';
  2121. break;
  2122. case '06':
  2123. $political_affiliation = '民建会员';
  2124. break;
  2125. case '07':
  2126. $political_affiliation = '民进会员';
  2127. break;
  2128. case '08':
  2129. $political_affiliation = '农工党党员';
  2130. break;
  2131. case '09':
  2132. $political_affiliation = '致公党党员';
  2133. break;
  2134. case '10':
  2135. $political_affiliation = '九三学社社员';
  2136. break;
  2137. case '11':
  2138. $political_affiliation = '台盟盟员';
  2139. break;
  2140. case '12':
  2141. $political_affiliation = '无党派人士';
  2142. break;
  2143. case '13':
  2144. $political_affiliation = '群众';
  2145. break;
  2146. default:
  2147. $political_affiliation = '未知';
  2148. break;
  2149. }
  2150. $familys[] = "称谓:" . $val['relation'] . ";姓名:".$val['realname'] . ';生日:'.$val['birthday'].';政治面貌:'.$political_affiliation.';职业:'.$val['work'];
  2151. }
  2152. $item[] = implode("\r\n", $familys);
  2153. if (in_array('identification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2154. $identification = json_decode($v->identification, true);
  2155. $identifications = [];
  2156. foreach ($identification as $val){
  2157. array_push($identifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2158. }
  2159. array_push($item, implode("\r\n", $identifications));
  2160. }
  2161. if (in_array('education_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2162. $education_certification = json_decode($v->education_certification, true);
  2163. $education_certifications = [];
  2164. foreach ($education_certification as $val){
  2165. array_push($education_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2166. }
  2167. array_push($item, implode("\r\n", $education_certifications));
  2168. }
  2169. if (in_array('other_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2170. $other_certification = json_decode($v->other_certification, true);
  2171. $other_certifications = [];
  2172. if($other_certification){
  2173. foreach ($other_certification as $val){
  2174. array_push($other_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2175. }
  2176. }
  2177. array_push($item, implode("\r\n", $other_certifications));
  2178. }
  2179. switch (intval($v->audit)){
  2180. case 1:
  2181. $item[] = '审核中';
  2182. $item[] = '';
  2183. break;
  2184. case 2:
  2185. case 3:
  2186. $log = RecruitAppointLog::where('appoint_id', $v->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  2187. if ($log) {
  2188. $log_arr = explode(',',$log->log);
  2189. $item[] = $log_arr[0];
  2190. $item[] = $log_arr[1];
  2191. } else {
  2192. $item[] = '';
  2193. $item[] = '';
  2194. }
  2195. break;
  2196. default:
  2197. $item[] = '';
  2198. $item[] = '';
  2199. break;
  2200. }
  2201. if(empty($v->word_url)){
  2202. $item[] = "暂无";
  2203. }else{
  2204. $item[] = "https://www.jucai.gov.cn/" . $v->word_url;
  2205. }
  2206. array_push($data,$item);
  2207. }
  2208. foreach($data as $k => $v){
  2209. for ($i = 0;$i<count($v);$i++){
  2210. if($i == 18 || $i == 19 || $i == 22){
  2211. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2212. }else{
  2213. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2214. }
  2215. }
  2216. $row++;
  2217. }
  2218. $file_name = $recruit->name . date("Y-m-d",time());
  2219. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2220. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2221. header('Cache-Control: max-age=0');
  2222. // If you're serving to IE 9, then the following may be needed
  2223. header('Cache-Control: max-age=1');
  2224. // If you're serving to IE over SSL, then the following may be needed
  2225. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2226. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2227. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2228. header('Pragma: public'); // HTTP/1.0
  2229. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2230. $writer->save('php://output');
  2231. }else{
  2232. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  2233. }
  2234. }
  2235. /**
  2236. * 座位贴
  2237. * @param Content $content
  2238. * @param Request $request
  2239. * @return Content
  2240. */
  2241. public function seat_sticker(Content $content, Request $request){
  2242. $recruit_id = $request->id;
  2243. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2244. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2245. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2246. ->orderBy('recruit_ticket.ex_room','asc')
  2247. ->orderBy('recruit_ticket.ex_seat','asc')
  2248. ->get();
  2249. $data = [];
  2250. foreach ($list as $k => $v){
  2251. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2252. if(!array_key_exists($room,$data)){
  2253. $data[$room] = [];
  2254. }
  2255. $item = [
  2256. 'avatar' => $v->avatar,
  2257. 'seat' => $v->ex_seat,
  2258. 'realname' => $v->realname,
  2259. 'number' => $v->ex_number
  2260. ];
  2261. array_push($data[$room],$item);
  2262. }
  2263. //dd($data);
  2264. return $content->body(view('admin.recruit.seat_sticker')->with(['data' => $data]));
  2265. }
  2266. public function sign_table(Content $content, Request $request){
  2267. $recruit_id = $request->id;
  2268. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2269. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2270. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2271. ->orderBy('recruit_ticket.ex_room','asc')
  2272. ->orderBy('recruit_ticket.ex_seat','asc')
  2273. ->get();
  2274. $data = [];
  2275. foreach ($list as $k => $v){
  2276. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2277. if(!array_key_exists($room,$data)){
  2278. $data[$room] = [];
  2279. }
  2280. $item = [
  2281. 'avatar' => $v->avatar,
  2282. 'seat' => $v->ex_seat,
  2283. 'realname' => $v->realname
  2284. ];
  2285. array_push($data[$room],$item);
  2286. }
  2287. return $content->body(view('admin.recruit.sign_table')->with(['data' => $data]));
  2288. }
  2289. /**
  2290. * 上传成绩页面
  2291. *
  2292. * @access public
  2293. */
  2294. public function ajax_record(Request $request)
  2295. {
  2296. $recruit_id = $request->input('recruit_id');
  2297. if(!$recruit_id){
  2298. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2299. }
  2300. $recruit = Recruit::where('id',$recruit_id)->first();
  2301. if(empty($recruit)){
  2302. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2303. }
  2304. $view_data = [
  2305. 'recruit' => $recruit
  2306. ];
  2307. return response(['data' => view('admin.recruit.ajax_record')->with($view_data)->render(), 'status' => 1], '200');
  2308. }
  2309. public function update_record(Request $request)
  2310. {
  2311. $data = $request->all();
  2312. if(!array_key_exists('recruit_id',$data) || !$data['recruit_id']){
  2313. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2314. }
  2315. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  2316. if(empty($recruit)){
  2317. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2318. }
  2319. if(array_key_exists('pen_data',$data)){
  2320. $ticket_url = base_path() . "/storage/app/public/recruit/ticket/" . uniqid() . '.xlsx';
  2321. if(move_uploaded_file($_FILES['pen_data']['tmp_name'],$ticket_url)){
  2322. $spreadsheet = IOFactory::load($ticket_url);
  2323. $sheet = $spreadsheet->getActiveSheet();
  2324. $rowCount = $sheet->getHighestRow();
  2325. $record = [];
  2326. for($row = 2;$row<=$rowCount;$row++){
  2327. $record[$sheet->getCell("A{$row}")->getValue()] = [
  2328. 'id' => $sheet->getCell("A{$row}")->getValue(),
  2329. 'realname' => $sheet->getCell("B{$row}")->getValue(),
  2330. 'card' => $sheet->getCell("C{$row}")->getValue(),
  2331. 'ex_number' => $sheet->getCell("E{$row}")->getValue(),
  2332. 'record' => $sheet->getCell("F{$row}")->getValue(),
  2333. 'next' => $sheet->getCell("G{$row}")->getValue()
  2334. ];
  2335. }
  2336. Recruit::where('id',$data['recruit_id'])->update(['pen_status' => 1]);
  2337. $record = new TicketJob($data['recruit_id'],'pen_result',$record);
  2338. dispatch($record);
  2339. return response()->json(['status' => 1, 'msg' => '成绩上传成功'], 200);
  2340. }else{
  2341. return response()->json(['status' => 0, 'msg' => '成绩上传失败'], 200);
  2342. }
  2343. }else{
  2344. return response()->json(['status' => 0, 'msg' => '笔试成绩不存在'], 200);
  2345. }
  2346. }
  2347. public function create_record_template(Request $request){
  2348. $recruit_id = $request->input('recruit_id');
  2349. if(!$recruit_id){
  2350. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2351. }
  2352. $recruit = Recruit::where('id',$recruit_id)->first();
  2353. if(empty($recruit)){
  2354. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2355. }
  2356. $type = $request->input('type','pen');
  2357. switch ($type){
  2358. case 'pen':
  2359. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2360. ->where('recruit_appoint_info.audit',3)
  2361. ->where('recruit_appoint_info.pen_audit',-1)
  2362. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')
  2363. ->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2364. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2365. $data = [];
  2366. foreach ($list as $k => $v){
  2367. $item = [
  2368. $v->id,
  2369. $v->realname,
  2370. $v->card,
  2371. $post_data[$v->post_id],
  2372. $v->ex_number
  2373. ];
  2374. array_push($data,$item);
  2375. }
  2376. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2377. $sheet = $spreadsheet->getActiveSheet();
  2378. $row = 2;
  2379. foreach($data as $k => $v){
  2380. for ($i = 0;$i<count($v);$i++){
  2381. if($i == 2 || $i == 4){
  2382. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2383. }else{
  2384. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2385. }
  2386. }
  2387. $row++;
  2388. }
  2389. $file_name = $recruit->company . "_成绩表模板";
  2390. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2391. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2392. header('Cache-Control: max-age=0');
  2393. // If you're serving to IE 9, then the following may be needed
  2394. header('Cache-Control: max-age=1');
  2395. // If you're serving to IE over SSL, then the following may be needed
  2396. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2397. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2398. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2399. header('Pragma: public'); // HTTP/1.0
  2400. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2401. $writer->save('php://output');
  2402. break;
  2403. case 'face':
  2404. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2405. ->where('recruit_appoint_info.audit',3)
  2406. ->where('recruit_appoint_info.face_audit',-1)
  2407. ->where(function($query){
  2408. $query->where('recruit_appoint_info.pen_audit',1)
  2409. ->orWhere('recruit_appoint_info.pen_audit',3);
  2410. })
  2411. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2412. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2413. $data = [];
  2414. foreach ($list as $k => $v){
  2415. $item = [
  2416. $v->id,
  2417. $v->realname,
  2418. $v->card,
  2419. $post_data[$v->post_id],
  2420. $v->ex_number
  2421. ];
  2422. array_push($data,$item);
  2423. }
  2424. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2425. $sheet = $spreadsheet->getActiveSheet();
  2426. $row = 2;
  2427. foreach($data as $k => $v){
  2428. for ($i = 0;$i<count($v);$i++){
  2429. if($i == 2 || $i == 4){
  2430. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2431. }else{
  2432. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2433. }
  2434. }
  2435. $row++;
  2436. }
  2437. $file_name = $recruit->company . "_成绩表模板";
  2438. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2439. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2440. header('Cache-Control: max-age=0');
  2441. // If you're serving to IE 9, then the following may be needed
  2442. header('Cache-Control: max-age=1');
  2443. // If you're serving to IE over SSL, then the following may be needed
  2444. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2445. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2446. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2447. header('Pragma: public'); // HTTP/1.0
  2448. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2449. $writer->save('php://output');
  2450. break;
  2451. }
  2452. }
  2453. public function ticket_template(Request $request)
  2454. {
  2455. }
  2456. public function create_ticket(Request $request)
  2457. {
  2458. $data = $request->only('recruit_id','type','channel','content','keys');
  2459. //dd($data);
  2460. }
  2461. public function test(Request $request){
  2462. $list = RecruitSupplement::where('recruit_supplement.status',1)
  2463. ->join('recruit_appoint_info', 'recruit_supplement.appoint_id', '=' , 'recruit_appoint_info.id', 'left')
  2464. ->select('recruit_appoint_info.*')
  2465. ->get();
  2466. $post_data = RecruitPost::where('recruit_id',5)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2467. $header = ['姓名','性别','年龄','联系电话','身份证号码','岗位'];
  2468. $spreadsheet = new Spreadsheet();
  2469. $sheet = $spreadsheet->getActiveSheet();
  2470. foreach ($header as $key => $value) {
  2471. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  2472. }
  2473. foreach($list as $k => $v){
  2474. $sheet->setCellValueByColumnAndRow(1, $k+2, $v->realname);
  2475. $sheet->setCellValueByColumnAndRow(2, $k+2, $v->sex == 0 ? '女' : '男');
  2476. $time = explode('-',$v->birthday);
  2477. $sheet->setCellValueByColumnAndRow(3, $k+2, 2021-$time[0]);
  2478. $sheet->setCellValueExplicitByColumnAndRow(4, $k+2, $v->mobile, DataType::TYPE_STRING);
  2479. $sheet->setCellValueExplicitByColumnAndRow(5, $k+2, $v->card, DataType::TYPE_STRING);
  2480. $sheet->setCellValueByColumnAndRow(6, $k+2, $post_data[$v->post_id]);
  2481. }
  2482. $file_name = '名单';
  2483. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2484. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2485. header('Cache-Control: max-age=0');
  2486. // If you're serving to IE 9, then the following may be needed
  2487. header('Cache-Control: max-age=1');
  2488. // If you're serving to IE over SSL, then the following may be needed
  2489. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2490. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2491. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2492. header('Pragma: public'); // HTTP/1.0
  2493. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2494. $writer->save('php://output');
  2495. dd($list);
  2496. // $ids = [6,7,121,47,181,66,108,138,21,212,177,130,114,27,63,31,51];
  2497. // $data = RecruitAppointInfo::whereIn('id',$ids)->get();
  2498. // $post_data = RecruitPost::where('recruit_id',1)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2499. //
  2500. //
  2501. // foreach ($data as $k => $v){
  2502. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_face_ticket.docx");
  2503. // $templateProcessor->setValue('realname', $v->realname);
  2504. // $templateProcessor->setValue('card', $v->card);
  2505. // $templateProcessor->setValue('post', $post_data[$v->post_id]);
  2506. // $name = 'jjhc';
  2507. // $date = '2020-11-30';
  2508. // if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face")){
  2509. // Storage::makeDirectory("public/recruit/ticket/word/{$date}/{$name}/face");
  2510. // }
  2511. // $filename = $v->realname . '_' . $v->card . '_' . $post_data[$v->post_id];
  2512. // $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';
  2513. // $templateProcessor->saveAs($word_url);//另存为
  2514. // }
  2515. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_pen_ticket.docx");
  2516. //
  2517. //
  2518. // $templateProcessor->setImageValue('avatar',['path' => 'https://www.jucai.gov.cn/storage/-1ae05561c7f32869.jpg', 'width' => 200, 'height' => 150]);
  2519. // $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/ticket/template/test.docx");//另存为
  2520. //shell_exec('libreoffice6.4 --headless --convert-to pdf:writer_pdf_Export ' . base_path() . "/storage/app/public/recruit/ticket/template/test.docx " . base_path() ."/storage/app/public/recruit/ticket/template/test.pdf");
  2521. //libreoffice --headless --convert-to pdf:writer_pdf_Export /data/wwwroot/jucai/storage/app/public/recruit/word/2020-11-30/jjhc/pen/*.docx --outdir /data/wwwroot/jucai/storage/app/public/recruit/pdf/2020-11-30/jjhc/pen
  2522. }
  2523. }