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); }
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); }
public void execute() throws Exception { // TODO Auto-generated method stub Long key = (Long) getView().getAllValues().get("id"); System.out.println("\n\n\n\n\n\n\n\n\n\n The value sent===" + getView().getAllValues()); Map payingAcct = (Map) getView().getAllValues().get("payingAccount"); PaymentBatch batch = XPersistence.getManager().find(PaymentBatch.class, key); TransitAccount debitAccount = batch.getPayingAccount(); if (payingAcct.get("id") != null) { debitAccount = (TransitAccount) MapFacade.findEntity("TransitAccount", payingAcct); batch.setPayingAccount(debitAccount); XPersistence.getManager().merge(batch); } if (UserManager.loginUserHasRole("funder") && debitAccount == null) { addError("As funder, You Need to Attach Debit Account", null); return; } Long transId = (Long) getView().getObject("transId"); Boolean fina = (Boolean) getView().getObject("final"); if (fina) { if (debitAccount == null) { addError(" Debit Account Yet To be Attached", null); return; } String token = (String) getView().getObject("token"); String softToken = (String) getView().getValue("softToken"); if (Is.empty(softToken)) { addError("Soft Token Is Required", null); return; } DateTime dT = (DateTime) getView().getObject("fiveMinutes"); DateTime presentTime = new DateTime(Dates.withTime(Dates.createCurrent())); if (!Is.equalAsStringIgnoreCase(token, softToken)) { addError("Incorrect Soft Token", null); return; } if (dT.getMillis() < presentTime.getMillis()) { addError("Token Has Expired", null); return; } System.out.println( "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n The sent object to this place ===" + transId); } Transaction transaction = XPersistence.getManager().find(Transaction.class, transId); AsyncEventBus eventBus = new AsyncEventBus(Executors.newCachedThreadPool()); eventBus.register(transaction); System.out.println(" 1111111approve already commented out......... "); eventBus.post(new Object()); // transaction.approve(); closeDialog(); setNextMode(LIST); }
private String inventoryToString() { StringBuffer epAvgInvBf = new StringBuffer(); epAvgInvBf.append("epAvgInv|"); StringBuffer epEopInvBf = new StringBuffer(); epEopInvBf.append("epEopInv|"); StringBuffer epInvOutBf = new StringBuffer(); epInvOutBf.append("epInvOut|"); StringBuffer epInvInBf = new StringBuffer(); epInvInBf.append("epInvIn|"); StringBuffer rcBopInvBf = new StringBuffer(); rcBopInvBf.append("rcBopInv|"); StringBuffer rcInvInBf = new StringBuffer(); rcInvInBf.append("rcInvIn|"); StringBuffer rcInvOutBf = new StringBuffer(); rcInvOutBf.append("rcInvOut|"); StringBuffer actualInvBf = new StringBuffer(); actualInvBf.append("actualInv|"); Iterator<Years> yrItr = inventoryMap.keySet().iterator(); Map<LocalDate, ProductInventory> currInvMap; LocalDate currDate; Years currYr; ProductInventory currInv; // Populate Sale buffers while (yrItr.hasNext()) { currYr = yrItr.next(); currInvMap = inventoryMap.get(currYr); Iterator<LocalDate> itr = currInvMap.keySet().iterator(); while (itr.hasNext()) { currDate = itr.next(); currInv = currInvMap.get(currDate); // epAvgInv epAvgInvBf.append(currDate); epAvgInvBf.append(":"); epAvgInvBf.append(currInv.getEpAvgInv()); epAvgInvBf.append("|"); // epEopInv epEopInvBf.append(currDate); epEopInvBf.append(":"); epEopInvBf.append(currInv.getEpEopInv()); epEopInvBf.append("|"); // epInvOut epInvOutBf.append(currDate); epInvOutBf.append(":"); epInvOutBf.append(currInv.getEpInvOut()); epInvOutBf.append("|"); // epInvIn epInvInBf.append(currDate); epInvInBf.append(":"); epInvInBf.append(currInv.getEpInvIn()); epInvInBf.append("|"); // rcBopInv rcBopInvBf.append(currDate); rcBopInvBf.append(":"); rcBopInvBf.append(currInv.getRcBopInv()); rcBopInvBf.append("|"); // rcInvInBf rcInvInBf.append(currDate); rcInvInBf.append(":"); rcInvInBf.append(currInv.getRcInvIn()); rcInvInBf.append("|"); // rcInvOut rcInvOutBf.append(currDate); rcInvOutBf.append(":"); rcInvOutBf.append(currInv.getRcInvOut()); rcInvOutBf.append("|"); // ActualInv actualInvBf.append(currDate); actualInvBf.append(":"); actualInvBf.append(currInv.getInventory()); actualInvBf.append("|"); } } epAvgInvBf.append(";\n"); epEopInvBf.append(";\n"); epInvOutBf.append(";\n"); epInvInBf.append(";\n"); actualInvBf.append(";\n"); rcBopInvBf.append(";\n"); rcInvInBf.append(";\n"); rcInvOutBf.append(";\n"); StringBuffer retBf = new StringBuffer(); retBf.append(epAvgInvBf.toString()); retBf.append(epEopInvBf.toString()); retBf.append(epInvOutBf.toString()); retBf.append(epInvInBf.toString()); retBf.append(actualInvBf.toString()); retBf.append(rcBopInvBf.toString()); retBf.append(rcInvInBf.toString()); retBf.append(rcInvOutBf.toString()); retBf.append("\n"); return retBf.toString(); }
private String demandToString() { Iterator<Years> yrItr = demandMap.keySet().iterator(); Map<LocalDate, Demand> currDemandMap; Years currYr; LocalDate currDate; Demand currDemand; StringBuffer epDemandBf = new StringBuffer(); epDemandBf.append("epDemand|"); StringBuffer rcActualDemandBf = new StringBuffer(); rcActualDemandBf.append("rcActualDemand|"); StringBuffer rcDemandBf = new StringBuffer(); rcDemandBf.append("rcDemand|"); StringBuffer rcAvgDemandBf = new StringBuffer(); rcAvgDemandBf.append("rcAvgDemand|"); StringBuffer rcAvgDemandActualBf = new StringBuffer(); rcAvgDemandActualBf.append("rcAvgDemandActual|"); while (yrItr.hasNext()) { currYr = yrItr.next(); currDemandMap = demandMap.get(currYr); Iterator<LocalDate> itr = currDemandMap.keySet().iterator(); while (itr.hasNext()) { currDate = itr.next(); currDemand = currDemandMap.get(currDate); // ep demand epDemandBf.append(currDate); epDemandBf.append(":"); epDemandBf.append(currDemand.getEpDemand()); epDemandBf.append("|"); // actual demand rcActualDemandBf.append(currDate); rcActualDemandBf.append(":"); rcActualDemandBf.append(currDemand.getRcDemandActual()); rcActualDemandBf.append("|"); // rc demand rcDemandBf.append(currDate); rcDemandBf.append(":"); rcDemandBf.append(currDemand.getRcDemand()); rcDemandBf.append("|"); // rc average demand rcAvgDemandBf.append(currDate); rcAvgDemandBf.append(":"); rcAvgDemandBf.append(currDemand.getRcAvgDemand()); rcAvgDemandBf.append("|"); // rc average demand actual rcAvgDemandActualBf.append(currDate); rcAvgDemandActualBf.append(":"); rcAvgDemandActualBf.append(currDemand.getRcAvgDemandActual()); rcAvgDemandActualBf.append("|"); } } rcActualDemandBf.append(";\n"); epDemandBf.append(";\n"); rcDemandBf.append(";\n"); rcAvgDemandBf.append(";\n"); rcAvgDemandActualBf.append(";\n"); StringBuffer retBf = new StringBuffer(); retBf.append(epDemandBf.toString()); retBf.append(rcActualDemandBf.toString()); retBf.append(rcDemandBf.toString()); retBf.append(rcAvgDemandBf.toString()); retBf.append(rcAvgDemandActualBf.toString()); retBf.append("\n"); return retBf.toString(); }
private String salesToString() { StringBuffer epSalesActualBf = new StringBuffer(); epSalesActualBf.append("epSalesActual|"); StringBuffer epSalesBf = new StringBuffer(); epSalesBf.append("epSales|"); StringBuffer rcSalesBf = new StringBuffer(); rcSalesBf.append("rcSales|"); StringBuffer rcAvgSalesBf = new StringBuffer(); rcAvgSalesBf.append("rcAvgSales|"); StringBuffer rcSalesActualBf = new StringBuffer(); rcSalesActualBf.append("rcSalesActual|"); StringBuffer rcAvgSalesActualBf = new StringBuffer(); rcAvgSalesActualBf.append("rcAvgSalesActual|"); Iterator<Years> yrItr = salesMap.keySet().iterator(); Map<LocalDate, Sales> currSalesMap; LocalDate currDate; Years currYr; Sales currSale; // Populate Sale buffers while (yrItr.hasNext()) { currYr = yrItr.next(); currSalesMap = salesMap.get(currYr); Iterator<LocalDate> itr = currSalesMap.keySet().iterator(); while (itr.hasNext()) { currDate = itr.next(); currSale = currSalesMap.get(currDate); // epSaleActual epSalesActualBf.append(currDate); epSalesActualBf.append(":"); epSalesActualBf.append(currSale.getEpSalesActual()); epSalesActualBf.append("|"); // epSale epSalesBf.append(currDate); epSalesBf.append(":"); epSalesBf.append(currSale.getEpSales()); epSalesBf.append("|"); // rc sales actual rcSalesActualBf.append(currDate); rcSalesActualBf.append(":"); rcSalesActualBf.append(currSale.getRcSalesActual()); rcSalesActualBf.append("|"); // rc average sales actual rcAvgSalesActualBf.append(currDate); rcAvgSalesActualBf.append(":"); rcAvgSalesActualBf.append(currSale.getRcAvgSalesActual()); rcAvgSalesActualBf.append("|"); // rc sales rcSalesBf.append(currDate); rcSalesBf.append(":"); rcSalesBf.append(currSale.getRcSales()); rcSalesBf.append("|"); // rc sales average rcAvgSalesBf.append(currDate); rcAvgSalesBf.append(":"); rcAvgSalesBf.append(currSale.getRcAvgSales()); rcAvgSalesBf.append("|"); } } epSalesActualBf.append(";\n"); epSalesBf.append(";\n"); rcSalesActualBf.append(";\n"); rcAvgSalesActualBf.append(";\n"); rcSalesBf.append(";\n"); rcAvgSalesBf.append(";\n"); StringBuffer retBf = new StringBuffer(); retBf.append(epSalesActualBf.toString()); retBf.append(epSalesBf.toString()); retBf.append(rcSalesActualBf.toString()); retBf.append(rcAvgSalesActualBf.toString()); retBf.append(rcSalesBf.toString()); retBf.append(rcAvgSalesBf.toString()); retBf.append("\n"); return retBf.toString(); }
/** 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(); }