|
|
|
@ -30,6 +30,16 @@ class updatestation extends CI_Controller
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function test(){
|
|
|
|
|
|
|
|
$results="";
|
|
|
|
|
|
|
|
for($i=1; $i<=90000; $i++){
|
|
|
|
|
|
|
|
$results.='"'.$i.'"';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$len = strlen($results);
|
|
|
|
|
|
|
|
header("Content-Length: $len");
|
|
|
|
|
|
|
|
echo $results;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @description: 从12306抓取数据对比翰特数据库
|
|
|
|
* @description: 从12306抓取数据对比翰特数据库
|
|
|
|
* @param {type}
|
|
|
|
* @param {type}
|
|
|
|
@ -43,18 +53,48 @@ class updatestation extends CI_Controller
|
|
|
|
$arr_Station = explode("@", str_replace("';", "", str_replace("var station_names ='", "", $StationData)));
|
|
|
|
$arr_Station = explode("@", str_replace("';", "", str_replace("var station_names ='", "", $StationData)));
|
|
|
|
//print_r($arr_Station);
|
|
|
|
//print_r($arr_Station);
|
|
|
|
$NewStation = "";
|
|
|
|
$NewStation = "";
|
|
|
|
|
|
|
|
$UpdateStaion="";
|
|
|
|
for ($i = 0; $i < count($arr_Station); $i++) {
|
|
|
|
for ($i = 0; $i < count($arr_Station); $i++) {
|
|
|
|
if ($arr_Station[$i] != null) {
|
|
|
|
if ($arr_Station[$i] != null) {
|
|
|
|
$arr_StationDetail = explode("|", $arr_Station[$i]);
|
|
|
|
$arr_StationDetail = explode("|", $arr_Station[$i]);
|
|
|
|
|
|
|
|
$TRS_Code = $arr_StationDetail[2];
|
|
|
|
|
|
|
|
$TRS_StationCN = $arr_StationDetail[1];
|
|
|
|
|
|
|
|
$TRS_Station = $arr_StationDetail[3];
|
|
|
|
// print_r($arr_StationDetail);
|
|
|
|
// print_r($arr_StationDetail);
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
$isNew = $this->station_model->GetStationCount($arr_StationDetail[2], $arr_StationDetail[1]);
|
|
|
|
$isNew = $this->station_model->CompareStation($TRS_Code, $TRS_StationCN);
|
|
|
|
if ($isNew) {
|
|
|
|
if ($isNew == 1) {
|
|
|
|
$NewStation .= $arr_Station[$i]."@";
|
|
|
|
//更新
|
|
|
|
|
|
|
|
$strStation = "@-1|" . $TRS_Code . "|" . $TRS_Station . "|" . $TRS_StationCN . "|2|";
|
|
|
|
|
|
|
|
$UpdateStaion .= $strStation;
|
|
|
|
|
|
|
|
//表操作
|
|
|
|
|
|
|
|
// $this->station_model->UpdateStation($TRS_Code, $TRS_StationCN);
|
|
|
|
|
|
|
|
} else if ($isNew == 2) {
|
|
|
|
|
|
|
|
//新增
|
|
|
|
|
|
|
|
$strStation = "@9999|" . $TRS_Code . "|" . $TRS_Station . "|" . $TRS_StationCN . "|2|";
|
|
|
|
|
|
|
|
$NewStation .= $strStation;
|
|
|
|
|
|
|
|
//表增加操作
|
|
|
|
|
|
|
|
$data["StationCN"] = $TRS_StationCN;
|
|
|
|
|
|
|
|
$data["Station"] = $TRS_Station;
|
|
|
|
|
|
|
|
$data["Code"] = $TRS_Code;
|
|
|
|
|
|
|
|
//$this->station_model->AddStation($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $NewStation;
|
|
|
|
$NewStationList = $UpdateStaion.$NewStation;
|
|
|
|
|
|
|
|
//发送邮件
|
|
|
|
|
|
|
|
$this->station_model->SendMail(
|
|
|
|
|
|
|
|
"UpdateStationSystem",
|
|
|
|
|
|
|
|
"noreplay@email.com",
|
|
|
|
|
|
|
|
'zhaopeng',
|
|
|
|
|
|
|
|
'zhaopeng@hainatravel.com',
|
|
|
|
|
|
|
|
'New Station(by12306):' . date("Y-m-d"),
|
|
|
|
|
|
|
|
$NewStationList
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$len = strlen($NewStationList);//count( explode("@",$NewStationList))-1;
|
|
|
|
|
|
|
|
header("Content-Length: $len");
|
|
|
|
|
|
|
|
echo $NewStationList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -76,50 +116,60 @@ class updatestation extends CI_Controller
|
|
|
|
for ($i = 0; $i < count($arr_Station); $i++) {
|
|
|
|
for ($i = 0; $i < count($arr_Station); $i++) {
|
|
|
|
$isNew = true;
|
|
|
|
$isNew = true;
|
|
|
|
$arr_StationDetail = explode("|", $arr_Station[$i]);
|
|
|
|
$arr_StationDetail = explode("|", $arr_Station[$i]);
|
|
|
|
for ($j = 0; $j < count($arr_StationFile); $j++) {
|
|
|
|
for ($j = 0; $j < count($arr_StationFile); $j++) {
|
|
|
|
if ($arr_Station[$i] != null) {
|
|
|
|
if ($arr_Station[$i] != null) {
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$j]);
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$j]);
|
|
|
|
//对比目前的站点文件,如果是新的就保存
|
|
|
|
//对比目前的站点文件,如果是新的就保存
|
|
|
|
if ($arr_StationDetail[2] == $arr_StationFileDetail[1] && $arr_StationDetail[1] == $arr_StationFileDetail[3]) {
|
|
|
|
if ($arr_StationDetail[2] == $arr_StationFileDetail[1] && $arr_StationDetail[1] == $arr_StationFileDetail[3]) {
|
|
|
|
//break;
|
|
|
|
|
|
|
|
$isNew = false;
|
|
|
|
$isNew = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
// continue 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($isNew) {
|
|
|
|
if ($isNew) {
|
|
|
|
$NewStation .= $arr_Station[$i]."@";
|
|
|
|
$NewStation .= $arr_Station[$i] . "@";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $NewStation;
|
|
|
|
echo $NewStation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @description: 目前站点文件与翰特数据对比
|
|
|
|
* @description: 目前站点文件与翰特数据对比,导入HT没有的数据
|
|
|
|
* @param {type}
|
|
|
|
* @param {type}
|
|
|
|
* @return:
|
|
|
|
* @return:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function CheckFileAndHT(){
|
|
|
|
public function CheckFileAndHT()
|
|
|
|
|
|
|
|
{
|
|
|
|
$StationFileUrl = "https://biz.chinahighlights.com/china-trains/js/train/StationInfo.js";
|
|
|
|
$StationFileUrl = "https://biz.chinahighlights.com/china-trains/js/train/StationInfo.js";
|
|
|
|
$StationFileData = $this->get_data($StationFileUrl);
|
|
|
|
$StationFileData = $this->get_data($StationFileUrl);
|
|
|
|
$arr_StationFile = explode("@", str_replace("\";", "", str_replace("var station_names =\"", "", $StationFileData)));
|
|
|
|
$arr_StationFile = explode("@", str_replace("\";", "", str_replace("var station_names =\"", "", $StationFileData)));
|
|
|
|
$NewStation = "";
|
|
|
|
$NewStation = "";
|
|
|
|
for ($i=0;$i<count($arr_StationFile);$i++){
|
|
|
|
for ($i = 0; $i < count($arr_StationFile); $i++) {
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$i]);
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$i]);
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
$isNew = $this->station_model->GetStationCount($arr_StationFileDetail[1], $arr_StationFileDetail[3]);
|
|
|
|
$isNew = $this->station_model->GetStationCount($arr_StationFileDetail[1], $arr_StationFileDetail[3]);
|
|
|
|
if ($isNew) {
|
|
|
|
if ($isNew) {
|
|
|
|
$NewStation .= $arr_StationFile[$i]."@";
|
|
|
|
$NewStation .= $arr_StationFile[$i] . "@";
|
|
|
|
|
|
|
|
|
|
|
|
//保存到数据库
|
|
|
|
//保存到数据库
|
|
|
|
$data["StationCN"] = $arr_StationFileDetail[3];
|
|
|
|
$data["StationCN"] = $arr_StationFileDetail[3];
|
|
|
|
$data["Station"] = $arr_StationFileDetail[2];
|
|
|
|
$data["Station"] = $arr_StationFileDetail[2];
|
|
|
|
$data["Code"] = $arr_StationFileDetail[1];
|
|
|
|
$data["Code"] = $arr_StationFileDetail[1];
|
|
|
|
$this->station_model->AddStation($data);
|
|
|
|
$this->station_model->AddStation($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $NewStation;
|
|
|
|
echo $NewStation;
|
|
|
|
|
|
|
|
//发送邮件
|
|
|
|
|
|
|
|
$this->station_model->SendMail(
|
|
|
|
|
|
|
|
"UpdateStationSystem",
|
|
|
|
|
|
|
|
"noreplay@email.com",
|
|
|
|
|
|
|
|
'zhaopeng',
|
|
|
|
|
|
|
|
'zhaopeng@hainatravel.com',
|
|
|
|
|
|
|
|
'站点文件导入HT:' . date("Y-m-d"),
|
|
|
|
|
|
|
|
$NewStation
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -128,7 +178,8 @@ class updatestation extends CI_Controller
|
|
|
|
* @param {type}
|
|
|
|
* @param {type}
|
|
|
|
* @return:
|
|
|
|
* @return:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function GetNewStationFromHT(){
|
|
|
|
public function GetNewStationFromHT()
|
|
|
|
|
|
|
|
{
|
|
|
|
//先获取当前使用的站点文件
|
|
|
|
//先获取当前使用的站点文件
|
|
|
|
$StationFileUrl = "https://biz.chinahighlights.com/china-trains/js/train/StationInfo.js";
|
|
|
|
$StationFileUrl = "https://biz.chinahighlights.com/china-trains/js/train/StationInfo.js";
|
|
|
|
$StationFileData = $this->get_data($StationFileUrl);
|
|
|
|
$StationFileData = $this->get_data($StationFileUrl);
|
|
|
|
@ -137,24 +188,36 @@ class updatestation extends CI_Controller
|
|
|
|
|
|
|
|
|
|
|
|
//循环HT站点表对比
|
|
|
|
//循环HT站点表对比
|
|
|
|
$StationList = $this->station_model->GetStationList();
|
|
|
|
$StationList = $this->station_model->GetStationList();
|
|
|
|
foreach($StationList as $Item){
|
|
|
|
foreach ($StationList as $Item) {
|
|
|
|
$isNew = true;
|
|
|
|
$isNew = true;
|
|
|
|
for ($i=0;$i<count($arr_StationFile);$i++){
|
|
|
|
$TRS_ID = $Item->TRS_ID;
|
|
|
|
|
|
|
|
$TRS_StationCN = $Item->TRS_StationCN;
|
|
|
|
|
|
|
|
$TRS_Station = $Item->TRS_Station;
|
|
|
|
|
|
|
|
$TRS_Code = $Item->TRS_Code;
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($arr_StationFile); $i++) {
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$i]);
|
|
|
|
$arr_StationFileDetail = explode("|", $arr_StationFile[$i]);
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
//对比数据库,如果是新的就保存
|
|
|
|
$TRS_StationCN = $Item->TRS_StationCN;
|
|
|
|
if ($TRS_StationCN == $arr_StationFileDetail[3] && $TRS_Code == $arr_StationFileDetail[1]) {
|
|
|
|
$TRS_Station = $Item->TRS_Station;
|
|
|
|
|
|
|
|
$TRS_Code = $Item->TRS_Code;
|
|
|
|
|
|
|
|
if ($TRS_StationCN==$arr_StationFileDetail[3] && $TRS_Code==$arr_StationFileDetail[1]){
|
|
|
|
|
|
|
|
$isNew = false;
|
|
|
|
$isNew = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($isNew) {
|
|
|
|
if ($isNew) {
|
|
|
|
$NewStation .= $arr_StationFile[$i]."@";
|
|
|
|
$strStation = "@" . $TRS_ID . "|" . $TRS_Code . "|" . $TRS_Station . "|" . $TRS_StationCN . "|2|";
|
|
|
|
|
|
|
|
$NewStation .= $strStation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $NewStation;
|
|
|
|
// echo $NewStation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发送邮件
|
|
|
|
|
|
|
|
$this->station_model->SendMail(
|
|
|
|
|
|
|
|
"UpdateStationSystem",
|
|
|
|
|
|
|
|
"noreplay@email.com",
|
|
|
|
|
|
|
|
'zhaopeng',
|
|
|
|
|
|
|
|
'zhaopeng@hainatravel.com',
|
|
|
|
|
|
|
|
'New Station:' . date("Y-m-d"),
|
|
|
|
|
|
|
|
$NewStation
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|