JjhcController.php 14 KB

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