RecruitController.php 95 KB

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