/** * 只查询拓展课的记录<br> * 只包括拓展课,<b>不包括</b>班级拓展课 */ @SuppressWarnings("unchecked") public String scheduleRecords() { Date curDate = new Date(); if (DateUtils.isLessCurDay(date, curDate) || DateUtils.isSameDay(date, curDate)) { expiration = "-1"; } else { FzxDto fzx = FzxDto.getFzxDto(cid.trim()); schedule.setStartDay(DateUtils.getTodayWeeHours(date)); schedule.setEndDay(DateUtils.getTomorrowWeeHours(date)); schedule.setSzfzx(fzx); schedule.setLessonType(LessonTypeDto.getComplement()); page = new Page(); page.setCur(0); page.setPageSize(Integer.MAX_VALUE); Map<String, Object> result = commonService.getSchedules(page, schedule); page = (Page) result.get(Constants.RESULT_MAP_PAGE); ss = (List<Schedule>) result.get(Constants.RESULT_MAP_LIST); for (Schedule s : ss) { int count = commonService.getOrderLessonCountBySchedule(s); s.setStudents(count); // TODO 根据人数判断是否可以订课,人数可由运营中心设置 if (count < Constants.MAX_STUDENTS_IN_CLASS) { s.setScheduleState(ScheduleStateDto.getCanOrder()); } else { s.setScheduleState(ScheduleStateDto.getIsFull()); } } expiration = String.valueOf(page.getTotal()); } return SUCCESS; }
/** * 订课,订课后可在订课记录中查看 * * @see LessonRecordAction#orderRecords() * @return */ public String orderLesson() { xyxx.setId(sid); schedule.setId(id); Calendar c = Calendar.getInstance(); int today = c.get(Calendar.DAY_OF_WEEK); if (today == Calendar.FRIDAY && c.get(Calendar.HOUR_OF_DAY) >= Constants.TIME_LINE) { schedule = commonService.getSchedule(schedule); c.add(Calendar.DATE, 1); if (org.apache.commons.lang.time.DateUtils.isSameDay(c.getTime(), schedule.getStart())) { msg = getText("周五" + Constants.TIME_LINE + "点之后不能预订周六的拓展课!"); return INPUT; } } if (today == Calendar.SATURDAY && c.get(Calendar.HOUR_OF_DAY) >= Constants.TIME_LINE) { schedule = commonService.getSchedule(schedule); c.add(Calendar.DATE, 1); if (org.apache.commons.lang.time.DateUtils.isSameDay(c.getTime(), schedule.getStart())) { msg = getText("周六" + Constants.TIME_LINE + "点之后不能预订当周的拓展课!"); return INPUT; } } if (commonService.getOrderLessonCountBySchedule(schedule) >= Constants.MAX_STUDENTS_IN_CLASS) { msg = getText("orderLesson.schedule.is.full", "本节拓展课已被订满!"); return INPUT; } if (!commonService.canOrderLesson(schedule, xyxx)) { msg = getText("orderLesson.schedule.has.ordered", "您已经订过本节拓展课了!"); return INPUT; } else { try { commonService.orderLesson(schedule, xyxx, fromType); schedule.setScheduleState(ScheduleStateDto.getCanOrder()); result = SfDto.TRUE; } catch (Exception e) { e.printStackTrace(); return INPUT; } } return SUCCESS; }