| Line 11... |
Line 11... |
| 11 |
import java.util.Arrays;
|
11 |
import java.util.Arrays;
|
| 12 |
import java.util.HashMap;
|
12 |
import java.util.HashMap;
|
| 13 |
import java.util.LinkedHashMap;
|
13 |
import java.util.LinkedHashMap;
|
| 14 |
import java.util.List;
|
14 |
import java.util.List;
|
| 15 |
import java.util.Map;
|
15 |
import java.util.Map;
|
| - |
|
16 |
import java.util.Map.Entry;
|
| 16 |
import java.util.stream.Collectors;
|
17 |
import java.util.stream.Collectors;
|
| 17 |
|
18 |
|
| 18 |
import javax.servlet.http.HttpServletRequest;
|
19 |
import javax.servlet.http.HttpServletRequest;
|
| 19 |
import javax.transaction.Transactional;
|
20 |
import javax.transaction.Transactional;
|
| 20 |
|
21 |
|
| 21 |
import org.apache.logging.log4j.LogManager;
|
22 |
import org.apache.logging.log4j.LogManager;
|
| 22 |
import org.apache.logging.log4j.Logger;
|
23 |
import org.apache.logging.log4j.Logger;
|
| - |
|
24 |
import org.json.JSONArray;
|
| - |
|
25 |
import org.json.JSONObject;
|
| 23 |
import org.springframework.beans.factory.annotation.Autowired;
|
26 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 24 |
import org.springframework.beans.factory.annotation.Value;
|
27 |
import org.springframework.beans.factory.annotation.Value;
|
| 25 |
import org.springframework.core.io.InputStreamResource;
|
28 |
import org.springframework.core.io.InputStreamResource;
|
| 26 |
import org.springframework.http.HttpHeaders;
|
29 |
import org.springframework.http.HttpHeaders;
|
| 27 |
import org.springframework.http.HttpStatus;
|
30 |
import org.springframework.http.HttpStatus;
|
| Line 36... |
Line 39... |
| 36 |
import com.mongodb.DBObject;
|
39 |
import com.mongodb.DBObject;
|
| 37 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
40 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 38 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
41 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 39 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
42 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 40 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
43 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| - |
|
44 |
import com.spice.profitmandi.common.model.ChartModel;
|
| 41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
45 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| - |
|
46 |
import com.spice.profitmandi.common.model.DataModel;
|
| - |
|
47 |
import com.spice.profitmandi.common.model.DatasetModel;
|
| - |
|
48 |
import com.spice.profitmandi.common.model.LegendModel;
|
| 42 |
import com.spice.profitmandi.common.model.Notification;
|
49 |
import com.spice.profitmandi.common.model.Notification;
|
| - |
|
50 |
import com.spice.profitmandi.common.model.OptionsModel;
|
| 43 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
51 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
52 |
import com.spice.profitmandi.common.model.TitleModel;
|
| 44 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
53 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 45 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
54 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 46 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
55 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 47 |
import com.spice.profitmandi.dao.entity.auth.Menu;
|
56 |
import com.spice.profitmandi.dao.entity.auth.Menu;
|
| 48 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
57 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 49 |
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
|
- |
|
| 50 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
58 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 51 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
59 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 52 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
60 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| 53 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
61 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 54 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
62 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| Line 199... |
Line 207... |
| 199 |
model.addAttribute("hasGift", hasGift(fofoId));
|
207 |
model.addAttribute("hasGift", hasGift(fofoId));
|
| 200 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
208 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 201 |
|
209 |
|
| 202 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
210 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| 203 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
211 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
| - |
|
212 |
ChartModel cm = this.getBrandChart(fofoId);
|
| - |
|
213 |
|
| - |
|
214 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 204 |
// this.setInvestments
|
215 |
// this.setInvestments
|
| 205 |
//
|
216 |
//
|
| 206 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
217 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
| 207 |
model.addAttribute("isInvestmentOk",
|
218 |
model.addAttribute("isInvestmentOk",
|
| 208 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
219 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| Line 293... |
Line 304... |
| 293 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
304 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| 294 |
|
305 |
|
| 295 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
306 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
| 296 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
307 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
| 297 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
308 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 298 |
|
- |
|
| 299 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
309 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| 300 |
salesMap.put("currentRate", currentRate);
|
310 |
salesMap.put("currentRate", currentRate);
|
| 301 |
salesMap.put("currentType", currentType);
|
311 |
salesMap.put("currentType", currentType);
|
| 302 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
312 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
| 303 |
return salesMap;
|
313 |
return salesMap;
|
| Line 350... |
Line 360... |
| 350 |
model.addAttribute("fofoStore", fofoStore);
|
360 |
model.addAttribute("fofoStore", fofoStore);
|
| 351 |
model.addAttribute("partnerType", partnerType);
|
361 |
model.addAttribute("partnerType", partnerType);
|
| 352 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
362 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 353 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
363 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 354 |
|
364 |
|
| 355 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
365 |
// model.addAttribute("brandStockPrices",this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 356 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
366 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| - |
|
367 |
ChartModel cm = this.getBrandChart(loginDetails.getFofoId());
|
| - |
|
368 |
|
| - |
|
369 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
| - |
|
370 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 357 |
// this.setInvestments
|
371 |
// this.setInvestments
|
| 358 |
//
|
372 |
//
|
| 359 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
373 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 360 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
374 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
| 361 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
375 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| Line 391... |
Line 405... |
| 391 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
405 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
| 392 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
406 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 393 |
return "dashboard1";
|
407 |
return "dashboard1";
|
| 394 |
}
|
408 |
}
|
| 395 |
|
409 |
|
| - |
|
410 |
private ChartModel getBrandChart(int fofoId) {
|
| - |
|
411 |
|
| - |
|
412 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
413 |
|
| - |
|
414 |
LOGGER.info("cur Date" + curDate.withDayOfMonth(1));
|
| - |
|
415 |
|
| - |
|
416 |
LOGGER.info("curDateYear" + curDate.with(LocalTime.MAX));
|
| - |
|
417 |
|
| - |
|
418 |
Map<String, Double> brandwisesale = fofoOrderItemRepository
|
| - |
|
419 |
.selectSumAmountGroupByBrand(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId);
|
| - |
|
420 |
LOGGER.info("brandwisesale" + brandwisesale);
|
| - |
|
421 |
|
| - |
|
422 |
Map<String, Double> lmtdBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
| - |
|
423 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), fofoId);
|
| - |
|
424 |
|
| - |
|
425 |
ChartModel cm = new ChartModel();
|
| - |
|
426 |
|
| - |
|
427 |
List<String> labels = new ArrayList<>();
|
| - |
|
428 |
labels.addAll(brandwisesale.keySet());
|
| - |
|
429 |
List<Double> values = new ArrayList<>();
|
| - |
|
430 |
values.addAll(brandwisesale.values());
|
| - |
|
431 |
|
| - |
|
432 |
List<Double> lmtdValues = new ArrayList<>();
|
| - |
|
433 |
lmtdValues.addAll(lmtdBrandWiseSale.values());
|
| - |
|
434 |
|
| - |
|
435 |
DatasetModel dsm = new DatasetModel();
|
| - |
|
436 |
dsm.setLabel("mtd sales");
|
| - |
|
437 |
|
| - |
|
438 |
List<String> backgroundColor = new ArrayList<>();
|
| - |
|
439 |
for (Entry<String, Double> bs : brandwisesale.entrySet()) {
|
| - |
|
440 |
backgroundColor.add("#3e95cd");
|
| - |
|
441 |
}
|
| - |
|
442 |
|
| - |
|
443 |
dsm.setBackgroundColor(backgroundColor);
|
| - |
|
444 |
dsm.setData(values);
|
| - |
|
445 |
|
| - |
|
446 |
DatasetModel lmtddsm = new DatasetModel();
|
| - |
|
447 |
lmtddsm.setLabel("lmtd sales");
|
| - |
|
448 |
|
| - |
|
449 |
List<String> background = new ArrayList<>();
|
| - |
|
450 |
for (Entry<String, Double> bs : lmtdBrandWiseSale.entrySet()) {
|
| - |
|
451 |
background.add("#8e5ea2");
|
| - |
|
452 |
}
|
| - |
|
453 |
|
| - |
|
454 |
lmtddsm.setBackgroundColor(background);
|
| - |
|
455 |
lmtddsm.setData(lmtdValues);
|
| - |
|
456 |
|
| - |
|
457 |
List<DatasetModel> datasets = new ArrayList<>();
|
| - |
|
458 |
datasets.add(dsm);
|
| - |
|
459 |
datasets.add(lmtddsm);
|
| - |
|
460 |
|
| - |
|
461 |
DataModel dm = new DataModel();
|
| - |
|
462 |
dm.setDatasets(datasets);
|
| - |
|
463 |
dm.setLabels(labels);
|
| - |
|
464 |
|
| - |
|
465 |
LegendModel lm = new LegendModel();
|
| - |
|
466 |
lm.setDisplay(true);
|
| - |
|
467 |
|
| - |
|
468 |
TitleModel tm = new TitleModel();
|
| - |
|
469 |
tm.setText("Brand Wise Sale Graph");
|
| - |
|
470 |
tm.setDisplay(true);
|
| - |
|
471 |
|
| - |
|
472 |
OptionsModel om = new OptionsModel();
|
| - |
|
473 |
om.setLegend(lm);
|
| - |
|
474 |
om.setTitle(tm);
|
| - |
|
475 |
|
| - |
|
476 |
cm.setType("bar");
|
| - |
|
477 |
cm.setData(dm);
|
| - |
|
478 |
cm.setOptions(om);
|
| - |
|
479 |
|
| - |
|
480 |
return cm;
|
| - |
|
481 |
|
| - |
|
482 |
}
|
| - |
|
483 |
|
| 396 |
private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
|
484 |
private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
|
| 397 |
List<Menu> menus = null;
|
485 |
List<Menu> menus = null;
|
| 398 |
try {
|
486 |
try {
|
| 399 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
487 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 400 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
488 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| 401 |
if(Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
|
489 |
if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
|
| 402 |
menus = menuRepository.selectAll();
|
490 |
menus = menuRepository.selectAll();
|
| 403 |
} else if (positions.size() > 0) {
|
491 |
} else if (positions.size() > 0) {
|
| 404 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
|
492 |
if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
|
| 405 |
menus = menuRepository.selectAll();
|
493 |
menus = menuRepository.selectAll();
|
| 406 |
} else {
|
494 |
} else {
|