RecruitController.php 95 KB

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