| Line 377... |
Line 377... |
| 377 |
"kamini.sharma@smartdukaan.com", "dhruv.kathpal@smartdukaan.com" },
|
377 |
"kamini.sharma@smartdukaan.com", "dhruv.kathpal@smartdukaan.com" },
|
| 378 |
"Partner Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
378 |
"Partner Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 379 |
}
|
379 |
}
|
| 380 |
|
380 |
|
| 381 |
private void sendMailWithAttachments(String[] email, String[] ccEmails, String body, String subject,
|
381 |
private void sendMailWithAttachments(String[] email, String[] ccEmails, String body, String subject,
|
| 382 |
InputStream is)
|
382 |
Map<String, InputStream> inputStreams)
|
| 383 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
383 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 384 |
MimeMessage message = mailSender.createMimeMessage();
|
384 |
MimeMessage message = mailSender.createMimeMessage();
|
| 385 |
MimeMessageHelper helper = new MimeMessageHelper(message, true, CharEncoding.UTF_8);
|
385 |
MimeMessageHelper helper = new MimeMessageHelper(message, true, CharEncoding.UTF_8);
|
| 386 |
helper.setSubject(subject);
|
386 |
helper.setSubject(subject);
|
| 387 |
helper.setText(body);
|
387 |
helper.setText(body);
|
| 388 |
if (ccEmails != null) {
|
388 |
if (ccEmails != null) {
|
| 389 |
helper.setCc(ccEmails);
|
389 |
helper.setCc(ccEmails);
|
| 390 |
}
|
390 |
}
|
| - |
|
391 |
for(String attachment:inputStreams.keySet())
|
| - |
|
392 |
{
|
| 391 |
helper.addAttachment("DailySaleTargetReports_"+LocalDate.now()+".xls",new ByteArrayResource(IOUtils.toByteArray(is)));
|
393 |
helper.addAttachment(attachment+"_"+LocalDate.now()+".xls",new ByteArrayResource(IOUtils.toByteArray(inputStreams.get(attachment))));
|
| - |
|
394 |
}
|
| 392 |
helper.setTo(email);
|
395 |
helper.setTo(email);
|
| 393 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "ProfitMandi Admin");
|
396 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "ProfitMandi Admin");
|
| 394 |
helper.setFrom(senderAddress);
|
397 |
helper.setFrom(senderAddress);
|
| 395 |
mailSender.send(message);
|
398 |
mailSender.send(message);
|
| 396 |
}
|
399 |
}
|
| Line 428... |
Line 431... |
| 428 |
LOGGER.info("message" + message);
|
431 |
LOGGER.info("message" + message);
|
| 429 |
if (salesHeadDetail.getName().equals("Kamal")) {
|
432 |
if (salesHeadDetail.getName().equals("Kamal")) {
|
| 430 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
433 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
| 431 |
String[] to = { salesHeadDetail.getEmail(), "mohinder.mutreja@smartdukaan.com" };
|
434 |
String[] to = { salesHeadDetail.getEmail(), "mohinder.mutreja@smartdukaan.com" };
|
| 432 |
|
435 |
|
| 433 |
//this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
436 |
this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
| 434 |
|
437 |
|
| 435 |
} else {
|
438 |
} else {
|
| 436 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
439 |
LOGGER.info("salesHeadDetail.getName()" + salesHeadDetail.getName());
|
| 437 |
String[] to = { salesHeadDetail.getEmail() };
|
440 |
String[] to = { salesHeadDetail.getEmail() };
|
| 438 |
//this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
441 |
this.sendMailWithAttachments(to, ccEmails, message, subject, inputStreams);
|
| 439 |
}
|
442 |
}
|
| 440 |
}
|
443 |
}
|
| 441 |
|
444 |
|
| 442 |
public void sendMailToPartnerAboutTargetAndSales()
|
445 |
public void sendMailToPartnerAboutTargetAndSales()
|
| 443 |
throws ProfitMandiBusinessException, MessagingException, IOException, EncryptedDocumentException, InvalidFormatException {
|
446 |
throws ProfitMandiBusinessException, MessagingException, IOException, EncryptedDocumentException, InvalidFormatException {
|
| 444 |
List<Integer> fofoIds = targetService.getfofoIdsFromfofoStore();
|
447 |
List<Integer> fofoIds = targetService.getfofoIdsFromfofoStore();
|
| 445 |
Map<String, InputStream> inputStreams = new HashMap<>();
|
- |
|
| 446 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService
|
448 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService
|
| 447 |
.getFofoRetailers(new ArrayList<>(fofoIds));
|
449 |
.getFofoRetailers(new ArrayList<>(fofoIds));
|
| 448 |
List<InputStream> input=new ArrayList<>();
|
450 |
List<InputStream> input=new ArrayList<>();
|
| 449 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
451 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 450 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
452 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|