RecruitController.php 147 KB

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