Subversion Repositories SmartDukaan

Rev

Rev 28468 | Rev 29165 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
28468 tejbeer 1
package com.spice.profitmandi.service;
2
 
3
import java.io.FileInputStream;
4
import java.io.ObjectInputStream;
5
import java.time.LocalDate;
6
import java.time.LocalDateTime;
7
import java.time.Period;
8
import java.time.YearMonth;
9
import java.time.format.DateTimeFormatter;
10
import java.util.ArrayList;
11
import java.util.Arrays;
12
import java.util.Comparator;
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.LinkedHashMap;
16
import java.util.List;
17
import java.util.Map;
18
import java.util.Optional;
19
import java.util.Set;
20
import java.util.TreeMap;
21
import java.util.Map.Entry;
22
import java.util.stream.Collectors;
23
 
24
import org.apache.logging.log4j.LogManager;
25
import org.apache.logging.log4j.Logger;
26
import org.springframework.beans.factory.annotation.Autowired;
27
import org.springframework.stereotype.Component;
28
import org.springframework.ui.Model;
29
 
30
import com.google.gson.Gson;
31
import com.spice.profitmandi.common.enumuration.ReporticoProject;
32
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
33
import com.spice.profitmandi.common.model.ChartModel;
34
import com.spice.profitmandi.common.model.CustomRetailer;
35
import com.spice.profitmandi.common.model.ProfitMandiConstants;
36
import com.spice.profitmandi.dao.entity.auth.AuthUser;
37
import com.spice.profitmandi.dao.entity.auth.Menu;
38
import com.spice.profitmandi.dao.entity.cs.Position;
39
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
40
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
41
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
28825 tejbeer 42
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
28468 tejbeer 43
import com.spice.profitmandi.dao.model.BrandWiseModel;
44
import com.spice.profitmandi.dao.model.PartnerDetailModel;
45
import com.spice.profitmandi.dao.model.WarehouseWiseStockModel;
46
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
47
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
48
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
49
import com.spice.profitmandi.dao.repository.cs.CsService;
50
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
51
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
52
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
28825 tejbeer 53
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
28468 tejbeer 54
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
55
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
56
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
57
import com.spice.profitmandi.service.user.RetailerService;
58
 
59
@Component
60
public class AdminUser {
61
	@Autowired
62
	private Gson gson;
63
 
64
	@Autowired
65
	private OrderRepository orderRepository;
66
 
67
	@Autowired
68
	TicketRepository ticketRepository;
69
 
70
	@Autowired
71
	private ChartService chartService;
72
 
73
	@Autowired
74
	RetailerService retailerService;
75
 
76
	@Autowired
77
	AuthRepository authRepository;
78
 
79
	@Autowired
80
	FofoStoreRepository fofoStoreRepository;
81
 
82
	@Autowired
83
	CsService csService;
84
 
85
	@Autowired
86
	private MenuRepository menuRepository;
87
 
88
	@Autowired
89
	private PositionRepository positionRepository;
90
 
91
	@Autowired
92
	private MenuCategoryRepository menuCategoryRepository;
93
 
94
	@Autowired
95
	private SaholicInventoryCISRepository saholicInventoryCISRepository;
96
 
97
	@Autowired
98
	private ReporticoCacheTableRepository reporticoCacheTableRepository;
99
 
100
	@Autowired
28825 tejbeer 101
	private ActivatedImeiRepository activatedImeiRepository;
102
 
103
	@Autowired
28468 tejbeer 104
	private PartnerStatsService partnerStatsService;
105
	List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
106
			"niranjan.kala@smartdukaan.com", "hemant.kaura@smartdukaan.com", "amit.gupta@shop2020.in",
107
			"tejbeer.kaur@shop2020.in");
108
 
109
	List<String> colorList = Arrays.asList("mediumseagreen", "dodgerblue", "darkblue", "gold", "coral", "steelblue",
110
			"red", "deeppink", "midnightblue", "cornsilk");
111
 
112
	List<String> borderList = Arrays.asList("lawngreen", "lightblue", "#0000cd", "#f7e98e", "lightcoral", "#0000cd",
113
			"lightsalmon", "pink", "#0000cd", "cornsilk");
114
 
