RecruitController.php 97 KB

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