Subversion Repositories SmartDukaan

Rev

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

Rev 29746 Rev 29875
Line 266... Line 266...
266
	@Autowired
266
	@Autowired
267
	private OrderRepository orderRepository;
267
	private OrderRepository orderRepository;
268
 
268
 
269
	@Autowired
269
	@Autowired
270
	private FofoUser fofoUser;
270
	private FofoUser fofoUser;
271
	
271
 
272
	@Autowired
272
	@Autowired
273
	private ActivatedImeiRepository activatedImeiRepository;
273
	private ActivatedImeiRepository activatedImeiRepository;
274
 
274
 
275
	@Autowired
275
	@Autowired
276
	private Mongo mongoClient;
276
	private Mongo mongoClient;
277
 
277
 
278
	@Autowired
278
	@Autowired
279
	private SchemeInOutRepository schemeInOutRepository;
279
	private SchemeInOutRepository schemeInOutRepository;
280
	
280
 
281
	@Autowired
281
	@Autowired
282
	private LineItemRepository lineItemRepository;
282
	private LineItemRepository lineItemRepository;
283
	
283
 
284
	@Autowired
284
	@Autowired
285
	private FofoLineItemRepository fofoLineItemRepository;
285
	private FofoLineItemRepository fofoLineItemRepository;
286
 
286
 
287
	@Autowired
287
	@Autowired
288
	private PositionRepository positionRepository;
288
	private PositionRepository positionRepository;
Line 351... Line 351...
351
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
351
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
352
		int dayOfMonth = curDate.getDayOfMonth();
352
		int dayOfMonth = curDate.getDayOfMonth();
353
		for (int i = 1; i <= 6; i++) {
353
		for (int i = 1; i <= 6; i++) {
354
			LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
354
			LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
355
			int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
355
			int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
356
			LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth,startOfMonth.plusMonths(1));
356
			LOGGER.info("Start of previous Month {}, start of next month Month {}", startOfMonth,
-
 
357
					startOfMonth.plusMonths(1));
357
			double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
358
			double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth,
358
					startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
359
					startOfMonth.plusMonths(1), loginDetails.getFofoId(), false).get(fofoId);
359
 
360
 
360
			double mtdSales = fofoOrderItemRepository
361
			double mtdSales = fofoOrderItemRepository
361
					.selectSumMopGroupByRetailer(startOfMonth,
362
					.selectSumMopGroupByRetailer(startOfMonth,
Line 368... Line 369...
368
			ms.setMtdSales(fofoUser.format((long) mtdSales));
369
			ms.setMtdSales(fofoUser.format((long) mtdSales));
369
			ms.setMonthlySales(fofoUser.format(((long) monthSales)));
370
			ms.setMonthlySales(fofoUser.format(((long) monthSales)));
370
			ms.setPartnerType(partnerType);
371
			ms.setPartnerType(partnerType);
371
			ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
372
			ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
372
			monthSaleMap.put(i, ms);
373
			monthSaleMap.put(i, ms);
373
       }
374
		}
374
 
375
 
375
		model.addAttribute("monthSales", monthSaleMap);
376
		model.addAttribute("monthSales", monthSaleMap);
376
		return "monthSales";
377
		return "monthSales";
377
	}
378
	}
378
 
379
 
Line 382... Line 383...
382
		String email = loginDetails.getEmailId();
383
		String email = loginDetails.getEmailId();
383
		int fofoId = loginDetails.getFofoId();
384
		int fofoId = loginDetails.getFofoId();
384
 
385
 
385
		LocalDateTime startDate = LocalDate.now().withDayOfYear(1).atStartOfDay();
386
		LocalDateTime startDate = LocalDate.now().withDayOfYear(1).atStartOfDay();
386
		LocalDateTime endtDate = LocalDateTime.now();
387
		LocalDateTime endtDate = LocalDateTime.now();
387
		OnlineDeliveredOrderSum onlineDeliveredOrderSum = pendingOrderItemRepository.selectSumSellingPriceOnlineOrder(fofoId, startDate, endtDate);
