RecruitController.php 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007
  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 dir\Dir;
  16. use Encore\Admin\Grid;
  17. use Encore\Admin\Form;
  18. use Encore\Admin\Show;
  19. use Encore\Admin\Layout\Content;
  20. use Encore\Admin\Facades\Admin;
  21. use Encore\Admin\Auth\Permission;
  22. use Illuminate\Http\Request;
  23. use Illuminate\Support\Facades\DB;
  24. use Illuminate\Support\Facades\Storage;
  25. use App\Models\Admin\AdminUser;
  26. use PhpOffice\PhpWord\TemplateProcessor;
  27. use Chumper\Zipper\Zipper;
  28. use App\Models\RecruitTicket;
  29. use App\Services\Common\SmsService;
  30. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  31. use PhpOffice\PhpSpreadsheet\IOFactory;
  32. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  33. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  34. use PhpOffice\PhpWord\Settings;
  35. use App\Jobs\TicketJob;
  36. class RecruitController extends Controller
  37. {
  38. private $smsService;
  39. public function __construct(SmsService $smsService)
  40. {
  41. $this->smsService = $smsService;
  42. }
  43. /**
  44. * 招考报名首页
  45. * @param Content $content
  46. * @return Content
  47. */
  48. public function index(Content $content)
  49. {
  50. return $content
  51. ->header('招考报名管理')
  52. ->description('')
  53. ->body($this->grid());
  54. }
  55. /**
  56. * 新增招考报名表单页.
  57. *
  58. * @param Content $content
  59. * @return Content
  60. */
  61. public function create(Content $content)
  62. {
  63. Permission::check('recruit_manager_create');
  64. return $content
  65. ->header('新增招聘场次')
  66. ->description('新增')
  67. ->body(view('admin.recruit.index')->with(['grid' => $this->form()->render(), 'id' => '0']));
  68. }
  69. /**
  70. * Edit interface.
  71. *
  72. * @param mixed $id
  73. * @param Content $content
  74. * @return Content
  75. */
  76. public function edit($id, Content $content)
  77. {
  78. Permission::check('recruit_manager_edit');
  79. $grid = $this->form()->edit($id)->render();
  80. return $content
  81. ->header('招考管理')
  82. ->description('编辑')
  83. ->body(view('admin.recruit.index')->with(['grid' => $grid, 'id' => $id]));
  84. }
  85. /**
  86. * Show interface.
  87. *
  88. * @param mixed $id
  89. * @param Content $content
  90. * @return Content
  91. */
  92. public function show($id, Content $content)
  93. {
  94. return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/index');
  95. }
  96. public function detail($id)
  97. {
  98. $show = new Show(Recruit::findOrFail($id));
  99. // $recruit = Recruit::findOrFail($id);
  100. $show->title('标题');
  101. $show->created_at('创建时间');
  102. return $show;
  103. }
  104. /**
  105. * 获得招考场次的岗位
  106. * @param Request $request
  107. * @return \Illuminate\Http\JsonResponse
  108. */
  109. public function getRecruitPost(Request $request)
  110. {
  111. $id = $request->id;
  112. $recruit = Recruit::find($id);
  113. $post = RecruitPost::where('recruit_id', $id)->get();
  114. return response()->json(['post' => $post, 'recruit' => $recruit], '200');
  115. }
  116. /**
  117. * Make a grid builder.
  118. *
  119. * @return Grid
  120. */
  121. protected function grid()
  122. {
  123. $grid = new Grid(new Recruit);
  124. $grid->model()->orderBy('created_at', 'DESC');
  125. $grid->model()->paginate(20);
  126. if (Admin::user()->can('recruit_manager_create')) {
  127. $grid->disableCreateButton(false);
  128. }
  129. $grid->perPages([10, 20, 30, 40, 50, 100]);
  130. $grid->id('ID');
  131. $grid->name('招考场次名称');
  132. $grid->column('current','当前阶段')->display(function ($current) {
  133. switch ($current){
  134. case '1':
  135. return '报名';
  136. break;
  137. case '2':
  138. return '审核';
  139. break;
  140. case '3':
  141. return '笔试';
  142. break;
  143. case '4':
  144. return '上机测试';
  145. break;
  146. case '5':
  147. return '面试';
  148. break;
  149. case '6':
  150. return '复试';
  151. break;
  152. case '7':
  153. return '体验';
  154. break;
  155. case '8':
  156. return '政审';
  157. break;
  158. case '9':
  159. return '公示';
  160. break;
  161. case '0':
  162. return '已结束';
  163. break;
  164. }
  165. });
  166. $grid->column('status','状态')->display(function ($status) {
  167. return $status ? '显示' : '隐藏';
  168. });
  169. $grid->created_at('创建时间');
  170. $grid->actions(function ($actions) {
  171. $actions->append('<a href="/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/recruit/appoint_list?id=' . $actions->row['id'] . '" class="btn btn-primary btn-xs" >报名管理</a>');
  172. $actions->disableEdit(false);
  173. $actions->disableDelete(false);
  174. $actions->disableView();
  175. });
  176. return $grid;
  177. }
  178. /**
  179. * 新增/修改招考场次的表单
  180. *
  181. * @return Form
  182. */
  183. protected function form()
  184. {
  185. $form = new ValidateForm(new Recruit);
  186. $form->tab('基础信息', function ($form) {
  187. $form->text('name', '招考场次名称')->rules('required|between:4,61', [
  188. 'required' => '请填写招考场次名称',
  189. 'between' => '招考场次名称长度为2~30个字符'
  190. ])->setWidth(5)->setMustMark();
  191. $form->text('company', '招聘主体')->rules('required|between:4,61', [
  192. 'required' => '请填写招聘主体',
  193. 'between' => '招聘主体长度为2~30个字符'
  194. ])->setWidth(5)->setMustMark();
  195. $form->text('name_en', '英文标识')->setWidth(5)->help('同一个招聘单位,发布的招聘场次若不在同一天,允许一样,若为空则自动生成');
  196. $form->image('small_img', '缩略图')->uniqueName()->setWidth(3);
  197. $form->switch('status', '状态')->default(1)->setMustMark();
  198. $form->switch('show_report', '显示报名人数')->default(0)->setMustMark();
  199. $form->radio('current', '当前进展')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示',0 => '已结束'])->default(1)->setMustMark();
  200. $form->checkbox('step', '招考流程')->options([1 => '报名', 2 => '审核', 3 => '笔试', 4 => '上机测试', 5 => '面试', 6 => '复试', 7 => '体检', 8 => '政审', 9 => '公示'])->default([1, 2])->setMustMark();
  201. $form->datetimeRange('apply_start', 'apply_end', '报名日期')->rules('required', array('required' => '报名日期必须设置'))->setMustMark();
  202. $form->datetimeRange('audit_start', 'audit_end', '审核日期');
  203. $form->datetimeRange('preliminary_start', 'preliminary_end', '笔试时间');
  204. $form->datetimeRange('computer_start', 'computer_end', '上机时间');
  205. $form->datetimeRange('interview_start', 'interview_end', '面试时间');
  206. $form->datetimeRange('reexamine_start', 'reexamine_end', '复试时间');
  207. $form->datetimeRange('health_start', 'health_end', '体检时间');
  208. $form->datetimeRange('political_start', 'political_end', '政审时间');
  209. $form->datetimeRange('publicity_start', 'publicity_end', '公示时间');
  210. $form->editor('introduction', '招考正文')->rules('required', array('required' => '招考正文不能为空。'))->setMustMark();
  211. $form->text('contact', '联系人');
  212. $form->text('phone', '联系电话');
  213. $form->text('host_address', '联系地址');
  214. //$form->switch('predetermined_status', '是否允许报名')->states($display_option)->default(1)->setMustMark();
  215. $form->number('ordid', '排序')->default(0);
  216. $form->multipleFile('addFile', '附件')->move('storage/app/public/recruit/' . time());
  217. })->tab('报名表单与条件', function ($form) {
  218. $form->checkbox('forms', '报名表单模块')->options(['basic' => '基础信息模块','expand_special' => '扩展模块-加分','detail' => '详情介绍模块','identification' => '身份证明上传模块','education_certification' => '学历证明上传模块','other_certification' => '其他证明上传模块', 'remark' => '备注模块'])->default(['basic'])->setMustMark();
  219. $form->text('limit_times', '报名次数限制')->rules('required|regex:/^\d+$/', [
  220. 'required' => '报名限制次数必须填写',
  221. 'regex' => '次数必须为数字'
  222. ])->default(1)->help('同一个场次允许同时报名几个岗位,直接输入数字即可');
  223. $form->text('post_times', '审核次数限制')->rules('required|regex:/^\d+$/', [
  224. 'required' => '审核限制次数必须填写',
  225. 'regex' => '次数必须为数字'
  226. ])->default(1)->help('允许提交审核的次数,直接输入数字即可');
  227. $form->radio('pay_switch', '缴费报名')->options([0 => '否', 1 => '是'])->default(0);
  228. })->tab('笔试', function ($form) {
  229. $form->radio('pen_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信'])->default(-1);
  230. $form->text('pen_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识');
  231. $form->listbox('pen_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('pen'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  232. })->tab('上机', function ($form) {
  233. $form->radio('computer_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信'])->default(-1);
  234. $form->text('computer_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识');
  235. $form->listbox('computer_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('computer'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  236. })->tab('面试', function ($form) {
  237. $form->radio('face_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信'])->default(-1);
  238. $form->text('face_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识');
  239. $form->listbox('face_ticket_field', '模板字段')->options(RecruitTicketField::ticketFieldData('face'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  240. })->tab('复试', function ($form) {
  241. $form->radio('reexamine_ticket_type', '准考证类型')->options([-1 => '不需要',1 => '纸质', 2 => '短信'])->default(-1);
  242. $form->text('reexamine_ticket_content', '准考证内容')->help('当类型为纸质时,此处填入准考证模板的路径,当类型为短信时,此处填入短信标识');
  243. $form->listbox('reexamine_field', '模板字段')->options(RecruitTicketField::ticketFieldData('reexamine'))->attribute('hight', '200px')->help('仅纸质准考证需要,非ex开头的字段将自动渲染');
  244. });
  245. return $form;
  246. }
  247. /**
  248. * Make a form builder.
  249. *
  250. * @return Form
  251. */
  252. public function store(Request $request)
  253. {
  254. $verify = $this->form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  255. $postCode = $request->input('postcode', []);
  256. $postName = $request->input('postname', []);
  257. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  258. return admin_toastr('请填写招考岗位', 'error');
  259. }
  260. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  261. return admin_toastr('请填写招考岗位名称', 'error');
  262. }
  263. $data = [];
  264. $data['name'] = $verify['name'];
  265. $data['company'] = $verify['company'];
  266. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  267. if(array_key_exists('small_img',$verify)){
  268. $data['small_img'] = $verify['small_img'];
  269. }else{
  270. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  271. }
  272. $data['status'] = $verify['status'];
  273. $data['show_report'] = $verify['show_report'];
  274. $data['current'] = $verify['current'];
  275. $data['step'] = implode(',',array_filter($verify['step']));
  276. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  277. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  278. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  279. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  280. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  281. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  282. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  283. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  284. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  285. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  286. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  287. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  288. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  289. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  290. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  291. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  292. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  293. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  294. $data['introduction'] = $verify['introduction'];
  295. $data['host_address'] = $verify['host_address'];
  296. $data['contact'] = $verify['contact'];
  297. $data['phone'] = $verify['phone'];
  298. $data['ordid'] = $verify['ordid'];
  299. $data['limit_times'] = $verify['limit_times'];
  300. $data['post_times'] = $verify['post_times'];
  301. $data['pay_switch'] = $verify['pay_switch'];
  302. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  303. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  304. $data['pen_ticket_status'] = 0;
  305. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  306. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  307. $data['computer_ticket_status'] = 0;
  308. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  309. $data['face_ticket_type'] = $verify['face_ticket_type'];
  310. $data['face_ticket_content'] = $verify['face_ticket_content'];
  311. $data['face_ticket_status'] = 0;
  312. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  313. $fileCharater = $request->input('addFile');
  314. DB::beginTransaction();//检查数据库事务
  315. try {
  316. $recruit = Recruit::create($data);
  317. $recruit_id = $recruit->id;
  318. //添加招聘岗位
  319. $postcode_array = $request->postcode;
  320. $postname_array = $request->postname;
  321. $postnumber_array = $request->postnumber;
  322. $limit_array = $request->postlimit;
  323. $countnum = count($postcode_array);
  324. for ($i = 0; $i < $countnum; $i++) {
  325. $data = array();
  326. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  327. $data['code'] = $postcode_array[$i];
  328. $data['name'] = $postname_array[$i];
  329. $data['number'] = $postnumber_array[$i];
  330. $data['limit'] = $limit_array[$i];
  331. $data['status'] = 1;
  332. $data['recruit_id'] = $recruit_id;
  333. RecruitPost::create($data);
  334. }
  335. }
  336. if (!empty($fileCharater)) {
  337. foreach ($fileCharater as $f => $fv) {
  338. $picpath = 'recruit/' . date('Ymd', time()) . '/';
  339. //获取文件的扩展名
  340. $ext = $fv->getClientOriginalExtension();
  341. //获取文件的绝对路径
  342. $path = $fv->getRealPath();
  343. //定义文件名
  344. $filename = time() . rand(100, 999) . '.' . $ext;
  345. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  346. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  347. $data = $picpath . $filename;
  348. $create_arr = [
  349. 'recruit_id' => $recruit_id,
  350. 'subjoin_name' => $fv->getClientOriginalName(),
  351. 'subjoin_path' => $data,
  352. 'subjoin_addtime' => time()
  353. ];
  354. RecruitSubjoin::create($create_arr);
  355. }
  356. }
  357. DB::commit();//检查数据库事务
  358. } catch (\Exception $e) {
  359. DB::rollback();
  360. return admin_toastr($e->getMessage(), 'error');
  361. }
  362. }
  363. /**
  364. * 更新报名场次信息
  365. * @param $id
  366. * @param Request $request
  367. */
  368. public function update($id, Request $request)
  369. {
  370. $verify = $this->Form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
  371. $postCode = $request->input('postcode', []);
  372. $postName = $request->input('postname', []);
  373. if (count($postCode) == 0 or (count($postCode) >= 1 and $postCode[0] == null)) {
  374. return admin_toastr('请填写招考岗位', 'error');
  375. }
  376. if (count($postName) == 0 or (count($postName) >= 1 and $postName[0] == null)) {
  377. return admin_toastr('请填写招考岗位名称', 'error');
  378. }
  379. $recruit_id = $id;
  380. $data = [];
  381. $data['name'] = $verify['name'];
  382. $data['company'] = $verify['company'];
  383. $data['name_en'] = (array_key_exists('name_en',$verify) && !empty($verify['name_en'])) ? $verify['name_en'] : uniqid();
  384. if(array_key_exists('small_img',$verify)){
  385. $data['small_img'] = $verify['small_img'];
  386. }else{
  387. $data['small_img'] = theme_asset('app/images/index/recruit_index.jpg');
  388. }
  389. $data['status'] = $verify['status'];
  390. $data['show_report'] = $verify['show_report'];
  391. $data['current'] = $verify['current'];
  392. $data['step'] = implode(',',array_filter($verify['step']));
  393. $data['apply_start'] = $verify['apply_start'] ? $verify['apply_start'] : null;//报名时间
  394. $data['apply_end'] = $verify['apply_end'] ? $verify['apply_end'] : null;
  395. $data['audit_start'] = $verify['audit_start'] ? $verify['audit_start'] : null;//审核时间
  396. $data['audit_end'] = $verify['audit_end'] ? $verify['audit_end'] : null;
  397. $data['preliminary_start'] = $verify['preliminary_start'] ? $verify['preliminary_start'] : null;//笔试时间
  398. $data['preliminary_end'] = $verify['preliminary_end'] ? $verify['preliminary_end'] : null;
  399. $data['computer_start'] = $verify['computer_start'] ? $verify['computer_start'] : null;//上机时间
  400. $data['computer_end'] = $verify['computer_end'] ? $verify['computer_end'] : null;
  401. $data['interview_start'] = $verify['interview_start'] ? $verify['interview_start'] : null;//面试时间
  402. $data['interview_end'] = $verify['interview_end'] ? $verify['interview_end'] : null;
  403. $data['reexamine_start'] = $verify['reexamine_start'] ? $verify['reexamine_start'] : null;//复试时间
  404. $data['reexamine_end'] = $verify['reexamine_end'] ? $verify['reexamine_end'] : null;
  405. $data['health_start'] = $verify['health_start'] ? $verify['health_start'] : null;//体检时间
  406. $data['health_end'] = $verify['health_end'] ? $verify['health_end'] : null;
  407. $data['political_start'] = $verify['political_start'] ? $verify['political_start'] : null;//政审时间
  408. $data['political_end'] = $verify['political_end'] ? $verify['political_end'] : null;
  409. $data['publicity_start'] = $verify['publicity_start'] ? $verify['publicity_start'] : null;//公示时间
  410. $data['publicity_end'] = $verify['publicity_end'] ? $verify['publicity_end'] : null;
  411. $data['introduction'] = $verify['introduction'];
  412. $data['host_address'] = $verify['host_address'];
  413. $data['contact'] = $verify['contact'];
  414. $data['phone'] = $verify['phone'];
  415. $data['ordid'] = $verify['ordid'];
  416. $data['limit_times'] = $verify['limit_times'];
  417. $data['post_times'] = $verify['post_times'];
  418. $data['pay_switch'] = $verify['pay_switch'];
  419. $data['forms'] = implode(',',array_filter($verify['forms']));
  420. $data['pen_ticket_type'] = $verify['pen_ticket_type'];
  421. $data['pen_ticket_content'] = $verify['pen_ticket_content'];
  422. $data['pen_ticket_status'] = 0;
  423. $data['pen_ticket_field'] = implode(',',$verify['pen_ticket_field']);
  424. $data['computer_ticket_type'] = $verify['computer_ticket_type'];
  425. $data['computer_ticket_content'] = $verify['computer_ticket_content'];
  426. $data['computer_ticket_status'] = 0;
  427. $data['computer_ticket_field'] = implode(',',$verify['computer_ticket_field']);
  428. $data['face_ticket_type'] = $verify['face_ticket_type'];
  429. $data['face_ticket_content'] = $verify['face_ticket_content'];
  430. $data['face_ticket_status'] = 0;
  431. $data['face_ticket_field'] = implode(',',$verify['face_ticket_field']);
  432. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  433. $fileCharater = $request->input('addFile');
  434. DB::beginTransaction();//检查数据库事务
  435. try {
  436. Recruit::where('id', $recruit_id)->update($data);
  437. $postcode_array = $request->postcode;
  438. $postname_array = $request->postname;
  439. $postnumber_array = $request->postnumber;
  440. $limit_array = $request->postlimit;
  441. $postid_arr = $request->postid_arr;
  442. $countnum = count($postcode_array);
  443. if ($countnum > 0) {
  444. $ids = RecruitPost::where('recruit_id', $recruit_id)->pluck('id');
  445. if (count($postid_arr) == 0) {//没有提交岗位代表删除岗位
  446. RecruitPost::where('recruit_id', $recruit_id)->delete();
  447. } else {
  448. foreach ($ids as $key => $value) {
  449. if (!in_array($value, $postid_arr)) {
  450. $post_is_create = RecruitAppointInfo::where('post_id', $value)->first();
  451. if (empty($post_is_create)) {
  452. //有报名信息的岗位不能删除
  453. RecruitPost::destroy($value);
  454. }
  455. }
  456. }
  457. }
  458. for ($i = 0; $i < $countnum; $i++) {
  459. $data = array();
  460. if ($postcode_array[$i] !== '' and $postname_array[$i] !== '') {
  461. if (isset($postid_arr[$i])) {
  462. $post_id = $postid_arr[$i];
  463. $data['code'] = $postcode_array[$i];
  464. $data['name'] = $postname_array[$i];
  465. $data['number'] = $postnumber_array[$i];
  466. $data['limit'] = $limit_array[$i];
  467. $data['recruit_id'] = $recruit_id;
  468. RecruitPost::where('id', $post_id)->update($data);
  469. } else {
  470. $data['code'] = $postcode_array[$i];
  471. $data['name'] = $postname_array[$i];
  472. $data['number'] = $postnumber_array[$i];
  473. $data['limit'] = $limit_array[$i];
  474. $data['recruit_id'] = $recruit_id;
  475. RecruitPost::create($data);
  476. }
  477. }
  478. }
  479. } else {
  480. RecruitPost::where('recruit_id', $recruit_id)->delete();
  481. }
  482. $fileCharater = $request->file('addFile');
  483. if (!empty($fileCharater)) {
  484. RecruitSubjoin::where('recruit_id', $recruit_id)->delete();
  485. foreach ($fileCharater as $f => $fv) {
  486. $picpath = 'zhaokaopic/' . date('Ymd', time()) . '/';
  487. //获取文件的扩展名
  488. $ext = $fv->getClientOriginalExtension();
  489. //获取文件的绝对路径
  490. $path = $fv->getRealPath();
  491. //定义文件名
  492. $filename = time() . rand(100, 999) . '.' . $ext;
  493. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  494. Storage::disk('public')->put($picpath . $filename, file_get_contents($path));
  495. $data = $picpath . $filename;
  496. $create_arr = [
  497. 'recruit_id' => $recruit_id,
  498. 'subjoin_name' => $fv->getClientOriginalName(),
  499. 'subjoin_path' => $data,
  500. 'subjoin_addtime' => time()
  501. ];
  502. RecruitSubjoin::create($create_arr);
  503. }
  504. }
  505. DB::commit();
  506. return admin_toastr('操作成功!', 'success');
  507. } catch (\Exception $e) {
  508. DB::rollback();
  509. return admin_toastr($e->getMessage(), 'error');
  510. }
  511. }
  512. /**
  513. * 删掉指定招考场次
  514. * @param $id
  515. */
  516. public function destroy($id)
  517. {
  518. Permission::check('recruit_manager_del');
  519. $info = Recruit::find($id);
  520. if($info){
  521. if($info->delete()){
  522. //RecruitAppointInfo::where('recruit_id', $id)->delete(); //todo保留
  523. return response()->json(['status' => 1, 'message' => '删除成功!'], '200');
  524. }else{
  525. return response()->json(['status' => 0, 'message' => '删除失败!'], '200');
  526. }
  527. }else{
  528. return response()->json(['status' => 0, 'message' => '找不到记录!'], '200');
  529. }
  530. //Recruit::find($id)->delete();
  531. }
  532. /**
  533. * 报名管理
  534. * @param Content $content
  535. * @param Request $request
  536. * @return Content|\Illuminate\Http\RedirectResponse
  537. */
  538. public function appointList(Content $content, Request $request)
  539. {
  540. Permission::check('recruit_appoint_list');
  541. $id = $request->id;
  542. $recruit = Recruit::find($id);
  543. if (empty($recruit)) {
  544. return back();
  545. }
  546. $search_data = $request->all();
  547. $where = [];
  548. $where[] = ['audit','>',0];
  549. if (isset($search_data['id']) || session('manage_search_data')['id']) {
  550. if (isset($search_data['page'])) {
  551. if (session('search_data')) {
  552. $where = session('managewhere');
  553. unset($search_data['page']);
  554. $search_data = session('manage_search_data');
  555. }
  556. }
  557. foreach ($search_data as $k => $v) {
  558. if ($k == 'realname') {
  559. $where[] = [$k, 'like', "%$v%"];
  560. } elseif ($k == 'id') {
  561. $where[] = ['recruit_appoint_info.recruit_id', '=', $v];
  562. } elseif($k == 'print_bs'){
  563. $where[] = ['recruit_ticket.ex_type', '=', 1];
  564. $where[] = ['recruit_ticket.ex_status', '=', $v];
  565. } elseif($k == 'print_js'){
  566. $where[] = ['recruit_ticket.ex_type', '=', 2];
  567. $where[] = ['recruit_ticket.ex_status', '=', $v];
  568. } elseif($k == 'print_ms'){
  569. $where[] = ['recruit_ticket.ex_type', '=', 3];
  570. $where[] = ['recruit_ticket.ex_status', '=', $v];
  571. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  572. $where[] = [$k, '=', $v];
  573. }
  574. }
  575. session(['managewhere' => $where]);
  576. session(['manage_search_data' => $search_data]);
  577. session()->save();
  578. }
  579. $session_data = session('search_data');
  580. if(isset($session_data['perpage'])){
  581. $perpage = $session_data['perpage'];
  582. }else{
  583. $perpage = 20;
  584. }
  585. $list = RecruitAppointInfo::where($where)
  586. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  587. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  588. ->select('recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name')
  589. ->orderBy('recruit_appoint_info.updated_at','desc')
  590. ->paginate($perpage);
  591. foreach ($list as $k => $v){
  592. if($v->sex == 0){
  593. $list[$k]['sex'] = '女';
  594. }else{
  595. $list[$k]['sex'] = '男';
  596. }
  597. switch ($v->political_affiliation){
  598. case '01':
  599. $list[$k]['political_affiliation'] = '中共党员';
  600. break;
  601. case '02':
  602. $list[$k]['political_affiliation'] = '中共预备党员';
  603. break;
  604. case '03':
  605. $list[$k]['political_affiliation'] = '共青团员';
  606. break;
  607. case '04':
  608. $list[$k]['political_affiliation'] = '民革党员';
  609. break;
  610. case '05':
  611. $list[$k]['political_affiliation'] = '民盟盟员';
  612. break;
  613. case '06':
  614. $list[$k]['political_affiliation'] = '民建会员';
  615. break;
  616. case '07':
  617. $list[$k]['political_affiliation'] = '民进会员';
  618. break;
  619. case '08':
  620. $list[$k]['political_affiliation'] = '农工党党员';
  621. break;
  622. case '09':
  623. $list[$k]['political_affiliation'] = '致公党党员';
  624. break;
  625. case '10':
  626. $list[$k]['political_affiliation'] = '九三学社社员';
  627. break;
  628. case '11':
  629. $list[$k]['political_affiliation'] = '台盟盟员';
  630. break;
  631. case '12':
  632. $list[$k]['political_affiliation'] = '无党派人士';
  633. break;
  634. case '13':
  635. $list[$k]['political_affiliation'] = '群众';
  636. break;
  637. }
  638. $list[$k]['pen_print'] = 0;
  639. $list[$k]['computer_print'] = 0;
  640. $list[$k]['face_print'] = 0;
  641. $list[$k]['reexamine_print'] = 0;
  642. $tickets = RecruitTicket::where('appoint_id',$v->id)->get();
  643. if($tickets){
  644. foreach ($tickets as $tk => $tv){
  645. if($tv->ex_type == 1){
  646. $list[$k]['pen_print'] = $tv->ex_status;
  647. }
  648. if($tv->ex_type == 2){
  649. $list[$k]['computer_print'] = $tv->ex_status;
  650. }
  651. if($tv->ex_type == 3){
  652. $list[$k]['face_print'] = $tv->ex_status;
  653. }
  654. if($tv->ex_type == 4){
  655. $list[$k]['reexamine_print'] = $tv->ex_status;
  656. }
  657. }
  658. }
  659. }
  660. $post_data = RecruitPost::where('recruit_id',$id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  661. return $content
  662. ->header('报名管理')
  663. ->description('招考人员信息列表')
  664. ->body(view('admin.recruit.appoint_list')->with([
  665. 'list' => $list,
  666. 'search_data' => $search_data,
  667. 'recruit' => $recruit,
  668. 'post' => $post_data
  669. ]));
  670. }
  671. /**
  672. * 查看报名详细信息
  673. * @param Request $request
  674. * @return \Illuminate\Http\JsonResponse
  675. * @throws \Throwable
  676. */
  677. public function getUserinfo(Request $request)
  678. {
  679. Permission::check('recruit_getUserinfo');
  680. $id = $request->id;
  681. $data = RecruitAppointInfo::where('recruit_appoint_info.id',$id)
  682. ->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left')
  683. ->join('recruit_appoint_expand_special', 'recruit_appoint_info.id', '=', 'recruit_appoint_expand_special.recruit_appoint_id', 'left')
  684. ->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left')
  685. ->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')
  686. ->first();
  687. $recruit = Recruit::where('id',$data->recruit_id)->first();
  688. $recruit->forms = explode(',', $recruit->forms);
  689. $data->family = json_decode($data->family);
  690. if ($data->family) {
  691. foreach ($data->family as $k => $v) {
  692. $v->political_affiliation = RecruitAppointInfo::$political_affiliation[$v->political_affiliation];
  693. }
  694. }
  695. //layer相册层
  696. $photos = [
  697. 'material'=>[],
  698. 'identification'=>[],
  699. 'education_certification'=>[],
  700. 'other_certification'=>[],
  701. ];
  702. if(in_array('expand_special',$recruit->forms)){
  703. if(json_decode($data->material)){
  704. $data->material = json_decode($data->material);
  705. $photo_data = [];
  706. foreach ($data->material as $k => $v) {
  707. $photo_data[] = [
  708. 'alt' => $v->name,
  709. 'pid' => $v->uid,
  710. 'src' => $v->response->path,
  711. ];
  712. }
  713. $photos['material'] = [
  714. 'title' => '申请加分佐证材料',
  715. 'id' => 1,
  716. 'start' => 0,
  717. 'data' =>$photo_data
  718. ];
  719. }else{
  720. $data->material = [];
  721. }
  722. }
  723. if(in_array('identification',$recruit->forms)){
  724. if(json_decode($data->identification)){
  725. $data->identification = json_decode($data->identification);
  726. $photo_data = [];
  727. foreach ($data->identification as $k => $v) {
  728. $photo_data[] = [
  729. 'alt' => $v->name,
  730. 'pid' => $v->uid,
  731. 'src' => $v->response->path,
  732. ];
  733. }
  734. $photos['identification'] = [
  735. 'title' => '身份证明',
  736. 'id' => 1,
  737. 'start' => 0,
  738. 'data' =>$photo_data
  739. ];
  740. }else{
  741. $data->identification = [];
  742. }
  743. }
  744. if(in_array('education_certification',$recruit->forms)){
  745. if(json_decode($data->education_certification)){
  746. $data->education_certification = json_decode($data->education_certification);
  747. $photo_data = [];
  748. foreach ($data->education_certification as $k => $v) {
  749. $photo_data[] = [
  750. 'alt' => $v->name,
  751. 'pid' => $v->uid,
  752. 'src' => $v->response->path,
  753. ];
  754. }
  755. $photos['education_certification'] = [
  756. 'title' => '学历证明',
  757. 'id' => 1,
  758. 'start' => 0,
  759. 'data' =>$photo_data
  760. ];
  761. }else{
  762. $data->education_certification = [];
  763. }
  764. }
  765. if(in_array('other_certification',$recruit->forms)){
  766. if(json_decode($data->other_certification)){
  767. $data->other_certification = json_decode($data->other_certification);
  768. $photo_data = [];
  769. foreach ($data->other_certification as $k => $v) {
  770. $photo_data[] = [
  771. 'alt' => $v->name,
  772. 'pid' => $v->uid,
  773. 'src' => $v->response->path,
  774. ];
  775. }
  776. $photos['other_certification'] = [
  777. 'title' => '其他证明',
  778. 'id' => 1,
  779. 'start' => 0,
  780. 'data' =>$photo_data
  781. ];
  782. }else{
  783. $data->other_certification = [];
  784. }
  785. }
  786. $html = view('admin.recruit.manageajax_userinfo')->with(['appointinfo' => $data,'recruit' => $recruit,'photos'=>$photos])->render();
  787. return response()->json(['code' => 1, 'data' => $html]);
  788. }
  789. /**
  790. * 第一阶段(报名审核)
  791. * @param Request $request
  792. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|mixed|\Psr\Container\ContainerInterface|\Symfony\Component\HttpFoundation\Response|\think\Response
  793. * @throws \Throwable
  794. */
  795. public function ajax_audit(Request $request)
  796. {
  797. Permission::check('recruit_ajax_audit');
  798. $ids = $request->ids;
  799. $view_data['ids'] = $ids;
  800. return response(['data' => view('admin.recruit.ajax_audit')->with($view_data)->render(), 'status' => 1], '200');
  801. }
  802. /**
  803. * 报名记录审核处理
  804. * @param Request $request
  805. * @return \Illuminate\Http\JsonResponse
  806. */
  807. public function appoint_audit(Request $request)
  808. {
  809. $ids = $request->ids;
  810. if (!is_array($ids)) {
  811. $ids = explode(",", $ids);
  812. }
  813. if (empty($ids)) {
  814. return response()->json(['status' => 0, 'msg' => '请选择审核记录!'], '200');
  815. }
  816. $audit = $request->audit;
  817. $exam_flow_path = $request->exam_flow_path;
  818. $reason = $request->reason;
  819. if(empty($audit)){
  820. return response()->json(['status' => 0, 'msg' => '请选择审核状态!'], '200');
  821. }
  822. if($audit == '3' && empty($exam_flow_path)){
  823. return response()->json(['status' => 0, 'msg' => '请选择审核后的考试流程!'], '200');
  824. }
  825. if($audit != '3' && empty($reason)){
  826. return response()->json(['status' => 0, 'msg' => '请输入审核原因!'], '200');
  827. }
  828. $message = [];
  829. switch ($audit){
  830. case '1':
  831. //撤回至未审核
  832. foreach ($ids as $k => $v){
  833. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  834. if(!$appointinfo || intval($appointinfo->audit) === 1){
  835. continue;
  836. }
  837. //设置该报名的各个状态
  838. $appointinfo_data = [
  839. 'current' => 1,
  840. 'audit' => 1,
  841. 'pen_audit' => -1,
  842. 'computer_audit' => -1,
  843. 'face_audit' => -1,
  844. 'reexamine_audit' => -1,
  845. 'inspect_audit' => -1,
  846. 'political_audit' => -1,
  847. 'employ_audit' => -1
  848. ];
  849. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  850. //写日志
  851. $log = [
  852. 'type' => 2,
  853. 'step' => 1,
  854. 'appoint_id' => $v,
  855. 'uid' => Admin::user()->id,
  856. 'log' => '撤回至未审核状态,原因是:'.$reason
  857. ];
  858. RecruitAppointLog::create($log);
  859. $message[$v] = '您此次的报名需要重新审核,原因是:'.$reason;
  860. }
  861. break;
  862. case '2':
  863. //审核未通过
  864. foreach ($ids as $k => $v){
  865. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  866. if(!$appointinfo || intval($appointinfo->audit) === 2){
  867. continue;
  868. }
  869. //设置该报名的各个状态
  870. $appointinfo_data = [
  871. 'current' => 1,
  872. 'audit' => 2,
  873. 'pen_audit' => -1,
  874. 'computer_audit' => -1,
  875. 'face_audit' => -1,
  876. 'reexamine_audit' => -1,
  877. 'inspect_audit' => -1,
  878. 'political_audit' => -1,
  879. 'employ_audit' => -1
  880. ];
  881. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  882. //写日志
  883. $log = [
  884. 'type' => 2,
  885. 'step' => 1,
  886. 'appoint_id' => $v,
  887. 'uid' => Admin::user()->id,
  888. 'log' => '审核未通过,原因是:'.$reason
  889. ];
  890. RecruitAppointLog::create($log);
  891. $message[$v] = '您此次报名审核未通过,原因是:'.$reason;
  892. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_error',array('reason'=>$reason));
  893. }
  894. break;
  895. case '3':
  896. //审核通过
  897. foreach ($ids as $k => $v){
  898. $appointinfo = RecruitAppointInfo::where('id', $v)->first();
  899. if(!$appointinfo || intval($appointinfo->audit) === 3){
  900. continue;
  901. }
  902. $recruit = Recruit::where('id',$appointinfo->recruit_id)->first();
  903. $step = explode(',',$recruit->step);
  904. $step_str = [
  905. 'pen' => '未设置此条报名记录的笔试信息',
  906. ];
  907. if(in_array('3',$step)){
  908. //场次有设置笔试
  909. if(in_array('pen',$exam_flow_path)){
  910. $step_str['pen'] = '该场次需要笔试,已设置此条报考需要参与笔试';
  911. $pen_audit = -1;
  912. }else{
  913. $step_str['pen'] = '该场次需要笔试,此条报考可跳过笔试';
  914. $pen_audit = 3;
  915. }
  916. }else{
  917. $step_str['pen'] = '该场次不需要笔试';
  918. $pen_audit = 3;
  919. }
  920. if(in_array('4',$step)){
  921. //场次有设置上机
  922. if(in_array('computer',$exam_flow_path)){
  923. $step_str['computer'] = '该场次需要上机,已设置此条报考需要参与上机';
  924. $computer_audit = -1;
  925. }else{
  926. $step_str['computer'] = '该场次需要上机,此条报考可跳过上机';
  927. $computer_audit = 3;
  928. }
  929. }else{
  930. $step_str['computer'] = '该场次不需要上机';
  931. $computer_audit = 3;
  932. }
  933. if(in_array('5',$step)){
  934. //场次有设置上机
  935. if(in_array('face',$exam_flow_path)){
  936. $step_str['face'] = '该场次需要面试,已设置此条报考需要参与面试';
  937. $face_audit = -1;
  938. }else{
  939. $step_str['face'] = '该场次需要面试,此条报考可跳过面试';
  940. $face_audit = 3;
  941. }
  942. }else{
  943. $step_str['face'] = '该场次不需要面试';
  944. $face_audit = 3;
  945. }
  946. if(in_array('6',$step)){
  947. //场次有设置复试
  948. if(in_array('reexamine',$exam_flow_path)){
  949. $step_str['reexamine'] = '该场次需要复试,已设置此条报考需要参与复试';
  950. $reexamine_audit = -1;
  951. }else{
  952. $step_str['reexamine'] = '该场次需要复试,此条报考可跳过复试';
  953. $reexamine_audit = 3;
  954. }
  955. }else{
  956. $step_str['reexamine'] = '该场次不需要复试';
  957. $reexamine_audit = 3;
  958. }
  959. //设置该报名的各个状态
  960. $appointinfo_data = [
  961. 'current' => 2,//审核成功后进入考试流程
  962. 'audit' => 3,
  963. 'pen_audit' => $pen_audit,
  964. 'computer_audit' => $computer_audit,
  965. 'face_audit' => $face_audit,
  966. 'reexamine_audit' => $reexamine_audit,
  967. 'inspect_audit' => -1,
  968. 'political_audit' => -1,
  969. 'employ_audit' => -1
  970. ];
  971. RecruitAppointInfo::where('id', $v)->update($appointinfo_data);
  972. $reason = $reason ?? '符合报考条件';
  973. //写日志
  974. $log = [
  975. 'type' => 2,
  976. 'step' => 1,
  977. 'appoint_id' => $v,
  978. 'uid' => Admin::user()->id,
  979. 'log' => '审核通过,原因是:' . $reason,
  980. 'admin_log' => implode(';',$step_str)
  981. ];
  982. RecruitAppointLog::create($log);
  983. $message[$v] = '您此次报名审核已通过,原因是:' . $reason;
  984. $this->smsService->sendSms($appointinfo->mobile,'sms_recruit_register_success',array('reason'=>$reason));
  985. $this->fetch_word(['recruit_id'=>$appointinfo->recruit_id,'appoint_id'=>$appointinfo->id]);
  986. }
  987. break;
  988. }
  989. //站内信
  990. foreach ($ids as $key => $val) {
  991. if(array_key_exists($val,$message)){
  992. $user_info = Member::where('id', $appointinfo->uid)->first();
  993. Pms::write_pmsnotice($user_info->id, $user_info->username, $message[$val]);
  994. }else{
  995. continue;
  996. }
  997. }
  998. return response()->json(['status' => 1, 'msg' => '操作成功!', 'data' => 'ok']);
  999. }
  1000. public function fetchWord(Request $request)
  1001. {
  1002. $recruit_id = $request->recruit_id;
  1003. $appoint_id = $request->appoint_id;
  1004. if(!empty($recruit_id) && !empty($appoint_id)){
  1005. $this->fetch_word(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id]);
  1006. return response()->json(['status' => 1, 'msg' => '生成Word简历成功!', 'data' => 'ok']);
  1007. }else{
  1008. return response()->json(['status' => 0, 'msg' => '参数缺失!', 'data' => 'fail']);
  1009. }
  1010. }
  1011. /**
  1012. * 查看审核日志
  1013. * @param Request $request
  1014. * @return \Illuminate\Http\JsonResponse
  1015. */
  1016. public function showLog(Request $request)
  1017. {
  1018. Permission::check('recruit_show_log');
  1019. $id = $request->id;
  1020. $logs = RecruitAppointLog::where('appoint_id', $id)->orderBy('created_at', 'desc')->get()->toArray();
  1021. $str = "";
  1022. if ($logs) {
  1023. $str .= "<table class='table'><tr style='background:#F0F8FD'><td>审核时间</td><td>操作级别</td><td>记录类型</td><td>触发操作的人员</td><td>审核描述</td></tr>";
  1024. foreach ($logs as $k => $v) {
  1025. switch ($v['type']){
  1026. case '1':
  1027. $level = '系统级操作';
  1028. $user = '系统';
  1029. break;
  1030. case '2':
  1031. $level = '审核系列操作';
  1032. $admin = AdminUser::where('id',$v['uid'])->first();
  1033. $user = $admin->name;
  1034. break;
  1035. case '3':
  1036. $level = '用户自行操作';
  1037. $member = Member::where('id',$v['uid'])->first();
  1038. $user = $member->username;
  1039. break;
  1040. }
  1041. switch ($v['step']){
  1042. case '1':
  1043. $step = '报名及审核';
  1044. break;
  1045. case '2':
  1046. $step = '笔试';
  1047. break;
  1048. case '3':
  1049. $step = '面试';
  1050. break;
  1051. case '4':
  1052. $step = '上机';
  1053. break;
  1054. case '5':
  1055. $step = '复审';
  1056. break;
  1057. case '6':
  1058. $step = '体检';
  1059. break;
  1060. case '7':
  1061. $step = '政审';
  1062. break;
  1063. case '8':
  1064. $step = '录用';
  1065. break;
  1066. }
  1067. $str .= "<tr><td>" . $v['created_at'] . "</td><td>" . $level . "</td><td>" . $step . "</td><td>" . $user . "</td><td>" . $v['log'] . "</td></tr>\r\n";
  1068. }
  1069. $str .= "</table>";
  1070. } else {
  1071. $str = "抱歉,暂未有审核记录";
  1072. }
  1073. return response()->json(['code' => 1, 'data' => $str]);
  1074. }
  1075. /**
  1076. * 生成word版简历
  1077. * @param null $data
  1078. * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  1079. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  1080. * @throws \PhpOffice\PhpWord\Exception\Exception
  1081. */
  1082. public function fetch_word($data = null)
  1083. {
  1084. if($data != null && array_key_exists('recruit_id',$data) && array_key_exists('appoint_id',$data)){
  1085. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1086. $appoint = RecruitAppointInfo::where('id',$data['appoint_id'])->first();
  1087. $templateProcessor = new TemplateProcessor(base_path() . '/public/word/example.docx');
  1088. //通过setValue 方法给模板赋值
  1089. $templateProcessor->setValue('title', $recruit->name);
  1090. $templateProcessor->setValue('realname', $appoint->realname);
  1091. $templateProcessor->setValue('realname', $appoint->realname);
  1092. $templateProcessor->setValue('sex', $appoint->sex == 0 ? '女' : '男');
  1093. $templateProcessor->setValue('birthday', $appoint->birthday);
  1094. $templateProcessor->setValue('nation', $appoint->nation);
  1095. $templateProcessor->setValue('native_place', $appoint->native_place);
  1096. $templateProcessor->setValue('card', $appoint->card);
  1097. switch ($appoint->political_affiliation){
  1098. case '01':
  1099. $templateProcessor->setValue('political_affiliation', '中共党员');
  1100. break;
  1101. case '02':
  1102. $templateProcessor->setValue('political_affiliation', '中共预备党员');
  1103. break;
  1104. case '03':
  1105. $templateProcessor->setValue('political_affiliation', '共青团员');
  1106. break;
  1107. case '04':
  1108. $templateProcessor->setValue('political_affiliation', '民革党员');
  1109. break;
  1110. case '05':
  1111. $templateProcessor->setValue('political_affiliation', '民盟盟员');
  1112. break;
  1113. case '06':
  1114. $templateProcessor->setValue('political_affiliation', '民建会员');
  1115. break;
  1116. case '07':
  1117. $templateProcessor->setValue('political_affiliation', '民进会员');
  1118. break;
  1119. case '08':
  1120. $templateProcessor->setValue('political_affiliation', '农工党党员');
  1121. break;
  1122. case '09':
  1123. $templateProcessor->setValue('political_affiliation', '致公党党员');
  1124. break;
  1125. case '10':
  1126. $templateProcessor->setValue('political_affiliation', '九三学社社员');
  1127. break;
  1128. case '11':
  1129. $templateProcessor->setValue('political_affiliation', '台盟盟员');
  1130. break;
  1131. case '12':
  1132. $templateProcessor->setValue('political_affiliation', '无党派人士');
  1133. break;
  1134. case '13':
  1135. $templateProcessor->setValue('political_affiliation', '群众');
  1136. }
  1137. $templateProcessor->setValue('join_time', $appoint->join_time);
  1138. $templateProcessor->setValue('house_register', $appoint->house_register);
  1139. switch ($appoint->edu_type){
  1140. case '1':
  1141. $templateProcessor->setValue('edu_type', '全日制');
  1142. break;
  1143. case '2':
  1144. $templateProcessor->setValue('edu_type', '在职教育');
  1145. break;
  1146. }
  1147. $templateProcessor->setValue('education', $appoint->education);
  1148. $templateProcessor->setValue('school', $appoint->school);
  1149. $templateProcessor->setValue('degree', $appoint->degree);
  1150. $templateProcessor->setValue('pro', $appoint->pro);
  1151. $templateProcessor->setValue('mobile', $appoint->mobile);
  1152. $templateProcessor->setValue('email', $appoint->email);
  1153. $templateProcessor->setValue('address', $appoint->address);
  1154. $post_data = RecruitPost::where('id',$appoint->post_id)->first();
  1155. $templateProcessor->setValue('post', $post_data->code . " " . $post_data->name);
  1156. $templateProcessor->setValue('work', $appoint->work);
  1157. $templateProcessor->setValue('titles', $appoint->titles);
  1158. $templateProcessor->setValue('concat_name', $appoint->concat_name);
  1159. $templateProcessor->setValue('concat_mobile', $appoint->concat_mobile);
  1160. $forms = explode(',', $recruit->forms);
  1161. if(in_array('expand_special',$forms)){
  1162. $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint->id)->first();
  1163. $templateProcessor->cloneBlock('special_block',1);
  1164. $templateProcessor->setValue('point_apply', $special->point_apply == 0 ? '否' : '是');
  1165. $templateProcessor->setValue('condition', $special->condition);
  1166. if($material = json_decode($special->material)){
  1167. foreach ($material as $k => $v){
  1168. $templateProcessor->setImageValue('material#'.($k+1),['src' => 'https://www.jucai.gov.cn/'.$v->url]);
  1169. }
  1170. }
  1171. }else{
  1172. $templateProcessor->cloneBlock('special_block',0);
  1173. }
  1174. $templateProcessor->setValue('resume', str_replace("\n",'<w:br/>',$appoint->resume));
  1175. if(in_array('detail',$forms)){
  1176. $detail = RecruitAppointDetail::where('recruit_appoint_id',$appoint->id)->first();
  1177. $templateProcessor->cloneBlock('detail_block',1);
  1178. $templateProcessor->setValue('train', str_replace("\n",'<w:br/>',$detail->train));
  1179. $templateProcessor->setValue('rewards_and_punishments', str_replace("\n",'<w:br/>',$detail->rewards_and_punishments));
  1180. $templateProcessor->setValue('introduce', str_replace("\n",'<w:br/>',$detail->introduce));
  1181. }else{
  1182. $templateProcessor->cloneBlock('detail_block',0);
  1183. }
  1184. if($family = json_decode($appoint->family,true)){
  1185. $templateProcessor->cloneRow('family_relation',count($family));
  1186. $i = 1;
  1187. foreach ($family as $k => $v){
  1188. $templateProcessor->setValue('family_relation#'.$i, $v['relation']);
  1189. $templateProcessor->setValue('family_realname#'.$i, $v['realname']);
  1190. $templateProcessor->setValue('family_birthday#'.$i, $v['birthday']);
  1191. switch ($v['political_affiliation']){
  1192. case '01':
  1193. $political_affiliation = '中共党员';
  1194. break;
  1195. case '02':
  1196. $political_affiliation = '中共预备党员';
  1197. break;
  1198. case '03':
  1199. $political_affiliation = '共青团员';
  1200. break;
  1201. case '04':
  1202. $political_affiliation = '民革党员';
  1203. break;
  1204. case '05':
  1205. $political_affiliation = '民盟盟员';
  1206. break;
  1207. case '06':
  1208. $political_affiliation = '民建会员';
  1209. break;
  1210. case '07':
  1211. $political_affiliation = '民进会员';
  1212. break;
  1213. case '08':
  1214. $political_affiliation = '农工党党员';
  1215. break;
  1216. case '09':
  1217. $political_affiliation = '致公党党员';
  1218. break;
  1219. case '10':
  1220. $political_affiliation = '九三学社社员';
  1221. break;
  1222. case '11':
  1223. $political_affiliation = '台盟盟员';
  1224. break;
  1225. case '12':
  1226. $political_affiliation = '无党派人士';
  1227. break;
  1228. case '13':
  1229. $political_affiliation = '群众';
  1230. }
  1231. $templateProcessor->setValue('family_political_affiliation#'.$i, $political_affiliation);
  1232. $templateProcessor->setValue('family_work#'.$i, $v['work']);
  1233. $i++;
  1234. }
  1235. }
  1236. $templateProcessor->setImageValue('avatar',['path' => 'http://www.jucai.gov.cn/'.$appoint->avatar, 'width' => 200, 'height' => 150]);
  1237. $filename = $appoint->realname . '_' . $appoint->card.'_' . $post_data->code . $post_data->name;
  1238. if(!is_dir(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en)){
  1239. Storage::makeDirectory("public/recruit/word/{$recruit->name_en}");
  1240. }
  1241. $word_url = "/{$filename}.docx";
  1242. $appoint->word_url = "/storage/recruit/word/" . $recruit->name_en .$word_url;
  1243. $appoint->save();
  1244. $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/word/" . $recruit->name_en . $word_url);//另存为
  1245. }
  1246. }
  1247. /**
  1248. * 将报名资料导出成ZIP压缩包
  1249. * @param Request $request
  1250. * @return \Illuminate\Http\JsonResponse
  1251. * @throws \Exception
  1252. */
  1253. public function out_zip(Request $request)
  1254. {//TODO 数据太大,无法压缩,得做成异步
  1255. Permission::check('recruit_out_excel');
  1256. $recruit_id = $request->id;
  1257. $recruit = Recruit::find($recruit_id);
  1258. if (empty($recruit)) {
  1259. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1260. }
  1261. $data = $request->all();
  1262. $where = [];
  1263. $where[] = ['audit','>',0];
  1264. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1265. $param = parse_url($data['where']);
  1266. parse_str($param['query'],$param);
  1267. if (is_array($param)) {
  1268. unset($param['id']);
  1269. foreach ($param as $k => $v) {
  1270. if ($k == 'realname') {
  1271. $where[] = [$k, 'like', "%$v%"];
  1272. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1273. $where[] = [$k, '=', $v];
  1274. }
  1275. }
  1276. }
  1277. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1278. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1279. if(in_array('expand_special',explode(',', $recruit->forms))){
  1280. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1281. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1282. $select = array_merge($select,$special_select);
  1283. }
  1284. if(in_array('detail',explode(',', $recruit->forms))){
  1285. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1286. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1287. $select = array_merge($select,$detail_select);
  1288. }
  1289. $list = $model->select($select)
  1290. ->orderBy('recruit_appoint_info.updated_at','desc')
  1291. ->get();
  1292. if(!is_dir(base_path() . "/storage/app/public/recruit/zip")){
  1293. Storage::makeDirectory("public/recruit/zip");
  1294. }
  1295. if (file_exists(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip')) {
  1296. unlink(base_path() . '/storage/app/public/recruit/zip/' . $recruit->company . '.zip');
  1297. }
  1298. if($list){
  1299. // foreach ($list as $key => $value){
  1300. // $path = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}/";
  1301. // if(!is_dir($path)){
  1302. // Storage::makeDirectory("public/recruit/zip/{$recruit->company}/{$value->realname}_{$value->card}");
  1303. // }
  1304. // if(in_array('expand_special',explode(',', $recruit->forms))){
  1305. // $special = RecruitAppointExpandSpecial::where('recruit_appoint_id',$value->id)->first();
  1306. // $material = json_decode($special['material'],true);
  1307. // if($material){
  1308. // foreach ($material as $k => $v){
  1309. // $old_path = base_path() . "/public/" . $v['url'];
  1310. // if (file_exists($old_path)) {
  1311. // $basename = basename($old_path);
  1312. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1313. // copy($old_path, $new_path); //拷贝到新目录
  1314. // }
  1315. // }
  1316. // }
  1317. // }
  1318. // if(in_array('identification',explode(',', $recruit->forms))){
  1319. // $identification = json_decode($value->identification,true);
  1320. // if($identification){
  1321. // foreach ($identification as $k => $v){
  1322. // $old_path = base_path() . "/public/" . $v['url'];
  1323. // if (file_exists($old_path)) {
  1324. // $basename = basename($old_path);
  1325. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1326. // copy($old_path, $new_path); //拷贝到新目录
  1327. // }
  1328. // }
  1329. // }
  1330. // }
  1331. // if(in_array('education_certification',explode(',', $recruit->forms))){
  1332. // $education_certification = json_decode($value->education_certification,true);
  1333. // if($education_certification){
  1334. // foreach ($education_certification as $k => $v){
  1335. // $old_path = base_path() . "/public/" . $v['url'];
  1336. // if (file_exists($old_path)) {
  1337. // $basename = basename($old_path);
  1338. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1339. // copy($old_path, $new_path); //拷贝到新目录
  1340. // }
  1341. // }
  1342. // }
  1343. // }
  1344. // if(in_array('other_certification',explode(',', $recruit->forms))){
  1345. // $other_certification = json_decode($value->other_certification,true);
  1346. // if($other_certification){
  1347. // foreach ($other_certification as $k => $v){
  1348. // $old_path = base_path() . "/public/" . $v['url'];
  1349. // if (file_exists($old_path)) {
  1350. // $basename = basename($old_path);
  1351. // $new_path = $path . $basename; //iconv("UTF-8", "GBK", $p->picture_name);
  1352. // copy($old_path, $new_path); //拷贝到新目录
  1353. // }
  1354. // }
  1355. // }
  1356. // }
  1357. // copy(base_path() . "/public/" . $value->word_url, $path . basename($value->word_url));
  1358. // }
  1359. $savename = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}.zip";
  1360. $zipper = new Zipper();
  1361. $folder = base_path() . "/storage/app/public/recruit/zip/{$recruit->company}/";//$public_path 被压缩的文件名
  1362. $zipper->make($savename)->add($folder)->close();//public_path($reduce_path) 压缩之后的文件名
  1363. // header("Content-Type: application/zip");
  1364. // header("Content-Transfer-Encoding: Binary");
  1365. // header("Content-Length: " . filesize($savename));
  1366. // header("Content-Disposition: attachment; filename=\"" . $savename . "\"");
  1367. //
  1368. // readfile($savename);
  1369. // exit;
  1370. return response()->json(['status' => 1, 'msg' => "/zip/{$recruit->name}.zip" ], 200);
  1371. }else{
  1372. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  1373. }
  1374. }
  1375. /**
  1376. * 准考证生成界面
  1377. *
  1378. * @param Content $content
  1379. * @param Request $request
  1380. * @return Content
  1381. */
  1382. public function ticket(Content $content, Request $request)
  1383. {
  1384. $recruit_id = $request->id;
  1385. $recruit = Recruit::find($recruit_id);
  1386. return $content
  1387. ->header('准考证管理')
  1388. ->description('')
  1389. ->body(view('admin.recruit.ticket')->with(['recruit'=>$recruit]));
  1390. }
  1391. /**
  1392. * 导出excel汇总表
  1393. * @param Content $content
  1394. * @param Request $request
  1395. * @return \Illuminate\Http\JsonResponse
  1396. * @throws \PhpOffice\PhpSpreadsheet\Exception
  1397. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  1398. */
  1399. public function out_excel(Content $content, Request $request)
  1400. {
  1401. Permission::check('recruit_out_excel');
  1402. $id = $request->id;
  1403. $recruit = Recruit::find($id);
  1404. if (empty($recruit)) {
  1405. return response()->json(['status' => 0, 'msg' => '找不到对应的招考场次'], 200);
  1406. }
  1407. $data = $request->all();
  1408. $where = [];
  1409. $where[] = ['audit','>',0];
  1410. $where[] = ['recruit_appoint_info.recruit_id', '=', $data['id']];
  1411. $param = parse_url($data['where']);
  1412. parse_str($param['query'],$param);
  1413. if (is_array($param)) {
  1414. unset($param['id']);
  1415. foreach ($param as $k => $v) {
  1416. if ($k == 'realname') {
  1417. $where[] = [$k, 'like', "%$v%"];
  1418. } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
  1419. $where[] = [$k, '=', $v];
  1420. }
  1421. }
  1422. }
  1423. $select = ['recruit_appoint_info.*', 'recruit_post.code', 'recruit_post.name'];
  1424. $model = RecruitAppointInfo::where($where)->join('recruit_post', 'recruit_appoint_info.post_id', '=', 'recruit_post.id', 'left');
  1425. if(in_array('expand_special',explode(',', $recruit->forms))){
  1426. $model->join('recruit_appoint_expand_special', 'recruit_appoint_expand_special.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1427. $special_select = ['recruit_appoint_expand_special.point_apply','recruit_appoint_expand_special.condition','recruit_appoint_expand_special.material'];
  1428. $select = array_merge($select,$special_select);
  1429. }
  1430. if(in_array('detail',explode(',', $recruit->forms))){
  1431. $model->join('recruit_appoint_detail', 'recruit_appoint_detail.recruit_appoint_id', '=', 'recruit_appoint_info.id', 'left');
  1432. $detail_select = ['recruit_appoint_detail.train','recruit_appoint_detail.rewards_and_punishments','recruit_appoint_detail.introduce'];
  1433. $select = array_merge($select,$detail_select);
  1434. }
  1435. $list = $model->select($select)
  1436. ->orderBy('recruit_appoint_info.updated_at','desc')
  1437. ->get();
  1438. if(count($list)){
  1439. $spreadsheet = new Spreadsheet();
  1440. $sheet = $spreadsheet->getActiveSheet();
  1441. $header = ['姓名','性别','生日','头像','民族','籍贯','报考岗位','政治面貌','入党时间','职称或职业资格','现工作单位及职务','户籍所在地','学历','学校','学位','所学专业','通信地址','身份证号码','联系电话','电子邮箱','紧急联系人','紧急联系电话'];
  1442. if(in_array('expand_special',explode(',', $recruit->forms))){
  1443. $special = ['是否申请加分','符合哪一项加分条件','加分佐证材料'];
  1444. $header = array_merge($header,$special);
  1445. }
  1446. if(in_array('detail',explode(',', $recruit->forms))){
  1447. $detail = ['个人简历','培训学习经历','奖惩情况','个人介绍'];
  1448. }else{
  1449. $detail = ['个人简历'];
  1450. }
  1451. $header = array_merge($header,$detail);
  1452. $header[] = '家庭成员及其社会关系';
  1453. if(in_array('identification',explode(',', $recruit->forms))){
  1454. $header[] = '身份证明';
  1455. }
  1456. if(in_array('education_certification',explode(',', $recruit->forms))){
  1457. $header[] = '学历证明';
  1458. }
  1459. if(in_array('other_certification',explode(',', $recruit->forms))){
  1460. $header[] = '其他证明';
  1461. }
  1462. $header[] = '审核状态';
  1463. $header[] = '审核意见';
  1464. // if(in_array('3',explode(',', $recruit->step))){
  1465. // $header = array_merge($header,['笔试准考证打印','笔试审核状态','笔试结果']);
  1466. // }
  1467. // if(in_array('4',explode(',', $recruit->step))){
  1468. // $header = array_merge($header,['上机准考证打印','上机审核状态','上机结果']);
  1469. // }
  1470. // if(in_array('5',explode(',', $recruit->step))){
  1471. // $header = array_merge($header,['面试准考证打印','面试审核状态','面试结果']);
  1472. // }
  1473. // if(in_array('6',explode(',', $recruit->step))){
  1474. // $header = array_merge($header,['复试准考证打印','复试审核状态','复试结果']);
  1475. // }
  1476. // if(in_array('7',explode(',', $recruit->step))){
  1477. // $header = array_merge($header,['体检审核状态','体检结果']);
  1478. // }
  1479. // if(in_array('8',explode(',', $recruit->step))){
  1480. // $header = array_merge($header,['政审状态','政审结果']);
  1481. // }
  1482. $header[] = 'word简历的下载地址';
  1483. foreach ($header as $key => $value) {
  1484. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  1485. }
  1486. $row = 2;
  1487. $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  1488. $length = count($list);//算出该数组的长度
  1489. $last = $list[$length-1];//取出最后一个数组的值,复制给新变量,-1是因为第一个数组元素下表为0
  1490. unset($list[$length-1]);//将最后一个数组注销
  1491. $list[] = $last;//再将新变量加入到数组里
  1492. $data = [];
  1493. foreach ($list as $k => $v) {
  1494. switch ($v->political_affiliation) {
  1495. case '01':
  1496. $political_affiliation = '中共党员';
  1497. break;
  1498. case '02':
  1499. $political_affiliation = '中共预备党员';
  1500. break;
  1501. case '03':
  1502. $political_affiliation = '共青团员';
  1503. break;
  1504. case '04':
  1505. $political_affiliation = '民革党员';
  1506. break;
  1507. case '05':
  1508. $political_affiliation = '民盟盟员';
  1509. break;
  1510. case '06':
  1511. $political_affiliation = '民建会员';
  1512. break;
  1513. case '07':
  1514. $political_affiliation = '民进会员';
  1515. break;
  1516. case '08':
  1517. $political_affiliation = '农工党党员';
  1518. break;
  1519. case '09':
  1520. $political_affiliation = '致公党党员';
  1521. break;
  1522. case '10':
  1523. $political_affiliation = '九三学社社员';
  1524. break;
  1525. case '11':
  1526. $political_affiliation = '台盟盟员';
  1527. break;
  1528. case '12':
  1529. $political_affiliation = '无党派人士';
  1530. break;
  1531. case '13':
  1532. $political_affiliation = '群众';
  1533. break;
  1534. default:
  1535. $political_affiliation = '未知';
  1536. break;
  1537. }
  1538. $item = [
  1539. $v->realname,
  1540. $v->sex == 0 ? '女' : '男',
  1541. $v->birthday,
  1542. "https://www.jucai.gov.cn" . $v->avatar,
  1543. $v->nation,
  1544. $v->native_place,
  1545. $v->code . $v->name,
  1546. $political_affiliation,
  1547. $v->join_time,
  1548. $v->titles,
  1549. $v->work,
  1550. $v->house_register,
  1551. $v->education,
  1552. $v->school,
  1553. $v->degree,
  1554. $v->pro,
  1555. $v->address,
  1556. '\''.$v->card,
  1557. $v->mobile,
  1558. $v->email,
  1559. $v->concat_name,
  1560. $v->concat_mobile
  1561. ];
  1562. if (in_array('expand_special', explode(',', $recruit->forms))) {
  1563. $material = json_decode($v->material, true);
  1564. $materials = [];
  1565. if($material){
  1566. foreach ($material as $key => $value) {
  1567. array_push($materials, "https://www.jucai.gov.cn" . $value['response']['path']);
  1568. }
  1569. }
  1570. $special = [
  1571. $v->point_apply == 0 ? '否' : '是',
  1572. $v->condition,
  1573. implode("\r\n", $materials)
  1574. ];
  1575. $item = array_merge($item, $special);
  1576. }
  1577. if (in_array('detail', explode(',', $recruit->forms))) {
  1578. $detail = [
  1579. $v->resume,
  1580. $v->train,
  1581. $v->rewards_and_punishments,
  1582. $v->introduce
  1583. ];
  1584. } else {
  1585. $detail = [$v->resume];
  1586. }
  1587. $item = array_merge($item, $detail);
  1588. $family = json_decode($v->family, true);
  1589. $familys = [];
  1590. foreach ($family as $val){
  1591. switch ($val['political_affiliation']) {
  1592. case '01':
  1593. $political_affiliation = '中共党员';
  1594. break;
  1595. case '02':
  1596. $political_affiliation = '中共预备党员';
  1597. break;
  1598. case '03':
  1599. $political_affiliation = '共青团员';
  1600. break;
  1601. case '04':
  1602. $political_affiliation = '民革党员';
  1603. break;
  1604. case '05':
  1605. $political_affiliation = '民盟盟员';
  1606. break;
  1607. case '06':
  1608. $political_affiliation = '民建会员';
  1609. break;
  1610. case '07':
  1611. $political_affiliation = '民进会员';
  1612. break;
  1613. case '08':
  1614. $political_affiliation = '农工党党员';
  1615. break;
  1616. case '09':
  1617. $political_affiliation = '致公党党员';
  1618. break;
  1619. case '10':
  1620. $political_affiliation = '九三学社社员';
  1621. break;
  1622. case '11':
  1623. $political_affiliation = '台盟盟员';
  1624. break;
  1625. case '12':
  1626. $political_affiliation = '无党派人士';
  1627. break;
  1628. case '13':
  1629. $political_affiliation = '群众';
  1630. break;
  1631. default:
  1632. $political_affiliation = '未知';
  1633. break;
  1634. }
  1635. $familys[] = "称谓:" . $val['relation'] . ";姓名:".$val['realname'] . ';生日:'.$val['birthday'].';政治面貌:'.$political_affiliation.';职业:'.$val['work'];
  1636. }
  1637. $item[] = implode("\r\n", $familys);
  1638. if (in_array('identification', explode(',', $recruit->forms))) {
  1639. $identification = json_decode($v->identification, true);
  1640. $identifications = [];
  1641. foreach ($identification as $val){
  1642. array_push($identifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  1643. }
  1644. array_push($item, implode("\r\n", $identifications));
  1645. }
  1646. if (in_array('education_certification', explode(',', $recruit->forms))) {
  1647. $education_certification = json_decode($v->education_certification, true);
  1648. $education_certifications = [];
  1649. foreach ($education_certification as $val){
  1650. array_push($education_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  1651. }
  1652. array_push($item, implode("\r\n", $education_certifications));
  1653. }
  1654. if (in_array('other_certification', explode(',', $recruit->forms))) {
  1655. $other_certification = json_decode($v->other_certification, true);
  1656. $other_certifications = [];
  1657. if($other_certification){
  1658. foreach ($other_certification as $val){
  1659. array_push($other_certifications,"https://www.jucai.gov.cn" . $val['response']['path']);
  1660. }
  1661. }
  1662. array_push($item, implode("\r\n", $other_certifications));
  1663. }
  1664. switch (intval($v->audit)){
  1665. case 1:
  1666. $item[] = '审核中';
  1667. $item[] = '';
  1668. break;
  1669. case 2:
  1670. case 3:
  1671. $log = RecruitAppointLog::where('appoint_id', $v->id)->where('step', 1)->where('type', 2)->orderBy('created_at', 'desc')->first();
  1672. if ($log) {
  1673. $log_arr = explode(',',$log->log);
  1674. $item[] = $log_arr[0];
  1675. $item[] = $log_arr[1];
  1676. } else {
  1677. $item[] = '';
  1678. $item[] = '';
  1679. }
  1680. break;
  1681. default:
  1682. $item[] = '';
  1683. $item[] = '';
  1684. break;
  1685. }
  1686. if(empty($v->word_url)){
  1687. $item[] = "暂无";
  1688. }else{
  1689. $item[] = "https://www.jucai.gov.cn/" . $v->word_url;
  1690. }
  1691. array_push($data,$item);
  1692. }
  1693. foreach($data as $k => $v){
  1694. for ($i = 0;$i<count($v);$i++){
  1695. if($i == 18 || $i == 19 || $i == 22){
  1696. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  1697. }else{
  1698. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  1699. }
  1700. }
  1701. $row++;
  1702. }
  1703. $file_name = $recruit->name . date("Y-m-d",time());
  1704. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  1705. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  1706. header('Cache-Control: max-age=0');
  1707. // If you're serving to IE 9, then the following may be needed
  1708. header('Cache-Control: max-age=1');
  1709. // If you're serving to IE over SSL, then the following may be needed
  1710. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  1711. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  1712. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  1713. header('Pragma: public'); // HTTP/1.0
  1714. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  1715. $writer->save('php://output');
  1716. }else{
  1717. return response()->json(['status' => 0, 'msg' => '没有搜索到相关人员'], 200);
  1718. }
  1719. }
  1720. /**
  1721. * 座位贴
  1722. * @param Content $content
  1723. * @param Request $request
  1724. * @return Content
  1725. */
  1726. public function seat_sticker(Content $content, Request $request){
  1727. $recruit_id = $request->id;
  1728. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  1729. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  1730. ->select('recruit_appoint_info.*','recruit_ticket.*')
  1731. ->orderBy('recruit_ticket.ex_seat','asc')
  1732. ->get();
  1733. $data = [];
  1734. foreach ($list as $k => $v){
  1735. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  1736. if(!array_key_exists($room,$data)){
  1737. $data[$room] = [];
  1738. }
  1739. $item = [
  1740. 'avatar' => $v->avatar,
  1741. 'seat' => $v->ex_seat,
  1742. 'realname' => $v->realname,
  1743. 'number' => $v->ex_number
  1744. ];
  1745. array_push($data[$room],$item);
  1746. }
  1747. //dd($data);
  1748. return $content->body(view('admin.recruit.seat_sticker')->with(['data' => $data]));
  1749. }
  1750. public function sign_table(Content $content, Request $request){
  1751. $recruit_id = $request->id;
  1752. $list = RecruitAppointInfo::where(['recruit_appoint_info.recruit_id' => $recruit_id,'recruit_appoint_info.audit' => 3, 'recruit_ticket.ex_type' => 1])
  1753. ->join('recruit_ticket', 'recruit_ticket.appoint_id', '=', 'recruit_appoint_info.id','left')
  1754. ->select('recruit_appoint_info.*','recruit_ticket.*')
  1755. ->orderBy('recruit_ticket.ex_seat','asc')
  1756. ->get();
  1757. $data = [];
  1758. foreach ($list as $k => $v){
  1759. $room = $v->ex_room == null ? 'empty' : $v->ex_room;
  1760. if(!array_key_exists($room,$data)){
  1761. $data[$room] = [];
  1762. }
  1763. $item = [
  1764. 'avatar' => $v->avatar,
  1765. 'seat' => $v->ex_seat,
  1766. 'realname' => $v->realname
  1767. ];
  1768. array_push($data[$room],$item);
  1769. }
  1770. return $content->body(view('admin.recruit.sign_table')->with(['data' => $data]));
  1771. }
  1772. /**
  1773. * 上传成绩页面
  1774. *
  1775. * @access public
  1776. */
  1777. public function ajax_record(Request $request)
  1778. {
  1779. $recruit_id = $request->input('recruit_id');
  1780. if(!$recruit_id){
  1781. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  1782. }
  1783. $recruit = Recruit::where('id',$recruit_id)->first();
  1784. if(empty($recruit)){
  1785. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  1786. }
  1787. $view_data = [
  1788. 'recruit' => $recruit
  1789. ];
  1790. return response(['data' => view('admin.recruit.ajax_record')->with($view_data)->render(), 'status' => 1], '200');
  1791. }
  1792. public function update_record(Request $request)
  1793. {
  1794. $data = $request->all();
  1795. if(!array_key_exists('recruit_id',$data) || !$data['recruit_id']){
  1796. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  1797. }
  1798. $recruit = Recruit::where('id',$data['recruit_id'])->first();
  1799. if(empty($recruit)){
  1800. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  1801. }
  1802. if(array_key_exists('pen_data',$data)){
  1803. $ticket_url = base_path() . "/storage/app/public/recruit/ticket/" . uniqid() . '.xlsx';
  1804. if(move_uploaded_file($_FILES['pen_data']['tmp_name'],$ticket_url)){
  1805. $spreadsheet = IOFactory::load($ticket_url);
  1806. $sheet = $spreadsheet->getActiveSheet();
  1807. $rowCount = $sheet->getHighestRow();
  1808. $record = [];
  1809. for($row = 2;$row<=$rowCount;$row++){
  1810. $record[$sheet->getCell("A{$row}")->getValue()] = [
  1811. 'id' => $sheet->getCell("A{$row}")->getValue(),
  1812. 'realname' => $sheet->getCell("B{$row}")->getValue(),
  1813. 'card' => $sheet->getCell("C{$row}")->getValue(),
  1814. 'ex_number' => $sheet->getCell("E{$row}")->getValue(),
  1815. 'record' => $sheet->getCell("F{$row}")->getValue(),
  1816. 'next' => $sheet->getCell("G{$row}")->getValue()
  1817. ];
  1818. }
  1819. Recruit::where('id',$data['recruit_id'])->update(['pen_status' => 1]);
  1820. $record = new TicketJob($data['recruit_id'],'pen_result',$record);
  1821. dispatch($record);
  1822. return response()->json(['status' => 1, 'msg' => '成绩上传成功'], 200);
  1823. }else{
  1824. return response()->json(['status' => 0, 'msg' => '成绩上传失败'], 200);
  1825. }
  1826. }
  1827. }
  1828. public function create_record_template(Request $request){
  1829. $recruit_id = $request->input('recruit_id');
  1830. if(!$recruit_id){
  1831. return response()->json(['status' => 0, 'msg' => '请指定招考场次'], 200);
  1832. }
  1833. $recruit = Recruit::where('id',$recruit_id)->first();
  1834. if(empty($recruit)){
  1835. return response()->json(['status' => 0, 'msg' => '找不到对应招考场次'], 200);
  1836. }
  1837. $type = $request->input('type','pen');
  1838. switch ($type){
  1839. case 'pen':
  1840. $list = RecruitAppointInfo::where('recruit_appoint_info.recruit_id',$recruit_id)->where('recruit_appoint_info.audit',3)->where('recruit_appoint_info.pen_audit',-1)->join('recruit_ticket', 'recruit_appoint_info.id', '=', 'recruit_ticket.appoint_id')->select('recruit_appoint_info.*','recruit_ticket.ex_number')->orderBy('post_id','asc')->get();
  1841. $post_data = RecruitPost::where('recruit_id',$recruit_id)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1842. $data = [];
  1843. foreach ($list as $k => $v){
  1844. $item = [
  1845. $v->id,
  1846. $v->realname,
  1847. $v->card,
  1848. $post_data[$v->post_id],
  1849. $v->ex_number
  1850. ];
  1851. array_push($data,$item);
  1852. }
  1853. $spreadsheet = IOFactory::load(base_path() . '/storage/app/public/recruit/ticket/template/record_data_template.xlsx');
  1854. $sheet = $spreadsheet->getActiveSheet();
  1855. $row = 2;
  1856. foreach($data as $k => $v){
  1857. for ($i = 0;$i<count($v);$i++){
  1858. if($i == 2 || $i == 4){
  1859. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v[$i], DataType::TYPE_STRING);
  1860. }else{
  1861. $sheet->setCellValueByColumnAndRow($i+1, $row, $v[$i]);
  1862. }
  1863. }
  1864. $row++;
  1865. }
  1866. $file_name = $recruit->company . "_成绩表模板";
  1867. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  1868. header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  1869. header('Cache-Control: max-age=0');
  1870. // If you're serving to IE 9, then the following may be needed
  1871. header('Cache-Control: max-age=1');
  1872. // If you're serving to IE over SSL, then the following may be needed
  1873. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  1874. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  1875. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  1876. header('Pragma: public'); // HTTP/1.0
  1877. $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  1878. $writer->save('php://output');
  1879. break;
  1880. }
  1881. }
  1882. public function create_ticket(Request $request)
  1883. {
  1884. $data = $request->only('recruit_id','type','channel','content','keys');
  1885. //dd($data);
  1886. }
  1887. public function test(Request $request){
  1888. // $ids = [6,7,121,47,181,66,108,138,21,212,177,130,114,27,63,31,51];
  1889. // $data = RecruitAppointInfo::whereIn('id',$ids)->get();
  1890. // $post_data = RecruitPost::where('recruit_id',1)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  1891. //
  1892. //
  1893. // foreach ($data as $k => $v){
  1894. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_face_ticket.docx");
  1895. // $templateProcessor->setValue('realname', $v->realname);
  1896. // $templateProcessor->setValue('card', $v->card);
  1897. // $templateProcessor->setValue('post', $post_data[$v->post_id]);
  1898. // $name = 'jjhc';
  1899. // $date = '2020-11-30';
  1900. // if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face")){
  1901. // Storage::makeDirectory("public/recruit/ticket/word/{$date}/{$name}/face");
  1902. // }
  1903. // $filename = $v->realname . '_' . $v->card . '_' . $post_data[$v->post_id];
  1904. // $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/face/" . $filename . '.docx';
  1905. // $templateProcessor->saveAs($word_url);//另存为
  1906. // }
  1907. // $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/recruit/ticket/template/jjhc_pen_ticket.docx");
  1908. //
  1909. //
  1910. // $templateProcessor->setImageValue('avatar',['path' => 'https://www.jucai.gov.cn/storage/-1ae05561c7f32869.jpg', 'width' => 200, 'height' => 150]);
  1911. // $templateProcessor->saveAs(base_path() . "/storage/app/public/recruit/ticket/template/test.docx");//另存为
  1912. //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");
  1913. //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
  1914. }
  1915. }