115
	List<String> brands = Arrays.asList("Oppo", "Vivo", "Samsung", "Realme", "Xiaomi", "Tecno", "Itel", "Lava",
116
			"Nokia");
117
 
118
	private static final Logger LOGGER = LogManager.getLogger(AdminUser.class);
119
 
120
	public ChartModel getBrandWiseLmp(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
121
		LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
122
 
123
		List<BrandWiseModel> brandWiseLms = orderRepository.selectGroupByBrandLmp(fofoIds, warehouseIds, startDateTime);
124
		LOGGER.info("brandWiseLms" + brandWiseLms);
125
 
126
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
127
 
128
		Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
129
		for (BrandWiseModel bwl : brandWiseLms) {
130
			Map<YearMonth, Double> yearMonthValue = new HashMap<>();
131
			if (brandMonthValue.containsKey(bwl.getBrand())) {
132
				yearMonthValue = brandMonthValue.get(bwl.getBrand());
133
				yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
134
			} else {
135
 
136
				yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
137
 
138
			}
139
			brandMonthValue.put(bwl.getBrand(), yearMonthValue);
140
 
141
		}
142
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
143
 
144
		Period age = Period.between(startDateTime, LocalDate.now());
145
		int months = age.getMonths();
146
 
147
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
148
 
149
		for (String brand : brands) {
150
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
151
			for (int i = months; i >= 0; i--) {
152
 
153
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
154
 
155
				if (yearMonthValue != null) {
156
					if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
157
						yearMonthValue.put(YearMonth.from(startMonth), 0.0);
158
					}
159
 
160
				} else {
161
					yearMonthValue = new HashMap<>();
162
					yearMonthValue.put(YearMonth.from(startMonth), 0.0);
163
				}
164
			}
165
 
166
			Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
167
 
168
			brandMonthValue.put(brand, sortedMonthBrandValue);
169
 
170
			sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
171
 
172
		}
173
 
174
		LOGGER.info("brandMonthValue" + brandMonthValue);
175
 
176
		LOGGER.info("sortedBrandValue" + sortedBrandValue);
177
 
178
		ChartModel cm = chartService.createChart(months, sortedBrandValue, colorList, borderList,
179
				"Brand Wise Monthly Purchase");
180
 
181
		return cm;
182
	}
183
 
184
	public Map<String, Object> getFilter(int warehouseId, String email, LocalDate date)
185
			throws ProfitMandiBusinessException {
186
		Map<String, Object> map = new HashMap<>();
187
 
188
		Map<Integer, CustomRetailer> customRetailersMap = null;
189
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
190
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
191
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
192
 
193
		Set<Integer> fofoIds = null;
194
		fofoIds = storeGuyMap.get(authUser.getEmailId());
195
		if (emails.contains(authUser.getEmailId())) {
196
			fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
197
 
198
		}
199
 
200
		if (fofoIds == null) {
201
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
202
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
203
					.count() > 0) {
204
				fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
205
						.map(x -> x.getPartnerId()).collect(Collectors.toSet());
206
			}
207
		}
208
 
209
		if (warehouseId != 0) {
210
 
211
			fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId)
212
					.stream().map(x -> x).collect(Collectors.toSet());
213
 
214
		}
215
		if (date == null) {
216
			LocalDateTime curDate = LocalDate.now().atStartOfDay();
217
 
218
			LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
219
			date = startOfMonth.toLocalDate();
220
		}
221
 
222
		if (fofoIds != null) {
223
			customRetailersMap = retailerService
224
					.getFofoRetailers(fofoIds.stream().map(x -> x).collect(Collectors.toList()));
225
 
226
		}
227
 
228
		map.put("date", date);
229
		map.put("customRetailersMap", customRetailersMap);
230
		map.put("fofoIds", fofoIds);
231
		map.put("warehouseMap", warehouseMap);
232
 
233
		return map;
234
 
235
	}
236
 
