JjhcController.php 3.7 KB

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