Subversion Repositories SmartDukaan

Rev

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

Rev 24276 Rev 24288
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.io.IOException;
3
import java.io.IOException;
4
import java.net.URISyntaxException;
4
import java.net.URISyntaxException;
-
 
5
import java.time.DayOfWeek;
-
 
6
import java.time.LocalDate;
5
import java.time.LocalDateTime;
7
import java.time.LocalDateTime;
-
 
8
import java.time.temporal.TemporalAdjusters;
-
 
9
import java.time.temporal.WeekFields;
-
 
10
import java.util.Collection;
6
import java.util.List;
11
import java.util.List;
-
 
12
import java.util.stream.Collectors;
7
 
13
 
8
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpServletRequest;
9
 
15
 
-
 
16
import org.apache.commons.lang3.StringUtils;
10
import org.apache.logging.log4j.LogManager;
17
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.Logger;
18
import org.apache.logging.log4j.Logger;
-
 
19
import org.apache.solr.common.util.Utils;
12
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.beans.factory.annotation.Value;
21
import org.springframework.beans.factory.annotation.Value;
14
import org.springframework.stereotype.Controller;
22
import org.springframework.stereotype.Controller;
15
import org.springframework.transaction.annotation.Transactional;
23
import org.springframework.transaction.annotation.Transactional;
16
import org.springframework.ui.Model;
24
import org.springframework.ui.Model;
Line 20... Line 28...
20
 
28
 
21
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
29
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
22
import com.spice.profitmandi.common.model.ProfitMandiConstants;
30
import com.spice.profitmandi.common.model.ProfitMandiConstants;
23
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
31
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
24
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
32
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
-
 
33
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
25
import com.spice.profitmandi.dao.entity.transaction.Order;
34
import com.spice.profitmandi.dao.entity.transaction.Order;
26
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
35
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
27
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
36
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
28
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
37
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
-
 
38
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
29
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
39
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
30
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
40
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
31
import com.spice.profitmandi.service.authentication.RoleManager;
41
import com.spice.profitmandi.service.authentication.RoleManager;
32
import com.spice.profitmandi.service.inventory.InventoryService;
42
import com.spice.profitmandi.service.inventory.InventoryService;
33
import com.spice.profitmandi.service.slab.TargetSlabService;
43
import com.spice.profitmandi.service.slab.TargetSlabService;
Line 44... Line 54...
44
	@Value("${web.api.host}")
54
	@Value("${web.api.host}")
45
	private String webApiHost;
55
	private String webApiHost;
46
 
56
 
47
	@Value("${web.api.scheme}")
57
	@Value("${web.api.scheme}")
48
	private String webApiScheme;
58
	private String webApiScheme;
49
	
59
 
50
	@Value("${web.api.root}")
60
	@Value("${web.api.root}")
51
	private String webApiRoot;
61
	private String webApiRoot;
52
 
62
 
53
	@Value("${web.api.port}")
63
	@Value("${web.api.port}")
54
	private int webApiPort;
64
	private int webApiPort;
55
 
65
 
56
 
-
 
57
	@Autowired
66
	@Autowired
58
	private CookiesProcessor cookiesProcessor;
67
	private CookiesProcessor cookiesProcessor;
59
 
68
 
60
	@Autowired
69
	@Autowired
61
	private RoleManager roleManager;
70
	private RoleManager roleManager;
Line 66... Line 75...
66
	@Autowired
75
	@Autowired
67
	private WalletService walletService;
76
	private WalletService walletService;
68
 
77
 
69
	@Autowired
78
	@Autowired
70
	private InventoryService inventoryService;
79
	private InventoryService inventoryService;
71
	
80
 
72
	@Autowired
81
	@Autowired
73
	private TargetSlabService targetSlabService;
82
	private TargetSlabService targetSlabService;
74
 
83
 
75
	@Autowired
84
	@Autowired
76
	private OrderRepository orderRepository;
85
	private OrderRepository orderRepository;
77
	
86
 
78
	@Autowired
87
	@Autowired
79
	private PurchaseReturnItemRepository purchaseReturnItemRepository;
88
	private PurchaseReturnItemRepository purchaseReturnItemRepository;
-
 
