查询课程列表(过滤出可以试听的)

public List<VCmCheckTrainCourseDef> getVctcdList(Pagination page){
  List<CmCheckTrainCourseDef> cctcList = (List<CmCheckTrainCourseDef>) page.getList();
  List<CmCheckCourseExperience> expList = courseExpService.getAll();
  List<VCmCheckTrainCourseDef> vcctcdList = new ArrayList<VCmCheckTrainCourseDef>();
  Set<CmCheckTrainCourseInfo> set = null;
  int flag = 0;
  int j = 0;
  for (CmCheckTrainCourseDef cctcd : cctcList) {
    flag = 0;
    set = cctcd.getCmCheckTrainCourseInfos();
    for (CmCheckTrainCourseInfo courseInfo : set) {
      if (flag == 1) {
        break;
      }
      j=j+1;
      System.out.println(j);
      for (int i=0;i<expList.size();i++) {
        VCmCheckTrainCourseDef vcctcd = null;
        if (courseInfo.getCtciId() == expList.get(i).getCmCheckTrainCourseInfo().getCtciId()) {
          flag = 1;
          j=0;
          vcctcd = new VCmCheckTrainCourseDef(cctcd, true);
          vcctcdList.add(vcctcd);
          break;
        }else {
          if (flag == 0 && j==set.size() && i==expList.size()-1) {
          j=0;
          flag=1;
          vcctcd = new VCmCheckTrainCourseDef(cctcd, false);
          vcctcdList.add(vcctcd);
        }
      }
    }
  }
}
  return vcctcdList;
}

 

提示:

  1.碰到可试听的课程直接退出循环,遍历下一个课程

  2.如果最后一个课程,还是没有可试听的,就处理为不可试听

posted on 2016-01-15 10:28  Simle  阅读(183)  评论(0)    收藏  举报