// should be private, but public because of unit test visibility
  public void detachWeekdaysFromWeekends(List<ParkingEvent> parkingEvents) {

    totalHours = 0; // for weekday hours

    weekends = new HashSet<String>(); // storing weekend days

    // iterating over events
    for (ParkingEvent parkingEvent : parkingEvents) {

      LocalDateTime startDateTime = new LocalDateTime(parkingEvent.getStartTime());
      LocalDateTime endDateTime = new LocalDateTime(parkingEvent.getEndTime());

      // iterating over event hours
      for (LocalDateTime date = startDateTime;
          date.isBefore(endDateTime);
          date = date.plusHours(1)) {
        if (date.getDayOfWeek() == DateTimeConstants.SATURDAY
            || date.getDayOfWeek() == DateTimeConstants.SUNDAY) {
          weekends.add(date.toLocalDate().toString());
        } else {
          totalHours++;
        }
      }
    }
  }
示例#2
0
  private void addTimeSlot(
      List<TimeSlot> timeSlots,
      LocalDateTime time,
      CalendarConfig config,
      BigDecimal pricePerMinDuration) {
    TimeSlot timeSlot = new TimeSlot();
    timeSlot.setDate(time.toLocalDate());
    timeSlot.setStartTime(time.toLocalTime());
    timeSlot.setEndTime(time.toLocalTime().plusMinutes(config.getMinDuration()));
    timeSlot.setConfig(config);
    timeSlot.setPricePerMinDuration(pricePerMinDuration);

    // only add timeSlot if timeSlots does not already contain an entry that overlaps
    if (!overlaps(timeSlot, timeSlots)) {
      timeSlots.add(timeSlot);
    }
  }
  @Override
  public UnidadeIndiceOEE gerarDetalheIndiceOEE(
      IndiceOEEPorHoraFilter filter, ApontamentoQuantidade quantidade) {
    LocalDateTime dtHr = quantidade.getDtHr();
    if (!dtHr.toLocalDate().equals(filter.getDt())) return null;

    int year = dtHr.getYear();
    int month = dtHr.getMonthOfYear();
    int day = dtHr.getDayOfMonth();
    int hour = dtHr.getHourOfDay();
    dtHr = new LocalDateTime(year, month, day, hour, 0, 0, 0);

    UnidadeIndiceOEE unidade = new UnidadeIndiceOEE();
    unidade.setInicio(dtHr);
    unidade.setFim(dtHr.plusMinutes(59));
    updateId(unidade);
    unidade.addQuantidadeProduzida(quantidade.getQuantidade(), quantidade.getDmQualidade());

    return unidade;
  }
  @Override
  public List<UnidadeIndiceOEE> gerarUnidadesIndiceOEE(
      IndiceOEEPorHoraFilter filter, LocalDateTime dtHrInicio, LocalDateTime dtHrFim) {
    if (dtHrFim == null) {
      LocalTime horaAtual = new LocalTime();
      dtHrFim =
          new LocalDate()
              .toLocalDateTime(
                  new LocalTime(horaAtual.getHourOfDay(), horaAtual.getMinuteOfHour(), 0, 0));
    }
    List<UnidadeIndiceOEE> result = new ArrayList<UnidadeIndiceOEE>();

    int year = dtHrInicio.getYear();
    int month = dtHrInicio.getMonthOfYear();
    int day = dtHrInicio.getDayOfMonth();
    int hour = dtHrInicio.getHourOfDay();

    LocalDateTime dtHr = new LocalDateTime(year, month, day, hour, 0, 0, 0);

    while (dtHr.isBefore(dtHrFim)) {
      if (dtHr.toLocalDate().equals(filter.getDt())) {

        UnidadeIndiceOEE unidade = new UnidadeIndiceOEE();
        unidade.setInicio(dtHr);
        unidade.setFim(dtHr.plusMinutes(59));
        updateId(unidade);

        LocalDateTime inicio = dtHrInicio.isAfter(dtHr) ? dtHrInicio : unidade.getInicio();
        LocalDateTime fim = dtHr.plusHours(1);
        fim = dtHrFim.isAfter(fim) ? fim : dtHrFim;
        Integer tempoUtilMinutos = DateUtils.getDiferencaEmMinutos(inicio, fim);
        unidade.setTempoUtilMinutos(tempoUtilMinutos);

        result.add(unidade);
      }
      dtHr = dtHr.plusHours(1);
    }

    return result;
  }
 /** Constructor */
 public LocalDatePropertyMetadata(
     String name, LocalDateTime minValue, LocalDateTime maxValue, boolean notNull) {
   this(name, minValue.toLocalDate(), maxValue.toLocalDate(), notNull);
 }