Subversion Repositories SmartDukaan

Rev

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

Rev 28471 Rev 28472
Line 12... Line 12...
12
import java.time.format.DateTimeFormatter;
12
import java.time.format.DateTimeFormatter;
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Arrays;
14
import java.util.Arrays;
15
import java.util.Collections;
15
import java.util.Collections;
16
import java.util.HashMap;
16
import java.util.HashMap;
-
 
17
import java.util.HashSet;
17
import java.util.LinkedHashMap;
18
import java.util.LinkedHashMap;
18
import java.util.List;
19
import java.util.List;
19
import java.util.Map;
20
import java.util.Map;
20
import java.util.Map.Entry;
21
import java.util.Map.Entry;
21
import java.util.Optional;
22
import java.util.Optional;
Line 680... Line 681...
680
	@RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
681
	@RequestMapping(value = "/getWarehousePartners", method = RequestMethod.GET)
681
	public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId)
682
	public String warehousePartnersDetail(HttpServletRequest request, Model model, @RequestParam int warehouseId)
682
			throws Exception {
683
			throws Exception {
683
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
684
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
684
		String email = loginDetails.getEmailId();
685
		String email = loginDetails.getEmailId();
-
 
686
 
-
 
687
		Set<Integer> authfofoIds = new HashSet<>();
685
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
688
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
686
		Set<Integer> authfofoIds = storeGuyMap.get(email);
689
		authfofoIds = storeGuyMap.get(email);
687
 
690
 
-
 
691
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
692
		if (authfofoIds == null) {
-
 
693
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
694
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
695
					.count() > 0) {
-
 
696
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
697
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
698
			}
-
 
699
		}
688
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
700
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
689
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
701
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
690
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
702
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
691
 
703
 
692
		Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
704
		Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
Line 699... Line 711...
699
			 * .map(x -> x.getId()).collect(Collectors.toList());
711
			 * .map(x -> x.getId()).collect(Collectors.toList());
700
			 */
712
			 */
701
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
713
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
702
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
714
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
703
		} else {
715
		} else {
-
 
716
 
704
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream()
717
			List<Integer> fofoIds = new ArrayList<>(authfofoIds);
705
					.filter(x -> new ArrayList<>(authfofoIds).contains(x.getKey()))
718
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
706
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
719
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
707
		}
720
		}
708
 
721
 
709
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
722
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
710
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
723
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
Line 829... Line 842...
829
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
842
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
830
		String email = loginDetails.getEmailId();
843
		String email = loginDetails.getEmailId();
831
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
844
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
832
		Set<Integer> authfofoIds = storeGuyMap.get(email);
845
		Set<Integer> authfofoIds = storeGuyMap.get(email);
833
 
846
 
-
 
847
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
848
		if (authfofoIds == null) {
-
 
849
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
850
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
851
					.count() > 0) {
-
 
852
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
853
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
854
			}
-
 
855
		}
-
 
856
 
834
		Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
857
		Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
835
				.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
858
				.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
836
				.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
859
				.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
837
 
860
 
838
		List<WarehouseWiseBrandUnbilledActivatedModel> unbilledStock = fofoStoreRepository
861
		List<WarehouseWiseBrandUnbilledActivatedModel> unbilledStock = fofoStoreRepository
Line 872... Line 895...
872
			@RequestParam String brand) throws Exception {
895
			@RequestParam String brand) throws Exception {
873
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
896
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
874
		String email = loginDetails.getEmailId();
897
		String email = loginDetails.getEmailId();
875
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
898
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
876
		Set<Integer> authfofoIds = storeGuyMap.get(email);
899
		Set<Integer> authfofoIds = storeGuyMap.get(email);
-
 
900
 
-
 
901
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
902
		if (authfofoIds == null) {
-
 
903
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
904
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
905
					.count() > 0) {
-
 
906
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
907
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
908
			}
-
 
909
		}
877
		List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
910
		List<WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
878
				.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds));
911
				.selectGroupByWarehouseAccesoriesBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds));
879
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
912
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
880
 
913
 
881
		Set<String> brands = inventoryService.getAllTagListingBrands();
914
		Set<String> brands = inventoryService.getAllTagListingBrands();