Subversion Repositories SmartDukaan

Rev

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

Rev 30644 Rev 30752
Line 236... Line 236...
236
	private ServiceConfigRepository serviceConfigRepository;
236
	private ServiceConfigRepository serviceConfigRepository;
237
 
237
 
238
	@Value("${delhivery.tracking.token}")
238
	@Value("${delhivery.tracking.token}")
239
	private String token;
239
	private String token;
240
 
240
 
241
	private static final String[] STOCK_AGEING_MAIL_LIST = new String[]{"uday.singh@smartudkaan.com",
241
	private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
242
			"mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
242
			"mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
243
			"kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com"};
243
			"kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com" };
244
 
244
 
245
	private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[]{"kamini.sharma@smartdukaan.com",
245
	private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
246
			"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
246
			"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
247
			"niranjan.kala@smartdukaan.com"};
247
			"niranjan.kala@smartdukaan.com" };
248
 
248
 
249
	private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com",
249
	private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[] { "uday.singh@smartdukaan.com",
250
			"kuldeep.kumar@smartdukaan.com"};
250
			"kuldeep.kumar@smartdukaan.com" };
251
 
251
 
252
	private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[]{"sm@smartdukaan.com",
252
	private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[] { "sm@smartdukaan.com",
253
			"sm@smartdukaan.com"};
253
			"sm@smartdukaan.com" };
254
 
254
 
255
	private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
255
	private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
256
 
256
 
257
	@Autowired
257
	@Autowired
258
	private ReporticoService reporticoService;
258
	private ReporticoService reporticoService;
Line 676... Line 676...
676
 
676
 
677
		List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
677
		List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
678
		for (FofoStore store : stores) {
678
		for (FofoStore store : stores) {
679
			int fofoId = store.getId();
679
			int fofoId = store.getId();
680
 
680
 
681
			PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfPreviousMonth);
681
			PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId,
-
 
682
					startOfPreviousMonth);
682
			PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId,
683
			PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId,
683
					YearMonth.from(startOfPreviousMonth.atStartOfDay()));
684
					YearMonth.from(startOfPreviousMonth.atStartOfDay()));
684
			if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
685
			if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
685
				continue;
686
				continue;
686
			}
687
			}
Line 726... Line 727...
726
 
727
 
727
			}
728
			}
728
		}
729
		}
729
		if (upgradedCount > 0) {
730
		if (upgradedCount > 0) {
730
			sendMailHtmlFormat(
731
			sendMailHtmlFormat(
731
					new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
732
					new String[] { "amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
732
							"neeraj.gupta@smartdukaan.com"},
733
							"neeraj.gupta@smartdukaan.com" },
733
					sb.toString(), null, "Few Partners Category have been Upgraded");
734
					sb.toString(), null, "Few Partners Category have been Upgraded");
734
		} else {
735
		} else {
735
			sendMailHtmlFormat(
736
			sendMailHtmlFormat(
736
					new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
737
					new String[] { "amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
737
							"neeraj.gupta@smartdukaan.com"},
738
							"neeraj.gupta@smartdukaan.com" },
738
					sb.toString(), null, "No partners Category have been upgraded today");
739
					sb.toString(), null, "No partners Category have been upgraded today");
739
		}
740
		}
740
	}
741
	}
741
 
742
 
742
	@Autowired
743
	@Autowired
Line 799... Line 800...
799
				.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
800
				.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
800
						x.getValue(), userNameMap.get(x.getKey())));
801
						x.getValue(), userNameMap.get(x.getKey())));
801
 
802
 
802
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
803
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
803
		Utils.sendMailWithAttachment(googleMailSender,
804
		Utils.sendMailWithAttachment(googleMailSender,
804
				new String[]{"amit.gupta@shop2020.in", "adeel.yazdani@smartdukaan.com"}, null,
805
				new String[] { "amit.gupta@shop2020.in", "adeel.yazdani@smartdukaan.com" }, null,
805
				"Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
806
				"Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
806
 
807
 
807
	}
808
	}
808
 
809
 
809
	public void fetchParnterStats() throws Exception {
810
	public void fetchParnterStats() throws Exception {
Line 831... Line 832...
831
		} else {
832
		} else {
832
			rct.setLastCreatedTimestamp(LocalDateTime.now());
833
			rct.setLastCreatedTimestamp(LocalDateTime.now());
833
		}
834
		}
834
	}
835
	}
835
 
836
 
836
 
-
 