89
 
-
 
90
	@Autowired
-
 
91
	private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
80
	
92
 
81
	/*
93
	/*
82
	 * @Autowired private ScanRepository scanRepository;
94
	 * @Autowired private ScanRepository scanRepository;
83
	 */
95
	 */
84
 
96
 
85
	@Autowired
97
	@Autowired
Line 217... Line 229...
217
				model.addAttribute("size", size);
229
				model.addAttribute("size", size);
218
				LOGGER.info("sizeOriginal {}", size);
230
				LOGGER.info("sizeOriginal {}", size);
219
 
231
 
220
			}
232
			}
221
		}
233
		}
-
 
234
		LocalDate endDate = LocalDate.now().minusDays(1);
-
 
235
		LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-
 
236
		LocalDate startDate = weekStartDate.minusWeeks(3);
-
 
237
		List<PartnerDailyInvestment> dailyInvestments = partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate);
-
 
238
		Collection<Integer> investmentMaintained = dailyInvestments.stream().collect(Collectors.groupingBy(
-
 
239
				x->x.getDate().get(WeekFields.ISO.weekOfYear()), 
-
 
240
				Collectors.summingInt(x1-> {return x1.isComplete()?1:0;})
-
 
241
		)).values();
-
 
242
		
-
 
243
		model.addAttribute("investmentMaintained", Utils.toJSONString(investmentMaintained));
222
		model.addAttribute("sale", sale);
244
		model.addAttribute("sale", sale);
223
		model.addAttribute("walletAmount", walletAmount);
245
		model.addAttribute("walletAmount", walletAmount);
224
		model.addAttribute("inStockAmount", inStockAmount);
246
		model.addAttribute("inStockAmount", inStockAmount);
225
		model.addAttribute("unbilledStockAmount", unbilledStockAmount);
247
		model.addAttribute("unbilledStockAmount", unbilledStockAmount);
226
		model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
248
		model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
Line 244... Line 266...
244
		// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
266
		// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
245
		// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
267
		// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
246
		return "dashboard";
268
		return "dashboard";
247
	}
269
	}
248
 
270
 
249
	//This method is currently hardcoded to faciliate watches sold as gift.
271
	// This method is currently hardcoded to faciliate watches sold as gift.
250
	private boolean hasGift(int fofoId) {
272
	private boolean hasGift(int fofoId) {
251
		try {
273
		try {
252
			return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
274
			return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
-
 
275
					.getAvailability() > 0;
253
		} catch (ProfitMandiBusinessException e) {
276
		} catch (ProfitMandiBusinessException e) {
254
			return false;
277
			return false;
255
		}
278
		}
256
	}
279
	}
-
 
280
 
257
	@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
281
	@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
258
	public String getPaginatedNotificationData(HttpServletRequest request,
282
	public String getPaginatedNotificationData(HttpServletRequest request,
259
			@RequestParam(name = "offset", defaultValue = "0") int offset,
283
			@RequestParam(name = "offset", defaultValue = "0") int offset,
260
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
284
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
261
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
285
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
Line 300... Line 324...
300
			}
324
			}
301
		}
325
		}
302
 
326
 
303
		return "dashboard-paginated";
327
		return "dashboard-paginated";
304
	}
328
	}
-
 
329
 
305
	@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
330
	@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
306
	public String contactUs(HttpServletRequest request, Model model) throws Throwable {
331
	public String contactUs(HttpServletRequest request, Model model) throws Throwable {
307
		model.addAttribute("appContextPath", request.getContextPath());
332
		model.addAttribute("appContextPath", request.getContextPath());
308
		return "contact-us";
333
		return "contact-us";
309
	}
334
	}
310
 
335
 
311
	/*
336
	/*
312
	 * private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
337
	 * private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
313
	 * paymentOptionIds =
338
	 * paymentOptionIds =
314
	 * fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId)
339
	 * fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
315
	 * ; if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
340
	 * if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
316
	 * paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
341
	 * paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
317
	 */
342
	 */
318
 
343
 
319
	@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
344
	@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
320
	public String inactiveNotificationData(HttpServletRequest request,
345
	public String inactiveNotificationData(HttpServletRequest request,