| Line 49... |
Line 49... |
| 49 |
import com.google.gson.GsonBuilder;
|
49 |
import com.google.gson.GsonBuilder;
|
| 50 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
50 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 51 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
51 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 52 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
52 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 53 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
53 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
54 |
import com.spice.profitmandi.common.model.CatalogIdAggregateValue;
|
| 54 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
55 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 55 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
56 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| 56 |
import com.spice.profitmandi.common.model.GstRate;
|
57 |
import com.spice.profitmandi.common.model.GstRate;
|
| 57 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
58 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 58 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
59 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| Line 62... |
Line 63... |
| 62 |
import com.spice.profitmandi.common.util.Utils;
|
63 |
import com.spice.profitmandi.common.util.Utils;
|
| 63 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
64 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 64 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
65 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
| 65 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeJsonConverter;
|
66 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeJsonConverter;
|
| 66 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
67 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
68 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 67 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
69 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 68 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
70 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 69 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
71 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 70 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
72 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 71 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
73 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| Line 73... |
Line 75... |
| 73 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
75 |
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
|
| 74 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
76 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 75 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
77 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 76 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
78 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 77 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
79 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| - |
|
80 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 78 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
81 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 79 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
82 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 80 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
83 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 81 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
84 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 82 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
85 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| Line 1538... |
Line 1541... |
| 1538 |
* storeGuyEntry.getValue()); }
|
1541 |
* storeGuyEntry.getValue()); }
|
| 1539 |
*/
|
1542 |
*/
|
| 1540 |
}
|
1543 |
}
|
| 1541 |
|
1544 |
|
| 1542 |
public void testToffee() throws Exception {
|
1545 |
public void testToffee() throws Exception {
|
| 1543 |
//LOGGER.info("{}", toffeeService.getAuthToken());
|
1546 |
// LOGGER.info("{}", toffeeService.getAuthToken());
|
| 1544 |
LOGGER.info("{}", toffeeService.getProducts());
|
1547 |
LOGGER.info("{}", toffeeService.getProducts());
|
| 1545 |
//LOGGER.info("{}", toffeeService.getPincodes("36103000PR"));
|
1548 |
// LOGGER.info("{}", toffeeService.getPincodes("36103000PR"));
|
| 1546 |
PremiumCalculationRequestModel pcrm = new PremiumCalculationRequestModel();
|
1549 |
PremiumCalculationRequestModel pcrm = new PremiumCalculationRequestModel();
|
| 1547 |
pcrm.setProductDetails("36103000PR");
|
1550 |
pcrm.setProductDetails("36103000PR");
|
| 1548 |
//pcrm.setProductDetails("36103000PR");
|
1551 |
// pcrm.setProductDetails("36103000PR");
|
| 1549 |
pcrm.setDurations(Arrays.asList("3 Months", "6 Months", "1 Year"));
|
1552 |
pcrm.setDurations(Arrays.asList("3 Months", "6 Months", "1 Year"));
|
| 1550 |
pcrm.setSumInsured("15000");
|
1553 |
pcrm.setSumInsured("15000");
|
| 1551 |
System.out.println(toffeeService.getPremiumCalculation(pcrm));
|
1554 |
System.out.println(toffeeService.getPremiumCalculation(pcrm));
|
| 1552 |
}
|
1555 |
}
|
| 1553 |
|
1556 |
|
| Line 1624... |
Line 1627... |
| 1624 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
1627 |
.collect(Collectors.groupingBy(x -> x.getCatalogItemId(),
|
| 1625 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
1628 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
| 1626 |
|
1629 |
|
| 1627 |
}
|
1630 |
}
|
| 1628 |
|
1631 |
|
| - |
|
1632 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
| - |
|
1633 |
.collect(Collectors.toList());
|
| - |
|
1634 |
|
| - |
|
1635 |
List<Integer> focusedModelCatalogId = focusedModelRepository.selectAll().stream().map(x -> x.getCatalogId())
|
| - |
|
1636 |
.collect(Collectors.toList());
|
| - |
|
1637 |
Map<String, Object> equalsMap = new HashMap<>();
|
| - |
|
1638 |
equalsMap.put("categoryId", 10006);
|
| - |
|
1639 |
equalsMap.put("brand", brands);
|
| - |
|
1640 |
|
| - |
|
1641 |
Map<String, List<?>> notEqualsMap = new HashMap<>();
|
| - |
|
1642 |
|
| - |
|
1643 |
Map<String, Object> equalsJoinMap = new HashMap<>();
|
| - |
|
1644 |
equalsJoinMap.put("catalogId", focusedModelCatalogId);
|
| - |
|
1645 |
|
| - |
|
1646 |
Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
|
| - |
|
1647 |
|
| - |
|
1648 |
List<Integer> catalogIds = itemRepository
|
| - |
|
1649 |
.selectItems(FocusedModel.class, "catalogItemId", "catalogId", equalsMap, notEqualsMap,
|
| - |
|
1650 |
equalsJoinMap, notEqualsJoinMap, "minimumQty")
|
| - |
|
1651 |
.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
| - |
|
1652 |
|
| 1629 |
Map<Integer, Integer> focusedCatalogIdAndQtyMap = focusedModelRepository.selectAll().stream()
|
1653 |
Map<Integer, Integer> focusedCatalogIdAndQtyMap = focusedModelRepository.selectByCatalogIdsl(catalogIds)
|
| 1630 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getMinimumQty()));
|
1654 |
.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getMinimumQty()));
|
| - |
|
1655 |
|
| - |
|
1656 |
/*
|
| - |
|
1657 |
* Map<Integer, Integer> focusedCatalogIdAndQtyMap =
|
| - |
|
1658 |
* focusedModelRepository.selectAll().stream() .collect(Collectors.toMap(x ->
|
| - |
|
1659 |
* x.getCatalogId(), x -> x.getMinimumQty()));
|
| - |
|
1660 |
*/
|
| - |
|
1661 |
|
| 1631 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
1662 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
| 1632 |
|
1663 |
|
| 1633 |
for (Map.Entry<Integer, Integer> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
1664 |
for (Map.Entry<Integer, Integer> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
| 1634 |
int inStockQty = 0;
|
1665 |
int inStockQty = 0;
|
| 1635 |
int processingQty = 0;
|
1666 |
int processingQty = 0;
|
| Line 1701... |
Line 1732... |
| 1701 |
|
1732 |
|
| 1702 |
UserCampaign uc = new UserCampaign();
|
1733 |
UserCampaign uc = new UserCampaign();
|
| 1703 |
uc.setCampaignId(nc.getId());
|
1734 |
uc.setCampaignId(nc.getId());
|
| 1704 |
uc.setUserId(userId);
|
1735 |
uc.setUserId(userId);
|
| 1705 |
uc.setPushTimestamp(LocalDateTime.now());
|
1736 |
uc.setPushTimestamp(LocalDateTime.now());
|
| - |
|
1737 |
|
| 1706 |
userCampaignRepository.persist(uc);
|
1738 |
userCampaignRepository.persist(uc);
|
| 1707 |
List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(userId,
|
1739 |
List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(userId,
|
| 1708 |
LocalDateTime.now().minusMonths(3), LocalDateTime.now());
|
1740 |
LocalDateTime.now().minusMonths(3), LocalDateTime.now());
|
| 1709 |
pushNotification(nc.getId(), devices);
|
1741 |
pushNotification(nc.getId(), devices);
|
| 1710 |
|
1742 |
|
| 1711 |
}
|
1743 |
}
|
| 1712 |
|
1744 |
|
| 1713 |
}
|
1745 |
}
|
| 1714 |
if(!focusedModelShortageReportMap.isEmpty()) {
|
1746 |
if (!focusedModelShortageReportMap.isEmpty())
|
| 1715 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
- |
|
| 1716 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
- |
|
| 1717 |
Map<String, List<List<? extends Serializable>>> emailRowsMap = new HashMap<>();
|
- |
|
| 1718 |
|
- |
|
| 1719 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
- |
|
| 1720 |
storeGuyMap.entrySet().forEach(y -> {
|
- |
|
| 1721 |
|
- |
|
| 1722 |
if (y.getValue().contains(x.getKey())) {
|
- |
|
| 1723 |
if (!emailRowsMap.containsKey(y.getKey())) {
|
- |
|
| 1724 |
emailRowsMap.put(y.getKey(), new ArrayList<>());
|
- |
|
| 1725 |
}
|
- |
|
| 1726 |
List<List<? extends Serializable>> fms = x.getValue().stream().map(
|
- |
|
| 1727 |
r -> Arrays.asList(r.getFofoId(), r.getStoreName(), r.getItemName(), r.getShortageQty()))
|
- |
|
| 1728 |
.collect(Collectors.toList());
|
- |
|
| 1729 |
emailRowsMap.get(y.getKey()).addAll(fms);
|
- |
|
| 1730 |
|
1747 |
|
| - |
|
1748 |
{
|
| - |
|
1749 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| - |
|
1750 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
1751 |
Map<String, List<List<? extends Serializable>>> emailRowsMap = new HashMap<>();
|
| - |
|
1752 |
|
| - |
|
1753 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
| - |
|
1754 |
storeGuyMap.entrySet().forEach(y -> {
|
| - |
|
1755 |
|
| - |
|
1756 |
if (y.getValue().contains(x.getKey())) {
|
| - |
|
1757 |
if (!emailRowsMap.containsKey(y.getKey())) {
|
| - |
|
1758 |
emailRowsMap.put(y.getKey(), new ArrayList<>());
|
| 1731 |
}
|
1759 |
}
|
| - |
|
1760 |
List<List<? extends Serializable>> fms = x.getValue().stream().map(r -> Arrays
|
| - |
|
1761 |
.asList(r.getFofoId(), r.getStoreName(), r.getItemName(), r.getShortageQty()))
|
| - |
|
1762 |
.collect(Collectors.toList());
|
| - |
|
1763 |
emailRowsMap.get(y.getKey()).addAll(fms);
|
| 1732 |
|
1764 |
|
| 1733 |
});
|
1765 |
}
|
| 1734 |
|
1766 |
|
| 1735 |
});
|
1767 |
});
|
| 1736 |
|
1768 |
|
| 1737 |
List<String> headers = Arrays.asList("Partner Id", "Partner Name", "Model Name", "Shortage Qty");
|
- |
|
| 1738 |
emailRowsMap.entrySet().forEach(e -> {
|
1769 |
});
|
| 1739 |
|
1770 |
|
| 1740 |
ByteArrayOutputStream baos = null;
|
- |
|
| 1741 |
try {
|
- |
|
| 1742 |
baos = FileUtil.getCSVByteStream(headers, e.getValue());
|
1771 |
List<String> headers = Arrays.asList("Partner Id", "Partner Name", "Model Name", "Shortage Qty");
|
| 1743 |
} catch (Exception e2) {
|
- |
|
| 1744 |
// TODO Auto-generated catch block
|
1772 |
emailRowsMap.entrySet().forEach(e -> {
|
| 1745 |
e2.printStackTrace();
|
- |
|
| 1746 |
}
|
- |
|
| 1747 |
String[] sendToArray = new String[] { e.getKey() };
|
- |
|
| 1748 |
try {
|
- |
|
| 1749 |
|
1773 |
|
| 1750 |
LOGGER.info("email" + e.getKey());
|
1774 |
ByteArrayOutputStream baos = null;
|
| - |
|
1775 |
try {
|
| 1751 |
LOGGER.info("list" + e.getValue());
|
1776 |
baos = FileUtil.getCSVByteStream(headers, e.getValue());
|
| - |
|
1777 |
} catch (Exception e2) {
|
| - |
|
1778 |
e2.printStackTrace();
|
| - |
|
1779 |
}
|
| - |
|
1780 |
String[] sendToArray = new String[] { e.getKey() };
|
| - |
|
1781 |
try {
|
| 1752 |
|
1782 |
|
| 1753 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
- |
|
| 1754 |
new ByteArrayResource(baos.toByteArray()));
|
1783 |
LOGGER.info("email" + e.getKey());
|
| 1755 |
} catch (Exception e1) {
|
- |
|
| 1756 |
// TODO Auto-generated catch block
|
- |
|
| 1757 |
e1.printStackTrace();
|
1784 |
LOGGER.info("list" + e.getValue());
|
| 1758 |
}
|
- |
|
| 1759 |
|
1785 |
|
| - |
|
1786 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
| - |
|
1787 |
new ByteArrayResource(baos.toByteArray()));
|
| - |
|
1788 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
| 1760 |
});
|
1789 |
e1.printStackTrace();
|
| 1761 |
}
|
1790 |
}
|
| 1762 |
|
1791 |
|
| - |
|
1792 |
});
|
| - |
|
1793 |
}
|
| 1763 |
}
|
1794 |
}
|
| 1764 |
|
1795 |
|
| 1765 |
private String getNotificationMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
1796 |
private String getNotificationMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
| 1766 |
StringBuilder sb = new StringBuilder();
|
1797 |
StringBuilder sb = new StringBuilder();
|
| 1767 |
sb.append("Focused Model Shortage in Your Stock : \n");
|
1798 |
sb.append("Focused Model Shortage in Your Stock : \n");
|