JjhcController.php 3.9 KB

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