Subversion Repositories SmartDukaan

Rev

Rev 27415 | Rev 27476 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27415 Rev 27474
Line 5... Line 5...
5
import java.io.FileNotFoundException;
5
import java.io.FileNotFoundException;
6
import java.time.LocalDate;
6
import java.time.LocalDate;
7
import java.time.LocalDateTime;
7
import java.time.LocalDateTime;
8
import java.time.LocalTime;
8
import java.time.LocalTime;
9
import java.time.ZoneOffset;
9
import java.time.ZoneOffset;
-
 
10
import java.time.format.DateTimeFormatter;
10
import java.util.ArrayList;
11
import java.util.ArrayList;
11
import java.util.Arrays;
12
import java.util.Arrays;
12
import java.util.HashMap;
13
import java.util.HashMap;
13
import java.util.HashSet;
14
import java.util.HashSet;
14
import java.util.LinkedHashMap;
15
import java.util.LinkedHashMap;
Line 66... Line 67...
66
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
67
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
67
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
68
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
68
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
69
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
69
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
70
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
70
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
71
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
-
 
72
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
71
import com.spice.profitmandi.dao.entity.user.Lead;
73
import com.spice.profitmandi.dao.entity.user.Lead;
72
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
74
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
73
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
75
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
74
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
76
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
75
import com.spice.profitmandi.dao.model.CreateOfferRequest;
77
import com.spice.profitmandi.dao.model.CreateOfferRequest;
76
import com.spice.profitmandi.dao.model.ItemTypeParams;
78
import com.spice.profitmandi.dao.model.ItemTypeParams;
-
 
79
import com.spice.profitmandi.dao.model.MonthSaleModel;
77
import com.spice.profitmandi.dao.model.PartnerDetailModel;
80
import com.spice.profitmandi.dao.model.PartnerDetailModel;
78
import com.spice.profitmandi.dao.model.SimpleCampaign;
81
import com.spice.profitmandi.dao.model.SimpleCampaign;
79
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
82
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
80
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
83
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
81
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
84
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
Line 101... Line 104...
101
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
104
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
102
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
105
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
103
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
106
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
104
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
107
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
105
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
108
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
-
 
109
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
106
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
110
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
107
import com.spice.profitmandi.service.PartnerInvestmentService;
111
import com.spice.profitmandi.service.PartnerInvestmentService;
108
import com.spice.profitmandi.service.PartnerStatsService;
112
import com.spice.profitmandi.service.PartnerStatsService;
109
import com.spice.profitmandi.service.authentication.RoleManager;
113
import com.spice.profitmandi.service.authentication.RoleManager;
110
import com.spice.profitmandi.service.inventory.InventoryService;
114
import com.spice.profitmandi.service.inventory.InventoryService;
Line 195... Line 199...
195
	@Autowired
199
	@Autowired
196
	private UserCampaignRepository userCampaignRepository;
200
	private UserCampaignRepository userCampaignRepository;
197
 
201
 
198
	@Autowired
202
	@Autowired
199
	private PositionRepository positionRepository;
203
	private PositionRepository positionRepository;
-
 
204
	@Autowired
-
 
205
	private PartnerTypeChangeRepository partnerTypeChangeRepository;
200
 
206
 
201
	@Autowired
207
	@Autowired
202
	private PartnersPositionRepository partnerPositionRepository;
208
	private PartnersPositionRepository partnerPositionRepository;
203
 
209
 
204
	@Autowired
210
	@Autowired
Line 368... Line 374...
368
		salesMap.put("currentType", currentType);
374
		salesMap.put("currentType", currentType);
369
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
375
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
370
		return salesMap;
376
		return salesMap;
371
	}
377
	}
372
 
378
 
-
 
379
	@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
-
 
380
	public String getMonthsale(HttpServletRequest request, Model model) throws Exception {
-
 
381
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
382
		int fofoId = loginDetails.getFofoId();
-
 
383
		Map<Integer, MonthSaleModel> monthSaleMap = new HashMap<>();
-
 
384
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
385
		int dayOfMonth = curDate.getDayOfMonth();
-
 
386
		for (int i = 1; i <= 6; i++) {
-
 
387
			LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
-
 
388
			double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
-
 
389
					startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
-
 
390
 
-
 
391
			double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
-
 
392
					startOfMonth.plusDays(dayOfMonth), loginDetails.getFofoId(), false).get(fofoId);
-
 
393
 
-
 
394
			PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth.toLocalDate());
-
 
395
 
-
 
396
			MonthSaleModel ms = new MonthSaleModel();
-
 
397
			ms.setMtdSales(this.format((long) mtdSales));
-
 
398
			ms.setMonthlySales(this.format(((long) monthSales)));
-
 
399
			ms.setPartnerType(partnerType);
-
 
400
			ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("LLL''yy")));
-
 
401
			monthSaleMap.put(i, ms);
-
 
402
 
-
 
403
		}
-
 
404
		model.addAttribute("monthSales", monthSaleMap);
-
 
405
		return "monthSales";
-
 
406
	}
-
 
407
 
-
 
408
	private String format(long value) {
-
 
409
		String finalval = null;
-
 
410
 
-
 
411
		if (value >= 100000 && value < 10000000) {
-
 
412
			long reminder = value / 100000;
-
 
413
			long quitonent = value % 100000;
-
 
414
			finalval = reminder + "." + quitonent;
-
 
415
			String secondval = String.valueOf(quitonent);
-
 
416
			if (secondval.length() >= 2) {
-
 
417
				secondval = secondval.substring(0, 2);
-
 
418
				finalval = reminder + "." + secondval;
-
 
419
			}
-
 
420
			return String.valueOf(finalval) + " Lacs";
-
 
421
		} else if (value >= 1000 && value < 100000) {
-
 
422
			long reminder = value / 1000;
-
 
423
			long quitonent = value % 1000;
-
 
424
			finalval = reminder + "." + quitonent;
-
 
425
			String secondval = String.valueOf(quitonent);
-
 
426
			if (secondval.length() >= 2) {
-
 
427
				secondval = secondval.substring(0, 2);
-
 
428
				finalval = reminder + "." + secondval;
-
 
429
			}
-
 
430
			return String.valueOf(finalval) + " K";
-
 
431
		} else if (value >= 10000000 && value < 1000000000) {
-
 
432
			long reminder = value / 10000000;
-
 
433
			long quitonent = value % 10000000;
-
 
434
			finalval = reminder + "." + quitonent;
-
 
435
			String secondval = String.valueOf(quitonent);
-
 
436
			if (secondval.length() >= 2) {
-
 
437
				secondval = secondval.substring(0, 2);
-
 
438
				finalval = reminder + "." + secondval;
-
 
439
			}
-
 
440
			return String.valueOf(finalval) + " Cr";
-
 
441
		}
-
 
442
		return String.valueOf(finalval);
-
 
443
 
-
 
444
	}
-
 
445
 
373
	private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
446
	private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
374
		Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
447
		Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
375
 
448
 
376
		List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
449
		List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
377
		List<BrandStockPrice> brandStockPrices = new ArrayList<>();
450
		List<BrandStockPrice> brandStockPrices = new ArrayList<>();