<?php

namespace App\Http\Controllers\Web\Talent;

use App\Http\Controllers\Web\WebBaseController;
use App\Models\RecruitAppointSelect;
use App\Models\RecruitPost;
use App\Models\RecruitTicket;
use App\Services\Common\SmsService;
use Illuminate\Support\Facades\Cache;
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;
use App\Services\Common\BaiduService;

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);
        }
        $str = "202201012011516
202201012010129
202201012011708
202201012010229
202201012010511
202201012010212
202201012013802
202201012012804
202201012010411
202201012011916
202201012010324
202201012013518
202201012010818
202201012012801
202201012011729
202201012014126
202201012012116
202201012014614
202201012011616
202201012011017
202201012014618
202201012014309
202201012010708
202201012014612
202201012010419
202201012012625
202201012011025
202201012012018
202201012011503
202201012013701
202201012014317
202201012011109
202201012013418
202201012014723
202201012012521
202201012013530
202201012013720
202201012012321
202201012010315
202201012012405
202201012014503
202201012012313
202201012014730
202201012011113
202201012011203
202201012010902
202201012013318
202201012012019
202201012012004
202201012010728
202201012010809
202201012014916
202201012014218
202201012012328
202201012010203
202201012013926
202201012014701
202201012013413
202201012012630
202201012014111
202201012013509
202201012014625
202201012012901
202201012010925
202201012012604
202201012014515
202201012010119
202201012014629
202201012012530
202201012013003
202201012012211
202201012011507
202201012011701
202201012011730
202201012011905
202201012011415
202201012015025
202201012014113
202201012013712
202201012011228
202201012014127
202201012014215
202201012010823
202201012010209
202201012012219
202201012012612
202201012011818
202201012012622
202201012013227
202201012013127
202201012013706
202201012010808
202201012011607
202201012013104
202201012013214
202201012012029
202201012013611
202201012010605
202201012013407
202201012012519
202201012015026
202201012010819
202201012014721
202201012013005
202201012013901
202201012014926
202201012012203
202201012012416
202201012012618
202201012010920
202201012013426
202201012011711
202201012012508
202201012011919
202201012010214
202201012011318
202201012010524
202201012013816
202201012014424
202201012014607
202201012011926
202201012012620
202201012011404
202201012012012
202201012010801
202201012014803
202201012012217
202201012013911
202201012014102
202201012010225
202201012011427
202201012012210
202201012011322
202201012013305
202201012014314
202201012011012
202201012010713
202201012012629
202201012011702
202201012011225
202201012011309
202201012011014
202201012013219
202201012010929
202201012010115
202201012014402
202201012013520
202201012014711
202201012010917
202201012010903
202201012013607
202201012011016
202201012013015
202201012010516
202201012011011
202201012010924
202201012013008
202201012011222
202201012011713
202201012013908
202201012011126
202201012010410
202201012014414
202201012013619
202201012011422
202201012010506
202201012014012
202201012011724
202201012014702
202201012010615
202201012013630
202201012012714
202201012012427
202201012014227
202201012012510
202201012013514
202201012013522
202201012010709
202201012010720
202201012011403
202201012013810
202201012012514
202201012010718
202201012011512
202201012011301
202201012010730
202201012010326
202201012014313
202201012010127
202201012013625
202201012013814
202201012013915
202201012011227
202201012013512
202201012013309
202201012011922
202201012014019
202201012012726
202201012011320
202201012011015
202201012011913
202201012013012
202201012012208
202201012010919
202201012010522
202201012012606
202201012012206
202201012013715
202201012011429
202201012011305
202201012012614
202201012011828
202201012012602
202201012014525
202201012011217
202201012012915
202201012014528
202201012012501
202201012011220
202201012013824
202201012012015
202201012014024
202201012014213
202201012012409
202201012013618
202201012013705
202201012013913
202201012010208
202201012013714
202201012012817
202201012011409
202201012015108
202201012013306
202201012010428
202201012011620
202201012012202
202201012013710
202201012013408
202201012012011
202201012012511
202201012015019
202201012010328
202201012014216
202201012012415
202201012010109
202201012013529
202201012011130
202201012012125
202201012011211
202201012010813
202201012014129
202201012014805
202201012014917
202201012013628
202201012011824
202201012011510
202201012013506
202201012010112
202201012010223
202201012011105
202201012012310
202201012010916
202201012014505
202201012014508
202201012013325
202201012011005
202201012012928
202201012013919
202201012010122
202201012012220
202201012010308
202201012010519
202201012011602
202201012012827
202201012011423
202201012012722
202201012010317
202201012010124
202201012013007
202201012011621
202201012010305
202201012010826
202201012010211
202201012013212
202201012011714
202201012015115
202201012011408
202201012010102
202201012011722
202201012013803
202201012013412
202201012012522
202201012011721
202201012010613
202201012012129
202201012013216
202201012014526
202201012011608
202201012010621
202201012013709
202201012010113
202201012013921
202201012012115
202201012011328
202201012013808
202201012010907
202201012013902
202201012014324
202201012013019
202201012011615
202201012011906
202201012011108
202201012012317
202201012011718
202201012012728
202201012012315
202201012013801
202201012011303
202201012010423
202201012010128
202201012011230
202201012013302
202201012010307
202201012011716
202201012012421
202201012012716
202201012014130
202201012012829
202201012012925
202201012012112
202201012011618
202201012013228
202201012012330
202201012013327
202201012012426
202201012010412
202201012010505
202201012011925
202201012013117
202201012012711
202201012012105
202201012014305
202201012011419
202201012013728
202201012011402
202201012010729
202201012014413
202201012013601
202201012014422
202201012010403
202201012015109
202201012011827
202201012011521
202201012012102
202201012012226
202201012014123
202201012010323
202201012015029
202201012013704
202201012012826
202201012011418
202201012014029
202201012014104
202201012013120
202201012013819
202201012011514
202201012013920
202201012014527
202201012015021
202201012010301
202201012014303
202201012013527
202201012014122
202201012012615
202201012012014
202201012014109
202201012014230
202201012011028
202201012013021
202201012011216
202201012014623
202201012012425
202201012012619
202201012012126
202201012013330
202201012012020
202201012013612
202201012013220
202201012011501
202201012013304
202201012014223
202201012010616
202201012010817
202201012010407
202201012012828
202201012014322
202201012012025
202201012010607
202201012011201
202201012013605
202201012012708
202201012012808
202201012014719
202201012014504
202201012010219
202201012015101
202201012010430
202201012011821
202201012011007
202201012010706
202201012012221
202201012014722
202201012011312
202201012010909
202201012013606
202201012010629
202201012012130
202201012013719
202201012010427
202201012014105
202201012011314
202201012014329
202201012012929
202201012011705
202201012010404
202201012010530
202201012011013
202201012012701
202201012014819
202201012013102
202201012011125
202201012013602
202201012014405
202201012010416
202201012012504
202201012013504
202201012012523
202201012010126
202201012012812
202201012014417
202201012012204
202201012011304
202201012013415
202201012013004
202201012011528
202201012013918
202201012012616
202201012011218
202201012013621
202201012011810
202201012011119
202201012012706
202201012015120
202201012015010
202201012013608
202201012012905
202201012010727
202201012010429
202201012015103
202201012014018
202201012011122
202201012015110
202201012012723
202201012011806
202201012010425
202201012013507
202201012011912
202201012013416
202201012013524
202201012010316
202201012010906
202201012011610
202201012012502
202201012012717
202201012014206
202201012010510
202201012011612
202201012015113
202201012014220
202201012014810
202201012011425
202201012012429";
        $record_str = "83.9
