JjhcController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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\Models\RecruitTicket;
  7. use App\Services\Common\SmsService;
  8. use Illuminate\Support\Facades\Cache;
  9. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  10. use PhpOffice\PhpSpreadsheet\IOFactory;
  11. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  12. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  13. use PhpOffice\PhpWord\Settings;
  14. use PhpOffice\PhpWord\TemplateProcessor;
  15. use Illuminate\Support\Facades\DB;
  16. use App\Exceptions\ResponseException;
  17. use Illuminate\Http\Request;
  18. use App\Services\Common\BaiduService;
  19. class JjhcController extends WebBaseController
  20. {
  21. private $smsService;
  22. public function __construct(SmsService $smsService)
  23. {
  24. $this->smsService = $smsService;
  25. }
  26. public function yqfk()
  27. {
  28. return view("app.talent.jjhc.yqfk");
  29. }
  30. public function chaxun(Request $request)
  31. {
  32. $data = array('msg'=>'查无此用户!','status' => 0);
  33. return response()->json($data);
  34. $info = DB::connection('fangyi')->table('fillinfo')
  35. ->where(['lxdh'=>$request->tel])->first();
  36. if($info){
  37. $data = array('status'=>1,'msg'=>'查到已存在数据!','info'=>$info);
  38. }else{
  39. $data = array('msg'=>'查无此用户!','status' => 0);
  40. }
  41. return response()->json($data);
  42. }
  43. public function test(Request $request)
  44. {
  45. $keyword = $request->input('keyword');
  46. if($keyword != "j0vOW5mBREZxdo3P"){
  47. throw new ResponseException("who are you?", [], 404);
  48. }
  49. // $redis = Cache::getRedis();
  50. // $quota = $redis->get('recruit_quota');
  51. // if(!$quota){
  52. // $quota = [
  53. // [
  54. // 'name' => '青阳街道',
  55. // 'value' => 29,
  56. // ],
  57. // [
  58. // 'name' => '梅岭街道',
  59. // 'value' => 41
  60. // ],
  61. // [
  62. // 'name' => '西园街道',
  63. // 'value' => 16
  64. // ],
  65. // [
  66. // 'name' => '罗山街道',
  67. // 'value' => 30
  68. // ],
  69. // [
  70. // 'name' => '灵源街道',
  71. // 'value' => 18
  72. // ],
  73. // [
  74. // 'name' => '新塘街道',
  75. // 'value' => 29
  76. // ],
  77. // [
  78. // 'name' => '陈埭镇',
  79. // 'value' => 112
  80. // ],
  81. // [
  82. // 'name' => '池店镇',
  83. // 'value' => 80
  84. // ],
  85. // [
  86. // 'name' => '安海镇',
  87. // 'value' => 86
  88. // ],
  89. // [
  90. // 'name' => '磁灶镇',
  91. // 'value' => 46
  92. // ],
  93. // [
  94. // 'name' => '内坑镇',
  95. // 'value' => 38
  96. // ],
  97. // [
  98. // 'name' => '紫帽镇',
  99. // 'value' => 9
  100. // ],
  101. // [
  102. // 'name' => '东石镇',
  103. // 'value' => 29
  104. // ],
  105. // [
  106. // 'name' => '永和镇',
  107. // 'value' => 43
  108. // ],
  109. // [
  110. // 'name' => '英林镇',
  111. // 'value' => 25
  112. // ],
  113. // [
  114. // 'name' => '金井镇',
  115. // 'value' => 28
  116. // ],
  117. // [
  118. // 'name' => '龙湖镇',
  119. // 'value' => 63
  120. // ],
  121. // [
  122. // 'name' => '深沪镇',
  123. // 'value' => 29
  124. // ],
  125. // [
  126. // 'name' => '西滨镇',
  127. // 'value' => 9
  128. // ]
  129. // ];
  130. // $redis->set('recruit_quota',json_encode($quota));
  131. // }else{
  132. // $quota = json_decode($quota,true);
  133. // }
  134. // $list = DB::table('recruit_appoint_select as a')->leftJoin('recruit_appoint_info as b','a.appoint_id','=','b.id')->leftJoin('recruit_ticket as c','a.appoint_id','=','c.appoint_id')->whereRaw('a.select_result is null and a.result is not null and a.status = 1')->select(['b.realname','c.ex_number','a.result','a.select_result','a.id'])->orderBy('record','desc')->get();
  135. //
  136. // $array_column = array_column($quota,'name');
  137. // foreach ($list as $k => $v){
  138. // $person_select_result = json_decode($v->result,true);
  139. // foreach ($person_select_result as $val){
  140. // //寻找下标
  141. // $index = array_search($val,$array_column);
  142. // if($quota[$index]['value'] > 0){
  143. // $quota_data = [
  144. // 'index' => $index,
  145. // 'old_value' => $quota[$index]['value']
  146. // ];
  147. // //有名额允许择岗
  148. // DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  149. // $v->select_result = $val;
  150. // $quota[$index]['value']--;
  151. // $quota_data['new_value'] = $quota[$index]['value'];
  152. // break;
  153. // }
  154. // }
  155. //
  156. //
  157. // }
  158. // $option_list = [
  159. // '青阳街道','梅岭街道','西园街道','罗山街道','灵源街道','新塘街道','陈埭镇','池店镇','安海镇','磁灶镇','内坑镇','紫帽镇','东石镇','永和镇','英林镇','金井镇','龙湖镇','深沪镇','西滨镇'
  160. // ];
  161. // $list = DB::table("recruit_appoint_info")->where('recruit_id',18)->where('audit',3)->where('pen_audit',1)->where('post_id',309)->get();
  162. // foreach ($list as $k => $v){
  163. // $uid = $v->uid;
  164. // $recruit_id = 18;
  165. // $appoint_id = $v->id;
  166. //// $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  167. //// if($info){
  168. //// return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  169. //// }
  170. // $data = [
  171. // 'recruit_id' => $recruit_id,
  172. // 'appoint_id' => $appoint_id,
  173. // 'uid' => $uid,
  174. // 'status' => 1,
  175. // 'record' => mt_rand(50.0,100)
  176. // ];
  177. // shuffle($option_list);
  178. // $select = array_slice($option_list,0,rand(1,19));
  179. // $result = [];
  180. // if(is_array($select) && count($select) > 0){
  181. // foreach ($select as $v) {
  182. // array_push($result,$v);
  183. // }
  184. // }
  185. // $data['result'] = json_encode($result);
  186. // RecruitAppointSelect::create($data);
  187. //
  188. // }
  189. // for ($room = 1;$room <= 78; $room++){
  190. // $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();
  191. //
  192. // $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
  193. // $sheet = $objPHPExcel->getActiveSheet();
  194. // $row = 4;
  195. // $sheet->setCellValue('A1', "晋江市公开招聘第十三批村务(社区)专职工作者笔试参考情况一览表(第".intval($room)."考场)");
  196. //
  197. // foreach ($list as $k => $v){
  198. // $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
  199. // $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
  200. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  201. // $row++;
  202. // }
  203. //
  204. // $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
  205. // $writer->save(base_path() . "/public/excel/cunwu{$room}.xlsx");
  206. // }
  207. // for ($room = 1;$room <= 78; $room++){
  208. // $word = new TemplateProcessor(base_path() . "/public/cunwu1.docx");
  209. // $word->setValue('room', $room);
  210. // if($room<10){
  211. // $room = sprintf('%02s', $room);
  212. // }
  213. // $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();
  214. // $rows = count($list);//总行数
  215. // $word->cloneRow('id', $rows);//复制行
  216. // for ($i = 0; $i < $rows; $i++) {
  217. // $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
  218. // $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
  219. // $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
  220. // }
  221. // $word->saveAs(base_path() ."/public/excel/cunwu_{$room}.docx");//另存为
  222. // }
  223. // $spreadsheet = new Spreadsheet();
  224. // $sheet = $spreadsheet->getActiveSheet();
  225. // $header = ['姓名','身份证','准考证','报考岗位'];
  226. // foreach ($header as $key => $value) {
  227. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  228. // }
  229. // $row = 2;
  230. // $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  231. // $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();
  232. // $post_data = RecruitPost::where('recruit_id',16)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  233. // foreach ($list as $k => $v){
  234. // $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
  235. // $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->card,DataType::TYPE_STRING);
  236. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  237. // $sheet->setCellValueByColumnAndRow('4',$row, $post_data[$v->post_id]);
  238. // $row++;
  239. // }
  240. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  241. // header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
  242. // header('Cache-Control: max-age=0');
  243. // // If you're serving to IE 9, then the following may be needed
  244. // header('Cache-Control: max-age=1');
  245. // // If you're serving to IE over SSL, then the following may be needed
  246. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  247. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  248. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  249. // header('Pragma: public'); // HTTP/1.0
  250. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  251. // $writer->save('php://output');
  252. echo "success";
  253. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  254. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  255. // $all = array_count_values($all);
  256. // $time = time();
  257. // $data = [
  258. // 'idCards' => $list,
  259. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  260. // 'timeStr' => $time,
  261. // ];
  262. // $data_string = json_encode($data);
  263. // $ch = curl_init ();
  264. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  265. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  266. // 'Content-Type: application/json',
  267. // 'Content-Length: ' . strlen($data_string))
  268. // );
  269. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  270. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  271. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  272. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  273. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  274. // curl_setopt( $ch, CURLOPT_POST, 1);
  275. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  276. // $result = curl_exec ( $ch );
  277. // curl_close ( $ch );
  278. // $ret = json_decode($result,true);
  279. // $res = [];
  280. // if(count($ret['obj']) > 0){
  281. // foreach ($ret['obj'] as $k => $v){
  282. // if(array_key_exists($v['street'],$res)){
  283. // $res[$v['street']]['number']++;
  284. // $res[$v['street']]['count'] += $all[$v['idCard']];
  285. // }else{
  286. // $res[$v['street']] = [
  287. // 'number' => 1,
  288. // 'count' => $all[$v['idCard']]
  289. // ];
  290. // }
  291. // }
  292. // }
  293. //
  294. // $spreadsheet = new Spreadsheet();
  295. // $sheet = $spreadsheet->getActiveSheet();
  296. // $header = ['镇街','使用人数','使用次数'];
  297. // foreach ($header as $key => $value) {
  298. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  299. // }
  300. // $row = 2;
  301. // foreach ($res as $k => $v){
  302. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  303. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  304. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  305. // $row++;
  306. // }
  307. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  308. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  309. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  310. // header('Cache-Control: max-age=0');
  311. // // If you're serving to IE 9, then the following may be needed
  312. // header('Cache-Control: max-age=1');
  313. // // If you're serving to IE over SSL, then the following may be needed
  314. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  315. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  316. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  317. // header('Pragma: public'); // HTTP/1.0
  318. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  319. // $writer->save('php://output');
  320. //
  321. // //dd($res);
  322. }
  323. }