RecruitController.php 96 KB

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