JjhcController.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace App\Http\Controllers\Web\Talent;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Services\Common\SmsService;
  5. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  6. use PhpOffice\PhpSpreadsheet\IOFactory;
  7. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  8. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  9. use PhpOffice\PhpWord\Settings;
  10. use Illuminate\Support\Facades\DB;
  11. use App\Exceptions\ResponseException;
  12. use Illuminate\Http\Request;
  13. class JjhcController extends WebBaseController
  14. {
  15. private $smsService;
  16. public function __construct(SmsService $smsService)
  17. {
  18. $this->smsService = $smsService;
  19. }
  20. public function yqfk()
  21. {
  22. return view("app.talent.jjhc.yqfk");
  23. }
  24. public function chaxun(Request $request)
  25. {
  26. $data = array('msg'=>'查无此用户!','status' => 0);
  27. return response()->json($data);
  28. $info = DB::connection('fangyi')->table('fillinfo')
  29. ->where(['lxdh'=>$request->tel])->first();
  30. if($info){
  31. $data = array('status'=>1,'msg'=>'查到已存在数据!','info'=>$info);
  32. }else{
  33. $data = array('msg'=>'查无此用户!','status' => 0);
  34. }
  35. return response()->json($data);
  36. }
  37. public function test(Request $request)
  38. {
  39. $keyword = $request->input('keyword');
  40. if($keyword != "j0vOW5mBREZxdo3P"){
  41. throw new ResponseException("who are you?", [], 404);
  42. }
  43. $room = $request->input('keyword',1);
  44. $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();
  45. $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
  46. $sheet = $objPHPExcel->getActiveSheet();
  47. $row = 4;
  48. $sheet->setCellValue('A1', "晋江市公开招聘第十二批村务(社区)专职工作者
  49. 笔试参考情况一览表(第".intval($room)."考场)");
  50. foreach ($list as $k => $v){
  51. $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
  52. $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
  53. $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  54. $row++;
  55. }
  56. $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
  57. $writer->save(base_path() . "/public/cunwu{$room}.xlsx");
  58. dd($list);
  59. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  60. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  61. // $all = array_count_values($all);
  62. // $time = time();
  63. // $data = [
  64. // 'idCards' => $list,
  65. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  66. // 'timeStr' => $time,
  67. // ];
  68. // $data_string = json_encode($data);
  69. // $ch = curl_init ();
  70. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  71. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  72. // 'Content-Type: application/json',
  73. // 'Content-Length: ' . strlen($data_string))
  74. // );
  75. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  76. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  77. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  78. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  79. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  80. // curl_setopt( $ch, CURLOPT_POST, 1);
  81. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  82. // $result = curl_exec ( $ch );
  83. // curl_close ( $ch );
  84. // $ret = json_decode($result,true);
  85. // $res = [];
  86. // if(count($ret['obj']) > 0){
  87. // foreach ($ret['obj'] as $k => $v){
  88. // if(array_key_exists($v['street'],$res)){
  89. // $res[$v['street']]['number']++;
  90. // $res[$v['street']]['count'] += $all[$v['idCard']];
  91. // }else{
  92. // $res[$v['street']] = [
  93. // 'number' => 1,
  94. // 'count' => $all[$v['idCard']]
  95. // ];
  96. // }
  97. // }
  98. // }
  99. //
  100. // $spreadsheet = new Spreadsheet();
  101. // $sheet = $spreadsheet->getActiveSheet();
  102. // $header = ['镇街','使用人数','使用次数'];
  103. // foreach ($header as $key => $value) {
  104. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  105. // }
  106. // $row = 2;
  107. // foreach ($res as $k => $v){
  108. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  109. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  110. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  111. // $row++;
  112. // }
  113. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  114. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  115. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  116. // header('Cache-Control: max-age=0');
  117. // // If you're serving to IE 9, then the following may be needed
  118. // header('Cache-Control: max-age=1');
  119. // // If you're serving to IE over SSL, then the following may be needed
  120. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  121. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  122. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  123. // header('Pragma: public'); // HTTP/1.0
  124. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  125. // $writer->save('php://output');
  126. //
  127. // //dd($res);
  128. }
  129. }