388
		OnlineDeliveredOrderSum onlineDeliveredOrderSum = pendingOrderItemRepository
-
 
389
				.selectSumSellingPriceOnlineOrder(fofoId, startDate, endtDate);
388
    	LOGGER.info("onlineDeliveredOrderSum" + onlineDeliveredOrderSum.getSellingPrice());
390
		LOGGER.info("onlineDeliveredOrderSum" + onlineDeliveredOrderSum.getSellingPrice());
389
 
391
 
390
		long countOrder = pendingOrderRepository.pendingOrderCount(fofoId, OrderStatus.PROCESSING);
392
		long countOrder = pendingOrderRepository.pendingOrderCount(fofoId, OrderStatus.PROCESSING);
391
		LOGGER.info("countOrder" + countOrder);
393
		LOGGER.info("countOrder" + countOrder);
392
		
394
 
393
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
395
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
394
		
396
 
395
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
397
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
396
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
398
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
397
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
399
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
398
		
-
 
399
		
400
 
400
		List<Order> order =orderRepository.selectOrders(fofoId,orderStatus);	
401
		List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
-
 
402
		List<Integer> submittedOrderIds = order.stream()
401
	    List<Integer>	submittedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING).map(x -> x.getId()).collect(Collectors.toList());
403
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING)
-
 
404
				.map(x -> x.getId()).collect(Collectors.toList());
-
 
405
		List<Integer> billedOrderIds = order.stream()
402
	    List<Integer>	billedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId()).collect(Collectors.toList());
406
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId())
-
 
407
				.collect(Collectors.toList());
-
 
408
		List<Integer> shippedOrderIds = order.stream()
403
	    List<Integer>	shippedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH).map(x -> x.getId()).collect(Collectors.toList());
409
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH)
-
 
410
				.map(x -> x.getId()).collect(Collectors.toList());
404
	    
411
 
405
	    LOGGER.info("billedOrderIds {}", billedOrderIds);
412
		LOGGER.info("billedOrderIds {}", billedOrderIds);
406
	    LOGGER.info("shippedOrderIds {}", shippedOrderIds);
413
		LOGGER.info("shippedOrderIds {}", shippedOrderIds);
407
	    
-
 
408
	    
414
 
409
	    List<Order> grnPendingOrder =orderRepository.selectPendingGrnOrders(fofoId);	
415
		List<Order> grnPendingOrder = orderRepository.selectPendingGrnOrders(fofoId);
410
	    List<Integer>	grnOrderIds = grnPendingOrder.stream().map(x -> x.getId()).collect(Collectors.toList());
416
		List<Integer> grnOrderIds = grnPendingOrder.stream().map(x -> x.getId()).collect(Collectors.toList());
411
	    model.addAttribute("grnOrderIds", grnOrderIds);
417
		model.addAttribute("grnOrderIds", grnOrderIds);
412
	    if(!grnOrderIds.isEmpty()) {
418
		if (!grnOrderIds.isEmpty()) {
413
	    
419
 
414
	    List<LineItem>  grnPendingLineItem = lineItemRepository.selectLineItem(grnOrderIds);
420
			List<LineItem> grnPendingLineItem = lineItemRepository.selectLineItem(grnOrderIds);
415
	    Map<Integer, LineItem> grnPendingLineMap = grnPendingLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
421
			Map<Integer, LineItem> grnPendingLineMap = grnPendingLineItem.stream()
416
	    
422
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
417
	    
423
 
418
	    long grnPendingCount = grnPendingLineMap.entrySet().stream().filter(x -> x.getKey() > 0 ).count();
424
			long grnPendingCount = grnPendingLineMap.entrySet().stream().filter(x -> x.getKey() > 0).count();
-
 
425
			long grnPendingValue = grnPendingLineMap.entrySet().stream()
419
		   long grnPendingValue = grnPendingLineMap.entrySet().stream().mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
426
					.mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
420
		   model.addAttribute("grnPendingCount", grnPendingCount);
427
			model.addAttribute("grnPendingCount", grnPendingCount);
421
		   model.addAttribute("grnPendingValue", grnPendingValue);
428
			model.addAttribute("grnPendingValue", grnPendingValue);
422
		  
429
 
423
		  
430
		}
424
	    }