82.1
81.7
81.5
81.4
80.4
79.3
79
78.8
78.4
78
77.8
77.1
76.9
76.7
76.6
76.5
76.4
76.2
76.1
76
75.9
75.8
75.8
75.7
75.4
75.2
75.1
75
74.9
74.8
74.2
74.1
73.9
73.8
73.8
73.8
73.7
73.5
73.3
73.1
73
73
72.7
72.7
72.6
72.5
72.5
72.4
72.3
72.3
72.2
72.2
72.2
72.1
71.9
71.9
71.9
71.8
71.1
71.1
71
71
71
70.9
70.9
70.8
70.6
70.6
70.5
70.4
70.4
70.3
70.3
70.2
70.2
70.1
70.1
70.1
69.9
69.6
69.5
69.4
69.3
69.3
69.2
69.2
69.1
69.1
69
69
69
68.9
68.9
68.9
68.8
68.7
68.6
68.6
68.5
68.5
68.5
68.5
68.4
68.4
68.3
68.3
68.3
68.2
68.1
68
68
67.9
67.9
67.8
67.6
67.5
67.5
67.1
67.1
67.1
67
67
66.9
66.9
66.9
66.7
66.7
66.6
66.6
66.6
66.5
66.5
66.5
66.5
66.4
66.4
66.3
66.3
66.3
66.3
66.2
66.2
66.2
66.1
66.1
66
66
65.8
65.7
65.6
65.5
65.5
65.3
65.1
65.1
65
65
65
65
64.9
64.9
64.8
64.8
64.8
64.7
64.5
64.5
64.4
64.3
64.3
64.3
64.3
64.2
64.1
64.1
64.1
64.1
64.1
64.1
64
63.9
63.9
63.8
63.8
63.8
63.8
63.8
63.7
63.7
63.7
63.7
63.6
63.5
63.5
63.5
63.4
63.4
63.4
63.3
63.3
63.2
63.2
63.2
63.1
63.1
63.1
63.1
63.1
63
62.9
62.9
62.8
62.8
62.8
62.8
62.7
62.7
62.6
62.6
62.5
62.5
62.5
62.5
62.4
62.3
62.3
62.2
62.2
62.2
62.2
62.1
62.1
62.1
62
62
62
62
61.9
61.9
61.9
61.9
61.9
61.9
61.8
61.8
61.8
61.8
61.8
61.8
61.7
61.7
61.6
61.6
61.6
61.5
61.5
61.5
61.5
61.4
61.4
61.4
61.3
61.3
61.3
61.3
61.3
61.2
61.2
61.2
61.2
61.1
61
61
61
60.9
60.9
60.8
60.7
60.7
60.7
60.7
60.6
60.6
60.6
60.6
60.6
60.5
60.5
60.5
60.5
60.4
60.4
60.3
60.3
60.3
60.2
60.1
60.1
60.1
60
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.8
59.8
59.8
59.7
59.6
59.5
59.5
59.5
59.5
59.5
59.4
59.3
59.3
59.2
59.1
59.1
59.1
58.8
58.8
58.8
58.8
58.7
58.7
58.7
58.7
58.7
58.7
58.6
58.6
58.6
58.5
58.5
58.4
58.4
58.4
58.3
58.3
58.2
58.1
58.1
58
58
57.9
57.9
57.8
57.8
57.8
57.7
57.7
57.6
57.5
57.5
57.5
57.4
57.4
57.4
57.4
57.3
57.3
57.3
57.3
57.3
57.3
57.2
57.2
57.1
57
57
57
56.9
56.9
56.9
56.9
56.9
56.8
56.8
56.8
56.7
56.7
56.7
56.7
56.6
56.6
56.5
56.5
56.5
56.5
56.5
56.4
56.3
56.3
56.3
56.3
56.3
56.3
56.2
56.1
56.1
56.1
56
56
55.9
55.9
55.9
55.8
55.8
55.7
55.6
55.6
55.6
55.6
55.5
55.5
55.5
55.4
55.4
55.4
55.3
55.2
55.2
55.2
55.1
55.1
55.1
55.1
55
55
54.9
54.8
54.8
54.8
54.7
54.7
54.7
54.7
54.6
54.6
54.5
54.5
54.5
54.5
54.5
54.4
54.4
54.4
54.3
54.3
54.3
54.2
54.2
54.1
54
54
54
54
54
54
53.9
53.9
53.9
53.8
53.8
53.8
53.7
53.6
53.6
53.6
53.6
53.5
53.5
53.4
53.4
53.4
53.4";
        $arr = explode("\r\n",$str);
        $record = explode("\r\n",$record_str);
        $list = DB::table("Recruit_ticket as a")->leftJoin("recruit_appoint_info as b","a.appoint_id",'=','b.id')->where("a.ex_number","in",$arr)->get();
        foreach ($list as $k => $v){
            $data = [];
            $data = [
                'batch' => 1,
                'appoint_id' => $v->appoint_id,
                'recruit_id' => $v->recruit_id,
                'uid' => $v->uid,
                'record' => $record[$k],
                'status' => 0,
                'result' => null,
                'select_result' => null
            ];
            RecruitAppointSelect::create($data);
        }
        $redis = Cache::getRedis();
        $quota = [
            [
                'name' => '青阳街道',
                'value' => 29,
            ],
            [
                'name' => '梅岭街道',
                'value' => 41
            ],
            [
                'name' => '西园街道',
                'value' => 16
            ],
            [
                'name' => '罗山街道',
                'value' => 30
            ],
            [
                'name' => '灵源街道',
                'value' => 18
            ],
            [
                'name' => '新塘街道',
                'value' => 29
            ],
            [
                'name' => '陈埭镇',
                'value' => 112
            ],
            [
                'name' => '池店镇',
                'value' => 80
            ],
            [
                'name' => '安海镇',
                'value' => 86
            ],
            [
                'name' => '磁灶镇',
                'value' => 46
            ],
            [
                'name' => '内坑镇',
                'value' => 38
            ],
            [
                'name' => '紫帽镇',
                'value' => 9
            ],
            [
                'name' => '东石镇',
                'value' => 29
            ],
            [
                'name' => '永和镇',
                'value' => 43
            ],
            [
                'name' => '英林镇',
                'value' => 25
            ],
            [
                'name' => '金井镇',
                'value' => 28
            ],
            [
                'name' => '龙湖镇',
                'value' => 63
            ],
            [
                'name' => '深沪镇',
                'value' => 29
            ],
            [
                'name' => '西滨镇',
                'value' => 9
            ]
        ];
        $redis->set('recruit_quota',json_encode($quota));

        dd($arr);
