Example #1
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     // 获取操作信息
     $action = Bll_Cms_BlockChange::getActionWithCommunity($this->actionId);
     if (empty($action) || empty($action['comms'])) {
         $this->writeLog('all action is finished');
         return false;
     }
     $isFinish = false;
     // 判断之前动作是否处理完
     if ($doListData = Bll_Cms_BlockChange::getDoList($action['id'], 3)) {
         if ($doListData['status'] == 2) {
             $isFinish = true;
         }
     } else {
         $this->writeLog('获取actionid=' . $action['id'] . '的dolist为空或者失败');
         return false;
     }
     if (!$isFinish) {
         $this->writeLog('action:' . $action['id'] . ' 正在' . $doListData['list_id'] . '处理阶段');
         return false;
     }
     // 标记处理状态
     Bll_Cms_BlockChange::updateDoList($action['id'], 4, 1, 'action:' . $action['id'] . ' list_id:4 处理中');
     // 处理comms
     $result = Bll_Cms_BlockChange::dealActionComms($action);
     // 更新dolist表
     if ($result && $result['status']) {
         Bll_Cms_BlockChange::updateDoList($action['id'], 4, 2);
         // 记录本次actionid
         file_put_contents($this->logDir . 'hzblock_change_actionid.log', $action['id']);
     } else {
         $errMsg = $result['msg'];
         Bll_Cms_BlockChange::updateDoList($action['id'], 4, 3, is_string($errMsg) ? $errMsg : implode(',', $errMsg));
     }
     // 记录log
     if ($result['msg'] && is_array($result['msg'])) {
         foreach ($result['msg'] as $msg) {
             $this->writeLog($msg);
         }
     }
 }
 public function handle_request()
 {
     $this->setLog(sprintf('[%s] start actionId: %s', date('Y-m-d H:i:s'), $this->actionId));
     // 获取任务
     $tasks = $this->getTasks();
     if ($tasks === false) {
         $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '获取数据失败'));
         exit;
     }
     if (empty($tasks)) {
         //没有数据
         // 更新action完成
         Bll_Cms_BlockChange::updateAction($this->actionId, 1);
         // 任务完成
         $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '任务执行完成'));
         exit;
     }
     // 循环处理任务
     foreach ($tasks as $task) {
         $this->dealTask($task);
     }
     $this->setLog(sprintf('[%s] end actionId: %s', date('Y-m-d H:i:s'), $this->actionId));
 }
Example #3
0
 /**
  * 处理comms业务功能
  * @param $action
  */
 public static function dealActionComms($action)
 {
     $allResult = array();
     //添加去重数组,为更新租房commid=0的数据做准备
     $blockInfoArr = array();
     foreach ($action['comms'] as $comm) {
         $blockInof = Bll_HzProp::getBlockByTypeCode($comm['new_block_code'], array(0, 1), true);
         // 判断小区solr是否ok
         $ajkBlock = Dao_Broker_HzProp::getAjkBlockInfo($comm['new_block_code']);
         if (!$ajkBlock) {
             return self::buildReturn(0, '二手房没有该板块:' . $comm['new_block_code']);
         }
         if (!Bll_HzProp::isCommSolrUpdated($ajkBlock['TypeId'], $ajkBlock['ParentId'], $blockInof['cityid'], $comm['community_id'], $comm['community_name'])) {
             return self::buildReturn(0, '租房小区solr还没更新完,动作id:' . $action['id'] . ' 小区id:' . $comm['community_id']);
         }
         if ($blockInof) {
             $result = Bll_HzProp::updatePropBlock($blockInof['id'], $blockInof['parentid'], $blockInof['cityid'], $comm['community_id']);
             if (!$result['status']) {
                 // 更新动作表
                 if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 3, '处理失败')) {
                     return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']);
                 }
                 return $result;
             }
             $allResult = array_merge($allResult, $result['msg']);
         }
         // 更新动作表
         if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 1, '处理成功')) {
             return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']);
         }
         $temp = array();
         $temp['new_code'] = $comm['new_block_code'];
         $temp['old_code'] = $comm['block_code'];
         $temp['city_id'] = $comm['city_id'];
         $blockInfoArr[$temp['old_code'] . '_' . $temp['new_code']] = $temp;
     }
     if (!empty($blockInfoArr)) {
         Bll_Cms_BlockChange::insertCommList($blockInfoArr);
     }
     return self::buildReturn(1, $allResult);
 }
 /**
  * 检查前面处理是否ok
  * @return bool
  */
 private function isPreFinished()
 {
     // 判断之前动作是否处理完
     if ($doListData = Bll_Cms_BlockChange::getDoList($this->actionId, 4)) {
         if ($doListData['status'] == 2) {
             return true;
         } else {
             $this->writeLog('action:' . $this->actionId . ' 正在' . $doListData['list_id'] . '处理阶段');
         }
     } else {
         $this->writeLog('获取actionid=' . $this->actionId . '的dolist为空或者失败');
     }
     return false;
 }