237
	public ChartModel getBrandWiseLms(List<Integer> warehouseIds, List<Integer> fofoIds, LocalDate startDateTime) {
238
		LOGGER.info("params" + warehouseIds + fofoIds + startDateTime);
239
 
240
		List<BrandWiseModel> brandWiseLms = fofoStoreRepository.selectGroupByBrandLms(fofoIds, warehouseIds,
241
				startDateTime);
242
		LOGGER.info("brandWiseLms" + brandWiseLms);
243
 
244
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-yyyy");
245
 
246
		Map<String, Map<YearMonth, Double>> brandMonthValue = new HashMap<>();
247
		for (BrandWiseModel bwl : brandWiseLms) {
248
			Map<YearMonth, Double> yearMonthValue = new HashMap<>();
249
			if (brandMonthValue.containsKey(bwl.getBrand())) {
250
				yearMonthValue = brandMonthValue.get(bwl.getBrand());
251
				yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
252
			} else {
253
 
254
				yearMonthValue.put(YearMonth.parse(bwl.getYearMonth(), dateTimeFormatter), (double) bwl.getAmount());
255
 
256
			}
257
			brandMonthValue.put(bwl.getBrand(), yearMonthValue);
258
 
259
		}
260
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
261
 
262
		Period age = Period.between(startDateTime, LocalDate.now());
263
		int months = age.getMonths();
264
		LOGGER.info("months" + months);
265
		LOGGER.info("brandWiseLms" + brandWiseLms);
266
		LOGGER.info("brandMonthValue" + brandMonthValue);
267
 
268
		Map<String, List<Double>> sortedBrandValue = new LinkedHashMap<>();
269
 
270
		for (String brand : brands) {
271
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
272
			for (int i = months; i >= 0; i--) {
273
 
274
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
275
 
276
				if (yearMonthValue != null) {
277
					if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
278
						yearMonthValue.put(YearMonth.from(startMonth), 0.0);
279
					}
280
 
281
				} else {
282
					yearMonthValue = new HashMap<>();
283
					yearMonthValue.put(YearMonth.from(startMonth), 0.0);
284
				}
285
			}
286
 
287
			Map<YearMonth, Double> sortedMonthBrandValue = new TreeMap<>(yearMonthValue);
288
 
289
			brandMonthValue.put(brand, sortedMonthBrandValue);
290
 
291
			sortedBrandValue.put(brand, sortedMonthBrandValue.values().stream().collect(Collectors.toList()));
292
 
293
		}
294
 
295
		ChartModel cm = chartService.createChart(months, sortedBrandValue, colorList, borderList,
296
				"Brand Wise Monthly Sale");
297
 
298
		return cm;
299
	}
300
 
301
	public String adminPanel(int fofoId, String email, Model model) throws Exception {
302
		List<Menu> menus = null;
303
		try {
304
			AuthUser authUser = authRepository.selectByEmailOrMobile(email);
305
			List<Position> positions = positionRepository.selectAll(authUser.getId());
306
			Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
307
			ReporticoCacheTable rctSaholic = null;
308
			ReporticoCacheTable rctPartneStat = null;
309
 
310
			Map<Integer, WarehouseWiseStockModel> warehouseStockMap = new HashMap<>();
311
			LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
312
 
313
			Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
314
			LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
315
 
316
			Map<AuthUser, Long> authUserTicketCount = null;
317
 
318
			for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
319
				wm.put(entry.getKey(), entry.getValue());
320
			}
321
 
322
			wm.put(0, "Total Values");
323
			long stockValue = 0;
324
			long stockQty = 0;
325
			long pendingIndent = 0;
326
			long tertiary = 0;
327
 
328
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
329
 
330
			Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
331
			if (emails.contains(authUser.getEmailId())) {
332
				fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
333
				LOGGER.info("fofoIds" + fofoIds);
334
			}
335
			if (fofoIds == null) {
336
				List<Position> positions1 = positionRepository.selectAll(authUser.getId());
337
				if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
338
						.count() > 0) {
339
					fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
340
							.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
341
				}
342
			}
343
 
344
			if (fofoIds != null && fofoIds.size() > 0) {
345
				Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
346
						.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream()
347
						.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
348
								Collectors.mapping(FofoStore::getId, Collectors.toList())));
349
				// warehouseStock
350
				List<WarehouseWiseStockModel> warehouseStocks = saholicInventoryCISRepository
351
						.selectGroupByWarehouse(new ArrayList<>(warehouseIdFofoIdMap.keySet()));
352
 
353
				warehouseStockMap = warehouseStocks.stream().collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
354
 
