| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
- |
|
| 4 |
import java.net.URISyntaxException;
|
- |
|
| 5 |
import java.time.DayOfWeek;
|
- |
|
| 6 |
import java.time.LocalDate;
|
3 |
import java.time.LocalDate;
|
| 7 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 8 |
import java.time.LocalTime;
|
5 |
import java.time.LocalTime;
|
| 9 |
import java.time.temporal.TemporalAdjusters;
|
- |
|
| 10 |
import java.util.ArrayList;
|
6 |
import java.util.ArrayList;
|
| 11 |
import java.util.HashMap;
|
- |
|
| 12 |
import java.util.LinkedHashMap;
|
7 |
import java.util.LinkedHashMap;
|
| 13 |
import java.util.List;
|
8 |
import java.util.List;
|
| 14 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| 15 |
import java.util.Set;
|
- |
|
| 16 |
import java.util.function.IntFunction;
|
- |
|
| 17 |
import java.util.function.IntPredicate;
|
- |
|
| 18 |
import java.util.stream.Collectors;
|
10 |
import java.util.stream.Collectors;
|
| 19 |
|
11 |
|
| 20 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 21 |
|
13 |
|
| 22 |
import org.apache.logging.log4j.LogManager;
|
14 |
import org.apache.logging.log4j.LogManager;
|
| 23 |
import org.apache.logging.log4j.Logger;
|
15 |
import org.apache.logging.log4j.Logger;
|
| 24 |
import org.json.JSONArray;
|
- |
|
| 25 |
import org.json.JSONObject;
|
- |
|
| 26 |
import org.springframework.beans.factory.annotation.Autowired;
|
16 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 27 |
import org.springframework.beans.factory.annotation.Value;
|
17 |
import org.springframework.beans.factory.annotation.Value;
|
| 28 |
import org.springframework.stereotype.Controller;
|
18 |
import org.springframework.stereotype.Controller;
|
| 29 |
import org.springframework.transaction.annotation.Transactional;
|
19 |
import org.springframework.transaction.annotation.Transactional;
|
| 30 |
import org.springframework.ui.Model;
|
20 |
import org.springframework.ui.Model;
|
| 31 |
import org.springframework.web.bind.annotation.RequestMapping;
|
21 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 32 |
import org.springframework.web.bind.annotation.RequestMethod;
|
22 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 33 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 34 |
|
23 |
|
| 35 |
import com.mongodb.DBObject;
|
24 |
import com.mongodb.DBObject;
|
| 36 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
- |
|
| 37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
25 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 38 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
26 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 39 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
27 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 40 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
- |
|
| 41 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
- |
|
| 42 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
- |
|
| 43 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
- |
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
28 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
29 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
30 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 47 |
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
|
- |
|
| 48 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
35 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| Line 130... |
Line 113... |
| 130 |
private Mongo mongoClient;
|
113 |
private Mongo mongoClient;
|
| 131 |
|
114 |
|
| 132 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
115 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 133 |
|
116 |
|
| 134 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
117 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 135 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
118 |
public String dashboard1(HttpServletRequest request, Model model) throws Exception {
|
| 136 |
LOGGER.info("In Dashboard1");
|
119 |
LOGGER.info("In Dashboard1");
|
| 137 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
120 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 138 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices());
|
121 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 139 |
model.addAttribute("salesMap", this.getSales());
|
122 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 140 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
123 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 141 |
return "dashboard1";
|
124 |
return "dashboard1";
|
| 142 |
}
|
125 |
}
|
| 143 |
|
126 |
|
| 144 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
127 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
| 145 |
Map<String, Object> investments = new LinkedHashMap<>();
|
128 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| 146 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
129 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| 147 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
130 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
| 148 |
LocalDate lastMonthStart = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
- |
|
| 149 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
131 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
| 150 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
132 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
| 151 |
if (yesterdayInvestment == null) {
|
133 |
if (yesterdayInvestment == null) {
|
| 152 |
yesterdayInvestment = new PartnerDailyInvestment();
|
134 |
yesterdayInvestment = new PartnerDailyInvestment();
|
| 153 |
}
|
135 |
}
|
| 154 |
List<PartnerDailyInvestment> lastMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
- |
|
| 155 |
lastMonthStart, lastMonthStart.withDayOfMonth(lastMonthStart.lengthOfMonth()));
|
- |
|
| 156 |
|
136 |
|
| 157 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
137 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
| 158 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
138 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
| 159 |
|
139 |
|
| 160 |
long lastMonthShortDays = lastMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
140 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= 10)
|
| 161 |
.collect(Collectors.counting());
|
141 |
.collect(Collectors.counting());
|
| 162 |
long mtdShortDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
142 |
investments.put("today", investment.getTotalInvestment());
|
| 163 |
.collect(Collectors.counting());
|
143 |
investments.put("investment", investment);
|
| 164 |
investments.put("Today", investment.getTotalInvestment());
|
144 |
investments.put("inStock", investment.getInStockAmount());
|
| 165 |
investments.put("Yesterday", yesterdayInvestment.getTotalInvestment());
|
145 |
investments.put("minimum", investment.getMinInvestment());
|
| 166 |
investments.put("Short MTD", mtdShortDays);
|
146 |
investments.put("short", investment.getShortPercentage());
|
| 167 |
investments.put("Short Last Month", lastMonthShortDays);
|
147 |
investments.put("okDays", okInvestmentDays);
|
| 168 |
return investments;
|
148 |
return investments;
|
| 169 |
}
|
149 |
}
|
| 170 |
|
150 |
|
| 171 |
private Map<String, Float> getSales() {
|
151 |
private Map<String, Double> getSales(int fofoId) {
|
| 172 |
Map<String, Float> salesMap = new LinkedHashMap<>();
|
152 |
Map<String, Double> salesMap = new LinkedHashMap<>();
|
| - |
|
153 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
154 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId, curDate,
|
| 173 |
salesMap.put("Today", 10000f);
|
155 |
curDate.with(LocalTime.MAX));
|
| - |
|
156 |
List<FofoOrderItem> mtdFofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
| - |
|
157 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| - |
|
158 |
double todaySale = fofoOrderItems.stream()
|
| - |
|
159 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
| - |
|
160 |
double mtdSale = mtdFofoOrderItems.stream()
|
| - |
|
161 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
| 174 |
salesMap.put("Yesterday", 100000f);
|
162 |
salesMap.put("todaySale", todaySale);
|
| 175 |
salesMap.put("MTD", 100000f);
|
163 |
salesMap.put("mtdSale", mtdSale);
|
| 176 |
return salesMap;
|
164 |
return salesMap;
|
| 177 |
}
|
165 |
}
|
| 178 |
|
166 |
|
| 179 |
private List<BrandStockPrice> getBrandStockPrices() {
|
167 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) {
|
| - |
|
168 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
| - |
|
169 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
| 180 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
170 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 181 |
BrandStockPrice brandStockPrice = new BrandStockPrice();
|
- |
|
| 182 |
brandStockPrice.setBrand("Nokia");
|
- |
|
| 183 |
brandStockPrice.setBrandUrl("");
|
171 |
mobileBrands.stream().forEach(x -> {
|
| 184 |
brandStockPrice.setRank(1);
|
172 |
String brand = (String) x.get("name");
|
| 185 |
brandStockPrice.setTotalQty(10);
|
- |
|
| 186 |
brandStockPrice.setTotalValue(10000);
|
173 |
if (brandStockPricesMap.containsKey(brand)) {
|
| 187 |
BrandStockPrice brandStockPrice1 = new BrandStockPrice();
|
174 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
| 188 |
brandStockPrice1.setBrand("Samsung");
|
- |
|
| 189 |
brandStockPrice1.setBrandUrl("");
|
175 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
| 190 |
brandStockPrice1.setRank(1);
|
- |
|
| 191 |
brandStockPrice1.setTotalQty(10);
|
- |
|
| 192 |
brandStockPrice1.setTotalValue(10000);
|
- |
|
| 193 |
BrandStockPrice brandStockPrice2 = new BrandStockPrice();
|
176 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
| 194 |
brandStockPrice2.setBrand("Oppo");
|
177 |
brandStockPrices.add(brandStockPrice);
|
| 195 |
brandStockPrice2.setBrandUrl("");
|
178 |
} else {
|
| 196 |
brandStockPrice2.setRank(1);
|
179 |
}
|
| 197 |
brandStockPrice2.setTotalQty(10);
|
180 |
});
|
| 198 |
brandStockPrice2.setTotalValue(10000);
|
- |
|
| - |
|
181 |
|
| 199 |
BrandStockPrice brandStockPrice3 = new BrandStockPrice();
|
182 |
return brandStockPrices.stream().sorted((x, y) -> y.getRank() - x.getRank()).collect(Collectors.toList());
|
| 200 |
brandStockPrice3.setBrand("Vivo");
|
- |
|
| 201 |
brandStockPrice3.setBrandUrl("");
|
- |
|
| 202 |
brandStockPrice3.setRank(1);
|
- |
|
| 203 |
brandStockPrice3.setTotalQty(10);
|
- |
|
| 204 |
brandStockPrice3.setTotalValue(10000);
|
- |
|
| 205 |
brandStockPrices.add(brandStockPrice);
|
- |
|
| 206 |
brandStockPrices.add(brandStockPrice1);
|
- |
|
| 207 |
brandStockPrices.add(brandStockPrice2);
|
- |
|
| 208 |
brandStockPrices.add(brandStockPrice3);
|
- |
|
| 209 |
return brandStockPrices;
|
- |
|
| 210 |
}
|
183 |
}
|
| 211 |
|
184 |
|
| 212 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
185 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 213 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
186 |
public String dashboard(HttpServletRequest request, Model model)
|
| 214 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
- |
|
| 215 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
- |
|
| 216 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
- |
|
| 217 |
// scanRepository.selectScansByInventoryItemId(1));
|
- |
|
| 218 |
LOGGER.info("In Dashboard");
|
187 |
throws Exception {
|
| - |
|
188 |
|
| 219 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
189 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 220 |
|
190 |
|
| 221 |
FofoStore fofoStore = null;
|
191 |
FofoStore fofoStore = null;
|
| 222 |
try {
|
192 |
try {
|
| 223 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
193 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 224 |
} catch (ProfitMandiBusinessException e) {
|
194 |
} catch (ProfitMandiBusinessException e) {
|
| 225 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
195 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 226 |
}
|
196 |
}
|
| 227 |
|
- |
|
| 228 |
float sale = 0;
|
- |
|
| 229 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
- |
|
| 230 |
model.addAttribute("sale", sale);
|
- |
|
| 231 |
List<NotificationData> notificationData = null;
|
- |
|
| 232 |
long size = 0;
|
- |
|
| 233 |
|
- |
|
| 234 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
- |
|
| 235 |
size = notificationPanelRepository.selectAllCount();
|
- |
|
| 236 |
LOGGER.info("notification_data {}", notificationData);
|
- |
|
| 237 |
|
- |
|
| 238 |
LOGGER.info("notification_data {}", size);
|
- |
|
| 239 |
// Map<String, Object> saleSummary=this.getAllSaleDetails(loginDetails);
|
- |
|
| 240 |
// model.addAllAttributes(saleSummary);
|
- |
|
| 241 |
if (!notificationData.isEmpty()) {
|
- |
|
| 242 |
|
- |
|
| 243 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 244 |
LOGGER.info("notificationdata", notificationData);
|
- |
|
| 245 |
model.addAttribute("start", offset + 1);
|
- |
|
| 246 |
model.addAttribute("size", size);
|
- |
|
| 247 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
- |
|
| 248 |
|
- |
|
| 249 |
LOGGER.info("start {}", offset + 1);
|
- |
|
| 250 |
LOGGER.info("SIZE {}", size);
|
- |
|
| 251 |
|
- |
|
| 252 |
if (notificationData.size() < limit) {
|
- |
|
| 253 |
model.addAttribute("end", offset + notificationData.size());
|
- |
|
| 254 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
- |
|
| 255 |
} else {
|
- |
|
| 256 |
model.addAttribute("end", offset + limit);
|
- |
|
| 257 |
|
- |
|
| 258 |
LOGGER.info("end {}", size);
|
- |
|
| 259 |
|
- |
|
| 260 |
}
|
- |
|
| 261 |
|
- |
|
| 262 |
} else {
|
- |
|
| 263 |
|
- |
|
| 264 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 265 |
model.addAttribute("size", size);
|
- |
|
| 266 |
LOGGER.info("sizeOriginal {}", size);
|
- |
|
| 267 |
|
- |
|
| 268 |
}
|
- |
|
| 269 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
- |
|
| 270 |
|
- |
|
| 271 |
List<NotificationData> notificationData = null;
|
- |
|
| 272 |
long size = 0;
|
- |
|
| 273 |
|
- |
|
| 274 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
- |
|
| 275 |
size = notificationPanelRepository.selectCountByActiveFlag(true);
|
- |
|
| 276 |
LOGGER.info("notification_data {}", notificationData);
|
- |
|
| 277 |
|
- |
|
| 278 |
LOGGER.info("notification_data {}", size);
|
- |
|
| 279 |
|
- |
|
| 280 |
///// DashBoard ......................///////
|
- |
|
| 281 |
model.addAllAttributes(this.getAllInsuranceDetails(loginDetails.getFofoId()));
|
- |
|
| 282 |
model.addAllAttributes(this.getAllRechargeDetails(loginDetails.getFofoId()));
|
- |
|
| 283 |
model.addAllAttributes(this.getAllSaleDetails(loginDetails.getFofoId()));
|
- |
|
| 284 |
model.addAttribute("fofoId", loginDetails.getFofoId());
|
- |
|
| 285 |
///////////////////////////////
|
- |
|
| 286 |
if (!notificationData.isEmpty()) {
|
- |
|
| 287 |
|
- |
|
| 288 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 289 |
LOGGER.info("notificationdata", notificationData);
|
- |
|
| 290 |
model.addAttribute("start", offset + 1);
|
- |
|
| 291 |
model.addAttribute("size", size);
|
- |
|
| 292 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
- |
|
| 293 |
|
- |
|
| 294 |
LOGGER.info("start {}", offset + 1);
|
- |
|
| 295 |
LOGGER.info("SIZE {}", size);
|
- |
|
| 296 |
|
- |
|
| 297 |
if (notificationData.size() < limit) {
|
- |
|
| 298 |
model.addAttribute("end", offset + notificationData.size());
|
- |
|
| 299 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
- |
|
| 300 |
} else {
|
- |
|
| 301 |
model.addAttribute("end", offset + limit);
|
- |
|
| 302 |
|
- |
|
| 303 |
LOGGER.info("end {}", size);
|
- |
|
| 304 |
|
- |
|
| 305 |
}
|
- |
|
| 306 |
|
- |
|
| 307 |
} else {
|
- |
|
| 308 |
|
- |
|
| 309 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 310 |
model.addAttribute("size", size);
|
- |
|
| 311 |
LOGGER.info("sizeOriginal {}", size);
|
- |
|
| 312 |
|
- |
|
| 313 |
}
|
- |
|
| 314 |
}
|
- |
|
| 315 |
|
- |
|
| 316 |
boolean isInvestmentOk = partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30);
|
- |
|
| 317 |
LocalDate endDate = LocalDate.now().minusDays(1);
|
- |
|
| 318 |
LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
- |
|
| 319 |
LocalDate startDate = weekStartDate.minusWeeks(2);
|
- |
|
| 320 |
List<PartnerDailyInvestment> partnerInvestments = new ArrayList<>();
|
- |
|
| 321 |
try {
|
- |
|
| 322 |
partnerInvestments.add(partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 1));
|
- |
|
| 323 |
partnerInvestments
|
- |
|
| 324 |
.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
- |
|
| 325 |
|
- |
|
| 326 |
} catch (Exception e) {
|
- |
|
| 327 |
LOGGER.error("partner Investment can't exists");
|
- |
|
| 328 |
}
|
- |
|
| 329 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService
|
- |
|
| 330 |
.getBrandWiseStockValue(loginDetails.getFofoId());
|
- |
|
| 331 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(loginDetails.getFofoId(), loginDetails.getEmailId(),
|
- |
|
| 332 |
3);
|
- |
|
| 333 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
- |
|
| 334 |
mobileBrands.stream().forEach(x -> {
|
- |
|
| 335 |
String brand = (String) x.get("name");
|
- |
|
| 336 |
if (brandStockPricesMap.containsKey(brand)) {
|
- |
|
| 337 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
- |
|
| 338 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
- |
|
| 339 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
- |
|
| 340 |
brandStockPrices.add(brandStockPrice);
|
- |
|
| 341 |
} else {
|
- |
|
| 342 |
}
|
- |
|
| 343 |
});
|
- |
|
| 344 |
model.addAttribute("brandStockPrices",
|
- |
|
| 345 |
brandStockPrices.stream().sorted((x, y) -> y.getRank() - x.getRank()).collect(Collectors.toList()));
|
- |
|
| 346 |
model.addAttribute("isInvestmentOk", isInvestmentOk || roleManager.isAdmin(loginDetails.getRoleIds()));
|
- |
|
| 347 |
model.addAttribute("partnerInvestment", partnerInvestments.get(0));
|
- |
|
| 348 |
// model.addAttribute("investmentChart",
|
- |
|
| 349 |
// this.getInvestmentChartData(partnerInvestments));
|
- |
|
| 350 |
model.addAttribute("fofoStore", fofoStore);
|
197 |
model.addAttribute("fofoStore", fofoStore);
|
| 351 |
model.addAttribute("walletAmount");
|
- |
|
| 352 |
model.addAttribute("appContextPath", request.getContextPath());
|
- |
|
| 353 |
model.addAttribute("isAdmin",
|
- |
|
| 354 |
roleManager.isAdmin(loginDetails.getRoleIds()));
|
198 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 355 |
//model.addAttribute("isAdmin", false);
|
- |
|
| 356 |
model.addAttribute("webApiHost", webApiHost);
|
199 |
model.addAttribute("webApiHost", webApiHost);
|
| 357 |
model.addAttribute("webApiPort", webApiPort);
|
200 |
model.addAttribute("webApiPort", webApiPort);
|
| 358 |
model.addAttribute("webApiScheme", webApiScheme);
|
201 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 359 |
model.addAttribute("webApiRoot", webApiRoot);
|
202 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 360 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
203 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 361 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
204 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 362 |
model.addAttribute("sale", sale);
|
- |
|
| 363 |
|
205 |
|
| 364 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
206 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 365 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
207 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 366 |
return "dashboard";
|
- |
|
| 367 |
}
|
- |
|
| 368 |
|
- |
|
| 369 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
208 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 370 |
|
- |
|
| 371 |
JSONObject scale = new JSONObject().put("scaleLabel", new JSONObject().put("scaleLabel", "Amount in Rs"));
|
- |
|
| 372 |
JSONObject titleObject = new JSONObject().put("display", true).put("text", "Investment Overview").put("display",
|
- |
|
| 373 |
true);
|
- |
|
| 374 |
|
- |
|
| 375 |
JSONObject barData = new JSONObject();
|
- |
|
| 376 |
|
- |
|
| 377 |
JSONObject walletStack = new JSONObject().put("backgroundColor", "rgba(255, 99, 132, 0.2)")
|
- |
|
| 378 |
.put("label", "Wallet").put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 379 |
JSONObject inStockStack = new JSONObject().put("label", "In Stock")
|
- |
|
| 380 |
.put("backgroundColor", "rgba(54, 162, 235, 0.2)").put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 381 |
JSONObject salesStack = new JSONObject().put("backgroundColor", "rgba(255, 206, 86, 0.2)").put("label", "Sales")
|
- |
|
| 382 |
.put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 383 |
JSONObject grnPendingStack = new JSONObject().put("backgroundColor", "rgba(75, 192, 192, 0.2)")
|
- |
|
| 384 |
.put("label", "Grn Pending").put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 385 |
JSONObject billingPendingStack = new JSONObject().put("backgroundColor", "rgba(153, 102, 255, 0.2)")
|
- |
|
| 386 |
.put("label", "Billing Pending").put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 387 |
JSONObject inTransitStack = new JSONObject().put("backgroundColor", "rgba(255, 159, 64, 0.2)")
|
- |
|
| 388 |
.put("label", "Returned").put("stack", "Stack1").put("data", new JSONArray());
|
- |
|
| 389 |
|
- |
|
| 390 |
JSONObject minInvestmentDataSet = new JSONObject().put("label", "Min. Ivestment").put("data", new JSONArray())
|
209 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30));
|
| 391 |
.put("type", "line");
|
- |
|
| 392 |
JSONArray dateLabels = new JSONArray();
|
- |
|
| 393 |
|
- |
|
| 394 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
- |
|
| 395 |
dateLabels = dateLabels.put(pdi.getDate().toString());
|
- |
|
| 396 |
walletStack.getJSONArray("data").put((int) pdi.getWalletAmount());
|
- |
|
| 397 |
inStockStack.getJSONArray("data").put((int) pdi.getInStockAmount());
|
- |
|
| 398 |
salesStack.getJSONArray("data").put((int) pdi.getSalesAmount());
|
- |
|
| 399 |
grnPendingStack.getJSONArray("data").put((int) pdi.getUnbilledAmount());
|
- |
|
| 400 |
billingPendingStack.getJSONArray("data").put((int) pdi.getGrnPendingAmount());
|
- |
|
| 401 |
inTransitStack.getJSONArray("data").put((int) pdi.getReturnInTransitAmount());
|
- |
|
| 402 |
minInvestmentDataSet.getJSONArray("data").put((int) pdi.getMinInvestment());
|
- |
|
| 403 |
}
|
- |
|
| 404 |
|
- |
|
| 405 |
JSONArray barDataSetsArray = new JSONArray().put(walletStack).put(inStockStack).put(salesStack)
|
- |
|
| 406 |
.put(grnPendingStack).put(billingPendingStack).put(inTransitStack);
|
- |
|
| 407 |
barData.put("labels", dateLabels).put("datasets", barDataSetsArray);
|
- |
|
| 408 |
scale.put("yAxes", new JSONArray().put(new JSONObject().put("stacked", true))).put("xAxes",
|
- |
|
| 409 |
new JSONArray().put(new JSONObject().put("stacked", true)));
|
- |
|
| 410 |
|
- |
|
| 411 |
JSONObject barOptions = new JSONObject().put("title", titleObject).put("responsive", true).put("scales", scale)
|
- |
|
| 412 |
.put("tooltips", new JSONObject().put("mode", "index").put("intersect", false));
|
- |
|
| 413 |
|
- |
|
| 414 |
JSONObject chartJSOn = new JSONObject().put("type", "bar").put("data", barData).put("options", barOptions);
|
- |
|
| 415 |
return chartJSOn.toString();
|
210 |
return "dashboard1";
|
| 416 |
}
|
211 |
}
|
| 417 |
|
212 |
|
| 418 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
213 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 419 |
private boolean hasGift(int fofoId) {
|
214 |
private boolean hasGift(int fofoId) {
|
| 420 |
try {
|
215 |
try {
|
| Line 423... |
Line 218... |
| 423 |
} catch (ProfitMandiBusinessException e) {
|
218 |
} catch (ProfitMandiBusinessException e) {
|
| 424 |
return false;
|
219 |
return false;
|
| 425 |
}
|
220 |
}
|
| 426 |
}
|
221 |
}
|
| 427 |
|
222 |
|
| 428 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
- |
|
| 429 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
- |
|
| 430 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 431 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
- |
|
| 432 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 433 |
|
- |
|
| 434 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
- |
|
| 435 |
List<NotificationData> notificationData = null;
|
- |
|
| 436 |
|
- |
|
| 437 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
- |
|
| 438 |
|
- |
|
| 439 |
LOGGER.info("notification_data {}", notificationData);
|
- |
|
| 440 |
|
- |
|
| 441 |
if (!notificationData.isEmpty()) {
|
- |
|
| 442 |
|
- |
|
| 443 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 444 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
- |
|
| 445 |
|
- |
|
| 446 |
} else {
|
- |
|
| 447 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 448 |
|
- |
|
| 449 |
}
|
- |
|
| 450 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
- |
|
| 451 |
|
- |
|
| 452 |
List<NotificationData> notificationData = null;
|
- |
|
| 453 |
|
- |
|
| 454 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
- |
|
| 455 |
LOGGER.info("notification_data {}", notificationData);
|
- |
|
| 456 |
|
- |
|
| 457 |
if (!notificationData.isEmpty()) {
|
- |
|
| 458 |
|
- |
|
| 459 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 460 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
- |
|
| 461 |
|
- |
|
| 462 |
} else {
|
- |
|
| 463 |
model.addAttribute("notificationData", notificationData);
|
- |
|
| 464 |
|
- |
|
| 465 |
}
|
- |
|
| 466 |
}
|
- |
|
| 467 |
|
- |
|
| 468 |
return "dashboard-paginated";
|
- |
|
| 469 |
}
|
- |
|
| 470 |
|
- |
|
| 471 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
223 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 472 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
224 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 473 |
model.addAttribute("appContextPath", request.getContextPath());
|
225 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 474 |
return "contact-us";
|
226 |
return "contact-us";
|
| 475 |
}
|
227 |
}
|
| 476 |
|
228 |
|
| 477 |
/*
|
- |
|
| 478 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
- |
|
| 479 |
* paymentOptionIds =
|
- |
|
| 480 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
- |
|
| 481 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
- |
|
| 482 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
- |
|
| 483 |
*/
|
- |
|
| 484 |
|
- |
|
| 485 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
- |
|
| 486 |
public String inactiveNotificationData(HttpServletRequest request,
|
- |
|
| 487 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
- |
|
| 488 |
|
- |
|
| 489 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
- |
|
| 490 |
if (notificationData != null) {
|
- |
|
| 491 |
|
- |
|
| 492 |
notificationData.setActive(false);
|
- |
|
| 493 |
LOGGER.info("notification" + notificationData);
|
- |
|
| 494 |
notificationPanelRepository.persist(notificationData);
|
- |
|
| 495 |
|
- |
|
| 496 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 497 |
} else {
|
- |
|
| 498 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
- |
|
| 499 |
|
- |
|
| 500 |
}
|
- |
|
| 501 |
return "response";
|
- |
|
| 502 |
}
|
- |
|
| 503 |
|
- |
|
| 504 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
- |
|
| 505 |
public String activeNotificationData(HttpServletRequest request,
|
- |
|
| 506 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
- |
|
| 507 |
|
- |
|
| 508 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
- |
|
| 509 |
if (notificationData != null) {
|
- |
|
| 510 |
|
- |
|
| 511 |
notificationData.setActive(true);
|
- |
|
| 512 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
- |
|
| 513 |
LOGGER.info("notification" + notificationData);
|
- |
|
| 514 |
notificationPanelRepository.persist(notificationData);
|
- |
|
| 515 |
|
- |
|
| 516 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 517 |
} else {
|
- |
|
| 518 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
- |
|
| 519 |
|
- |
|
| 520 |
}
|
- |
|
| 521 |
return "response";
|
- |
|
| 522 |
}
|
- |
|
| 523 |
|
- |
|
| 524 |
private Map<String, Object> getAllInsuranceDetails(int fofoId) {
|
- |
|
| 525 |
|
- |
|
| 526 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
- |
|
| 527 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
- |
|
| 528 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
- |
|
| 529 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
- |
|
| 530 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
- |
|
| 531 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
- |
|
| 532 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
- |
|
| 533 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
- |
|
| 534 |
|
- |
|
| 535 |
List<String> insuranceProviders = insuranceProviderRepository.selectAll().stream().map(x -> x.getName())
|
- |
|
| 536 |
.collect(Collectors.toList());
|
- |
|
| 537 |
|
- |
|
| 538 |
Map<String, Object> map = new HashMap<>();
|
- |
|
| 539 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
- |
|
| 540 |
.selectByRetailerIdAndBetweenCreatedTimeStamp(fofoId, previousMonthFirstDay, LocalDateTime.now());
|
- |
|
| 541 |
|
- |
|
| 542 |
Map<Integer, Double> currentMonthTotalInsurance = insurancePolicies.stream()
|
- |
|
| 543 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 544 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 545 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
- |
|
| 546 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 547 |
|
- |
|
| 548 |
Map<Integer, Double> previousMonthTotalInsurance = insurancePolicies.stream()
|
- |
|
| 549 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 550 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
- |
|
| 551 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
- |
|
| 552 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 553 |
|
- |
|
| 554 |
Map<Integer, Double> currentDayTotalInsurance = insurancePolicies.stream().filter(
|
- |
|
| 555 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 556 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
- |
|
| 557 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 558 |
|
- |
|
| 559 |
Map<Integer, Double> previousDayTotalInsurance = insurancePolicies.stream()
|
- |
|
| 560 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 561 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
- |
|
| 562 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
- |
|
| 563 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 564 |
|
- |
|
| 565 |
IntFunction<String> intFunction = (providerId) -> {
|
- |
|
| 566 |
try {
|
- |
|
| 567 |
return insuranceProviderRepository.selectById(providerId).getName();
|
- |
|
| 568 |
} catch (ProfitMandiBusinessException e1) {
|
- |
|
| 569 |
// TODO Auto-generated catch block
|
- |
|
| 570 |
return "";
|
- |
|
| 571 |
}
|
- |
|
| 572 |
};
|
- |
|
| 573 |
Map<String, Double> currentMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
- |
|
| 574 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 575 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 576 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 577 |
return intFunction.apply(x.getProviderId());
|
- |
|
| 578 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 579 |
|
- |
|
| 580 |
Map<String, Double> previousMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
- |
|
| 581 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 582 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
- |
|
| 583 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 584 |
return intFunction.apply(x.getProviderId());
|
- |
|
| 585 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 586 |
|
- |
|
| 587 |
Map<String, Double> previousDayTotalInsuranceByPolicyName = insurancePolicies.stream()
|
- |
|
| 588 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 589 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
- |
|
| 590 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 591 |
return intFunction.apply(x.getProviderId());
|
- |
|
| 592 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 593 |
|
- |
|
| 594 |
Map<String, Double> currentDayTotalInsuranceByPolicyName = insurancePolicies.stream().filter(
|
- |
|
| 595 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 596 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 597 |
return intFunction.apply(x.getProviderId());
|
- |
|
| 598 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
- |
|
| 599 |
|
- |
|
| 600 |
map.put("currentMonthTotalInsurance", currentMonthTotalInsurance);
|
- |
|
| 601 |
map.put("previousMonthTotalInsurance", previousMonthTotalInsurance);
|
- |
|
| 602 |
map.put("currentDayTotalInsurance", currentDayTotalInsurance);
|
- |
|
| 603 |
map.put("previousDayTotalInsurance", previousDayTotalInsurance);
|
- |
|
| 604 |
map.put("currentMonthTotalInsuranceByPolicyName", currentMonthTotalInsuranceByPolicyName);
|
- |
|
| 605 |
map.put("previousMonthTotalInsuranceByPolicyName", previousMonthTotalInsuranceByPolicyName);
|
- |
|
| 606 |
map.put("previousDayTotalInsuranceByPolicyName", previousDayTotalInsuranceByPolicyName);
|
- |
|
| 607 |
map.put("currentDayTotalInsuranceByPolicyName", currentDayTotalInsuranceByPolicyName);
|
- |
|
| 608 |
map.put("insuranceProviders", insuranceProviders);
|
- |
|
| 609 |
return map;
|
- |
|
| 610 |
}
|
- |
|
| 611 |
|
- |
|
| 612 |
private Map<String, Object> getAllRechargeDetails(int fofoId) {
|
- |
|
| 613 |
|
- |
|
| 614 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
- |
|
| 615 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
- |
|
| 616 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
- |
|
| 617 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
- |
|
| 618 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
- |
|
| 619 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
- |
|
| 620 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
- |
|
| 621 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
- |
|
| 622 |
|
- |
|
| 623 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
- |
|
| 624 |
.getAllRechargeTransactionByCreatedTimeStamp(fofoId, previousMonthFirstDay, currentDayEnd).stream()
|
- |
|
| 625 |
.filter(x -> x.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
- |
|
| 626 |
|
- |
|
| 627 |
LOGGER.info(rechargeTransactions);
|
- |
|
| 628 |
Map<Integer, Double> currentMonthTotalRecharge = rechargeTransactions.stream()
|
- |
|
| 629 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 630 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 631 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
- |
|
| 632 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 633 |
LOGGER.info(currentMonthTotalRecharge);
|
- |
|
| 634 |
Map<Integer, Double> previousMonthTotalRecharge = rechargeTransactions.stream()
|
- |
|
| 635 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 636 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
- |
|
| 637 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
- |
|
| 638 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 639 |
|
- |
|
| 640 |
LOGGER.info(previousMonthTotalRecharge);
|
- |
|
| 641 |
Map<Integer, Double> currentDayTotalRecharge = rechargeTransactions.stream().filter(
|
- |
|
| 642 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 643 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
- |
|
| 644 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 645 |
|
- |
|
| 646 |
Map<Integer, Double> previousDayTotalRecharge = rechargeTransactions.stream()
|
- |
|
| 647 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 648 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
- |
|
| 649 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
- |
|
| 650 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 651 |
|
- |
|
| 652 |
Map<Object, Double> currentMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
- |
|
| 653 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 654 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 655 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 656 |
return x.getType();
|
- |
|
| 657 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 658 |
|
- |
|
| 659 |
Map<Object, Double> previosMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
- |
|
| 660 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 661 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
- |
|
| 662 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 663 |
return x.getType();
|
- |
|
| 664 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 665 |
|
- |
|
| 666 |
Map<Object, Double> currentDayTotalRechargeByRechargeType = rechargeTransactions.stream().filter(
|
- |
|
| 667 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 668 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 669 |
return x.getType();
|
- |
|
| 670 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 671 |
|
- |
|
| 672 |
Map<Object, Double> previousDayTotalRechargeByRechargeType = rechargeTransactions.stream()
|
- |
|
| 673 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 674 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
- |
|
| 675 |
.collect(Collectors.groupingBy(x -> {
|
- |
|
| 676 |
return x.getType();
|
- |
|
| 677 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
- |
|
| 678 |
|
- |
|
| 679 |
LOGGER.info("previosMonthTotalRechargeByRechargeType" + previosMonthTotalRechargeByRechargeType);
|
- |
|
| 680 |
Map<String, Object> map = new HashMap<>();
|
- |
|
| 681 |
map.put("currentMonthTotalRecharge", currentMonthTotalRecharge);
|
- |
|
| 682 |
map.put("previousMonthTotalRecharge", previousMonthTotalRecharge);
|
- |
|
| 683 |
map.put("currentDayTotalRecharge", currentDayTotalRecharge);
|
- |
|
| 684 |
map.put("previousDayTotalRecharge", previousDayTotalRecharge);
|
- |
|
| 685 |
map.put("currentMonthTotalRechargeByRechargeType", currentMonthTotalRechargeByRechargeType);
|
- |
|
| 686 |
map.put("previosMonthTotalRechargeByRechargeType", previosMonthTotalRechargeByRechargeType);
|
- |
|
| 687 |
map.put("currentDayTotalRechargeByRechargeType", currentDayTotalRechargeByRechargeType);
|
- |
|
| 688 |
map.put("previousDayTotalRechargeByRechargeType", previousDayTotalRechargeByRechargeType);
|
- |
|
| 689 |
map.put("rechargeTypes", RechargeType.values());
|
- |
|
| 690 |
|
- |
|
| 691 |
return map;
|
- |
|
| 692 |
|
- |
|
| 693 |
}
|
- |
|
| 694 |
|
- |
|
| 695 |
private Map<String, Object> getAllSaleDetails(int fofoId) {
|
- |
|
| 696 |
|
- |
|
| 697 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
- |
|
| 698 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
- |
|
| 699 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
- |
|
| 700 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
- |
|
| 701 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
- |
|
| 702 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
- |
|
| 703 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
- |
|
| 704 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
- |
|
| 705 |
|
- |
|
| 706 |
Map<String, Object> map = new HashMap<>();
|
- |
|
| 707 |
|
- |
|
| 708 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
- |
|
| 709 |
previousMonthFirstDay, currentDayEnd);
|
- |
|
| 710 |
|
- |
|
| 711 |
Double currentMonthTotalSale = fofoOrderItems.stream()
|
- |
|
| 712 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 713 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 714 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 715 |
|
- |
|
| 716 |
LOGGER.info("currentMonthTotalSale" + currentMonthTotalSale);
|
- |
|
| 717 |
Double previousMonthTotalSale = fofoOrderItems.stream()
|
- |
|
| 718 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 719 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
- |
|
| 720 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 721 |
|
- |
|
| 722 |
Double currentDayTotalSale = fofoOrderItems.stream().filter(
|
- |
|
| 723 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
- |
|
| 724 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 725 |
|
- |
|
| 726 |
LOGGER.info(currentDayTotalSale);
|
- |
|
| 727 |
|
- |
|
| 728 |
Double previousDayTotalSale = fofoOrderItems.stream()
|
- |
|
| 729 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 730 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
- |
|
| 731 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 732 |
LOGGER.info(previousDayTotalSale);
|
- |
|
| 733 |
IntPredicate checkHandset = (itemId) -> {
|
- |
|
| 734 |
try {
|
- |
|
| 735 |
Item item = itemRepository.selectById(itemId);
|
- |
|
| 736 |
return item.getCategoryId() == 10006;
|
- |
|
| 737 |
} catch (ProfitMandiBusinessException e) {
|
- |
|
| 738 |
// TODO Auto-generated catch block
|
- |
|
| 739 |
e.printStackTrace();
|
- |
|
| 740 |
return false;
|
- |
|
| 741 |
}
|
- |
|
| 742 |
};
|
- |
|
| 743 |
|
- |
|
| 744 |
Set<String> brands = fofoOrderItemRepository
|
- |
|
| 745 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
- |
|
| 746 |
.filter(x -> checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
- |
|
| 747 |
Set<String> accessories = fofoOrderItemRepository
|
- |
|
| 748 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
- |
|
| 749 |
.filter(x -> !checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
- |
|
| 750 |
|
- |
|
| 751 |
Double currentMonthTotalMobileSale = fofoOrderItems.stream()
|
- |
|
| 752 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 753 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 754 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 755 |
|
- |
|
| 756 |
Double previousMonthTotalMobileSale = fofoOrderItems.stream()
|
- |
|
| 757 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 758 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
- |
|
| 759 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 760 |
|
- |
|
| 761 |
Double previousDayTotalMobileSale = fofoOrderItems.stream()
|
- |
|
| 762 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 763 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 764 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 765 |
|
- |
|
| 766 |
Double currentDayTotalMobileSale = fofoOrderItems.stream()
|
- |
|
| 767 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
- |
|
| 768 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 769 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 770 |
|
- |
|
| 771 |
Double currentMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
- |
|
| 772 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 773 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 774 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 775 |
|
- |
|
| 776 |
Double previousMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
- |
|
| 777 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 778 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
- |
|
| 779 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 780 |
|
- |
|
| 781 |
Double previousDayTotalAccessoriesSale = fofoOrderItems.stream()
|
- |
|
| 782 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 783 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 784 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 785 |
|
- |
|
| 786 |
Double currentDayTotalAccessoriesSale = fofoOrderItems.stream()
|
- |
|
| 787 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
- |
|
| 788 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 789 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
- |
|
| 790 |
|
- |
|
| 791 |
Map<String, Double> currentMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 792 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 793 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 794 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 795 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 796 |
|
- |
|
| 797 |
Map<String, Double> currentMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 798 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
- |
|
| 799 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 800 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 801 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 802 |
|
- |
|
| 803 |
Map<String, Double> previousMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 804 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 805 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
- |
|
| 806 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 807 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 808 |
|
- |
|
| 809 |
Map<String, Double> currentDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 810 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
- |
|
| 811 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 812 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 813 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 814 |
|
- |
|
| 815 |
Map<String, Double> previousDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 816 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 817 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
- |
|
| 818 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 819 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 820 |
|
- |
|
| 821 |
Map<String, Double> currentDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 822 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
- |
|
| 823 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 824 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 825 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 826 |
|
- |
|
| 827 |
Map<String, Double> previousDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 828 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
- |
|
| 829 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
- |
|
| 830 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 831 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 832 |
Map<String, Double> previousMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
- |
|
| 833 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
- |
|
| 834 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
- |
|
| 835 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
- |
|
| 836 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
- |
|
| 837 |
|
- |
|
| 838 |
map.put("brands", brands);
|
- |
|
| 839 |
map.put("accessories", accessories);
|
- |
|
| 840 |
map.put("currentMonthTotalSale", currentMonthTotalSale);
|
- |
|
| 841 |
map.put("previousMonthTotalSale", previousMonthTotalSale);
|
- |
|
| 842 |
map.put("currentDayTotalSale", currentDayTotalSale);
|
- |
|
| 843 |
map.put("previousDayTotalSale", previousDayTotalSale);
|
- |
|
| 844 |
map.put("currentMonthMobileSalegroupByBrand", currentMonthMobileSalegroupByBrand);
|
- |
|
| 845 |
map.put("currentMonthAccesoriesSalegroupByBrand", currentMonthAccesoriesSalegroupByBrand);
|
- |
|
| 846 |
map.put("previousMonthAccesoriesSalegroupByBrand", previousMonthAccesoriesSalegroupByBrand);
|
- |
|
| 847 |
map.put("previousDayAccesoriesSalegroupByBrand", previousDayAccesoriesSalegroupByBrand);
|
- |
|
| 848 |
map.put("currentDayMobileSalegroupByBrand", currentDayMobileSalegroupByBrand);
|
- |
|
| 849 |
map.put("previousDayMobileSalegroupByBrand", previousDayMobileSalegroupByBrand);
|
- |
|
| 850 |
map.put("currentDayAccesoriesSalegroupByBrand", currentDayAccesoriesSalegroupByBrand);
|
- |
|
| 851 |
map.put("previousMonthMobileSalegroupByBrand", previousMonthMobileSalegroupByBrand);
|
- |
|
| 852 |
|
- |
|
| 853 |
map.put("currentMonthTotalMobileSale", currentMonthTotalMobileSale);
|
- |
|
| 854 |
map.put("previousMonthTotalMobileSale", previousMonthTotalMobileSale);
|
- |
|
| 855 |
map.put("previousDayTotalMobileSale", previousDayTotalMobileSale);
|
- |
|
| 856 |
map.put("currentDayTotalMobileSale", currentDayTotalMobileSale);
|
- |
|
| 857 |
map.put("currentMonthTotalAccessoriesSale", currentMonthTotalAccessoriesSale);
|
- |
|
| 858 |
map.put("previousMonthTotalAccessoriesSale", previousMonthTotalAccessoriesSale);
|
- |
|
| 859 |
map.put("previousDayTotalAccessoriesSale", previousDayTotalAccessoriesSale);
|
- |
|
| 860 |
map.put("currentDayTotalAccessoriesSale", currentDayTotalAccessoriesSale);
|
- |
|
| 861 |
|
- |
|
| 862 |
return map;
|
- |
|
| 863 |
}
|
- |
|
| 864 |
}
|
229 |
}
|