RecruitController.php 132 KB

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