JjhcController.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. namespace App\Http\Controllers\Web\Talent;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Models\RecruitPost;
  5. use App\Services\Common\SmsService;
  6. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  7. use PhpOffice\PhpSpreadsheet\IOFactory;
  8. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  9. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  10. use PhpOffice\PhpWord\Settings;
  11. use PhpOffice\PhpWord\TemplateProcessor;
  12. use Illuminate\Support\Facades\DB;
  13. use App\Exceptions\ResponseException;
  14. use Illuminate\Http\Request;
  15. use App\Services\Common\BaiduService;
  16. class JjhcController extends WebBaseController
  17. {
  18. private $smsService;
  19. public function __construct(SmsService $smsService)
  20. {
  21. $this->smsService = $smsService;
  22. }
  23. public function yqfk()
  24. {
  25. return view("app.talent.jjhc.yqfk");
  26. }
  27. public function chaxun(Request $request)
  28. {
  29. $data = array('msg'=>'查无此用户!','status' => 0);
  30. return response()->json($data);
  31. $info = DB::connection('fangyi')->table('fillinfo')
  32. ->where(['lxdh'=>$request->tel])->first();
  33. if($info){
  34. $data = array('status'=>1,'msg'=>'查到已存在数据!','info'=>$info);
  35. }else{
  36. $data = array('msg'=>'查无此用户!','status' => 0);
  37. }
  38. return response()->json($data);
  39. }
  40. public function test(Request $request)
  41. {
  42. $keyword = $request->input('keyword');
  43. if($keyword != "j0vOW5mBREZxdo3P"){
  44. throw new ResponseException("who are you?", [], 404);
  45. }
  46. $baidu = new BaiduService();
  47. $health_result = $baidu->health_code(file_get_contents(base_path() . "/public/test.jpg" ));
  48. dd($health_result);
  49. // for ($room = 1;$room <= 78; $room++){
  50. // $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-08-05 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
  51. //
  52. // $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
  53. // $sheet = $objPHPExcel->getActiveSheet();
  54. // $row = 4;
  55. // $sheet->setCellValue('A1', "晋江市公开招聘第十三批村务(社区)专职工作者笔试参考情况一览表(第".intval($room)."考场)");
  56. //
  57. // foreach ($list as $k => $v){
  58. // $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
  59. // $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
  60. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  61. // $row++;
  62. // }
  63. //
  64. // $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
  65. // $writer->save(base_path() . "/public/excel/cunwu{$room}.xlsx");
  66. // }
  67. // for ($room = 1;$room <= 78; $room++){
  68. // $word = new TemplateProcessor(base_path() . "/public/cunwu1.docx");
  69. // $word->setValue('room', $room);
  70. // if($room<10){
  71. // $room = sprintf('%02s', $room);
  72. // }
  73. // $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_ticket.ex_start",'2022-08-05 08:00:00')->where('recruit_ticket.ex_room',$room)->orderBy('ex_seat','ASC')->get()->toArray();
  74. // $rows = count($list);//总行数
  75. // $word->cloneRow('id', $rows);//复制行
  76. // for ($i = 0; $i < $rows; $i++) {
  77. // $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
  78. // $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
  79. // $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
  80. // }
  81. // $word->saveAs(base_path() ."/public/excel/cunwu_{$room}.docx");//另存为
  82. // }
  83. // $spreadsheet = new Spreadsheet();
  84. // $sheet = $spreadsheet->getActiveSheet();
  85. // $header = ['姓名','身份证','准考证','报考岗位'];
  86. // foreach ($header as $key => $value) {
  87. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  88. // }
  89. // $row = 2;
  90. // $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  91. // $list = DB::table("recruit_ticket")->leftJoin("recruit_appoint_info","recruit_ticket.appoint_id",'=','recruit_appoint_info.id')->where("recruit_appoint_info.recruit_id",'16')->orderBy('recruit_appoint_info.post_id','ASC')->orderBy('recruit_appoint_info.id','ASC')->get()->toArray();
  92. // $post_data = RecruitPost::where('recruit_id',16)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  93. // foreach ($list as $k => $v){
  94. // $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
  95. // $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->card,DataType::TYPE_STRING);
  96. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  97. // $sheet->setCellValueByColumnAndRow('4',$row, $post_data[$v->post_id]);
  98. // $row++;
  99. // }
  100. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  101. // header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
  102. // header('Cache-Control: max-age=0');
  103. // // If you're serving to IE 9, then the following may be needed
  104. // header('Cache-Control: max-age=1');
  105. // // If you're serving to IE over SSL, then the following may be needed
  106. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  107. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  108. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  109. // header('Pragma: public'); // HTTP/1.0
  110. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  111. // $writer->save('php://output');
  112. echo "success";
  113. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  114. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  115. // $all = array_count_values($all);
  116. // $time = time();
  117. // $data = [
  118. // 'idCards' => $list,
  119. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  120. // 'timeStr' => $time,
  121. // ];
  122. // $data_string = json_encode($data);
  123. // $ch = curl_init ();
  124. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  125. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  126. // 'Content-Type: application/json',
  127. // 'Content-Length: ' . strlen($data_string))
  128. // );
  129. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  130. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  131. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  132. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  133. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  134. // curl_setopt( $ch, CURLOPT_POST, 1);
  135. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  136. // $result = curl_exec ( $ch );
  137. // curl_close ( $ch );
  138. // $ret = json_decode($result,true);
  139. // $res = [];
  140. // if(count($ret['obj']) > 0){
  141. // foreach ($ret['obj'] as $k => $v){
  142. // if(array_key_exists($v['street'],$res)){
  143. // $res[$v['street']]['number']++;
  144. // $res[$v['street']]['count'] += $all[$v['idCard']];
  145. // }else{
  146. // $res[$v['street']] = [
  147. // 'number' => 1,
  148. // 'count' => $all[$v['idCard']]
  149. // ];
  150. // }
  151. // }
  152. // }
  153. //
  154. // $spreadsheet = new Spreadsheet();
  155. // $sheet = $spreadsheet->getActiveSheet();
  156. // $header = ['镇街','使用人数','使用次数'];
  157. // foreach ($header as $key => $value) {
  158. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  159. // }
  160. // $row = 2;
  161. // foreach ($res as $k => $v){
  162. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  163. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  164. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  165. // $row++;
  166. // }
  167. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  168. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  169. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  170. // header('Cache-Control: max-age=0');
  171. // // If you're serving to IE 9, then the following may be needed
  172. // header('Cache-Control: max-age=1');
  173. // // If you're serving to IE over SSL, then the following may be needed
  174. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  175. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  176. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  177. // header('Pragma: public'); // HTTP/1.0
  178. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  179. // $writer->save('php://output');
  180. //
  181. // //dd($res);
  182. }
  183. }