| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.io.InputStream;
|
4 |
import java.io.InputStream;
|
| 5 |
import java.io.Serializable;
|
5 |
import java.io.Serializable;
|
| 6 |
import java.sql.Timestamp;
|
6 |
import java.sql.Timestamp;
|
| 7 |
import java.text.MessageFormat;
|
- |
|
| 8 |
import java.time.LocalDate;
|
7 |
import java.time.LocalDate;
|
| 9 |
import java.time.LocalDateTime;
|
8 |
import java.time.LocalDateTime;
|
| 10 |
import java.time.LocalTime;
|
9 |
import java.time.LocalTime;
|
| 11 |
import java.time.ZoneOffset;
|
10 |
import java.time.ZoneOffset;
|
| 12 |
import java.time.format.DateTimeFormatter;
|
11 |
import java.time.format.DateTimeFormatter;
|
| Line 23... |
Line 22... |
| 23 |
import java.util.stream.Collectors;
|
22 |
import java.util.stream.Collectors;
|
| 24 |
|
23 |
|
| 25 |
import javax.mail.MessagingException;
|
24 |
import javax.mail.MessagingException;
|
| 26 |
import javax.mail.internet.InternetAddress;
|
25 |
import javax.mail.internet.InternetAddress;
|
| 27 |
import javax.mail.internet.MimeMessage;
|
26 |
import javax.mail.internet.MimeMessage;
|
| 28 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 29 |
|
27 |
|
| 30 |
import org.apache.commons.codec.CharEncoding;
|
28 |
import org.apache.commons.codec.CharEncoding;
|
| 31 |
import org.apache.commons.io.IOUtils;
|
29 |
import org.apache.commons.io.IOUtils;
|
| 32 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
30 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 33 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
31 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
| Line 35... |
Line 33... |
| 35 |
import org.apache.http.entity.StringEntity;
|
33 |
import org.apache.http.entity.StringEntity;
|
| 36 |
import org.apache.http.impl.client.CloseableHttpClient;
|
34 |
import org.apache.http.impl.client.CloseableHttpClient;
|
| 37 |
import org.apache.http.impl.client.HttpClients;
|
35 |
import org.apache.http.impl.client.HttpClients;
|
| 38 |
import org.apache.logging.log4j.LogManager;
|
36 |
import org.apache.logging.log4j.LogManager;
|
| 39 |
import org.apache.logging.log4j.Logger;
|
37 |
import org.apache.logging.log4j.Logger;
|
| 40 |
import org.apache.poi.EncryptedDocumentException;
|
- |
|
| 41 |
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
- |
|
| 42 |
import org.json.JSONObject;
|
38 |
import org.json.JSONObject;
|
| 43 |
import org.springframework.beans.factory.annotation.Autowired;
|
39 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 44 |
import org.springframework.beans.factory.annotation.Qualifier;
|
40 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 45 |
import org.springframework.beans.factory.annotation.Value;
|
41 |
import org.springframework.beans.factory.annotation.Value;
|
| 46 |
import org.springframework.core.io.ByteArrayResource;
|
42 |
import org.springframework.core.io.ByteArrayResource;
|
| 47 |
import org.springframework.core.io.InputStreamSource;
|
43 |
import org.springframework.core.io.InputStreamSource;
|
| 48 |
import org.springframework.mail.javamail.JavaMailSender;
|
44 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 49 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
45 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| 50 |
import org.springframework.stereotype.Component;
|
46 |
import org.springframework.stereotype.Component;
|
| 51 |
import org.springframework.transaction.annotation.Transactional;
|
47 |
import org.springframework.transaction.annotation.Transactional;
|
| 52 |
import org.springframework.ui.Model;
|
- |
|
| 53 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 54 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 55 |
|
48 |
|
| 56 |
import com.google.common.collect.Lists;
|
49 |
import com.google.common.collect.Lists;
|
| 57 |
import com.google.gson.Gson;
|
50 |
import com.google.gson.Gson;
|
| 58 |
import com.google.gson.GsonBuilder;
|
51 |
import com.google.gson.GsonBuilder;
|
| 59 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
52 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| Line 84... |
Line 77... |
| 84 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
77 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 85 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
78 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 86 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
79 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 87 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
80 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 88 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
81 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 89 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
- |
|
| 90 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
82 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 91 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
83 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 92 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
84 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 93 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
85 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 94 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
86 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| Line 527... |
Line 519... |
| 527 |
processScheme(fromDate, LocalDateTime.now());
|
519 |
processScheme(fromDate, LocalDateTime.now());
|
| 528 |
}
|
520 |
}
|
| 529 |
|
521 |
|
| 530 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate) throws Exception {
|
522 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate) throws Exception {
|
| 531 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
523 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| - |
|
524 |
System.out.println(
|
| 532 |
System.out.println("InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
|
525 |
"InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
|
| 533 |
try {
|
526 |
try {
|
| 534 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
527 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
| 535 |
for (Purchase purchase : purchases) {
|
528 |
for (Purchase purchase : purchases) {
|
| 536 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
529 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
| 537 |
}
|
530 |
}
|
| Line 542... |
Line 535... |
| 542 |
}
|
535 |
}
|
| 543 |
} catch (Exception e) {
|
536 |
} catch (Exception e) {
|
| 544 |
e.printStackTrace();
|
537 |
e.printStackTrace();
|
| 545 |
throw e;
|
538 |
throw e;
|
| 546 |
}
|
539 |
}
|
| 547 |
List<UserWalletHistory> uwhs =userWalletHistoryRepository.selectAllByDateType(startDate, endDate, Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
540 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
|
| - |
|
541 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 548 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
542 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
| 549 |
for(UserWalletHistory uwh : uwhs) {
|
543 |
for (UserWalletHistory uwh : uwhs) {
|
| 550 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(), uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
544 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
|
| - |
|
545 |
uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
| 551 |
}
|
546 |
}
|
| 552 |
LOGGER.info("Schemes process successfully.");
|
547 |
LOGGER.info("Schemes process successfully.");
|
| 553 |
//throw new Exception();
|
548 |
// throw new Exception();
|
| 554 |
}
|
549 |
}
|
| 555 |
|
550 |
|
| 556 |
public void processRechargeCashback() throws Throwable {
|
551 |
public void processRechargeCashback() throws Throwable {
|
| 557 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
552 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
| 558 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
553 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
| Line 575... |
Line 570... |
| 575 |
}
|
570 |
}
|
| 576 |
LOGGER.info("Cashbacks for Recharge processed Successfully");
|
571 |
LOGGER.info("Cashbacks for Recharge processed Successfully");
|
| 577 |
}
|
572 |
}
|
| 578 |
|
573 |
|
| 579 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
574 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
| - |
|
575 |
if (sendTo == null) {
|
| - |
|
576 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| - |
|
577 |
"amit.gupta@shop2020.in");
|
| - |
|
578 |
}
|
| 580 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
579 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
| 581 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
580 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 582 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
581 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
| 583 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
582 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 584 |
|
583 |
|
| 585 |
List<String> headers = Arrays.asList("Code", "StoreName", "Email", "Mobile", "Wallet Amount",
|
584 |
List<String> headers = Arrays.asList("Code", "Store Name", "Firm Name", "State Manager", "Teritory Manager",
|
| 586 |
"Yesterday's Sale", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount",
|
585 |
"Team Leader", "Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount",
|
| 587 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short");
|
586 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short");
|
| 588 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
587 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
| - |
|
588 |
Map<String, List<? extends Serializable>> partnerRow = new HashMap<>();
|
| 589 |
for (FofoStore fofoStore : fofoStores) {
|
589 |
for (FofoStore fofoStore : fofoStores) {
|
| 590 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
590 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 591 |
if (retailer == null) {
|
591 |
if (retailer == null) {
|
| 592 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
592 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 593 |
continue;
|
593 |
continue;
|
| Line 595... |
Line 595... |
| 595 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
595 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
| 596 |
1);
|
596 |
1);
|
| 597 |
partnerDailyInvestment.setDate(yesterDay);
|
597 |
partnerDailyInvestment.setDate(yesterDay);
|
| 598 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
598 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
| 599 |
|
599 |
|
| 600 |
List<? extends Serializable> row = Arrays.asList(fofoStore.getCode(), retailer.getBusinessName(),
|
600 |
List<? extends Serializable> row = Arrays.asList(fofoStore.getCode(),
|
| - |
|
601 |
"SmartDukaan-" + fofoStore.getCode().substring(5), retailer.getBusinessName(),
|
| 601 |
retailer.getEmail(), retailer.getMobileNumber(), partnerDailyInvestment.getWalletAmount(),
|
602 |
storeManagerMap.get(retailer.getEmail()).get(2), storeManagerMap.get(retailer.getEmail()).get(1),
|
| 602 |
partnerDailyInvestment.getSalesAmount(), partnerDailyInvestment.getInStockAmount(), 0,
|
603 |
storeManagerMap.get(retailer.getEmail()).get(0), partnerDailyInvestment.getWalletAmount(), 0,
|
| 603 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
604 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
| 604 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
605 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
| 605 |
partnerDailyInvestment.getShortInvestment());
|
606 |
partnerDailyInvestment.getShortInvestment());
|
| - |
|
607 |
partnerRow.put(retailer.getEmail(), row);
|
| 606 |
rows.add(row);
|
608 |
rows.add(row);
|
| 607 |
|
609 |
|
| 608 |
}
|
610 |
}
|
| - |
|
611 |
Map<String, Set<String>> storeGuyMap = new HashMap<>();
|
| - |
|
612 |
for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
|
| - |
|
613 |
String storeEmail = entry.getKey();
|
| - |
|
614 |
List<String> storeGuys = entry.getValue();
|
| - |
|
615 |
for (String storeGuy : storeGuys) {
|
| - |
|
616 |
if (!storeGuyMap.containsKey(storeGuy)) {
|
| - |
|
617 |
storeGuyMap.put(storeGuy, new HashSet<>());
|
| - |
|
618 |
}
|
| - |
|
619 |
storeGuyMap.get(storeGuy).add(storeEmail);
|
| - |
|
620 |
}
|
| - |
|
621 |
}
|
| - |
|
622 |
|
| 609 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
623 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| - |
|
624 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| - |
|
625 |
List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
|
| - |
|
626 |
.map(x -> partnerRow.get(x)).collect(Collectors.toList());
|
| - |
|
627 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| - |
|
628 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
| - |
|
629 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Partner Investment Summary", "PFA",
|
| - |
|
630 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| - |
|
631 |
}
|
| - |
|
632 |
|
| 610 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
633 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 611 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
634 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 612 |
|
- |
|
| 613 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Partner Investment Summary", "PFA", fileName,
|
635 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Partner Investment Summary", "PFA", fileName,
|
| 614 |
new ByteArrayResource(baos.toByteArray()));
|
636 |
new ByteArrayResource(baos.toByteArray()));
|
| 615 |
|
637 |
|
| 616 |
}
|
638 |
}
|
| 617 |
|
639 |
|
| 618 |
public void sendPartnerInvestmentDetails() throws Exception {
|
640 |
public void sendPartnerInvestmentDetails() throws Exception {
|
| 619 |
List<String> sendTo = Arrays.asList("adeel.yazdani@smartdukaan.com", "amandeep.singh@smartdukaan.com",
|
- |
|
| 620 |
"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "dhruv.kathpal@smartdukaan.com",
|
- |
|
| 621 |
"neeraj.gupta@smartdukaan.com");
|
- |
|
| 622 |
this.sendPartnerInvestmentDetails(sendTo);
|
641 |
this.sendPartnerInvestmentDetails(null);
|
| 623 |
|
642 |
|
| 624 |
}
|
643 |
}
|
| 625 |
|
644 |
|
| 626 |
private void sendMailWithAttachments(String[] email, String[] ccEmails, String body, String subject,
|
645 |
private void sendMailWithAttachments(String[] email, String[] ccEmails, String body, String subject,
|
| 627 |
Map<String, InputStream> inputStreams)
|
646 |
Map<String, InputStream> inputStreams)
|
| Line 641... |
Line 660... |
| 641 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
660 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
| 642 |
helper.setFrom(senderAddress);
|
661 |
helper.setFrom(senderAddress);
|
| 643 |
mailSender.send(message);
|
662 |
mailSender.send(message);
|
| 644 |
}
|
663 |
}
|
| 645 |
|
664 |
|
| 646 |
private void sendMailWithAttachmentsForPartners(String email, String body, String subject, InputStream is)
|
- |
|
| 647 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
665 |
public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
|
| 648 |
MimeMessage message = mailSender.createMimeMessage();
|
- |
|
| 649 |
MimeMessageHelper helper = new MimeMessageHelper(message, true, CharEncoding.UTF_8);
|
- |
|
| 650 |
helper.setSubject(subject);
|
- |
|
| 651 |
helper.setText(body);
|
- |
|
| 652 |
helper.addAttachment("DailySaleTargetReports_" + LocalDate.now() + ".xls",
|
- |
|
| 653 |
new ByteArrayResource(IOUtils.toByteArray(is)));
|
- |
|
| 654 |
helper.setTo(email);
|
- |
|
| 655 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
- |
|
| 656 |
helper.setFrom(senderAddress);
|
- |
|
| 657 |
mailSender.send(message);
|
- |
|
| 658 |
}
|
- |
|
| 659 |
|
666 |
|
| - |
|
667 |
if (sendTo == null) {
|
| 660 |
public void sendMailToSalesHeadAboutTargetAndSales(SaleHeadDetails salesHeadDetail)
|
668 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 661 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
669 |
"amit.gupta@shop2020.in");
|
| - |
|
670 |
}
|
| 662 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
671 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 663 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
672 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 664 |
Map<String, InputStream> inputStreams = new HashMap<>();
|
673 |
Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = new HashMap<>();
|
| 665 |
for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
|
674 |
for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
|
| 666 |
InputStream is = targetService.getDailySaleReportVsTargetForSaleHead(partnerTargetDetail,
|
675 |
partnerSalesTargetRowsMap.putAll(targetService.getDailySaleReportVsTarget(partnerTargetDetail));
|
| 667 |
salesHeadDetail.getName());
|
- |
|
| 668 |
|
- |
|
| 669 |
inputStreams.put(partnerTargetDetail.getTargetName(), is);
|
- |
|
| 670 |
|
- |
|
| 671 |
}
|
676 |
}
|
| 672 |
// String[] ccEmails = null;
|
- |
|
| 673 |
if (partnerTargetDetails.size() > 0) {
|
- |
|
| 674 |
String[] ccEmails = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com",
|
- |
|
| 675 |
"chaitnaya.vats@smartdukaan.com", "amit.gupta@shop2020.in" };
|
- |
|
| 676 |
String subject = "Daily Sales Report ";
|
- |
|
| 677 |
String message = MessageFormat.format("Sale Target summary for {0}", LocalDate.now());
|
677 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 678 |
LOGGER.info("message" + message);
|
- |
|
| 679 |
if (salesHeadDetail.getName().equals("Kamal")) {
|
- |
|
| 680 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
678 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
| 681 |
String[] to = { salesHeadDetail.getEmail(), "mohinder.mutreja@smartdukaan.com" };
|
679 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 682 |
|
680 |
|
| - |
|
681 |
List<String> headers = Arrays.asList("Code", "Store Name", "Firm Name", "State Manager", "Teritory Manager",
|
| - |
|
682 |
"Team Leader", "Target Name", "Target Value", "Target Achieved", "Today Achievement Percentage",
|
| 683 |
this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
683 |
"Daily target", "Today's achievement", "Remaining Target");
|
| 684 |
|
684 |
|
| - |
|
685 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
| - |
|
686 |
Map<String, List<Serializable>> partnerRowMap = new HashMap<>();
|
| 685 |
} else {
|
687 |
for (FofoStore fofoStore : fofoStores) {
|
| 686 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
688 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 687 |
String[] to = { salesHeadDetail.getEmail() };
|
689 |
if (retailer == null) {
|
| 688 |
this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
690 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| - |
|
691 |
continue;
|
| 689 |
}
|
692 |
}
|
| - |
|
693 |
Serializable code = fofoStore.getCode();
|
| - |
|
694 |
Serializable storeName = "SmartDukaan-" + fofoStore.getCode().substring(5);
|
| - |
|
695 |
Serializable stateManager = storeManagerMap.get(retailer.getEmail()).get(2);
|
| - |
|
696 |
Serializable territoryManager = storeManagerMap.get(retailer.getEmail()).get(1);
|
| - |
|
697 |
Serializable teamLeader = storeManagerMap.get(retailer.getEmail()).get(0);
|
| - |
|
698 |
List<Serializable> row = Arrays.asList(fofoStore.getCode(),
|
| - |
|
699 |
"SmartDukaan-" + fofoStore.getCode().substring(5), retailer.getBusinessName(), stateManager,
|
| - |
|
700 |
territoryManager, teamLeader);
|
| - |
|
701 |
row.addAll(0, partnerSalesTargetRowsMap.get(retailer.getEmail()));
|
| - |
|
702 |
partnerRowMap.put(retailer.getEmail(), row);
|
| - |
|
703 |
rows.add(row);
|
| - |
|
704 |
|
| 690 |
}
|
705 |
}
|
| 691 |
}
|
- |
|
| 692 |
|
706 |
|
| 693 |
public void sendMailToPartnerAboutTargetAndSales() throws ProfitMandiBusinessException, MessagingException,
|
- |
|
| 694 |
IOException, EncryptedDocumentException, InvalidFormatException {
|
- |
|
| 695 |
List<Integer> fofoIds = targetService.getfofoIdsFromfofoStore();
|
707 |
Map<String, Set<String>> storeGuyMap = new HashMap<>();
|
| 696 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService
|
708 |
for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
|
| 697 |
.getFofoRetailers(new ArrayList<>(fofoIds));
|
709 |
String storeEmail = entry.getKey();
|
| 698 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
710 |
List<String> storeGuys = entry.getValue();
|
| 699 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
- |
|
| 700 |
for (Integer fofoId : fofoIds) {
|
711 |
for (String storeGuy : storeGuys) {
|
| 701 |
InputStream is = targetService.getDailySaleReportVsTargetForPartner(fofoId, partnerTargetDetails);
|
712 |
if (!storeGuyMap.containsKey(storeGuy)) {
|
| 702 |
LOGGER.info("is" + is);
|
713 |
storeGuyMap.put(storeGuy, new HashSet<>());
|
| 703 |
if (is == null) {
|
714 |
}
|
| 704 |
continue;
|
715 |
storeGuyMap.get(storeGuy).add(storeEmail);
|
| 705 |
}
|
716 |
}
|
| 706 |
LOGGER.info("fofoId" + fofoId);
|
- |
|
| 707 |
|
717 |
}
|
| 708 |
LOGGER.info(fofoIdsAndCustomRetailer.get(fofoId).getEmail());
|
- |
|
| 709 |
String subject = "Daily Sales Report";
|
- |
|
| 710 |
String message = MessageFormat.format("Sale Target summary for {0}", LocalDate.now());
|
- |
|
| 711 |
LOGGER.info(message);
|
- |
|
| 712 |
this.sendMailWithAttachmentsForPartners(fofoIdsAndCustomRetailer.get(fofoId).getEmail(), message, subject,
|
- |
|
| 713 |
is);
|
- |
|
| 714 |
|
718 |
|
| - |
|
719 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| - |
|
720 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| - |
|
721 |
List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
|
| - |
|
722 |
.map(x -> partnerRowMap.get(x)).collect(Collectors.toList());
|
| - |
|
723 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| - |
|
724 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
| - |
|
725 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA",
|
| - |
|
726 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 715 |
}
|
727 |
}
|
| - |
|
728 |
|
| - |
|
729 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| - |
|
730 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| - |
|
731 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Target vs Sales Summary", "PFA", fileName,
|
| - |
|
732 |
new ByteArrayResource(baos.toByteArray()));
|
| 716 |
}
|
733 |
}
|
| 717 |
|
734 |
|
| 718 |
public void sendAgeingReport(String... sendTo) throws Exception {
|
735 |
public void sendAgeingReport(String... sendTo) throws Exception {
|
| 719 |
|
736 |
|
| 720 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
|
737 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
|
| Line 1334... |
Line 1351... |
| 1334 |
|
1351 |
|
| 1335 |
}
|
1352 |
}
|
| 1336 |
}
|
1353 |
}
|
| 1337 |
}
|
1354 |
}
|
| 1338 |
|
1355 |
|
| - |
|
1356 |
public static final Map<String, String> nameEmail = new HashMap<>();
|
| - |
|
1357 |
|
| - |
|
1358 |
public static final Map<String, List<String>> storeManagerMap = new HashMap<>();
|
| - |
|
1359 |
|
| - |
|
1360 |
static {
|
| - |
|
1361 |
nameEmail.put("Amod", "amod.sen@smartdukaan.com");
|
| - |
|
1362 |
nameEmail.put("Pramod", "pk957415@gmail.com");
|
| - |
|
1363 |
nameEmail.put("Anis", "md.anis@smartdukaan.com");
|
| - |
|
1364 |
nameEmail.put("Manoj", "mspatwal545@gmail.com");
|
| - |
|
1365 |
nameEmail.put("Adeel", "adeel.yazdani@smartdukaan.com");
|
| - |
|
1366 |
nameEmail.put("Mohinder", "mohinder.mutreja@smartdukaan.coms");
|
| - |
|
1367 |
nameEmail.put("Dharmendar", "dharmender.verma@smartdukaan.com");
|
| - |
|
1368 |
nameEmail.put("Rajat", "rajat.gupta@smartdukaan.com");
|
| - |
|
1369 |
nameEmail.put("Ankit", "ankit.bhatia@smartdukaan.com");
|
| - |
|
1370 |
nameEmail.put("Rajit", "rajit.alag@smartdukaan.com");
|
| - |
|
1371 |
nameEmail.put("Gulshan", "gul9711251125@gmail.com");
|
| - |
|
1372 |
nameEmail.put("PramodSharma", "prmdretail@gmail.com");
|
| - |
|
1373 |
// nameEmail.put("Gulshan","");
|
| - |
|
1374 |
storeManagerMap.put("themobileplanet03@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1375 |
storeManagerMap.put("mobileplanet7599@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1376 |
storeManagerMap.put("robintelecom.snp@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1377 |
storeManagerMap.put("smartconnect4141@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1378 |
storeManagerMap.put("bhimsain919@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1379 |
storeManagerMap.put("babitaranirk@gmail.com", Arrays.asList("Pramod", "", "Mohinder"));
|
| - |
|
1380 |
storeManagerMap.put("dharmendery079@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1381 |
storeManagerMap.put("kkv.enterprises1@gmail.com", Arrays.asList("Pramod", "", "Mohinder"));
|
| - |
|
1382 |
storeManagerMap.put("gulshersaifi74226@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1383 |
storeManagerMap.put("deepak.lalwani1985@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1384 |
storeManagerMap.put("gupta.smartdukaan@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1385 |
storeManagerMap.put("sachinindri2006@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1386 |
storeManagerMap.put("kambojanil83@gmail.com", Arrays.asList("Pramod", "", "Mohinder"));
|
| - |
|
1387 |
storeManagerMap.put("uppal.neeraj82@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1388 |
storeManagerMap.put("thefonehousekarnal@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1389 |
storeManagerMap.put("richa9910763006@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1390 |
storeManagerMap.put("smartdukangzb@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1391 |
storeManagerMap.put("lovelymobile183@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1392 |
storeManagerMap.put("smartdukaan.sonepat@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1393 |
storeManagerMap.put("arunmittal299@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1394 |
storeManagerMap.put("gtc01100@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1395 |
storeManagerMap.put("sumittyagi1975@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1396 |
storeManagerMap.put("metrofurniture342@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1397 |
storeManagerMap.put("suryaelectronicskaithal@gmail.com", Arrays.asList("Pramod", "", "Mohinder"));
|
| - |
|
1398 |
storeManagerMap.put("mmtelecomsec16@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1399 |
storeManagerMap.put("omsonsindia08@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1400 |
storeManagerMap.put("smartenterprisespv@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1401 |
storeManagerMap.put("cachaitnya@gmail.com", Arrays.asList("Amod", "", "Adeel"));
|
| - |
|
1402 |
storeManagerMap.put("ajaykumarkansal03@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1403 |
storeManagerMap.put("spurwar73@gmail.com", Arrays.asList("Anis", "Rajat", "Adeel"));
|
| - |
|
1404 |
storeManagerMap.put("Shreemobile.ind@gmail.com", Arrays.asList("Anis", "Rajat", "Adeel"));
|
| - |
|
1405 |
storeManagerMap.put("felixenterprises2017@rediffmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
|
| - |
|
1406 |
storeManagerMap.put("nareandergupta@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
|
| - |
|
1407 |
storeManagerMap.put("shreebalajielectronic2019@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1408 |
storeManagerMap.put("saranshary@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
|
| - |
|
1409 |
storeManagerMap.put("gambhirsmartphone@gmail.com", Arrays.asList("", "Gulshan", "Adeel"));
|
| - |
|
1410 |
storeManagerMap.put("Priyankaenterprises9910@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1411 |
storeManagerMap.put("pawan.dhimaan@gmail.com", Arrays.asList("", "Dharmendar", "Mohinder"));
|
| - |
|
1412 |
storeManagerMap.put("lakshaydhulla62@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1413 |
storeManagerMap.put("parastelecom.stp@gmail.com", Arrays.asList("Anis", "Rajat", "Adeel"));
|
| - |
|
1414 |
storeManagerMap.put("talwarmukesh298@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1415 |
storeManagerMap.put("sahilnarang0009@gmail.com", Arrays.asList("Pramod", "", "Mohinder"));
|
| - |
|
1416 |
storeManagerMap.put("supertelecomjind@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1417 |
storeManagerMap.put("saketnagpal@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
|
| - |
|
1418 |
storeManagerMap.put("DEEPAKGOYAL702.DG@GMAIL.COM", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1419 |
storeManagerMap.put("sambhav350@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1420 |
storeManagerMap.put("mayankarora98133@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1421 |
storeManagerMap.put("vijaymobilityandmoew@gmail.com", Arrays.asList("Manoj", "", "Adeel"));
|
| - |
|
1422 |
storeManagerMap.put("amitv70003@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1423 |
storeManagerMap.put("newagelucknow.123@gmail.com", Arrays.asList("Anis", "Rajat", "Adeel"));
|
| - |
|
1424 |
storeManagerMap.put("Newagetechnologygomtinagar@gmail.com", Arrays.asList("Anis", "Rajat", "Adeel"));
|
| - |
|
1425 |
storeManagerMap.put("rohitbatra106@gmail.com", Arrays.asList("Pramod", "Dharmendar", "Mohinder"));
|
| - |
|
1426 |
storeManagerMap.put("sonisunil9050873061@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1427 |
storeManagerMap.put("moderncohsr@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1428 |
storeManagerMap.put("raghubir.ngh@gmail.com", Arrays.asList("", "Ankit", "Mohinder"));
|
| - |
|
1429 |
storeManagerMap.put("aman007singla@gmail.com", Arrays.asList("", "Rajit", "Mohinder"));
|
| - |
|
1430 |
}
|
| 1339 |
}
|
1431 |
}
|