RecruitController.php 118 KB

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