RecruitController.php 96 KB

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