355
				if (!warehouseStockMap.isEmpty()) {
356
					for (Entry<Integer, WarehouseWiseStockModel> warehouseStock : warehouseStockMap.entrySet()) {
357
						stockValue += warehouseStock.getValue().getStockValue();
358
						stockQty += warehouseStock.getValue().getStockQty();
359
						pendingIndent += warehouseStock.getValue().getPendingIndent();
360
						tertiary += warehouseStock.getValue().getTertiary();
361
					}
362
					WarehouseWiseStockModel ws = new WarehouseWiseStockModel();
363
					ws.setStockQty(stockQty);
364
					ws.setStockValue(stockValue);
365
					ws.setPendingIndent(pendingIndent);
366
					ws.setTertiary(tertiary);
367
					ws.setWarehouseId(0);
368
					warehouseStockMap.put(0, ws);
369
 
370
				}
371
 
372
				warehouseStockMap.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder()))
373
						.forEachOrdered(x -> warehouseStockSortedMap.put(x.getKey(), x.getValue()));
374
 
375
				rctSaholic = reporticoCacheTableRepository.selectByTableName("SaholicInventoryCIS");
376
 
377
				// warehouseStock
378
				warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
379
				rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
380
 
381
				Set<CustomRetailer> positionRetailers = fofoIds.stream()
382
						.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
383
						.collect(Collectors.toSet());
384
				model.addAttribute("retailers", gson.toJson(positionRetailers));
385
				model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
386
				model.addAttribute("warehouses", getWarehouses(positionRetailers));
387
			} else {
388
				List<Position> warehousePositions = positions.stream()
389
						.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
390
						.collect(Collectors.toList());
391
				if (warehousePositions.size() > 0) {
392
					Set<CustomRetailer> positionRetailers = new HashSet<>();
393
					csService.getPositionCustomRetailerMap(warehousePositions).values().forEach(customRetailers -> {
394
						positionRetailers.addAll(customRetailers);
395
					});
396
					model.addAttribute("reporticoProjectMap", ReporticoProject.warehouseReporticoMap);
397
					model.addAttribute("retailers", gson.toJson(positionRetailers));
398
					model.addAttribute("warehouses", getWarehouses(positionRetailers));
399
				}
400
			}
401
 
402
			if (positions.size() > 0) {
403
				if (positions.stream()
404
						.filter(x -> x.getEscalationType().equals(EscalationType.L3)
405
								|| x.getEscalationType().equals(EscalationType.L4)
406
								|| x.getEscalationType().equals(EscalationType.L5))
407
						.count() > 0) {
408
					authUserTicketCount = ticketRepository.selectAllAuthUserTicketCount(Optional.of(false));
409
				}
410
			}
411
 
412
			if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in", "manish.tiwari@smartdukaan.com")
413
					.contains(email)) {
414
				menus = menuRepository.selectAll();
415
			} else if (positions.size() > 0) {
416
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
417
					menus = menuRepository.selectAll();
418
				} else {
419
					List<Integer> menuIds = menuCategoryRepository.selectAllByPositions(positions).stream()
420
							.map(x -> x.getMenuId()).collect(Collectors.toList());
421
					if (menuIds.size() > 0) {
422
						menus = menuRepository.selectAllByIds(menuIds);
423
					}
424
				}
425
			}
426
 
427
			model.addAttribute("authId", authUser.getId());
428
 
429
			model.addAttribute("rctPartneStat", rctPartneStat);
430
 
431
			model.addAttribute("reporticoDate", rctSaholic);
432
			model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
433
			model.addAttribute("warehouseMap", wm);
434
			model.addAttribute("authUserTicketCount", authUserTicketCount);
435
			model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
436
			LocalDateTime curDate = LocalDate.now().atStartOfDay();
437
 
438
			model.addAttribute("date", curDate.withDayOfMonth(1).minusMonths(6).toLocalDate());
439
 
440
		} catch (ProfitMandiBusinessException e) {
441
		}
442
		List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
443
		LOGGER.info("menu" + menuList);
444
		model.addAttribute("menu", menuList);
445
		return "admin";
446
	}
447
 
