| Line 1417... |
Line 1417... |
| 1417 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
1417 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| 1418 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
1418 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 1419 |
notificationService.sendNotification(sendNotificationModel);
|
1419 |
notificationService.sendNotification(sendNotificationModel);
|
| 1420 |
}
|
1420 |
}
|
| 1421 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
1421 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
| - |
|
1422 |
String statewiseSaleReport = this.getStateWiseSales(partnerOrderQtyMap, partnerOrderAmountMap);
|
| 1422 |
LOGGER.info(saleReport);
|
1423 |
LOGGER.info(saleReport);
|
| 1423 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
1424 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
| 1424 |
"chaitnaya.vats@smartdukaan.com" };
|
1425 |
"niranjan.kala@smartdukaan.com", "up.singh@smartdukaan.com", "shankar.mushra@smartdukaan.com" };
|
| 1425 |
|
1426 |
|
| 1426 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
1427 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
| 1427 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
1428 |
this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc, subject);
|
| - |
|
1429 |
this.sendMailOfHtmlFomat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
|
| 1428 |
}
|
1430 |
}
|
| 1429 |
|
1431 |
|
| 1430 |
public static class SaleTargetReportModel {
|
1432 |
public static class SaleTargetReportModel {
|
| 1431 |
private double totalSale;
|
1433 |
private double totalSale;
|
| 1432 |
private int fofoId;
|
1434 |
private int fofoId;
|
| Line 1532... |
Line 1534... |
| 1532 |
+ ", insruanceQty=" + insruanceQty + "]";
|
1534 |
+ ", insruanceQty=" + insruanceQty + "]";
|
| 1533 |
}
|
1535 |
}
|
| 1534 |
|
1536 |
|
| 1535 |
}
|
1537 |
}
|
| 1536 |
|
1538 |
|
| - |
|
1539 |
private String getStateWiseSales(Map<Integer, Long> partnerOrderQtyMap, Map<Integer, Double> partnerOrderAmountMap) {
|
| - |
|
1540 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
| - |
|
1541 |
Map<String, List<Integer>> stateMap = stores.stream().collect(Collectors.groupingBy(
|
| - |
|
1542 |
x->x.getCode().substring(0,1),
|
| - |
|
1543 |
Collectors.mapping(x->x.getId(), Collectors.toList())));
|
| - |
|
1544 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
| - |
|
1545 |
for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
| - |
|
1546 |
long totalQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x->partnerOrderQtyMap.get(x)));
|
| - |
|
1547 |
double totalSale = stateMapEntry.getValue().stream().collect(Collectors.summingDouble(x->partnerOrderAmountMap.get(x)));
|
| - |
|
1548 |
stateWiseSales.add(Arrays.asList(stateMapEntry.getKey(), totalQty, totalSale));
|
| - |
|
1549 |
}
|
| - |
|
1550 |
StringBuilder sb = new StringBuilder();
|
| - |
|
1551 |
sb.append("<html><body><p>Statewise Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| - |
|
1552 |
sb.append("<tbody>\n" + " <tr>"
|
| - |
|
1553 |
+ " <th style='border:1px solid black;padding: 5px'>State</th>"
|
| - |
|
1554 |
+ " <th style='border:1px solid black;padding: 5px'>Sale Qty</th>"
|
| - |
|
1555 |
+ " <th style='border:1px solid black;padding: 5px'>Sale Value</th>"
|
| - |
|
1556 |
+ " </tr>");
|
| - |
|
1557 |
for (List<Serializable> stateSale : stateWiseSales) {
|
| - |
|
1558 |
sb.append("<tr>");
|
| - |
|
1559 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(0) + "</td>");
|
| - |
|
1560 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(1) + "</td>");
|
| - |
|
1561 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(2) + "</td>");
|
| - |
|
1562 |
sb.append("</tr>");
|
| - |
|
1563 |
}
|
| - |
|
1564 |
sb.append("</tbody></table></body></html>");
|
| - |
|
1565 |
return sb.toString();
|
| - |
|
1566 |
}
|
| 1537 |
private String getDailySalesReportHtml(Map<Integer, List<Serializable>> partnerSalesHeadersMap,
|
1567 |
private String getDailySalesReportHtml(Map<Integer, List<Serializable>> partnerSalesHeadersMap,
|
| 1538 |
Map<Integer, SaleTargetReportModel> saleReportTargetMap) throws ProfitMandiBusinessException {
|
1568 |
Map<Integer, SaleTargetReportModel> saleReportTargetMap) throws ProfitMandiBusinessException {
|
| 1539 |
StringBuilder sb = new StringBuilder();
|
1569 |
StringBuilder sb = new StringBuilder();
|
| 1540 |
|
1570 |
|
| 1541 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
1571 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|