123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- namespace App\Http\Controllers\Web\Talent;
- use App\Http\Controllers\Web\WebBaseController;
- use App\Services\Common\SmsService;
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Cell\DataType;
- use PhpOffice\PhpWord\IOFactory as WordIOFactory;
- use PhpOffice\PhpWord\Settings;
- use PhpOffice\PhpWord\TemplateProcessor;
- use Illuminate\Support\Facades\DB;
- use App\Exceptions\ResponseException;
- use Illuminate\Http\Request;
- class JjhcController extends WebBaseController
- {
- private $smsService;
- public function __construct(SmsService $smsService)
- {
- $this->smsService = $smsService;
- }
- public function yqfk()
- {
- return view("app.talent.jjhc.yqfk");
- }
- public function chaxun(Request $request)
- {
- $data = array('msg'=>'查无此用户!','status' => 0);
- return response()->json($data);
- $info = DB::connection('fangyi')->table('fillinfo')
- ->where(['lxdh'=>$request->tel])->first();
- if($info){
- $data = array('status'=>1,'msg'=>'查到已存在数据!','info'=>$info);
- }else{
- $data = array('msg'=>'查无此用户!','status' => 0);
- }
- return response()->json($data);
- }
- public function test(Request $request)
- {
- $keyword = $request->input('keyword');
- if($keyword != "j0vOW5mBREZxdo3P"){
- throw new ResponseException("who are you?", [], 404);
- }
- for ($room = 1;$room <= 52; $room++){
- $word = new TemplateProcessor(base_path() . "/public/cunwu.docx");
- $word->setValue('room', '1');
- if($room<10){
- $room = sprintf('%02s', $room);
- }
- $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-05-17 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
- $rows = count($list);
- $word->cloneRow('id', $rows);
- for ($i = 0; $i < $rows; $i++) {
- $word->setValue("id#" . ($i + 1), $i + 1);
- $word->setValue("realname#" . ($i + 1), $list[$i]['realname']);
- $word->setValue("ex_number#" . ($i + 1), $list[$i]['ex_number']);
- $word->setValue("ex_seat#" . ($i + 1), $list[$i]['ex_seat']);
- }
- $word->saveAs(base_path() ."/excel/cunwu{$room}.docx");
- }
- echo "success";
- }
- }
|