Subversion Repositories SmartDukaan

Rev

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

Rev 31332 Rev 31388
Line 24... Line 24...
24
import com.spice.profitmandi.dao.entity.auth.AuthUser;
24
import com.spice.profitmandi.dao.entity.auth.AuthUser;
25
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
25
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
26
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
26
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
27
import com.spice.profitmandi.dao.entity.catalog.Item;
27
import com.spice.profitmandi.dao.entity.catalog.Item;
28
import com.spice.profitmandi.dao.entity.catalog.Scheme;
28
import com.spice.profitmandi.dao.entity.catalog.Scheme;
-
 
29
import com.spice.profitmandi.dao.entity.catalog.TagListing;
29
import com.spice.profitmandi.dao.entity.cs.Position;
30
import com.spice.profitmandi.dao.entity.cs.Position;
30
import com.spice.profitmandi.dao.entity.cs.Ticket;
31
import com.spice.profitmandi.dao.entity.cs.Ticket;
31
import com.spice.profitmandi.dao.entity.dtr.User;
32
import com.spice.profitmandi.dao.entity.dtr.User;
32
import com.spice.profitmandi.dao.entity.dtr.*;
33
import com.spice.profitmandi.dao.entity.dtr.*;
33
import com.spice.profitmandi.dao.entity.fofo.*;
34
import com.spice.profitmandi.dao.entity.fofo.*;
Line 453... Line 454...
453
	private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
454
	private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
454
 
455
 
455
	private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
456
	private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
456
	private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
457
	private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
457
 
458
 
-
 
459
	@Autowired
-
 
460
	private TagListingRepository tagListingRepository;
-
 
461
 
458
	public void generateDailyRecharge() {
462
	public void generateDailyRecharge() {
459
		List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
463
		List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
460
				.selectAll(0, 2000);
464
				.selectAll(0, 2000);
461
		List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
465
		List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
462
		rechargeProviders.stream().forEach(x -> x.setAmount(0));
466
		rechargeProviders.stream().forEach(x -> x.setAmount(0));
Line 2485... Line 2489...
2485
				int grnStockQty = grnPendingQty + inStockQty;
2489
				int grnStockQty = grnPendingQty + inStockQty;
2486
				int totalQty = processingQty + grnPendingQty + inStockQty;
2490
				int totalQty = processingQty + grnPendingQty + inStockQty;
2487
 
2491
 
2488
				int shortageQty = minQty - totalQty;
2492
				int shortageQty = minQty - totalQty;
2489
				List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
2493
				List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
-
 
2494
 
-
 
2495
				TagListing tagListing = tagListingRepository.selectByCatalogId(entry.getKey());
-
 
2496
 
2490
				FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
2497
				FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
2491
 
2498
 
2492
				Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap
2499
				Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap
2493
						.get(fofoStore.getWarehouseId());
2500
						.get(fofoStore.getWarehouseId());
2494
 
2501
 
Line 2525... Line 2532...
2525
				fm.setModelName(items.get(0).getModelName());
2532
				fm.setModelName(items.get(0).getModelName());
2526
				fm.setModelNumber(items.get(0).getModelNumber());
2533
				fm.setModelNumber(items.get(0).getModelNumber());
2527
				fm.setGrnStockQty(grnStockQty);
2534
				fm.setGrnStockQty(grnStockQty);
2528
				fm.setPendingIndentQty(processingQty);
2535
				fm.setPendingIndentQty(processingQty);
2529
				fm.setShortageQty(shortageQty);
2536
				fm.setShortageQty(shortageQty);
2530
				fm.setPoAvailabitiy(allColorPoAvailability);
2537
				fm.setPoAvailability(allColorPoAvailability);
-
 
2538
				fm.setDp(tagListing.getSellingPrice());
2531
				fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2539
				fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2532
				fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2540
				fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2533
				fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
2541
				fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
2534
				fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
2542
				fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
2535
				fm.setAvailabitiy(allColorNetAvailability);
2543
				fm.setAvailability(allColorNetAvailability);
2536
 
2544
 
2537
				focusedModelShortageList.add(fm);
2545
				focusedModelShortageList.add(fm);
2538
			}
2546
			}
2539
 
2547
 
