Example #1
0
  private void processInventory() {
    LocalDate crc = SystemDao.getCrc();
    if (isStockedOut) {
      Demand d = getDemand(SystemDao.getCrc());
      if (crc.getDayOfWeek() == DateTimeConstants.SUNDAY) {
        d = getDemand(SystemDao.getReviewCycleStartDate());
      }
      int targetInv = (int) d.getRcAvgDemand() - inventory;

      setInventory(targetInv > 0 ? targetInv : (int) d.getRcAvgDemand());
      isStockedOut = false;
    }

    if (crc.getDayOfWeek() == DateTimeConstants.SUNDAY) {
      rcBopInv = inventory;
    }
    // daily inventory updates
    updateEpEopInv();
    epEopInv = inventory;
    rcInvOut += epInvOut;
    rcInvIn += epInvIn;
    ProductInventory p = getInventory(SystemDao.getReviewCycleStartDate());
    double beginOfPeriodEpAvgInv = 0;
    if (p != null) {
      beginOfPeriodEpAvgInv = p.getEpAvgInv();
    }
    double weight_5 = SystemDao.getWeight_5();
    epAvgInv =
        weight_5 * ((epEopInv >= 0) ? epEopInv : 0) + (((1 - weight_5) * beginOfPeriodEpAvgInv));
    epAvgInv = Math.max(0, epAvgInv);
  }
Example #2
0
  private void storeWeeklyMetrics(LocalDate crc) {
    // Store weekly demand metrics
    Years yr = Years.years(crc.getYear());
    Map<LocalDate, Demand> currDemandMap = demandMap.get(yr);
    if (currDemandMap == null) {
      currDemandMap = new TreeMap<LocalDate, Demand>();
    }
    Demand d = currDemandMap.get(crc);
    if (d == null) {
      d = new Demand();
    }
    d.setRcAvgDemand(rcAvgDemand);
    d.setRcAvgDemandActual(rcAvgDemandActual);
    currDemandMap.put(crc, d);
    demandMap.put(yr, currDemandMap);

    // Store weekly sales metrics
    Map<LocalDate, Sales> currSalesMap = salesMap.get(yr);
    if (currSalesMap == null) {
      currSalesMap = new TreeMap<LocalDate, Sales>();
    }
    Sales s = currSalesMap.get(crc);
    if (s == null) {
      s = new Sales();
    }
    s.setRcAvgSalesActual(rcAvgSalesActual);
    s.setRcAvgSales(rcAvgSales);
    currSalesMap.put(crc, s);
    salesMap.put(yr, currSalesMap);
  }
