| Line 2228... |
Line 2228... |
| 2228 |
public void notifyLead() throws Exception {
|
2228 |
public void notifyLead() throws Exception {
|
| 2229 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15),
|
2229 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15),
|
| 2230 |
LocalDateTime.now().plusHours(4));
|
2230 |
LocalDateTime.now().plusHours(4));
|
| 2231 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
2231 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
| 2232 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
2232 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| 2233 |
System.out.printf("authUserEmailMap - %s", authUserEmailMap);
|
2233 |
LOGGER.info("authUserEmailMap {}", authUserEmailMap);
|
| 2234 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
2234 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
| 2235 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
2235 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
| 2236 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
2236 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| 2237 |
|
2237 |
|
| 2238 |
System.out.printf("dtrEmailMap - %s", dtrEmailMap);
|
2238 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
| 2239 |
|
2239 |
|
| 2240 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
2240 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 2241 |
|
2241 |
|
| 2242 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
2242 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| 2243 |
int authId = authUserEmail.getKey();
|
2243 |
int authId = authUserEmail.getKey();
|
| 2244 |
String email = authUserEmail.getValue();
|
2244 |
String email = authUserEmail.getValue();
|
| 2245 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
2245 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
| 2246 |
}
|
2246 |
}
|
| 2247 |
System.out.println(authUserKeyMap);
|
2247 |
LOGGER.info("authUserKeyMap", authUserKeyMap);
|
| 2248 |
System.out.println(leadsToNotify);
|
2248 |
LOGGER.info("leadsToNotify {}", leadsToNotify);
|
| 2249 |
|
2249 |
|
| 2250 |
String templateMessage = "Lead followup for %s %s, %s is due by %s";
|
2250 |
String templateMessage = "Lead followup for %s %s, %s is due by %s";
|
| 2251 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
2251 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| 2252 |
for (Lead lead : leadsToNotify) {
|
2252 |
for (Lead lead : leadsToNotify) {
|
| 2253 |
if (authUserKeyMap.get(lead.getAssignTo()) == null) {
|
2253 |
if (authUserKeyMap.get(lead.getAssignTo()) == null) {
|