Package web.rechelper

Examples of web.rechelper.WeekDay


                rdto.setCollaborator(sheduleReception.getCollaborator());
                rdto.setLpu(sheduleReception.getCollaborator().getLpu());
                rdto.setType(sheduleReception.getWorkType());
                Day day = new Day(sheduleReception.getBegin());
                ReceptionHelper rhBefore = new ReceptionHelper(getDao(), rdto, day.getDate(), day.getEndDate());
                WeekDay weekDay = rhBefore.getModel().get(0);
                List<Ticket> ticketsBefore = weekDay.getTickets();

                getDao().delete(sheduleReception);

                //Ебём мозг 2, нарезаем тикеты после удаления
                ReceptionHelper rhAfter = new ReceptionHelper(getDao(), rdto, day.getDate(), day.getEndDate());
                weekDay = rhAfter.getModel().get(0);
                List<Ticket> ticketsAfter = weekDay.getTickets();

                //Сравниваем списки - получаем свободные тикеты
                ticketsAfter.removeAll(ticketsBefore);
                for (Ticket ticket : ticketsAfter) {
                    updater.addTicketP(rdto.getCollaborator(), rdto.getType(), ticket);
View Full Code Here


            Date dateEnd = day.getEndDate();

            ReceptionHelper rh = new ReceptionHelper(getDao(), rdto, dateStart, dateEnd);
            List<WeekDay> wModel = rh.getModel();
            for (int i = 0; i < wModel.size() && collabTicketMap.get(collabWorkTypeDTO) == null; i++) {
                WeekDay weekDay = wModel.get(i);
                List<Ticket> tickets = weekDay.getTickets();
                if (tickets != null){
                    for (Ticket ticket : tickets) {
                        if (!ticket.isBuzy()){
                            collabTicketMap.put(collabWorkTypeDTO, ticket);
                            break;
View Full Code Here

        if(model.size() != 1) {
            errors.reject("reception.incorrect.time");
            return showForm(request, errors, getFormView());
        }
        WeekDay weekDay = model.get(0);
        Ticket ticket = null;
        if(weekDay.getTickets() != null) {
            for(Ticket t: weekDay.getTickets()) {
                long ticketTime = t.getTime();
                if(ticketTime == dto.getTime()) {
                    ticket = t;
                    break;
                }
View Full Code Here

        ReceptionHelper rh = new ReceptionHelper(getDao(), dto,
                weekIndex.getBegin().getTime(), weekIndex.getEnd().getTime());
        List<WeekDay> weekDays = rh.getModel();

        int day = dto.getDay();
        WeekDay weekDay = weekDays.get(day-1 < 0 ? 0 : (day-1) % 7);

        //Создаем таблицу часы минуты
        ArrayList<Hour> hours = new ArrayList<Hour>();
        List<Ticket> tickets = weekDay.getTickets();
        for (int i = 0; i < 23; i++) {
            hours.add(new Hour(i));
        }

        if (tickets != null && tickets.size() > 0) {
            //распределяем тикеты по часам
            for (int i = 0; i < tickets.size(); i++) {
                Ticket ticket = tickets.get(i);
                ticket.setHeight(ticket.getDuration());
                int mm = ticket.getMinute();
                int hh = ticket.getHour();
                int duration = ticket.getHeight();

                while (duration > 0) {
                    if (mm + duration <= 60) {
                        ticket.setHeight(duration);
                        if (ticket.getHeight() >= 3) {
                            hours.get(hh).getTickets().add(ticket);
                        }
                        duration = 0;
                    } else {
                        ticket.setHeight(60-mm);
                        if (ticket.getHeight() >= 3) {
                            hours.get(hh).getTickets().add(ticket);
                        }
                        boolean buzy = ticket.isBuzy();
                        duration = duration - (60-mm);
                        ticket = new Ticket(ticket.getCalendar(), ticket.getDuration());
                        ticket.setBuzy(buzy);
                        //переход на след. час
                        hh += 1;
                        mm = 0;
                    }
                }
            }

            //заполняем пустые места в часе
            for (Hour hour : hours) {
                ArrayList<Ticket> tList = hour.getTickets();
                ArrayList<Ticket> newTickets = new ArrayList<Ticket>();
                Collections.sort(tList);
                int lasttime = 0;
                for (Ticket ticket : tList) {
                    if (ticket.getHour() != hour.getHour()) {
                        Calendar cal = (Calendar) ticket.getCalendar().clone();
                        cal.add(Calendar.MINUTE, ticket.getDuration());
                        lasttime = cal.get(Calendar.MINUTE);
                    }
                    else if (ticket.getMinute() > lasttime) {
                        int height = ticket.getMinute()-lasttime;
                        Calendar cal = (Calendar) ticket.getCalendar().clone();
                        cal.add(Calendar.MINUTE, -height);
                        cal.set(Calendar.HOUR_OF_DAY, hour.getHour());
                        Ticket newTicket = new Ticket(cal, height);
                        newTicket.setHeight(height);
                        newTicket.setBuzy(true);
                        if (newTicket.getHeight() >= 3) {
                            newTickets.add(newTicket);
                        }
                    }
                    lasttime = ticket.getMinute()+ ticket.getDuration();
                }
                if (lasttime < 60) {
                    Calendar cal = weekDay.getDay().getCalendar();
                    cal.set(Calendar.HOUR_OF_DAY, hour.getHour());
                    cal.set(Calendar.MINUTE, lasttime);
                    cal.set(Calendar.SECOND, 0);
                    cal.set(Calendar.MILLISECOND, 0);
                    Ticket newTicket = new Ticket(cal, 60 - lasttime);
                    newTicket.setHeight(60 - lasttime);
                    newTicket.setBuzy(true);
                    if (newTicket.getHeight() >= 3) {
                        newTickets.add(newTicket);
                    }
                }
                tList.addAll(newTickets);
                Collections.sort(tList);
            }

        }
        //Удаляем пустые часы за рамками интервала
        for (Iterator<Hour> it = hours.iterator(); it.hasNext();) {
            Hour hour = it.next();
            if (hour.getHour() < 8 || hour.getHour() > 18) {
                boolean empty = true;
                for (Ticket ticket : hour.getTickets()) {
                    if (!ticket.isBuzy()) {
                        empty = false;
                    }
                }
                if (empty) {
                    it.remove();
                }
            }
        }
        //если часов больше 11 то удаляем пустые начиная с конца
        for (int i = hours.size() - 1; i >=0; i--) {
            Hour hour = hours.get(i);
                boolean empty = true;
                for (Ticket ticket : hour.getTickets()) {
                    if (!ticket.isBuzy()) {
                        empty = false;
                    }
                }
                if (empty && hours.size() > 11) {
                    hours.remove(i);
                }

        }


        model.put("hours", hours);
        model.put("day", weekDay.getDay());
        model.put("pageBreadcrumb", ReceptionController.initBreadCrumb(dto.getClient(), dto.getType(), dto.getLpu(), dto.getCollaborator()));
        model.put("command", command);
        return new ModelAndView("reception/receptionday", model);
    }
View Full Code Here

            Date dateEnd = day.getEndDate();

            ReceptionHelper rh = new ReceptionHelper(getDao(), dto, dateStart, dateEnd);
            List<WeekDay> wModel = rh.getModel();
            for (int i = 0; i < wModel.size() && collabTicketMap.get(collaborator) == null; i++) {
                WeekDay weekDay = wModel.get(i);
                List<Ticket> tickets = weekDay.getTickets();
                if (tickets != null){
                    for (Ticket ticket : tickets) {
                        if (!ticket.isBuzy()){
                            collabTicketMap.put(collaborator, ticket);
                            break;
View Full Code Here

        if(model.size() != 1) {
            errors.reject("reception.incorrect.time");
            return showForm(request, errors, getFormView());
        }
        WeekDay weekDay = model.get(0);
        Ticket ticket = null;
        if(weekDay.getTickets() != null) {
            for(Ticket t: weekDay.getTickets()) {
                if(t.getTime() == dto.getTime()) {
                    ticket = t;
                    break;
                }
            }
View Full Code Here

TOP

Related Classes of web.rechelper.WeekDay

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.