2540
			/*
-
 
2541
			 * if (!focusedModelShortageList.isEmpty()) { String subject = "Stock Alert";
-
 
2542
			 * String messageText = this.getMessage(focusedModelShortageList);
-
 
2543
			 *
-
 
2544
			 * this.sendMailWithAttachments(subject, messageText,
-
 
2545
			 * customRetailer.getEmail()); String notificationMessage =
-
 
2546
			 * this.getNotificationMessage(focusedModelShortageList);
-
 
2547
			 *
-
 
2548
			 * LOGGER.info("notificationMessage" + notificationMessage);
-
 
2549
			 *
-
 
2550
			 * SendNotificationModel sendNotificationModel = new SendNotificationModel();
-
 
2551
			 * sendNotificationModel.setCampaignName("Stock Alert");
-
 
2552
			 * sendNotificationModel.setTitle("Alert");
-
 
2553
			 * sendNotificationModel.setMessage(notificationMessage);
-
 
2554
			 * sendNotificationModel.setType("url"); sendNotificationModel.setUrl(
-
 
2555
			 * "https://app.smartdukaan.com/pages/home/notifications");
-
 
2556
			 * sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
-
 
2557
			 * sendNotificationModel.setMessageType(MessageType.notification); int userId =
-
 
2558
			 * userAccountRepository.selectUserIdByRetailerId(fofoId);
-
 
2559
			 * sendNotificationModel.setUserIds(Arrays.asList(userId));
-
 
2560
			 * notificationService.sendNotification(sendNotificationModel);
-
 
2561
			 *
-
 
2562
			 * }
-
 
2563
			 */
-
 
2564
 
-
 
2565
		}
2548
		}
2566
		if (!focusedModelShortageReportMap.isEmpty()) {
2549
		if (!focusedModelShortageReportMap.isEmpty()) {
2567
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2550
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2568
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2551
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2569
			Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2552
			Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
Line 2575... Line 2558...
2575
						if (!emailRowsMap.containsKey(y.getKey())) {
2558
						if (!emailRowsMap.containsKey(y.getKey())) {
2576
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2559
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2577
						}
2560
						}
2578
						List<List<? extends Serializable>> fms = x.getValue().stream()
2561
						List<List<? extends Serializable>> fms = x.getValue().stream()
2579
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2562
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2580
										r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
2563
										r.getModelName(), r.getModelNumber(), r.getDp(), r.getWarehouseName(), r.getStateManager(),
2581
										r.getTerritoryManager(), r.getPendingIndentQty(), r.getGrnStockQty(),
2564
										r.getTerritoryManager(), r.getPendingIndentQty(), r.getGrnStockQty(),
2582
										r.getShortageQty(), r.getAvailabitiy()))
2565
										r.getShortageQty(), r.getAvailability()))
2583
								.collect(Collectors.toList());
2566
								.collect(Collectors.toList());
2584
						emailRowsMap.get(y.getKey()).addAll(fms);
2567
						emailRowsMap.get(y.getKey()).addAll(fms);
2585
 
2568
 
2586
					}
2569
					}
2587
 
2570
 
2588
				});
2571
				});
2589
 
2572
 
2590
			});
2573
			});
2591
 
2574
 
2592
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
2575
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number", "DP",
2593
					"Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty",
2576
					"Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty",
2594
					"Availability");
2577
					"Availability");
2595
			emailRowsMap.entrySet().forEach(entry -> {
2578
			emailRowsMap.entrySet().forEach(entry -> {
2596
 
2579
 
2597
				ByteArrayOutputStream baos = null;
2580
				ByteArrayOutputStream baos = null;
Line 2991... Line 2974...
2991
		List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
2974
		List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
2992
 
2975
 
2993
		Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream()
2976
		Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream()
2994
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
2977
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
2995
 
2978
 
2996
		List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
2979
		List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com");
2997
				"niranjan.kala@smartdukaan.com", "sm@smartdukaan.com");
-
 
2998
		LOGGER.info("partnerProblem" + partnerProblems);
2980
		LOGGER.info("partnerProblem" + partnerProblems);
2999
		StringBuilder sb = new StringBuilder();
2981
		StringBuilder sb = new StringBuilder();
3000
		sb.append("<htl><body>");
2982
		sb.append("<htl><body>");
3001
		sb.append(
2983
		sb.append(
3002
				"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
2984
				"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");