RecruitController.php 146 KB

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