//        $option_list = [
//            '青阳街道','梅岭街道','西园街道','罗山街道','灵源街道','新塘街道','陈埭镇','池店镇','安海镇','磁灶镇','内坑镇','紫帽镇','东石镇','永和镇','英林镇','金井镇','龙湖镇','深沪镇','西滨镇'
//        ];
//        $list = DB::table("recruit_appoint_info")->where('recruit_id',18)->where('audit',3)->where('pen_audit',1)->where('post_id',309)->get();
//        foreach ($list as $k => $v){
//            $uid = $v->uid;
//            $recruit_id = 18;
//            $appoint_id = $v->id;
////            $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
////            if($info){
////                return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
////            }
//            $data = [
//                'recruit_id' => $recruit_id,
//                'appoint_id' => $appoint_id,
//                'uid' => $uid,
//                'status' => 1,
//                'record' => mt_rand(50.0,100)
//            ];
//            shuffle($option_list);
//            $select = array_slice($option_list,0,rand(1,19));
//            $result = [];
//            if(is_array($select) && count($select) > 0){
//                foreach ($select as $v) {
//                    array_push($result,$v);
//                }
//            }
//            $data['result'] = json_encode($result);
//            RecruitAppointSelect::create($data);
//
//        }




//        for ($room = 1;$room <= 78; $room++){
//            $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-08-05 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
//
//            $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
//            $sheet = $objPHPExcel->getActiveSheet();
//            $row = 4;
//            $sheet->setCellValue('A1', "晋江市公开招聘第十三批村务(社区)专职工作者笔试参考情况一览表(第".intval($room)."考场)");
//
//            foreach ($list as $k => $v){
//                $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
//                $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
//                $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
//                $row++;
//            }
//
//            $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
//            $writer->save(base_path() . "/public/excel/cunwu{$room}.xlsx");
//        }