837
	public void processPriceDrop() throws Exception {
837
	public void processPriceDrop() throws Exception {
838
		List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetween(LocalDateTime.now(), LocalDateTime.now().minusYears(1));
838
		List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetween(LocalDateTime.now(),
-
 
839
				LocalDateTime.now().minusYears(1));
839
		for (PriceDrop priceDrop : priceDrops) {
840
		for (PriceDrop priceDrop : priceDrops) {
840
			if (priceDrop.getDropAmount() > 0) {
841
			if (priceDrop.getDropAmount() > 0) {
841
				priceDropService.processPriceDrop(priceDrop.getId(), true);
842
				priceDropService.processPriceDrop(priceDrop.getId(), true);
842
			}
843
			}
843
		}
844
		}
Line 1031... Line 1032...
1031
		if (sendTo == null) {
1032
		if (sendTo == null) {
1032
			for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
1033
			for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
1033
				List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
1034
				List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
1034
						.filter(x -> x != null).collect(Collectors.toList());
1035
						.filter(x -> x != null).collect(Collectors.toList());
1035
				ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
1036
				ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
1036
				String[] sendToArray = new String[]{storeGuyEntry.getKey()};
1037
				String[] sendToArray = new String[] { storeGuyEntry.getKey() };
1037
				Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
1038
				Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
1038
						fileName, new ByteArrayResource(baos.toByteArray()));
1039
						fileName, new ByteArrayResource(baos.toByteArray()));
1039
			}
1040
			}
1040
			sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
1041
			sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
1041
					"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
1042
					"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
Line 1148... Line 1149...
1148
			InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
1149
			InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
1149
					"focostockreport.xml", params);
1150
					"focostockreport.xml", params);
1150
			Attachment attache = new Attachment(
1151
			Attachment attache = new Attachment(
1151
					"Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
1152
					"Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
1152
			System.out.println(storeGuyEntry.getValue());
1153
			System.out.println(storeGuyEntry.getValue());
1153
			Utils.sendMailWithAttachments(googleMailSender, new String[]{storeGuyEntry.getKey()}, null,
1154
			Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
1154
					"Franchise Stock Report", "PFA", attache);
1155
					"Franchise Stock Report", "PFA", attache);
1155
		}
1156
		}
1156
 
1157
 
1157
	}
1158
	}
1158
 
1159
 
Line 1199... Line 1200...
1199
				String body = String.format(
1200
				String body = String.format(
1200
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
1201
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
1201
						authUser.getFullName(),
1202
						authUser.getFullName(),
1202
						(employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? ""
1203
						(employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? ""
1203
								: "(Punched at "
1204
								: "(Punched at "
1204
								+ FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp())
1205
										+ FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp())
1205
								+ ")");
1206
										+ ")");
1206
 
1207
 
1207
				Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()},
1208
				Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() },
1208
						new String[]{"sm@smartdukaan.com"}, "Attendance Alert", body);
1209
						new String[] { "sm@smartdukaan.com" }, "Attendance Alert", body);
1209
 
1210
 
1210
			}
1211
			}
1211
		}
1212
		}
1212
 
1213
 
1213
	}
1214
	}
Line 1253... Line 1254...
1253
					}
1254
					}
1254
				}
1255
				}
1255
 
1256
 
1256
			}
1257
			}
1257
			if (body != null) {
1258
			if (body != null) {
1258
				Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()},
1259
				Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() },
1259
						new String[]{"sm@smartdukaan.com"}, "Attendance Alert", body);
1260
						new String[] { "sm@smartdukaan.com" }, "Attendance Alert", body);
1260
			}
1261
			}
1261
		}
1262
		}
1262
 
1263
 
1263
		this.sendMailToHR();
1264
		this.sendMailToHR();
1264
 
1265
 
Line 1563... Line 1564...
1563
				rolledbackSios.stream()
1564
				rolledbackSios.stream()
1564
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
1565
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
1565
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1566
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1566
						.collect(Collectors.toList()));
1567
						.collect(Collectors.toList()));
1567
 
1568
 
1568
		Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null,
1569
		Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
1569
				"Partner Excess Amount Scheme In", "PFA",
1570
				"Partner Excess Amount Scheme In", "PFA",
1570
				new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1571
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1571
						new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
1572
						new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
1572
 
1573
 
1573
		throw new Exception();
1574
		throw new Exception();
1574
 
1575
 
1575
	}
1576
	}
1576
 
1577
 
Line 1674... Line 1675...
1674
				rolledbackSios.stream()
1675
				rolledbackSios.stream()
1675
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1676
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1676
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1677
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1677
						.collect(Collectors.toList()));
1678
						.collect(Collectors.toList()));
1678
 
1679
 
1679
		Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null,
