| Line 1763... |
Line 1763... |
| 1763 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
1763 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| 1764 |
if (emails.contains(authUser.getEmailId())) {
|
1764 |
if (emails.contains(authUser.getEmailId())) {
|
| 1765 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
1765 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| 1766 |
LOGGER.info("fofoIds" + fofoIds);
|
1766 |
LOGGER.info("fofoIds" + fofoIds);
|
| 1767 |
}
|
1767 |
}
|
| 1768 |
|
- |
|
| 1769 |
if(fofoIds==null) {
|
1768 |
if(fofoIds==null) {
|
| 1770 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
1769 |
List<Position> positions1 = positionRepository.selectAll(authUser.getId());
|
| 1771 |
if(positions1.stream().filter(x->x.getCategoryId()==ProfitMandiConstants.TICKET_CATEGORY_MASTER).count() > 0) {
|
1770 |
if(positions1.stream().filter(x->x.getCategoryId()==ProfitMandiConstants.TICKET_CATEGORY_MASTER).count() > 0) {
|
| 1772 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x->x.stream()).map(x->x.getPartnerId()).collect(Collectors.toSet());
|
1771 |
fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x->x.stream()).map(x->x.getPartnerId()).collect(Collectors.toSet());
|
| 1773 |
}
|
1772 |
}
|
| Line 1854... |
Line 1853... |
| 1854 |
menus = menuRepository.selectAllByIds(menuIds);
|
1853 |
menus = menuRepository.selectAllByIds(menuIds);
|
| 1855 |
}
|
1854 |
}
|
| 1856 |
}
|
1855 |
}
|
| 1857 |
}
|
1856 |
}
|
| 1858 |
|
1857 |
|
| 1859 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
- |
|
| 1860 |
.getFofoRetailers(fofoIds.stream().map(x -> x).collect(Collectors.toList()));
|
- |
|
| 1861 |
|
- |
|
| 1862 |
model.addAttribute("authId", authUser.getId());
|
1858 |
model.addAttribute("authId", authUser.getId());
|
| 1863 |
|
1859 |
|
| 1864 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
1860 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
| 1865 |
|
1861 |
|
| 1866 |
model.addAttribute("reporticoDate", rctSaholic);
|
1862 |
model.addAttribute("reporticoDate", rctSaholic);
|
| 1867 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
1863 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
| 1868 |
model.addAttribute("warehouseMap", wm);
|
1864 |
model.addAttribute("warehouseMap", wm);
|
| 1869 |
model.addAttribute("customRetailersMap", customRetailerMap);
|
- |
|
| 1870 |
model.addAttribute("fofoIds", fofoIds);
|
- |
|
| 1871 |
|
- |
|
| 1872 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
1865 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
| 1873 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
1866 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
| 1874 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
1867 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 1875 |
|
1868 |
|
| 1876 |
model.addAttribute("date", curDate.withDayOfMonth(1).minusMonths(6).toLocalDate());
|
1869 |
model.addAttribute("date", curDate.withDayOfMonth(1).minusMonths(6).toLocalDate());
|
| Line 2770... |
Line 2763... |
| 2770 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
2763 |
model.addAttribute("accessoriesBrandSales", accessoriesBrandSales);
|
| 2771 |
return "accessories-brand-wise-report";
|
2764 |
return "accessories-brand-wise-report";
|
| 2772 |
}
|
2765 |
}
|
| 2773 |
|
2766 |
|
| 2774 |
@RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
|
2767 |
@RequestMapping(value = "/getMobileLMSGraph", method = RequestMethod.GET)
|
| 2775 |
public String getMobileLMSGraph(HttpServletRequest request, @RequestParam int warehouseId,
|
2768 |
public String getMobileLMSGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
|
| 2776 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
2769 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
| 2777 |
throws Exception {
|
2770 |
throws Exception {
|
| 2778 |
|
- |
|
| 2779 |
if (date == null) {
|
- |
|
| 2780 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
- |
|
| 2781 |
|
- |
|
| 2782 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
- |
|
| 2783 |
date = startOfMonth.toLocalDate();
|
- |
|
| 2784 |
}
|
- |
|
| 2785 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
2771 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
| 2786 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
2772 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
| 2787 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
2773 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
| 2788 |
|
2774 |
|
| 2789 |
ChartModel cm;
|
2775 |
ChartModel cm;
|
| Line 2799... |
Line 2785... |
| 2799 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
2785 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
| 2800 |
model.addAttribute("chartMap", gson.toJson(cm));
|
2786 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 2801 |
return "brand-wise-mobile-lms-chart";
|
2787 |
return "brand-wise-mobile-lms-chart";
|
| 2802 |
}
|
2788 |
}
|
| 2803 |
|
2789 |
|
| - |
|
2790 |
@RequestMapping(value = "/getMobileLMSFilter", method = RequestMethod.GET)
|
| - |
|
2791 |
public String getMobileLMSFilter(HttpServletRequest request,
|
| - |
|
2792 |
@RequestParam(required = false, defaultValue = "0") int warehouseId,
|
| - |
|
2793 |
@RequestParam(required = false) LocalDate date, Model model) throws Exception {
|
| - |
|
2794 |
|
| - |
|
2795 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
2796 |
String email = loginDetails.getEmailId();
|
| - |
|
2797 |
Map<String, Object> map = this.getFilter(warehouseId, email, date);
|
| - |
|
2798 |
model.addAttribute("warehouseId", warehouseId);
|
| - |
|
2799 |
model.addAllAttributes(map);
|
| - |
|
2800 |
|
| - |
|
2801 |
return "chart-filter-lms";
|
| - |
|
2802 |
}
|
| - |
|
2803 |
|
| - |
|
2804 |
@RequestMapping(value = "/getMobileLMPFilter", method = RequestMethod.GET)
|
| - |
|
2805 |
public String getMobileLMPFilter(HttpServletRequest request,
|
| - |
|
2806 |
@RequestParam(required = false, defaultValue = "0") int warehouseId,
|
| - |
|
2807 |
@RequestParam(required = false) LocalDate date, Model model) throws Exception {
|
| - |
|
2808 |
|
| - |
|
2809 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
2810 |
String email = loginDetails.getEmailId();
|
| - |
|
2811 |
Map<String, Object> map = this.getFilter(warehouseId, email, date);
|
| - |
|
2812 |
model.addAttribute("warehouseId", warehouseId);
|
| - |
|
2813 |
model.addAllAttributes(map);
|
| - |
|
2814 |
|
| - |
|
2815 |
return "chart-filter-lmp";
|
| - |
|
2816 |
}
|
| - |
|
2817 |
|
| - |
|
2818 |
@RequestMapping(value = "/getMobileLMPGraph", method = RequestMethod.GET)
|
| - |
|
2819 |
public String getMobileLMPGraph(HttpServletRequest request, @RequestParam(required = false) int warehouseId,
|
| - |
|
2820 |
@RequestParam(required = false) LocalDate date, @RequestParam List<Integer> fofoIds, Model model)
|
| - |
|
2821 |
throws Exception {
|
| - |
|
2822 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
| - |
|
2823 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream().collect(Collectors.groupingBy(
|
| - |
|
2824 |
FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
| - |
|
2825 |
|
| - |
|
2826 |
ChartModel cm;
|
| - |
|
2827 |
if (warehouseId != 0) {
|
| - |
|
2828 |
cm = this.getBrandWiseLmp(Arrays.asList(warehouseId),
|
| - |
|
2829 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
| - |
|
2830 |
} else {
|
| - |
|
2831 |
cm = this.getBrandWiseLmp(new ArrayList<>(warehouseIdFofoIdMap.keySet()),
|
| - |
|
2832 |
fofoIds.stream().map(x -> x).collect(Collectors.toList()), date);
|
| - |
|
2833 |
|
| - |
|
2834 |
}
|
| - |
|
2835 |
|
| - |
|
2836 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
| - |
|
2837 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| - |
|
2838 |
return "brand-wise-mobile-lmp-chart";
|
| - |
|
2839 |
}
|
| - |
|
2840 |
|
| - |
|
2841 |
public Map<String, Object> getFilter(int warehouseId, String email, LocalDate date)
|
| - |
|
2842 |
throws ProfitMandiBusinessException {
|
| - |
|
2843 |
Map<String, Object> map = new HashMap<>();
|
| - |
|
2844 |
|
| - |
|
2845 |
Map<Integer, CustomRetailer> customRetailersMap = null;
|
| - |
|
2846 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
2847 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
2848 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| - |
|
2849 |
|
| - |
|
2850 |
Set<Integer> fofoIds = null;
|
| - |
|
2851 |
fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| - |
|
2852 |
if (emails.contains(authUser.getEmailId())) {
|
| - |
|
2853 |
fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
|
| - |
|
2854 |
|
| - |
|
2855 |
}
|
| - |
|
2856 |
if (warehouseId != 0) {
|
| - |
|
2857 |
|
| - |
|
2858 |
fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId)
|
| - |
|
2859 |
.stream().map(x -> x).collect(Collectors.toSet());
|
| - |
|
2860 |
|
| - |
|
2861 |
}
|
| - |
|
2862 |
if (date == null) {
|
| - |
|
2863 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
2864 |
|
| - |
|
2865 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| - |
|
2866 |
date = startOfMonth.toLocalDate();
|
| - |
|
2867 |
}
|
| - |
|
2868 |
|
| - |
|
2869 |
if (fofoIds != null) {
|
| - |
|
2870 |
customRetailersMap = retailerService
|
| - |
|
2871 |
.getFofoRetailers(fofoIds.stream().map(x -> x).collect(Collectors.toList()));
|
| - |
|
2872 |
|
| - |
|
2873 |
}
|
| - |
|
2874 |
|
| - |
|
2875 |
map.put("date", date);
|
| - |
|
2876 |
map.put("customRetailersMap", customRetailersMap);
|
| - |
|
2877 |
map.put("fofoIds", fofoIds);
|
| - |
|
2878 |
map.put("warehouseMap", warehouseMap);
|
| - |
|
2879 |
|
| - |
|
2880 |
return map;
|
| - |
|
2881 |
|
| - |
|
2882 |
}
|
| - |
|
2883 |
|
| 2804 |
private ChartModel getBrandWiseLms(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
|
2884 |
private ChartModel getBrandWiseLms(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
|
| 2805 |
LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
|
2885 |
LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
|
| 2806 |
|
2886 |
|
| 2807 |
List<BrandWiseModel> brandWiseLms = fofoStoreRepository.selectGroupByBrandLms(fofoIds, warehouseIds,
|
2887 |
List<BrandWiseModel> brandWiseLms = fofoStoreRepository.selectGroupByBrandLms(fofoIds, warehouseIds,
|
| 2808 |
startDateTime);
|
2888 |
startDateTime);
|
| Line 2843... |
Line 2923... |
| 2843 |
brands.add("Nokia");
|
2923 |
brands.add("Nokia");
|
| 2844 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
2924 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 2845 |
|
2925 |
|
| 2846 |
for (String brand : brands) {
|
2926 |
for (String brand : brands) {
|
| 2847 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
2927 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
| 2848 |
for (int i = months; i >= 1; i--) {
|
2928 |
for (int i = months; i >= 0; i--) {
|
| 2849 |
|
2929 |
|
| 2850 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
2930 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 2851 |
|
2931 |
|
| 2852 |
if (yearMonthValue != null) {
|
2932 |
if (yearMonthValue != null) {
|
| 2853 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
2933 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
| Line 2872... |
Line 2952... |
| 2872 |
|
2952 |
|
| 2873 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
2953 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| 2874 |
|
2954 |
|
| 2875 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
2955 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
| 2876 |
|
2956 |
|
| 2877 |
for (int i = months; i >= 1; i--) {
|
2957 |
for (int i = months; i >= 0; i--) {
|
| 2878 |
|
2958 |
|
| 2879 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
2959 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 2880 |
labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
2960 |
labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
| 2881 |
}
|
2961 |
}
|
| 2882 |
|
2962 |
|
| Line 2891... |
Line 2971... |
| 2891 |
colorList.add("red");
|
2971 |
colorList.add("red");
|
| 2892 |
colorList.add("midnightblue");
|
2972 |
colorList.add("midnightblue");
|
| 2893 |
colorList.add("cornsilk");
|
2973 |
colorList.add("cornsilk");
|
| 2894 |
|
2974 |
|
| 2895 |
List<String> borderList = new ArrayList<>();
|
2975 |
List<String> borderList = new ArrayList<>();
|
| 2896 |
borderList.add("pink");
|
- |
|
| 2897 |
borderList.add("mediumseagreen");
|
2976 |
borderList.add("mediumseagreen");
|
| 2898 |
borderList.add("lightblue");
|
2977 |
borderList.add("lightblue");
|
| 2899 |
borderList.add("#0000cd");
|
2978 |
borderList.add("#0000cd");
|
| 2900 |
borderList.add("#f7e98e");
|
2979 |
borderList.add("#f7e98e");
|
| 2901 |
|
2980 |
|
| Line 2912... |
Line 2991... |
| 2912 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
2991 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
| 2913 |
|
2992 |
|
| 2914 |
DatasetModel lmsModel = new DatasetModel();
|
2993 |
DatasetModel lmsModel = new DatasetModel();
|
| 2915 |
lmsModel.setLabel(brandValue.getKey());
|
2994 |
lmsModel.setLabel(brandValue.getKey());
|
| 2916 |
lmsModel.setBackgroundColor(colorList.get(i));
|
2995 |
lmsModel.setBackgroundColor(colorList.get(i));
|
| 2917 |
if (brandValue.getValue().isEmpty()) {
|
- |
|
| 2918 |
|
2996 |
|
| 2919 |
lmsModel.setData(Arrays.asList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
|
2997 |
lmsModel.setData(brandValue.getValue());
|
| - |
|
2998 |
|
| - |
|
2999 |
lmsModel.setType("line");
|
| - |
|
3000 |
lmsModel.setOrder(1);
|
| - |
|
3001 |
lmsModel.setFill("false");
|
| - |
|
3002 |
lmsModel.setBorderColor(borderList.get(i));
|
| - |
|
3003 |
datasets.add(lmsModel);
|
| - |
|
3004 |
|
| - |
|
3005 |
i++;
|
| - |
|
3006 |
}
|
| - |
|
3007 |
|
| - |
|
3008 |
DataModel dm = new DataModel();
|
| - |
|
3009 |
dm.setDatasets(datasets);
|
| - |
|
3010 |
dm.setLabels(labels);
|
| - |
|
3011 |
|
| - |
|
3012 |
LegendModel lm = new LegendModel();
|
| - |
|
3013 |
lm.setPosition("top");
|
| - |
|
3014 |
|
| - |
|
3015 |
Tooltips tooltips = new Tooltips();
|
| - |
|
3016 |
tooltips.setBodyFontSize(15);
|
| - |
|
3017 |
tooltips.setTitleFontSize(15);
|
| - |
|
3018 |
tooltips.setMode("index");
|
| - |
|
3019 |
tooltips.setIntersect(false);
|
| - |
|
3020 |
tooltips.setBackgroundColor("rgba(0, 0, 0, .5)");
|
| - |
|
3021 |
|
| - |
|
3022 |
HoverModel hover = new HoverModel();
|
| - |
|
3023 |
hover.setIntersect(false);
|
| - |
|
3024 |
hover.setMode("index");
|
| - |
|
3025 |
|
| - |
|
3026 |
TitleModel tm = new TitleModel();
|
| - |
|
3027 |
tm.setText("Brand Wise Monthly Sale");
|
| - |
|
3028 |
tm.setDisplay(true);
|
| - |
|
3029 |
tm.setFontSize(20);
|
| - |
|
3030 |
tm.setFontColor("#111");
|
| - |
|
3031 |
|
| - |
|
3032 |
OptionsModel om = new OptionsModel();
|
| - |
|
3033 |
om.setResponsive(true);
|
| - |
|
3034 |
om.setLegend(lm);
|
| - |
|
3035 |
om.setTitle(tm);
|
| - |
|
3036 |
om.setTooltips(tooltips);
|
| - |
|
3037 |
om.setHover(hover);
|
| - |
|
3038 |
|
| - |
|
3039 |
ChartModel cm = new ChartModel();
|
| - |
|
3040 |
|
| - |
|
3041 |
cm.setType("line");
|
| - |
|
3042 |
cm.setData(dm);
|
| - |
|
3043 |
cm.setOptions(om);
|
| - |
|
3044 |
|
| - |
|
3045 |
LOGGER.info("cm" + cm);
|
| - |
|
3046 |
|
| - |
|
3047 |
return cm;
|
| - |
|
3048 |
}
|
| - |
|
3049 |
|
| - |
|
3050 |
private ChartModel getBrandWiseLmp(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
|
| - |
|
3051 |
LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
|
| - |
|
3052 |
|
| - |
|
3053 |
List<BrandWiseModel> brandWiseLms = orderRepository.selectGroupByBrandLmp(fofoIds, warehouseIds, startDateTime);
|
| - |
|
3054 |
LOGGER.info("brandWiseLms" + brandWiseLms);
|
| - |
|
3055 |
|
| - |
|
3056 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| - |
|
3057 |
|
| - |
|
3058 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
| - |
|
3059 |
for (BrandWiseModel bwl : brandWiseLms) {
|
| - |
|
3060 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| - |
|
3061 |
if (brandMonthValue.containsKey(bwl.getBrand())) {
|
| - |
|
3062 |
brandValue = brandMonthValue.get(bwl.getBrand());
|
| - |
|
3063 |
brandValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
| 2920 |
} else {
|
3064 |
} else {
|
| - |
|
3065 |
|
| 2921 |
lmsModel.setData(brandValue.getValue());
|
3066 |
brandValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
| - |
|
3067 |
|
| 2922 |
}
|
3068 |
}
|
| - |
|
3069 |
brandMonthValue.put(bwl.getBrand(), brandValue);
|
| - |
|
3070 |
|
| - |
|
3071 |
}
|
| - |
|
3072 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
3073 |
|
| - |
|
3074 |
Period age = Period.between(startDateTime, LocalDate.now());
|
| - |
|
3075 |
int months = age.getMonths();
|
| - |
|
3076 |
LOGGER.info("months" + months);
|
| - |
|
3077 |
LOGGER.info("brandWiseLms" + brandWiseLms);
|
| - |
|
3078 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| - |
|
3079 |
List<String> brands = new ArrayList<>();
|
| - |
|
3080 |
brands.add("Oppo");
|
| - |
|
3081 |
brands.add("Vivo");
|
| - |
|
3082 |
brands.add("Samsung");
|
| - |
|
3083 |
brands.add("Realme");
|
| - |
|
3084 |
brands.add("Mi");
|
| - |
|
3085 |
brands.add("Tecno");
|
| - |
|
3086 |
brands.add("Itel");
|
| - |
|
3087 |
brands.add("Lava");
|
| - |
|
3088 |
brands.add("Nokia");
|
| - |
|
3089 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| - |
|
3090 |
|
| - |
|
3091 |
for (String brand : brands) {
|
| - |
|
3092 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
| - |
|
3093 |
for (int i = months; i >= 0; i--) {
|
| - |
|
3094 |
|
| - |
|
3095 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
3096 |
|
| - |
|
3097 |
if (yearMonthValue != null) {
|
| - |
|
3098 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
| - |
|
3099 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
3100 |
}
|
| - |
|
3101 |
|
| - |
|
3102 |
} else {
|
| - |
|
3103 |
yearMonthValue = new HashMap<>();
|
| - |
|
3104 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
3105 |
}
|
| - |
|
3106 |
}
|
| - |
|
3107 |
|
| - |
|
3108 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| - |
|
3109 |
|
| - |
|
3110 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| - |
|
3111 |
|
| - |
|
3112 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| - |
|
3113 |
|
| - |
|
3114 |
}
|
| - |
|
3115 |
|
| - |
|
3116 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| - |
|
3117 |
|
| - |
|
3118 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| - |
|
3119 |
|
| - |
|
3120 |
LinkedHashSet<String> labels = new LinkedHashSet<String>();
|
| - |
|
3121 |
|
| - |
|
3122 |
for (int i = months; i >= 0; i--) {
|
| - |
|
3123 |
|
| - |
|
3124 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
3125 |
labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
|
| - |
|
3126 |
}
|
| - |
|
3127 |
|
| - |
|
3128 |
List<DatasetModel> datasets = new ArrayList<>();
|
| - |
|
3129 |
List<String> colorList = new ArrayList<>();
|
| - |
|
3130 |
colorList.add("darkgreen");
|
| - |
|
3131 |
colorList.add("dodgerblue");
|
| - |
|
3132 |
colorList.add("darkblue");
|
| - |
|
3133 |
colorList.add("gold");
|
| - |
|
3134 |
colorList.add("coral");
|
| - |
|
3135 |
colorList.add("steelblue");
|
| - |
|
3136 |
colorList.add("red");
|
| - |
|
3137 |
colorList.add("midnightblue");
|
| - |
|
3138 |
colorList.add("cornsilk");
|
| - |
|
3139 |
|
| - |
|
3140 |
List<String> borderList = new ArrayList<>();
|
| - |
|
3141 |
borderList.add("mediumseagreen");
|
| - |
|
3142 |
borderList.add("lightblue");
|
| - |
|
3143 |
borderList.add("#0000cd");
|
| - |
|
3144 |
borderList.add("#f7e98e");
|
| - |
|
3145 |
|
| - |
|
3146 |
borderList.add("#ff8c69");
|
| - |
|
3147 |
|
| - |
|
3148 |
borderList.add("#0000cd");
|
| - |
|
3149 |
borderList.add("lightsalmon");
|
| - |
|
3150 |
|
| - |
|
3151 |
borderList.add("#0000cd");
|
| - |
|
3152 |
borderList.add("cornsilk");
|
| - |
|
3153 |
|
| - |
|
3154 |
int i = 0;
|
| - |
|
3155 |
|
| - |
|
3156 |
for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
|
| - |
|
3157 |
|
| - |
|
3158 |
DatasetModel lmsModel = new DatasetModel();
|
| - |
|
3159 |
lmsModel.setLabel(brandValue.getKey());
|
| - |
|
3160 |
lmsModel.setBackgroundColor(colorList.get(i));
|
| - |
|
3161 |
|
| - |
|
3162 |
lmsModel.setData(brandValue.getValue());
|
| - |
|
3163 |
|
| 2923 |
lmsModel.setType("line");
|
3164 |
lmsModel.setType("line");
|
| 2924 |
lmsModel.setOrder(1);
|
3165 |
lmsModel.setOrder(1);
|
| 2925 |
lmsModel.setFill("false");
|
3166 |
lmsModel.setFill("false");
|
| 2926 |
lmsModel.setBorderColor(borderList.get(i));
|
3167 |
lmsModel.setBorderColor(borderList.get(i));
|
| 2927 |
datasets.add(lmsModel);
|
3168 |
datasets.add(lmsModel);
|
| Line 2946... |
Line 3187... |
| 2946 |
HoverModel hover = new HoverModel();
|
3187 |
HoverModel hover = new HoverModel();
|
| 2947 |
hover.setIntersect(false);
|
3188 |
hover.setIntersect(false);
|
| 2948 |
hover.setMode("index");
|
3189 |
hover.setMode("index");
|
| 2949 |
|
3190 |
|
| 2950 |
TitleModel tm = new TitleModel();
|
3191 |
TitleModel tm = new TitleModel();
|
| 2951 |
tm.setText("Brand Wise Monthly Sale");
|
3192 |
tm.setText("Brand Wise Monthly Purchase");
|
| 2952 |
tm.setDisplay(true);
|
3193 |
tm.setDisplay(true);
|
| 2953 |
tm.setFontSize(20);
|
3194 |
tm.setFontSize(20);
|
| 2954 |
tm.setFontColor("#111");
|
3195 |
tm.setFontColor("#111");
|
| 2955 |
|
3196 |
|
| 2956 |
OptionsModel om = new OptionsModel();
|
3197 |
OptionsModel om = new OptionsModel();
|