Package web.rechelper

Examples of web.rechelper.Ticket


        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;
                }
            }
        }
        if(ticket == null) {
            errors.reject("reception.incorrect.time");
            return showForm(request, errors, getFormView());
        }
        if(ticket.isBuzy()) {
            errors.reject("reception.buzy");
            return showForm(request, errors, getFormView());
        }

        if(dto.getClient() == null) {
            return new ModelAndView("redirect:/operator/chooseclient.htm"
                    + "?type=" + dto.getType().getId()
                    + "&lpu=" + dto.getLpu().getId()
                    + "&collaborator=" + dto.getCollaborator().getId()
                    + "&time=" + dto.getTime()
                    );
        }

        //проверка для автоматического подтверждения
        //В один день нельзя записываться к сотрудникам с одинаковыми типами работ 2 раза
        Date thisDate = DateTimeUtils.getDateOnly(cal).getTime();
        Date nextDate = DateTimeUtils.getDateOnly(cal).getTime();
        boolean autoconfirm = true;
        DetachedCriteria queryCriteria = DetachedCriteria.forClass(SheduleReception.class)
                .add(Property.forName("register").ge(thisDate))
                .add(Property.forName("register").lt(nextDate))
                .add(Property.forName("client").eq(dto.getClient()))
                .add(Property.forName("workType").eq(dto.getType()));
        List<SheduleReception> conflictList = getDao().getList(queryCriteria, 0, 0);
        if (conflictList.size() > 0) {
            autoconfirm = false;
            //т.к. это рабочее место оператора, то посылать сообщение пользователю ненадо
        }

        SheduleReception reception = new SheduleReception();
        reception.setAuthor(getDao().getById(Collaborator.class, getUserInfo().getCurrentCollaboratorId()));
        reception.setCollaborator(dto.getCollaborator());
        reception.setBegin(cal.getTime());
        reception.setClient(dto.getClient());
        reception.setDuration(ticket.getDuration());
        reception.setDescription(dto.getType().getDescription());
        reception.setConfirmed(autoconfirm);
        reception.setRegister(new Date());
        reception.setWorkType(dto.getType());
        getDao().save(reception);

        ticket.setBuzy(true);
        updater.addTicketP(dto.getCollaborator(), dto.getType(), ticket);

        String date = Converter.dateToString(cal.getTime());
        String time = Converter.dateToString(cal.getTime(), "HH:mm");
        return new ModelAndView("redirect:/operator/complete.htm"
View Full Code Here


        }

        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);
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;
                }
            }
        }
        if(ticket == null) {
            errors.reject("reception.incorrect.time");
            return showForm(request, errors, getFormView());
        }
        if(ticket.isBuzy()) {
            errors.reject("reception.buzy");
            return showForm(request, errors, getFormView());
        }

        //проверка для автоматического подтверждения
        //В один день нельзя записываться к сотрудникам с одинаковыми типами работ 2 раза
        Date thisDate = DateTimeUtils.getDateOnly(cal).getTime();
        Date nextDate = DateTimeUtils.getDateOnly(cal).getTime();
        boolean autoconfirm = true;
        DetachedCriteria queryCriteria = DetachedCriteria.forClass(SheduleReception.class)
                .add(Property.forName("register").ge(thisDate))
                .add(Property.forName("register").lt(nextDate))
                .add(Property.forName("client").eq(dto.getClient()))
                .add(Property.forName("workType").eq(dto.getType()));
        List<SheduleReception> conflictList = getDao().getList(queryCriteria, 0, 0);
        if (conflictList.size() > 0) {
            autoconfirm = false;
            //т.к. это рабочее место оператора, то посылать сообщение пользователю ненадо
        }
        SheduleReception reception = new SheduleReception();
        //STUB
        reception.setAuthor(getDao().getById(Collaborator.class, UserInfo.CURRENT_COLLABORATOR_ID));
        //reception.setAuthor(dto.getCollaborator());
        //ENDSTUB
        reception.setCollaborator(dto.getCollaborator());
        reception.setBegin(cal.getTime());
        reception.setClient(dto.getClient());
        reception.setDuration(ticket.getDuration());
       
        reception.setDescription(dto.getType().getDescription()== null ? "":dto.getType().getDescription());
        reception.setConfirmed(autoconfirm);
        reception.setRegister(new Date());
        reception.setWorkType(dto.getType());
View Full Code Here

TOP

Related Classes of web.rechelper.Ticket

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.