RecruitController.php 138 KB

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