| Line 1... |
Line 1... |
| 1 |
package com.smartdukaan.cron.scheduled;
|
1 |
package com.smartdukaan.cron.scheduled;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.io.InputStream;
|
- |
|
| 5 |
import java.io.Serializable;
|
4 |
import java.io.Serializable;
|
| 6 |
import java.sql.Timestamp;
|
5 |
import java.sql.Timestamp;
|
| 7 |
import java.time.LocalDate;
|
6 |
import java.time.LocalDate;
|
| 8 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| 9 |
import java.time.LocalTime;
|
8 |
import java.time.LocalTime;
|
| Line 23... |
Line 22... |
| 23 |
|
22 |
|
| 24 |
import javax.mail.MessagingException;
|
23 |
import javax.mail.MessagingException;
|
| 25 |
import javax.mail.internet.InternetAddress;
|
24 |
import javax.mail.internet.InternetAddress;
|
| 26 |
import javax.mail.internet.MimeMessage;
|
25 |
import javax.mail.internet.MimeMessage;
|
| 27 |
|
26 |
|
| 28 |
import org.apache.commons.codec.CharEncoding;
|
- |
|
| 29 |
import org.apache.commons.io.IOUtils;
|
- |
|
| 30 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
27 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 31 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
28 |
import org.apache.http.client.methods.CloseableHttpResponse;
|
| 32 |
import org.apache.http.client.methods.HttpPost;
|
29 |
import org.apache.http.client.methods.HttpPost;
|
| 33 |
import org.apache.http.entity.StringEntity;
|
30 |
import org.apache.http.entity.StringEntity;
|
| 34 |
import org.apache.http.impl.client.CloseableHttpClient;
|
31 |
import org.apache.http.impl.client.CloseableHttpClient;
|
| Line 585... |
Line 582... |
| 585 |
"Team Leader", "Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount",
|
582 |
"Team Leader", "Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount",
|
| 586 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short");
|
583 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short");
|
| 587 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
584 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
| 588 |
Map<String, List<? extends Serializable>> partnerRow = new HashMap<>();
|
585 |
Map<String, List<? extends Serializable>> partnerRow = new HashMap<>();
|
| 589 |
for (FofoStore fofoStore : fofoStores) {
|
586 |
for (FofoStore fofoStore : fofoStores) {
|
| - |
|
587 |
if (!fofoStore.isActive())
|
| - |
|
588 |
continue;
|
| 590 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
589 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 591 |
if (retailer == null) {
|
590 |
if (retailer == null || storeManagerMap.get(retailer.getEmail()) == null) {
|
| 592 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
591 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 593 |
continue;
|
592 |
continue;
|
| 594 |
}
|
593 |
}
|
| 595 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
594 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
| 596 |
1);
|
595 |
1);
|
| Line 640... |
Line 639... |
| 640 |
public void sendPartnerInvestmentDetails() throws Exception {
|
639 |
public void sendPartnerInvestmentDetails() throws Exception {
|
| 641 |
this.sendPartnerInvestmentDetails(null);
|
640 |
this.sendPartnerInvestmentDetails(null);
|
| 642 |
|
641 |
|
| 643 |
}
|
642 |
}
|
| 644 |
|
643 |
|
| 645 |
private void sendMailWithAttachments(String[] email, String[] ccEmails, String body, String subject,
|
- |
|
| 646 |
Map<String, InputStream> inputStreams)
|
- |
|
| 647 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
- |
|
| 648 |
MimeMessage message = mailSender.createMimeMessage();
|
- |
|
| 649 |
MimeMessageHelper helper = new MimeMessageHelper(message, true, CharEncoding.UTF_8);
|
- |
|
| 650 |
helper.setSubject(subject);
|
- |
|
| 651 |
helper.setText(body);
|
- |
|
| 652 |
if (ccEmails != null) {
|
- |
|
| 653 |
helper.setCc(ccEmails);
|
- |
|
| 654 |
}
|
- |
|
| 655 |
for (String attachment : inputStreams.keySet()) {
|
- |
|
| 656 |
helper.addAttachment(attachment + "_" + LocalDate.now() + ".xls",
|
- |
|
| 657 |
new ByteArrayResource(IOUtils.toByteArray(inputStreams.get(attachment))));
|
- |
|
| 658 |
}
|
- |
|
| 659 |
helper.setTo(email);
|
- |
|
| 660 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
- |
|
| 661 |
helper.setFrom(senderAddress);
|
- |
|
| 662 |
mailSender.send(message);
|
- |
|
| 663 |
}
|
- |
|
| 664 |
|
- |
|
| 665 |
public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
|
644 |
public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
|
| 666 |
|
645 |
|
| 667 |
if (sendTo == null) {
|
646 |
if (sendTo == null) {
|
| 668 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
647 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 669 |
"amit.gupta@shop2020.in");
|
648 |
"amit.gupta@shop2020.in");
|
| Line 683... |
Line 662... |
| 683 |
"Daily target", "Today's achievement", "Remaining Target");
|
662 |
"Daily target", "Today's achievement", "Remaining Target");
|
| 684 |
|
663 |
|
| 685 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
664 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
| 686 |
Map<String, List<Serializable>> partnerRowMap = new HashMap<>();
|
665 |
Map<String, List<Serializable>> partnerRowMap = new HashMap<>();
|
| 687 |
for (FofoStore fofoStore : fofoStores) {
|
666 |
for (FofoStore fofoStore : fofoStores) {
|
| - |
|
667 |
if (!fofoStore.isActive())
|
| - |
|
668 |
continue;
|
| 688 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
669 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 689 |
if (retailer == null) {
|
670 |
if (retailer == null || storeManagerMap.get(retailer.getEmail()) == null) {
|
| 690 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
671 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 691 |
continue;
|
672 |
continue;
|
| 692 |
}
|
673 |
}
|
| 693 |
Serializable code = fofoStore.getCode();
|
674 |
Serializable code = fofoStore.getCode();
|
| 694 |
Serializable storeName = "SmartDukaan-" + fofoStore.getCode().substring(5);
|
675 |
Serializable storeName = "SmartDukaan-" + fofoStore.getCode().substring(5);
|
| - |
|
676 |
Serializable businessName = retailer.getBusinessName();
|
| 695 |
Serializable stateManager = storeManagerMap.get(retailer.getEmail()).get(2);
|
677 |
Serializable stateManager = storeManagerMap.get(retailer.getEmail()).get(2);
|
| 696 |
Serializable territoryManager = storeManagerMap.get(retailer.getEmail()).get(1);
|
678 |
Serializable territoryManager = storeManagerMap.get(retailer.getEmail()).get(1);
|
| 697 |
Serializable teamLeader = storeManagerMap.get(retailer.getEmail()).get(0);
|
679 |
Serializable teamLeader = storeManagerMap.get(retailer.getEmail()).get(0);
|
| 698 |
List<Serializable> row = Arrays.asList(fofoStore.getCode(),
|
680 |
List<Serializable> row = Arrays.asList(code, storeName, businessName, stateManager, territoryManager,
|
| 699 |
"SmartDukaan-" + fofoStore.getCode().substring(5), retailer.getBusinessName(), stateManager,
|
- |
|
| 700 |
territoryManager, teamLeader);
|
681 |
teamLeader);
|
| 701 |
row.addAll(0, partnerSalesTargetRowsMap.get(retailer.getEmail()));
|
682 |
row.addAll(0, partnerSalesTargetRowsMap.get(retailer.getEmail()));
|
| 702 |
partnerRowMap.put(retailer.getEmail(), row);
|
683 |
partnerRowMap.put(retailer.getEmail(), row);
|
| 703 |
rows.add(row);
|
684 |
rows.add(row);
|
| 704 |
|
685 |
|
| 705 |
}
|
686 |
}
|