Subversion Repositories SmartDukaan

Rev

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

Rev 25676 Rev 25677
Line 29... Line 29...
29
import org.springframework.web.bind.annotation.RequestMapping;
29
import org.springframework.web.bind.annotation.RequestMapping;
30
import org.springframework.web.bind.annotation.RequestMethod;
30
import org.springframework.web.bind.annotation.RequestMethod;
31
import org.springframework.web.bind.annotation.RequestParam;
31
import org.springframework.web.bind.annotation.RequestParam;
32
 
32
 
33
import com.google.gson.Gson;
33
import com.google.gson.Gson;
-
 
34
import com.mongodb.DBObject;
34
import com.spice.profitmandi.common.enumuration.ContentType;
35
import com.spice.profitmandi.common.enumuration.ContentType;
35
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
36
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
37
import com.spice.profitmandi.common.model.BrandStockPrice;
36
import com.spice.profitmandi.common.model.Notification;
38
import com.spice.profitmandi.common.model.Notification;
37
import com.spice.profitmandi.common.model.ProfitMandiConstants;
39
import com.spice.profitmandi.common.model.ProfitMandiConstants;
38
import com.spice.profitmandi.common.web.util.ResponseSender;
40
import com.spice.profitmandi.common.web.util.ResponseSender;
39
import com.spice.profitmandi.dao.Interface.Campaign;
41
import com.spice.profitmandi.dao.Interface.Campaign;
40
import com.spice.profitmandi.dao.entity.dtr.Document;
42
import com.spice.profitmandi.dao.entity.dtr.Document;
Line 58... Line 60...
58
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
60
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
59
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
61
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
60
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
62
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
61
import com.spice.profitmandi.service.PartnerInvestmentService;
63
import com.spice.profitmandi.service.PartnerInvestmentService;
62
import com.spice.profitmandi.service.authentication.RoleManager;
64
import com.spice.profitmandi.service.authentication.RoleManager;
-
 
65
import com.spice.profitmandi.service.inventory.InventoryService;
63
import com.spice.profitmandi.web.model.LoginDetails;
66
import com.spice.profitmandi.web.model.LoginDetails;
64
import com.spice.profitmandi.web.util.CookiesProcessor;
67
import com.spice.profitmandi.web.util.CookiesProcessor;
65
 
68
 
66
@Controller
69
@Controller
67
@Transactional(rollbackOn = Throwable.class)
70
@Transactional(rollbackOn = Throwable.class)
Line 100... Line 103...
100
	@Autowired
103
	@Autowired
101
	private PartnerInvestmentService partnerInvestmentService;
104
	private PartnerInvestmentService partnerInvestmentService;
102
 
105
 
103
	@Autowired
106
	@Autowired
104
	DocumentRepository documentRepository;
107
	DocumentRepository documentRepository;
-
 
108
	
-
 
109
	@Autowired
-
 
110
	InventoryService inventoryService;
105
 
111
 
106
	@Autowired
112
	@Autowired
107
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
113
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
108
 
114
 
109
	@Autowired
115
	@Autowired
Line 210... Line 216...
210
		salesMap.put("currentType", currentType);
216
		salesMap.put("currentType", currentType);
211
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
217
		salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
212
		return salesMap;
218
		return salesMap;
213
	}
219
	}
214
 
220
 
215
	/*
-
 
216
	 * private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws
221
	private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
217
	 * Exception { Map<String, BrandStockPrice> brandStockPricesMap =
-
 
218
	 * inventoryService.getBrandWiseStockValue(fofoId);
222
		Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
219
	 * 
223
 
220
	 * List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
224
		List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
221
	 * List<BrandStockPrice> brandStockPrices = new ArrayList<>();
225
		List<BrandStockPrice> brandStockPrices = new ArrayList<>();
222
	 * 
226
 
-
 
227
		mobileBrands.stream().forEach(x -> {
223
	 * mobileBrands.stream().forEach(x -> { String brand = (String) x.get("name");
228
			String brand = (String) x.get("name");
224
	 * if (brandStockPricesMap.containsKey(brand)) { BrandStockPrice brandStockPrice
229
			if (brandStockPricesMap.containsKey(brand)) {
225
	 * = brandStockPricesMap.get(brand); brandStockPrice.setBrandUrl((String)
230
				BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
-
 
231
				brandStockPrice.setBrandUrl((String) x.get("url"));
226
	 * x.get("url")); brandStockPrice.setRank(((Double) x.get("rank")).intValue());
232
				brandStockPrice.setRank(((Double) x.get("rank")).intValue());
227
	 * brandStockPrices.add(brandStockPrice); } });
233
				brandStockPrices.add(brandStockPrice);
228
	 * 
234
			}
-
 
235
		});
-
 
236
 
229
	 * return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x,
237
		return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
230
	 * y) -> x.getRank() - y.getRank()) .collect(Collectors.toList()); }
238
				.collect(Collectors.toList());
231
	 */
239
	}
232
 
240
 
233
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
241
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
234
	public String dashboard(HttpServletRequest request, Model model) throws Exception {
242
	public String dashboard(HttpServletRequest request, Model model) throws Exception {
235
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
243
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
236
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
244
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
Line 258... Line 266...
258
				model.addAttribute("fofoStore", fofoStore);
266
				model.addAttribute("fofoStore", fofoStore);
259
				model.addAttribute("partnerType", partnerType);
267
				model.addAttribute("partnerType", partnerType);
260
				model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
268
				model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
261
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
269
				model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
262
 
270
 
263
				// model.addAttribute("brandStockPrices",
-
 
264
				// this.getBrandStockPrices(loginDetails.getFofoId()));
271
				model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
265
				model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
272
				model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
266
				// this.setInvestments
273
				// this.setInvestments
267
				//
274
				//
268
				model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
275
				model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
269
				model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
276
				model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
Line 275... Line 282...
275
		}
282
		}
276
 
283
 
277
		LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
284
		LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
278
		LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
285
		LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
279
		double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
286
		double currentMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
280
				currentMonthEnd)/2;
287
				currentMonthEnd) / 2;
281
		double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
288
		double lastMonthRating = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
282
				currentMonthEnd)/2;
289
				currentMonthEnd) / 2;
283
		double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
290
		double ratingTillDate = hygieneDataRepository.selectRatingAvg(loginDetails.getFofoId(), currentMonthStart,
284
				currentMonthEnd)/2;
291
				currentMonthEnd) / 2;
285
		model.addAttribute("currentMonthRating", (float)Math.round(currentMonthRating*10)/10);
292
		model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
286
		model.addAttribute("lastMonthRating", (float)Math.round(lastMonthRating*10)/10);
293
		model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
287
		model.addAttribute("ratingTillDate", (float)Math.round(ratingTillDate*10)/10);
294
		model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
288
 
295
 
289
		long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
296
		long hygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), true, currentMonthStart,
290
				currentMonthEnd);
297
				currentMonthEnd);
291
 
298
 
292
		long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,
299
		long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(loginDetails.getFofoId(), false,