448
	private List<Menu> prepareMenu(List<Menu> menus) {
449
		List<Menu> returnMenu = new ArrayList<>();
450
		Map<Menu, List<Menu>> subMenuMap = new HashMap<Menu, List<Menu>>();
451
		for (Menu menu : menus) {
452
			if (menu.get_parent() == null) {
453
				if (!subMenuMap.containsKey(menu)) {
454
					subMenuMap.put(menu, new ArrayList<>());
455
				}
456
			} else {
457
				Menu parentMenu = menu.get_parent();
458
				if (!subMenuMap.containsKey(parentMenu)) {
459
					subMenuMap.put(parentMenu, new ArrayList<>());
460
				}
461
				subMenuMap.get(parentMenu).add(menu);
462
			}
463
		}
464
		subMenuMap.entrySet().stream().forEach(entry -> {
465
			entry.getKey().setSubMenus(entry.getValue());
466
			returnMenu.add(entry.getKey());
467
		});
468
		return returnMenu;
469
	}
470
 
471
	public Map<Integer, PartnerDetailModel> getWarehousePartnerDetail(Map<Integer, List<Integer>> warehousePartnerMap)
472
			throws Exception {
473
 
474
		Map<Integer, PartnerDetailModel> warehouseIdAndallValues = new LinkedHashMap<>();
475
		// Map<Integer, List<FofoStore>> warehousePartnerMap =
476
		// fofoStoreRepository.getWarehousePartnerMap();
477
		Map<Integer, PartnerDetailModel> partnerStats = this.getPartnersStatDataFromFile();
478
		List<Integer> allfofoIds = new ArrayList<>();
479
		if (partnerStats != null) {
480
			for (Entry<Integer, List<Integer>> warehouse : warehousePartnerMap.entrySet()) {
481
				List<Integer> fofoIds = warehouse.getValue().stream().map(x -> x).collect(Collectors.toList());
482
				allfofoIds.addAll(fofoIds);
483
				List<PartnerDetailModel> partnerDetails = fofoIds.stream().map(x -> partnerStats.get(x))
484
						.collect(Collectors.toList());
485
				if (partnerDetails != null && !partnerDetails.isEmpty()) {
486
					PartnerDetailModel partnerDetailModel = partnerStatsService.getAggregateStats(partnerDetails);
487
					warehouseIdAndallValues.put(warehouse.getKey(), partnerDetailModel);
488
				}
489
 
490
			}
491
			List<PartnerDetailModel> allPartnerDetails = allfofoIds.stream().map(x -> partnerStats.get(x))
492
					.collect(Collectors.toList());
493
			LOGGER.info("allPartnerDetails" + allPartnerDetails);
494
			PartnerDetailModel partnerDetailModel = partnerStatsService
495
					.getAggregateStats(new ArrayList<>(allPartnerDetails));
496
			warehouseIdAndallValues.put(0, partnerDetailModel);
497
		}
498
		return warehouseIdAndallValues;
499
	}
500
 
501
	public Map<Integer, PartnerDetailModel> getPartnersStatDataFromFile() throws Exception {
502
		ObjectInputStream objectinputstream = null;
503
		Map<Integer, PartnerDetailModel> partnerStat = null;
504
		try {
505
			FileInputStream streamIn = new FileInputStream("/tmp/partnerStat.tmp");
506
			objectinputstream = new ObjectInputStream(streamIn);
507
			partnerStat = (Map<Integer, PartnerDetailModel>) objectinputstream.readObject();
508
 
509
			LOGGER.info("partnerStat" + partnerStat);
510
			objectinputstream.close();
511
 
512
		} catch (Exception e) {
513
			LOGGER.info("exceptionddd" + e);
514
 
515
			e.printStackTrace();
516
 
517
		} finally {
518
			if (objectinputstream != null) {
519
				objectinputstream.close();
520
				LOGGER.info("clofddd" + partnerStat);
521
 
522
			}
523
		}
524
		return partnerStat;
525
 
526
	}
527
 
528
	private String getWarehouses(Set<CustomRetailer> positionRetailers) {
529
		Map<Integer, String> warehouses = new HashMap<>();
530
		positionRetailers.stream().forEach(x -> {
531
			if (x.getWarehouseId() != 0) {
532
				warehouses.put(x.getWarehouseId(), ProfitMandiConstants.WAREHOUSE_MAP.get(x.getWarehouseId()));
533
			}
534
		});
535
		return gson.toJson(warehouses);
536
 
537
	}
538
 
539
}