RecruitController.php 106 KB

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