RecruitController.php 141 KB

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