/** 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(); }