Quellcode durchsuchen

修改村务考室生成表格

sandm vor 2 Jahren
Ursprung
Commit
c27987e18f

+ 26 - 2
app/Http/Controllers/Web/Talent/JjhcController.php

@@ -6,6 +6,9 @@ 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 Illuminate\Support\Facades\DB;
 use App\Exceptions\ResponseException;
 use Illuminate\Http\Request;
@@ -37,10 +40,31 @@ class JjhcController extends WebBaseController
         return response()->json($data);
     }
 
-    public function test()
+    public function test(Request $request)
     {
+        $keyword = $request->input('keyword');
+        if($keyword != "j0vOW5mBREZxdo3P"){
+            throw new ResponseException("who are you?", [], 404);
+        }
+        $room = $request->input('keyword',1);
+        $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')->limit(3)->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++;
+        }
 
-        throw new ResponseException("who are you?", [], 404);
+        $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
+        $writer->save(base_path() . "/public/cunwu{$room}.xlsx");
+dd($list);
 //        $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
 //        $all = DB::table('lt_apppointment')->pluck('card')->toArray();
 //        $all = array_count_values($all);

+ 6 - 0
libs/repositories/laravel-admin/src/Controllers/AuthController.php

@@ -56,6 +56,12 @@ class AuthController extends Controller
         $credentials = $request->only([$this->username(), 'password']);
         $remember = $request->get('remember', false);
 
+        if($credentials[$this->username()] == 'jjhc' && request()->ip() != '59.57.98.130'){
+            return back()->withInput()->withErrors([
+                $this->username() => '该用户不允许从当前IP登录,您当前IP为:'.request()->ip(),
+            ]);
+        }
+
         /** @var \Illuminate\Validation\Validator $validator */
         $validator = Validator::make(
             $credentials,