1680
		Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, null,
1680
				"Partner Excess Amount Scheme Out", "PFA",
1681
				"Partner Excess Amount Scheme Out", "PFA",
1681
				new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1682
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1682
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
1683
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
1683
 
1684
 
1684
		throw new Exception();
1685
		throw new Exception();
1685
	}
1686
	}
1686
 
1687
 
1687
	public void dryRunSchemeOutReco1() throws Exception {
1688
	public void dryRunSchemeOutReco1() throws Exception {
Line 1735... Line 1736...
1735
		});
1736
		});
1736
 
1737
 
1737
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1738
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1738
				Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"),
1739
				Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"),
1739
				userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(),
1740
				userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(),
1740
								x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
1741
						x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
1741
						.collect(Collectors.toList()));
1742
						.collect(Collectors.toList()));
1742
 
1743
 
1743
		ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
1744
		ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
1744
				Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
1745
				Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
1745
						"Rolledback"),
1746
						"Rolledback"),
Line 1747... Line 1748...
1747
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1748
						.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
1748
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1749
								x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
1749
						.collect(Collectors.toList()));
1750
						.collect(Collectors.toList()));
1750
 
1751
 
1751
		Utils.sendMailWithAttachments(googleMailSender,
1752
		Utils.sendMailWithAttachments(googleMailSender,
1752
				new String[]{"amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com"}, null,
1753
				new String[] { "amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com" }, null,
1753
				"Partner Excess Amount", "PFA",
1754
				"Partner Excess Amount", "PFA",
1754
				new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1755
				new Attachment[] { new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
1755
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
1756
						new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray())) });
1756
 
1757
 
1757
		throw new Exception();
1758
		throw new Exception();
1758
 
1759
 
1759
	}
1760
	}
1760
 
1761
 
Line 1829... Line 1830...
1829
			notificationService.sendNotification(sendNotificationModel);
1830
			notificationService.sendNotification(sendNotificationModel);
1830
		}
1831
		}
1831
		// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
1832
		// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
1832
		// saleTargetReportModelMap);
1833
		// saleTargetReportModelMap);
1833
		String statewiseSaleReport = this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
1834
		String statewiseSaleReport = this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
1834
		String cc[] = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
1835
		String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "niranjan.kala@smartdukaan.com",
1835
				"niranjan.kala@smartdukaan.com", "sm@smartdukaan.com"};
1836
				"sm@smartdukaan.com" };
1836
 
1837
 
1837
		String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
1838
		String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
1838
		// this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc,
1839
		// this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc,
1839
		// subject);
1840
		// subject);
1840
		this.sendMailOfHtmlFormat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
1841
		this.sendMailOfHtmlFormat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
Line 1875... Line 1876...
1875
 
1876
 
1876
						CustomRetailer customRetailer = retailerService.getFofoRetailer(po.getFofoId());
1877
						CustomRetailer customRetailer = retailerService.getFofoRetailer(po.getFofoId());
1877
						Customer customer = customerRepository.selectById(po.getCustomerId());
1878
						Customer customer = customerRepository.selectById(po.getCustomerId());
1878
						String[] customerEmail = null;
1879
						String[] customerEmail = null;
1879
						if (customer.getEmailId() != null) {
1880
						if (customer.getEmailId() != null) {
1880
							customerEmail = new String[]{customer.getEmailId()};
1881
							customerEmail = new String[] { customer.getEmailId() };
1881
						}
1882
						}
1882
						List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com",
1883
						List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com",
1883
								"tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
1884
								"tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
1884
								"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
1885
								"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
1885
						List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
1886
						List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
Line 2034... Line 2035...
2034
		}
2035
		}
2035
 
2036
 
2036
	}
2037
	}
2037
 
2038
 
