JjhcController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <?php
  2. namespace App\Http\Controllers\Web\Talent;
  3. libxml_disable_entity_loader(false);
  4. use App\Http\Controllers\Web\WebBaseController;
  5. use App\Models\RecruitAppointInfo;
  6. use App\Models\RecruitAppointSelect;
  7. use App\Models\RecruitPost;
  8. use App\Models\RecruitTicket;
  9. use App\Services\Common\SmsService;
  10. use Illuminate\Support\Facades\Cache;
  11. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  12. use PhpOffice\PhpSpreadsheet\IOFactory;
  13. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  14. use PhpOffice\PhpWord\IOFactory as WordIOFactory;
  15. use PhpOffice\PhpWord\Settings;
  16. use PhpOffice\PhpWord\TemplateProcessor;
  17. use Illuminate\Support\Facades\DB;
  18. use App\Exceptions\ResponseException;
  19. use Illuminate\Http\Request;
  20. use App\Services\Common\BaiduService;
  21. class JjhcController extends WebBaseController
  22. {
  23. private $smsService;
  24. public function __construct(SmsService $smsService)
  25. {
  26. $this->smsService = $smsService;
  27. }
  28. public function yqfk()
  29. {
  30. return view("app.talent.jjhc.yqfk");
  31. }
  32. public function chaxun(Request $request)
  33. {
  34. $data = array('msg'=>'查无此用户!','status' => 0);
  35. return response()->json($data);
  36. $info = DB::connection('fangyi')->table('fillinfo')
  37. ->where(['lxdh'=>$request->tel])->first();
  38. if($info){
  39. $data = array('status'=>1,'msg'=>'查到已存在数据!','info'=>$info);
  40. }else{
  41. $data = array('msg'=>'查无此用户!','status' => 0);
  42. }
  43. return response()->json($data);
  44. }
  45. public function getGuid(){
  46. $redis = Cache::getRedis();
  47. $guid = $redis->get('sjhj_guid');
  48. if(!$guid){
  49. $client = new \SoapClient("http://222.77.0.158:8090/Convergence/webservice/ConvergenceService?wsdl");
  50. // 组织参数 根据接口具体提供参数组织对应参数
  51. $param = [
  52. 'userid'=>'jjswzzb_cxz',
  53. 'password'=>'Cxz@1234'
  54. ];
  55. $guid =$client->LoginByAccount ($param);
  56. $redis->set('sjhj_guid',$guid->return);
  57. $redis->expire('sjhj_guid',1800);
  58. return $guid->return;
  59. }
  60. return $guid;
  61. }
  62. public function push(){
  63. ini_set('display_errors',1);
  64. error_reporting(E_ALL);
  65. $guid = $this->getGuid();
  66. $index = 0;
  67. for ($i = 71;$i<=100;$i++){
  68. $list = DB::table("recruit_appoint_info")->distinct('card')->offset($index)->limit(500)->get();
  69. if($list && count($list) > 0){
  70. $str = '<?xml version="1.0" encoding="UTF-8"?><table>';
  71. $template = '<row type="add">
  72. <id name="主键" isattachment="false"><![CDATA[%s]]></id>
  73. <uid name="用户id" isattachment="false"><![CDATA[%s]]></uid>
  74. <realname name="姓名" isattachment="false"><![CDATA[%s]]></realname>
  75. <sex name="性别" isattachment="false"><![CDATA[%s]]></sex>
  76. <birthday name="生日" isattachment="false"><![CDATA[%s]]></birthday>
  77. <nation name="民族" isattachment="false"><![CDATA[%s]]></nation>
  78. <native_place name="籍贯" isattachment="false"><![CDATA[%s]]></native_place>
  79. <political_attitudes name="政治面貌" isattachment="false"><![CDATA[%s]]></political_attitudes>
  80. <join_time name="入党时间" isattachment="false"><![CDATA[%s]]></join_time>
  81. <titles name="职称或职业资格" isattachment="false"><![CDATA[%s]]></titles>
  82. <work name="现工作单位及职务" isattachment="false"><![CDATA[%s]]></work>
  83. <house_register name="户籍所在地" isattachment="false"><![CDATA[%s]]></house_register>
  84. <edu_type name="教育类型" isattachment="false"><![CDATA[%s]]></edu_type>
  85. <education name="学历" isattachment="false"><![CDATA[%s]]></education>
  86. <school name="学校" isattachment="false"><![CDATA[%s]]></school>
  87. <degree name="学位" isattachment="false"><![CDATA[%s]]></degree>
  88. <pro name="所学专业" isattachment="false"><![CDATA[%s]]></pro>
  89. <address name="通信地址" isattachment="false"><![CDATA[%s]]></address>
  90. <card name="身份证号码" isattachment="false"><![CDATA[%s]]></card>
  91. <mobile name="联系电话" isattachment="false"><![CDATA[%s]]></mobile>
  92. <email name="电子邮箱" isattachment="false"><![CDATA[%s]]></email>
  93. <concat_name name="联系人姓名" isattachment="false"><![CDATA[%s]]></concat_name>
  94. <concat_mobile name="联系人手机号码" isattachment="false"><![CDATA[%s]]></concat_mobile>
  95. <resume name="个人简历" isattachment="false"><![CDATA[%s]]></resume>
  96. <training name="培训学习经历" isattachment="false"><![CDATA[%s]]></training>
  97. <rewards_and_punishments name="奖惩情况" isattachment="false"><![CDATA[%s]]></rewards_and_punishments>
  98. <introduce name="个人情况介绍" isattachment="false"><![CDATA[%s]]></introduce>
  99. <status name="状态" isattachment="false"><![CDATA[%s]]></status>
  100. <createtime name="提交时间" isattachment="false"><![CDATA[%s]]></createtime>
  101. </row>';
  102. foreach ($list as $k => $v){
  103. $item_str = sprintf($template,$v->id,$v->uid,$v->realname,$v->sex,$v->birthday,$v->nation,$v->native_place,$v->political_affiliation,$v->join_time
  104. ,$v->titles,$v->work,$v->house_register,$v->edu_type,$v->education,$v->school,$v->degree,$v->pro,$v->address
  105. ,$v->card,$v->mobile,$v->email,$v->concat_name,$v->concat_mobile,$v->resume,'','',''
  106. ,$v->audit,$v->created_at);
  107. // dd($item_str);
  108. $str .= $item_str;
  109. }
  110. $str .= '</table>';
  111. try{
  112. $client = new \SoapClient('http://61.131.47.134:8756/Convergence/webservice/ConvergenceService?wsdl');
  113. // 组织参数 根据接口具体提供参数组织对应参数
  114. $param = [
  115. 'guid'=>$guid,
  116. 'catalogid'=>'WEB2445',
  117. 'xmlstr' => $str
  118. ];
  119. $res = $client->pushXml($param);
  120. echo $res->return;
  121. } catch (\Exception $e){
  122. dd($e->getMessage());
  123. }
  124. }
  125. $index += 500;
  126. }
  127. echo $index;
  128. }
  129. public function test(Request $request)
  130. {
  131. $keyword = $request->input('keyword');
  132. if($keyword != "j0vOW5mBREZxdo3P"){
  133. throw new ResponseException("who are you?", [], 404);
  134. }
  135. // $redis = Cache::getRedis();
  136. // $quota = $redis->get('recruit_quota');
  137. // if(!$quota){
  138. // $quota = [
  139. // [
  140. // 'name' => '新塘街道',
  141. // 'value' => 13
  142. // ],
  143. // [
  144. // 'name' => '陈埭镇',
  145. // 'value' => 88
  146. // ],
  147. // [
  148. // 'name' => '池店镇',
  149. // 'value' => 10
  150. // ],
  151. // [
  152. // 'name' => '安海镇',
  153. // 'value' => 10
  154. // ],
  155. // [
  156. // 'name' => '磁灶镇',
  157. // 'value' => 21
  158. // ],
  159. // [
  160. // 'name' => '内坑镇',
  161. // 'value' => 22
  162. // ],
  163. // [
  164. // 'name' => '东石镇',
  165. // 'value' => 4
  166. // ],
  167. // [
  168. // 'name' => '永和镇',
  169. // 'value' => 27
  170. // ],
  171. // [
  172. // 'name' => '英林镇',
  173. // 'value' => 5
  174. // ],
  175. // [
  176. // 'name' => '金井镇',
  177. // 'value' => 13
  178. // ],
  179. // [
  180. // 'name' => '龙湖镇',
  181. // 'value' => 53
  182. // ],
  183. // [
  184. // 'name' => '深沪镇',
  185. // 'value' => 23
  186. // ],
  187. // [
  188. // 'name' => '西滨镇',
  189. // 'value' => 3
  190. // ]
  191. // ];
  192. // $redis->set('recruit_quota',json_encode($quota));
  193. // }else{
  194. // $quota = json_decode($quota,true);
  195. // }
  196. // $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();
  197. //
  198. // $array_column = array_column($quota,'name');
  199. // foreach ($list as $k => $v){
  200. // $person_select_result = json_decode($v->result,true);
  201. // foreach ($person_select_result as $val){
  202. // //寻找下标
  203. // $index = array_search($val,$array_column);
  204. // if($quota[$index]['value'] > 0){
  205. // $quota_data = [
  206. // 'index' => $index,
  207. // 'old_value' => $quota[$index]['value']
  208. // ];
  209. // //有名额允许择岗
  210. // DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  211. // $v->select_result = $val;
  212. // $quota[$index]['value']--;
  213. // $quota_data['new_value'] = $quota[$index]['value'];
  214. // break;
  215. // }
  216. // }
  217. //
  218. //
  219. // }
  220. // $option_list = [
  221. // '青阳街道','梅岭街道','西园街道','罗山街道','灵源街道','新塘街道','陈埭镇','池店镇','安海镇','磁灶镇','内坑镇','紫帽镇','东石镇','永和镇','英林镇','金井镇','龙湖镇','深沪镇','西滨镇'
  222. // ];
  223. // $list = DB::table("recruit_appoint_info")->where('recruit_id',18)->where('audit',3)->where('pen_audit',1)->where('post_id',309)->get();
  224. // foreach ($list as $k => $v){
  225. // $uid = $v->uid;
  226. // $recruit_id = 18;
  227. // $appoint_id = $v->id;
  228. //// $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  229. //// if($info){
  230. //// return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  231. //// }
  232. // $data = [
  233. // 'recruit_id' => $recruit_id,
  234. // 'appoint_id' => $appoint_id,
  235. // 'uid' => $uid,
  236. // 'status' => 1,
  237. // 'record' => mt_rand(50.0,100)
  238. // ];
  239. // shuffle($option_list);
  240. // $select = array_slice($option_list,0,rand(1,19));
  241. // $result = [];
  242. // if(is_array($select) && count($select) > 0){
  243. // foreach ($select as $v) {
  244. // array_push($result,$v);
  245. // }
  246. // }
  247. // $data['result'] = json_encode($result);
  248. // RecruitAppointSelect::create($data);
  249. //
  250. // }
  251. $redis = Cache::getRedis();
  252. $redis->set('recruit_quota',false);
  253. // $list = DB::table("recruit_temp")->get();
  254. // foreach ($list as $k => $v){
  255. // $appoint_info = RecruitAppointInfo::where('card',$v->f3)->where('recruit_id',18)->first();
  256. // $data = [
  257. // 'batch' => 2,
  258. // 'appoint_id' => $appoint_info->id,
  259. // 'recruit_id' => 18,
  260. // 'uid' => $appoint_info->uid,
  261. // 'record' => $v->f6,
  262. // 'status' => 0
  263. // ];
  264. //
  265. // RecruitAppointSelect::create($data);
  266. // }
  267. // for ($room = 1;$room <= 78; $room++){
  268. // $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();
  269. //
  270. // $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
  271. // $sheet = $objPHPExcel->getActiveSheet();
  272. // $row = 4;
  273. // $sheet->setCellValue('A1', "晋江市公开招聘第十三批村务(社区)专职工作者笔试参考情况一览表(第".intval($room)."考场)");
  274. //
  275. // foreach ($list as $k => $v){
  276. // $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
  277. // $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
  278. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  279. // $row++;
  280. // }
  281. //
  282. // $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
  283. // $writer->save(base_path() . "/public/excel/cunwu{$room}.xlsx");
  284. // }
  285. // for ($room = 1;$room <= 78; $room++){
  286. // $word = new TemplateProcessor(base_path() . "/public/cunwu1.docx");
  287. // $word->setValue('room', $room);
  288. // if($room<10){
  289. // $room = sprintf('%02s', $room);
  290. // }
  291. // $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();
  292. // $rows = count($list);//总行数
  293. // $word->cloneRow('id', $rows);//复制行
  294. // for ($i = 0; $i < $rows; $i++) {
  295. // $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
  296. // $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
  297. // $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
  298. // }
  299. // $word->saveAs(base_path() ."/public/excel/cunwu_{$room}.docx");//另存为
  300. // }
  301. // $spreadsheet = new Spreadsheet();
  302. // $sheet = $spreadsheet->getActiveSheet();
  303. // $header = ['姓名','身份证','准考证','报考岗位'];
  304. // foreach ($header as $key => $value) {
  305. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  306. // }
  307. // $row = 2;
  308. // $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  309. // $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();
  310. // $post_data = RecruitPost::where('recruit_id',16)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  311. // foreach ($list as $k => $v){
  312. // $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
  313. // $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->card,DataType::TYPE_STRING);
  314. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  315. // $sheet->setCellValueByColumnAndRow('4',$row, $post_data[$v->post_id]);
  316. // $row++;
  317. // }
  318. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  319. // header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
  320. // header('Cache-Control: max-age=0');
  321. // // If you're serving to IE 9, then the following may be needed
  322. // header('Cache-Control: max-age=1');
  323. // // If you're serving to IE over SSL, then the following may be needed
  324. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  325. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  326. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  327. // header('Pragma: public'); // HTTP/1.0
  328. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  329. // $writer->save('php://output');
  330. echo "success";
  331. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  332. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  333. // $all = array_count_values($all);
  334. // $time = time();
  335. // $data = [
  336. // 'idCards' => $list,
  337. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  338. // 'timeStr' => $time,
  339. // ];
  340. // $data_string = json_encode($data);
  341. // $ch = curl_init ();
  342. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  343. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  344. // 'Content-Type: application/json',
  345. // 'Content-Length: ' . strlen($data_string))
  346. // );
  347. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  348. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  349. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  350. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  351. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  352. // curl_setopt( $ch, CURLOPT_POST, 1);
  353. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  354. // $result = curl_exec ( $ch );
  355. // curl_close ( $ch );
  356. // $ret = json_decode($result,true);
  357. // $res = [];
  358. // if(count($ret['obj']) > 0){
  359. // foreach ($ret['obj'] as $k => $v){
  360. // if(array_key_exists($v['street'],$res)){
  361. // $res[$v['street']]['number']++;
  362. // $res[$v['street']]['count'] += $all[$v['idCard']];
  363. // }else{
  364. // $res[$v['street']] = [
  365. // 'number' => 1,
  366. // 'count' => $all[$v['idCard']]
  367. // ];
  368. // }
  369. // }
  370. // }
  371. //
  372. // $spreadsheet = new Spreadsheet();
  373. // $sheet = $spreadsheet->getActiveSheet();
  374. // $header = ['镇街','使用人数','使用次数'];
  375. // foreach ($header as $key => $value) {
  376. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  377. // }
  378. // $row = 2;
  379. // foreach ($res as $k => $v){
  380. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  381. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  382. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  383. // $row++;
  384. // }
  385. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  386. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  387. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  388. // header('Cache-Control: max-age=0');
  389. // // If you're serving to IE 9, then the following may be needed
  390. // header('Cache-Control: max-age=1');
  391. // // If you're serving to IE over SSL, then the following may be needed
  392. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  393. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  394. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  395. // header('Pragma: public'); // HTTP/1.0
  396. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  397. // $writer->save('php://output');
  398. //
  399. // //dd($res);
  400. }
  401. }