Subversion Repositories SmartDukaan

Rev

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

Rev 27100 Rev 27102
Line 263... Line 263...
263
	private PartnerTypeChangeRepository partnerTypeChangeRepository;
263
	private PartnerTypeChangeRepository partnerTypeChangeRepository;
264
	@Autowired
264
	@Autowired
265
	private SchemeService schemeService;
265
	private SchemeService schemeService;
266
 
266
 
267
	private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
267
	private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
268
			"adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com",
268
			"adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com",
269
			"mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
269
			"ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "hemant.kaura@smartdukaan.com",
270
			"hemant.kaura@smartdukaan.com", "rajat.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
270
			"rajat.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "prakash.rai@smartdukaan.com" };
271
			"prakash.rai@smartdukaan.com" };
-
 
272
 
271
 
273
	private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
272
	private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
274
			"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com",
273
			"prakash.rai@smartdukaan.com", "tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com",
275
			"kuldeep.kumar@smartdukaan.com" };
274
			"kuldeep.kumar@smartdukaan.com" };
276
 
275
 
Line 1959... Line 1958...
1959
 
1958
 
1960
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
1959
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
1961
				.collect(Collectors.toList());
1960
				.collect(Collectors.toList());
1962
		Map<Integer, List<FocusedModelShortageModel>> focusedModelShortageReportMap = new HashMap<>();
1961
		Map<Integer, List<FocusedModelShortageModel>> focusedModelShortageReportMap = new HashMap<>();
1963
		for (Integer fofoId : fofoIds) {
1962
		for (Integer fofoId : fofoIds) {
1964
			if (!focusedModelShortageReportMap.containsKey(fofoId)) {
1963
			List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
1965
				focusedModelShortageReportMap.put(fofoId, new ArrayList<>());
1964
			focusedModelShortageReportMap.put(fofoId, focusedModelShortageList);
1966
			}
-
 
1967
			CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1965
			CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1968
			Map<Integer, Integer> processingOrderMap = null;
1966
			Map<Integer, Integer> processingOrderMap = null;
1969
			Map<Integer, Integer> catalogIdAndQtyMap = null;
1967
			Map<Integer, Integer> catalogIdAndQtyMap = null;
1970
			Map<Integer, Integer> grnPendingOrdersMap = null;
1968
			Map<Integer, Integer> grnPendingOrdersMap = null;
1971
 
1969
 
Line 2003... Line 2001...
2003
					.collect(Collectors.toList());
2001
					.collect(Collectors.toList());
2004
 
2002
 
2005
			List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
2003
			List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
2006
					.collect(Collectors.toList());
2004
					.collect(Collectors.toList());
2007
			LOGGER.info("regionIds" + regionIds);
2005
			LOGGER.info("regionIds" + regionIds);
-
 
2006
			if (regionIds.size() == 0) {
-
 
2007
				LOGGER.info("No region found for partner {}", fofoId);
-
 
2008
				continue;
-
 
2009
			}
-
 
2010
			/*
-
 
2011
			 * List<Integer> focusedModelCatalogId =
2008
			List<Integer> focusedModelCatalogId = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
2012
			 * focusedModelRepository.selectAllByRegionIds(regionIds).stream() .map(x ->
2009
					.map(x -> x.getCatalogId()).collect(Collectors.toList());
2013
			 * x.getCatalogId()).collect(Collectors.toList());
2010
			LOGGER.info("focusedModelCatalogId" + focusedModelCatalogId);
2014
			 * LOGGER.info("focusedModelCatalogId" + focusedModelCatalogId); Map<String,
2011
			Map<String, Object> equalsMap = new HashMap<>();
-
 
2012
			equalsMap.put("categoryId", 10006);
2015
			 * Object> equalsMap = new HashMap<>(); equalsMap.put("categoryId", 10006);
2013
			equalsMap.put("brand", brands);
2016
			 * equalsMap.put("brand", brands);
2014
 
2017
			 * 
2015
			Map<String, List<?>> notEqualsMap = new HashMap<>();
2018
			 * Map<String, List<?>> notEqualsMap = new HashMap<>();
2016
 
2019
			 * 
2017
			Map<String, Object> equalsJoinMap = new HashMap<>();
2020
			 * Map<String, Object> equalsJoinMap = new HashMap<>();
2018
			equalsJoinMap.put("catalogId", focusedModelCatalogId);
2021
			 * equalsJoinMap.put("catalogId", focusedModelCatalogId);
2019
 
2022
			 * 
2020
			Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
2023
			 * Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
2021
 
2024
			 */
2022
/*			List<Integer> catalogIds = itemRepository
-
 
2023
					.selectItems(FocusedModel.class, "catalogItemId", "catalogId", equalsMap, notEqualsMap,
-
 
2024
							equalsJoinMap, notEqualsJoinMap, "minimumQty")
-
 
2025
					.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
-
 
2026
 
2025
 
2027
*/			
2026
			/*
-
 
2027
			 * List<Integer> catalogIds = itemRepository .selectItems(FocusedModel.class,
-
 
2028
			 * "catalogItemId", "catalogId", equalsMap, notEqualsMap, equalsJoinMap,
-
 
2029
			 * notEqualsJoinMap, "minimumQty") .stream().map(x ->
-
 
2030
			 * x.getCatalogId()).collect(Collectors.toList());
-
 
2031
			 * 
-
 
2032
			 */
2028
			Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
2033
			Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
2029
					.selectAllByRegionIds(regionIds).stream()
-
 
2030
					.collect(Collectors.groupingBy(FocusedModel::getCatalogId, 
2034
					.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
2031
							Collectors.mapping(FocusedModel::getMinimumQty, 
2035
							Collectors.mapping(FocusedModel::getMinimumQty, Collectors.maxBy(Integer::compareTo))));
2032
									Collectors.maxBy(Integer::compareTo))));
