| Line 809... |
Line 809... |
| 809 |
|
809 |
|
| 810 |
private ChartModel getMonthlyPriceDrop(int fofoId) throws ProfitMandiBusinessException {
|
810 |
private ChartModel getMonthlyPriceDrop(int fofoId) throws ProfitMandiBusinessException {
|
| 811 |
|
811 |
|
| 812 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
812 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 813 |
|
813 |
|
| 814 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(20);
|
814 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
|
| 815 |
|
815 |
|
| 816 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
816 |
List<PriceDropYearMonthModel> priceDropYearMonthModels = priceDropRepository
|
| 817 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
817 |
.selectBrandPendingPriceDropByYearMonth(fofoId, startOfMonth);
|
| 818 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
818 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
| 819 |
|
819 |
|
| 820 |
Map<YearMonth, Map<String, Double>> monthBrandValue = new HashMap<>();
|
820 |
Map<YearMonth, Map<String, Double>> monthBrandValue = new HashMap<>();
|
| 821 |
|
- |
|
| - |
|
821 |
LOGGER.info("priceDropYearMonthModels"+priceDropYearMonthModels);
|
| 822 |
for (PriceDropYearMonthModel priceDropYearMonthModel : priceDropYearMonthModels) {
|
822 |
for (PriceDropYearMonthModel priceDropYearMonthModel : priceDropYearMonthModels) {
|
| 823 |
|
823 |
|
| 824 |
Map<String, Double> brandValue = new HashMap<>();
|
824 |
Map<String, Double> brandValue = new HashMap<>();
|
| 825 |
brandValue.put(priceDropYearMonthModel.getBrand(), (double) priceDropYearMonthModel.getAmount());
|
825 |
brandValue.put(priceDropYearMonthModel.getBrand(), (double) priceDropYearMonthModel.getAmount());
|
| 826 |
monthBrandValue.put(YearMonth.parse(priceDropYearMonthModel.getYearMonth(), dateTimeFormatter), brandValue);
|
826 |
monthBrandValue.put(YearMonth.parse(priceDropYearMonthModel.getYearMonth(), dateTimeFormatter), brandValue);
|
| 827 |
}
|
827 |
}
|
| 828 |
Map<YearMonth, Map<String, Double>> sortedMonthBrandValue = new TreeMap<>(monthBrandValue);
|
828 |
Map<YearMonth, Map<String, Double>> sortedMonthBrandValue = new TreeMap<>(monthBrandValue);
|
| - |
|
829 |
|
| - |
|
830 |
LOGGER.info("sortedMonthBrandValue"+sortedMonthBrandValue);
|
| 829 |
List<String> brands = new ArrayList<>();
|
831 |
List<String> brands = new ArrayList<>();
|
| 830 |
|
832 |
|
| 831 |
brands.add("Accessories");
|
833 |
brands.add("Accessories");
|
| 832 |
brands.add("Oppo");
|
834 |
brands.add("Oppo");
|
| 833 |
brands.add("Vivo");
|
835 |
brands.add("Vivo");
|
| Line 839... |
Line 841... |
| 839 |
brands.add("Lava");
|
841 |
brands.add("Lava");
|
| 840 |
brands.add("Nokia");
|
842 |
brands.add("Nokia");
|
| 841 |
for (int i = 6; i >= 1; i--) {
|
843 |
for (int i = 6; i >= 1; i--) {
|
| 842 |
|
844 |
|
| 843 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
845 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| - |
|
846 |
|
| - |
|
847 |
LOGGER.info("getStartMonth"+sortedMonthBrandValue.get(YearMonth.from(startMonth)));
|
| 844 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
848 |
Map<String, Double> valbrand = sortedMonthBrandValue.get(YearMonth.from(startMonth));
|
| 845 |
for (String brand : brands) {
|
849 |
for (String brand : brands) {
|
| 846 |
if (valbrand != null) {
|
850 |
if (valbrand != null) {
|
| 847 |
if (!valbrand.containsKey(brand)) {
|
851 |
if (!valbrand.containsKey(brand)) {
|
| 848 |
valbrand.put(brand, 0.0);
|
852 |
valbrand.put(brand, 0.0);
|
| - |
|
853 |
}
|
| 849 |
} else {
|
854 |
else {
|
| 850 |
valbrand.put(brand, valbrand.get(brand));
|
855 |
valbrand.put(brand, valbrand.get(brand));
|
| 851 |
}
|
856 |
}
|
| 852 |
|
857 |
|
| 853 |
} else {
|
858 |
} else {
|
| 854 |
valbrand = new HashMap<String, Double>();
|
859 |
valbrand = new HashMap<String, Double>();
|