| 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 |
/*
|
- |
|
| 775 |
* sendTo = Arrays.asList("tarun.verma@smartdukaan.com",
|
774 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 776 |
* "kamini.sharma@smartdukaan.com", "amit.gupta@shop2020.in",
|
- |
|
| 777 |
* "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
|
775 |
"amit.gupta@shop2020.in", "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
|
| 778 |
*/
|
- |
|
| 779 |
sendTo = Arrays.asList("amit.gupta@shop2020.in");
|
- |
|
| 780 |
}
|
776 |
}
|
| 781 |
Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
|
777 |
Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
|
| 782 |
partnerSalesTargetRowsMap = targetService.getDailySaleReportVsTarget();
|
778 |
partnerSalesTargetRowsMap = targetService.getDailySaleReportVsTarget();
|
| 783 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
779 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
| 784 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
780 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| Line 794... |
Line 790... |
| 794 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "Current Category", "State Manager",
|
790 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "Current Category", "State Manager",
|
| 795 |
"Teritory Manager", "Team Leader", "Targeted Category", "Targeted Value", "Target Achieved",
|
791 |
"Teritory Manager", "Team Leader", "Targeted Category", "Targeted Value", "Target Achieved",
|
| 796 |
"Achived Percentage", "Remaining Target", "Today's Target", "Today's achievement");
|
792 |
"Achived Percentage", "Remaining Target", "Today's Target", "Today's achievement");
|
| 797 |
|
793 |
|
| 798 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
794 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
| 799 |
Map<String, List<Serializable>> partnerRowMap = new HashMap<>();
|
795 |
Map<String, List<? extends Serializable>> partnerRowMap = new HashMap<>();
|
| 800 |
for (Map.Entry<String, List<? extends Serializable>> partnerSalesTargetRowEntry : partnerSalesTargetRowsMap
|
796 |
for (Map.Entry<String, List<? extends Serializable>> partnerSalesTargetRowEntry : partnerSalesTargetRowsMap
|
| 801 |
.entrySet()) {
|
797 |
.entrySet()) {
|
| 802 |
CustomRetailer retailer = customRetailerEmailMap.get(partnerSalesTargetRowEntry.getKey());
|
798 |
CustomRetailer retailer = customRetailerEmailMap.get(partnerSalesTargetRowEntry.getKey());
|
| 803 |
FofoStore fofoStore = fofoStoresMap.get(retailer.getPartnerId());
|
799 |
FofoStore fofoStore = fofoStoresMap.get(retailer.getPartnerId());
|
| 804 |
Serializable code = fofoStore.getCode();
|
800 |
Serializable code = fofoStore.getCode();
|
| Line 821... |
Line 817... |
| 821 |
}
|
817 |
}
|
| 822 |
|
818 |
|
| 823 |
}
|
819 |
}
|
| 824 |
|
820 |
|
| 825 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
821 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| - |
|
822 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| - |
|
823 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| - |
|
824 |
if (storeGuyEntry.getValue().size() == 0)
|
| - |
|
825 |
continue;
|
| - |
|
826 |
List<List<? extends Serializable>> storeGuyRows = storeGuyEntry.getValue().stream()
|
| - |
|
827 |
.map(x -> partnerRowMap.get(x)).collect(Collectors.toList());
|
| - |
|
828 |
ByteArrayOutputStream authUserStream = FileUtil.getCSVByteStream(headers, storeGuyRows);
|
| - |
|
829 |
Attachment attache = new Attachment(fileName, new ByteArrayResource(authUserStream.toByteArray()));
|
| - |
|
830 |
System.out.println(storeGuyEntry.getValue());
|
| - |
|
831 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
| - |
|
832 |
"Franchise Stock Report", "PFA", attache);
|
| - |
|
833 |
}
|
| 826 |
|
834 |
|
| 827 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
835 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 828 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
836 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 829 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
|
837 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
|
| 830 |
new ByteArrayResource(baos.toByteArray()));
|
838 |
new ByteArrayResource(baos.toByteArray()));
|