JjhcController.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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 = 1;$i<=3;$i++){
  68. $list = DB::table("companys")->where('updated_at','>','2019-01-01 00:00:00')->where('huiju',0)->orderBy('created_at','asc')->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. <username name="企业登录名" isattachment="false"><![CDATA[%s]]></username>
  74. <mobile name="手机号" isattachment="false"><![CDATA[%s]]></mobile>
  75. <mobile_audit name="手机认证状态" isattachment="false"><![CDATA[%s]]></mobile_audit>
  76. <email name="邮箱" isattachment="false"><![CDATA[%s]]></email>
  77. <email_audit name="邮箱认证状态" isattachment="false"><![CDATA[%s]]></email_audit>
  78. <reg_time name="注册时间" isattachment="false"><![CDATA[%s]]></reg_time>
  79. <reg_ip name="注册ip" isattachment="false"><![CDATA[%s]]></reg_ip>
  80. <last_login_time name="最后登录时间" isattachment="false"><![CDATA[%s]]></last_login_time>
  81. <last_login_ip name="最后登录ip" isattachment="false"><![CDATA[%s]]></last_login_ip>
  82. <reg_address name="注册地址" isattachment="false"><![CDATA[%s]]></reg_address>
  83. <reg_type name="注册方式" isattachment="false"><![CDATA[%s]]></reg_type>
  84. <companyname name="企业名称" isattachment="false"><![CDATA[%s]]></companyname>
  85. <certificate_img name="营业执照" isattachment="false"><![CDATA[%s]]></certificate_img>
  86. <legal name="法人姓名" isattachment="false"><![CDATA[%s]]></legal>
  87. <legal_idcard name="法人身份证" isattachment="false"><![CDATA[%s]]></legal_idcard>
  88. </row>';
  89. foreach ($list as $k => $v){
  90. $certificate_img = empty($v->certificate_img) ? '无' : $v->certificate_img;
  91. $item_str = sprintf($template,$v->id,$v->username,$v->mobile,$v->mobile_audit,$v->email,$v->email_audit,$v->reg_time,$v->reg_ip,$v->last_login_time,$v->last_login_ip,$v->reg_address,$v->reg_type,$v->companyname,$certificate_img,$v->legal,$v->legal_idcard);
  92. $str .= $item_str;
  93. }
  94. $str .= '</table>';
  95. try{
  96. $client = new \SoapClient('http://61.131.47.134:8756/Convergence/webservice/ConvergenceService?wsdl');
  97. // 组织参数 根据接口具体提供参数组织对应参数
  98. $param = [
  99. 'guid'=>$guid,
  100. 'catalogid'=>'WEB2458',
  101. 'xmlstr' => $str
  102. ];
  103. $res = $client->pushXml($param);
  104. echo $res->return;
  105. } catch (\Exception $e){
  106. dd($e->getMessage());
  107. }
  108. }
  109. $index += 500;
  110. }
  111. echo $index;
  112. }
  113. public function test(Request $request)
  114. {
  115. $keyword = $request->input('keyword');
  116. if($keyword != "j0vOW5mBREZxdo3P"){
  117. throw new ResponseException("who are you?", [], 404);
  118. }
  119. // $redis = Cache::getRedis();
  120. // $quota = $redis->get('recruit_quota');
  121. // if(!$quota){
  122. // $quota = [
  123. // [
  124. // 'name' => '新塘街道',
  125. // 'value' => 13
  126. // ],
  127. // [
  128. // 'name' => '陈埭镇',
  129. // 'value' => 88
  130. // ],
  131. // [
  132. // 'name' => '池店镇',
  133. // 'value' => 10
  134. // ],
  135. // [
  136. // 'name' => '安海镇',
  137. // 'value' => 10
  138. // ],
  139. // [
  140. // 'name' => '磁灶镇',
  141. // 'value' => 21
  142. // ],
  143. // [
  144. // 'name' => '内坑镇',
  145. // 'value' => 22
  146. // ],
  147. // [
  148. // 'name' => '东石镇',
  149. // 'value' => 4
  150. // ],
  151. // [
  152. // 'name' => '永和镇',
  153. // 'value' => 27
  154. // ],
  155. // [
  156. // 'name' => '英林镇',
  157. // 'value' => 5
  158. // ],
  159. // [
  160. // 'name' => '金井镇',
  161. // 'value' => 13
  162. // ],
  163. // [
  164. // 'name' => '龙湖镇',
  165. // 'value' => 53
  166. // ],
  167. // [
  168. // 'name' => '深沪镇',
  169. // 'value' => 23
  170. // ],
  171. // [
  172. // 'name' => '西滨镇',
  173. // 'value' => 3
  174. // ]
  175. // ];
  176. // $redis->set('recruit_quota',json_encode($quota));
  177. // }else{
  178. // $quota = json_decode($quota,true);
  179. // }
  180. // $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();
  181. //
  182. // $array_column = array_column($quota,'name');
  183. // foreach ($list as $k => $v){
  184. // $person_select_result = json_decode($v->result,true);
  185. // foreach ($person_select_result as $val){
  186. // //寻找下标
  187. // $index = array_search($val,$array_column);
  188. // if($quota[$index]['value'] > 0){
  189. // $quota_data = [
  190. // 'index' => $index,
  191. // 'old_value' => $quota[$index]['value']
  192. // ];
  193. // //有名额允许择岗
  194. // DB::table('recruit_appoint_select')->where('id',$v->id)->update(['select_result'=>$val,'status' => 1]);
  195. // $v->select_result = $val;
  196. // $quota[$index]['value']--;
  197. // $quota_data['new_value'] = $quota[$index]['value'];
  198. // break;
  199. // }
  200. // }
  201. //
  202. //
  203. // }
  204. // $option_list = [
  205. // '青阳街道','梅岭街道','西园街道','罗山街道','灵源街道','新塘街道','陈埭镇','池店镇','安海镇','磁灶镇','内坑镇','紫帽镇','东石镇','永和镇','英林镇','金井镇','龙湖镇','深沪镇','西滨镇'
  206. // ];
  207. // $list = DB::table("recruit_appoint_info")->where('recruit_id',18)->where('audit',3)->where('pen_audit',1)->where('post_id',309)->get();
  208. // foreach ($list as $k => $v){
  209. // $uid = $v->uid;
  210. // $recruit_id = 18;
  211. // $appoint_id = $v->id;
  212. //// $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
  213. //// if($info){
  214. //// return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
  215. //// }
  216. // $data = [
  217. // 'recruit_id' => $recruit_id,
  218. // 'appoint_id' => $appoint_id,
  219. // 'uid' => $uid,
  220. // 'status' => 1,
  221. // 'record' => mt_rand(50.0,100)
  222. // ];
  223. // shuffle($option_list);
  224. // $select = array_slice($option_list,0,rand(1,19));
  225. // $result = [];
  226. // if(is_array($select) && count($select) > 0){
  227. // foreach ($select as $v) {
  228. // array_push($result,$v);
  229. // }
  230. // }
  231. // $data['result'] = json_encode($result);
  232. // RecruitAppointSelect::create($data);
  233. //
  234. // }
  235. $redis = Cache::getRedis();
  236. $redis->set('recruit_quota',false);
  237. // $list = DB::table("recruit_temp")->get();
  238. // foreach ($list as $k => $v){
  239. // $appoint_info = RecruitAppointInfo::where('card',$v->f3)->where('recruit_id',18)->first();
  240. // $data = [
  241. // 'batch' => 2,
  242. // 'appoint_id' => $appoint_info->id,
  243. // 'recruit_id' => 18,
  244. // 'uid' => $appoint_info->uid,
  245. // 'record' => $v->f6,
  246. // 'status' => 0
  247. // ];
  248. //
  249. // RecruitAppointSelect::create($data);
  250. // }
  251. // for ($room = 1;$room <= 78; $room++){
  252. // $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();
  253. //
  254. // $objPHPExcel = IOFactory::load(base_path() . "/public/cunwu.xlsx");
  255. // $sheet = $objPHPExcel->getActiveSheet();
  256. // $row = 4;
  257. // $sheet->setCellValue('A1', "晋江市公开招聘第十三批村务(社区)专职工作者笔试参考情况一览表(第".intval($room)."考场)");
  258. //
  259. // foreach ($list as $k => $v){
  260. // $sheet->setCellValueByColumnAndRow('1',$row, $v->ex_seat);
  261. // $sheet->setCellValueByColumnAndRow('2',$row, $v->realname);
  262. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  263. // $row++;
  264. // }
  265. //
  266. // $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
  267. // $writer->save(base_path() . "/public/excel/cunwu{$room}.xlsx");
  268. // }
  269. // for ($room = 1;$room <= 78; $room++){
  270. // $word = new TemplateProcessor(base_path() . "/public/cunwu1.docx");
  271. // $word->setValue('room', $room);
  272. // if($room<10){
  273. // $room = sprintf('%02s', $room);
  274. // }
  275. // $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();
  276. // $rows = count($list);//总行数
  277. // $word->cloneRow('id', $rows);//复制行
  278. // for ($i = 0; $i < $rows; $i++) {
  279. // $word->setValue("id#" . ($i + 1), $i + 1);//替换变量
  280. // $word->setValue("realname#" . ($i + 1), $list[$i]->realname);
  281. // $word->setValue("ex_number#" . ($i + 1), $list[$i]->ex_number);
  282. // }
  283. // $word->saveAs(base_path() ."/public/excel/cunwu_{$room}.docx");//另存为
  284. // }
  285. // $spreadsheet = new Spreadsheet();
  286. // $sheet = $spreadsheet->getActiveSheet();
  287. // $header = ['姓名','身份证','准考证','报考岗位'];
  288. // foreach ($header as $key => $value) {
  289. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  290. // }
  291. // $row = 2;
  292. // $sheet->getStyle('S')->getNumberFormat()->setFormatCode('0');
  293. // $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();
  294. // $post_data = RecruitPost::where('recruit_id',16)->where('status',1)->selectRaw('id, CONCAT(code," ",name) as post')->pluck('post', 'id');
  295. // foreach ($list as $k => $v){
  296. // $sheet->setCellValueByColumnAndRow('1',$row, $v->realname);
  297. // $sheet->setCellValueExplicitByColumnAndRow('2',$row, $v->card,DataType::TYPE_STRING);
  298. // $sheet->setCellValueExplicitByColumnAndRow('3',$row, $v->ex_number,DataType::TYPE_STRING);
  299. // $sheet->setCellValueByColumnAndRow('4',$row, $post_data[$v->post_id]);
  300. // $row++;
  301. // }
  302. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  303. // header('Content-Disposition: attachment;filename="'.time().'.xlsx"');
  304. // header('Cache-Control: max-age=0');
  305. // // If you're serving to IE 9, then the following may be needed
  306. // header('Cache-Control: max-age=1');
  307. // // If you're serving to IE over SSL, then the following may be needed
  308. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  309. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  310. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  311. // header('Pragma: public'); // HTTP/1.0
  312. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  313. // $writer->save('php://output');
  314. echo "success";
  315. // $list = DB::table('lt_apppointment')->distinct()->pluck('card')->toArray();
  316. // $all = DB::table('lt_apppointment')->pluck('card')->toArray();
  317. // $all = array_count_values($all);
  318. // $time = time();
  319. // $data = [
  320. // 'idCards' => $list,
  321. // 'sign' => strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  322. // 'timeStr' => $time,
  323. // ];
  324. // $data_string = json_encode($data);
  325. // $ch = curl_init ();
  326. // curl_setopt( $ch, CURLOPT_URL, "http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards" );
  327. // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  328. // 'Content-Type: application/json',
  329. // 'Content-Length: ' . strlen($data_string))
  330. // );
  331. // curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  332. // curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  333. // curl_setopt( $ch, CURLOPT_TIMEOUT,60);
  334. // curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
  335. // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
  336. // curl_setopt( $ch, CURLOPT_POST, 1);
  337. // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  338. // $result = curl_exec ( $ch );
  339. // curl_close ( $ch );
  340. // $ret = json_decode($result,true);
  341. // $res = [];
  342. // if(count($ret['obj']) > 0){
  343. // foreach ($ret['obj'] as $k => $v){
  344. // if(array_key_exists($v['street'],$res)){
  345. // $res[$v['street']]['number']++;
  346. // $res[$v['street']]['count'] += $all[$v['idCard']];
  347. // }else{
  348. // $res[$v['street']] = [
  349. // 'number' => 1,
  350. // 'count' => $all[$v['idCard']]
  351. // ];
  352. // }
  353. // }
  354. // }
  355. //
  356. // $spreadsheet = new Spreadsheet();
  357. // $sheet = $spreadsheet->getActiveSheet();
  358. // $header = ['镇街','使用人数','使用次数'];
  359. // foreach ($header as $key => $value) {
  360. // $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  361. // }
  362. // $row = 2;
  363. // foreach ($res as $k => $v){
  364. // $sheet->setCellValueByColumnAndRow(1, $row, $k);
  365. // $sheet->setCellValueByColumnAndRow(2, $row, $v['number']);
  366. // $sheet->setCellValueByColumnAndRow(3, $row, $v['count']);
  367. // $row++;
  368. // }
  369. // $file_name = date("Y-m-d",time()) . '码上服务数据';
  370. // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  371. // header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
  372. // header('Cache-Control: max-age=0');
  373. // // If you're serving to IE 9, then the following may be needed
  374. // header('Cache-Control: max-age=1');
  375. // // If you're serving to IE over SSL, then the following may be needed
  376. // header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  377. // header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  378. // header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  379. // header('Pragma: public'); // HTTP/1.0
  380. // $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  381. // $writer->save('php://output');
  382. //
  383. // //dd($res);
  384. }
  385. }