JjhcController.php 17 KB

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