RecruitController.php 97 KB

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