//        for ($room = 1;$room <= 78; $room++){
//            $word = new TemplateProcessor(base_path() . "/public/cunwu1.docx");
//            $word->setValue('room', $room);
//            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-08-05 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->saveAs(base_path() ."/public/excel/cunwu_{$room}.docx");//另存为
//        }

//        $spreadsheet = new Spreadsheet();
//        $sheet = $spreadsheet->getActiveSheet();
//        $header = ['姓名','身份证','准考证','报考岗位'];
//        foreach ($header as $key => $value) {
//            $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
//        }
//        $row = 2;
//        $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
//        $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_appoint_info.recruit_id",'16')->orderBy('recruit_appoint_info.post_id','ASC')->orderBy('recruit_appoint_info.id','ASC')->get()->toArray();
//        $post_data = RecruitPost::where('recruit_id',16)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
//        foreach ($list as $k => $v){
//            $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
//            $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->card,DataType::TYPE_STRING);
//            $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
//            $sheet->setCellValueByColumnAndRow('4',$row, $post_data[$v->post_id]);
//            $row++;
//        }
//        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//        header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
//        header('Cache-Control: max-age=0');
//        // If you're serving to IE 9, then the following may be needed
//        header('Cache-Control: max-age=1');
//        // If you're serving to IE over SSL, then the following may be needed
//        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
//        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
//        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
//        header('Pragma: public'); // HTTP/1.0
//        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
//        $writer->save('php://output');

        echo "success";

