| Line 4... |
Line 4... |
| 4 |
import java.io.FileInputStream;
|
4 |
import java.io.FileInputStream;
|
| 5 |
import java.io.FileNotFoundException;
|
5 |
import java.io.FileNotFoundException;
|
| 6 |
import java.io.FileOutputStream;
|
6 |
import java.io.FileOutputStream;
|
| 7 |
import java.io.ObjectInputStream;
|
7 |
import java.io.ObjectInputStream;
|
| 8 |
import java.io.ObjectOutputStream;
|
8 |
import java.io.ObjectOutputStream;
|
| - |
|
9 |
import java.text.DateFormat;
|
| - |
|
10 |
import java.text.SimpleDateFormat;
|
| 9 |
import java.time.LocalDate;
|
11 |
import java.time.LocalDate;
|
| 10 |
import java.time.LocalDateTime;
|
12 |
import java.time.LocalDateTime;
|
| 11 |
import java.time.LocalTime;
|
13 |
import java.time.LocalTime;
|
| 12 |
import java.time.Month;
|
14 |
import java.time.Month;
|
| 13 |
import java.time.Period;
|
15 |
import java.time.Period;
|
| Line 15... |
Line 17... |
| 15 |
import java.time.ZoneOffset;
|
17 |
import java.time.ZoneOffset;
|
| 16 |
import java.time.format.DateTimeFormatter;
|
18 |
import java.time.format.DateTimeFormatter;
|
| 17 |
import java.util.ArrayList;
|
19 |
import java.util.ArrayList;
|
| 18 |
import java.util.Arrays;
|
20 |
import java.util.Arrays;
|
| 19 |
import java.util.Collection;
|
21 |
import java.util.Collection;
|
| - |
|
22 |
import java.util.Collections;
|
| 20 |
import java.util.Comparator;
|
23 |
import java.util.Comparator;
|
| - |
|
24 |
import java.util.Date;
|
| 21 |
import java.util.HashMap;
|
25 |
import java.util.HashMap;
|
| 22 |
import java.util.HashSet;
|
26 |
import java.util.HashSet;
|
| 23 |
import java.util.LinkedHashMap;
|
27 |
import java.util.LinkedHashMap;
|
| 24 |
import java.util.LinkedHashSet;
|
28 |
import java.util.LinkedHashSet;
|
| 25 |
import java.util.List;
|
29 |
import java.util.List;
|
| - |
|
30 |
import java.util.Locale;
|
| 26 |
import java.util.Map;
|
31 |
import java.util.Map;
|
| 27 |
import java.util.Map.Entry;
|
32 |
import java.util.Map.Entry;
|
| 28 |
import java.util.Optional;
|
33 |
import java.util.Optional;
|
| 29 |
import java.util.Set;
|
34 |
import java.util.Set;
|
| 30 |
import java.util.TreeMap;
|
35 |
import java.util.TreeMap;
|
| Line 114... |
Line 119... |
| 114 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
119 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
| 115 |
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
|
120 |
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
|
| 116 |
import com.spice.profitmandi.dao.model.MonthSaleModel;
|
121 |
import com.spice.profitmandi.dao.model.MonthSaleModel;
|
| 117 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
122 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 118 |
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
|
123 |
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
|
| - |
|
124 |
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
|
| 119 |
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
|
125 |
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
|
| 120 |
import com.spice.profitmandi.dao.model.SecondaryOrderBilledLmsModel;
|
126 |
import com.spice.profitmandi.dao.model.SecondaryOrderBilledLmsModel;
|
| 121 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
127 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 122 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
128 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 123 |
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
|
129 |
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
|
| Line 766... |
Line 772... |
| 766 |
int fofoId = loginDetails.getFofoId();
|
772 |
int fofoId = loginDetails.getFofoId();
|
| 767 |
ChartModel cm = this.getLmsLineChart(loginDetails.getFofoId());
|
773 |
ChartModel cm = this.getLmsLineChart(loginDetails.getFofoId());
|
| 768 |
|
774 |
|
| 769 |
LOGGER.info("linechartMap" + gson.toJson(cm));
|
775 |
LOGGER.info("linechartMap" + gson.toJson(cm));
|
| 770 |
model.addAttribute("linechartMap", gson.toJson(cm));
|
776 |
model.addAttribute("linechartMap", gson.toJson(cm));
|
| 771 |
|
- |
|
| 772 |
return "lmsLineChart";
|
777 |
return "lmsLineChart";
|
| 773 |
}
|
778 |
}
|
| 774 |
|
779 |
|
| 775 |
@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
|
780 |
@RequestMapping(value = "/getMonthlyPurchaseLineChart", method = RequestMethod.GET)
|
| 776 |
public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model) throws Exception {
|
781 |
public String getMonthlyPurchaseLineChart(HttpServletRequest request, Model model) throws Exception {
|
| Line 794... |
Line 799... |
| 794 |
model.addAttribute("chartMap", gson.toJson(cm));
|
799 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 795 |
|
800 |
|
| 796 |
return "bar_chart";
|
801 |
return "bar_chart";
|
| 797 |
}
|
802 |
}
|
| 798 |
|
803 |
|
| 799 |
@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
|
804 |
@RequestMapping(value = "/getMonthlyPriceDropTab", method = RequestMethod.GET)
|
| 800 |
public String getMonthlyPriceDrop(HttpServletRequest request, Model model) throws Exception {
|
805 |
public String getMonthlyPriceDrop(HttpServletRequest request, Model model) throws Exception {
|
| 801 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
806 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 802 |
int fofoId = loginDetails.getFofoId();
|
807 |
int fofoId = loginDetails.getFofoId();
|
| 803 |
ChartModel cm = this.getMonthlyPriceDrop(fofoId);
|
808 |
ChartModel cm = this.getMonthlyPriceDrop(fofoId);
|
| 804 |
|
809 |
|
| Line 806... |
Line 811... |
| 806 |
model.addAttribute("chartMap", gson.toJson(cm));
|
811 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 807 |
|
812 |
|
| 808 |
return "price_drop_chart";
|
813 |
return "price_drop_chart";
|
| 809 |
}
|
814 |
}
|
| 810 |
|
815 |
|
| - |
|
816 |
@RequestMapping(value = "/getPriceDropDetails", method = RequestMethod.GET)
|
| - |
|
817 |
public String getPriceDropDetails(HttpServletRequest request,
|
| - |
|
818 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
| - |
|
819 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
| - |
|
820 |
@RequestParam(name = "yearMonth", required = true, defaultValue = "0") String yearMonth, Model model)
|
| - |
|
821 |
throws Exception {
|
| - |
|
822 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
823 |
|
| - |
|
824 |
LOGGER.info("params" + fofoId + brand + yearMonth);
|
| - |
|
825 |
|
| - |
|
826 |
List<PriceDropWithDetailsByYearMonthModel> priceDropdetailsList = priceDropRepository
|
| - |
|
827 |
.selectBrandPendingPriceDropWithDetailsByYearMonth(fofoId, brand, yearMonth);
|
| - |
|
828 |
|
| - |
|
829 |
LOGGER.info("priceDropdetailsList" + priceDropdetailsList);
|
| - |
|
830 |
|
| - |
|
831 |
model.addAttribute("priceDropdetailsList", priceDropdetailsList);
|
| - |
|
832 |
|
| - |
|
833 |
return "price-drop-details";
|
| - |
|
834 |
}
|
| - |
|
835 |
|
| - |
|
836 |
@RequestMapping(value = "/getMonthlyPriceDrop", method = RequestMethod.GET)
|
| - |
|
837 |
public String getMonthlyPriceDropTabular(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
838 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
839 |
int fofoId = loginDetails.getFofoId();
|
| - |
|
840 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
841 |
|
| - |
|
842 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| - |
|
843 |
|
| - |
|
844 |
List<YearMonth> ym = new ArrayList<YearMonth>();
|
| - |
|
845 |
|
| - |
|
846 |
for (int i = 1; i <= 6; i++) {
|
| - |
|
847 |
ym.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
|
| - |
|
848 |
}
|
| - |
|
849 |
Collections.reverse(ym);
|
| - |
|
850 |
model.addAttribute("ym", ym);
|
| - |
|
851 |
LOGGER.info("ym" + ym);
|
| - |
|
852 |
|
| - |
|
853 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
| - |
|
854 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
| - |
|
855 |
|
| - |
|
856 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| - |
|
857 |
|
| - |
|
858 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
| - |
|
859 |
LOGGER.info("priceDropYearMonthModels" + priceDropYearMonthModels);
|
| - |
|
860 |
for (PriceDropYearMonthModel pdm : priceDropYearMonthModels) {
|
| - |
|
861 |
|
| - |
|
862 |
Map<YearMonth, Double> brandValue = new HashMap<>();
|
| - |
|
863 |
if (brandMonthValue.containsKey(pdm.getBrand())) {
|
| - |
|
864 |
brandValue = brandMonthValue.get(pdm.getBrand());
|
| - |
|
865 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
| - |
|
866 |
} else {
|
| - |
|
867 |
|
| - |
|
868 |
brandValue.put(YearMonth.parse(pdm.getYearMonth(), dateTimeFormatter), (double) pdm.getAmount());
|
| - |
|
869 |
|
| - |
|
870 |
}
|
| - |
|
871 |
brandMonthValue.put(pdm.getBrand(), brandValue);
|
| - |
|
872 |
}
|
| - |
|
873 |
List<String> brands = new ArrayList<>();
|
| - |
|
874 |
brands.add("Accessories");
|
| - |
|
875 |
brands.add("Oppo");
|
| - |
|
876 |
brands.add("Vivo");
|
| - |
|
877 |
brands.add("Samsung");
|
| - |
|
878 |
brands.add("Realme");
|
| - |
|
879 |
brands.add("Mi");
|
| - |
|
880 |
brands.add("Tecno");
|
| - |
|
881 |
brands.add("Itel");
|
| - |
|
882 |
brands.add("Nokia");
|
| - |
|
883 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| - |
|
884 |
|
| - |
|
885 |
for (String brand : brands) {
|
| - |
|
886 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
| - |
|
887 |
for (int i = 6; i >= 1; i--) {
|
| - |
|
888 |
|
| - |
|
889 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
890 |
|
| - |
|
891 |
if (yearMonthValue != null) {
|
| - |
|
892 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
| - |
|
893 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
894 |
}
|
| - |
|
895 |
|
| - |
|
896 |
} else {
|
| - |
|
897 |
yearMonthValue = new HashMap<>();
|
| - |
|
898 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
| - |
|
899 |
}
|
| - |
|
900 |
}
|
| - |
|
901 |
|
| - |
|
902 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| - |
|
903 |
|
| - |
|
904 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| - |
|
905 |
|
| - |
|
906 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| - |
|
907 |
|
| - |
|
908 |
}
|
| - |
|
909 |
|
| - |
|
910 |
Map<String, List<Double>> brandValues = new LinkedHashMap<>();
|
| - |
|
911 |
|
| - |
|
912 |
for (Entry<String, List<Double>> vv : sortedBrandValue.entrySet()) {
|
| - |
|
913 |
|
| - |
|
914 |
Double total = vv.getValue().stream().mapToDouble(x -> x.doubleValue()).sum();
|
| - |
|
915 |
|
| - |
|
916 |
if (total != 0.0) {
|
| - |
|
917 |
brandValues.put(vv.getKey(), vv.getValue());
|
| - |
|
918 |
|
| - |
|
919 |
}
|
| - |
|
920 |
|
| - |
|
921 |
LOGGER.info("total" + total);
|
| - |
|
922 |
}
|
| - |
|
923 |
|
| - |
|
924 |
LOGGER.info("sortedBrandValue" + brandValues);
|
| - |
|
925 |
model.addAttribute("fofoId", fofoId);
|
| - |
|
926 |
|
| - |
|
927 |
model.addAttribute("sortedBrandValue", brandValues);
|
| - |
|
928 |
|
| - |
|
929 |
return "price-drop-tabular";
|
| - |
|
930 |
}
|
| - |
|
931 |
|
| 811 |
private ChartModel getMonthlyPriceDrop(int fofoId) throws ProfitMandiBusinessException {
|
932 |
private ChartModel getMonthlyPriceDrop(int fofoId) throws ProfitMandiBusinessException {
|
| 812 |
|
933 |
|
| 813 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
934 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 814 |
|
935 |
|
| 815 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
936 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| Line 839... |
Line 960... |
| 839 |
brands.add("Mi");
|
960 |
brands.add("Mi");
|
| 840 |
brands.add("Tecno");
|
961 |
brands.add("Tecno");
|
| 841 |
brands.add("Itel");
|
962 |
brands.add("Itel");
|
| 842 |
|
963 |
|
| 843 |
brands.add("Nokia");
|
964 |
brands.add("Nokia");
|
| - |
|
965 |
|
| 844 |
for (int i = 6; i >= 1; i--) {
|
966 |
for (int i = 6; i >= 1; i--) {
|
| 845 |
|
967 |
|
| 846 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
968 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 847 |
|
- |
|
| 848 |
LOGGER.info("getStartMonth" + sortedMonthBrandValue.get(YearMonth.from(startMonth)));
|
969 |
LOGGER.info("getStartMonth" + sortedMonthBrandValue.get(YearMonth.from(startMonth)));
|
| 849 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
970 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
| 850 |
for (String brand : brands) {
|
971 |
for (String brand : brands) {
|
| 851 |
if (valbrand != null) {
|
972 |
if (valbrand != null) {
|
| 852 |
if (!valbrand.containsKey(brand)) {
|
973 |
if (!valbrand.containsKey(brand)) {
|
| Line 922... |
Line 1043... |
| 922 |
|
1043 |
|
| 923 |
borderList.add("#ff8c69");
|
1044 |
borderList.add("#ff8c69");
|
| 924 |
|
1045 |
|
| 925 |
borderList.add("#0000cd");
|
1046 |
borderList.add("#0000cd");
|
| 926 |
borderList.add("lightsalmon");
|
1047 |
borderList.add("lightsalmon");
|
| - |
|
1048 |
|
| 927 |
borderList.add("#0000cd");
|
1049 |
borderList.add("#0000cd");
|
| 928 |
borderList.add("cornsilk");
|
1050 |
borderList.add("cornsilk");
|
| 929 |
|
1051 |
|
| 930 |
int i = 0;
|
1052 |
int i = 0;
|
| 931 |
|
1053 |
|