JjhcController.php 4.4 KB

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