where($map)->select(); foreach($ents as $ent){ $status = new Status($ent['id']); $new_status = $status->get(); $ent['status'] = $new_status; $this->save($ent); } } public function refreshStatusOne($job_id){ $ent = $this->getOne($job_id); $status = new Status($ent['id']); $new_status = $status->get(); $ent['status'] = $new_status; $this->save($ent); } public function rebuildJob(){ $map['status'] = array('not in', array(DBCont::JOB_STATUS_WAITING, DBCont::JOB_STATUS_COMPLETE)); $ents = $this->where($map)->select(); foreach($ents as $ent){ $job = $ent['job']; $args = json_decode($ent['args'], true); $job_id = Resque::enqueue('default', $job, $args, true); $this->where(array('id' => $ent['id']))->delete(); $ent['id'] = $job_id; $ent['status'] = DBCont::JOB_STATUS_WAITING; $ent['create_date'] = time(); $this->add($ent); } } public function rebuildJobOne($job_id){ $ent = $this->getOne($job_id); if(!$ent){ $this->error = '任务不存在'; return false; } if($ent['status'] == DBCont::JOB_STATUS_WAITING || $ent['status'] == DBCont::JOB_STATUS_COMPLETE){ $this->error = "任务状态为等待或者完成,不可重启"; return false; } $job = $ent['job']; $args = json_decode($ent['args'], true); $queue = $ent['queue'] ?: 'default'; $new_job_id = Resque::enqueue($queue, $job, $args, true); $this->where(array('id' => $ent['id']))->delete(); $ent['id'] = $new_job_id; $ent['status'] = DBCont::JOB_STATUS_WAITING; $ent['create_date'] = time(); $this->add($ent); return true; } }