public static function updateDoctor() { self::$log->debugLog("Begin Update Ths Doctor"); //$i = 2; $list = Refer::getStock(); foreach ($list as $item) { //if (--$i < 0 ) break; if ('sz300033' == $item['code']) { continue; } $numCode = substr($item['code'], 2); $url = "http://doctor.10jqka.com.cn/" . $numCode . '/'; self::$log->debugLog($item['name'], $item['code'], $url); $html = ThsDoctorKeeper::fetchSingleThsDoctor($url, $numCode); if ($html) { self::$log->debugLog($item['name'], $item['code'], "Fetch ThsDoctor Success"); $now = ThsDoctorKeeper::parseThsDoctorHtml($html); if ($now) { $tdd = new ThsDoctorData($item['code']); $last = $tdd->getThsDoctorData(); //print_r($last); if ($last) { $updata = ThsDoctorKeeper::mergeThsDoctorUpdate($last, $now); ThsDoctorKeeper::addThsDoctor($tdd->getDataFile(), $updata); } else { $updata = $now; ThsDoctorKeeper::putThsDoctor($tdd->getDataFile(), $updata); } self::$log->noticeLog($item['name'], $item['code'], "Update ThsDoctor Success"); } else { self::$log->errorLog($item['name'], $item['code'], "Parse ThsDoctor Failed"); self::$tmp->putTmpContent('thsdoctor.duty.failed', join(":", $item) . "|", FILE_APPEND); } $now = ThsDoctorKeeper::parseThsDoctorMesHtml($html); if ($now) { $tdmd = new ThsDoctorMesData($item['code']); $last = $tdmd->getThsDoctorMesData(); //print_r($last); if ($last) { $updata = ThsDoctorKeeper::mergeThsDoctorMesUpdate($last, $now); ThsDoctorKeeper::addThsDoctor($tdmd->getDataFile(), $updata); } else { $updata = $now; ThsDoctorKeeper::putThsDoctor($tdmd->getDataFile(), $updata); } self::$log->noticeLog($item['name'], $item['code'], "Update ThsDoctorMes Success"); } else { self::$log->errorLog($item['name'], $item['code'], "Parse ThsDoctorMes Failed"); } } else { self::$log->errorLog($item['name'], $item['code'], "Fetch ThsDoctor Failed"); self::$tmp->putTmpContent('thsdoctor.duty.failed', join(":", $item) . "|", FILE_APPEND); } } self::$log->debugLog("Finish Update Ths Doctor"); }
public static function testThsDoctorData() { $td = new ThsDoctorData('sz300313'); $rows = $td->getThsDoctorData(); $columns = array_keys($rows[0]); for ($i = 0; $i < sizeof($columns); $i++) { $t = str_replace('_', ' ', $columns[$i]); $columns[$i] = array('title' => $t, 'data' => $columns[$i]); } echo json_encode(array('columns' => $columns, 'rows' => $rows)); }
public static function show() { parent::show(); $stockInfo = array(); $stockInfo["code"] = $_GET["code"]; $i = Refer::searchCode($stockInfo["code"]); if (!$i) { exit(0); } $stockInfo["name"] = $i['name']; $stockInfo["spell"] = $i['spell']; $stockInfo["period"] = null; /* * $stockInfo["period"] = array('start'=>strtotime("Thu May 28 00:00:00 +0800 2015")*1000, 'end'=>strtotime("Mon Dec 23 00:00:00 +0800 2015")*1000); */ $stockInfo["right"] = "before"; $gd = new GbbqData($stockInfo["code"]); $gbbq = $gd->getGbbqLabel(); $stockInfo['gbbq'] = $gbbq; $dd = new DdeData($stockInfo["code"]); $dde = $dd->getDdeData(); $stockInfo['dde'] = $dde; $tdd = new ThsDoctorData($stockInfo["code"]); $ths = $tdd->getThsDoctorData(); $stockInfo['ths'] = $ths; $ld = new LhbData($stockInfo["code"]); $lhb = $ld->getLhbData(); $stockInfo['lhb'] = $lhb; $rd = new RateData($stockInfo["code"]); $rate = RateData::filterBuy($rd->getRateData()); $stockInfo['rate'] = $rate; $stockInfo['day'] = array(); $typeRight = array("normal", "before", "after"); foreach ($typeRight as $aTypeRight) { $dd = new DayData($stockInfo["code"], $aTypeRight); if ($dd->prepareData()) { $stockInfo['day'][$aTypeRight] = $dd->getStockData(); } else { $stockInfo['day'][$aTypeRight] = null; } } self::setTitle($stockInfo['name'] . '(' . $stockInfo['code'] . ') - Stock -- ForeShadow (Alpha)'); self::$smarty->assign('historyUrl', Url::getBasePhp('History')); self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite')); self::$smarty->assign('rawData', json_encode($stockInfo)); self::$smarty->display('Chart.tpl'); }