Subversion Repositories SmartDukaan

Rev

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

Rev 31129 Rev 31152
Line 1191... Line 1191...
1191
			throws Exception {
1191
			throws Exception {
1192
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1192
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1193
		String email = loginDetails.getEmailId();
1193
		String email = loginDetails.getEmailId();
1194
 
1194
 
1195
		Set<Integer> authfofoIds = new HashSet<>();
1195
		Set<Integer> authfofoIds = new HashSet<>();
1196
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1197
		authfofoIds = storeGuyMap.get(email);
1196
		authfofoIds = csService.getAuthFofoIds(email);
1198
 
-
 
1199
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
1200
		if (authfofoIds == null) {
-
 
1201
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1202
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1203
					.count() > 0) {
-
 
1204
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
1205
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1206
			}
-
 
1207
		}
-
 
1208
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
1197
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
1209
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1198
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1210
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1199
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1211
 
1200
 
1212
		Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
1201
		Map<Integer, CustomRetailer> fofoIdAndPartnerMap = retailerService.getFofoRetailers(false);
Line 1240... Line 1229...
1240
	@RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
1229
	@RequestMapping(value = "/getWarehouseWiseBrandStock", method = RequestMethod.GET)
1241
	public String getWarehouseWiseBrandStock(HttpServletRequest request, Model model,
1230
	public String getWarehouseWiseBrandStock(HttpServletRequest request, Model model,
1242
			@RequestParam List<Integer> warehouseId) throws Exception {
1231
			@RequestParam List<Integer> warehouseId) throws Exception {
1243
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1232
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1244
		String email = loginDetails.getEmailId();
1233
		String email = loginDetails.getEmailId();
1245
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1246
		Set<Integer> authfofoIds = storeGuyMap.get(email);
1234
		Set<Integer> authfofoIds = csService.getAuthFofoIds(email);
1247
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
1248
 
-
 
1249
		if (authfofoIds == null) {
-
 
1250
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1251
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1252
					.count() > 0) {
-
 
1253
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
1254
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1255
			}
-
 
1256
		}
-
 
1257
 
-
 
1258
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
1235
		Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
1259
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1236
				.selectActivePartnersByRetailerIds(new ArrayList<>(authfofoIds)).stream().collect(Collectors.groupingBy(
1260
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1237
						FofoStore::getWarehouseId, Collectors.mapping(FofoStore::getId, Collectors.toList())));
1261
		List<WarehouseWiseBrandStockModel> warehouseWiseBrandStock = new ArrayList<>();
1238
		List<WarehouseWiseBrandStockModel> warehouseWiseBrandStock = new ArrayList<>();
1262
		if (!warehouseId.contains(0)) {
1239
		if (!warehouseId.contains(0)) {
Line 1322... Line 1299...
1322
	public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand)
1299
	public String getWarehouseWiseBrandPartnerSale(HttpServletRequest request, Model model, @RequestParam String brand)
1323
			throws Exception {
1300
			throws Exception {
1324
 
1301
 
1325
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1302
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1326
		String email = loginDetails.getEmailId();
1303
		String email = loginDetails.getEmailId();
1327
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1328
		Set<Integer> authfofoIds = storeGuyMap.get(email);
-
 
1329
 
1304
 
1330
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
1305
		Set<Integer> authfofoIds = csService.getAuthFofoIds(email);
1331
		if (authfofoIds == null) {
-
 
1332
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1333
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1334
					.count() > 0) {
-
 
1335
				authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream()
-
 
1336
						.flatMap(x -> x.stream()).map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1337
			}
-
 
1338
		}
-
 
1339
 
1306
 
1340
		Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
1307
		Map<Integer, WarehouseWiseBrandSaleModel> warehouseWiseBrandPartnerSales = fofoStoreRepository
1341
				.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
1308
				.selectGroupByWarehouseBrandWisePartnerSale(brand, new ArrayList<>(authfofoIds)).stream()
1342
				.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
1309
				.collect(Collectors.toMap(x -> x.getWarehouseId(), x -> x));
1343
 
1310
 
Line 1406... Line 1373...
1406
	public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model,
1373
	public String getWarehouseBrandWiseItemSale(HttpServletRequest request, Model model,
1407
			@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1374
			@RequestParam List<Integer> warehouseId, @RequestParam String brand) throws Exception {
1408
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1375
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1409
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1376
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1410
		String email = loginDetails.getEmailId();
1377
		String email = loginDetails.getEmailId();
1411
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1412
		Set<Integer> authfofoIds = storeGuyMap.get(email);
1378
		Set<Integer> authfofoIds = csService.getAuthFofoIds(email);
1413
		Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository
1379
		Map<Integer, WarehouseBrandWiseItemSaleModel> branditemSalesMap = fofoStoreRepository
1414
				.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream()
1380
				.selectWarehouseBrandItemSale(warehouseId, brand, new ArrayList<>(authfofoIds)).stream()
1415
				.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
1381
				.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
1416
 
1382
 
1417
		List<WarehouseBrandItemUnbilledActivatedModel> unbilledItems = fofoStoreRepository
1383
		List<WarehouseBrandItemUnbilledActivatedModel> unbilledItems = fofoStoreRepository
Line 1787... Line 1753...
1787
	public String getMobileBrandWise(HttpServletRequest request, Model model) throws Exception {
1753
	public String getMobileBrandWise(HttpServletRequest request, Model model) throws Exception {
1788
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1754
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1789
		String email = loginDetails.getEmailId();
1755
		String email = loginDetails.getEmailId();
1790
 
1756
 
1791
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
1757
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
1792
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1793
 
-
 
1794
		Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
1758
		Set<Integer> fofoIds = csService.getAuthFofoIds(email);
1795
		if (emails.contains(authUser.getEmailId())) {
-
 
1796
			fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
-
 
1797
			LOGGER.info("fofoIds" + fofoIds);
-
 
1798
		}
-
 
1799
 
-
 
1800
		if (fofoIds == null) {
-
 
1801
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1802
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1803
					.count() > 0) {
-
 
1804
				fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
-
 
1805
						.map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1806
			}
-
 
1807
		}
-
 
1808
 
1759
 
1809
		Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
1760
		Map<String, BrandWisePartnerSaleModel> partnersBrandSaleMap = null;
1810
		partnersBrandSaleMap = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds))
1761
		partnersBrandSaleMap = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(new ArrayList<>(fofoIds))
1811
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1762
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1812
 
1763
 
Line 1840... Line 1791...
1840
	@RequestMapping(value = "/getAccessoriesBrandWise", method = RequestMethod.GET)
1791
	@RequestMapping(value = "/getAccessoriesBrandWise", method = RequestMethod.GET)
1841
	public String getAccessoriesBrandWise(HttpServletRequest request, Model model) throws Exception {
1792
	public String getAccessoriesBrandWise(HttpServletRequest request, Model model) throws Exception {
1842
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1793
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1843
		String email = loginDetails.getEmailId();
1794
		String email = loginDetails.getEmailId();
1844
 
1795
 
1845
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
1846
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1847
 
-
 
1848
		Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
1796
		Set<Integer> fofoIds = csService.getAuthFofoIds(email);
1849
		if (emails.contains(authUser.getEmailId())) {
-
 
1850
			fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
-
 
1851
			LOGGER.info("fofoIds" + fofoIds);
-
 
1852
		}
-
 
1853
 
-
 
1854
		if (fofoIds == null) {
-
 
1855
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
1856
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
1857
					.count() > 0) {
-
 
1858
				fofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
-
 
1859
						.map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
1860
			}
-
 
1861
		}
-
 
1862
 
1797
 
1863
		List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
1798
		List<BrandWisePartnerSaleModel> accessoriesBrandSales = null;
1864
 
1799
 
1865
		accessoriesBrandSales = fofoStoreRepository
1800
		accessoriesBrandSales = fofoStoreRepository
1866
				.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
1801
				.selectGroupByBrandAccesoriesWarehousePartnerSale(new ArrayList<>(fofoIds));
Line 1971... Line 1906...
1971
	}
1906
	}
1972
 
1907
 
1973
	@RequestMapping(value = "/getActivatedModelByBrand", method = RequestMethod.GET)
1908
	@RequestMapping(value = "/getActivatedModelByBrand", method = RequestMethod.GET)
1974
	public String getActivatedModelByBrand(HttpServletRequest request, Model model) throws Exception {
1909
	public String getActivatedModelByBrand(HttpServletRequest request, Model model) throws Exception {
1975
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1910
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1976
		List<Integer> fofoIds = getFofoIds(loginDetails);
1911
		Set<Integer> fofoIds = csService.getAuthFofoIds(loginDetails.getEmailId());
-
 
1912
 
1977
		List<BrandWiseActivatedModel> activatedModels = activatedImeiRepository
1913
		List<BrandWiseActivatedModel> activatedModels = activatedImeiRepository
1978
				.selectActivatedModelGroupByBrand(new ArrayList<>(fofoIds));
1914
				.selectActivatedModelGroupByBrand(new ArrayList<>(fofoIds));
1979
		model.addAttribute("activatedModels", activatedModels);
1915
		model.addAttribute("activatedModels", activatedModels);
1980
		return "activation-brandwise-report";
1916
		return "activation-brandwise-report";
1981
	}
1917
	}