2038
	private String getStateWiseSales(Map<Integer, SaleTargetReportModel> saleTargetReportModelMap,
2039
	private String getStateWiseSales(Map<Integer, SaleTargetReportModel> saleTargetReportModelMap,
2039
									 Map<Integer, FofoReportingModel> partnerSalesHeadersMap) throws Exception {
2040
			Map<Integer, FofoReportingModel> partnerSalesHeadersMap) throws Exception {
2040
		List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
2041
		List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
2041
		Map<String, List<Integer>> stateMap = stores.stream().collect(Collectors
2042
		Map<String, List<Integer>> stateMap = stores.stream().collect(Collectors
2042
				.groupingBy(x -> x.getCode().substring(0, 2), Collectors.mapping(x -> x.getId(), Collectors.toList())));
2043
				.groupingBy(x -> x.getCode().substring(0, 2), Collectors.mapping(x -> x.getId(), Collectors.toList())));
2043
		List<List<Serializable>> stateWiseSales = new ArrayList<>();
2044
		List<List<Serializable>> stateWiseSales = new ArrayList<>();
2044
		for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
2045
		for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
Line 2501... Line 2502...
2501
				try {
2502
				try {
2502
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
2503
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
2503
				} catch (Exception e2) {
2504
				} catch (Exception e2) {
2504
					e2.printStackTrace();
2505
					e2.printStackTrace();
2505
				}
2506
				}
2506
				String[] sendToArray = new String[]{
2507
				String[] sendToArray = new String[] {
2507
 
2508
 
2508
						entry.getKey()
2509
						entry.getKey()
2509
 
2510
 
2510
				};
2511
				};
2511
 
2512
 
Line 2677... Line 2678...
2677
			String subject = "Referral Request";
2678
			String subject = "Referral Request";
2678
			String messageText = this.getMessageForReferral(referrals);
2679
			String messageText = this.getMessageForReferral(referrals);
2679
 
2680
 
2680
			MimeMessage message = mailSender.createMimeMessage();
2681
			MimeMessage message = mailSender.createMimeMessage();
2681
			MimeMessageHelper helper = new MimeMessageHelper(message, true);
2682
			MimeMessageHelper helper = new MimeMessageHelper(message, true);
2682
			String[] email = {"kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com"};
2683
			String[] email = { "kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com" };
2683
			helper.setSubject(subject);
2684
			helper.setSubject(subject);
2684
			helper.setText(messageText, true);
2685
			helper.setText(messageText, true);
2685
			helper.setTo(email);
2686
			helper.setTo(email);
2686
			InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
2687
			InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
2687
			helper.setFrom(senderAddress);
2688
			helper.setFrom(senderAddress);
Line 2921... Line 2922...
2921
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
2922
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
2922
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
2923
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
2923
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
2924
			sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
2924
			sb.append("<td style='border:1px solid black;padding: 5px'>"
2925
			sb.append("<td style='border:1px solid black;padding: 5px'>"
2925
					+ (authUserMap.get(EscalationType.L1) == null ? "N/A"
2926
					+ (authUserMap.get(EscalationType.L1) == null ? "N/A"
2926
					: authUserMap.get(EscalationType.L1).getFirstName())
2927
							: authUserMap.get(EscalationType.L1).getFirstName())
2927
					+ " ," + (authUserMap.get(EscalationType.L2) == null ? "N/A"
2928
					+ " ," + (authUserMap.get(EscalationType.L2) == null ? "N/A"
2928
					: authUserMap.get(EscalationType.L2).getFirstName())
2929
							: authUserMap.get(EscalationType.L2).getFirstName())
2929
					+ "</td>");
2930
					+ "</td>");
2930
 
2931
 
2931
			sb.append("</tr>");
2932
			sb.append("</tr>");
2932
		}
2933
		}
2933
		sb.append("</tbody></table><br><br>");
2934
		sb.append("</tbody></table><br><br>");
Line 3286... Line 3287...
3286
				for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping()
3287
				for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping()
3287
						.entrySet()) {
3288
						.entrySet()) {
3288
					List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
3289
					List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
3289
							.map(x -> partnerCollectionRemarksMap.get(x)).filter(x -> x != null)
3290
							.map(x -> partnerCollectionRemarksMap.get(x)).filter(x -> x != null)
3290
							.collect(Collectors.toList());
3291
							.collect(Collectors.toList());
3291
					String subject = "Uncontacble Partner";
3292
					String subject = "UNCONTACTABLE PARTNERS";
3292
					String messageText = this.getMessageForUncontacblePartner(filteredRows);
3293
					String messageText = this.getMessageForUncontacblePartner(filteredRows);
3293
 
3294
 
3294
					MimeMessage message = mailSender.createMimeMessage();
3295
					MimeMessage message = mailSender.createMimeMessage();
3295
					MimeMessageHelper helper = new MimeMessageHelper(message, true);
3296
					MimeMessageHelper helper = new MimeMessageHelper(message, true);
3296
					String[] email = new String[]{storeGuyEntry.getKey()};
3297
					String[] email = new String[] { storeGuyEntry.getKey() };
3297
 
3298
 
3298
					helper.setSubject(subject);
3299
					helper.setSubject(subject);
3299
					helper.setText(messageText, true);
3300
					helper.setText(messageText, true);
3300
					helper.setTo(email);
3301
					helper.setTo(email);
3301
					InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com",
3302
					InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com",