Package web.rechelper

Examples of web.rechelper.ReceptionDTO


            try {
                SheduleReception sheduleReception = CH.get(getDao(), SheduleReception.class, receptionStr);

                //Ебём мозг, что б с помощю ресепшн хедлпера нарезать тикеты
                //Готови данные
                ReceptionDTO rdto = new ReceptionDTO();
                rdto.setClient(sheduleReception.getClient());
                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);
                }
            } catch (Exception ex) {
                log.debug("Удаление не удалось", ex);
            }
        }
View Full Code Here


        List<WorkType> workTypes = getDao().getList(WorkType.class);

        Map<CollabWorkTypeDTO, Ticket> collabTicketMap = new HashMap<CollabWorkTypeDTO, Ticket>();

        for (CollabWorkTypeDTO collabWorkTypeDTO : collabWorks) {
            ReceptionDTO rdto = new ReceptionDTO();
            rdto.setCollaborator(collabWorkTypeDTO.getCollaborator());
            rdto.setLpu(lpu);
            rdto.setType(collabWorkTypeDTO.getWorkType());
            Day day = new Day(new Date());
            Date dateStart = day.getDate();
            Calendar calendar = day.getCalendar();
            calendar.add(Calendar.DAY_OF_MONTH, 13);
            day = new Day(calendar);
View Full Code Here



    @Override
    protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {
        ReceptionDTO dto = (ReceptionDTO) command;
        int uid = updater.registerPage(dto.getCollaborator(), dto.getType());

        Day beginDay = new Day();
        Calendar calEnd = beginDay.getCalendar();
        calEnd.add(Calendar.WEEK_OF_YEAR, 2);
        calEnd.add(Calendar.MILLISECOND, -1);

        ReceptionHelper rh = new ReceptionHelper(getDao(), dto, beginDay.getDate(), calEnd.getTime());
       
        List<WeekDay> mm = rh.getModel();
        int kk = mm.size();

        HashMap model = new HashMap();
        model.put("uid", uid);

        model.put("days", rh.getModel());
        model.put("pageBreadcrumb",
                initBreadCrumb(dto.getClient(), dto.getType(), dto.getLpu(), dto.getCollaborator(), 0));
       
        return model;
    }
View Full Code Here

        return model;
    }

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
        ReceptionDTO dto = (ReceptionDTO) command;

        Calendar cal = GregorianCalendar.getInstance();
        cal.setTimeInMillis(dto.getTime());
        if(dto.getTime() == 0) {
            errors.reject("reception.incorrect.time");
            return showForm(request, errors, getFormView());
        }

        Day day = new Day(cal);
        Calendar dayEnd = day.getCalendar();
        dayEnd.add(Calendar.DAY_OF_MONTH, 1);
        dayEnd.add(Calendar.MILLISECOND, -1);

        ReceptionHelper rh = new ReceptionHelper(getDao(), dto, day.getDate(), dayEnd.getTime());
        List<WeekDay> model = rh.getModel();

        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"
                + "?client=" + dto.getClient().getId()
                + "&lpu=" + dto.getLpu().getId()
                + "&collaborator=" + dto.getCollaborator().getId()
                + "&date=" + date
                + "&time=" + time
                + "&type=" + dto.getType().getId());
    }
View Full Code Here

            fmap.put(collaborator, functions);
        }

        Map<Collaborator, Ticket> collabTicketMap = new HashMap<Collaborator, Ticket>();
        for (Collaborator collaborator : collaborators) {
            ReceptionDTO dto = new ReceptionDTO();
            dto.setCollaborator(collaborator);
            dto.setLpu(lpu);
            dto.setType(type);
            Day day = new Day(new Date());
            Date dateStart = day.getDate();
            Calendar calendar = day.getCalendar();
            calendar.add(Calendar.DAY_OF_MONTH, 13);
            day = new Day(calendar);
View Full Code Here

TOP

Related Classes of web.rechelper.ReceptionDTO

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.