Subversion Repositories SmartDukaan

Rev

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

Rev 25821 Rev 25822
Line 769... Line 769...
769
	}
769
	}
770
 
770
 
771
	public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
771
	public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
772
 
772
 
773
		if (sendTo == null) {
773
		if (sendTo == null) {
-
 
774
			/*
774
			sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
775
			 * sendTo = Arrays.asList("tarun.verma@smartdukaan.com",
-
 
776
			 * "kamini.sharma@smartdukaan.com", "amit.gupta@shop2020.in",
775
					"amit.gupta@shop2020.in", "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
777
			 * "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
-
 
778
			 */
-
 
779
			sendTo = Arrays.asList("amit.gupta@shop2020.in");
776
		}
780
		}
777
		List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
-
 
778
				.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusDays(1));
-
 
779
		Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
781
		Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
780
		for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
-
 
781
			partnerSalesTargetRowsMap.putAll(targetService.getDailySaleReportVsTarget(partnerTargetDetail));
782
		partnerSalesTargetRowsMap = targetService.getDailySaleReportVsTarget();
782
		}
-
 
783
		Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
783
		Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
784
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
784
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
785
 
785
 
786
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
786
		Map<Integer, CustomRetailer> customRetailerMap = retailerService
787
				.getFofoRetailers(new ArrayList<>(fofoStoresMap.keySet()));
787
				.getFofoRetailers(new ArrayList<>(fofoStoresMap.keySet()));
Line 821... Line 821...
821
			}
821
			}
822
 
822
 
823
		}
823
		}
824
 
824
 
825
		String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
825
		String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
826
		/*
-
 
827
		 * for (Map.Entry<String, Set<String>> storeGuyEntry :
-
 
828
		 * csService.getAuthUserPartnerEmailMapping().entrySet()) { List<List<? extends
-
 
829
		 * Serializable>> filteredRows = storeGuyEntry.getValue().stream() .map(x ->
-
 
830
		 * partnerRowMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
-
 
831
		 * ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers,
-
 
832
		 * filteredRows); String[] sendToArray = new String[] { storeGuyEntry.getKey()
-
 
833
		 * }; Utils.sendMailWithAttachment(googleMailSender, sendToArray, null,
-
 
834
		 * "Target vs Sales Summary", "PFA", fileName, new
-
 
835
		 * ByteArrayResource(baos.toByteArray())); }
-
 
836
		 */
-
 
837
 
826
 
838
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
827
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
839
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
828
		String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
840
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
829
		Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
841
				new ByteArrayResource(baos.toByteArray()));
830
				new ByteArrayResource(baos.toByteArray()));
Line 1358... Line 1347...
1358
			salesByFofoIdMap.put(fofoId, sale);
1347
			salesByFofoIdMap.put(fofoId, sale);
1359
			LOGGER.info(sale);
1348
			LOGGER.info(sale);
1360
		}
1349
		}
1361
		String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
1350
		String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
1362
		LOGGER.info(saleReport);
1351
		LOGGER.info(saleReport);
-
 
1352
		String cc[] = {};/*
1363
		String cc[] =  {};/*{ "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
1353
							 * { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
-
 
1354
							 * "prakash.rai@smartdukaan.com", "chaitnaya.vats@smartdukaan.com",
1364
				"chaitnaya.vats@smartdukaan.com", "adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };*/
1355
							 * "adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };
-
 
1356
							 */
1365
		String subject = "sale report till" + " " + now.format(timeFormatter);
1357
		String subject = "sale report till" + " " + now.format(timeFormatter);
1366
		this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
1358
		this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
1367
		//this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc, subject);
1359
		// this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc,
-
 
1360
		// subject);
1368
	}
1361
	}
1369
 
1362
 
1370
	public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
1363
	public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
1371
			throws ProfitMandiBusinessException {
1364
			throws ProfitMandiBusinessException {
1372
		StringBuilder sb = new StringBuilder();
1365
		StringBuilder sb = new StringBuilder();