예제 #1
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 获取任务
     $tasks = Util_SearchUtil::getHzPropsListFromSolr($this->cityId, $this->lastLogId, $this->limit);
     if ($tasks === false) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败');
         exit;
     }
     if (empty($tasks)) {
         // 任务完成
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成');
         $this->setStop();
         $this->setShStopFlag();
         $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->cityId => 0)));
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->dealTask($task);
         $this->lastLogId += 1;
     }
     //记录游标
     $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->cityId => $this->lastLogId)));
 }
예제 #2
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 获取任务
     // TODO传入对应城市列表
     $tasks = Util_SearchUtil::getHzPropsListFromSolr(self::getCityIdByTable(), $this->lastLogId, $this->limit);
     if ($tasks === false) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败');
         exit;
     }
     if (empty($tasks)) {
         // 任务完成
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成');
         $this->setStop();
         $this->setShStopFlag();
         $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => 0)));
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->proceLog = date('Y-m-d H:i:s') . ' solrId:' . $this->lastLogId . ' proId:' . $task['id'] . ' ';
         $this->dealTask($task);
         //记录日志
         $this->setLog($this->proceLog);
         $this->lastLogId += 1;
     }
     //记录游标
     $this->setFlag(array_merge($this->getFlag(), array('lastLogId' . $this->table => $this->lastLogId)));
     /*
             // 发邮件获取记录日志
             if (!empty($this->errorPropIds) || !empty($this->emptyPropIds)) {
                 Bll_House_UpDown_Worker_MailBll::getInstance()->setSubject('房源不在线 solr却在线')->send(array('message' => json_encode(array(
                     array('error prop' => $this->errorPropIds),
                     array('prop not found in db' => $this->emptyPropIds)
                 ))));
             }*/
 }