mzyQyxxInsert(); $this->jlQyxxInsert(); echo '时长:'.number_format(((time()-$start_time)/60),2).'分钟'; } //化工人员定位煤制油区域信息录入 public function mzyQyxxInsert(){ //获取token $url = 'http://10.186.64.30:8091/chem/api/getToken?username=super&password=meizhiyou'; $result = $this->httpRequest($url,'post'); if($result['data']){ //获取部门列表 $url = 'http://10.186.64.30:8091/chem/api/getAreaInfo?token='.$result['data']; $result2 = $this->httpRequest($url); // dd($result2); if($result2['data'] && count($result2['data']) > 0){ DB::connection('mysql_fwe10')->table('uf_mzy_total')->delete(); DB::connection('mysql_fwe10')->table('uf_mzy_parent_counts')->delete(); DB::connection('mysql_fwe10')->table('uf_mzy_counts')->delete(); DB::connection('mysql_fwe10')->table('uf_mzy_type')->delete(); //uf_mzy_total $total['total'] = $result2['data']['total']; $total['staffNumb'] = $result2['data']['staffNumb']; $total['callerNumb'] = $result2['data']['callerNumb']; $total['carNumb'] = $result2['data']['carNumb']; $total['contractorNumb'] = $result2['data']['contractorNumb']; $total['toolcarNumb'] = $result2['data']['toolcarNumb']; DB::connection('mysql_fwe10')->table('uf_mzy_total')->insert($total); $counts_list = $result2['data']['counts']; if(count($counts_list) > 0){ for($i=0;$itable('uf_mzy_parent_counts')->insertGetId($pcounts); if(count($counts_list[$i]['counts']) > 0){ for($j=0;$jtable('uf_mzy_counts')->insert($counts); $persons = $counts_list[$i]['counts'][$j]['persons']; $personContractor = $counts_list[$i]['counts'][$j]['personContractor']; $personCaller = $counts_list[$i]['counts'][$j]['personCaller']; $car = $counts_list[$i]['counts'][$j]['car']; if(count($persons) > 0){ for($x=0;$xtable('uf_mzy_type')->insert($type); } } if(count($personContractor) > 0){ for($x=0;$xtable('uf_mzy_type')->insert($type); } } if(count($personCaller) > 0){ for($x=0;$xtable('uf_mzy_type')->insert($type); } } if(count($car) > 0){ for($x=0;$xtable('uf_mzy_type')->insert($type); } } } } // dd($id); } } // dd(123); } } } //化工人员定位精蜡区域信息录入 public function jlQyxxInsert(){ //获取token $url = 'http://10.186.64.31:8091/chem/api/getToken?username=test&password=123456'; $result = $this->httpRequest($url,'post'); if($result['data']){ //获取部门列表 $url = 'http://10.186.64.31:8091/chem/api/getAreaInfo?token='.$result['data']; $result2 = $this->httpRequest($url); // dd($result2); if($result2['data'] && count($result2['data']) > 0){ DB::connection('mysql_fwe10')->table('uf_jl_total')->delete(); DB::connection('mysql_fwe10')->table('uf_jl_parent_counts')->delete(); DB::connection('mysql_fwe10')->table('uf_jl_counts')->delete(); DB::connection('mysql_fwe10')->table('uf_jl_type')->delete(); //uf_mzy_total $total['total'] = $result2['data']['total']; $total['staffNumb'] = $result2['data']['staffNumb']; $total['callerNumb'] = $result2['data']['callerNumb']; $total['carNumb'] = $result2['data']['carNumb']; $total['contractorNumb'] = $result2['data']['contractorNumb']; $total['toolcarNumb'] = $result2['data']['toolcarNumb']; DB::connection('mysql_fwe10')->table('uf_jl_total')->insert($total); $counts_list = $result2['data']['counts']; if(count($counts_list) > 0){ for($i=0;$itable('uf_jl_parent_counts')->insertGetId($pcounts); if(count($counts_list[$i]['counts']) > 0){ for($j=0;$jtable('uf_jl_counts')->insert($counts); $persons = $counts_list[$i]['counts'][$j]['persons']; $personContractor = $counts_list[$i]['counts'][$j]['personContractor']; $personCaller = $counts_list[$i]['counts'][$j]['personCaller']; $car = $counts_list[$i]['counts'][$j]['car']; if(count($persons) > 0){ for($x=0;$xtable('uf_jl_type')->insert($type); } } if(count($personContractor) > 0){ for($x=0;$xtable('uf_jl_type')->insert($type); } } if(count($personCaller) > 0){ for($x=0;$xtable('uf_jl_type')->insert($type); } } if(count($car) > 0){ for($x=0;$xtable('uf_jl_type')->insert($type); } } } } // dd($id); } } // dd(123); } } } //接口第三方调用 public function httpRequest($url, $format = 'get', $data = null, $token = null){ //设置头信息 $headerArray =array("Content-type:application/json;","Accept:application/json"); if ($token) { $headerArray[] = "Authorization:bearer " . $token; } $curl=curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if ($format == 'post') { //post传值设置post传参 curl_setopt($curl, CURLOPT_POST, 1); if ($data) { $data = json_encode($data); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray); $data=json_decode(curl_exec($curl), true); curl_close($curl); //返回接口返回数据 return $data; } }