-
 
425
	    
431
 
426
	    if(!submittedOrderIds.isEmpty()) {
432
		if (!submittedOrderIds.isEmpty()) {
427
	    
433
 
428
	    List<LineItem>  submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
434
			List<LineItem> submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
429
	    Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
435
			Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream()
-
 
436
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
430
	    LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
437
			LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
431
	      
438
 
432
	   long submittedCount = submittedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0 ).count();
439
			long submittedCount = submittedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0).count();
-
 
440
			long submittedValue = submittedLineItemMap.entrySet().stream()
433
	   long submittedValue = submittedLineItemMap.entrySet().stream().mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
441
					.mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
434
	   model.addAttribute("submittedCount", submittedCount);
442
			model.addAttribute("submittedCount", submittedCount);
435
	   model.addAttribute("submittedValue", submittedValue);
443
			model.addAttribute("submittedValue", submittedValue);
436
	   LOGGER.info("submittedCount {}", submittedCount);
444
			LOGGER.info("submittedCount {}", submittedCount);
437
	    }
445
		}
438
	    if(!billedOrderIds.isEmpty()) {
446
		if (!billedOrderIds.isEmpty()) {
439
	    List<LineItem>  billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
447
			List<LineItem> billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
440
	    Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
448
			Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream()
-
 
449
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
441
	    LOGGER.info("billedLineItemMap {}", billedLineItemMap);
450
			LOGGER.info("billedLineItemMap {}", billedLineItemMap);
442
	    long billedCount = billedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0 ).count();
451
			long billedCount = billedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0).count();
443
		   model.addAttribute("billedCount", billedCount);
452
			model.addAttribute("billedCount", billedCount);
444
		   LOGGER.info("billedCount {}", billedCount);
453
			LOGGER.info("billedCount {}", billedCount);
445
		   
454
 
-
 
455
			long billedValue = billedLineItemMap.entrySet().stream()
446
		   long billedValue = billedLineItemMap.entrySet().stream().mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
456
					.mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
447
		   model.addAttribute("billedValue", billedValue);
457
			model.addAttribute("billedValue", billedValue);
448
	    }
458
		}
449
	    
459
 
450
	    if(!shippedOrderIds.isEmpty()) {
460
		if (!shippedOrderIds.isEmpty()) {
451
	    List<LineItem>  shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
461
			List<LineItem> shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
452
	    Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
462
			Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream()
-
 
463
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
453
	    LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
464
			LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
454
	    
465
 
455
	    long shippedCount = shippedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0 ).count();
466
			long shippedCount = shippedLineItemMap.entrySet().stream().filter(x -> x.getKey() > 0).count();
456
		   model.addAttribute("shippedCount", shippedCount);
467
			model.addAttribute("shippedCount", shippedCount);
457
		   LOGGER.info("shippedCount {}", shippedCount);
468
			LOGGER.info("shippedCount {}", shippedCount);
458
		   
469
 
-
 
470
			long shippedValue = shippedLineItemMap.entrySet().stream()
459
		   long shippedValue = shippedLineItemMap.entrySet().stream().mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
471
					.mapToLong(x -> x.getValue().getTotalPrice().longValue()).sum();
460
		   model.addAttribute("shippedValue", shippedValue);
472
			model.addAttribute("shippedValue", shippedValue);
461
	    }
-
 
462
	   
473
		}
463
	    
-
 
464
	    
-
 
465
	 
474
 
466
		model.addAttribute("countOrder", countOrder);
475
		model.addAttribute("countOrder", countOrder);
467
		model.addAttribute("onlineDeliveredOrderSum", onlineDeliveredOrderSum.getSellingPrice());
