JjhcController.php 4.5 KB

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