Subversion Repositories SmartDukaan

Rev

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

Rev 28467 Rev 28526
Line 2131... Line 2131...
2131
				if (catalogIdAndQtyMap != null) {
2131
				if (catalogIdAndQtyMap != null) {
2132
					inStockQty = (catalogIdAndQtyMap.get(entry.getKey()) == null) ? 0
2132
					inStockQty = (catalogIdAndQtyMap.get(entry.getKey()) == null) ? 0
2133
							: catalogIdAndQtyMap.get(entry.getKey());
2133
							: catalogIdAndQtyMap.get(entry.getKey());
2134
 
2134
 
2135
				}
2135
				}
-
 
2136
 
-
 
2137
				int grnStockQty = grnPendingQty + inStockQty;
2136
				int totalQty = processingQty + grnPendingQty + inStockQty;
2138
				int totalQty = processingQty + grnPendingQty + inStockQty;
2137
 
2139
 
2138
				if (totalQty < minQty) {
2140
				if (totalQty < minQty) {
2139
 
2141
 
2140
					int shortageQty = minQty - totalQty;
2142
					int shortageQty = minQty - totalQty;
Line 2167... Line 2169...
2167
					fm.setStoreCode(fofoStore.getCode());
2169
					fm.setStoreCode(fofoStore.getCode());
2168
					fm.setStoreName(customRetailer.getBusinessName());
2170
					fm.setStoreName(customRetailer.getBusinessName());
2169
					fm.setBrandName(item.get(0).getBrand());
2171
					fm.setBrandName(item.get(0).getBrand());
2170
					fm.setModelName(item.get(0).getModelName());
2172
					fm.setModelName(item.get(0).getModelName());
2171
					fm.setModelNumber(item.get(0).getModelNumber());
2173
					fm.setModelNumber(item.get(0).getModelNumber());
-
 
2174
					fm.setGrnStockQty(grnStockQty);
-
 
2175
					fm.setPendingIndentQty(processingQty);
2172
					fm.setShortageQty(shortageQty);
2176
					fm.setShortageQty(shortageQty);
2173
					fm.setPoAvailabitiy(allColorPoAvailability);
2177
					fm.setPoAvailabitiy(allColorPoAvailability);
2174
					fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2178
					fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2175
					fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2179
					fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2176
					fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
2180
					fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
Line 2180... Line 2184...
2180
					focusedModelShortageList.add(fm);
2184
					focusedModelShortageList.add(fm);
2181
				}
2185
				}
2182
 
2186
 
2183
			}
2187
			}
2184
 
2188
 
-
 
2189
			/*
2185
			if (!focusedModelShortageList.isEmpty()) {
2190
			 * if (!focusedModelShortageList.isEmpty()) { String subject = "Stock Alert";
2186
				String subject = "Stock Alert";
-
 
2187
				String messageText = this.getMessage(focusedModelShortageList);
2191
			 * String messageText = this.getMessage(focusedModelShortageList);
2188
 
2192
			 * 
2189
				this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
2193
			 * this.sendMailWithAttachments(subject, messageText,
-
 
2194
			 * customRetailer.getEmail()); String notificationMessage =
2190
				String notificationMessage = this.getNotificationMessage(focusedModelShortageList);
2195
			 * this.getNotificationMessage(focusedModelShortageList);
2191
 
2196
			 * 
2192
				LOGGER.info("notificationMessage" + notificationMessage);
2197
			 * LOGGER.info("notificationMessage" + notificationMessage);
2193
 
2198
			 * 
2194
				SendNotificationModel sendNotificationModel = new SendNotificationModel();
2199
			 * SendNotificationModel sendNotificationModel = new SendNotificationModel();
2195
				sendNotificationModel.setCampaignName("Stock Alert");
2200
			 * sendNotificationModel.setCampaignName("Stock Alert");
2196
				sendNotificationModel.setTitle("Alert");
2201
			 * sendNotificationModel.setTitle("Alert");
2197
				sendNotificationModel.setMessage(notificationMessage);
2202
			 * sendNotificationModel.setMessage(notificationMessage);
2198
				sendNotificationModel.setType("url");
2203
			 * sendNotificationModel.setType("url"); sendNotificationModel.setUrl(
2199
				sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
2204
			 * "https://app.smartdukaan.com/pages/home/notifications");
2200
				sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
2205
			 * sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
2201
				sendNotificationModel.setMessageType(MessageType.notification);
2206
			 * sendNotificationModel.setMessageType(MessageType.notification); int userId =
2202
				int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
2207
			 * userAccountRepository.selectUserIdByRetailerId(fofoId);
2203
				sendNotificationModel.setUserIds(Arrays.asList(userId));
2208
			 * sendNotificationModel.setUserIds(Arrays.asList(userId));
2204
				notificationService.sendNotification(sendNotificationModel);
2209
			 * notificationService.sendNotification(sendNotificationModel);
2205
 
2210
			 * 
2206
			}
2211
			 * }
-
 
2212
			 */
2207
 
2213
 
2208
		}
2214
		}
2209
		if (!focusedModelShortageReportMap.isEmpty()) {
2215
		if (!focusedModelShortageReportMap.isEmpty()) {
2210
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2216
			String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2211
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2217
			Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
Line 2219... Line 2225...
2219
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2225
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2220
						}
2226
						}
2221
						List<List<? extends Serializable>> fms = x.getValue().stream()
2227
						List<List<? extends Serializable>> fms = x.getValue().stream()
2222
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2228
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2223
										r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
2229
										r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
2224
										r.getTerritoryManager(), r.getShortageQty(), r.getAvailabitiy()))
2230
										r.getTerritoryManager(), r.getPendingIndentQty(), r.getGrnStockQty(),
-
 
2231
										r.getShortageQty(), r.getAvailabitiy()))
2225
								.collect(Collectors.toList());
2232
								.collect(Collectors.toList());
2226
						emailRowsMap.get(y.getKey()).addAll(fms);
2233
						emailRowsMap.get(y.getKey()).addAll(fms);
2227
 
2234
 
2228
					}
2235
					}
2229
 
2236
 
2230
				});
2237
				});
2231
 
2238
 
2232
			});
2239
			});
2233
 
2240
 
2234
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
2241
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
2235
					"Warehouse Name", "State Manager", "Territory Manager", "Shortage Qty", "Availability");
2242
					"Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty",
-
 
2243
					"Availability");
2236
			emailRowsMap.entrySet().forEach(entry -> {
2244
			emailRowsMap.entrySet().forEach(entry -> {
2237
 
2245
 
2238
				ByteArrayOutputStream baos = null;
2246
				ByteArrayOutputStream baos = null;
2239
				try {
2247
				try {
2240
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
2248
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
2241
				} catch (Exception e2) {
2249
				} catch (Exception e2) {
2242
					e2.printStackTrace();
2250
					e2.printStackTrace();
2243
				}
2251
				}
2244
				String[] sendToArray = new String[] { entry.getKey() };
2252
				String[] sendToArray = new String[] { // entry.getKey()
-
 
2253
						"tejbeer.kaur@smartdukaan.com" };
-
 
2254
 
2245
				try {
2255
				try {
2246
					Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
2256
					Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
2247
							new ByteArrayResource(baos.toByteArray()));
2257
							new ByteArrayResource(baos.toByteArray()));
2248
				} catch (Exception e1) { // TODO Auto-generated catch block
2258
				} catch (Exception e1) { // TODO Auto-generated catch block
2249
					e1.printStackTrace();
2259
					e1.printStackTrace();