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