| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.service;
|
1 |
package com.spice.profitmandi.dao.service;
|
| 2 |
|
2 |
|
| 3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
4 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 4 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
5 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
6 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 5 |
import com.spice.profitmandi.dao.model.purchaseSaleRatio.CatalogAgedModel;
|
7 |
import com.spice.profitmandi.dao.model.purchaseSaleRatio.CatalogAgedModel;
|
| 6 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
8 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| - |
|
9 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 7 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseSupplierInvoiceRepository;
|
10 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseSupplierInvoiceRepository;
|
| 8 |
import com.spice.profitmandi.service.AuthService;
|
11 |
import com.spice.profitmandi.service.AuthService;
|
| 9 |
import org.apache.logging.log4j.LogManager;
|
12 |
import org.apache.logging.log4j.LogManager;
|
| 10 |
import org.apache.logging.log4j.Logger;
|
13 |
import org.apache.logging.log4j.Logger;
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 38... |
Line 41... |
| 38 |
@Autowired
|
41 |
@Autowired
|
| 39 |
AuthService authService;
|
42 |
AuthService authService;
|
| 40 |
@Autowired
|
43 |
@Autowired
|
| 41 |
AuthRepository authRepository;
|
44 |
AuthRepository authRepository;
|
| 42 |
|
45 |
|
| - |
|
46 |
@Autowired
|
| - |
|
47 |
CsService csService;
|
| - |
|
48 |
|
| 43 |
@Override
|
49 |
@Override
|
| 44 |
public void moreThen10DaysEgedStockReport() throws MessagingException, UnsupportedEncodingException, ProfitMandiBusinessException {
|
50 |
public void moreThen10DaysEgedStockReport() throws MessagingException, UnsupportedEncodingException, ProfitMandiBusinessException {
|
| 45 |
LocalDateTime startDate = LocalDateTime.now().minusMonths(3);
|
51 |
LocalDateTime startDate = LocalDateTime.now().minusMonths(3);
|
| 46 |
LocalDateTime endDate = LocalDateTime.now();
|
52 |
LocalDateTime endDate = LocalDateTime.now();
|
| 47 |
List<CatalogAgedModel> moreThen10DaysAgedCatalogModels = getCatalogModelsOlderThan10Days(startDate, endDate);
|
53 |
List<CatalogAgedModel> moreThen10DaysAgedCatalogModels = getCatalogModelsOlderThan10Days(startDate, endDate);
|
| 48 |
StringBuilder sb = new StringBuilder();
|
54 |
StringBuilder sb = new StringBuilder();
|
| 49 |
sb.append("<html><body><b>Aging Stock List: Items that are 10 days old or older (Date Range - " + startDate.toLocalDate() + " To " + endDate.toLocalDate() + " )</b>" + "<br/><table style='border:1px solid black ;padding: 5px ;bgColor=green'>");
|
55 |
sb.append("<html><body><b>Aging Stock List: Items that are 7 days old or older (Date Range - " + startDate.toLocalDate() + " To " + endDate.toLocalDate() + " )</b>" + "<br/><table style='border:1px solid black ;padding: 5px ;bgColor=green'>");
|
| 50 |
sb.append("<tbody>" +
|
56 |
sb.append("<tbody>" +
|
| 51 |
"<tr>" +
|
57 |
"<tr>" +
|
| 52 |
"<th style='border:1px solid black;padding: 5px'>No.</th>" +
|
58 |
"<th style='border:1px solid black;padding: 5px'>No.</th>" +
|
| 53 |
"<th style='border:1px solid black;padding: 5px'>Brand</th>" +
|
59 |
"<th style='border:1px solid black;padding: 5px'>Brand</th>" +
|
| 54 |
"<th style='border:1px solid black;padding: 5px'>Vendor</th>" +
|
60 |
"<th style='border:1px solid black;padding: 5px'>Vendor</th>" +
|
| Line 86... |
Line 92... |
| 86 |
}
|
92 |
}
|
| 87 |
String subject = "Aging Stock Report: 10 Days or Older";
|
93 |
String subject = "Aging Stock Report: 10 Days or Older";
|
| 88 |
String messageText = sb.toString();
|
94 |
String messageText = sb.toString();
|
| 89 |
MimeMessage message = mailSender.createMimeMessage();
|
95 |
MimeMessage message = mailSender.createMimeMessage();
|
| 90 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
96 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 91 |
|
- |
|
| - |
|
97 |
List<AuthUser> salesAuthUserList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Arrays.asList(EscalationType.L1, EscalationType.L2));
|
| - |
|
98 |
List<String> salesTeamMails = salesAuthUserList.stream().map(x->x.getEmailId()).collect(Collectors.toList());
|
| 92 |
List<String> allEmails = new ArrayList<>(Arrays.asList(
|
99 |
List<String> allEmails = new ArrayList<>(Arrays.asList(
|
| 93 |
"sm@smartdukaan.com",
|
100 |
"sm@smartdukaan.com",
|
| 94 |
"manish.gupta1@smartdukaan.com",
|
101 |
"manish.gupta1@smartdukaan.com",
|
| 95 |
"tarun.verma@smartdukaan.com",
|
102 |
"tarun.verma@smartdukaan.com",
|
| 96 |
"chiranjib.sarkar@smartdukaan.com",
|
- |
|
| 97 |
"niranjan.kala@smartdukaan.com",
|
103 |
"niranjan.kala@smartdukaan.com",
|
| 98 |
"mohit.gulati@smartdukaan.com"
|
104 |
"mohit.gulati@smartdukaan.com"
|
| 99 |
// "tejus.lohani@smartdukaan.com"
|
105 |
// "tejus.lohani@smartdukaan.com"
|
| 100 |
));
|
106 |
));
|
| 101 |
|
107 |
|
| - |
|
108 |
allEmails.addAll(salesTeamMails);
|
| - |
|
109 |
|
| 102 |
// niranjan kala(authId -54) Team Emails,
|
110 |
// niranjan kala(authId -54) Team Emails,
|
| 103 |
List<Integer> allReportees = authService.getAllReportees(54);
|
111 |
List<Integer> allReportees = authService.getAllReportees(54);
|
| 104 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(allReportees);
|
112 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(allReportees);
|
| 105 |
List<String> categotyTeamEmails = authUsers.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
113 |
List<String> categotyTeamEmails = authUsers.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 106 |
|
114 |
|
| Line 117... |
Line 125... |
| 117 |
|
125 |
|
| 118 |
@Override
|
126 |
@Override
|
| 119 |
public List<CatalogAgedModel> getCatalogModelsOlderThan10Days(LocalDateTime startDate, LocalDateTime endDate) {
|
127 |
public List<CatalogAgedModel> getCatalogModelsOlderThan10Days(LocalDateTime startDate, LocalDateTime endDate) {
|
| 120 |
List<CatalogAgedModel> fiterCatalogAgedModels =
|
128 |
List<CatalogAgedModel> fiterCatalogAgedModels =
|
| 121 |
warehouseSupplierInvoiceRepository.selectCatalogAge(startDate, endDate, null, 0, null)
|
129 |
warehouseSupplierInvoiceRepository.selectCatalogAge(startDate, endDate, null, 0, null)
|
| 122 |
.stream().filter(x -> x.getAge() >= 10 && x.getUnsold() > 0).collect(Collectors.toList());
|
130 |
.stream().filter(x -> x.getAge() >= 7 && x.getUnsold() > 0).collect(Collectors.toList());
|
| 123 |
LOGGER.info("fiterCatalogAgedModels - " + fiterCatalogAgedModels);
|
131 |
LOGGER.info("fiterCatalogAgedModels - " + fiterCatalogAgedModels);
|
| 124 |
return fiterCatalogAgedModels;
|
132 |
return fiterCatalogAgedModels;
|
| 125 |
}
|
133 |
}
|
| 126 |
// 192.168.0.16:8080
|
134 |
// 192.168.0.16:8080
|
| 127 |
}
|
135 |
}
|