476
		model.addAttribute("onlineDeliveredOrderSum", onlineDeliveredOrderSum.getSellingPrice());
468
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
477
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
469
		model.addAttribute("isAdmin", isAdmin);
478
		model.addAttribute("isAdmin", isAdmin);
470
 
479
 
Line 565... Line 574...
565
		 */
574
		 */
566
 
575
 
567
		return "dashboard1";
576
		return "dashboard1";
568
 
577
 
569
	}
578
	}
570
	
579
 
571
	@RequestMapping(value = "/getGrnPendingOrderStatus", method = RequestMethod.GET)
580
	@RequestMapping(value = "/getGrnPendingOrderStatus", method = RequestMethod.GET)
572
	public String getGrnPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
581
	public String getGrnPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
573
		
-
 
574
		
582
 
575
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
583
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
576
		int fofoId = loginDetails.getFofoId();
584
		int fofoId = loginDetails.getFofoId();
577
        ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
585
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
578
				
586
 
579
		List<Order> order =orderRepository.selectPendingGrnOrders(fofoId);	
587
		List<Order> order = orderRepository.selectPendingGrnOrders(fofoId);
580
	    List<Integer>	orderIds = order.stream().map(x -> x.getId()).collect(Collectors.toList());
588
		List<Integer> orderIds = order.stream().map(x -> x.getId()).collect(Collectors.toList());
581
	    model.addAttribute("grnOrderIds", orderIds);
589
		model.addAttribute("grnOrderIds", orderIds);
582
	   
590
 
583
	    if(!orderIds.isEmpty()) {
591
		if (!orderIds.isEmpty()) {
584
	    
592
 
585
	    List<LineItem>  grnPendingLineItem = lineItemRepository.selectLineItem(orderIds);
593
			List<LineItem> grnPendingLineItem = lineItemRepository.selectLineItem(orderIds);
586
	    Map<Integer, LineItem> grnPendingLineMap = grnPendingLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
594
			Map<Integer, LineItem> grnPendingLineMap = grnPendingLineItem.stream()
-
 
595
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
587
	    LOGGER.info("grnPendingLineMap {}", grnPendingLineMap);
596
			LOGGER.info("grnPendingLineMap {}", grnPendingLineMap);
588
	    model.addAttribute("grnPendingLineMap", grnPendingLineMap);
597
			model.addAttribute("grnPendingLineMap", grnPendingLineMap);
589
	    Map<Integer, Order> orderMap = order.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
598
			Map<Integer, Order> orderMap = order.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
590
 
599
 
591
	    model.addAttribute("orderMap", orderMap);
600
			model.addAttribute("orderMap", orderMap);
592
		  
601
 
593
	    }
602
		}
594
	   
603
 
595
		return "purchase-grn-order-status";
604
		return "purchase-grn-order-status";
596
	}
605
	}
597
	
606
 
598
	@RequestMapping(value = "/getPendingOrderStatus", method = RequestMethod.GET)
607
	@RequestMapping(value = "/getPendingOrderStatus", method = RequestMethod.GET)
599
	public String getPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
608
	public String getPendingOrderStatus(HttpServletRequest request, Model model) throws Exception {
600
		
-
 
601
		
609
 
602
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
610
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
603
		int fofoId = loginDetails.getFofoId();
611
		int fofoId = loginDetails.getFofoId();
604
        ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
612
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
605
		
613
 
606
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
614
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING);
607
		
-
 
608
		
615
 
609
		List<Order> order =orderRepository.selectOrders(fofoId,orderStatus);	
616
		List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
-
 
617
		List<Integer> submittedOrderIds = order.stream()
610
	    List<Integer>	submittedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING).map(x -> x.getId()).collect(Collectors.toList());
618
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING)
-
 
619
				.map(x -> x.getId()).collect(Collectors.toList());
611
	    model.addAttribute("submittedOrderIds", submittedOrderIds);
620
		model.addAttribute("submittedOrderIds", submittedOrderIds);
