| 28468 |
tejbeer |
1 |
package com.spice.profitmandi.service;
|
|
|
2 |
|
|
|
3 |
import com.google.gson.Gson;
|
|
|
4 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
|
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30250 |
amit.gupta |
6 |
import com.spice.profitmandi.common.model.*;
|
| 28468 |
tejbeer |
7 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 33087 |
amit.gupta |
8 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
| 28468 |
tejbeer |
9 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
|
|
10 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
|
|
11 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
|
|
12 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
|
|
13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
|
|
14 |
import com.spice.profitmandi.dao.model.BrandWiseModel;
|
|
|
15 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
|
|
16 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
|
|
17 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
|
|
18 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 30250 |
amit.gupta |
19 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 28468 |
tejbeer |
20 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 33087 |
amit.gupta |
21 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 28468 |
tejbeer |
22 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 30250 |
amit.gupta |
23 |
import org.apache.logging.log4j.LogManager;
|
|
|
24 |
import org.apache.logging.log4j.Logger;
|
|
|
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 35595 |
amit |
26 |
import org.springframework.cache.annotation.Cacheable;
|
| 30250 |
amit.gupta |
27 |
import org.springframework.stereotype.Component;
|
| 28468 |
tejbeer |
28 |
|
| 30250 |
amit.gupta |
29 |
import java.time.*;
|
|
|
30 |
import java.time.format.DateTimeFormatter;
|
|
|
31 |
import java.util.*;
|
|
|
32 |
import java.util.Map.Entry;
|
|
|
33 |
import java.util.stream.Collectors;
|
|
|
34 |
|
| 28468 |
tejbeer |
35 |
@Component
|
|
|
36 |
public class FofoUser {
|
|
|
37 |
|
| 31884 |
tejbeer |
38 |
@Autowired
|
|
|
39 |
private Gson gson;
|
| 28468 |
tejbeer |
40 |
|
| 31884 |
tejbeer |
41 |
@Autowired
|
|
|
42 |
private PartnerInvestmentService partnerInvestmentService;
|
| 28468 |
tejbeer |
43 |
|
| 31884 |
tejbeer |
44 |
@Autowired
|
|
|
45 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 28468 |
tejbeer |
46 |
|
| 31884 |
tejbeer |
47 |
@Autowired
|
|
|
48 |
ChartService chartService;
|
| 28468 |
tejbeer |
49 |
|
| 31884 |
tejbeer |
50 |
@Autowired
|
|
|
51 |
FofoOrderItemRepository fofoOrderItemRepository;
|
| 28468 |
tejbeer |
52 |
|
| 31884 |
tejbeer |
53 |
@Autowired
|
|
|
54 |
FofoOrderRepository fofoOrderRepository;
|
| 28468 |
tejbeer |
55 |
|
| 31884 |
tejbeer |
56 |
@Autowired
|
|
|
57 |
PartnerTypeChangeService partnerTypeChangeService;
|
| 28468 |
tejbeer |
58 |
|
| 31884 |
tejbeer |
59 |
@Autowired
|
|
|
60 |
PartnerTargetRepository partnerTargetRepository;
|
| 28468 |
tejbeer |
61 |
|
| 31884 |
tejbeer |
62 |
@Autowired
|
|
|
63 |
InventoryService inventoryService;
|
| 28468 |
tejbeer |
64 |
|
| 31884 |
tejbeer |
65 |
@Autowired
|
|
|
66 |
private Mongo mongoClient;
|
| 28468 |
tejbeer |
67 |
|
| 31884 |
tejbeer |
68 |
@Autowired
|
|
|
69 |
private OrderRepository orderRepository;
|
| 28468 |
tejbeer |
70 |
|
| 31884 |
tejbeer |
71 |
@Autowired
|
|
|
72 |
DocumentRepository documentRepository;
|
| 28468 |
tejbeer |
73 |
|
| 31884 |
tejbeer |
74 |
@Autowired
|
| 33087 |
amit.gupta |
75 |
BrandsService brandsService;
|
|
|
76 |
|
|
|
77 |
@Autowired
|
| 31884 |
tejbeer |
78 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 28468 |
tejbeer |
79 |
|
| 31884 |
tejbeer |
80 |
private static final Logger LOGGER = LogManager.getLogger(FofoUser.class);
|
| 28468 |
tejbeer |
81 |
|
| 31884 |
tejbeer |
82 |
List<String> colorList = Arrays.asList("papayawhip", "mediumseagreen", "dodgerblue", "darkblue", "gold", "#eb0029", "coral", "steelblue", "red", "deeppink", "midnightblue", "cornsilk");
|
| 28468 |
tejbeer |
83 |
|
| 31884 |
tejbeer |
84 |
List<String> borderList = Arrays.asList("pink", "lawngreen", "lightblue", "#0000cd", "#f7e98e", "#eb0029", "lightcoral", "#0000cd", "lightsalmon", "pink", "#0000cd", "cornsilk");
|
| 28468 |
tejbeer |
85 |
|
| 31884 |
tejbeer |
86 |
List<String> brands = Arrays.asList("Accessories", "Oppo", "Vivo", "Samsung", "Realme", "Xiaomi", "OnePlus", "Tecno", "Itel", "Lava", "Nokia");
|
| 28468 |
tejbeer |
87 |
|
| 31884 |
tejbeer |
88 |
public String format(long value) {
|
| 28468 |
tejbeer |
89 |
|
| 35285 |
aman |
90 |
if (value >= 1000 && value < 100000) {
|
|
|
91 |
double lakhs = value / 100000.0;
|
|
|
92 |
double truncated = Math.floor(lakhs * 100) / 100.0;
|
|
|
93 |
return String.format("%.2f L", truncated);
|
|
|
94 |
}
|
|
|
95 |
|
| 31884 |
tejbeer |
96 |
if (value >= 100000 && value < 10000000) {
|
| 35285 |
aman |
97 |
double lakhs = value / 100000.0;
|
|
|
98 |
double truncated = Math.floor(lakhs * 100) / 100.0;
|
|
|
99 |
return String.format("%.2f L", truncated);
|
| 31884 |
tejbeer |
100 |
}
|
| 28468 |
tejbeer |
101 |
|
| 35285 |
aman |
102 |
if (value >= 10000000) {
|
|
|
103 |
double crores = value / 10000000.0;
|
|
|
104 |
double truncated = Math.floor(crores * 100) / 100.0;
|
|
|
105 |
return String.format("%.2f Cr", truncated);
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
return String.valueOf(value);
|
| 31884 |
tejbeer |
109 |
}
|
| 28468 |
tejbeer |
110 |
|
| 35285 |
aman |
111 |
|
| 35600 |
amit |
112 |
@Cacheable(value = "brandStockPrices", cacheManager = "redisVeryShortCacheManager")
|
| 31884 |
tejbeer |
113 |
public List<BrandStockPrice> getBrandStockPrices(int fofoId, boolean allBrands) throws Exception {
|
|
|
114 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
|
|
115 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 33127 |
amit.gupta |
116 |
List<BrandCatalog> mobileBrands = brandsService.getBrandsToDisplay(3);
|
| 31884 |
tejbeer |
117 |
mobileBrands.stream().forEach(x -> {
|
| 33087 |
amit.gupta |
118 |
if (brandStockPricesMap.containsKey(x.getName())) {
|
|
|
119 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(x.getName());
|
| 33119 |
amit.gupta |
120 |
brandStockPrice.setBrandUrl(x.getLogoUrl());
|
| 33087 |
amit.gupta |
121 |
brandStockPrice.setRank(x.getBrandCategory().getRank());
|
| 31884 |
tejbeer |
122 |
brandStockPrices.add(brandStockPrice);
|
|
|
123 |
}
|
|
|
124 |
});
|
| 28468 |
tejbeer |
125 |
|
| 31884 |
tejbeer |
126 |
if (allBrands) {
|
|
|
127 |
return brandStockPrices.stream().sorted(Comparator.comparingInt(BrandStockPrice::getRank)).collect(Collectors.toList());
|
| 28468 |
tejbeer |
128 |
|
| 31884 |
tejbeer |
129 |
}
|
| 28468 |
tejbeer |
130 |
|
| 31884 |
tejbeer |
131 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted(Comparator.comparingInt(BrandStockPrice::getRank)).collect(Collectors.toList());
|
|
|
132 |
}
|
| 28468 |
tejbeer |
133 |
|
| 35600 |
amit |
134 |
@Cacheable(value = "partnerInvestments", cacheManager = "redisVeryShortCacheManager")
|
| 31884 |
tejbeer |
135 |
public Map<String, Object> getInvestments(int fofoId) throws Exception {
|
|
|
136 |
Map<String, Object> investments = new LinkedHashMap<>();
|
|
|
137 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
|
|
138 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
|
|
139 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
140 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
141 |
if (yesterdayInvestment == null) {
|
|
|
142 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
143 |
}
|
| 28468 |
tejbeer |
144 |
|
| 31884 |
tejbeer |
145 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId, currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
| 34527 |
tejus.loha |
146 |
boolean isInvestmentOk = partnerInvestmentService.isInvestmentOk(fofoId, ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE, ProfitMandiConstants.CUTOFF_INVESTMENT);
|
| 28468 |
tejbeer |
147 |
|
| 35848 |
amit |
148 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= ProfitMandiConstants.OK_INVESTMENT_SHORT_PERCENTAGE).collect(Collectors.counting());
|
| 34527 |
tejus.loha |
149 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 35848 |
amit |
150 |
investments.put("today", investment.getOwnInvestment());
|
| 34527 |
tejus.loha |
151 |
investments.put("partnerType", partnerType);
|
| 31884 |
tejbeer |
152 |
investments.put("investment", investment);
|
| 34527 |
tejus.loha |
153 |
investments.put("minimumInvestment", investment.getMinInvestment());
|
| 35848 |
amit |
154 |
investments.put("totalInvestment", investment.getOwnInvestment());
|
| 34527 |
tejus.loha |
155 |
investments.put("isInvestmentOk", isInvestmentOk);
|
| 31884 |
tejbeer |
156 |
investments.put("inStock", investment.getInStockAmount());
|
|
|
157 |
investments.put("minimum", investment.getMinInvestmentString());
|
|
|
158 |
investments.put("short", investment.getShortPercentage());
|
|
|
159 |
investments.put("activated_stock", investment.getActivatedStockAmount());
|
|
|
160 |
investments.put("okDays", okInvestmentDays);
|
| 34527 |
tejus.loha |
161 |
investments.put("cutOf", 100-ProfitMandiConstants.CUTOFF_INVESTMENT);
|
|
|
162 |
investments.put("minInvestment", 100-ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE);
|
| 31884 |
tejbeer |
163 |
return investments;
|
|
|
164 |
}
|
| 28468 |
tejbeer |
165 |
|
| 31884 |
tejbeer |
166 |
public Map<String, Object> getInvestmentsMonths(int fofoId, int month) throws Exception {
|
|
|
167 |
Map<String, Object> investments = new LinkedHashMap<>();
|
|
|
168 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
|
|
169 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1).minusMonths(month);
|
| 28468 |
tejbeer |
170 |
|
| 31884 |
tejbeer |
171 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
172 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
173 |
if (yesterdayInvestment == null) {
|
|
|
174 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
175 |
}
|
| 28468 |
tejbeer |
176 |
|
| 31884 |
tejbeer |
177 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId, currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
| 28468 |
tejbeer |
178 |
|
| 35848 |
amit |
179 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= ProfitMandiConstants.OK_INVESTMENT_SHORT_PERCENTAGE).collect(Collectors.counting());
|
|
|
180 |
investments.put("today", investment.getOwnInvestment());
|
| 31884 |
tejbeer |
181 |
investments.put("investment", investment);
|
|
|
182 |
investments.put("inStock", investment.getInStockAmount());
|
|
|
183 |
investments.put("minimum", investment.getMinInvestmentString());
|
|
|
184 |
investments.put("short", investment.getShortPercentage());
|
|
|
185 |
investments.put("activated_stock", investment.getActivatedStockAmount());
|
|
|
186 |
investments.put("okDays", okInvestmentDays);
|
|
|
187 |
return investments;
|
|
|
188 |
}
|
| 28468 |
tejbeer |
189 |
|
| 31884 |
tejbeer |
190 |
public ChartModel getLmsLineChart(int fofoId) throws ProfitMandiBusinessException {
|
| 28468 |
tejbeer |
191 |
|
| 31884 |
tejbeer |
192 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
193 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
|
|
194 |
Map<YearMonth, Map<String, Double>> monthValueMap = new HashMap<>();
|
| 28468 |
tejbeer |
195 |
|
| 31884 |
tejbeer |
196 |
Map<String, Double> lmsBrandWiseSale = null;
|
| 28468 |
tejbeer |
197 |
|
| 31884 |
tejbeer |
198 |
for (int i = 0; i <= 6; i++) {
|
| 28530 |
tejbeer |
199 |
|
| 31884 |
tejbeer |
200 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 28468 |
tejbeer |
201 |
|
| 31884 |
tejbeer |
202 |
LOGGER.info("startOfMonth" + startOfMonth);
|
| 28468 |
tejbeer |
203 |
|
| 31884 |
tejbeer |
204 |
lmsBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(
|
|
|
205 |
curDate.withDayOfMonth(1).minusMonths(i), curDate.withDayOfMonth(1).minusMonths(i - 1), fofoId);
|
| 28468 |
tejbeer |
206 |
|
| 31884 |
tejbeer |
207 |
Map<Integer, Double> accesorieslmsSale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(i), curDate.withDayOfMonth(1).minusMonths(i - 1), Optional.of(false));
|
|
|
208 |
LOGGER.info("lmsBrandWiseSale" + lmsBrandWiseSale);
|
| 28468 |
tejbeer |
209 |
|
| 31884 |
tejbeer |
210 |
lmsBrandWiseSale.put("Accessories", accesorieslmsSale.get(fofoId));
|
| 28468 |
tejbeer |
211 |
|
| 31884 |
tejbeer |
212 |
monthValueMap.put(YearMonth.from(startOfMonth), lmsBrandWiseSale);
|
|
|
213 |
for (Entry<String, Double> lbw : lmsBrandWiseSale.entrySet()) {
|
|
|
214 |
Map<YearMonth, Double> yearMonthValue = new HashMap<>();
|
|
|
215 |
if (brandMonthValue.containsKey(lbw.getKey())) {
|
|
|
216 |
yearMonthValue = brandMonthValue.get(lbw.getKey());
|
|
|
217 |
yearMonthValue.put(YearMonth.from(startOfMonth), lbw.getValue());
|
|
|
218 |
} else {
|
| 28468 |
tejbeer |
219 |
|
| 31884 |
tejbeer |
220 |
yearMonthValue.put(YearMonth.from(startOfMonth), lbw.getValue());
|
| 28468 |
tejbeer |
221 |
|
| 31884 |
tejbeer |
222 |
}
|
|
|
223 |
brandMonthValue.put(lbw.getKey(), yearMonthValue);
|
| 28468 |
tejbeer |
224 |
|
| 31884 |
tejbeer |
225 |
}
|
| 28530 |
tejbeer |
226 |
|
| 31884 |
tejbeer |
227 |
}
|
| 28468 |
tejbeer |
228 |
|
| 31884 |
tejbeer |
229 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| 28468 |
tejbeer |
230 |
|
| 31884 |
tejbeer |
231 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 28468 |
tejbeer |
232 |
|
| 31884 |
tejbeer |
233 |
for (String brand : brands) {
|
|
|
234 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
|
|
235 |
for (int i = 6; i >= 0; i--) {
|
| 28468 |
tejbeer |
236 |
|
| 31884 |
tejbeer |
237 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 35942 |
amit |
238 |
LOGGER.debug("startMonth {}", startMonth);
|
| 28468 |
tejbeer |
239 |
|
| 31884 |
tejbeer |
240 |
if (yearMonthValue != null) {
|
|
|
241 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
242 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
243 |
}
|
| 28468 |
tejbeer |
244 |
|
| 31884 |
tejbeer |
245 |
} else {
|
|
|
246 |
yearMonthValue = new HashMap<>();
|
|
|
247 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
248 |
}
|
|
|
249 |
}
|
| 28468 |
tejbeer |
250 |
|
| 31884 |
tejbeer |
251 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| 28468 |
tejbeer |
252 |
|
| 31884 |
tejbeer |
253 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| 28468 |
tejbeer |
254 |
|
| 31884 |
tejbeer |
255 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| 28530 |
tejbeer |
256 |
|
| 31884 |
tejbeer |
257 |
}
|
| 28468 |
tejbeer |
258 |
|
| 31884 |
tejbeer |
259 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| 28468 |
tejbeer |
260 |
|
| 31884 |
tejbeer |
261 |
LOGGER.info("sortedBrandValue" + sortedBrandValue);
|
| 28468 |
tejbeer |
262 |
|
| 31884 |
tejbeer |
263 |
ChartModel cm = chartService.createChart(6, sortedBrandValue, colorList, borderList, "Brand Wise LMS");
|
| 28468 |
tejbeer |
264 |
|
| 31884 |
tejbeer |
265 |
return cm;
|
| 28468 |
tejbeer |
266 |
|
| 31884 |
tejbeer |
267 |
}
|
| 28530 |
tejbeer |
268 |
|
| 31884 |
tejbeer |
269 |
public ChartModel getPurchaseOrderChart(int fofoId) throws ProfitMandiBusinessException {
|
| 28530 |
tejbeer |
270 |
|
| 31884 |
tejbeer |
271 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 28468 |
tejbeer |
272 |
|
| 31884 |
tejbeer |
273 |
LOGGER.info("startMonth" + curDate.withDayOfMonth(1).minusMonths(6));
|
| 28468 |
tejbeer |
274 |
|
| 31884 |
tejbeer |
275 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(1);
|
|
|
276 |
List<BrandWiseModel> soblms = orderRepository.selectAllBilledOrderGroupByBrandFofoId(fofoId, curDate.withDayOfMonth(1).minusMonths(6));
|
|
|
277 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
|
|
|
278 |
Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
|
|
|
279 |
for (BrandWiseModel bwl : soblms) {
|
|
|
280 |
Map<YearMonth, Double> yearMonthValue = new HashMap<>();
|
|
|
281 |
if (brandMonthValue.containsKey(bwl.getBrand())) {
|
|
|
282 |
yearMonthValue = brandMonthValue.get(bwl.getBrand());
|
|
|
283 |
yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
|
|
284 |
} else {
|
| 28468 |
tejbeer |
285 |
|
| 31884 |
tejbeer |
286 |
yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
|
| 28468 |
tejbeer |
287 |
|
| 31884 |
tejbeer |
288 |
}
|
|
|
289 |
brandMonthValue.put(bwl.getBrand(), yearMonthValue);
|
| 28468 |
tejbeer |
290 |
|
| 31884 |
tejbeer |
291 |
}
|
|
|
292 |
LOGGER.info("soblms" + brandMonthValue);
|
| 28468 |
tejbeer |
293 |
|
| 31884 |
tejbeer |
294 |
Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
|
| 28468 |
tejbeer |
295 |
|
| 31884 |
tejbeer |
296 |
for (String brand : brands) {
|
|
|
297 |
Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
|
|
|
298 |
for (int i = 6; i >= 0; i--) {
|
| 28468 |
tejbeer |
299 |
|
| 31884 |
tejbeer |
300 |
LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
| 28468 |
tejbeer |
301 |
|
| 31884 |
tejbeer |
302 |
if (yearMonthValue != null) {
|
|
|
303 |
if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
|
|
|
304 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
305 |
}
|
| 28468 |
tejbeer |
306 |
|
| 31884 |
tejbeer |
307 |
} else {
|
|
|
308 |
yearMonthValue = new HashMap<>();
|
|
|
309 |
yearMonthValue.put(YearMonth.from(startMonth), 0.0);
|
|
|
310 |
}
|
|
|
311 |
}
|
| 28468 |
tejbeer |
312 |
|
| 31884 |
tejbeer |
313 |
Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
|
| 28468 |
tejbeer |
314 |
|
| 31884 |
tejbeer |
315 |
brandMonthValue.put(brand, sortedMonthBrandValue);
|
| 28530 |
tejbeer |
316 |
|
| 31884 |
tejbeer |
317 |
sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
|
| 28530 |
tejbeer |
318 |
|
| 31884 |
tejbeer |
319 |
}
|
| 28468 |
tejbeer |
320 |
|
| 31884 |
tejbeer |
321 |
LOGGER.info("brandMonthValue" + brandMonthValue);
|
| 28468 |
tejbeer |
322 |
|
| 31884 |
tejbeer |
323 |
ChartModel cm = chartService.createChart(6, sortedBrandValue, colorList, borderList, "Brand Wise Monthly Purchase");
|
| 28468 |
tejbeer |
324 |
|
| 31884 |
tejbeer |
325 |
return cm;
|
| 28468 |
tejbeer |
326 |
|
| 31884 |
tejbeer |
327 |
}
|
| 28468 |
tejbeer |
328 |
|
| 35600 |
amit |
329 |
@Cacheable(value = "partnerSales", cacheManager = "redisVeryShortCacheManager")
|
| 33245 |
ranu |
330 |
public Map<String, Object> getSales(int fofoId) throws ProfitMandiBusinessException {
|
| 28468 |
tejbeer |
331 |
|
| 31884 |
tejbeer |
332 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
|
|
333 |
LocalDateTime now = LocalDateTime.now();
|
|
|
334 |
LocalDateTime startOfToday = LocalDate.now().atStartOfDay();
|
|
|
335 |
int monthLength = LocalDate.now().lengthOfMonth();
|
|
|
336 |
int daysGone = now.getDayOfMonth() - 1;
|
|
|
337 |
int daysRemaining = monthLength - daysGone;
|
|
|
338 |
Double todaySale = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfToday, now, fofoId, false).get(fofoId);
|
|
|
339 |
Double mtdSaleTillYesterDay = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfToday.withDayOfMonth(1), startOfToday, fofoId, false).get(fofoId);
|
|
|
340 |
Double mtdSale = mtdSaleTillYesterDay + todaySale;
|
| 34685 |
aman.kumar |
341 |
// This matches exactly what getMonthsale() does
|
|
|
342 |
LocalDateTime startOfLastMonth = startOfToday.withDayOfMonth(1).minusMonths(1);
|
|
|
343 |
int currentDayOfMonth = startOfToday.getDayOfMonth();
|
|
|
344 |
int lastMonthLength = YearMonth.from(startOfLastMonth).lengthOfMonth();
|
|
|
345 |
LocalDateTime lmtdEndDate = startOfLastMonth.plusDays(Math.min(currentDayOfMonth, lastMonthLength));
|
|
|
346 |
|
| 31884 |
tejbeer |
347 |
Double lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| 34685 |
aman.kumar |
348 |
startOfLastMonth, lmtdEndDate, fofoId, false).get(fofoId);
|
| 28468 |
tejbeer |
349 |
|
| 31884 |
tejbeer |
350 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
|
|
351 |
if (partnerTargetDetails.isEmpty()) {
|
|
|
352 |
partnerTargetDetails = partnerTargetRepository.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(3));
|
|
|
353 |
}
|
| 28468 |
tejbeer |
354 |
|
| 31884 |
tejbeer |
355 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 28468 |
tejbeer |
356 |
|
| 31884 |
tejbeer |
357 |
int currentRate = 0;
|
|
|
358 |
if (mtdSaleTillYesterDay > 0) {
|
|
|
359 |
currentRate = (int) (mtdSaleTillYesterDay / daysGone);
|
|
|
360 |
}
|
| 28468 |
tejbeer |
361 |
|
| 31884 |
tejbeer |
362 |
salesMap.put("requiredType", partnerType.next());
|
|
|
363 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
|
|
364 |
int requiredRate = (int) ((reqdAmount - mtdSaleTillYesterDay) / daysRemaining);
|
|
|
365 |
if (partnerType.equals(PartnerType.PLATINUM) && requiredRate < currentRate) {
|
|
|
366 |
requiredRate = currentRate;
|
|
|
367 |
}
|
|
|
368 |
salesMap.put("requiredRate", requiredRate);
|
|
|
369 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| 28468 |
tejbeer |
370 |
|
| 31884 |
tejbeer |
371 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
|
|
372 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
|
|
373 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 28468 |
tejbeer |
374 |
|
| 31884 |
tejbeer |
375 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
|
|
376 |
salesMap.put("currentRate", currentRate);
|
|
|
377 |
salesMap.put("currentType", currentType);
|
|
|
378 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
|
|
379 |
return salesMap;
|
|
|
380 |
}
|
| 28468 |
tejbeer |
381 |
|
|
|
382 |
|
| 35595 |
amit |
383 |
@Cacheable(value = "partnerBrandChart", cacheManager = "redisShortCacheManager")
|
| 34388 |
tejus.loha |
384 |
public ChartModel getBrandChart(int fofoId, LocalDate startDate, LocalDate endDate, boolean isQuantity) {
|
| 28468 |
tejbeer |
385 |
|
| 34388 |
tejus.loha |
386 |
LocalDateTime curDate = startDate == null ? LocalDate.now().atStartOfDay().withDayOfMonth(1) : startDate.atStartOfDay();
|
|
|
387 |
LocalDateTime lastDate = endDate == null ? LocalDate.now().atStartOfDay().with(LocalTime.MAX) : endDate.atStartOfDay();
|
| 28468 |
tejbeer |
388 |
|
| 34388 |
tejus.loha |
389 |
Map<String, Double> brandWiseAllSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate, lastDate, fofoId);
|
|
|
390 |
Map<String, Long> brandWiseSaleQuantity = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate, lastDate, fofoId);
|
| 28468 |
tejbeer |
391 |
|
| 34388 |
tejus.loha |
392 |
Map<Integer, Double> accesoriesmtdsale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate, lastDate, Optional.of(false));
|
|
|
393 |
brandWiseAllSale.put("Accessories", accesoriesmtdsale.get(fofoId));
|
|
|
394 |
Map<Integer, Long> accesoriesMtdSaleQuantity = fofoOrderRepository.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId, curDate, lastDate, Optional.of(false));
|
|
|
395 |
brandWiseSaleQuantity.put("Accessories", accesoriesMtdSaleQuantity.get(fofoId));
|
|
|
396 |
List<ActivatedImeisWithSellingPrice> activatedImeisWithSellingPrices = fofoOrderRepository.selectValueOfActivatedImeis(curDate, lastDate, fofoId);
|
|
|
397 |
Map<String, Double> activatedImeisWithSellingPriceMTD = activatedImeisWithSellingPrices.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
|
|
|
398 |
Map<String, Long> activatedImeisWithSellingQuantityMTD = activatedImeisWithSellingPrices.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (long) x.getQuantity()));
|
| 28468 |
tejbeer |
399 |
|
| 34388 |
tejus.loha |
400 |
activatedImeisWithSellingPriceMTD.put("Lava", brandWiseAllSale.get("Lava"));
|
|
|
401 |
activatedImeisWithSellingQuantityMTD.put("Lava", brandWiseSaleQuantity.get("Lava"));
|
| 28468 |
tejbeer |
402 |
|
| 34388 |
tejus.loha |
403 |
//--------------------------
|
| 28468 |
tejbeer |
404 |
|
| 34388 |
tejus.loha |
405 |
Map<String, Double> LMTDBrandWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId);
|
|
|
406 |
Map<String, Long> LMTDBrandWiseSaleQuantity = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId);
|
| 28468 |
tejbeer |
407 |
|
| 34388 |
tejus.loha |
408 |
List<ActivatedImeisWithSellingPrice> LMTDActivatedImeisWithSellingPrices = fofoOrderRepository.selectValueOfActivatedImeis(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId);
|
|
|
409 |
Map<String, Double> LMTDActivatedImeisWithSellingPrice = LMTDActivatedImeisWithSellingPrices.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (double) x.getSellingPrice()));
|
|
|
410 |
Map<String, Long> LMTDActivatedImeisWithSellingQuantity = LMTDActivatedImeisWithSellingPrices.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> (long) x.getQuantity()));
|
| 28468 |
tejbeer |
411 |
|
| 34388 |
tejus.loha |
412 |
LMTDActivatedImeisWithSellingPrice.put("Lava", LMTDBrandWiseSale.get("Lava"));
|
|
|
413 |
LMTDActivatedImeisWithSellingQuantity.put("Lava", LMTDBrandWiseSaleQuantity.get("Lava"));
|
| 28468 |
tejbeer |
414 |
|
| 31884 |
tejbeer |
415 |
ChartModel cm = new ChartModel();
|
| 28468 |
tejbeer |
416 |
|
| 34388 |
tejus.loha |
417 |
List<String> brandList = Arrays.asList("Vivo", "Oppo", "Samsung", "Realme", "Xiaomi", "POCO", "Apple", "Tecno", "Lava", "Itel");
|
|
|
418 |
LinkedHashSet<String> brandAsLabel = new LinkedHashSet<>(brandList);
|
| 28468 |
tejbeer |
419 |
|
| 31884 |
tejbeer |
420 |
List<Double> mtdActivatedImeisValues = new ArrayList<>();
|
| 34388 |
tejus.loha |
421 |
List<Double> mtdValues = new ArrayList<>();
|
|
|
422 |
List<Double> mtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
423 |
List<Double> mtdActivatedImeisQuantity = new ArrayList<>();
|
|
|
424 |
List<Double> mtdQuantity = new ArrayList<>();
|
|
|
425 |
List<Double> mtdUnActivatedImeisQuantity = new ArrayList<>();
|
| 28468 |
tejbeer |
426 |
|
| 31884 |
tejbeer |
427 |
List<Double> lmtdActivatedImeisValues = new ArrayList<>();
|
|
|
428 |
List<Double> lmtdValues = new ArrayList<>();
|
| 34388 |
tejus.loha |
429 |
List<Double> lmtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
430 |
List<Double> lmtdActivatedImeisQuantity = new ArrayList<>();
|
|
|
431 |
List<Double> lmtdQuantity = new ArrayList<>();
|
|
|
432 |
List<Double> lmtdUnActivatedImeisQuantity = new ArrayList<>();
|
| 28468 |
tejbeer |
433 |
|
| 34388 |
tejus.loha |
434 |
|
|
|
435 |
for (String brand : brandList) {
|
|
|
436 |
if (isQuantity) {
|
|
|
437 |
mtdActivatedImeisQuantity.add(activatedImeisWithSellingQuantityMTD.get(brand) == null ? 0 : (double) activatedImeisWithSellingQuantityMTD.get(brand));
|
|
|
438 |
mtdQuantity.add(brandWiseSaleQuantity.get(brand) == null ? 0 : (double) brandWiseSaleQuantity.get(brand));
|
|
|
439 |
if (brandWiseSaleQuantity.get(brand) != null) {
|
|
|
440 |
mtdUnActivatedImeisQuantity.add(brandWiseSaleQuantity.get(brand) - (activatedImeisWithSellingQuantityMTD.get(brand) == null ? 0 : (double) activatedImeisWithSellingQuantityMTD.get(brand)));
|
|
|
441 |
}
|
|
|
442 |
lmtdQuantity.add(LMTDBrandWiseSaleQuantity.get(brand) == null ? 0 : (double) LMTDBrandWiseSaleQuantity.get(brand));
|
|
|
443 |
lmtdActivatedImeisQuantity.add(LMTDActivatedImeisWithSellingQuantity.get(brand) == null ? 0 : (double) LMTDActivatedImeisWithSellingQuantity.get(brand));
|
|
|
444 |
lmtdUnActivatedImeisQuantity.add(LMTDBrandWiseSaleQuantity.get(brand) == null ? 0 : LMTDBrandWiseSaleQuantity.get(brand) - (LMTDActivatedImeisWithSellingQuantity.get(brand) == null ? 0 : (double) LMTDActivatedImeisWithSellingQuantity.get(brand)));
|
| 31884 |
tejbeer |
445 |
} else {
|
| 34388 |
tejus.loha |
446 |
mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(brand) == null ? 0 : activatedImeisWithSellingPriceMTD.get(brand));
|
|
|
447 |
mtdValues.add(brandWiseAllSale.get(brand) == null ? 0 : brandWiseAllSale.get(brand));
|
|
|
448 |
if (brandWiseAllSale.get(brand) != null) {
|
|
|
449 |
mtdUnActivatedImeisValues.add(brandWiseAllSale.get(brand) - (activatedImeisWithSellingPriceMTD.get(brand) == null ? 0 : activatedImeisWithSellingPriceMTD.get(brand)));
|
|
|
450 |
}
|
|
|
451 |
lmtdValues.add(LMTDBrandWiseSale.get(brand) == null ? 0.0 : LMTDBrandWiseSale.get(brand));
|
|
|
452 |
lmtdActivatedImeisValues.add(LMTDActivatedImeisWithSellingPrice.get(brand) == null ? 0.0 : LMTDActivatedImeisWithSellingPrice.get(brand));
|
|
|
453 |
if (LMTDBrandWiseSale.get(brand) != null) {
|
|
|
454 |
lmtdUnActivatedImeisValues.add(LMTDBrandWiseSale.get(brand) - (LMTDActivatedImeisWithSellingPrice.get(brand) == null ? 0.0 : LMTDActivatedImeisWithSellingPrice.get(brand)));
|
|
|
455 |
}
|
| 31884 |
tejbeer |
456 |
}
|
|
|
457 |
}
|
| 28468 |
tejbeer |
458 |
|
| 34388 |
tejus.loha |
459 |
DatasetModel mtdActivatedImeis = new DatasetModel();
|
|
|
460 |
mtdActivatedImeis.setLabel("Total Activation");
|
|
|
461 |
mtdActivatedImeis.setBorderColor("#00008b");
|
|
|
462 |
mtdActivatedImeis.setBackgroundColor("#00008b");
|
|
|
463 |
mtdActivatedImeis.setStack("stack0");
|
|
|
464 |
mtdActivatedImeis.setOrder(0);
|
|
|
465 |
|
| 31884 |
tejbeer |
466 |
DatasetModel dsmUnactivated = new DatasetModel();
|
| 34388 |
tejus.loha |
467 |
dsmUnactivated.setLabel("Total Unactivated");
|
| 31884 |
tejbeer |
468 |
dsmUnactivated.setBackgroundColor("red");
|
|
|
469 |
dsmUnactivated.setBorderColor("red");
|
|
|
470 |
dsmUnactivated.setStack("stack0");
|
|
|
471 |
dsmUnactivated.setOrder(1);
|
| 28468 |
tejbeer |
472 |
|
| 34388 |
tejus.loha |
473 |
DatasetModel linemtdChart = new DatasetModel();
|
|
|
474 |
linemtdChart.setLabel("Total");
|
|
|
475 |
linemtdChart.setBackgroundColor("#006400");
|
|
|
476 |
linemtdChart.setBorderColor("#006400");
|
|
|
477 |
linemtdChart.setType("line");
|
|
|
478 |
linemtdChart.setOrder(2);
|
|
|
479 |
linemtdChart.setFill("false");
|
| 28468 |
tejbeer |
480 |
|
| 34388 |
tejus.loha |
481 |
DatasetModel lmtdActivatedImeis = new DatasetModel();
|
| 34466 |
tejus.loha |
482 |
lmtdActivatedImeis.setLabel("prev mth Activation");
|
| 34388 |
tejus.loha |
483 |
lmtdActivatedImeis.setBackgroundColor("#87ceeb");
|
|
|
484 |
lmtdActivatedImeis.setBorderColor("#87ceeb");
|
|
|
485 |
lmtdActivatedImeis.setStack("stack1");
|
|
|
486 |
lmtdActivatedImeis.setOrder(3);
|
| 28468 |
tejbeer |
487 |
|
|
|
488 |
|
| 31884 |
tejbeer |
489 |
DatasetModel lmtdUnActivated = new DatasetModel();
|
| 34466 |
tejus.loha |
490 |
lmtdUnActivated.setLabel("prev mth Unactivation");
|
| 31884 |
tejbeer |
491 |
lmtdUnActivated.setBackgroundColor("red");
|
|
|
492 |
lmtdUnActivated.setBorderColor("red");
|
|
|
493 |
lmtdUnActivated.setStack("stack1");
|
| 34388 |
tejus.loha |
494 |
lmtdUnActivated.setOrder(4);
|
| 28468 |
tejbeer |
495 |
|
|
|
496 |
|
| 31884 |
tejbeer |
497 |
DatasetModel lineLmtdChart = new DatasetModel();
|
| 34466 |
tejus.loha |
498 |
lineLmtdChart.setLabel("prev mth TOTAL");
|
| 31884 |
tejbeer |
499 |
lineLmtdChart.setBackgroundColor("hotpink");
|
|
|
500 |
lineLmtdChart.setBorderColor("hotpink");
|
|
|
501 |
lineLmtdChart.setType("line");
|
| 34388 |
tejus.loha |
502 |
lineLmtdChart.setOrder(5);
|
| 31884 |
tejbeer |
503 |
lineLmtdChart.setFill("false");
|
| 28468 |
tejbeer |
504 |
|
| 34388 |
tejus.loha |
505 |
if (isQuantity) {
|
|
|
506 |
mtdActivatedImeis.setData(mtdActivatedImeisQuantity);
|
|
|
507 |
dsmUnactivated.setData(mtdUnActivatedImeisQuantity);
|
|
|
508 |
linemtdChart.setData(mtdQuantity);
|
|
|
509 |
lmtdActivatedImeis.setData(lmtdActivatedImeisQuantity);
|
|
|
510 |
lmtdUnActivated.setData(lmtdUnActivatedImeisQuantity);
|
|
|
511 |
lineLmtdChart.setData(lmtdQuantity);
|
|
|
512 |
} else {
|
|
|
513 |
mtdActivatedImeis.setData(mtdActivatedImeisValues);
|
|
|
514 |
dsmUnactivated.setData(mtdUnActivatedImeisValues);
|
|
|
515 |
linemtdChart.setData(mtdValues);
|
|
|
516 |
lmtdActivatedImeis.setData(lmtdActivatedImeisValues);
|
|
|
517 |
lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
|
|
|
518 |
lineLmtdChart.setData(lmtdValues);
|
|
|
519 |
}
|
|
|
520 |
|
| 31884 |
tejbeer |
521 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
522 |
datasets.add(mtdActivatedImeis);
|
|
|
523 |
datasets.add(dsmUnactivated);
|
| 34388 |
tejus.loha |
524 |
datasets.add(linemtdChart);
|
|
|
525 |
datasets.add(lmtdActivatedImeis);
|
| 31884 |
tejbeer |
526 |
datasets.add(lmtdUnActivated);
|
|
|
527 |
datasets.add(lineLmtdChart);
|
| 28468 |
tejbeer |
528 |
|
| 31884 |
tejbeer |
529 |
DataModel dm = new DataModel();
|
|
|
530 |
dm.setDatasets(datasets);
|
| 34388 |
tejus.loha |
531 |
dm.setLabels(brandAsLabel);
|
| 31884 |
tejbeer |
532 |
Tooltips tooltips = new Tooltips();
|
| 34388 |
tejus.loha |
533 |
tooltips.setBodyFontSize(25);
|
|
|
534 |
tooltips.setTitleFontSize(25);
|
| 31884 |
tejbeer |
535 |
tooltips.setMode("index");
|
|
|
536 |
tooltips.setIntersect(false);
|
| 34388 |
tejus.loha |
537 |
tooltips.setBackgroundColor("rgba(0, 0, 0, 0.7)");
|
| 31884 |
tejbeer |
538 |
HoverModel hover = new HoverModel();
|
|
|
539 |
hover.setIntersect(false);
|
|
|
540 |
hover.setMode("index");
|
| 28468 |
tejbeer |
541 |
|
| 31884 |
tejbeer |
542 |
LegendModel lm = new LegendModel();
|
|
|
543 |
lm.setPosition("top");
|
| 28468 |
tejbeer |
544 |
|
| 31884 |
tejbeer |
545 |
TitleModel tm = new TitleModel();
|
| 34426 |
tejus.loha |
546 |
if (isQuantity) {
|
|
|
547 |
tm.setText("Brand Wise Sales Quantity");
|
|
|
548 |
} else {
|
|
|
549 |
tm.setText("Brand Wise Sales Value");
|
|
|
550 |
}
|
| 31884 |
tejbeer |
551 |
tm.setDisplay(true);
|
|
|
552 |
tm.setFontSize(20);
|
|
|
553 |
tm.setFontColor("#111");
|
| 28468 |
tejbeer |
554 |
|
| 31884 |
tejbeer |
555 |
List<Axis> xAxes = new ArrayList<>();
|
|
|
556 |
Axis xAxis = new Axis();
|
|
|
557 |
xAxis.setStacked(true);
|
|
|
558 |
xAxes.add(xAxis);
|
| 28468 |
tejbeer |
559 |
|
| 31884 |
tejbeer |
560 |
List<Axis> yAxes = new ArrayList<>();
|
|
|
561 |
Axis yAxis = new Axis();
|
|
|
562 |
yAxis.setStacked(false);
|
|
|
563 |
yAxes.add(yAxis);
|
| 28468 |
tejbeer |
564 |
|
| 31884 |
tejbeer |
565 |
ScalesModel sm = new ScalesModel();
|
|
|
566 |
sm.setxAxes(xAxes);
|
| 28468 |
tejbeer |
567 |
|
| 31884 |
tejbeer |
568 |
OptionsModel om = new OptionsModel();
|
|
|
569 |
om.setLegend(lm);
|
|
|
570 |
om.setTitle(tm);
|
|
|
571 |
om.setScales(sm);
|
|
|
572 |
om.setHover(hover);
|
|
|
573 |
om.setTooltips(tooltips);
|
| 28468 |
tejbeer |
574 |
|
| 31884 |
tejbeer |
575 |
cm.setType("bar");
|
|
|
576 |
cm.setData(dm);
|
|
|
577 |
cm.setOptions(om);
|
| 28468 |
tejbeer |
578 |
|
| 31884 |
tejbeer |
579 |
LOGGER.info("cm" + cm);
|
| 28468 |
tejbeer |
580 |
|
| 31884 |
tejbeer |
581 |
return cm;
|
| 28468 |
tejbeer |
582 |
|
| 31884 |
tejbeer |
583 |
}
|
| 28468 |
tejbeer |
584 |
|
| 31884 |
tejbeer |
585 |
public ChartInvestmentModel getInvestmentChart(int fofoId) throws ProfitMandiBusinessException {
|
|
|
586 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 28468 |
tejbeer |
587 |
|
| 31884 |
tejbeer |
588 |
Map<String, Float> investmentWalletAmount = new HashMap<>();
|
|
|
589 |
investmentWalletAmount.put("Wallet", investment.getWalletAmount());
|
|
|
590 |
investmentWalletAmount.put("InStocks", investment.getInStockAmount() - investment.getActivatedStockAmount());
|
|
|
591 |
investmentWalletAmount.put("Unbilled Order", investment.getUnbilledAmount());
|
|
|
592 |
investmentWalletAmount.put("GrnPending", investment.getGrnPendingAmount() - investment.getActivatedGrnPendingAmount());
|
|
|
593 |
investmentWalletAmount.put("ReturnInTransit", investment.getReturnInTransitAmount());
|
| 28468 |
tejbeer |
594 |
|
| 35848 |
amit |
595 |
if (investment.getUtilizedAmount() > 0) {
|
|
|
596 |
investmentWalletAmount.put("Credit Utilized", -investment.getUtilizedAmount());
|
|
|
597 |
}
|
|
|
598 |
|
| 31884 |
tejbeer |
599 |
if (investment.getShortInvestment() > 0) {
|
|
|
600 |
investmentWalletAmount.put("Short Investment", investment.getShortInvestment());
|
|
|
601 |
}
|
| 28468 |
tejbeer |
602 |
|
| 31884 |
tejbeer |
603 |
ChartInvestmentModel cm = new ChartInvestmentModel();
|
| 28468 |
tejbeer |
604 |
|
| 31884 |
tejbeer |
605 |
HashSet<String> labels = new HashSet<String>();
|
|
|
606 |
labels.addAll(investmentWalletAmount.keySet());
|
| 28468 |
tejbeer |
607 |
|
| 31884 |
tejbeer |
608 |
List<String> labelList = new ArrayList<>(labels);
|
|
|
609 |
List<String> backgroundColor = new ArrayList<>();
|
|
|
610 |
List<Float> values = new ArrayList<>();
|
|
|
611 |
for (String label : labelList) {
|
|
|
612 |
values.add(investmentWalletAmount.get(label));
|
|
|
613 |
if (label.equals("Wallet")) {
|
|
|
614 |
backgroundColor.add("pink");
|
|
|
615 |
}
|
|
|
616 |
if (label.equals("Short Investment")) {
|
|
|
617 |
backgroundColor.add("red");
|
|
|
618 |
}
|
|
|
619 |
if (label.equals("InStocks")) {
|
|
|
620 |
backgroundColor.add("#9ACD32");
|
|
|
621 |
}
|
|
|
622 |
if (label.equals("Unbilled Order")) {
|
|
|
623 |
backgroundColor.add("blue");
|
|
|
624 |
}
|
| 28468 |
tejbeer |
625 |
|
| 31884 |
tejbeer |
626 |
if (label.equals("ReturnInTransit")) {
|
|
|
627 |
backgroundColor.add("orange");
|
|
|
628 |
}
|
|
|
629 |
if (label.equals("GrnPending")) {
|
|
|
630 |
backgroundColor.add("yellow");
|
|
|
631 |
}
|
| 35848 |
amit |
632 |
if (label.equals("Credit Utilized")) {
|
|
|
633 |
backgroundColor.add("grey");
|
|
|
634 |
}
|
| 28468 |
tejbeer |
635 |
|
| 31884 |
tejbeer |
636 |
}
|
| 28468 |
tejbeer |
637 |
|
| 31884 |
tejbeer |
638 |
Data data = new Data();
|
|
|
639 |
data.setData(values);
|
|
|
640 |
data.setBackgroundColor(backgroundColor);
|
|
|
641 |
data.setLabel("DataSet 1");
|
| 28468 |
tejbeer |
642 |
|
| 31884 |
tejbeer |
643 |
PieLables label = new PieLables();
|
|
|
644 |
label.setFontColor("White");
|
|
|
645 |
label.setFontSize(15);
|
| 28468 |
tejbeer |
646 |
|
| 31884 |
tejbeer |
647 |
Legend legend = new Legend();
|
|
|
648 |
legend.setLabels(label);
|
|
|
649 |
legend.setPosition("left");
|
| 28468 |
tejbeer |
650 |
|
| 31884 |
tejbeer |
651 |
List<Data> dataList = new ArrayList<>();
|
|
|
652 |
dataList.add(data);
|
| 28468 |
tejbeer |
653 |
|
| 31884 |
tejbeer |
654 |
DataInvestmentModel datasets = new DataInvestmentModel();
|
|
|
655 |
datasets.setDatasets(dataList);
|
|
|
656 |
datasets.setLabels(labels);
|
| 28468 |
tejbeer |
657 |
|
| 31884 |
tejbeer |
658 |
OptionModel om = new OptionModel();
|
|
|
659 |
om.setLegend(legend);
|
|
|
660 |
cm.setType("pie");
|
|
|
661 |
cm.setData(datasets);
|
|
|
662 |
cm.setOptions(om);
|
| 28468 |
tejbeer |
663 |
|
| 31884 |
tejbeer |
664 |
return cm;
|
|
|
665 |
}
|
| 28468 |
tejbeer |
666 |
|
| 31884 |
tejbeer |
667 |
public List<Notification> getNotifications(List<NotificationCampaign> nc, MessageType messageType) throws ProfitMandiBusinessException {
|
|
|
668 |
List<Notification> notifications = new ArrayList<>();
|
|
|
669 |
Document document = null;
|
|
|
670 |
if (messageType != null) {
|
|
|
671 |
for (NotificationCampaign notificationCampaign : nc) {
|
|
|
672 |
if (notificationCampaign.getMessageType() == messageType) {
|
|
|
673 |
Notification ns = new Notification();
|
|
|
674 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(), SimpleCampaignParams.class);
|
|
|
675 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
676 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
677 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
678 |
ns.setType(campaign.getType());
|
|
|
679 |
ns.setMessage(campaign.getMessage());
|
|
|
680 |
ns.setTitle(campaign.getTitle());
|
|
|
681 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
682 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
683 |
ns.setDocumentName(document.getDisplayName());
|
|
|
684 |
}
|
|
|
685 |
ns.setUrl(campaign.getUrl());
|
|
|
686 |
ns.setShowImage(campaign.getShowImage());
|
|
|
687 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
688 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
689 |
ns.setMessageType(notificationCampaign.getMessageType());
|
|
|
690 |
ns.setCreated(
|
|
|
691 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
|
|
692 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
693 |
ns.setExpired(true);
|
|
|
694 |
} else {
|
|
|
695 |
ns.setExpired(false);
|
|
|
696 |
}
|
|
|
697 |
notifications.add(ns);
|
|
|
698 |
}
|
|
|
699 |
}
|
|
|
700 |
} else {
|
|
|
701 |
for (NotificationCampaign notificationCampaign : nc) {
|
| 28468 |
tejbeer |
702 |
|
| 31884 |
tejbeer |
703 |
Notification ns = new Notification();
|
|
|
704 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(), SimpleCampaignParams.class);
|
|
|
705 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
706 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
707 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
708 |
ns.setType(campaign.getType());
|
|
|
709 |
ns.setMessage(campaign.getMessage());
|
|
|
710 |
ns.setTitle(campaign.getTitle());
|
|
|
711 |
if (notificationCampaign.getDocumentId() != null) {
|
|
|
712 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
|
|
713 |
ns.setDocumentName(document.getDisplayName());
|
|
|
714 |
}
|
|
|
715 |
ns.setUrl(campaign.getUrl());
|
|
|
716 |
ns.setShowImage(campaign.getShowImage());
|
|
|
717 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
718 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
|
|
719 |
ns.setMessageType(notificationCampaign.getMessageType());
|
|
|
720 |
ns.setCreated(notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
|
|
721 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
722 |
ns.setExpired(true);
|
|
|
723 |
} else {
|
|
|
724 |
ns.setExpired(false);
|
|
|
725 |
}
|
|
|
726 |
notifications.add(ns);
|
|
|
727 |
}
|
| 28468 |
tejbeer |
728 |
|
| 31884 |
tejbeer |
729 |
}
|
|
|
730 |
return notifications;
|
| 28468 |
tejbeer |
731 |
|
| 31884 |
tejbeer |
732 |
}
|
|
|
733 |
|
|
|
734 |
public boolean hasGift(int fofoId) {
|
|
|
735 |
try {
|
|
|
736 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
|
|
737 |
} catch (ProfitMandiBusinessException e) {
|
|
|
738 |
return false;
|
|
|
739 |
}
|
|
|
740 |
}
|
|
|
741 |
|
| 34388 |
tejus.loha |
742 |
public ChartModel getModelBrandChart(int fofoId, String brand, LocalDate startDate, LocalDate endDate, boolean isQuantity) {
|
|
|
743 |
|
|
|
744 |
LocalDateTime curDate = startDate == null ? LocalDate.now().atStartOfDay().withDayOfMonth(1) : startDate.atStartOfDay();
|
|
|
745 |
LocalDateTime lastDate = endDate == null ? LocalDate.now().atStartOfDay().with(LocalTime.MAX) : endDate.atStartOfDay();
|
|
|
746 |
|
|
|
747 |
//----------------------------MTD-------------------------
|
|
|
748 |
Map<String, Double> modelWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate, lastDate, fofoId, "modelNumber", brand);
|
|
|
749 |
Map<String, Long> modelWiseSaleQuantity = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate, lastDate, fofoId, "modelNumber", brand);
|
|
|
750 |
|
|
|
751 |
List<ActivatedImeisWithSellingPrice> activatedImeisWithSellingPricesMTD = fofoOrderItemRepository.selectValueOfActivatedImeisModelWise(curDate, lastDate, fofoId, brand);
|
|
|
752 |
Map<String, Double> activatedImeisWithSellingPriceMTD = activatedImeisWithSellingPricesMTD.stream().collect(Collectors.toMap(x -> x.getModel(), x -> (double) x.getSellingPrice()));
|
|
|
753 |
Map<String, Long> activatedImeisWithSellingQuantityMTD = activatedImeisWithSellingPricesMTD.stream().collect(Collectors.toMap(x -> x.getModel(), x -> (long) x.getQuantity()));
|
|
|
754 |
|
|
|
755 |
|
|
|
756 |
//---------------------------------LMTD----------------------
|
|
|
757 |
Map<String, Double> lmtdModelWiseSale = fofoOrderItemRepository.selectSumAmountGroupByBrand(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId, "modelNumber", brand);
|
|
|
758 |
Map<String, Long> lmtdModelWiseSaleQuantity = fofoOrderItemRepository.selectSumQuantityGroupByBrand(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId, "modelNumber", brand);
|
|
|
759 |
|
|
|
760 |
List<ActivatedImeisWithSellingPrice> lmtdActivatedImeisWithSellingPrices = fofoOrderItemRepository.selectValueOfActivatedImeisModelWise(curDate.minusMonths(1), lastDate.minusMonths(1), fofoId, brand);
|
|
|
761 |
Map<String, Double> lmtdActivatedImeisWithSellingPrice = lmtdActivatedImeisWithSellingPrices.stream().collect(Collectors.toMap(x -> x.getModel(), x -> (double) x.getSellingPrice()));
|
|
|
762 |
Map<String, Long> lmtdActivatedImeisWithSellingQuantity = lmtdActivatedImeisWithSellingPrices.stream().collect(Collectors.groupingBy(x -> x.getModel(), Collectors.summingLong(x -> x.getQuantity())));
|
|
|
763 |
|
|
|
764 |
ChartModel cm = new ChartModel();
|
|
|
765 |
|
|
|
766 |
List<String> brandList1 = lmtdModelWiseSale.keySet().stream().collect(Collectors.toList());
|
|
|
767 |
List<String> brandList2 = modelWiseSale.keySet().stream().collect(Collectors.toList());
|
|
|
768 |
HashSet<String> brandsAsLabelList = new HashSet<>();
|
|
|
769 |
brandsAsLabelList.addAll(brandList1);
|
|
|
770 |
brandsAsLabelList.addAll(brandList2);
|
|
|
771 |
// for MTD
|
|
|
772 |
List<Double> mtdActivatedImeisValues = new ArrayList<>();
|
|
|
773 |
List<Double> mtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
774 |
List<Double> mtdValues = new ArrayList<>();
|
|
|
775 |
List<Double> mtdActivatedImeisQuantity = new ArrayList<>();
|
|
|
776 |
List<Double> mtdUnActivatedImeisQuantity = new ArrayList<>();
|
|
|
777 |
List<Double> mtdQuantity = new ArrayList<>();
|
|
|
778 |
|
|
|
779 |
// for LMTD
|
|
|
780 |
List<Double> lmtdActivatedImeisValues = new ArrayList<>();
|
|
|
781 |
List<Double> lmtdUnActivatedImeisValues = new ArrayList<>();
|
|
|
782 |
List<Double> lmtdValues = new ArrayList<>();
|
|
|
783 |
List<Double> lmtdActivatedImeisQuantity = new ArrayList<>();
|
|
|
784 |
List<Double> lmtdUnActivatedImeisQuantity = new ArrayList<>();
|
|
|
785 |
List<Double> lmtdQuantity = new ArrayList<>();
|
|
|
786 |
|
|
|
787 |
|
|
|
788 |
LOGGER.info("labelsList - " + brandsAsLabelList);
|
|
|
789 |
for (String brandAsLabel : brandsAsLabelList) {
|
|
|
790 |
brandAsLabel = brandAsLabel.trim();
|
|
|
791 |
if (isQuantity) {
|
|
|
792 |
mtdActivatedImeisQuantity.add(activatedImeisWithSellingQuantityMTD.get(brandAsLabel) == null ? 0 : (double) activatedImeisWithSellingQuantityMTD.get(brandAsLabel));
|
|
|
793 |
mtdQuantity.add(modelWiseSaleQuantity.get(brandAsLabel) == null ? 0 : (double) modelWiseSaleQuantity.get(brandAsLabel));
|
|
|
794 |
mtdUnActivatedImeisQuantity.add(modelWiseSaleQuantity.get(brandAsLabel) == null ? 0 : modelWiseSaleQuantity.get(brandAsLabel) - (activatedImeisWithSellingQuantityMTD.get(brandAsLabel) == null ? 0 : (double) activatedImeisWithSellingQuantityMTD.get(brandAsLabel)));
|
|
|
795 |
|
|
|
796 |
lmtdActivatedImeisQuantity.add(lmtdActivatedImeisWithSellingQuantity.get(brandAsLabel) == null ? 0 : (double) lmtdActivatedImeisWithSellingQuantity.get(brandAsLabel));
|
|
|
797 |
lmtdUnActivatedImeisQuantity.add(lmtdModelWiseSaleQuantity.get(brandAsLabel) == null ? 0 : lmtdModelWiseSaleQuantity.get(brandAsLabel) - (lmtdActivatedImeisWithSellingQuantity.get(brandAsLabel) == null ? 0 : (double) lmtdActivatedImeisWithSellingQuantity.get(brandAsLabel)));
|
|
|
798 |
lmtdQuantity.add(lmtdModelWiseSaleQuantity.get(brandAsLabel) == null ? 0 : (double) lmtdModelWiseSaleQuantity.get(brandAsLabel));
|
|
|
799 |
} else {
|
|
|
800 |
mtdActivatedImeisValues.add(activatedImeisWithSellingPriceMTD.get(brandAsLabel) == null ? 0 : activatedImeisWithSellingPriceMTD.get(brandAsLabel));
|
|
|
801 |
mtdValues.add(modelWiseSale.get(brandAsLabel) == null ? 0 : modelWiseSale.get(brandAsLabel));
|
|
|
802 |
if (modelWiseSale.get(brandAsLabel) != null) {
|
|
|
803 |
mtdUnActivatedImeisValues.add(modelWiseSale.get(brandAsLabel) - (activatedImeisWithSellingPriceMTD.get(brandAsLabel) == null ? 0 : activatedImeisWithSellingPriceMTD.get(brandAsLabel)));
|
|
|
804 |
} else {
|
|
|
805 |
mtdUnActivatedImeisValues.add(0.0);
|
|
|
806 |
}
|
|
|
807 |
lmtdValues.add(lmtdModelWiseSale.get(brandAsLabel) == null ? 0 : lmtdModelWiseSale.get(brandAsLabel));
|
|
|
808 |
lmtdActivatedImeisValues.add(lmtdActivatedImeisWithSellingPrice.get(brandAsLabel) == null ? 0 : lmtdActivatedImeisWithSellingPrice.get(brandAsLabel));
|
|
|
809 |
if (lmtdModelWiseSale.get(brandAsLabel.trim()) != null) {
|
|
|
810 |
lmtdUnActivatedImeisValues.add(lmtdModelWiseSale.get(brandAsLabel) - (lmtdActivatedImeisWithSellingPrice.get(brandAsLabel) == null ? 0 : lmtdActivatedImeisWithSellingPrice.get(brandAsLabel)));
|
|
|
811 |
} else {
|
|
|
812 |
lmtdUnActivatedImeisValues.add(0.0);
|
|
|
813 |
}
|
|
|
814 |
}
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
DatasetModel mtdActivatedImeis = new DatasetModel();
|
|
|
818 |
mtdActivatedImeis.setLabel("Total Activation");
|
|
|
819 |
mtdActivatedImeis.setBorderColor("#00008b");
|
|
|
820 |
mtdActivatedImeis.setBackgroundColor("#00008b");
|
|
|
821 |
mtdActivatedImeis.setStack("stack0");
|
|
|
822 |
mtdActivatedImeis.setOrder(0);
|
|
|
823 |
|
|
|
824 |
DatasetModel dsmUnactivated = new DatasetModel();
|
|
|
825 |
dsmUnactivated.setLabel("Total Unactivated");
|
|
|
826 |
dsmUnactivated.setBackgroundColor("red");
|
|
|
827 |
dsmUnactivated.setBorderColor("red");
|
|
|
828 |
dsmUnactivated.setStack("stack0");
|
|
|
829 |
dsmUnactivated.setOrder(1);
|
|
|
830 |
|
|
|
831 |
DatasetModel linemtdChart = new DatasetModel();
|
|
|
832 |
linemtdChart.setLabel("Total");
|
|
|
833 |
linemtdChart.setBackgroundColor("#006400");
|
|
|
834 |
linemtdChart.setBorderColor("#006400");
|
|
|
835 |
linemtdChart.setType("line");
|
|
|
836 |
linemtdChart.setOrder(2);
|
|
|
837 |
linemtdChart.setFill("false");
|
|
|
838 |
|
|
|
839 |
DatasetModel LmtdActivatedImeis = new DatasetModel();
|
| 34466 |
tejus.loha |
840 |
LmtdActivatedImeis.setLabel("prev mth Activation");
|
| 34388 |
tejus.loha |
841 |
LmtdActivatedImeis.setBackgroundColor("#87ceeb");
|
|
|
842 |
LmtdActivatedImeis.setBorderColor("#87ceeb");
|
|
|
843 |
LmtdActivatedImeis.setStack("stack1");
|
|
|
844 |
LmtdActivatedImeis.setOrder(3);
|
|
|
845 |
|
|
|
846 |
DatasetModel lmtdUnActivated = new DatasetModel();
|
| 34466 |
tejus.loha |
847 |
lmtdUnActivated.setLabel("prev mth Unactivation");
|
| 34388 |
tejus.loha |
848 |
lmtdUnActivated.setBackgroundColor("red");
|
|
|
849 |
lmtdUnActivated.setBorderColor("red");
|
|
|
850 |
lmtdUnActivated.setStack("stack1");
|
|
|
851 |
lmtdUnActivated.setOrder(4);
|
|
|
852 |
|
|
|
853 |
DatasetModel lineLmtdChart = new DatasetModel();
|
| 34466 |
tejus.loha |
854 |
lineLmtdChart.setLabel("prev mth TOTAL");
|
| 34388 |
tejus.loha |
855 |
lineLmtdChart.setBackgroundColor("hotpink");
|
|
|
856 |
lineLmtdChart.setBorderColor("hotpink");
|
|
|
857 |
lineLmtdChart.setType("line");
|
|
|
858 |
lineLmtdChart.setOrder(5);
|
|
|
859 |
lineLmtdChart.setFill("false");
|
|
|
860 |
|
|
|
861 |
|
|
|
862 |
if (isQuantity) {
|
|
|
863 |
mtdActivatedImeis.setData(mtdActivatedImeisQuantity);
|
|
|
864 |
dsmUnactivated.setData(mtdUnActivatedImeisQuantity);
|
|
|
865 |
linemtdChart.setData(mtdQuantity);
|
|
|
866 |
LmtdActivatedImeis.setData(lmtdActivatedImeisQuantity);
|
|
|
867 |
lmtdUnActivated.setData(lmtdUnActivatedImeisQuantity);
|
|
|
868 |
lineLmtdChart.setData(lmtdQuantity);
|
|
|
869 |
} else {
|
|
|
870 |
mtdActivatedImeis.setData(mtdActivatedImeisValues);
|
|
|
871 |
dsmUnactivated.setData(mtdUnActivatedImeisValues);
|
|
|
872 |
linemtdChart.setData(mtdValues);
|
|
|
873 |
LmtdActivatedImeis.setData(lmtdActivatedImeisValues);
|
|
|
874 |
lmtdUnActivated.setData(lmtdUnActivatedImeisValues);
|
|
|
875 |
lineLmtdChart.setData(lmtdValues);
|
|
|
876 |
}
|
|
|
877 |
|
|
|
878 |
List<DatasetModel> datasets = new ArrayList<>();
|
|
|
879 |
datasets.add(mtdActivatedImeis);
|
|
|
880 |
datasets.add(dsmUnactivated);
|
|
|
881 |
datasets.add(linemtdChart);
|
|
|
882 |
datasets.add(LmtdActivatedImeis);
|
|
|
883 |
datasets.add(lmtdUnActivated);
|
|
|
884 |
datasets.add(lineLmtdChart);
|
|
|
885 |
|
|
|
886 |
DataModel dm = new DataModel();
|
|
|
887 |
dm.setDatasets(datasets);
|
|
|
888 |
dm.setLabels(brandsAsLabelList);
|
|
|
889 |
|
|
|
890 |
Tooltips tooltips = new Tooltips();
|
|
|
891 |
tooltips.setBodyFontSize(25);
|
|
|
892 |
tooltips.setTitleFontSize(25);
|
|
|
893 |
tooltips.setMode("index");
|
|
|
894 |
tooltips.setIntersect(false);
|
|
|
895 |
tooltips.setBackgroundColor("rgba(0, 0, 0, 0.7)");
|
|
|
896 |
HoverModel hover = new HoverModel();
|
|
|
897 |
hover.setIntersect(false);
|
|
|
898 |
hover.setMode("index");
|
|
|
899 |
|
|
|
900 |
LegendModel lm = new LegendModel();
|
|
|
901 |
lm.setPosition("top");
|
|
|
902 |
TitleModel tm = new TitleModel();
|
| 34426 |
tejus.loha |
903 |
if (isQuantity) {
|
|
|
904 |
tm.setText("Model Wise Sales Quantity");
|
|
|
905 |
} else {
|
|
|
906 |
tm.setText("Model Wise Sales Value");
|
|
|
907 |
}
|
| 34388 |
tejus.loha |
908 |
tm.setDisplay(true);
|
| 34426 |
tejus.loha |
909 |
tm.setFontSize(30);
|
|
|
910 |
tm.setFontColor("#050a4d");
|
| 34388 |
tejus.loha |
911 |
|
|
|
912 |
List<Axis> xAxes = new ArrayList<>();
|
|
|
913 |
Axis xAxis = new Axis();
|
|
|
914 |
xAxis.setStacked(true);
|
|
|
915 |
xAxes.add(xAxis);
|
|
|
916 |
|
|
|
917 |
List<Axis> yAxes = new ArrayList<>();
|
|
|
918 |
Axis yAxis = new Axis();
|
|
|
919 |
yAxis.setStacked(false);
|
|
|
920 |
yAxes.add(yAxis);
|
|
|
921 |
|
|
|
922 |
ScalesModel sm = new ScalesModel();
|
|
|
923 |
sm.setxAxes(xAxes);
|
|
|
924 |
|
|
|
925 |
OptionsModel om = new OptionsModel();
|
|
|
926 |
om.setLegend(lm);
|
|
|
927 |
om.setTitle(tm);
|
|
|
928 |
om.setScales(sm);
|
|
|
929 |
om.setHover(hover);
|
|
|
930 |
om.setTooltips(tooltips);
|
|
|
931 |
|
|
|
932 |
cm.setType("bar");
|
|
|
933 |
cm.setData(dm);
|
|
|
934 |
cm.setOptions(om);
|
|
|
935 |
|
|
|
936 |
LOGGER.info("Model_cm" + cm);
|
|
|
937 |
return cm;
|
|
|
938 |
|
|
|
939 |
}
|
|
|
940 |
|
| 28468 |
tejbeer |
941 |
}
|