Subversion Repositories SmartDukaan

Rev

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

Rev 26060 Rev 26065
Line 19... Line 19...
19
import javax.servlet.http.HttpServletRequest;
19
import javax.servlet.http.HttpServletRequest;
20
import javax.transaction.Transactional;
20
import javax.transaction.Transactional;
21
 
21
 
22
import org.apache.logging.log4j.LogManager;
22
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.Logger;
23
import org.apache.logging.log4j.Logger;
24
import org.json.JSONArray;
-
 
25
import org.json.JSONObject;
-
 
26
import org.springframework.beans.factory.annotation.Autowired;
24
import org.springframework.beans.factory.annotation.Autowired;
27
import org.springframework.beans.factory.annotation.Value;
25
import org.springframework.beans.factory.annotation.Value;
28
import org.springframework.core.io.InputStreamResource;
26
import org.springframework.core.io.InputStreamResource;
29
import org.springframework.http.HttpHeaders;
27
import org.springframework.http.HttpHeaders;
30
import org.springframework.http.HttpStatus;
28
import org.springframework.http.HttpStatus;
Line 37... Line 35...
37
 
35
 
38
import com.google.gson.Gson;
36
import com.google.gson.Gson;
39
import com.mongodb.DBObject;
37
import com.mongodb.DBObject;
40
import com.spice.profitmandi.common.enumuration.ContentType;
38
import com.spice.profitmandi.common.enumuration.ContentType;
41
import com.spice.profitmandi.common.enumuration.MessageType;
39
import com.spice.profitmandi.common.enumuration.MessageType;
-
 
40
import com.spice.profitmandi.common.enumuration.ReporticoProject;
42
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
41
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
43
import com.spice.profitmandi.common.model.BrandStockPrice;
42
import com.spice.profitmandi.common.model.BrandStockPrice;
44
import com.spice.profitmandi.common.model.ChartModel;
43
import com.spice.profitmandi.common.model.ChartModel;
45
import com.spice.profitmandi.common.model.CustomRetailer;
44
import com.spice.profitmandi.common.model.CustomRetailer;
46
import com.spice.profitmandi.common.model.DataModel;
45
import com.spice.profitmandi.common.model.DataModel;
Line 207... Line 206...
207
				model.addAttribute("hasGift", hasGift(fofoId));
206
				model.addAttribute("hasGift", hasGift(fofoId));
208
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
207
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
209
 
208
 
210
				model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
209
				model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
211
				model.addAttribute("salesMap", this.getSales(fofoId));
210
				model.addAttribute("salesMap", this.getSales(fofoId));
212
				ChartModel cm = this.getBrandChart(fofoId);
-
 
213
 
-
 
214
				model.addAttribute("chartMap", gson.toJson(cm));
-
 
215
				// this.setInvestments
211
				// this.setInvestments
216
				//
212
				//
217
				model.addAttribute("investments", this.getInvestments(fofoId));
213
				model.addAttribute("investments", this.getInvestments(fofoId));
218
				model.addAttribute("isInvestmentOk",
214
				model.addAttribute("isInvestmentOk",
219
						partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
215
						partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
Line 304... Line 300...
304
		salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
300
		salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
305
 
301
 
306
		salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
302
		salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
307
		salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
303
		salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
308
		salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
304
		salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
-
 
305
 
309
		PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
306
		PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
310
		salesMap.put("currentRate", currentRate);
307
		salesMap.put("currentRate", currentRate);
311
		salesMap.put("currentType", currentType);
308
		salesMap.put("currentType", currentType);
312
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
309
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
313
		return salesMap;
310
		return salesMap;
Line 360... Line 357...
360
				model.addAttribute("fofoStore", fofoStore);
357
				model.addAttribute("fofoStore", fofoStore);
361
				model.addAttribute("partnerType", partnerType);
358
				model.addAttribute("partnerType", partnerType);
362
				model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
359
				model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
363
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
360
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
364
 
361
 
365
				model.addAttribute("brandStockPrices",this.getBrandStockPrices(loginDetails.getFofoId()));
362
				model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
366
				model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
363
				model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
367
				ChartModel cm = this.getBrandChart(loginDetails.getFofoId());
364
				ChartModel cm = this.getBrandChart(loginDetails.getFofoId());
368
 
365
 
369
				LOGGER.info("chartMap" + gson.toJson(cm));
366
				LOGGER.info("chartMap" + gson.toJson(cm));
370
				model.addAttribute("chartMap", gson.toJson(cm));
367
				model.addAttribute("chartMap", gson.toJson(cm));
Line 484... Line 481...
484
	private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
481
	private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
485
		List<Menu> menus = null;
482
		List<Menu> menus = null;
486
		try {
483
		try {
487
			AuthUser authUser = authRepository.selectByEmailOrMobile(email);
484
			AuthUser authUser = authRepository.selectByEmailOrMobile(email);
488
			List<Position> positions = positionRepository.selectAll(authUser.getId());
485
			List<Position> positions = positionRepository.selectAll(authUser.getId());
489
			if (Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
486
			if(Arrays.asList("amit.gupta@shop2020.in", "tejbeer.kaur@shop2020.in").contains(email)) {
490
				menus = menuRepository.selectAll();
487
				menus = menuRepository.selectAll();
491
			} else if (positions.size() > 0) {
488
			} else if (positions.size() > 0) {
492
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
489
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L4)).count() > 0) {
493
					menus = menuRepository.selectAll();
490
					menus = menuRepository.selectAll();
494
				} else {
491
				} else {
Line 504... Line 501...
504
		} catch (ProfitMandiBusinessException e) {
501
		} catch (ProfitMandiBusinessException e) {
505
		}
502
		}
506
		List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
503
		List<Menu> menuList = (menus != null) ? this.prepareMenu(menus) : new ArrayList<>();
507
 
504
 
508
		model.addAttribute("menu", menuList);
505
		model.addAttribute("menu", menuList);
-
 
506
		model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
509
		return "admin";
507
		return "admin";
510
	}
508
	}
511
 
509
 
512
	private List<Menu> prepareMenu(List<Menu> menus) {
510
	private List<Menu> prepareMenu(List<Menu> menus) {
513
		List<Menu> returnMenu = new ArrayList<>();
511
		List<Menu> returnMenu = new ArrayList<>();