RecruitController.php 143 KB

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