Subversion Repositories SmartDukaan

Rev

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

Rev 25373 Rev 25407
Line 695... Line 695...
695
			} catch (Exception e) {
695
			} catch (Exception e) {
696
				LOGGER.warn("Could not find partner with email - {}", retailer.getEmail());
696
				LOGGER.warn("Could not find partner with email - {}", retailer.getEmail());
697
			}
697
			}
698
 
698
 
699
		}
699
		}
700
 
-
 
701
		Map<String, Set<String>> storeGuyMap = new HashMap<>();
-
 
702
		for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
-
 
703
			String storeEmail = entry.getKey();
-
 
704
			List<String> storeGuys = entry.getValue();
-
 
705
			for (String storeGuy : storeGuys) {
-
 
706
				if (!storeGuyMap.containsKey(storeGuy)) {
-
 
707
					storeGuyMap.put(storeGuy, new HashSet<>());
-
 
708
				}
-
 
709
				storeGuyMap.get(storeGuy).add(storeEmail);
-
 
710
			}
-
 
711
		}
700
		
712
		storeGuyMap.remove("");
-
 
713
 
-
 
714
		String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
701
		String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
715
		for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuyMap.entrySet()) {
702
		for (Map.Entry<String, Set<String>> storeGuyEntry : getStoreGuyMap().entrySet()) {
716
			List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
703
			List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
717
					.map(x -> partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
704
					.map(x -> partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
718
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
705
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
719
			String[] sendToArray = new String[] { nameEmail.get(storeGuyEntry.getKey()) };
706
			String[] sendToArray = new String[] { nameEmail.get(storeGuyEntry.getKey()) };
720
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA",
707
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA",
Line 725... Line 712...
725
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
712
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
726
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
713
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
727
				new ByteArrayResource(baos.toByteArray()));
714
				new ByteArrayResource(baos.toByteArray()));
728
	}
715
	}
729
 
716
 
-
 
717
	private Map<String, Set<String>> getStoreGuyMap() {
-
 
718
		Map<String, Set<String>> storeGuyMap = new HashMap<>();
-
 
719
		for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
-
 
720
			String storeEmail = entry.getKey();
-
 
721
			List<String> storeGuys = entry.getValue();
-
 
722
			for (String storeGuy : storeGuys) {
-
 
723
				if (!storeGuyMap.containsKey(storeGuy)) {
-
 
724
					storeGuyMap.put(storeGuy, new HashSet<>());
-
 
725
				}
-
 
726
				storeGuyMap.get(storeGuy).add(storeEmail);
-
 
727
			}
-
 
728
		}
-
 
729
		storeGuyMap.remove("");
-
 
730
		return storeGuyMap;
-
 
731
	}
-
 
732
 
730
	public void sendAgeingReport(String... sendTo) throws Exception {
733
	public void sendAgeingReport(String... sendTo) throws Exception {
731
 
734
 
732
		InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
735
		InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
733
				"itemstockageing.xml");
736
				"itemstockageing.xml");
734
		InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
737
		InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
Line 737... Line 740...
737
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
740
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
738
		Attachment attachment1 = new Attachment(
741
		Attachment attachment1 = new Attachment(
739
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
742
				"aeging-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
740
		Utils.sendMailWithAttachments(googleMailSender, sendTo, null, "Stock Aeging Report", "PFA", attachment,
743
		Utils.sendMailWithAttachments(googleMailSender, sendTo, null, "Stock Aeging Report", "PFA", attachment,
741
				attachment1);
744
				attachment1);
-
 
745
		Set<String> storeGuys = getStoreGuyMap().keySet();
-
 
746
		
-
 
747
		String[] sendToArray = new String[storeGuys.size()];
-
 
748
		Utils.sendMailWithAttachments(googleMailSender, sendToArray, null, "Stock Aeging Report", "PFA", attachment);
-
 
749
		
742
	}
750
	}
743
 
751
 
744
	public void sendAgeingReport() throws Exception {
752
	public void sendAgeingReport() throws Exception {
745
		sendAgeingReport("amod.sen@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com",
753
		sendAgeingReport("amod.sen@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com",
746
				"tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com", "mohinder.mutreja@smartdukaan.com");
754
				"tarun.verma@smartdukaan.com", "chaitnaya.vats@smartdukaan.com", "mohinder.mutreja@smartdukaan.com");
Line 1423... Line 1431...
1423
		storeManagerMap.put("moderncohsr@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1431
		storeManagerMap.put("moderncohsr@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1424
		storeManagerMap.put("raghubir.ngh@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1432
		storeManagerMap.put("raghubir.ngh@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
1425
		storeManagerMap.put("aman007singla@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
1433
		storeManagerMap.put("aman007singla@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
1426
	}
1434
	}
1427
}
1435
}
1428
 
-