public function findByUIDsWithDestinations($uids) { $criteria = new CDbCriteria(); $criteria->alias = "t1"; $criteria->join = 'LEFT JOIN `' . ScheduleTypeReport::model()->tableName() . '` `t2` on `t1`.`ex_schedule_id`=`t2`.`ex_schedule_id`'; $criteria->with = array('ex_schedule_report', 'send_log.destination'); foreach ($uids as $uid) { $res = self::parseUID($uid); $criteria->addCondition('(`t1`.`check_period_start`="' . $res['check_period_start'] . '" AND `t2`.`ex_schedule_ident`="' . $res['ex_schedule_ident'] . '")', 'OR'); } $result = $this->findAll($criteria); if (!is_null($result)) { foreach ($result as &$item) { if (is_object($item->ex_schedule_report)) { $item->setUniqueID($item->ex_schedule_report->ex_schedule_ident); } } $UIDsArray = $this->getUIDsArray($result); return array('result' => $result, 'uids' => $UIDsArray); } return array('result' => array(), 'uids' => array()); }
echo CHtml::activeDropDownList($scheduleTypeReportForm, 'report_type', ScheduleTypeReport::getReportType(), array('style' => 'width: 50px;')); ?> </td> <td> <?php echo CHtml::activeDropDownList($scheduleTypeReportForm, 'period', ScheduleTypeReport::getPeriod(), array('style' => 'width: 50px;')); ?> </td> <td> <?php echo CHtml::activeDropDownList($scheduleTypeReportForm, 'report_format', ScheduleTypeReport::getReportFormat(), array('style' => 'width: 50px;')); ?> </td> <td> <?php echo CHtml::activeDropDownList($scheduleTypeReportForm, "station_type", ScheduleTypeReport::getStationTypes()); ?> </td> <td> <div> <div style="float:left"><b>Date of next run: </b></div> <?php echo CHtml::activeTextField($scheduleTypeReportForm, 'start_date', array('class' => 'date-pick input-calendar', 'style' => 'width: 80px')); ?> </div> </td> <td> <div> <div style="float:left"><b>Time: </b></div> <?php echo CHtml::activeTextField($scheduleTypeReportForm, 'start_time', array('style' => 'width: 50px;'));
/** * @param $uids array * @param bool $sent true| false * @return array */ public function findByUIDsWithDestinations($uids, $sent = false) { $criteria = new CDbCriteria(); $criteria->alias = "t1"; $criteria->join = ' LEFT JOIN `' . ScheduleTypeReportProcessed::model()->tableName() . '` `t2` on `t1`.`ex_schedule_processed_id`=`t2`.`ex_schedule_processed_id` LEFT JOIN `' . ScheduleTypeReport::model()->tableName() . '` `t3` on `t2`.`ex_schedule_id`=`t3`.`ex_schedule_id` '; $criteria->with = array('report_processed.ex_schedule_report', 'destination'); if ($sent == false) { $sent_condition = ' AND `t1`.`sent`="0"'; } if ($sent == true) { $sent_condition = ' AND `t1`.`sent`="1"'; } if (count($uids)) { foreach ($uids as $uid) { $res = ScheduleTypeReportProcessed::parseUID($uid['report_uid']); $criteria->addCondition('(`t2`.`check_period_start`="' . $res['check_period_start'] . '" AND `t3`.`ex_schedule_ident`="' . $res['ex_schedule_ident'] . '" ' . $sent_condition . ')', 'OR'); } $result = $this->findAll($criteria); if (!is_null($result)) { foreach ($result as &$item) { if (is_object($item->report_processed->ex_schedule_report) && is_object($item->report_processed)) { $item->report_processed->setUniqueID($item->report_processed->ex_schedule_report->ex_schedule_ident); } } $UIDsArray = $this->getUIDsArray($result); return array('result' => $result, 'uids' => $UIDsArray); } } return array('result' => array(), 'uids' => array()); }
public function run($args) { // if (!Yii::app()->mutex->lock('ScheduleTypeReports',3600)) { // Yii::app()->end(); // } // $synchronization = new Synchronization(); // if (!$synchronization->isMaster() and $synchronization->isProcessed()) // return; $generationTime = time(); $proper_periods = $this->getProperPeriods($generationTime); $this->_logger->log(__METHOD__ . ' proper periods: ' . print_r($proper_periods, 1)); // if (count($proper_periods) === 0) { // $this->_logger->log(__METHOD__ . ' Exiting. No proper periods found.' . "\n\n"); // Yii::app()->mutex->unlock(); // Yii::app()->end(); // } $criteria = new CDbCriteria(); $criteria->select = array('ex_schedule_id', 'report_type', 'station_type', 'report_format', 'period', 'aging_time_delay', 'start_datetime', 'next_run_planned'); $criteria->compare('period', '>0'); $criteria->addCondition('active=1'); /** @var array|ScheduleTypeReport[] $scheduledReports */ $scheduledTypeReports = ScheduleTypeReport::model()->findAll($criteria); $this->_logger->log(__METHOD__ . ' $scheduledReports: ' . print_r($scheduledTypeReports, 1)); if (count($scheduledTypeReports) === 0) { // $this->_logger->log(__METHOD__ . ' Exiting. No proper reports found.' . "\n\n"); // Yii::app()->mutex->unlock(); // Yii::app()->end(); } /** * @var $typeReportItem ScheduleTypeReport */ foreach ($scheduledTypeReports as $typeReportItem) { if (strtotime($typeReportItem->next_run_planned_delayed) != mktime(date('H'), date('i'), 0, date('m'), date('d'), date('Y')) && strtotime($typeReportItem->next_run_planned_delayed) > mktime(date('H'), date('i'), 0, date('m'), date('d'), date('Y'))) { continue; } $weatherTypeReport = null; switch (strtolower($typeReportItem->report_type)) { // case 'synop' : // $weatherTypeReport = WeatherTypeReport::create('Synop', $this->_logger); // break; // // case 'bufr' : // $weatherTypeReport = WeatherTypeReport::create('Bufr', $this->_logger); // break; // // case 'metar' : // $weatherTypeReport = WeatherTypeReport::create('Metar', $this->_logger); // break; case 'odss': $weatherTypeReport = WeatherTypeReport::create('ODSS', $this->_logger); break; // default : // $weatherTypeReport = WeatherTypeReport::create('Export', $this->_logger); // break; } try { $weatherTypeReport->load($typeReportItem); $typeReportItem->setTimeStep(); // $synchronization = new Synchronization(); // if(!$synchronization->isMaster() and $synchronization->isProcessed()) // return; // $weatherTypeReport->deliverReport(); $weatherTypeReport->newReportAdd(); } catch (Exteption $e) { $this->_logger->log(__METHOD__ . ' Error ', array('err' => $e->getMessage())); } } }
public function actionStationTypeDataHistory() { $ex_schedule_id = isset($_REQUEST['ex_schedule_id']) ? intval($_REQUEST['ex_schedule_id']) : null; if (!(int) $ex_schedule_id) { $this->redirect($this->createUrl('site/StationTypeDataExport')); } TimezoneWork::set('UTC'); $history = ScheduleTypeReportProcessed::getHistory($ex_schedule_id); $scheduleTypeReport = new ScheduleTypeReport(); $report = $scheduleTypeReport->findByPk($ex_schedule_id); $this->render('schedule_type_report_history', array('report' => $report, 'history' => $history)); }