612
	    if(!submittedOrderIds.isEmpty()) {
621
		if (!submittedOrderIds.isEmpty()) {
613
	    
622
 
614
	    List<LineItem>  submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
623
			List<LineItem> submittedLineItem = lineItemRepository.selectLineItem(submittedOrderIds);
615
	    Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
624
			Map<Integer, LineItem> submittedLineItemMap = submittedLineItem.stream()
-
 
625
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
616
	    LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
626
			LOGGER.info("submittedLineItemMap {}", submittedLineItemMap);
617
	    model.addAttribute("submittedLineItemMap", submittedLineItemMap);
627
			model.addAttribute("submittedLineItemMap", submittedLineItemMap);
618
		    }
628
		}
619
	   
629
 
620
		return "purchase-pending-order-status";
630
		return "purchase-pending-order-status";
621
	}
631
	}
622
	
632
 
623
	@RequestMapping(value = "/getBilledOrderStatus", method = RequestMethod.GET)
633
	@RequestMapping(value = "/getBilledOrderStatus", method = RequestMethod.GET)
624
	public String getBilledOrderStatus(HttpServletRequest request, Model model) throws Exception {
634
	public String getBilledOrderStatus(HttpServletRequest request, Model model) throws Exception {
625
		
-
 
626
		
635
 
627
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
636
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
628
		int fofoId = loginDetails.getFofoId();
637
		int fofoId = loginDetails.getFofoId();
629
        ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
638
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
630
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
639
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.BILLED);
631
			
640
 
632
		List<Order> order =orderRepository.selectOrders(fofoId,orderStatus);	
641
		List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
-
 
642
		List<Integer> billedOrderIds = order.stream()
633
	    	    List<Integer>	billedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId()).collect(Collectors.toList());
643
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.BILLED).map(x -> x.getId())
-
 
644
				.collect(Collectors.toList());
634
	     LOGGER.info("billedOrderIds {}", billedOrderIds);
645
		LOGGER.info("billedOrderIds {}", billedOrderIds);
635
	 	    model.addAttribute("billedOrderIds", billedOrderIds);
646
		model.addAttribute("billedOrderIds", billedOrderIds);
636
	  
647
 
637
	    if(!billedOrderIds.isEmpty()) {
648
		if (!billedOrderIds.isEmpty()) {
638
	    List<LineItem>  billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
649
			List<LineItem> billedLineItem = lineItemRepository.selectLineItem(billedOrderIds);
639
	    Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
650
			Map<Integer, LineItem> billedLineItemMap = billedLineItem.stream()
-
 
651
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
640
	    LOGGER.info("billedLineItemMap {}", billedLineItemMap);
652
			LOGGER.info("billedLineItemMap {}", billedLineItemMap);
641
	    model.addAttribute("billedLineItemMap", billedLineItemMap);
653
			model.addAttribute("billedLineItemMap", billedLineItemMap);
642
	    }
654
		}
643
	   
655
 
644
		return "purchase-billed-order-status";
656
		return "purchase-billed-order-status";
645
	}
657
	}
-
 
658
 
646
	@RequestMapping(value = "/getShippedOrderStatus", method = RequestMethod.GET)
659
	@RequestMapping(value = "/getShippedOrderStatus", method = RequestMethod.GET)
