RecruitController.php 130 KB

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