Пример #1
0
 public function schedule()
 {
     $type = \Hnust\input('type');
     $week = \Hnust\input('week');
     $term = \Hnust\input('term');
     $week = strlen($week) ? $week : \Hnust\week();
     $term = strlen($term) ? $term : Config::getConfig('current_term');
     $isDownload = \Hnust\input('download/b', false);
     $schedule = new \Hnust\Analyse\Schedule($this->sid);
     if ($isDownload) {
         $schedule->getExcel($this->uid, $this->sid, $term);
     } else {
         $this->data = $schedule->getSchdule($this->sid, $term, $type, $week);
         $this->info = array('sid' => $this->sid, 'week' => $week, 'term' => $term, 'terms' => $this->getTerms(), 'remarks' => $this->data['remarks']);
         $this->msg = $schedule->error;
         unset($this->data['remarks']);
     }
 }
Пример #2
0
 public function schedule()
 {
     $term = Config::getConfig('current_term');
     $schedule = new \Hnust\Analyse\Schedule($this->sid);
     $data = $schedule->getSchdule($this->sid, $term, 1);
     //获取周次与星期
     $week = \Hnust\week();
     $day = date('w');
     $isToday = true;
     if (date('H') >= 21) {
         $isToday = false;
         $day = ($day + 1) % 7;
     }
     $day = $day ? $day : 7;
     //获取当天课表
     $data = $data[$week][$day];
     $session = array('', '一、二', '三、四', '五、六', '七、八', '九、十');
     $content = '';
     for ($i = 1; $i <= 5; $i++) {
         if (empty($data[$i])) {
             continue;
         }
         $content .= "第{$session[$i]}节:\n课程:{$data[$i]['course']}\n教室:{$data[$i]['classroom']}\n\n";
     }
     //回复
     if ($content) {
         $content = ($isToday ? '今' : '明') . "日课表如下:\n\n" . $content;
         if ($schedule->error) {
             $content .= $schedule->error;
         }
         $this->data = trim($content);
     } else {
         $this->data = ($isToday ? '今' : '明') . '日无课,但不要太放松哦';
     }
 }
Пример #3
0
 public function time()
 {
     $week = \Hnust\input('week/d');
     $gid = \Hnust\input('group/d');
     $list = \Hnust\input('list');
     //判断周次
     if ($week < 1 || $week > 20) {
         $this->msg = '周次有误,请重新选择';
         $this->code = Config::RETURN_ERROR;
         return;
     }
     $student = array();
     //群组中获取
     if ($gid) {
         $group = new Group();
         $result = $group->getMember($gid);
         if ($result) {
             foreach ($result as $item) {
                 $student[] = $item['sid'];
             }
         }
     }
     //输入框中获取
     $list = trim($list);
     if ($list) {
         $list = explode("\n", $list);
         if ($list) {
             $student = array_merge($student, $list);
         }
     }
     $student = array_unique($student);
     //判断学号
     if (empty($student)) {
         $this->msg = '学号不能为空,请选择群组或者输入学号';
         $this->code = Config::RETURN_ERROR;
         return;
     }
     //正常
     $schedule = new \Hnust\Analyse\Schedule('1301010101');
     $result = $schedule->getFreeTime($student, $week);
     $this->data = $result['data'];
     $this->info = array('week' => $week, 'list' => $list, 'error' => $result['error']);
 }
Пример #4
0
 public function schedule()
 {
     $type = \Hnust\input('type');
     $week = \Hnust\input('week');
     $term = \Hnust\input('term');
     $term = empty($term) ? Config::getConfig('current_term') : $term;
     $schedule = new \Hnust\Analyse\Schedule($this->sid);
     $this->data = $schedule->getSchdule($this->sid, $term, $type, $week);
     $this->info = array('sid' => $this->sid, 'week' => $week, 'term' => $term, 'remarks' => $this->data['remarks']);
     $this->msg = $schedule->error;
     unset($this->data['remarks']);
 }
Пример #5
0
 public function schedule()
 {
     //获取起始学号
     $this->getCache(__FUNCTION__);
     if (empty($this->sid)) {
         return $this->log('', '课表更新', '学号为空,不更新课表');
     }
     //全负荷运行
     Config::fullLoad();
     $sql = "SELECT `a`.`sid`, `a`.`school` FROM `student` `a`\n                LEFT JOIN `schedule` `b` ON `a`.`sid` = `b`.`sid`\n                WHERE (`b`.`sid` IS NULL OR (`b`.`time` + INTERVAL 1 WEEK) < NOW())\n                AND `a`.`sid` > ? LIMIT 1";
     $result = Mysql::execute($sql, array($this->sid));
     if (empty($result)) {
         return $this->log('', '课表更新', '课表更新完成');
     }
     $this->sid = $result[0]['sid'];
     $term = Config::getConfig('current_term');
     $school = $result[0]['school'];
     $schedule = new \Hnust\Analyse\Schedule($this->sid, '');
     $sql = 'SELECT `a`.`sid` FROM `student` `a`
             LEFT JOIN `schedule` `b` ON `a`.`sid` = `b`.`sid`
             WHERE `a`.`sid` >= ? AND `a`.`school` = ?
             AND (`b`.`sid` IS NULL OR (`b`.`time` + INTERVAL 1 WEEK) < NOW())
             LIMIT 100';
     $students = Mysql::execute($sql, array($this->sid, $school));
     foreach ($students as $student) {
         try {
             $schedule->getSchdule($student['sid'], $term);
             $this->log($student['sid'], '课表更新', '课表更新至' . $student['sid']);
         } catch (\Exception $e) {
             //pass
         }
     }
     //递归
     $this->setCache(__FUNCTION__, $this->sid);
     $this->recursion(__FUNCTION__);
 }