RecruitController.php 142 KB

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