| Line 1345... |
Line 1345... |
| 1345 |
model.getInsuranceSale(), model.getTotalSale(), now.format(timeFormatter)));
|
1345 |
model.getInsuranceSale(), model.getTotalSale(), now.format(timeFormatter)));
|
| 1346 |
sendNotificationModel.setType("url");
|
1346 |
sendNotificationModel.setType("url");
|
| 1347 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
1347 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1348 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
1348 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1349 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1349 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
1350 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| 1350 |
sendNotificationModel.setUserIds(Arrays.asList(fofoId));
|
1351 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 1351 |
notificationService.sendNotification(sendNotificationModel);
|
1352 |
notificationService.sendNotification(sendNotificationModel);
|
| 1352 |
}
|
1353 |
}
|
| 1353 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
1354 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
| 1354 |
LOGGER.info(saleReport);
|
1355 |
LOGGER.info(saleReport);
|
| 1355 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
1356 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
| Line 1452... |
Line 1453... |
| 1452 |
}
|
1453 |
}
|
| 1453 |
|
1454 |
|
| 1454 |
}
|
1455 |
}
|
| 1455 |
|
1456 |
|
| 1456 |
private String getDailySalesReportHtml(Map<Integer, List<Serializable>> partnerSalesHeadersMap,
|
1457 |
private String getDailySalesReportHtml(Map<Integer, List<Serializable>> partnerSalesHeadersMap,
|
| 1457 |
Map<Integer, SaleTargetReportModel> saleReportTargetMap)
|
1458 |
Map<Integer, SaleTargetReportModel> saleReportTargetMap) throws ProfitMandiBusinessException {
|
| 1458 |
throws ProfitMandiBusinessException {
|
- |
|
| 1459 |
StringBuilder sb = new StringBuilder();
|
1459 |
StringBuilder sb = new StringBuilder();
|
| 1460 |
|
1460 |
|
| 1461 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
1461 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 1462 |
sb.append("<tbody>\n" + " <tr>\n"
|
1462 |
sb.append("<tbody>\n" + " <tr>\n"
|
| 1463 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
1463 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
| 1464 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
1464 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
| 1465 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
1465 |
+ " <th style='border:1px solid black;padding: 5px'>%s</th>\n"
|
| Line 1776... |
Line 1776... |
| 1776 |
|
1776 |
|
| 1777 |
this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
|
1777 |
this.sendMailWithAttachments(subject, messageText, customRetailer.getEmail());
|
| 1778 |
String notificationMessage = this.getNotificationMessage(focusedModelShortageModel);
|
1778 |
String notificationMessage = this.getNotificationMessage(focusedModelShortageModel);
|
| 1779 |
|
1779 |
|
| 1780 |
LOGGER.info("notificationMessage" + notificationMessage);
|
1780 |
LOGGER.info("notificationMessage" + notificationMessage);
|
| 1781 |
SimpleCampaignParams scp = new SimpleCampaignParams();
|
- |
|
| 1782 |
|
1781 |
|
| 1783 |
scp.setTitle("Alert");
|
- |
|
| 1784 |
scp.setType("url");
|
- |
|
| 1785 |
scp.setUrl("http://app.smartdukaan.com/pages/home/notifications");
|
1782 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1786 |
scp.setMessage(notificationMessage);
|
- |
|
| 1787 |
scp.setExpireTimestamp(LocalDateTime.now().plusDays(2));
|
1783 |
sendNotificationModel.setCampaignName("Stock Alert");
|
| 1788 |
SimpleCampaign sc = new SimpleCampaign(scp);
|
1784 |
sendNotificationModel.setTitle("Alert");
|
| 1789 |
sc.setSimpleCampaignParams(scp);
|
- |
|
| 1790 |
LOGGER.info("scp" + scp);
|
- |
|
| 1791 |
NotificationCampaign nc = new NotificationCampaign();
|
1785 |
sendNotificationModel.setMessage(notificationMessage);
|
| 1792 |
nc.setName("Stock Alert");
|
- |
|
| 1793 |
nc.setImplementationType("SimpleCampaign");
|
1786 |
sendNotificationModel.setType("url");
|
| 1794 |
nc.setImplementationParams(gson.toJson(scp));
|
1787 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1795 |
nc.setCreatedTimestamp(LocalDateTime.now());
|
1788 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| 1796 |
nc.setMessageType(MessageType.notification);
|
1789 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1797 |
notificationCampaignRepository.persist(nc);
|
- |
|
| 1798 |
LOGGER.info("nc" + nc);
|
- |
|
| 1799 |
LOGGER.info("fofoID" + fofoId);
|
- |
|
| 1800 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
1790 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| 1801 |
LOGGER.info("userId" + userId);
|
- |
|
| 1802 |
|
- |
|
| 1803 |
UserCampaign uc = new UserCampaign();
|
- |
|
| 1804 |
uc.setCampaignId(nc.getId());
|
- |
|
| 1805 |
uc.setUserId(userId);
|
- |
|
| 1806 |
uc.setPushTimestamp(LocalDateTime.now());
|
- |
|
| 1807 |
|
- |
|
| 1808 |
userCampaignRepository.persist(uc);
|
1791 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 1809 |
List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(userId,
|
- |
|
| 1810 |
LocalDateTime.now().minusMonths(3), LocalDateTime.now());
|
1792 |
notificationService.sendNotification(sendNotificationModel);
|
| 1811 |
pushNotification(nc.getId(), devices);
|
- |
|
| 1812 |
|
1793 |
|
| 1813 |
}
|
1794 |
}
|
| 1814 |
|
1795 |
|
| 1815 |
}
|
1796 |
}
|
| 1816 |
if (!focusedModelShortageReportMap.isEmpty())
|
1797 |
if (!focusedModelShortageReportMap.isEmpty())
|
| Line 1868... |
Line 1849... |
| 1868 |
sb.append(String.format("%n", ""));
|
1849 |
sb.append(String.format("%n", ""));
|
| 1869 |
}
|
1850 |
}
|
| 1870 |
return sb.toString();
|
1851 |
return sb.toString();
|
| 1871 |
}
|
1852 |
}
|
| 1872 |
|
1853 |
|
| 1873 |
public void pushNotification(int cid, List<Device> devices) {
|
- |
|
| 1874 |
for (Device device : devices) {
|
- |
|
| 1875 |
PushNotifications pn = new PushNotifications();
|
- |
|
| 1876 |
pn.setNotificationCampaignid(cid);
|
- |
|
| 1877 |
pn.setDeviceId(device.getId());
|
- |
|
| 1878 |
pn.setUserId(device.getUser_id());
|
- |
|
| 1879 |
pushNotificationRepository.persist(pn);
|
- |
|
| 1880 |
}
|
- |
|
| 1881 |
|
- |
|
| 1882 |
}
|
- |
|
| 1883 |
|
- |
|
| 1884 |
private void sendMailWithAttachments(String subject, String messageText, String email) throws Exception {
|
1854 |
private void sendMailWithAttachments(String subject, String messageText, String email) throws Exception {
|
| 1885 |
MimeMessage message = mailSender.createMimeMessage();
|
1855 |
MimeMessage message = mailSender.createMimeMessage();
|
| 1886 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
1856 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 1887 |
|
1857 |
|
| 1888 |
helper.setSubject(subject);
|
1858 |
helper.setSubject(subject);
|