RecruitController.php 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711
  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)->where('type','supplement')->first();
  853. if(!$info){
  854. $view_data['switch'] = 0;
  855. $view_data['photos'] = [
  856. 'identification'=>[],
  857. 'household_register' => [],
  858. 'education_certification'=>[],
  859. 'family_planning'=>[],
  860. 'manage' => []
  861. ];
  862. }else{
  863. $view_data['switch'] = 1;
  864. $photos = [
  865. 'identification'=>[],
  866. 'household_register' => [],
  867. 'education_certification'=>[],
  868. 'family_planning'=>[],
  869. 'manage' => []
  870. ];
  871. $info->identification = json_decode($info->identification);
  872. $photo_data = [];
  873. if(is_array($info->identification)){
  874. foreach ($info->identification as $k => $v) {
  875. if($v->status){
  876. $photo_data[] = [
  877. 'alt' => $v->name,
  878. 'pid' => $v->uid,
  879. 'src' => $v->response->path,
  880. ];
  881. }
  882. }
  883. }
  884. $photos['identification'] = [
  885. 'title' => '身份证明',
  886. 'id' => 1,
  887. 'start' => 0,
  888. 'data' =>$photo_data
  889. ];
  890. $info->household_register = json_decode($info->household_register);
  891. $photo_data = [];
  892. if(is_array($info->household_register)){
  893. foreach ($info->household_register as $k => $v) {
  894. if($v->status){
  895. $photo_data[] = [
  896. 'alt' => $v->name,
  897. 'pid' => $v->uid,
  898. 'src' => $v->response->path,
  899. ];
  900. }
  901. }
  902. }
  903. $photos['household_register'] = [
  904. 'title' => '户口簿',
  905. 'id' => 1,
  906. 'start' => 0,
  907. 'data' =>$photo_data
  908. ];
  909. $info->education_certification = json_decode($info->education_certification);
  910. $photo_data = [];
  911. if(is_array($info->education_certification)){
  912. foreach ($info->education_certification as $k => $v) {
  913. if($v->status){
  914. $photo_data[] = [
  915. 'alt' => $v->name,
  916. 'pid' => $v->uid,
  917. 'src' => $v->response->path,
  918. ];
  919. }
  920. }
  921. }
  922. $photos['education_certification'] = [
  923. 'title' => '教育证明',
  924. 'id' => 1,
  925. 'start' => 0,
  926. 'data' =>$photo_data
  927. ];
  928. // $info->family_planning = json_decode($info->family_planning);
  929. // $photo_data = [];
  930. // foreach ($info->family_planning as $k => $v) {
  931. // if($v->status){
  932. // $photo_data[] = [
  933. // 'alt' => $v->name,
  934. // 'pid' => $v->uid,
  935. // 'src' => $v->response->path,
  936. // ];
  937. // }
  938. // }
  939. // $photos['family_planning'] = [
  940. // 'title' => '计生证明',
  941. // 'id' => 1,
  942. // 'start' => 0,
  943. // 'data' =>$photo_data
  944. // ];
  945. $info->manage = json_decode($info->manage);
  946. $photo_data = [];
  947. if(is_array($info->manage)){
  948. foreach ($info->manage as $k => $v) {
  949. if($v->status){
  950. $photo_data[] = [
  951. 'alt' => $v->name,
  952. 'pid' => $v->uid,
  953. 'src' => $v->response->path,
  954. ];
  955. }
  956. }
  957. }
  958. $photos['manage'] = [
  959. 'title' => '综治证明',
  960. 'id' => 1,
  961. 'start' => 0,
  962. 'data' =>$photo_data
  963. ];
  964. $view_data['info'] = $info;
  965. $view_data['photos'] = $photos;
  966. }
  967. return response(['data' => view('admin.recruit.ajax_supplement')->with($view_data)->render(), 'status' => 1], '200');
  968. }
  969. /**
  970. * 健康信息审核
  971. * @param Request $request
  972. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  973. * @throws \Throwable
  974. */
  975. public function ajax_health(Request $request)
  976. {
  977. Permission::check('recruit_ajax_health');
  978. $ids = $request->ids;
  979. $type = $request->type;
  980. $view_data['ids'] = $ids;
  981. $info = RecruitSupplement::where('appoint_id',$ids)->where("type",$type)->first();
  982. $view_data['type'] = $type;
  983. if(!$info){
  984. $view_data['switch'] = 0;
  985. $view_data['photos'] = [];
  986. }else{
  987. $view_data['switch'] = 1;
  988. $photos = [
  989. 'health_code'=>[],
  990. 'trip_code' => []
  991. ];
  992. $info->health_code = json_decode($info->health_code);
  993. $photo_data = [];
  994. if(is_array($info->health_code)){
  995. foreach ($info->health_code as $k => $v) {
  996. if($v->status){
  997. $photo_data[] = [
  998. 'alt' => $v->name,
  999. 'pid' => $v->uid,
  1000. 'src' => $v->response->path,
  1001. ];
  1002. }
  1003. }
  1004. }
  1005. $photos['health_code'] = [
  1006. 'title' => '健康码',
  1007. 'id' => 1,
  1008. 'start' => 0,
  1009. 'data' =>$photo_data
  1010. ];
  1011. $info->trip_code = json_decode($info->trip_code);
  1012. $photo_data = [];
  1013. if(is_array($info->trip_code)){
  1014. foreach ($info->trip_code as $k => $v) {
  1015. if($v->status){
  1016. $photo_data[] = [
  1017. 'alt' => $v->name,
  1018. 'pid' => $v->uid,
  1019. 'src' => $v->response->path,
  1020. ];
  1021. }
  1022. }
  1023. }
  1024. $photos['trip_code'] = [
  1025. 'title' => '行程码',
  1026. 'id' => 1,
  1027. 'start' => 0,
  1028. 'data' =>$photo_data
  1029. ];
  1030. $view_data['info'] = $info;
  1031. $view_data['photos'] = $photos;
  1032. }
  1033. return response(['data' => view('admin.recruit.ajax_health')->with($view_data)->render(), 'status' => 1], '200');
  1034. }
  1035. /**
  1036. * 报名记录审核处理
  1037. * @param Request $request
  1038. * @return \Illuminate\Http\JsonResponse
  1039. */
  1040. public function appoint_audit(Request $request)
  1041. {
  1042. $ids = $request->ids;
  1043. if (!is_array($ids)) {
  1044. $ids = explode(",", $ids);
  1045. }
  1046. if (empty($ids)) {
  1047. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1048. }
  1049. $audit = $request->audit;
  1050. $exam_flow_path = $request->exam_flow_path;
  1051. $reason = $request->reason;
  1052. if(empty($audit)){
  1053. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1054. }
  1055. if($audit == '3' && empty($exam_flow_path)){
  1056. return response()->json(['status' => 0, 'msg' => '请选择审核后的考试流程!'], '200');
  1057. }
  1058. if($audit != '3' && empty($reason)){
  1059. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1060. }
  1061. $message = [];
  1062. switch ($audit){
  1063. case '1':
  1064. //撤回至未审核
  1065. foreach ($ids as $k => $v){
  1066. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1067. if(!$appointinfo || intval($appointinfo->audit) === 1){
  1068. continue;
  1069. }
  1070. //设置该报名的各个状态
  1071. $appointinfo_data = [
  1072. 'current' => 1,
  1073. 'audit' => 1,
  1074. 'pen_audit' => -1,
  1075. 'computer_audit' => -1,
  1076. 'face_audit' => -1,
  1077. 'reexamine_audit' => -1,
  1078. 'inspect_audit' => -1,
  1079. 'political_audit' => -1,
  1080. 'employ_audit' => -1
  1081. ];
  1082. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1083. //写日志
  1084. $log = [
  1085. 'type' => 2,
  1086. 'step' => 1,
  1087. 'appoint_id' => $v,
  1088. 'uid' => Admin::user()->id,
  1089. 'log' => '撤回至未审核状态,原因是:'.$reason
  1090. ];
  1091. RecruitAppointLog::create($log);
  1092. $message[$v] = '您此次的报名需要重新审核,原因是:'.$reason;
  1093. }
  1094. break;
  1095. case '2':
  1096. //审核未通过
  1097. foreach ($ids as $k => $v){
  1098. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1099. if(!$appointinfo || intval($appointinfo->audit) === 2){
  1100. continue;
  1101. }
  1102. //设置该报名的各个状态
  1103. $appointinfo_data = [
  1104. 'current' => 1,
  1105. 'audit' => 2,
  1106. 'pen_audit' => -1,
  1107. 'computer_audit' => -1,
  1108. 'face_audit' => -1,
  1109. 'reexamine_audit' => -1,
  1110. 'inspect_audit' => -1,
  1111. 'political_audit' => -1,
  1112. 'employ_audit' => -1
  1113. ];
  1114. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1115. //写日志
  1116. $log = [
  1117. 'type' => 2,
  1118. 'step' => 1,
  1119. 'appoint_id' => $v,
  1120. 'uid' => Admin::user()->id,
  1121. 'log' => '审核未通过,原因是:'.$reason
  1122. ];
  1123. RecruitAppointLog::create($log);
  1124. $message[$v] = '您此次报名审核未通过,原因是:'.$reason;
  1125. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1126. }
  1127. break;
  1128. case '3':
  1129. //审核通过
  1130. foreach ($ids as $k => $v){
  1131. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  1132. if(!$appointinfo || intval($appointinfo->audit) === 3){
  1133. continue;
  1134. }
  1135. $recruit = Recruit::where('id',$appointinfo->recruit_id)->first();
  1136. $step = explode(',',$recruit->step);
  1137. $step_str = [
  1138. 'pen' => '未设置此条报名记录的笔试信息',
  1139. ];
  1140. if(in_array('3',$step)){
  1141. //场次有设置笔试
  1142. if(in_array('pen',$exam_flow_path)){
  1143. $step_str['pen'] = '该场次需要笔试,已设置此条报考需要参与笔试';
  1144. $pen_audit = -1;
  1145. }else{
  1146. $step_str['pen'] = '该场次需要笔试,此条报考可跳过笔试';
  1147. $pen_audit = 3;
  1148. }
  1149. }else{
  1150. $step_str['pen'] = '该场次不需要笔试';
  1151. $pen_audit = 3;
  1152. }
  1153. if(in_array('4',$step)){
  1154. //场次有设置上机
  1155. if(in_array('computer',$exam_flow_path)){
  1156. $step_str['computer'] = '该场次需要上机,已设置此条报考需要参与上机';
  1157. $computer_audit = -1;
  1158. }else{
  1159. $step_str['computer'] = '该场次需要上机,此条报考可跳过上机';
  1160. $computer_audit = 3;
  1161. }
  1162. }else{
  1163. $step_str['computer'] = '该场次不需要上机';
  1164. $computer_audit = 3;
  1165. }
  1166. if(in_array('5',$step)){
  1167. //场次有设置上机
  1168. if(in_array('face',$exam_flow_path)){
  1169. $step_str['face'] = '该场次需要面试,已设置此条报考需要参与面试';
  1170. $face_audit = -1;
  1171. }else{
  1172. $step_str['face'] = '该场次需要面试,此条报考可跳过面试';
  1173. $face_audit = 3;
  1174. }
  1175. }else{
  1176. $step_str['face'] = '该场次不需要面试';
  1177. $face_audit = 3;
  1178. }
  1179. if(in_array('6',$step)){
  1180. //场次有设置复试
  1181. if(in_array('reexamine',$exam_flow_path)){
  1182. $step_str['reexamine'] = '该场次需要复试,已设置此条报考需要参与复试';
  1183. $reexamine_audit = -1;
  1184. }else{
  1185. $step_str['reexamine'] = '该场次需要复试,此条报考可跳过复试';
  1186. $reexamine_audit = 3;
  1187. }
  1188. }else{
  1189. $step_str['reexamine'] = '该场次不需要复试';
  1190. $reexamine_audit = 3;
  1191. }
  1192. //设置该报名的各个状态
  1193. $appointinfo_data = [
  1194. 'current' => 2,//审核成功后进入考试流程
  1195. 'audit' => 3,
  1196. 'pen_audit' => $pen_audit,
  1197. 'computer_audit' => $computer_audit,
  1198. 'face_audit' => $face_audit,
  1199. 'reexamine_audit' => $reexamine_audit,
  1200. 'inspect_audit' => -1,
  1201. 'political_audit' => -1,
  1202. 'employ_audit' => -1
  1203. ];
  1204. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  1205. $reason = $reason ?? '符合报考条件';
  1206. //写日志
  1207. $log = [
  1208. 'type' => 2,
  1209. 'step' => 1,
  1210. 'appoint_id' => $v,
  1211. 'uid' => Admin::user()->id,
  1212. 'log' => '审核通过,原因是:' . $reason,
  1213. 'admin_log' => implode(';',$step_str)
  1214. ];
  1215. RecruitAppointLog::create($log);
  1216. $message[$v] = '您此次报名审核已通过,原因是:' . $reason;
  1217. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1218. $this->fetch_word(['recruit_id'=>$appointinfo->recruit_id,'appoint_id'=>$appointinfo->id]);
  1219. }
  1220. break;
  1221. }
  1222. //站内信
  1223. foreach ($ids as $key => $val) {
  1224. if(array_key_exists($val,$message)){
  1225. $user_info = Member::where('id', $appointinfo->uid)->first();
  1226. Pms::write_pmsnotice($user_info->id, $user_info->username, $message[$val]);
  1227. }else{
  1228. continue;
  1229. }
  1230. }
  1231. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1232. }
  1233. /**
  1234. * 材料补登审核处理
  1235. * @param Request $request
  1236. * @return \Illuminate\Http\JsonResponse
  1237. */
  1238. public function supplement(Request $request)
  1239. {
  1240. Permission::check('ajax_supplement');
  1241. $ids = $request->ids;
  1242. if (empty($ids)) {
  1243. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1244. }
  1245. $status = $request->status;
  1246. $reason = $request->reason;
  1247. if(empty($status)){
  1248. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1249. }
  1250. if($status == -1 && empty($reason)){
  1251. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1252. }
  1253. if($status == -1){
  1254. $info = RecruitSupplement::where('appoint_id', $ids)->where('type','supplement')->first();
  1255. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1256. //写日志
  1257. $log = [
  1258. 'type' => 2,
  1259. 'step' => 1,
  1260. 'appoint_id' => $ids,
  1261. 'uid' => Admin::user()->id,
  1262. 'log' => '材料补登审核未通过,原因是:'.$reason
  1263. ];
  1264. RecruitAppointLog::create($log);
  1265. $info->status = -1;
  1266. $info->msg = $reason;
  1267. $info->save();
  1268. $appointinfo->political_audit = 0;
  1269. $appointinfo->save();
  1270. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1271. }
  1272. if($status == 1){
  1273. $reason = $reason ?? '符合报考条件';
  1274. $info = RecruitSupplement::where('appoint_id', $ids)->where('type','supplement')->first();
  1275. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1276. //写日志
  1277. $log = [
  1278. 'type' => 2,
  1279. 'step' => 1,
  1280. 'appoint_id' => $ids,
  1281. 'uid' => Admin::user()->id,
  1282. 'log' => '审核通过,原因是:' . $reason
  1283. ];
  1284. RecruitAppointLog::create($log);
  1285. $info->status = 1;
  1286. $info->msg = $reason;
  1287. $info->save();
  1288. $appointinfo->political_audit = 1;
  1289. $appointinfo->save();
  1290. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  1291. }
  1292. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1293. }
  1294. /**
  1295. * 健康信息处理
  1296. * @param Request $request
  1297. * @return \Illuminate\Http\JsonResponse
  1298. */
  1299. public function health(Request $request)
  1300. {
  1301. Permission::check('ajax_health');
  1302. $ids = $request->ids;
  1303. if (empty($ids)) {
  1304. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  1305. }
  1306. $type = $request->type;
  1307. $status = $request->h_status;
  1308. $reason = $request->reason;
  1309. if(empty($status)){
  1310. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  1311. }
  1312. if($status == -1 && empty($reason)){
  1313. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  1314. }
  1315. if($status == -1){
  1316. $info = RecruitSupplement::where('appoint_id', $ids)->where('type',$type)->first();
  1317. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1318. //写日志
  1319. $log = [
  1320. 'type' => 2,
  1321. 'step' => 1,
  1322. 'appoint_id' => $ids,
  1323. 'uid' => Admin::user()->id,
  1324. 'log' => '健康信息审核未通过,原因是:'.$reason
  1325. ];
  1326. RecruitAppointLog::create($log);
  1327. $info->h_status = -1;
  1328. $info->h_msg = $reason;
  1329. $info->save();
  1330. $appointinfo->health_audit = 0;
  1331. $appointinfo->save();
  1332. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  1333. }
  1334. if($status == 1){
  1335. $reason = $reason ?? '符合报考条件';
  1336. $info = RecruitSupplement::where('appoint_id', $ids)->where('type',$type)->first();
  1337. $appointinfo = RecruitAppointInfo::where('id', $ids)->first();
  1338. //写日志
  1339. $log = [
  1340. 'type' => 2,
  1341. 'step' => 1,
  1342. 'appoint_id' => $ids,
  1343. 'uid' => Admin::user()->id,
  1344. 'log' => '审核通过,原因是:' . $reason
  1345. ];
  1346. RecruitAppointLog::create($log);
  1347. $info->h_status = 1;
  1348. $info->h_msg = $reason;
  1349. $info->save();
  1350. $appointinfo->health_audit = 1;
  1351. $appointinfo->save();
  1352. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>"健康信息审核通过,请及时打印准考证"));
  1353. }
  1354. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  1355. }
  1356. public function fetchWord(Request $request)
  1357. {
  1358. $recruit_id = $request->recruit_id;
  1359. $appoint_id = $request->appoint_id;
  1360. if(!empty($recruit_id) && !empty($appoint_id)){
  1361. $url = $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  1362. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok', 'url' => $url]);
  1363. }else{
  1364. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  1365. }
  1366. }
  1367. /**
  1368. * 查看审核日志
  1369. * @param Request $request
  1370. * @return \Illuminate\Http\JsonResponse
  1371. */
  1372. public function showLog(Request $request)
  1373. {
  1374. Permission::check('recruit_show_log');
  1375. $id = $request->id;
  1376. $logs = RecruitAppointLog::where('appoint_id', $id)->orderBy('created_at', 'desc')->get()->toArray();
  1377. $str = "";
  1378. if ($logs) {
  1379. $str .= "<table class='table'><tr style='background:#F0F8FD'><td>审核时间</td><td>操作级别</td><td>记录类型</td><td>触发操作的人员</td><td>审核描述</td></tr>";
  1380. foreach ($logs as $k => $v) {
  1381. switch ($v['type']){
  1382. case '1':
  1383. $level = '系统级操作';
  1384. $user = '系统';
  1385. break;
  1386. case '2':
  1387. $level = '审核系列操作';
  1388. $admin = AdminUser::where('id',$v['uid'])->first();
  1389. $user = $admin->name;
  1390. break;
  1391. case '3':
  1392. $level = '用户自行操作';
  1393. $member = Member::where('id',$v['uid'])->first();
  1394. $user = $member->username;
  1395. break;
  1396. }
  1397. switch ($v['step']){
  1398. case '1':
  1399. $step = '报名及审核';
  1400. break;
  1401. case '2':
  1402. $step = '笔试';
  1403. break;
  1404. case '3':
  1405. $step = '面试';
  1406. break;
  1407. case '4':
  1408. $step = '上机';
  1409. break;
  1410. case '5':
  1411. $step = '复审';
  1412. break;
  1413. case '6':
  1414. $step = '体检';
  1415. break;
  1416. case '7':
  1417. $step = '政审';
  1418. break;
  1419. case '8':
  1420. $step = '录用';
  1421. break;
  1422. }
  1423. $str .= "<tr><td>" . $v['created_at'] . "</td><td>" . $level . "</td><td>" . $step . "</td><td>" . $user . "</td><td>" . $v['log'] . "</td></tr>\r\n";
  1424. }
  1425. $str .= "</table>";
  1426. } else {
  1427. $str = "抱歉,暂未有审核记录";
  1428. }
  1429. return response()->json(['code' => 1, 'data' => $str]);
  1430. }
  1431. /**
  1432. * 生成word版简历
  1433. * @param null $data
  1434. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1435. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1436. * @throws \PhpOffice\PhpWord\Exception\Exception
  1437. */
  1438. public function fetch_word($data = null)
  1439. {
  1440. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1441. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1442. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1443. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example.docx');
  1444. //通过setValue 方法给模板赋值
  1445. $templateProcessor->setValue('title', $recruit->name);
  1446. $templateProcessor->setValue('realname', $appoint->realname);
  1447. $templateProcessor->setValue('realname', $appoint->realname);
  1448. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1449. $templateProcessor->setValue('birthday', $appoint->birthday);
  1450. $templateProcessor->setValue('nation', $appoint->nation);
  1451. $templateProcessor->setValue('native_place', $appoint->native_place);
  1452. $templateProcessor->setValue('card', $appoint->card);
  1453. switch ($appoint->political_affiliation){
  1454. case '01':
  1455. $templateProcessor->setValue('political_affiliation', '中共党员');
  1456. break;
  1457. case '02':
  1458. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1459. break;
  1460. case '03':
  1461. $templateProcessor->setValue('political_affiliation', '共青团员');
  1462. break;
  1463. case '04':
  1464. $templateProcessor->setValue('political_affiliation', '民革党员');
  1465. break;
  1466. case '05':
  1467. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1468. break;
  1469. case '06':
  1470. $templateProcessor->setValue('political_affiliation', '民建会员');
  1471. break;
  1472. case '07':
  1473. $templateProcessor->setValue('political_affiliation', '民进会员');
  1474. break;
  1475. case '08':
  1476. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1477. break;
  1478. case '09':
  1479. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1480. break;
  1481. case '10':
  1482. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1483. break;
  1484. case '11':
  1485. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1486. break;
  1487. case '12':
  1488. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1489. break;
  1490. case '13':
  1491. $templateProcessor->setValue('political_affiliation', '群众');
  1492. }
  1493. $templateProcessor->setValue('join_time', $appoint->join_time);
  1494. $templateProcessor->setValue('house_register', $appoint->house_register);
  1495. switch ($appoint->edu_type){
  1496. case '1':
  1497. $templateProcessor->setValue('edu_type', '全日制');
  1498. break;
  1499. case '2':
  1500. $templateProcessor->setValue('edu_type', '在职教育');
  1501. break;
  1502. }
  1503. $templateProcessor->setValue('education', $appoint->education);
  1504. $templateProcessor->setValue('school', $appoint->school);
  1505. $templateProcessor->setValue('degree', $appoint->degree);
  1506. $templateProcessor->setValue('pro', $appoint->pro);
  1507. $templateProcessor->setValue('mobile', $appoint->mobile);
  1508. $templateProcessor->setValue('email', $appoint->email);
  1509. $templateProcessor->setValue('address', $appoint->address);
  1510. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1511. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1512. $templateProcessor->setValue('work', $appoint->work);
  1513. $templateProcessor->setValue('titles', $appoint->titles);
  1514. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1515. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1516. $forms = explode(',', $recruit->forms);
  1517. if(in_array('expand_special',$forms)){
  1518. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint->id)->first();
  1519. $templateProcessor->cloneBlock('special_block',1);
  1520. $templateProcessor->setValue('point_apply', $special->point_apply == 0 ? '否' : '是');
  1521. $templateProcessor->setValue('condition', $special->condition);
  1522. if($material = json_decode($special->material)){
  1523. foreach ($material as $k => $v){
  1524. $templateProcessor->setImageValue('material#'.($k+1),['src' => 'https://www.jucai.gov.cn/'.$v->url]);
  1525. }
  1526. }
  1527. }else{
  1528. $templateProcessor->cloneBlock('special_block',0);
  1529. }
  1530. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1531. if(in_array('detail',$forms)){
  1532. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1533. $templateProcessor->cloneBlock('detail_block',1);
  1534. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1535. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1536. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1537. }else{
  1538. $templateProcessor->cloneBlock('detail_block',0);
  1539. }
  1540. if($family = json_decode($appoint->family,true)){
  1541. $templateProcessor->cloneRow('family_relation',count($family));
  1542. $i = 1;
  1543. foreach ($family as $k => $v){
  1544. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1545. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1546. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1547. switch ($v['political_affiliation']){
  1548. case '01':
  1549. $political_affiliation = '中共党员';
  1550. break;
  1551. case '02':
  1552. $political_affiliation = '中共预备党员';
  1553. break;
  1554. case '03':
  1555. $political_affiliation = '共青团员';
  1556. break;
  1557. case '04':
  1558. $political_affiliation = '民革党员';
  1559. break;
  1560. case '05':
  1561. $political_affiliation = '民盟盟员';
  1562. break;
  1563. case '06':
  1564. $political_affiliation = '民建会员';
  1565. break;
  1566. case '07':
  1567. $political_affiliation = '民进会员';
  1568. break;
  1569. case '08':
  1570. $political_affiliation = '农工党党员';
  1571. break;
  1572. case '09':
  1573. $political_affiliation = '致公党党员';
  1574. break;
  1575. case '10':
  1576. $political_affiliation = '九三学社社员';
  1577. break;
  1578. case '11':
  1579. $political_affiliation = '台盟盟员';
  1580. break;
  1581. case '12':
  1582. $political_affiliation = '无党派人士';
  1583. break;
  1584. case '13':
  1585. $political_affiliation = '群众';
  1586. }
  1587. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1588. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1589. $i++;
  1590. }
  1591. }
  1592. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1593. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1594. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1595. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1596. }
  1597. $word_url = "/{$filename}.docx";
  1598. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1599. $appoint->save();
  1600. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1601. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1602. }
  1603. }
  1604. /**
  1605. * 生成word版简历
  1606. * @param null $data
  1607. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1608. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1609. * @throws \PhpOffice\PhpWord\Exception\Exception
  1610. */
  1611. public function fetch_word_internship($data = null)
  1612. {
  1613. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1614. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1615. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1616. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example_internship.docx');
  1617. //通过setValue 方法给模板赋值
  1618. $templateProcessor->setValue('title', $recruit->name);
  1619. $templateProcessor->setValue('realname', $appoint->realname);
  1620. $templateProcessor->setValue('realname', $appoint->realname);
  1621. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1622. $templateProcessor->setValue('birthday', $appoint->birthday);
  1623. $templateProcessor->setValue('nation', $appoint->nation);
  1624. $templateProcessor->setValue('native_place', $appoint->native_place);
  1625. $templateProcessor->setValue('card', $appoint->card);
  1626. switch ($appoint->political_affiliation){
  1627. case '01':
  1628. $templateProcessor->setValue('political_affiliation', '中共党员');
  1629. break;
  1630. case '02':
  1631. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1632. break;
  1633. case '03':
  1634. $templateProcessor->setValue('political_affiliation', '共青团员');
  1635. break;
  1636. case '04':
  1637. $templateProcessor->setValue('political_affiliation', '民革党员');
  1638. break;
  1639. case '05':
  1640. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1641. break;
  1642. case '06':
  1643. $templateProcessor->setValue('political_affiliation', '民建会员');
  1644. break;
  1645. case '07':
  1646. $templateProcessor->setValue('political_affiliation', '民进会员');
  1647. break;
  1648. case '08':
  1649. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1650. break;
  1651. case '09':
  1652. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1653. break;
  1654. case '10':
  1655. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1656. break;
  1657. case '11':
  1658. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1659. break;
  1660. case '12':
  1661. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1662. break;
  1663. case '13':
  1664. $templateProcessor->setValue('political_affiliation', '群众');
  1665. }
  1666. $templateProcessor->setValue('join_time', $appoint->join_time);
  1667. $templateProcessor->setValue('house_register', $appoint->house_register);
  1668. $templateProcessor->setValue('education', $appoint->education);
  1669. $templateProcessor->setValue('school', $appoint->school);
  1670. $templateProcessor->setValue('pro', $appoint->pro);
  1671. $templateProcessor->setValue('adjust', $appoint->adjust == 0 ? '否' : '是');
  1672. $templateProcessor->setValue('mobile', $appoint->mobile);
  1673. $templateProcessor->setValue('email', $appoint->email);
  1674. $templateProcessor->setValue('address', $appoint->address);
  1675. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1676. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1677. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1678. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1679. $forms = explode(',', $recruit->forms);
  1680. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1681. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1682. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1683. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1684. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1685. if($family = json_decode($appoint->family,true)){
  1686. $templateProcessor->cloneRow('family_relation',count($family));
  1687. $i = 1;
  1688. foreach ($family as $k => $v){
  1689. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1690. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1691. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1692. switch ($v['political_affiliation']){
  1693. case '01':
  1694. $political_affiliation = '中共党员';
  1695. break;
  1696. case '02':
  1697. $political_affiliation = '中共预备党员';
  1698. break;
  1699. case '03':
  1700. $political_affiliation = '共青团员';
  1701. break;
  1702. case '04':
  1703. $political_affiliation = '民革党员';
  1704. break;
  1705. case '05':
  1706. $political_affiliation = '民盟盟员';
  1707. break;
  1708. case '06':
  1709. $political_affiliation = '民建会员';
  1710. break;
  1711. case '07':
  1712. $political_affiliation = '民进会员';
  1713. break;
  1714. case '08':
  1715. $political_affiliation = '农工党党员';
  1716. break;
  1717. case '09':
  1718. $political_affiliation = '致公党党员';
  1719. break;
  1720. case '10':
  1721. $political_affiliation = '九三学社社员';
  1722. break;
  1723. case '11':
  1724. $political_affiliation = '台盟盟员';
  1725. break;
  1726. case '12':
  1727. $political_affiliation = '无党派人士';
  1728. break;
  1729. case '13':
  1730. $political_affiliation = '群众';
  1731. }
  1732. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1733. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1734. $i++;
  1735. }
  1736. }
  1737. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1738. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1739. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1740. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1741. }
  1742. $word_url = "/{$filename}.docx";
  1743. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1744. $appoint->save();
  1745. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1746. return "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1747. }
  1748. }
  1749. /**
  1750. * 将报名资料导出成ZIP压缩包
  1751. * @param Request $request
  1752. * @return \Illuminate\Http\JsonResponse
  1753. * @throws \Exception
  1754. */
  1755. public function out_zip(Request $request)
  1756. {//TODO 数据太大,无法压缩,得做成异步
  1757. Permission::check('recruit_out_excel');
  1758. $recruit_id = $request->id;
  1759. $recruit = Recruit::find($recruit_id);
  1760. if (empty($recruit)) {
  1761. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1762. }
  1763. $data = $request->all();
  1764. $where = [];
  1765. $where[] = ['audit','>',0];
  1766. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1767. $param = parse_url($data['where']);
  1768. parse_str($param['query'],$param);
  1769. if (is_array($param)) {
  1770. unset($param['id']);
  1771. foreach ($param as $k => $v) {
  1772. if ($k == 'realname') {
  1773. $where[] = [$k, 'like', "%$v%"];
  1774. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1775. $where[] = [$k, '=', $v];
  1776. }
  1777. }
  1778. }
  1779. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1780. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1781. if(in_array('expand_special',explode(',', $recruit->forms))){
  1782. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1783. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1784. $select = array_merge($select,$special_select);
  1785. }
  1786. if(in_array('detail',explode(',', $recruit->forms))){
  1787. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1788. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1789. $select = array_merge($select,$detail_select);
  1790. }
  1791. $list = $model->select($select)
  1792. ->orderBy('recruit_appoint_info.updated_at','desc')
  1793. ->get();
  1794. if(!is_dir(base_path() . "/storage/app/public/recruit/zip")){
  1795. Storage::makeDirectory("public/recruit/zip");
  1796. }
  1797. if (file_exists(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip')) {
  1798. unlink(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip');
  1799. }
  1800. if($list){
  1801. // foreach ($list as $key => $value){
  1802. // $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
  1803. // if(!is_dir($path)){
  1804. // Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
  1805. // }
  1806. // if(in_array('expand_special',explode(',', $recruit->forms))){
  1807. // $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
  1808. // $material = json_decode($special['material'],true);
  1809. // if($material){
  1810. // foreach ($material as $k => $v){
  1811. // $old_path = base_path() . "/public/" . $v['url'];
  1812. // if (file_exists($old_path)) {
  1813. // $basename = basename($old_path);
  1814. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1815. // copy($old_path, $new_path); //拷贝到新目录
  1816. // }
  1817. // }
  1818. // }
  1819. // }
  1820. // if(in_array('identification',explode(',', $recruit->forms))){
  1821. // $identification = json_decode($value->identification,true);
  1822. // if($identification){
  1823. // foreach ($identification as $k => $v){
  1824. // $old_path = base_path() . "/public/" . $v['url'];
  1825. // if (file_exists($old_path)) {
  1826. // $basename = basename($old_path);
  1827. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1828. // copy($old_path, $new_path); //拷贝到新目录
  1829. // }
  1830. // }
  1831. // }
  1832. // }
  1833. // if(in_array('education_certification',explode(',', $recruit->forms))){
  1834. // $education_certification = json_decode($value->education_certification,true);
  1835. // if($education_certification){
  1836. // foreach ($education_certification as $k => $v){
  1837. // $old_path = base_path() . "/public/" . $v['url'];
  1838. // if (file_exists($old_path)) {
  1839. // $basename = basename($old_path);
  1840. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1841. // copy($old_path, $new_path); //拷贝到新目录
  1842. // }
  1843. // }
  1844. // }
  1845. // }
  1846. // if(in_array('other_certification',explode(',', $recruit->forms))){
  1847. // $other_certification = json_decode($value->other_certification,true);
  1848. // if($other_certification){
  1849. // foreach ($other_certification as $k => $v){
  1850. // $old_path = base_path() . "/public/" . $v['url'];
  1851. // if (file_exists($old_path)) {
  1852. // $basename = basename($old_path);
  1853. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1854. // copy($old_path, $new_path); //拷贝到新目录
  1855. // }
  1856. // }
  1857. // }
  1858. // }
  1859. // copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
  1860. // }
  1861. $savename = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}.zip";
  1862. $zipper = new Zipper();
  1863. $folder = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/";//$public_path 被压缩的文件名
  1864. $zipper->make($savename)->add($folder)->close();//public_path($reduce_path) 压缩之后的文件名
  1865. // header("Content-Type: application/zip");
  1866. // header("Content-Transfer-Encoding: Binary");
  1867. // header("Content-Length: " . filesize($savename));
  1868. // header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
  1869. //
  1870. // readfile($savename);
  1871. // exit;
  1872. return response()->json(['status' => 1, 'msg' => "/zip/{$recruit->name}.zip" ], 200);
  1873. }else{
  1874. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  1875. }
  1876. }
  1877. /**
  1878. * 准考证生成界面
  1879. *
  1880. * @param Content $content
  1881. * @param Request $request
  1882. * @return Content
  1883. */
  1884. public function ticket(Content $content, Request $request)
  1885. {
  1886. $recruit_id = $request->id;
  1887. $recruit = Recruit::find($recruit_id);
  1888. return $content
  1889. ->header('准考证管理')
  1890. ->description('')
  1891. ->body(view('admin.recruit.ticket')->with(['recruit'=>$recruit]));
  1892. }
  1893. /**
  1894. * 导出excel汇总表
  1895. * @param Content $content
  1896. * @param Request $request
  1897. * @return \Illuminate\Http\JsonResponse
  1898. * @throws \PhpOffice\PhpSpreadsheet\Exception
  1899. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  1900. */
  1901. public function out_excel(Content $content, Request $request)
  1902. {
  1903. Permission::check('recruit_out_excel');
  1904. $id = $request->id;
  1905. $recruit = Recruit::find($id);
  1906. if (empty($recruit)) {
  1907. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1908. }
  1909. $data = $request->all();
  1910. $where = [];
  1911. $where[] = ['audit','>',0];
  1912. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1913. $param = parse_url($data['where']);
  1914. parse_str($param['query'],$param);
  1915. if (is_array($param)) {
  1916. unset($param['id']);
  1917. foreach ($param as $k => $v) {
  1918. if ($k == 'realname') {
  1919. $where[] = [$k, 'like', "%$v%"];
  1920. } elseif ($k == 'id') {
  1921. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  1922. } elseif($k == 'print_bs'){
  1923. $where[] = ['recruit_ticket.ex_type', '=', 1];
  1924. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1925. } elseif($k == 'print_js'){
  1926. $where[] = ['recruit_ticket.ex_type', '=', 2];
  1927. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1928. } elseif($k == 'print_ms'){
  1929. $where[] = ['recruit_ticket.ex_type', '=', 3];
  1930. $where[] = ['recruit_ticket.ex_status', '=', $v];
  1931. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1932. $where[] = [$k, '=', $v];
  1933. }
  1934. }
  1935. }
  1936. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1937. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1938. if(in_array('expand_special',explode(',', $recruit->forms))){
  1939. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1940. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1941. $select = array_merge($select,$special_select);
  1942. }
  1943. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1944. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1945. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1946. $select = array_merge($select,$detail_select);
  1947. }
  1948. $list = $model->select($select)
  1949. ->orderBy('recruit_appoint_info.updated_at','desc')
  1950. ->get();
  1951. if(count($list)){
  1952. $spreadsheet = new Spreadsheet();
  1953. $sheet = $spreadsheet->getActiveSheet();
  1954. if(in_array('internship',explode(',', $recruit->forms))){
  1955. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1956. }else{
  1957. $header = ['姓名','性别','生日','头像','民族','籍贯','报考岗位','政治面貌','入党时间','职称或职业资格','现工作单位及职务','户籍所在地','学历','学校','学位','所学专业','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1958. }
  1959. if(in_array('expand_special',explode(',', $recruit->forms))){
  1960. $special = ['是否申请加分','符合哪一项加分条件','加分佐证材料'];
  1961. $header = array_merge($header,$special);
  1962. }
  1963. if(in_array('detail',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1964. $detail = ['个人简历','培训学习经历','奖惩情况','个人介绍'];
  1965. }else{
  1966. $detail = ['个人简历'];
  1967. }
  1968. $header = array_merge($header,$detail);
  1969. $header[] = '家庭成员及其社会关系';
  1970. if(in_array('identification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1971. $header[] = '身份证明';
  1972. }
  1973. if(in_array('education_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1974. $header[] = '学历证明';
  1975. }
  1976. if(in_array('other_certification',explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))){
  1977. $header[] = '其他证明';
  1978. }
  1979. $header[] = '审核状态';
  1980. $header[] = '审核意见';
  1981. // if(in_array('3',explode(',', $recruit->step))){
  1982. // $header = array_merge($header,['笔试准考证打印','笔试审核状态','笔试结果']);
  1983. // }
  1984. // if(in_array('4',explode(',', $recruit->step))){
  1985. // $header = array_merge($header,['上机准考证打印','上机审核状态','上机结果']);
  1986. // }
  1987. // if(in_array('5',explode(',', $recruit->step))){
  1988. // $header = array_merge($header,['面试准考证打印','面试审核状态','面试结果']);
  1989. // }
  1990. // if(in_array('6',explode(',', $recruit->step))){
  1991. // $header = array_merge($header,['复试准考证打印','复试审核状态','复试结果']);
  1992. // }
  1993. // if(in_array('7',explode(',', $recruit->step))){
  1994. // $header = array_merge($header,['体检审核状态','体检结果']);
  1995. // }
  1996. // if(in_array('8',explode(',', $recruit->step))){
  1997. // $header = array_merge($header,['政审状态','政审结果']);
  1998. // }
  1999. $header[] = 'word简历的下载地址';
  2000. foreach ($header as $key => $value) {
  2001. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  2002. }
  2003. $row = 2;
  2004. $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  2005. $length = count($list);//算出该数组的长度
  2006. $last = $list[$length-1];//取出最后一个数组的值,复制给新变量,-1是因为第一个数组元素下表为0
  2007. unset($list[$length-1]);//将最后一个数组注销
  2008. $list[] = $last;//再将新变量加入到数组里
  2009. $data = [];
  2010. foreach ($list as $k => $v) {
  2011. switch ($v->political_affiliation) {
  2012. case '01':
  2013. $political_affiliation = '中共党员';
  2014. break;
  2015. case '02':
  2016. $political_affiliation = '中共预备党员';
  2017. break;
  2018. case '03':
  2019. $political_affiliation = '共青团员';
  2020. break;
  2021. case '04':
  2022. $political_affiliation = '民革党员';
  2023. break;
  2024. case '05':
  2025. $political_affiliation = '民盟盟员';
  2026. break;
  2027. case '06':
  2028. $political_affiliation = '民建会员';
  2029. break;
  2030. case '07':
  2031. $political_affiliation = '民进会员';
  2032. break;
  2033. case '08':
  2034. $political_affiliation = '农工党党员';
  2035. break;
  2036. case '09':
  2037. $political_affiliation = '致公党党员';
  2038. break;
  2039. case '10':
  2040. $political_affiliation = '九三学社社员';
  2041. break;
  2042. case '11':
  2043. $political_affiliation = '台盟盟员';
  2044. break;
  2045. case '12':
  2046. $political_affiliation = '无党派人士';
  2047. break;
  2048. case '13':
  2049. $political_affiliation = '群众';
  2050. break;
  2051. default:
  2052. $political_affiliation = '未知';
  2053. break;
  2054. }
  2055. if(in_array('internship',explode(',', $recruit->forms))){
  2056. $header = ['姓名','性别','生日','头像','民族','籍贯','报名岗位','政治面貌','入党时间','户籍所在地','年级','就读院校','所学专业','是否接受调剂','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  2057. $item = [
  2058. $v->realname,
  2059. $v->sex == 0 ? '女' : '男',
  2060. $v->birthday,
  2061. "https://www.jucai.gov.cn" . $v->avatar,
  2062. $v->nation,
  2063. $v->native_place,
  2064. $v->code . $v->name,
  2065. $political_affiliation,
  2066. $v->join_time,
  2067. $v->house_register,
  2068. $v->education,
  2069. $v->school,
  2070. $v->pro,
  2071. $v->adjust == 0 ? '否' : '是',
  2072. $v->address,
  2073. '\''.$v->card,
  2074. $v->mobile,
  2075. $v->email,
  2076. $v->concat_name,
  2077. $v->concat_mobile
  2078. ];
  2079. }else{
  2080. $item = [
  2081. $v->realname,
  2082. $v->sex == 0 ? '女' : '男',
  2083. $v->birthday,
  2084. "https://www.jucai.gov.cn" . $v->avatar,
  2085. $v->nation,
  2086. $v->native_place,
  2087. $v->code . $v->name,
  2088. $political_affiliation,
  2089. $v->join_time,
  2090. $v->titles,
  2091. $v->work,
  2092. $v->house_register,
  2093. $v->education,
  2094. $v->school,
  2095. $v->degree,
  2096. $v->pro,
  2097. $v->address,
  2098. '\''.$v->card,
  2099. $v->mobile,
  2100. $v->email,
  2101. $v->concat_name,
  2102. $v->concat_mobile
  2103. ];
  2104. }
  2105. if (in_array('expand_special', explode(',', $recruit->forms))) {
  2106. $material = json_decode($v->material, true);
  2107. $materials = [];
  2108. if($material){
  2109. foreach ($material as $key => $value) {
  2110. array_push($materials, "https://www.jucai.gov.cn" . $value['response']['path']);
  2111. }
  2112. }
  2113. $special = [
  2114. $v->point_apply == 0 ? '否' : '是',
  2115. $v->condition,
  2116. implode("\r\n", $materials)
  2117. ];
  2118. $item = array_merge($item, $special);
  2119. }
  2120. if (in_array('detail', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2121. $detail = [
  2122. $v->resume,
  2123. $v->train,
  2124. $v->rewards_and_punishments,
  2125. $v->introduce
  2126. ];
  2127. } else {
  2128. $detail = [$v->resume];
  2129. }
  2130. $item = array_merge($item, $detail);
  2131. $family = json_decode($v->family, true);
  2132. $familys = [];
  2133. foreach ($family as $val){
  2134. switch ($val['political_affiliation']) {
  2135. case '01':
  2136. $political_affiliation = '中共党员';
  2137. break;
  2138. case '02':
  2139. $political_affiliation = '中共预备党员';
  2140. break;
  2141. case '03':
  2142. $political_affiliation = '共青团员';
  2143. break;
  2144. case '04':
  2145. $political_affiliation = '民革党员';
  2146. break;
  2147. case '05':
  2148. $political_affiliation = '民盟盟员';
  2149. break;
  2150. case '06':
  2151. $political_affiliation = '民建会员';
  2152. break;
  2153. case '07':
  2154. $political_affiliation = '民进会员';
  2155. break;
  2156. case '08':
  2157. $political_affiliation = '农工党党员';
  2158. break;
  2159. case '09':
  2160. $political_affiliation = '致公党党员';
  2161. break;
  2162. case '10':
  2163. $political_affiliation = '九三学社社员';
  2164. break;
  2165. case '11':
  2166. $political_affiliation = '台盟盟员';
  2167. break;
  2168. case '12':
  2169. $political_affiliation = '无党派人士';
  2170. break;
  2171. case '13':
  2172. $political_affiliation = '群众';
  2173. break;
  2174. default:
  2175. $political_affiliation = '未知';
  2176. break;
  2177. }
  2178. $familys[] = "称谓:" . $val['relation'] . ";姓名:".$val['realname'] . ';生日:'.$val['birthday'].';政治面貌:'.$political_affiliation.';职业:'.$val['work'];
  2179. }
  2180. $item[] = implode("\r\n", $familys);
  2181. if (in_array('identification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2182. $identification = json_decode($v->identification, true);
  2183. $identifications = [];
  2184. foreach ($identification as $val){
  2185. array_push($identifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2186. }
  2187. array_push($item, implode("\r\n", $identifications));
  2188. }
  2189. if (in_array('education_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2190. $education_certification = json_decode($v->education_certification, true);
  2191. $education_certifications = [];
  2192. foreach ($education_certification as $val){
  2193. array_push($education_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2194. }
  2195. array_push($item, implode("\r\n", $education_certifications));
  2196. }
  2197. if (in_array('other_certification', explode(',', $recruit->forms)) || in_array('internship',explode(',', $recruit->forms))) {
  2198. $other_certification = json_decode($v->other_certification, true);
  2199. $other_certifications = [];
  2200. if($other_certification){
  2201. foreach ($other_certification as $val){
  2202. array_push($other_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  2203. }
  2204. }
  2205. array_push($item, implode("\r\n", $other_certifications));
  2206. }
  2207. switch (intval($v->audit)){
  2208. case 1:
  2209. $item[] = '审核中';
  2210. $item[] = '';
  2211. break;
  2212. case 2:
  2213. case 3:
  2214. $log = RecruitAppointLog::where('appoint_id', $v->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  2215. if ($log) {
  2216. $log_arr = explode(',',$log->log);
  2217. $item[] = $log_arr[0];
  2218. $item[] = $log_arr[1];
  2219. } else {
  2220. $item[] = '';
  2221. $item[] = '';
  2222. }
  2223. break;
  2224. default:
  2225. $item[] = '';
  2226. $item[] = '';
  2227. break;
  2228. }
  2229. if(empty($v->word_url)){
  2230. $item[] = "暂无";
  2231. }else{
  2232. $item[] = "https://www.jucai.gov.cn/" . $v->word_url;
  2233. }
  2234. array_push($data,$item);
  2235. }
  2236. foreach($data as $k => $v){
  2237. for ($i = 0;$i<count($v);$i++){
  2238. if($i == 18 || $i == 19 || $i == 22){
  2239. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2240. }else{
  2241. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2242. }
  2243. }
  2244. $row++;
  2245. }
  2246. $file_name = $recruit->name . date("Y-m-d",time());
  2247. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2248. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2249. header('Cache-Control: max-age=0');
  2250. // If you're serving to IE 9, then the following may be needed
  2251. header('Cache-Control: max-age=1');
  2252. // If you're serving to IE over SSL, then the following may be needed
  2253. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2254. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2255. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2256. header('Pragma: public'); // HTTP/1.0
  2257. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2258. $writer->save('php://output');
  2259. }else{
  2260. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  2261. }
  2262. }
  2263. /**
  2264. * 座位贴
  2265. * @param Content $content
  2266. * @param Request $request
  2267. * @return Content
  2268. */
  2269. public function seat_sticker(Content $content, Request $request){
  2270. $recruit_id = $request->id;
  2271. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2272. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2273. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2274. ->orderBy('recruit_ticket.ex_room','asc')
  2275. ->orderBy('recruit_ticket.ex_seat','asc')
  2276. ->get();
  2277. $data = [];
  2278. foreach ($list as $k => $v){
  2279. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2280. if(!array_key_exists($room,$data)){
  2281. $data[$room] = [];
  2282. }
  2283. $item = [
  2284. 'avatar' => $v->avatar,
  2285. 'seat' => $v->ex_seat,
  2286. 'realname' => $v->realname,
  2287. 'number' => $v->ex_number
  2288. ];
  2289. array_push($data[$room],$item);
  2290. }
  2291. //dd($data);
  2292. return $content->body(view('admin.recruit.seat_sticker')->with(['data' => $data]));
  2293. }
  2294. public function sign_table(Content $content, Request $request){
  2295. $recruit_id = $request->id;
  2296. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  2297. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  2298. ->select('recruit_appoint_info.*','recruit_ticket.*')
  2299. ->orderBy('recruit_ticket.ex_room','asc')
  2300. ->orderBy('recruit_ticket.ex_seat','asc')
  2301. ->get();
  2302. $data = [];
  2303. foreach ($list as $k => $v){
  2304. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  2305. if(!array_key_exists($room,$data)){
  2306. $data[$room] = [];
  2307. }
  2308. $item = [
  2309. 'avatar' => $v->avatar,
  2310. 'seat' => $v->ex_seat,
  2311. 'realname' => $v->realname
  2312. ];
  2313. array_push($data[$room],$item);
  2314. }
  2315. return $content->body(view('admin.recruit.sign_table')->with(['data' => $data]));
  2316. }
  2317. /**
  2318. * 上传成绩页面
  2319. *
  2320. * @access public
  2321. */
  2322. public function ajax_record(Request $request)
  2323. {
  2324. $recruit_id = $request->input('recruit_id');
  2325. if(!$recruit_id){
  2326. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2327. }
  2328. $recruit = Recruit::where('id',$recruit_id)->first();
  2329. if(empty($recruit)){
  2330. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2331. }
  2332. $view_data = [
  2333. 'recruit' => $recruit
  2334. ];
  2335. return response(['data' => view('admin.recruit.ajax_record')->with($view_data)->render(), 'status' => 1], '200');
  2336. }
  2337. public function update_record(Request $request)
  2338. {
  2339. $data = $request->all();
  2340. if(!array_key_exists('recruit_id',$data) || !$data['recruit_id']){
  2341. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2342. }
  2343. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  2344. if(empty($recruit)){
  2345. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2346. }
  2347. if(array_key_exists('pen_data',$data)){
  2348. $ticket_url = base_path() . "/storage/app/public/recruit/ticket/" . uniqid() . '.xlsx';
  2349. if(move_uploaded_file($_FILES['pen_data']['tmp_name'],$ticket_url)){
  2350. $spreadsheet = IOFactory::load($ticket_url);
  2351. $sheet = $spreadsheet->getActiveSheet();
  2352. $rowCount = $sheet->getHighestRow();
  2353. $record = [];
  2354. for($row = 2;$row<=$rowCount;$row++){
  2355. $record[$sheet->getCell("A{$row}")->getValue()] = [
  2356. 'id' => $sheet->getCell("A{$row}")->getValue(),
  2357. 'realname' => $sheet->getCell("B{$row}")->getValue(),
  2358. 'card' => $sheet->getCell("C{$row}")->getValue(),
  2359. 'ex_number' => $sheet->getCell("E{$row}")->getValue(),
  2360. 'record' => $sheet->getCell("F{$row}")->getValue(),
  2361. 'next' => $sheet->getCell("G{$row}")->getValue()
  2362. ];
  2363. }
  2364. Recruit::where('id',$data['recruit_id'])->update(['pen_status' => 1]);
  2365. $record = new TicketJob($data['recruit_id'],'pen_result',$record);
  2366. dispatch($record);
  2367. return response()->json(['status' => 1, 'msg' => '成绩上传成功'], 200);
  2368. }else{
  2369. return response()->json(['status' => 0, 'msg' => '成绩上传失败'], 200);
  2370. }
  2371. }else{
  2372. return response()->json(['status' => 0, 'msg' => '笔试成绩不存在'], 200);
  2373. }
  2374. }
  2375. public function create_record_template(Request $request){
  2376. $recruit_id = $request->input('recruit_id');
  2377. if(!$recruit_id){
  2378. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  2379. }
  2380. $recruit = Recruit::where('id',$recruit_id)->first();
  2381. if(empty($recruit)){
  2382. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  2383. }
  2384. $type = $request->input('type','pen');
  2385. switch ($type){
  2386. case 'pen':
  2387. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2388. ->where('recruit_appoint_info.audit',3)
  2389. ->where('recruit_appoint_info.pen_audit',-1)
  2390. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')
  2391. ->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2392. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2393. $data = [];
  2394. foreach ($list as $k => $v){
  2395. $item = [
  2396. $v->id,
  2397. $v->realname,
  2398. $v->card,
  2399. $post_data[$v->post_id],
  2400. $v->ex_number
  2401. ];
  2402. array_push($data,$item);
  2403. }
  2404. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2405. $sheet = $spreadsheet->getActiveSheet();
  2406. $row = 2;
  2407. foreach($data as $k => $v){
  2408. for ($i = 0;$i<count($v);$i++){
  2409. if($i == 2 || $i == 4){
  2410. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2411. }else{
  2412. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2413. }
  2414. }
  2415. $row++;
  2416. }
  2417. $file_name = $recruit->company . "_成绩表模板";
  2418. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2419. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2420. header('Cache-Control: max-age=0');
  2421. // If you're serving to IE 9, then the following may be needed
  2422. header('Cache-Control: max-age=1');
  2423. // If you're serving to IE over SSL, then the following may be needed
  2424. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2425. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2426. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2427. header('Pragma: public'); // HTTP/1.0
  2428. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2429. $writer->save('php://output');
  2430. break;
  2431. case 'face':
  2432. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)
  2433. ->where('recruit_appoint_info.audit',3)
  2434. ->where('recruit_appoint_info.face_audit',-1)
  2435. ->where(function($query){
  2436. $query->where('recruit_appoint_info.pen_audit',1)
  2437. ->orWhere('recruit_appoint_info.pen_audit',3);
  2438. })
  2439. ->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  2440. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2441. $data = [];
  2442. foreach ($list as $k => $v){
  2443. $item = [
  2444. $v->id,
  2445. $v->realname,
  2446. $v->card,
  2447. $post_data[$v->post_id],
  2448. $v->ex_number
  2449. ];
  2450. array_push($data,$item);
  2451. }
  2452. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  2453. $sheet = $spreadsheet->getActiveSheet();
  2454. $row = 2;
  2455. foreach($data as $k => $v){
  2456. for ($i = 0;$i<count($v);$i++){
  2457. if($i == 2 || $i == 4){
  2458. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  2459. }else{
  2460. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  2461. }
  2462. }
  2463. $row++;
  2464. }
  2465. $file_name = $recruit->company . "_成绩表模板";
  2466. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2467. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2468. header('Cache-Control: max-age=0');
  2469. // If you're serving to IE 9, then the following may be needed
  2470. header('Cache-Control: max-age=1');
  2471. // If you're serving to IE over SSL, then the following may be needed
  2472. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2473. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2474. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2475. header('Pragma: public'); // HTTP/1.0
  2476. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2477. $writer->save('php://output');
  2478. break;
  2479. }
  2480. }
  2481. public function ticket_template(Request $request)
  2482. {
  2483. }
  2484. public function create_ticket(Request $request)
  2485. {
  2486. $data = $request->only('recruit_id','type','channel','content','keys');
  2487. //dd($data);
  2488. }
  2489. public function test(Request $request){
  2490. $list = RecruitSupplement::where('recruit_supplement.status',1)
  2491. ->join('recruit_appoint_info', 'recruit_supplement.appoint_id', '=' , 'recruit_appoint_info.id', 'left')
  2492. ->select('recruit_appoint_info.*')
  2493. ->get();
  2494. $post_data = RecruitPost::where('recruit_id',5)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2495. $header = ['姓名','性别','年龄','联系电话','身份证号码','岗位'];
  2496. $spreadsheet = new Spreadsheet();
  2497. $sheet = $spreadsheet->getActiveSheet();
  2498. foreach ($header as $key => $value) {
  2499. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  2500. }
  2501. foreach($list as $k => $v){
  2502. $sheet->setCellValueByColumnAndRow(1, $k+2, $v->realname);
  2503. $sheet->setCellValueByColumnAndRow(2, $k+2, $v->sex == 0 ? '女' : '男');
  2504. $time = explode('-',$v->birthday);
  2505. $sheet->setCellValueByColumnAndRow(3, $k+2, 2021-$time[0]);
  2506. $sheet->setCellValueExplicitByColumnAndRow(4, $k+2, $v->mobile, DataType::TYPE_STRING);
  2507. $sheet->setCellValueExplicitByColumnAndRow(5, $k+2, $v->card, DataType::TYPE_STRING);
  2508. $sheet->setCellValueByColumnAndRow(6, $k+2, $post_data[$v->post_id]);
  2509. }
  2510. $file_name = '名单';
  2511. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  2512. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  2513. header('Cache-Control: max-age=0');
  2514. // If you're serving to IE 9, then the following may be needed
  2515. header('Cache-Control: max-age=1');
  2516. // If you're serving to IE over SSL, then the following may be needed
  2517. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  2518. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  2519. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  2520. header('Pragma: public'); // HTTP/1.0
  2521. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  2522. $writer->save('php://output');
  2523. dd($list);
  2524. // $ids = [6,7,121,47,181,66,108,138,21,212,177,130,114,27,63,31,51];
  2525. // $data = RecruitAppointInfo::whereIn('id',$ids)->get();
  2526. // $post_data = RecruitPost::where('recruit_id',1)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  2527. //
  2528. //
  2529. // foreach ($data as $k => $v){
  2530. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_face_ticket.docx");
  2531. // $templateProcessor->setValue('realname', $v->realname);
  2532. // $templateProcessor->setValue('card', $v->card);
  2533. // $templateProcessor->setValue('post', $post_data[$v->post_id]);
  2534. // $name = 'jjhc';
  2535. // $date = '2020-11-30';
  2536. // if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face")){
  2537. // Storage::makeDirectory("public/recruit/ticket/word/{$date}/{$name}/face");
  2538. // }
  2539. // $filename = $v->realname . '_' . $v->card . '_' . $post_data[$v->post_id];
  2540. // $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';
  2541. // $templateProcessor->saveAs($word_url);//另存为
  2542. // }
  2543. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_pen_ticket.docx");
  2544. //
  2545. //
  2546. // $templateProcessor->setImageValue('avatar',['path' => 'https://www.jucai.gov.cn/storage/-1ae05561c7f32869.jpg', 'width' => 200, 'height' => 150]);
  2547. // $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/ticket/template/test.docx");//另存为
  2548. //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");
  2549. //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
  2550. }
  2551. public function batchFetchWord(Request $request)
  2552. {
  2553. set_time_limit(0);
  2554. ini_set('memory_limit',-1);
  2555. $recruit_id = $request->recruit_id;
  2556. $audit = $request->audit;
  2557. if(!empty($recruit_id)){
  2558. $where = [['recruit_id','=',$recruit_id]];
  2559. if (!empty($audit)) {
  2560. if ($audit == 3) {
  2561. $where[] = ['audit','=',3];
  2562. } else {
  2563. $where[] = ['audit','!=',0];
  2564. $where[] = ['audit','!=',3];
  2565. }
  2566. } else {
  2567. $where[] = ['audit','!=',0];
  2568. }
  2569. $list = RecruitAppointInfo::where($where)->pluck('id')->all();
  2570. if (!empty($list)) {
  2571. foreach ($list as $appoint_id) {
  2572. $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  2573. }
  2574. }
  2575. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok']);
  2576. }else{
  2577. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  2578. }
  2579. }
  2580. }