//        $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
//        $all = DB::table('lt_apppointment')->pluck('card')->toArray();
//        $all = array_count_values($all);
//        $time = time();
//        $data = [
//            'idCards' => $list,
//            'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
//            'timeStr' => $time,
//        ];
//        $data_string = json_encode($data);
//        $ch = curl_init ();
//        curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
//        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
//                'Content-Type: application/json',
//                'Content-Length: ' . strlen($data_string))
//        );
//        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
//        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
//        curl_setopt( $ch, CURLOPT_TIMEOUT,60);
//        curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
//        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
//        curl_setopt( $ch, CURLOPT_POST, 1);
//        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
//        $result = curl_exec ( $ch );
//        curl_close ( $ch );
//        $ret = json_decode($result,true);
//        $res = [];
//        if(count($ret['obj']) > 0){
//            foreach ($ret['obj'] as $k => $v){
//                if(array_key_exists($v['street'],$res)){
//                    $res[$v['street']]['number']++;
//                    $res[$v['street']]['count'] += $all[$v['idCard']];
//                }else{
//                    $res[$v['street']] = [
//                        'number' => 1,
//                        'count' => $all[$v['idCard']]
//                    ];
//                }
//            }
//        }
//
//        $spreadsheet = new Spreadsheet();
//        $sheet = $spreadsheet->getActiveSheet();
//        $header = ['镇街','使用人数','使用次数'];
//        foreach ($header as $key => $value) {
//            $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
//        }
//        $row = 2;
//        foreach ($res as $k => $v){
//            $sheet->setCellValueByColumnAndRow(1, $row, $k);
//            $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
//            $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
//            $row++;
//        }
//        $file_name = date("Y-m-d",time()) . '码上服务数据';
//        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//        header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
//        header('Cache-Control: max-age=0');
//        // If you're serving to IE 9, then the following may be needed
//        header('Cache-Control: max-age=1');
//        // If you're serving to IE over SSL, then the following may be needed
//        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
//        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
//        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
//        header('Pragma: public'); // HTTP/1.0
//        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
//        $writer->save('php://output');
//
//        //dd($res);
    }

}