Exemplo n.º 1
0
 public static boolean isContainsProject(List<Project> projects, Project target) {
   boolean res = false;
   for (Project p : projects) {
     if (p.getProjectId() == target.getProjectId()) {
       res = true;
       return res;
     }
   }
   return res;
 }
Exemplo n.º 2
0
  /**
   * @param startTime 开始玩的时间 比如:12:00:00 动态变化
   * @param playTime
   * @param allProjects 项目集合 不变
   * @param planningNow 现在已经规划的路线 动态变化
   * @param matrix 项目路线矩阵 不变
   */
  public void addNext(
      String startTime,
      int playTime,
      List<Project> allProjects,
      List<Project> planningNow,
      int[][] matrix) {
    // 获取起始点 比如 "gate"
    Project beginProject = planningNow.get(0);
    Project nowLastProject = planningNow.get(planningNow.size() - 1);

    List<Project> plannResult = new ArrayList<Project>();
    plannResult.addAll(planningNow);

    int begin = getIndex(allProjects, nowLastProject);
    for (int j = 0; j < matrix[begin].length; j++) {
      if (matrix[begin][j] == 1) // 如果有路
      {
        Project nextProject = allProjects.get(j); // 得到下一个规划的点
        int projectStayMins = nextProject.getProjectStayTime();
        // 判断这个是否能在规定时间内玩完
        boolean canPlayOver =
            canPlayOverInOpenTime(startTime, projectStayMins, nextProject.getProjectOpenTime());
        if (canPlayOver == true && playTime >= 0) {
          // System.out.println("playTime="+playTime);
          // 这个点和初始点相同则结束
          if (nextProject.getProjectId() == beginProject.getProjectId()) {
            plannResult.add(nextProject);
            printRounter(plannResult);
            set.add(plannResult);
            plannResult = planningNow;
            continue;
          } // 如果这个点是通路但是还没走到 就加进来
          else if (!isContainsProject(planningNow, nextProject)) {
            List<Project> plannNextVertex = new ArrayList<Project>();
            plannNextVertex.addAll(planningNow);
            plannNextVertex.add(nextProject);
            String nextStartTime =
                DateUtil.addMins(
                    DateUtil.StringToDate(DateUtil.getNowTimeWithoutHourAndMin() + startTime),
                    projectStayMins);
            addNext(
                nextStartTime, playTime - projectStayMins, allProjects, plannNextVertex, matrix);
            // addNext(startTime,playTime ,allProjects,plannNextVertex,matrix);

          }
        }
      }
    }
  }
Exemplo n.º 3
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html;charset=utf-8");
    PrintWriter out = response.getWriter();
    int userId =
        request.getParameter("userId") == null
            ? MyConst.USERID_DEFAULT
            : Integer.parseInt(request.getParameter("userId"));
    int projectId =
        request.getParameter("scenerySpotId") == null
            ? 1
            : Integer.parseInt(request.getParameter("scenerySpotId"));
    SignatureDao dao = new SignatureDao();
    List<Project> list = new ArrayList<Project>();
    list = dao.getMySignedProjects(userId, projectId);
    JSONArray array = JSONArray.fromObject(list);
    for (Project p : list) {
      System.out.print(p.getProjectId() + " ");
    }
    if (array.size() != 0) {
      out.print(array);
    }
    out.flush();
    out.close();
  }
Exemplo n.º 4
0
 public static int getIndex(List<Project> projects, Project beginProject) {
   int index = 0;
   for (int i = 0; i < projects.size(); i++) {
     if (beginProject.getProjectId() == projects.get(i).getProjectId()) {
       index = i;
       return index;
     }
   }
   return index;
 }