647
	public String getShippedOrderStatus(HttpServletRequest request, Model model) throws Exception {
660
	public String getShippedOrderStatus(HttpServletRequest request, Model model) throws Exception {
648
		
-
 
649
		
661
 
650
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
662
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
651
		int fofoId = loginDetails.getFofoId();
663
		int fofoId = loginDetails.getFofoId();
652
        ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
664
		ArrayList<in.shop2020.model.v1.order.OrderStatus> orderStatus = new ArrayList<>();
653
		
665
 
654
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
666
		orderStatus.add(in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH);
655
		
-
 
656
		
667
 
657
		List<Order> order =orderRepository.selectOrders(fofoId,orderStatus);	
668
		List<Order> order = orderRepository.selectOrders(fofoId, orderStatus);
-
 
669
		List<Integer> shippedOrderIds = order.stream()
658
	   	    List<Integer>	shippedOrderIds = order.stream().filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH).map(x -> x.getId()).collect(Collectors.toList());
670
				.filter(x -> x.getStatus() == in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH)
-
 
671
				.map(x -> x.getId()).collect(Collectors.toList());
659
	    	  	    model.addAttribute("shippedOrderIds", shippedOrderIds);
672
		model.addAttribute("shippedOrderIds", shippedOrderIds);
660
	    LOGGER.info("shippedOrderIds {}", shippedOrderIds);
673
		LOGGER.info("shippedOrderIds {}", shippedOrderIds);
661
	    
-
 
662
	 
674
 
663
	    if(!shippedOrderIds.isEmpty()) {
675
		if (!shippedOrderIds.isEmpty()) {
664
	    List<LineItem>  shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
676
			List<LineItem> shippedLineItem = lineItemRepository.selectLineItem(shippedOrderIds);
665
	    Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
677
			Map<Integer, LineItem> shippedLineItemMap = shippedLineItem.stream()
-
 
678
					.collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
666
	    LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
679
			LOGGER.info("shippedLineItemMap {}", shippedLineItemMap);
667
	    
680
 
668
	    model.addAttribute("shippedLineItemMap", shippedLineItemMap);
681
			model.addAttribute("shippedLineItemMap", shippedLineItemMap);
669
	    }
682
		}
670
		return "purchase-shipped-order-status";
683
		return "purchase-shipped-order-status";
671
	}
684
	}
672
 
685
 
673
	@RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
686
	@RequestMapping(value = "/getMonthsInvestment", method = RequestMethod.GET)
674
	public String getMonthsInvestment(HttpServletRequest request,
687
	public String getMonthsInvestment(HttpServletRequest request,
Line 806... Line 819...
806
		int fofoId = loginDetails.getFofoId();
819
		int fofoId = loginDetails.getFofoId();
807
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
820
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
808
 
821
 
809
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
822
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(6);
810
		LocalDateTime startfMonthTotal = curDate.withDayOfMonth(1).minusMonths(12);
823
		LocalDateTime startfMonthTotal = curDate.withDayOfMonth(1).minusMonths(12);
811
		LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(6);
824
		LocalDateTime endMonthTotal = curDate.withDayOfMonth(1).minusMonths(5);
812
 
825
 
-
 
826
		LOGGER.info("startfMonthTotal" + startfMonthTotal);
-
 
827
 
-
 
828
		LOGGER.info("endMonthTotal" + endMonthTotal);
813
		List<YearMonth> yms = new ArrayList<YearMonth>();
829
		List<YearMonth> yms = new ArrayList<YearMonth>();
814
 
830
 
815
		for (int i = 1; i <= 6; i++) {
831
		for (int i = 0; i <= 5; i++) {
816
			yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
832
			yms.add(YearMonth.from(curDate.withDayOfMonth(1).minusMonths(i)));
817
		}
833
		}
818
		Collections.reverse(yms);
834
		Collections.reverse(yms);
819
		model.addAttribute("yms", yms);
835
		model.addAttribute("yms", yms);
820
		LOGGER.info("ym" + yms);
836
		LOGGER.info("ym" + yms);
Line 865... Line 881...
865
 
881
 
866
		model.addAttribute("brands", brands);
882
		model.addAttribute("brands", brands);
867
 
883
 
868
		for (String brand : brands) {
884
		for (String brand : brands) {
869
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
885
			Map<YearMonth, Double> yearMonthValue = brandMonthValue.get(brand);
870
			for (int i = 6; i >= 1; i--) {
886
			for (int i = 5; i >= 0; i--) {
871
 
887
 
872
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
888
				LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
873
 
889
 
874
				if (yearMonthValue != null) {
890
				if (yearMonthValue != null) {
875
					if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {
891
					if (yearMonthValue.get(YearMonth.from(startMonth)) == null) {