| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.io.InputStream;
|
4 |
import java.io.InputStream;
|
| 5 |
import java.sql.Timestamp;
|
5 |
import java.sql.Timestamp;
|
| 6 |
import java.text.MessageFormat;
|
6 |
import java.text.MessageFormat;
|
| - |
|
7 |
import java.time.Duration;
|
| 7 |
import java.time.LocalDate;
|
8 |
import java.time.LocalDate;
|
| 8 |
import java.time.LocalDateTime;
|
9 |
import java.time.LocalDateTime;
|
| 9 |
import java.time.LocalTime;
|
10 |
import java.time.LocalTime;
|
| - |
|
11 |
import java.time.ZoneOffset;
|
| - |
|
12 |
import java.time.format.DateTimeFormatter;
|
| 10 |
import java.time.temporal.ChronoUnit;
|
13 |
import java.time.temporal.ChronoUnit;
|
| 11 |
import java.util.ArrayList;
|
14 |
import java.util.ArrayList;
|
| 12 |
import java.util.Arrays;
|
15 |
import java.util.Arrays;
|
| 13 |
import java.util.Collections;
|
16 |
import java.util.Collections;
|
| 14 |
import java.util.HashMap;
|
17 |
import java.util.HashMap;
|
| 15 |
import java.util.HashSet;
|
18 |
import java.util.HashSet;
|
| 16 |
import java.util.List;
|
19 |
import java.util.List;
|
| 17 |
import java.util.Map;
|
20 |
import java.util.Map;
|
| - |
|
21 |
import java.util.Map.Entry;
|
| 18 |
import java.util.Optional;
|
22 |
import java.util.Optional;
|
| 19 |
import java.util.Set;
|
23 |
import java.util.Set;
|
| 20 |
import java.util.stream.Collectors;
|
24 |
import java.util.stream.Collectors;
|
| 21 |
|
25 |
|
| 22 |
import javax.mail.MessagingException;
|
26 |
import javax.mail.MessagingException;
|
| Line 47... |
Line 51... |
| 47 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
51 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 48 |
import com.spice.profitmandi.common.util.FileUtil;
|
52 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 49 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
53 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 50 |
import com.spice.profitmandi.common.util.Utils;
|
54 |
import com.spice.profitmandi.common.util.Utils;
|
| 51 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
55 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| - |
|
56 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 52 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
57 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 53 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
58 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 54 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
59 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 55 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
60 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| - |
|
61 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaigns;
|
| 56 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
62 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 57 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
63 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 58 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
64 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| - |
|
65 |
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
|
| 59 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
66 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 60 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
67 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 61 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
68 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 62 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
69 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 63 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
70 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 64 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
71 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
72 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
73 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTarget;
|
| 66 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
74 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 67 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
75 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
76 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
77 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
78 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 71 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
79 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 72 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
80 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 73 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
81 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 74 |
import com.spice.profitmandi.dao.entity.user.Address;
|
82 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 75 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
83 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| - |
|
84 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 76 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
85 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 77 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
86 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
87 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
88 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
89 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| 81 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
90 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| - |
|
91 |
import com.spice.profitmandi.dao.repository.cs.TicketSubCategoryRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
92 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
93 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
94 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 84 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
95 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
| 85 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
96 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| 86 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
97 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 87 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
98 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 88 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
99 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| Line 100... |
Line 111... |
| 100 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
111 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 101 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
112 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 102 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
113 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 103 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
114 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 104 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
115 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 105 |
import com.spice.profitmandi.service.order.OrderService;
|
- |
|
| 106 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
116 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 107 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
117 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
| 108 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
118 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
| 109 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
119 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 110 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
120 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| Line 164... |
Line 174... |
| 164 |
|
174 |
|
| 165 |
@Autowired
|
175 |
@Autowired
|
| 166 |
private SchemeService schemeService;
|
176 |
private SchemeService schemeService;
|
| 167 |
|
177 |
|
| 168 |
@Autowired
|
178 |
@Autowired
|
| 169 |
private OrderService orderService;
|
- |
|
| 170 |
|
- |
|
| 171 |
@Autowired
|
- |
|
| 172 |
private PartnerInvestmentService partnerInvestmentService;
|
179 |
private PartnerInvestmentService partnerInvestmentService;
|
| 173 |
|
180 |
|
| 174 |
@Autowired
|
181 |
@Autowired
|
| 175 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
182 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 176 |
|
183 |
|
| Line 275... |
Line 282... |
| 275 |
private AddressRepository addressRepository;
|
282 |
private AddressRepository addressRepository;
|
| 276 |
|
283 |
|
| 277 |
@Autowired
|
284 |
@Autowired
|
| 278 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
285 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
| 279 |
|
286 |
|
| - |
|
287 |
@Autowired
|
| - |
|
288 |
private TicketSubCategoryRepository ticketSubCategoryRepository;
|
| - |
|
289 |
|
| - |
|
290 |
@Autowired
|
| - |
|
291 |
private Mongo mongoClient;
|
| - |
|
292 |
|
| 280 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
293 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 281 |
|
294 |
|
| 282 |
public void generateDailyRecharge() {
|
295 |
public void generateDailyRecharge() {
|
| 283 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
296 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
| 284 |
.selectAll(0, 2000);
|
297 |
.selectAll(0, 2000);
|
| Line 702... |
Line 715... |
| 702 |
}
|
715 |
}
|
| 703 |
|
716 |
|
| 704 |
}
|
717 |
}
|
| 705 |
|
718 |
|
| 706 |
public void escalateTicket() throws ProfitMandiBusinessException {
|
719 |
public void escalateTicket() throws ProfitMandiBusinessException {
|
| 707 |
List<Ticket> tickets = ticketRepository.selectAllNotClosedTickets();
|
720 |
List<Ticket> tickets = ticketRepository.selectAllNotClosedTickets().stream()
|
| - |
|
721 |
.filter(x -> x.getLastActivity() != ActivityType.RESOLVED).collect(Collectors.toList());
|
| 708 |
LocalDateTime now = LocalDateTime.now();
|
722 |
LocalDateTime now = LocalDateTime.now();
|
| 709 |
for (Ticket ticket : tickets) {
|
723 |
for (Ticket ticket : tickets) {
|
| 710 |
if (ticket.getL2EscalationTimestamp().isBefore(now) && ticket.getL3EscalationTimestamp().isAfter(now)) {
|
724 |
if (ticket.getL2EscalationTimestamp().isBefore(now) && ticket.getL3EscalationTimestamp().isAfter(now)) {
|
| 711 |
TicketAssigned ticketAssigned = ticketAssignedRepository
|
725 |
TicketAssigned ticketAssigned = ticketAssignedRepository
|
| 712 |
.selectByAssigneeIdAndTicketId(ticket.getL2AuthUser(), ticket.getId());
|
726 |
.selectByAssigneeIdAndTicketId(ticket.getL2AuthUser(), ticket.getId());
|
| Line 995... |
Line 1009... |
| 995 |
LocalDateTime startDate = LocalDate.of(2018, 9, 1).atStartOfDay();
|
1009 |
LocalDateTime startDate = LocalDate.of(2018, 9, 1).atStartOfDay();
|
| 996 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
1010 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
| 997 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
1011 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
| 998 |
// Collections.reverse(allOrders);
|
1012 |
// Collections.reverse(allOrders);
|
| 999 |
// List<FofoOrder> allOrders =
|
1013 |
// List<FofoOrder> allOrders =
|
| - |
|
1014 |
// List<FofoOrder> allOrders =
|
| 1000 |
// Arrays.asList(fofoOrderRepository.selectByInvoiceNumber("UPGZ019/25"));
|
1015 |
// Arrays.asList(fofoOrderRepository.selectByInvoiceNumber("UPGZ019/25"));
|
| 1001 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
1016 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
| 1002 |
allOrders.stream().forEach(fofoOrder -> {
|
1017 |
allOrders.stream().forEach(fofoOrder -> {
|
| 1003 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
1018 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
| 1004 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
1019 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
| Line 1165... |
Line 1180... |
| 1165 |
|
1180 |
|
| 1166 |
throw new Exception();
|
1181 |
throw new Exception();
|
| 1167 |
|
1182 |
|
| 1168 |
}
|
1183 |
}
|
| 1169 |
|
1184 |
|
| - |
|
1185 |
public void alertforTicket() throws Exception {
|
| - |
|
1186 |
List<Ticket> tickets = ticketRepository.selectAllNotClosedTickets();
|
| - |
|
1187 |
Map<Integer, List<Ticket>> l1AuthUserAndTicketMap = new HashMap<>();
|
| - |
|
1188 |
Map<Integer, List<Ticket>> l2AuthUserAndTicketMap = new HashMap<>();
|
| - |
|
1189 |
Set<Integer> l1AuthUsers = tickets.stream().map(x -> x.getL1AuthUser()).collect(Collectors.toSet());
|
| - |
|
1190 |
Set<Integer> l2AuthUsers = tickets.stream()
|
| - |
|
1191 |
.filter(x -> x.getL2EscalationTimestamp().isAfter(LocalDateTime.now())).map(x -> x.getL1AuthUser())
|
| - |
|
1192 |
.collect(Collectors.toSet());
|
| - |
|
1193 |
for (Integer l1AuthUser : l1AuthUsers) {
|
| - |
|
1194 |
List<Ticket> ticketsForl1AuthUser = tickets.stream().filter(ticket -> l1AuthUser == ticket.getL1AuthUser())
|
| - |
|
1195 |
.collect(Collectors.toList());
|
| - |
|
1196 |
l1AuthUserAndTicketMap.put(l1AuthUser, ticketsForl1AuthUser);
|
| - |
|
1197 |
}
|
| - |
|
1198 |
for (Integer l2AuthUser : l2AuthUsers) {
|
| - |
|
1199 |
List<Ticket> ticketsForl2AuthUser = tickets.stream().filter(ticket -> l2AuthUser == ticket.getL2AuthUser())
|
| - |
|
1200 |
.collect(Collectors.toList());
|
| - |
|
1201 |
l2AuthUserAndTicketMap.put(l2AuthUser, ticketsForl2AuthUser);
|
| - |
|
1202 |
}
|
| - |
|
1203 |
for (Entry<Integer, List<Ticket>> entry : l1AuthUserAndTicketMap.entrySet()) {
|
| - |
|
1204 |
List<Ticket> ticketsForAuthUser = entry.getValue();
|
| - |
|
1205 |
AuthUser authUser = authRepository.selectById(entry.getKey());
|
| - |
|
1206 |
String message = this.getMessageForAlertTicket(ticketsForAuthUser, EscalationType.L1);
|
| - |
|
1207 |
this.sendMailOfHtmlFomat(authUser.getEmailId(), message, null, "Daily Pending Ticket");
|
| - |
|
1208 |
}
|
| - |
|
1209 |
for (Entry<Integer, List<Ticket>> entry : l2AuthUserAndTicketMap.entrySet()) {
|
| - |
|
1210 |
List<Ticket> ticketsForAuthUser = entry.getValue();
|
| - |
|
1211 |
AuthUser authUser = authRepository.selectById(entry.getKey());
|
| - |
|
1212 |
String message = this.getMessageForAlertTicket(ticketsForAuthUser, EscalationType.L2);
|
| - |
|
1213 |
this.sendMailOfHtmlFomat(authUser.getEmailId(), message, null, "Daily Pending Ticket");
|
| - |
|
1214 |
}
|
| - |
|
1215 |
}
|
| - |
|
1216 |
|
| - |
|
1217 |
public String getMessageForAlertTicket(List<Ticket> tickets, EscalationType escalationType)
|
| - |
|
1218 |
throws ProfitMandiBusinessException {
|
| - |
|
1219 |
StringBuilder sb = new StringBuilder();
|
| - |
|
1220 |
sb.append("<html><body><p>Your Pending Tickets</p><br/><table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
1221 |
sb.append("<tbody>\n" + " <tr>\n"
|
| - |
|
1222 |
+ " <th style='border:1px solid black;padding: 5px'>Ticket Id</th>\n"
|
| - |
|
1223 |
+ " <th style='border:1px solid black;padding: 5px'>Partner</th>\n"
|
| - |
|
1224 |
+ " <th style='border:1px solid black;padding: 5px'>SubCategory</th>\n"
|
| - |
|
1225 |
+ " <th style='border:1px solid black;padding: 5px'>Remaining Time To Escalate</th>\n"
|
| - |
|
1226 |
+ " <th style='border:1px solid black;padding: 5px'>Escalated</th>\n"
|
| - |
|
1227 |
+ " </tr>");
|
| - |
|
1228 |
for (Ticket ticket : tickets) {
|
| - |
|
1229 |
sb.append("<tr>");
|
| - |
|
1230 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + ticket.getId() + "</td>");
|
| - |
|
1231 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
1232 |
+ retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName() + "</td>");
|
| - |
|
1233 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
1234 |
+ ticketSubCategoryRepository.selectById(ticket.getSubCategoryId()).getDescription() + "</td>");
|
| - |
|
1235 |
if (escalationType == EscalationType.L1) {
|
| - |
|
1236 |
if (ticket.getL2EscalationTimestamp().isBefore(LocalDateTime.now())) {
|
| - |
|
1237 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + 0 + "</td>");
|
| - |
|
1238 |
sb.append("<td style='border:1px solid black;padding: 5px'>YES</td>");
|
| - |
|
1239 |
} else {
|
| - |
|
1240 |
Duration duration = Duration.between(LocalDateTime.now(), ticket.getL2EscalationTimestamp());
|
| - |
|
1241 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + duration.toHours() + "hrs</td>");
|
| - |
|
1242 |
sb.append("<td style='border:1px solid black;padding: 5px'>NO</td>");
|
| - |
|
1243 |
}
|
| - |
|
1244 |
} else if (escalationType == EscalationType.L2) {
|
| - |
|
1245 |
if (ticket.getL3EscalationTimestamp().isBefore(LocalDateTime.now())) {
|
| - |
|
1246 |
Duration duration = Duration.between(ticket.getL3EscalationTimestamp(), LocalDateTime.now());
|
| - |
|
1247 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + duration.toHours() + " hrs</td>");
|
| - |
|
1248 |
sb.append("<td style='border:1px solid black;padding: 5px'>YES</td>");
|
| - |
|
1249 |
} else {
|
| - |
|
1250 |
sb.append("<td style='border:1px solid black;padding: 5px'>NO</td>");
|
| - |
|
1251 |
}
|
| - |
|
1252 |
}
|
| - |
|
1253 |
sb.append("</tr>");
|
| - |
|
1254 |
}
|
| - |
|
1255 |
sb.append("</tbody></table></body></html>");
|
| - |
|
1256 |
return sb.toString();
|
| - |
|
1257 |
}
|
| - |
|
1258 |
|
| - |
|
1259 |
private void sendMailOfHtmlFomat(String email, String body, String cc[], String subject)
|
| - |
|
1260 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
| - |
|
1261 |
MimeMessage message = mailSender.createMimeMessage();
|
| - |
|
1262 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
| - |
|
1263 |
helper.setSubject(subject);
|
| - |
|
1264 |
helper.setText(body, true);
|
| - |
|
1265 |
helper.setTo(email);
|
| - |
|
1266 |
helper.setCc(cc);
|
| - |
|
1267 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
| - |
|
1268 |
helper.setFrom(senderAddress);
|
| - |
|
1269 |
mailSender.send(message);
|
| - |
|
1270 |
}
|
| - |
|
1271 |
|
| - |
|
1272 |
public void sendDailySalesReportNotificationToPartner()
|
| - |
|
1273 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
| - |
|
1274 |
LocalDateTime now = LocalDateTime.now();
|
| - |
|
1275 |
LocalDateTime from = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 00, 00);
|
| - |
|
1276 |
Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
|
| - |
|
1277 |
List<Integer> fofoIds = targetService.getfofoIdsFromfofoStore();
|
| - |
|
1278 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| - |
|
1279 |
.selectAllGeEqAndLeEqStartDateAndEndDate(now);
|
| - |
|
1280 |
DateTimeFormatter timeFormatter = DateTimeFormatter
|
| - |
|
1281 |
.ofPattern("h a");
|
| - |
|
1282 |
|
| - |
|
1283 |
Map<Integer,Float> dailyTarget=new HashMap<>();
|
| - |
|
1284 |
for (Integer fofoId : fofoIds) {
|
| - |
|
1285 |
Map<Integer,Float> dailyAverageSale=null;
|
| - |
|
1286 |
double sale = fofoOrderRepository.selectTotalSaleSumByFofoIdBrtweenDate(fofoId, from, now);
|
| - |
|
1287 |
for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
|
| - |
|
1288 |
Map<Integer, Float> targetValues = targetService.getTargetValueByFofoIdAndTargetId(fofoId,
|
| - |
|
1289 |
partnerTargetDetail.getId());
|
| - |
|
1290 |
if (targetValues.size() == 0) {
|
| - |
|
1291 |
continue;
|
| - |
|
1292 |
} else {
|
| - |
|
1293 |
List<Integer> partnerIds = new ArrayList<>();
|
| - |
|
1294 |
partnerIds.add(fofoId);
|
| - |
|
1295 |
dailyAverageSale = targetService.getDailyAverageSaleForCurrentForSingleFofoIdAndBrand(partnerIds,
|
| - |
|
1296 |
targetValues, partnerTargetDetail.getStartDate(), partnerTargetDetail.getEndDate(),
|
| - |
|
1297 |
partnerTargetDetail.getBrandName());
|
| - |
|
1298 |
dailyTarget.put(fofoId, dailyAverageSale.get(fofoId));
|
| - |
|
1299 |
break;
|
| - |
|
1300 |
}
|
| - |
|
1301 |
}
|
| - |
|
1302 |
NotificationCampaigns notification = new NotificationCampaigns();
|
| - |
|
1303 |
notification.setName("Today's Sale");
|
| - |
|
1304 |
if(dailyAverageSale!=null && dailyAverageSale.get(fofoId)!=null) {
|
| - |
|
1305 |
LOGGER.info("Your today sale till" + " " + now.format(timeFormatter) +" "+ "is" + " " + sale+" "+"vs" +" "+"daily target="+dailyAverageSale.get(fofoId));
|
| - |
|
1306 |
notification.setTitle("Your today sale till" + " " + now.format(timeFormatter) +" "+ "is" + " " + sale+" "+"vs" +" "+"daily target="+dailyAverageSale.get(fofoId));
|
| - |
|
1307 |
}
|
| - |
|
1308 |
else
|
| - |
|
1309 |
{
|
| - |
|
1310 |
notification.setTitle("Your today sale till" + " " + now.format(timeFormatter) +" "+"is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
| - |
|
1311 |
LOGGER.info("Your today sale till" + " " + now.format(timeFormatter) +" "+ "is" + " " + sale+" "+"vs" +" "+"daily target = 0.0");
|
| - |
|
1312 |
}
|
| - |
|
1313 |
// notification.setMessage("Your sale is "+salesbyfofoId.get(fofoId));
|
| - |
|
1314 |
notification.setType("Url");
|
| - |
|
1315 |
notification.setUrl("http://app.profitmandi.com/pages/home/dashboard");
|
| - |
|
1316 |
notification
|
| - |
|
1317 |
.setSql(MessageFormat.format("SELECT distinct d1.user_id from devices d1 left join devices d2 on"
|
| - |
|
1318 |
+ "(d1.imeinumber = d2.imeinumber and d1.created < d2.created) "
|
| - |
|
1319 |
+ " where d2.id is null and d1.user_id in ({0})", fofoId));
|
| - |
|
1320 |
notification.setExpiresat(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)));
|
| - |
|
1321 |
notification.setStatus("active");
|
| - |
|
1322 |
notification.setSmsprocessed(0);
|
| - |
|
1323 |
notification.setNotification_processed(0);
|
| - |
|
1324 |
notification.setNotification_type("GENERAL_NOTIFICATION");
|
| - |
|
1325 |
// mongoClient.persistNotificationCmpInfo(notification);
|
| - |
|
1326 |
salesByFofoIdMap.put(fofoId, sale);
|
| - |
|
1327 |
LOGGER.info(sale);
|
| - |
|
1328 |
}
|
| - |
|
1329 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap,dailyTarget);
|
| - |
|
1330 |
LOGGER.info(saleReport);
|
| - |
|
1331 |
String cc[] = { "Tarun.verma@smartdukaan.com", "Kamini.sharma@smartdukaan.com",
|
| - |
|
1332 |
"chaitnaya.vats@smartdukaan.com" };
|
| - |
|
1333 |
String subject = "sale report till" + " " + now.format(timeFormatter);
|
| - |
|
1334 |
this.sendMailOfHtmlFomat("govind.kumar@shop2020.in", saleReport, null, subject);
|
| - |
|
1335 |
}
|
| - |
|
1336 |
|
| - |
|
1337 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap,Map<Integer, Float> dailyTarget)
|
| - |
|
1338 |
throws ProfitMandiBusinessException {
|
| - |
|
1339 |
StringBuilder sb = new StringBuilder();
|
| - |
|
1340 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
1341 |
sb.append("<tbody>\n" + " <tr>\n"
|
| - |
|
1342 |
+ " <th style='border:1px solid black;padding: 5px'>Partner</th>\n"
|
| - |
|
1343 |
+ " <th style='border:1px solid black;padding: 5px'>Daily Target</th>\n"
|
| - |
|
1344 |
+ " <th style='border:1px solid black;padding: 5px'>Sale</th>\n"
|
| - |
|
1345 |
+ " </tr>");
|
| - |
|
1346 |
for (Integer fofoId : salesByFofoIdMap.keySet()) {
|
| - |
|
1347 |
sb.append("<tr>");
|
| - |
|
1348 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
1349 |
+ retailerService.getFofoRetailer(fofoId).getBusinessName() + "</td>");
|
| - |
|
1350 |
if(dailyTarget!=null && dailyTarget.get(fofoId)!=null) {
|
| - |
|
1351 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + dailyTarget.get(fofoId) + "</td>");
|
| - |
|
1352 |
}
|
| - |
|
1353 |
else
|
| - |
|
1354 |
{
|
| - |
|
1355 |
sb.append("<td style='border:1px solid black;padding: 5px'>" +0.0+ "</td>");
|
| - |
|
1356 |
}
|
| - |
|
1357 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + salesByFofoIdMap.get(fofoId) + "</td>");
|
| - |
|
1358 |
|
| - |
|
1359 |
sb.append("</tr>");
|
| - |
|
1360 |
}
|
| - |
|
1361 |
|
| - |
|
1362 |
sb.append("</tbody></table></body></html>");
|
| - |
|
1363 |
return sb.toString();
|
| - |
|
1364 |
}
|
| 1170 |
}
|
1365 |
}
|
| 1171 |
|
1366 |
|
| 1172 |
/*
|
1367 |
/*
|
| 1173 |
* public void processSchemeForModel(String string) { pricingService
|
1368 |
* public void processSchemeForModel(String string) { pricingService
|
| 1174 |
*
|
1369 |
*
|