| Line 8... |
Line 8... |
| 8 |
import java.io.ObjectOutputStream;
|
8 |
import java.io.ObjectOutputStream;
|
| 9 |
import java.time.LocalDate;
|
9 |
import java.time.LocalDate;
|
| 10 |
import java.time.LocalDateTime;
|
10 |
import java.time.LocalDateTime;
|
| 11 |
import java.time.LocalTime;
|
11 |
import java.time.LocalTime;
|
| 12 |
import java.time.Month;
|
12 |
import java.time.Month;
|
| - |
|
13 |
import java.time.Period;
|
| 13 |
import java.time.YearMonth;
|
14 |
import java.time.YearMonth;
|
| 14 |
import java.time.ZoneOffset;
|
15 |
import java.time.ZoneOffset;
|
| 15 |
import java.time.format.DateTimeFormatter;
|
16 |
import java.time.format.DateTimeFormatter;
|
| 16 |
import java.util.ArrayList;
|
17 |
import java.util.ArrayList;
|
| 17 |
import java.util.Arrays;
|
18 |
import java.util.Arrays;
|
| Line 34... |
Line 35... |
| 34 |
import javax.transaction.Transactional;
|
35 |
import javax.transaction.Transactional;
|
| 35 |
|
36 |
|
| 36 |
import org.apache.commons.collections4.OrderedMap;
|
37 |
import org.apache.commons.collections4.OrderedMap;
|
| 37 |
import org.apache.logging.log4j.LogManager;
|
38 |
import org.apache.logging.log4j.LogManager;
|
| 38 |
import org.apache.logging.log4j.Logger;
|
39 |
import org.apache.logging.log4j.Logger;
|
| 39 |
import org.bouncycastle.crypto.tls.HashAlgorithm;
|
- |
|
| - |
|
40 |
|
| 40 |
import org.json.JSONObject;
|
41 |
import org.json.JSONObject;
|
| 41 |
import org.springframework.beans.factory.annotation.Autowired;
|
42 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 42 |
import org.springframework.beans.factory.annotation.Value;
|
43 |
import org.springframework.beans.factory.annotation.Value;
|
| 43 |
import org.springframework.core.io.InputStreamResource;
|
44 |
import org.springframework.core.io.InputStreamResource;
|
| 44 |
import org.springframework.http.HttpHeaders;
|
45 |
import org.springframework.http.HttpHeaders;
|
| Line 103... |
Line 104... |
| 103 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
104 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 104 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
105 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 105 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
106 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 106 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
107 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| 107 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
108 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| - |
|
109 |
import com.spice.profitmandi.dao.model.BrandWiseModel;
|
| 108 |
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
|
110 |
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
|
| 109 |
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
|
111 |
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
|
| 110 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
112 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 111 |
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
|
113 |
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
|
| 112 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
114 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
| Line 446... |
Line 448... |
| 446 |
|
448 |
|
| 447 |
private Map<String, Object> getSales(int fofoId) {
|
449 |
private Map<String, Object> getSales(int fofoId) {
|
| 448 |
|
450 |
|
| 449 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
451 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 450 |
LocalDateTime now = LocalDateTime.now();
|
452 |
LocalDateTime now = LocalDateTime.now();
|
| 451 |
LocalDateTime startOfToday= LocalDate.now().atStartOfDay();
|
453 |
LocalDateTime startOfToday = LocalDate.now().atStartOfDay();
|
| 452 |
int monthLength = LocalDate.now().lengthOfMonth();
|
454 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 453 |
int daysGone = now.getDayOfMonth() - 1;
|
455 |
int daysGone = now.getDayOfMonth() - 1;
|
| 454 |
int daysRemaining = monthLength - daysGone;
|
456 |
int daysRemaining = monthLength - daysGone;
|
| 455 |
Double todaySale = fofoOrderItemRepository
|
- |
|
| 456 |
.selectSumMopGroupByRetailer(startOfToday, now, fofoId, false).get(fofoId);
|
457 |
Double todaySale = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfToday, now, fofoId, false)
|
| 457 |
Double mtdSaleTillYesterDay = fofoOrderItemRepository
|
- |
|
| 458 |
.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1), startOfToday, fofoId, false)
|
- |
|
| 459 |
.get(fofoId);
|
458 |
.get(fofoId);
|
| - |
|
459 |
Double mtdSaleTillYesterDay = fofoOrderItemRepository
|
| - |
|
460 |
.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1), startOfToday, fofoId, false).get(fofoId);
|
| 460 |
Double mtdSale = mtdSaleTillYesterDay + todaySale;
|
461 |
Double mtdSale = mtdSaleTillYesterDay + todaySale;
|
| 461 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1).minusMonths(1),
|
462 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| 462 |
now.minusMonths(1), fofoId, false).get(fofoId);
|
463 |
startOfToday.withDayOfMonth(1).minusMonths(1), now.minusMonths(1), fofoId, false).get(fofoId);
|
| 463 |
|
464 |
|
| 464 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
465 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 465 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
466 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 466 |
if (partnerTargetDetails.isEmpty()) {
|
467 |
if (partnerTargetDetails.isEmpty()) {
|
| 467 |
partnerTargetDetails = partnerTargetRepository
|
468 |
partnerTargetDetails = partnerTargetRepository
|
| Line 469... |
Line 470... |
| 469 |
}
|
470 |
}
|
| 470 |
|
471 |
|
| 471 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
472 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 472 |
|
473 |
|
| 473 |
int currentRate = 0;
|
474 |
int currentRate = 0;
|
| 474 |
if(mtdSaleTillYesterDay> 0) {
|
475 |
if (mtdSaleTillYesterDay > 0) {
|
| 475 |
currentRate = (int) (mtdSaleTillYesterDay / daysGone);
|
476 |
currentRate = (int) (mtdSaleTillYesterDay / daysGone);
|
| 476 |
}
|
477 |
}
|
| 477 |
|
478 |
|
| 478 |
salesMap.put("requiredType", partnerType.next());
|
479 |
salesMap.put("requiredType", partnerType.next());
|
| 479 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
480 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
| Line 813... |
Line 814... |
| 813 |
|
814 |
|
| 814 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
815 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 815 |
|
816 |
|
| 816 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
817 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
| 817 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
818 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
| 818 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
819 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| 819 |
|
820 |
|
| 820 |
Map<YearMonth, Map<String, Double>> monthBrandValue = new HashMap<>();
|
821 |
Map<YearMonth, Map<String, Double>> monthBrandValue = new HashMap<>();
|
| 821 |
LOGGER.info("priceDropYearMonthModels"+priceDropYearMonthModels);
|
822 |
LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
|
| 822 |
for (PriceDropYearMonthModel priceDropYearMonthModel : priceDropYearMonthModels) {
|
823 |
for (PriceDropYearMonthModel priceDropYearMonthModel : priceDropYearMonthModels) {
|
| 823 |
|
824 |
|
| 824 |
Map<String, Double> brandValue = new HashMap<>();
|
825 |
Map<String, Double> brandValue = new HashMap<>();
|
| 825 |
brandValue.put(priceDropYearMonthModel.getBrand(), (double) priceDropYearMonthModel.getAmount());
|
826 |
brandValue.put(priceDropYearMonthModel.getBrand(), (double) priceDropYearMonthModel.getAmount());
|
| 826 |
monthBrandValue.put(YearMonth.parse(priceDropYearMonthModel.getYearMonth(), dateTimeFormatter), brandValue);
|
827 |
monthBrandValue.put(YearMonth.parse(priceDropYearMonthModel.getYearMonth(), dateTimeFormatter), brandValue);
|
| 827 |
}
|
828 |
}
|
| 828 |
Map<YearMonth, Map<String, Double>> sortedMonthBrandValue = new TreeMap<>(monthBrandValue);
|
829 |
Map<YearMonth, Map<String, Double>> sortedMonthBrandValue = new TreeMap<>(monthBrandValue);
|
| 829 |
|
830 |
|
| 830 |
LOGGER.info("sortedMonthBrandValue"+sortedMonthBrandValue);
|
831 |
LOGGER.info("sortedMonthBrandValue" + sortedMonthBrandValue);
|
| 831 |
List<String> brands = new ArrayList<>();
|
832 |
List<String> brands = new ArrayList<>();
|
| 832 |
|
833 |
|
| 833 |
brands.add("Accessories");
|
834 |
brands.add("Accessories");
|
| 834 |
brands.add("Oppo");
|
835 |
brands.add("Oppo");
|
| 835 |
brands.add("Vivo");
|
836 |
brands.add("Vivo");
|
| 836 |
brands.add("Samsung");
|
837 |
brands.add("Samsung");
|
| 837 |
brands.add("Realme");
|
838 |
brands.add("Realme");
|
| 838 |
brands.add("Mi");
|
839 |
brands.add("Mi");
|
| 839 |
brands.add("Tecno");
|
840 |
brands.add("Tecno");
|
| 840 |
brands.add("Itel");
|
841 |
brands.add("Itel");
|
| 841 |
|
842 |
|
| 842 |
brands.add("Nokia");
|
843 |
brands.add("Nokia");
|
| 843 |
for (int i = 6; i >= 1; i--) {
|
844 |
for (int i = 6; i >= 1; i--) {
|
| 844 |
|
845 |
|
| 845 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
846 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 846 |
|
847 |
|
| 847 |
LOGGER.info("getStartMonth"+sortedMonthBrandValue.get(YearMonth.from(startMonth)));
|
848 |
LOGGER.info("getStartMonth" + sortedMonthBrandValue.get(YearMonth.from(startMonth)));
|
| 848 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
849 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
| 849 |
for (String brand : brands) {
|
850 |
for (String brand : brands) {
|
| 850 |
if (valbrand != null) {
|
851 |
if (valbrand != null) {
|
| 851 |
if (!valbrand.containsKey(brand)) {
|
852 |
if (!valbrand.containsKey(brand)) {
|
| 852 |
valbrand.put(brand, 0.0);
|
853 |
valbrand.put(brand, 0.0);
|
| 853 |
}
|
- |
|
| 854 |
else {
|
854 |
} else {
|
| 855 |
valbrand.put(brand, valbrand.get(brand));
|
855 |
valbrand.put(brand, valbrand.get(brand));
|
| 856 |
}
|
856 |
}
|
| 857 |
|
857 |
|
| 858 |
} else {
|
858 |
} else {
|
| 859 |
valbrand = new HashMap<String, Double>();
|
859 |
valbrand = new HashMap<String, Double>();
|
| Line 907... |
Line 907... |
| 907 |
|
907 |
|
| 908 |
colorList.add("coral");
|
908 |
colorList.add("coral");
|
| 909 |
|
909 |
|
| 910 |
colorList.add("steelblue");
|
910 |
colorList.add("steelblue");
|
| 911 |
colorList.add("red");
|
911 |
colorList.add("red");
|
| 912 |
|
912 |
|
| 913 |
colorList.add("midnightblue");
|
913 |
colorList.add("midnightblue");
|
| 914 |
colorList.add("cornsilk");
|
914 |
colorList.add("cornsilk");
|
| 915 |
|
915 |
|
| 916 |
List<String> borderList = new ArrayList<>();
|
916 |
List<String> borderList = new ArrayList<>();
|
| 917 |
borderList.add("pink");
|
917 |
borderList.add("pink");
|
| Line 922... |
Line 922... |
| 922 |
|
922 |
|
| 923 |
borderList.add("#ff8c69");
|
923 |
borderList.add("#ff8c69");
|
| 924 |
|
924 |
|
| 925 |
borderList.add("#0000cd");
|
925 |
borderList.add("#0000cd");
|
| 926 |
borderList.add("lightsalmon");
|
926 |
borderList.add("lightsalmon");
|
| 927 |
|
- |
|
| 928 |
borderList.add("#0000cd");
|
927 |
borderList.add("#0000cd");
|
| 929 |
borderList.add("cornsilk");
|
928 |
borderList.add("cornsilk");
|
| 930 |
|
929 |
|
| 931 |
int i = 0;
|
930 |
int i = 0;
|
| 932 |
|
931 |
|
| 933 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
932 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
| 934 |
|
933 |
|
| 935 |
DatasetModel purchaseModel = new DatasetModel();
|
934 |
DatasetModel purchaseModel = new DatasetModel();
|
| 936 |
purchaseModel.setLabel(brandValue.getKey());
|
935 |
purchaseModel.setLabel(brandValue.getKey());
|
| 937 |
purchaseModel.setBackgroundColor(colorList.get(i));
|
936 |
purchaseModel.setBackgroundColor(colorList.get(i));
|
| 938 |
if (brandValue.getValue().isEmpty()) {
|
937 |
if (brandValue.getValue().isEmpty()) {
|
| 939 |
|
938 |
|
| Line 1200... |
Line 1199... |
| 1200 |
Tooltips tooltips = new Tooltips();
|
1199 |
Tooltips tooltips = new Tooltips();
|
| 1201 |
tooltips.setBodyFontSize(15);
|
1200 |
tooltips.setBodyFontSize(15);
|
| 1202 |
tooltips.setTitleFontSize(15);
|
1201 |
tooltips.setTitleFontSize(15);
|
| 1203 |
tooltips.setMode("index");
|
1202 |
tooltips.setMode("index");
|
| 1204 |
tooltips.setIntersect(false);
|
1203 |
tooltips.setIntersect(false);
|
| 1205 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
1204 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
| 1206 |
HoverModel hover = new HoverModel();
|
1205 |
HoverModel hover = new HoverModel();
|
| 1207 |
hover.setIntersect(false);
|
1206 |
hover.setIntersect(false);
|
| 1208 |
hover.setMode("index");
|
1207 |
hover.setMode("index");
|
| 1209 |
|
1208 |
|
| 1210 |
TitleModel tm = new TitleModel();
|
1209 |
TitleModel tm = new TitleModel();
|
| Line 1374... |
Line 1373... |
| 1374 |
tooltips.setBodyFontSize(15);
|
1373 |
tooltips.setBodyFontSize(15);
|
| 1375 |
tooltips.setTitleFontSize(15);
|
1374 |
tooltips.setTitleFontSize(15);
|
| 1376 |
tooltips.setMode("index");
|
1375 |
tooltips.setMode("index");
|
| 1377 |
tooltips.setIntersect(false);
|
1376 |
tooltips.setIntersect(false);
|
| 1378 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
1377 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
| 1379 |
|
1378 |
|
| 1380 |
HoverModel hover = new HoverModel();
|
1379 |
HoverModel hover = new HoverModel();
|
| 1381 |
hover.setIntersect(false);
|
1380 |
hover.setIntersect(false);
|
| 1382 |
hover.setMode("index");
|
1381 |
hover.setMode("index");
|
| 1383 |
|
1382 |
|
| 1384 |
TitleModel tm = new TitleModel();
|
1383 |
TitleModel tm = new TitleModel();
|
| Line 1623... |
Line 1622... |
| 1623 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
1622 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
| 1624 |
|
1623 |
|
| 1625 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
1624 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 1626 |
LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
|
1625 |
LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
|
| 1627 |
|
1626 |
|
| 1628 |
Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
|
- |
|
| 1629 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
- |
|
| 1630 |
|
- |
|
| 1631 |
Map<AuthUser, Long> authUserTicketCount = null;
|
1627 |
Map<AuthUser, Long> authUserTicketCount = null;
|
| 1632 |
|
1628 |
|
| 1633 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
1629 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
| 1634 |
wm.put(entry.getKey(), entry.getValue());
|
1630 |
wm.put(entry.getKey(), entry.getValue());
|
| 1635 |
}
|
1631 |
}
|
| Line 1684... |
Line 1680... |
| 1684 |
|
1680 |
|
| 1685 |
// warehouseStock
|
1681 |
// warehouseStock
|
| 1686 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
|
1682 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
|
| 1687 |
rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
1683 |
rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
| 1688 |
|
1684 |
|
| 1689 |
partnersBrandSaleMap = fofoStoreRepository
|
- |
|
| 1690 |
.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds)).stream()
|
- |
|
| 1691 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
- |
|
| 1692 |
|
- |
|
| 1693 |
List<BrandWiseUnbilledActivateStockModel> unbilledActivatedStock = fofoStoreRepository
|
- |
|
| 1694 |
.selectUnbilledActivateStockGroupByBrand(new ArrayList<>(fofoIds));
|
- |
|
| 1695 |
for (BrandWiseUnbilledActivateStockModel un : unbilledActivatedStock) {
|
- |
|
| 1696 |
BrandWisePartnerSaleModel bpt = partnersBrandSaleMap.get(un.getBrand());
|
- |
|
| 1697 |
if (bpt != null) {
|
- |
|
| 1698 |
bpt.setAmtd(un.getUnbilledMtd());
|
- |
|
| 1699 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
- |
|
| 1700 |
} else {
|
- |
|
| 1701 |
bpt = new BrandWisePartnerSaleModel();
|
- |
|
| 1702 |
bpt.setBrand(un.getBrand());
|
- |
|
| 1703 |
bpt.setAmtd(un.getUnbilledMtd());
|
- |
|
| 1704 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
- |
|
| 1705 |
bpt.setLms(0);
|
- |
|
| 1706 |
bpt.setLmtd(0);
|
- |
|
| 1707 |
bpt.setMtd(0);
|
- |
|
| 1708 |
bpt.setMtdQty(0);
|
- |
|
| 1709 |
bpt.setLmtd(0);
|
- |
|
| 1710 |
bpt.setLmtdQty(0);
|
- |
|
| 1711 |
partnersBrandSaleMap.put(un.getBrand(), bpt);
|
- |
|
| 1712 |
}
|
- |
|
| 1713 |
}
|
- |
|
| 1714 |
accessoriesBrandSales = fofoStoreRepository
|
- |
|
| 1715 |
.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
|
- |
|
| 1716 |
Set<CustomRetailer> positionRetailers = fofoIds.stream()
|
1685 |
Set<CustomRetailer> positionRetailers = fofoIds.stream()
|
| 1717 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
1686 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
| 1718 |
.collect(Collectors.toSet());
|
1687 |
.collect(Collectors.toSet());
|
| 1719 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
1688 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
| 1720 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
1689 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
| Line 1756... |
Line 1725... |
| 1756 |
if (menuIds.size() > 0) {
|
1725 |
if (menuIds.size() > 0) {
|
| 1757 |
menus = menuRepository.selectAllByIds(menuIds);
|
1726 |
menus = menuRepository.selectAllByIds(menuIds);
|
| 1758 |
}
|
1727 |
}
|
| 1759 |
}
|
1728 |
}
|
| 1760 |
}
|
1729 |
}
|
| - |
|
1730 |
|
| - |
|
1731 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
| - |
|
1732 |
.getFofoRetailers(fofoIds.stream().map(x -> x).collect(Collectors.toList()));
|
| - |
|
1733 |
|
| 1761 |
model.addAttribute("authId", authUser.getId());
|
1734 |
model.addAttribute("authId", authUser.getId());
|
| 1762 |
|
1735 |
|
| 1763 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
1736 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
| 1764 |
|
1737 |
|
| 1765 |
model.addAttribute("reporticoDate", rctSaholic);
|
1738 |
model.addAttribute("reporticoDate", rctSaholic);
|
| 1766 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
1739 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
| 1767 |
model.addAttribute("warehouseMap", wm);
|
1740 |
model.addAttribute("warehouseMap", wm);
|
| - |
|
1741 |
model.addAttribute("customRetailersMap", customRetailerMap);
|
| - |
|
1742 |
model.addAttribute("fofoIds", fofoIds);
|
| 1768 |
|
1743 |
|
| 1769 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
1744 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
| 1770 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
1745 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
| 1771 |
model.addAttribute("brandSalesMap", partnersBrandSaleMap);
|
1746 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1772 |
|
1747 |
|
| 1773 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
1748 |
model.addAttribute("date", curDate.withDayOfMonth(1).minusMonths(6).toLocalDate());
|
| 1774 |
|
1749 |
|
| 1775 |
} catch (ProfitMandiBusinessException e) {
|
1750 |
} catch (ProfitMandiBusinessException e) {
|
| 1776 |
}
|
1751 |
}
|
| 1777 |
List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
|
1752 |
List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
|
| 1778 |
LOGGER.info("menu" + menuList);
|
1753 |
LOGGER.info("menu" + menuList);
|
| Line 2598... |
Line 2573... |
| 2598 |
model.addAttribute("customRetailer", customRetailer);
|
2573 |
model.addAttribute("customRetailer", customRetailer);
|
| 2599 |
|
2574 |
|
| 2600 |
return "partner-secondary-order";
|
2575 |
return "partner-secondary-order";
|
| 2601 |
}
|
2576 |
}
|
| 2602 |
|
2577 |
|
| - |
|
2578 |
@RequestMapping(value = "/getMobileBrandWise", method = RequestMethod.GET)
|
| - |
|
2579 |
public String getMobileBrandWise(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
2580 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
2581 |
String email = loginDetails.getEmailId();
|
| - |
|
2582 |
|
| - |
|
2583 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
2584 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
2585 |
|
| - |
|
2586 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| - |
|
2587 |
if (emails.contains(authUser.getEmailId())) {
|
| - |
|
2588 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| - |
|
2589 |
LOGGER.info("fofoIds" + fofoIds);
|
| - |
|
2590 |
}
|
| - |
|
2591 |
|
| - |
|
2592 |
Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
|
| - |
|
2593 |
partnersBrandSaleMap = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds))
|
| - |
|
2594 |
.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
| - |
|
2595 |
|
| - |
|
2596 |
List<BrandWiseUnbilledActivateStockModel> unbilledActivatedStock = fofoStoreRepository
|
| - |
|
2597 |
.selectUnbilledActivateStockGroupByBrand(new ArrayList<>(fofoIds));
|
| - |
|
2598 |
for (BrandWiseUnbilledActivateStockModel un : unbilledActivatedStock) {
|
| - |
|
2599 |
BrandWisePartnerSaleModel bpt = partnersBrandSaleMap.get(un.getBrand());
|
| - |
|
2600 |
if (bpt != null) {
|
| - |
|
2601 |
bpt.setAmtd(un.getUnbilledMtd());
|
| - |
|
2602 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
| - |
|
2603 |
} else {
|
| - |
|
2604 |
bpt = new BrandWisePartnerSaleModel();
|
| - |
|
2605 |
bpt.setBrand(un.getBrand());
|
| - |
|
2606 |
bpt.setAmtd(un.getUnbilledMtd());
|
| - |
|
2607 |
bpt.setUamtdQty(un.getUnbilledMTDQty());
|
| - |
|
2608 |
bpt.setLms(0);
|
| - |
|
2609 |
bpt.setLmtd(0);
|
| - |
|
2610 |
bpt.setMtd(0);
|
| - |
|
2611 |
bpt.setMtdQty(0);
|
| - |
|
2612 |
bpt.setLmtd(0);
|
| - |
|
2613 |
bpt.setLmtdQty(0);
|
| - |
|
2614 |
partnersBrandSaleMap.put(un.getBrand(), bpt);
|
| - |
|
2615 |
}
|
| - |
|
2616 |
}
|
| - |
|
2617 |
|
| - |
|
2618 |
model.addAttribute("brandSalesMap", partnersBrandSaleMap);
|
| - |
|
2619 |
|
| - |
|
2620 |
return "mobile-brand-wise-report";
|
| - |
|
2621 |
}
|
| - |
|
2622 |
|
| - |
|
2623 |
@RequestMapping(value = "/getAccessoriesBrandWise", method = RequestMethod.GET)
|
| - |
|
2624 |
public String getAccessoriesBrandWise(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
2625 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
2626 |
String email = loginDetails.getEmailId();
|
| - |
|
2627 |
|
| - |
|
2628 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
2629 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
2630 |
|
| - |
|
2631 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| - |
|
2632 |
if (emails.contains(authUser.getEmailId())) {
|
| - |
|
2633 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| - |
|
2634 |
LOGGER.info("fofoIds" + fofoIds);
|
| - |
|
2635 |
}
|
| - |
|
2636 |
|
| - |
|
2637 |
List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
|
| - |
|
2638 |
|
| - |
|
2639 |
accessoriesBrandSales = fofoStoreRepository
|
| - |
|
2640 |
.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
|
| - |
|
2641 |
|
| - |
|
2642 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
| - |
|
2643 |
return "accessories-brand-wise-report";
|
| - |
|
2644 |
}
|
| - |
|
2645 |
|
| - |
|
2646 |
@RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
|
| - |
|
2647 |
public String getMobileLMSGraph(HttpServletRequest request, @RequestParam int warehouseId,
|
| - |
|
2648 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
| - |
|
2649 |
throws Exception {
|
| - |
|
2650 |
|
| - |
|
2651 |
if (date == null) {
|
| - |
|
2652 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
2653 |
|
| - |
|
2654 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| - |
|
2655 |
date = startOfMonth.toLocalDate();
|
| - |
|
2656 |
}
|
| - |
|
2657 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
| - |
|
2658 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
| - |
|
2659 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
| - |
|
2660 |
|
| - |
|
2661 |
ChartModel cm;
|
| - |
|
2662 |
if (warehouseId != 0) {
|
| - |
|
2663 |
cm = this.getBrandWiseLms(Arrays.asList(warehouseId),
|
| - |
|
2664 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
| - |
|
2665 |
} else {
|
| - |
|
2666 |
cm = this.getBrandWiseLms(new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
| - |
|
2667 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
| - |
|
2668 |
|
| - |
|
2669 |
}
|
| - |
|
2670 |
|
| - |
|
2671 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
| - |
|
2672 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| - |
|
2673 |
return "brand-wise-mobile-lms-chart";
|
| - |
|
2674 |
}
|
| - |
|
2675 |
|
| - |
|
2676 |
private ChartModel getBrandWiseLms(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
|
| - |
|
2677 |
LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
|
| - |
|
2678 |
|
| - |
|
2679 |
List<BrandWiseModel> brandWiseLms = fofoStoreRepository.selectGroupByBrandLms(fofoIds, warehouseIds,
|
| - |
|
2680 |
startDateTime);
|
| - |
|
2681 |
LOGGER.info("brandWiseLms" + brandWiseLms);
|
| - |
|
2682 |
|
| - |
|
2683 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| - |
|
2684 |
|
| - |
|
2685 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
| - |
|
2686 |
for (BrandWiseModel bwl : brandWiseLms) {
|
| - |
|
2687 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| - |
|
2688 |
if (brandMonthValue.containsKey(bwl.getBrand())) {
|
| - |
|
2689 |
brandValue = brandMonthValue.get(bwl.getBrand());
|
| - |
|
2690 |
brandValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
| - |
|
2691 |
} else {
|
| - |
|
2692 |
|
| - |
|
2693 |
brandValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
| - |
|
2694 |
|
| - |
|
2695 |
}
|
| - |
|
2696 |
brandMonthValue.put(bwl.getBrand(), brandValue);
|
| - |
|
2697 |
|
| - |
|
2698 |
}
|
| - |
|
2699 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
2700 |
|
| - |
|
2701 |
Period age = Period.between(startDateTime, LocalDate.now());
|
| - |
|
2702 |
int months = age.getMonths();
|
| - |
|
2703 |
LOGGER.info("months" + months);
|
| - |
|
2704 |
LOGGER.info("brandWiseLms" + brandWiseLms);
|
| - |
|
2705 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| - |
|
2706 |
List<String> brands = new ArrayList<>();
|
| - |
|
2707 |
brands.add("Oppo");
|
| - |
|
2708 |
brands.add("Vivo");
|
| - |
|
2709 |
brands.add("Samsung");
|
| - |
|
2710 |
brands.add("Realme");
|
| - |
|
2711 |
brands.add("Mi");
|
| - |
|
2712 |
brands.add("Tecno");
|
| - |
|
2713 |
brands.add("Itel");
|
| - |
|
2714 |
brands.add("Lava");
|
| - |
|
2715 |
brands.add("Nokia");
|
| - |
|
2716 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| - |
|
2717 |
|
| - |
|
2718 |
for (String brand : brands) {
|
| - |
|
2719 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
| - |
|
2720 |
for (int i = months; i >= 1; i--) {
|
| - |
|
2721 |
|
| - |
|
2722 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
2723 |
|
| - |
|
2724 |
if (yearMonthValue != null) {
|
| - |
|
2725 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
| - |
|
2726 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
2727 |
}
|
| - |
|
2728 |
|
| - |
|
2729 |
} else {
|
| - |
|
2730 |
yearMonthValue = new HashMap<>();
|
| - |
|
2731 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
2732 |
}
|
| - |
|
2733 |
}
|
| - |
|
2734 |
|
| - |
|
2735 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| - |
|
2736 |
|
| - |
|
2737 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| - |
|
2738 |
|
| - |
|
2739 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| - |
|
2740 |
|
| - |
|
2741 |
}
|
| - |
|
2742 |
|
| - |
|
2743 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| - |
|
2744 |
|
| - |
|
2745 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| - |
|
2746 |
|
| - |
|
2747 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
| - |
|
2748 |
|
| - |
|
2749 |
for (int i = months; i >= 1; i--) {
|
| - |
|
2750 |
|
| - |
|
2751 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
2752 |
labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
| - |
|
2753 |
}
|
| - |
|
2754 |
|
| - |
|
2755 |
List<DatasetModel> datasets = new ArrayList<>();
|
| - |
|
2756 |
List<String> colorList = new ArrayList<>();
|
| - |
|
2757 |
colorList.add("darkgreen");
|
| - |
|
2758 |
colorList.add("dodgerblue");
|
| - |
|
2759 |
colorList.add("darkblue");
|
| - |
|
2760 |
colorList.add("gold");
|
| - |
|
2761 |
colorList.add("coral");
|
| - |
|
2762 |
colorList.add("steelblue");
|
| - |
|
2763 |
colorList.add("red");
|
| - |
|
2764 |
colorList.add("midnightblue");
|
| - |
|
2765 |
colorList.add("cornsilk");
|
| - |
|
2766 |
|
| - |
|
2767 |
List<String> borderList = new ArrayList<>();
|
| - |
|
2768 |
borderList.add("pink");
|
| - |
|
2769 |
borderList.add("mediumseagreen");
|
| - |
|
2770 |
borderList.add("lightblue");
|
| - |
|
2771 |
borderList.add("#0000cd");
|
| - |
|
2772 |
borderList.add("#f7e98e");
|
| - |
|
2773 |
|
| - |
|
2774 |
borderList.add("#ff8c69");
|
| - |
|
2775 |
|
| - |
|
2776 |
borderList.add("#0000cd");
|
| - |
|
2777 |
borderList.add("lightsalmon");
|
| - |
|
2778 |
|
| - |
|
2779 |
borderList.add("#0000cd");
|
| - |
|
2780 |
borderList.add("cornsilk");
|
| - |
|
2781 |
|
| - |
|
2782 |
int i = 0;
|
| - |
|
2783 |
|
| - |
|
2784 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
| - |
|
2785 |
|
| - |
|
2786 |
DatasetModel lmsModel = new DatasetModel();
|
| - |
|
2787 |
lmsModel.setLabel(brandValue.getKey());
|
| - |
|
2788 |
lmsModel.setBackgroundColor(colorList.get(i));
|
| - |
|
2789 |
if (brandValue.getValue().isEmpty()) {
|
| - |
|
2790 |
|
| - |
|
2791 |
lmsModel.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
|
| - |
|
2792 |
} else {
|
| - |
|
2793 |
lmsModel.setData(brandValue.getValue());
|
| - |
|
2794 |
}
|
| - |
|
2795 |
lmsModel.setType("line");
|
| - |
|
2796 |
lmsModel.setOrder(1);
|
| - |
|
2797 |
lmsModel.setFill("false");
|
| - |
|
2798 |
lmsModel.setBorderColor(borderList.get(i));
|
| - |
|
2799 |
datasets.add(lmsModel);
|
| - |
|
2800 |
|
| - |
|
2801 |
i++;
|
| - |
|
2802 |
}
|
| - |
|
2803 |
|
| - |
|
2804 |
DataModel dm = new DataModel();
|
| - |
|
2805 |
dm.setDatasets(datasets);
|
| - |
|
2806 |
dm.setLabels(labels);
|
| - |
|
2807 |
|
| - |
|
2808 |
LegendModel lm = new LegendModel();
|
| - |
|
2809 |
lm.setPosition("top");
|
| - |
|
2810 |
|
| - |
|
2811 |
Tooltips tooltips = new Tooltips();
|
| - |
|
2812 |
tooltips.setBodyFontSize(15);
|
| - |
|
2813 |
tooltips.setTitleFontSize(15);
|
| - |
|
2814 |
tooltips.setMode("index");
|
| - |
|
2815 |
tooltips.setIntersect(false);
|
| - |
|
2816 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
| - |
|
2817 |
|
| - |
|
2818 |
HoverModel hover = new HoverModel();
|
| - |
|
2819 |
hover.setIntersect(false);
|
| - |
|
2820 |
hover.setMode("index");
|
| - |
|
2821 |
|
| - |
|
2822 |
TitleModel tm = new TitleModel();
|
| - |
|
2823 |
tm.setText("Brand Wise Monthly Sale");
|
| - |
|
2824 |
tm.setDisplay(true);
|
| - |
|
2825 |
tm.setFontSize(20);
|
| - |
|
2826 |
tm.setFontColor("#111");
|
| - |
|
2827 |
|
| - |
|
2828 |
OptionsModel om = new OptionsModel();
|
| - |
|
2829 |
om.setResponsive(true);
|
| - |
|
2830 |
om.setLegend(lm);
|
| - |
|
2831 |
om.setTitle(tm);
|
| - |
|
2832 |
om.setTooltips(tooltips);
|
| - |
|
2833 |
om.setHover(hover);
|
| - |
|
2834 |
|
| - |
|
2835 |
ChartModel cm = new ChartModel();
|
| - |
|
2836 |
|
| - |
|
2837 |
cm.setType("line");
|
| - |
|
2838 |
cm.setData(dm);
|
| - |
|
2839 |
cm.setOptions(om);
|
| - |
|
2840 |
|
| - |
|
2841 |
LOGGER.info("cm" + cm);
|
| - |
|
2842 |
|
| - |
|
2843 |
return cm;
|
| - |
|
2844 |
}
|
| - |
|
2845 |
|
| 2603 |
}
|
2846 |
}
|