RecruitController.php 146 KB

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