JjhcController.php 11 KB

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