-
 
2033
 
2036
 
2034
			/*
2037
			/*
2035
			 * Map<Integer, Integer> focusedCatalogIdAndQtyMap =
2038
			 * Map<Integer, Integer> focusedCatalogIdAndQtyMap =
2036
			 * focusedModelRepository.selectAll().stream() .collect(Collectors.toMap(x ->
2039
			 * focusedModelRepository.selectAll().stream() .collect(Collectors.toMap(x ->
2037
			 * x.getCatalogId(), x -> x.getMinimumQty()));
2040
			 * x.getCatalogId(), x -> x.getMinimumQty()));
Line 2071... Line 2074...
2071
					fm.setStoreName(customRetailer.getBusinessName());
2074
					fm.setStoreName(customRetailer.getBusinessName());
2072
 
2075
 
2073
					fm.setItemName(item.get(0).getBrand() + item.get(0).getModelNumber() + item.get(0).getModelName());
2076
					fm.setItemName(item.get(0).getBrand() + item.get(0).getModelNumber() + item.get(0).getModelName());
2074
					fm.setShortageQty(shortageQty);
2077
					fm.setShortageQty(shortageQty);
2075
 
2078
 
2076
					focusedModelShortageReportMap.get(fofoId).add(fm);
2079
					focusedModelShortageList.add(fm);
2077
				}
2080
				}
2078
 
2081
 
2079
			}
2082
			}
2080
			List<FocusedModelShortageModel> focusedModelShortageModel = focusedModelShortageReportMap.get(fofoId);
-
 
2081
			LOGGER.info("focusedModelShortageModel" + focusedModelShortageModel);
-
 
2082
			if (!focusedModelShortageModel.isEmpty()) {
2083
			if (!focusedModelShortageList.isEmpty()) {
2083
				String subject = "Stock Alert";
2084
				String subject = "Stock Alert";
2084
				String messageText = this.getMessage(focusedModelShortageModel);
2085
				String messageText = this.getMessage(focusedModelShortageList);
2085
 
2086
 
2086
				this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
2087
				this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
2087
				String notificationMessage = this.getNotificationMessage(focusedModelShortageModel);
2088
				String notificationMessage = this.getNotificationMessage(focusedModelShortageList);
2088
 
2089
 
2089
				LOGGER.info("notificationMessage" + notificationMessage);
2090
				LOGGER.info("notificationMessage" + notificationMessage);
2090
 
2091
 
2091
				SendNotificationModel sendNotificationModel = new SendNotificationModel();
2092
				SendNotificationModel sendNotificationModel = new SendNotificationModel();
2092
				sendNotificationModel.setCampaignName("Stock Alert");
2093
				sendNotificationModel.setCampaignName("Stock Alert");
Line 2101... Line 2102...
2101
				notificationService.sendNotification(sendNotificationModel);
2102
				notificationService.sendNotification(sendNotificationModel);
2102
 
2103
 
2103
			}
2104
			}
2104
 
2105
 
2105
		}
2106
		}
2106
		if (!focusedModelShortageReportMap.isEmpty())
2107
		if (!focusedModelShortageReportMap.isEmpty()) {
2107
 
-
 
2108
		{
-
 
2109
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2108
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2110
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2109
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2111
			Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2110
			Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2112
 
2111
 
2113
			focusedModelShortageReportMap.entrySet().forEach(x -> {
2112
			focusedModelShortageReportMap.entrySet().forEach(x -> {
Line 2350... Line 2349...
2350
 
2349
 
2351
		return sb.toString();
2350
		return sb.toString();
2352
	}
2351
	}
2353
 
2352
 
2354
}
2353
}
2355
 
-
 
2356
 
-
 
2357
 
-
 
2358
 
-
 
2359
 
-
 
2360
 
-