Example #3
0
  public static void main(String[] args) {
    ZonedDateTime apollo11launch =
        ZonedDateTime.of(1969, 7, 16, 9, 32, 0, 0, ZoneId.of("America/New_York"));

    String formatted = DateTimeFormatter.ISO_DATE_TIME.format(apollo11launch);
    // 1969-07-16T09:32:00-05:00[America/New_York]
    System.out.println(formatted);

    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
    formatted = formatter.format(apollo11launch);
    // July 16, 1969 9:32:00 AM EDT
    System.out.println(formatted);
    formatted = formatter.withLocale(Locale.FRENCH).format(apollo11launch);
    // 16 juillet 1969 09:32:00 EDT
    System.out.println(formatted);

    formatter = DateTimeFormatter.ofPattern("E yyyy-MM-dd HH:mm");
    formatted = formatter.format(apollo11launch);
    System.out.println(formatted);

    LocalDate churchsBirthday = LocalDate.parse("1903-06-14");
    System.out.println("churchsBirthday: " + churchsBirthday);
    apollo11launch =
        ZonedDateTime.parse(
            "1969-07-16 03:32:00-0400", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssxx"));
    System.out.println("apollo11launch: " + apollo11launch);
  }
Example #4
0
 private double getDemandUplift(LocalDate dt) {
   Map<LocalDate, List<Event>> currEventMap = eventsMap.get(Years.years(dt.getYear()));
   if (currEventMap == null) {
     return 1.0;
   }
   List<Event> events = currEventMap.get(dt);
   return Event.calculateDemandUplift(events);
 }
Example #5
0
 public void setTempOnHold(LocalDate dt, Boolean val) {
   Years yr = Years.years(dt.getYear());
   Map<LocalDate, Boolean> map = tempOnHoldMap.get(yr);
   if (map == null) {
     map = new TreeMap<LocalDate, Boolean>();
   }
   map.put(dt, val);
   tempOnHoldMap.put(yr, map);
 }
Example #6
0
 public void updateStatusCode() {
   switch (this.statusCd) {
     case NEW:
       if (this.statusCd == STATUS_CD.NEW
           && !firstReceiptDate.isAfter(SystemDao.getCrc())
           && !storeOpenDate.isAfter(SystemDao.getCrc())) {
         this.statusCd = STATUS_CD.LEARNING;
       }
       break;
     case LEARNING:
       // provided there have been no non-demand events or events that lasted most of the week and
       // the PL has been on
       // range the entire time, the PL is moved to status_cd = ACTIVE after the 3rd full week.
       if (!hasBeenOffRange && learningWeekCounter > 3) {
         statusCd = STATUS_CD.ACTIVE;
       }
       break;
     case INACTIVE:
       // item only goes inactive during integration, when PL drops from the file
   }
 }
Example #7
0
  public void addEvent(LocalDate dt, Event e) {
    Years yr = Years.years(dt.getYear());
    Map<LocalDate, List<Event>> currEventMap = eventsMap.get(yr);
    if (currEventMap == null) {
      currEventMap = new TreeMap<LocalDate, List<Event>>();
    }

    List<Event> eventList = currEventMap.get(dt);
    if (eventList == null) {
      eventList = new ArrayList<Event>();
    }
    eventList.add(e);
    currEventMap.put(dt, eventList);
    eventsMap.put(yr, currEventMap);
  }
Example #8
0
  /** Outlier filtering has been done prior to processing daily metrics * */
  private void processDailyMetrics() {
    LocalDate crc = SystemDao.getCrc();
    double lostSales = getLostSales();

    rcSalesActual = rcSalesActual + epSalesActual;
    // rcSales is outlier filtered sales and has been calculated in outlier processing
    rcSales = rcSales + epSales;

    Years yr = Years.years(crc.getYear());
    Map<LocalDate, Sales> currSalesMap = salesMap.get(yr);
    if (currSalesMap == null) {
      currSalesMap = new TreeMap<LocalDate, Sales>();
    }
    Sales s = currSalesMap.get(crc);
    if (s == null) {
      s = new Sales();
    }
    s.setEpSalesActual(epSalesActual);
    s.setEpSales(epSales);
    s.setRcSales(rcSales);
    s.setRcSalesActual(rcSalesActual);
    s.setLostSales(lostSales);

    currSalesMap.put(crc, s);
    salesMap.put(yr, currSalesMap);

    /** * Daily Demand Calculations **** */
    // daily demand
    epDemand = getEpDemand();
    // demand = sales + lostsales
    // outlier filtered sales used for rcDemand
    rcDemand = rcSales + lostSales;
    rcDemandActual += (epSalesActual + lostSales);

    Map<LocalDate, Demand> currDemandMap = demandMap.get(yr);
    if (currDemandMap == null) {
      currDemandMap = new TreeMap<LocalDate, Demand>();
    }
    Demand d = currDemandMap.get(crc);
    if (d == null) {
      d = new Demand();
    }
    d.setEpDemand(epDemand);
    d.setRcDemand(rcDemand);
    d.setRcDemandActual(rcDemandActual);
    currDemandMap.put(crc, d);
    demandMap.put(yr, currDemandMap);

    /** **** Daily Inventory Calculations ****** */
    processInventory();

    if (epSales > rcMaxSales) {
      rcMaxSales = epSales;
      weekSinceMaxSales = 0;
    }

    if (epEopInv > demoStock) {
      daysSinceWalk = daysSinceWalk + 1;
    } else {
      daysSinceWalk = 0;
    }

    if (epSalesActual == 0) {
      daysSinceSale = daysSinceSale + 1;
    } else {
      daysSinceSale = 0;
    }

    Map<LocalDate, ProductInventory> currInventoryMap = inventoryMap.get(yr);
    if (currInventoryMap == null) {
      currInventoryMap = new TreeMap<LocalDate, ProductInventory>();
    }
    ProductInventory inv = currInventoryMap.get(crc);
    if (inv == null) {
      inv = new ProductInventory();
    }
    inv.setEpAvgInv(epAvgInv);
    inv.setEpEopInv(epEopInv);
    inv.setEpInvOut(epInvOut);
    inv.setEpInvIn(epInvIn);
    inv.setRcBopInv(rcBopInv);
    inv.setRcBopInv(rcBopInv);
    inv.setRcInvIn(rcInvIn);
    inv.setRcInvOut(rcInvOut);
    inv.setInventory(inventory);

    currInventoryMap.put(crc, inv);
    inventoryMap.put(yr, currInventoryMap);

    if (statusCd == STATUS_CD.LEARNING) {
      performDailyLearning();
    }
    resetEpAccumulators();
  }
 public void setTime(int hour, int minute, int second) {
   LocalDate currentDate = LocalDate.from(dateAndTime);
   LocalTime timeToSet = LocalTime.of(hour, minute, second);
   dateAndTime = LocalDateTime.of(currentDate, timeToSet);
 }
 public boolean equals(Object o) {
   return o instanceof LocalDateRange
       && startDate.equals(((LocalDateRange) o).startDate)
       && endDate.equals(((LocalDateRange) o).endDate);
 }
Example #11
0
 private Sales getSales(LocalDate dt) {
   return salesMap.get(Years.years(dt.getYear())) == null
       ? null
       : salesMap.get(Years.years(dt.getYear())).get(dt);
 }
 public void setDateAndTime(int day, int month, int year, int hour, int minute, int second) {
   LocalDate dateToSet = LocalDate.of(day, month, year);
   LocalTime timeToSet = LocalTime.of(hour, minute, second);
   dateAndTime = LocalDateTime.of(dateToSet, timeToSet);
 }
 public void setDate(int day, int month, int year) {
   LocalDate dateToSet = LocalDate.of(day, month, year);
   LocalTime currentTime = LocalTime.from(dateAndTime);
   dateAndTime = LocalDateTime.of(dateToSet, currentTime);
 }
 /**
  * Checks if this range is entirely before the specified time.
  *
  * <p>The comparison is based on the time-line position of the time within a day.
  *
  * @param other the other time to compare to, not null
  * @return true if this range is entirely before the specified time
  * @throws NullPointerException if {@code other} is null
  */
 public boolean isBefore(LocalDate other) {
   return endDate.isBefore(other);
 }
Example #15
0
 private Demand getDemand(LocalDate dt) {
   return demandMap.get(Years.years(dt.getYear())) == null
       ? null
       : demandMap.get(Years.years(dt.getYear())).get(dt);
 }
 /**
  * Checks if this range is entirely after the specified time.
  *
  * <p>The comparison is based on the time-line position of the time within a day.
  *
  * @param other the other time to compare to, not null
  * @return true if this range is entirely after the specified time
  * @throws NullPointerException if {@code other} is null
  */
 public boolean isAfter(LocalDate other) {
   return startDate.isAfter(other);
 }
Example #17
0
 private ProductInventory getInventory(LocalDate dt) {
   return inventoryMap.get(Years.years(dt.getYear())) == null
       ? null
       : inventoryMap.get(Years.years(dt.getYear())).get(dt);
 }
 public int hashCode() {
   return startDate.hashCode() ^ endDate.hashCode();
 }
Example #19
0
 public static Date today() {
   return LocalDate.now().toDate();
 }