| Line 4160... |
Line 4160... |
| 4160 |
LOGGER.info("response" + response);
|
4160 |
LOGGER.info("response" + response);
|
| 4161 |
}
|
4161 |
}
|
| 4162 |
|
4162 |
|
| 4163 |
}
|
4163 |
}
|
| 4164 |
|
4164 |
|
| - |
|
4165 |
@Autowired
|
| - |
|
4166 |
private HygieneDataRepository hygieneDataRepository;
|
| - |
|
4167 |
|
| - |
|
4168 |
public void hygineAlertForPartner() throws ProfitMandiBusinessException, MessagingException, IOException {
|
| - |
|
4169 |
|
| - |
|
4170 |
List<String> remarks = new ArrayList<>();
|
| - |
|
4171 |
remarks.add("Out of Service");
|
| - |
|
4172 |
remarks.add("Duplicate number");
|
| - |
|
4173 |
remarks.add("Partner number");
|
| - |
|
4174 |
List<HygieneData> hygieneData = hygieneDataRepository.selectAllByDisposedDateAndRemark(LocalDate.now(),
|
| - |
|
4175 |
remarks);
|
| - |
|
4176 |
|
| - |
|
4177 |
if (!hygieneData.isEmpty()) {
|
| - |
|
4178 |
|
| - |
|
4179 |
Map<Integer, List<HygieneData>> partnerHygieneDataMap = hygieneData.stream()
|
| - |
|
4180 |
.collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| - |
|
4181 |
|
| - |
|
4182 |
for (Entry<Integer, List<HygieneData>> partnerHygieneDataMapEntry : partnerHygieneDataMap.entrySet()) {
|
| - |
|
4183 |
|
| - |
|
4184 |
StringBuilder sb = new StringBuilder();
|
| - |
|
4185 |
sb.append("<html><body><p>Dear Partner,"
|
| - |
|
4186 |
+ "</p><br/><p>It has been observed in our calls to the respective customers that the contact no is either not correct or does not have incoming calls.\n"
|
| - |
|
4187 |
|
| - |
|
4188 |
+ " </p>"
|
| - |
|
4189 |
+ "<p>We would like to inform you that this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from your inventory."
|
| - |
|
4190 |
+ "</p><p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n"
|
| - |
|
4191 |
+ "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n"
|
| - |
|
4192 |
+ " " + "</p>"
|
| - |
|
4193 |
|
| - |
|
4194 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
4195 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| - |
|
4196 |
sb.append("<th style='border:1px solid black;padding: 5px'>Invoice Number</th>\n");
|
| - |
|
4197 |
sb.append("<th style='border:1px solid black;padding: 5px'>Customer Name</th>\n");
|
| - |
|
4198 |
sb.append("<th style='border:1px solid black;padding: 5px'>Customer Number</th>\n");
|
| - |
|
4199 |
sb.append("</tr>\n");
|
| - |
|
4200 |
|
| - |
|
4201 |
List<HygieneData> hygienes = partnerHygieneDataMapEntry.getValue();
|
| - |
|
4202 |
|
| - |
|
4203 |
List<Integer> orderIds = hygienes.stream().map(x -> x.getOrderId()).collect(Collectors.toList());
|
| - |
|
4204 |
|
| - |
|
4205 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectAllByOrderIds(orderIds);
|
| - |
|
4206 |
|
| - |
|
4207 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| - |
|
4208 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| - |
|
4209 |
sb.append("<tr>");
|
| - |
|
4210 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoOrder.getInvoiceNumber()
|
| - |
|
4211 |
+ "</td>\n");
|
| - |
|
4212 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getFirstName() + ""
|
| - |
|
4213 |
+ customer.getLastName() + "</td>\n");
|
| - |
|
4214 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getMobileNumber()
|
| - |
|
4215 |
+ "</td>\n");
|
| - |
|
4216 |
|
| - |
|
4217 |
sb.append("</tr>\n");
|
| - |
|
4218 |
}
|
| - |
|
4219 |
|
| - |
|
4220 |
sb.append("</tbody></table></body></html>");
|
| - |
|
4221 |
String subject = "Customer Info - Hygiene Alert";
|
| - |
|
4222 |
|
| - |
|
4223 |
this.sendMailOfHtmlFormat("tejbeer.kaur@smartdukaan.com", sb.toString(), null, subject);
|
| - |
|
4224 |
|
| - |
|
4225 |
}
|
| - |
|
4226 |
|
| - |
|
4227 |
}
|
| - |
|
4228 |
|
| 4165 |
}
|
4229 |
}
|
| - |
|
4230 |
|
| - |
|
4231 |
public void hygineAlertForInternalTeam() throws ProfitMandiBusinessException, MessagingException, IOException {
|
| - |
|
4232 |
|
| - |
|
4233 |
List<String> remarks = new ArrayList<>();
|
| - |
|
4234 |
remarks.add("Out of Service");
|
| - |
|
4235 |
remarks.add("Duplicate number");
|
| - |
|
4236 |
remarks.add("Partner number");
|
| - |
|
4237 |
List<HygieneData> hygieneDataLastThreeMonth = hygieneDataRepository
|
| - |
|
4238 |
.selectDisposedDateAndRemarks(
|
| - |
|
4239 |
LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay(), LocalDate.now().minusMonths(1)
|
| - |
|
4240 |
.withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX),
|
| - |
|
4241 |
remarks);
|
| - |
|
4242 |
|
| - |
|
4243 |
List<HygieneData> hygieneDataRecentMonth = hygieneDataRepository
|
| - |
|
4244 |
.selectDisposedDateAndRemarks(LocalDate.now().withDayOfMonth(1), remarks);
|
| - |
|
4245 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| - |
|
4246 |
Map<Integer, List<HygieneData>> partnerHygieneLastThreeMonthMap = null;
|
| - |
|
4247 |
|
| - |
|
4248 |
Map<Integer, List<HygieneData>> partnerHygieneDataRecentMonth = null;
|
| - |
|
4249 |
|
| - |
|
4250 |
if (!hygieneDataLastThreeMonth.isEmpty()) {
|
| - |
|
4251 |
partnerHygieneLastThreeMonthMap = hygieneDataLastThreeMonth.stream()
|
| - |
|
4252 |
.collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| - |
|
4253 |
|
| - |
|
4254 |
}
|
| - |
|
4255 |
|
| - |
|
4256 |
if (!hygieneDataRecentMonth.isEmpty()) {
|
| - |
|
4257 |
partnerHygieneDataRecentMonth = hygieneDataRecentMonth.stream()
|
| - |
|
4258 |
.collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| - |
|
4259 |
}
|
| - |
|
4260 |
|
| - |
|
4261 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| - |
|
4262 |
|
| - |
|
4263 |
String email = storeGuyEntry.getKey();
|
| - |
|
4264 |
|
| - |
|
4265 |
List<Integer> fofoIds = new ArrayList<>(storeGuyEntry.getValue());
|
| - |
|
4266 |
|
| - |
|
4267 |
Map<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthData = new HashMap<>();
|
| - |
|
4268 |
Map<Integer, Map<LocalDate, List<HygieneData>>> partnerDateWiseData = new HashMap<>();
|
| - |
|
4269 |
for (Integer fofoId : fofoIds) {
|
| - |
|
4270 |
|
| - |
|
4271 |
partnerYearMonthData.put(fofoId, null);
|
| - |
|
4272 |
partnerDateWiseData.put(fofoId, null);
|
| - |
|
4273 |
if (!partnerHygieneLastThreeMonthMap.isEmpty()) {
|
| - |
|
4274 |
List<HygieneData> hygienes = partnerHygieneLastThreeMonthMap.get(fofoId);
|
| - |
|
4275 |
|
| - |
|
4276 |
if (hygienes != null) {
|
| - |
|
4277 |
Map<YearMonth, List<HygieneData>> yearMonthData = hygienes.stream()
|
| - |
|
4278 |
.collect(Collectors.groupingBy(x -> YearMonth.from(x.getDisposedTimestamp())));
|
| - |
|
4279 |
|
| - |
|
4280 |
partnerYearMonthData.put(fofoId, yearMonthData);
|
| - |
|
4281 |
|
| - |
|
4282 |
}
|
| - |
|
4283 |
List<HygieneData> dateWiseHygienes = partnerHygieneDataRecentMonth.get(fofoId);
|
| - |
|
4284 |
|
| - |
|
4285 |
if (dateWiseHygienes != null) {
|
| - |
|
4286 |
|
| - |
|
4287 |
Map<LocalDate, List<HygieneData>> dateWiseData = hygienes.stream()
|
| - |
|
4288 |
.collect(Collectors.groupingBy(x -> (x.getDisposedTimestamp()).toLocalDate()));
|
| - |
|
4289 |
|
| - |
|
4290 |
partnerDateWiseData.put(fofoId, dateWiseData);
|
| - |
|
4291 |
|
| - |
|
4292 |
}
|
| - |
|
4293 |
|
| - |
|
4294 |
}
|
| - |
|
4295 |
|
| - |
|
4296 |
}
|
| - |
|
4297 |
|
| - |
|
4298 |
String subject = "Customer Info - Hygiene Alert";
|
| - |
|
4299 |
|
| - |
|
4300 |
LOGGER.info("hygieneData {}", partnerDateWiseData.values());
|
| - |
|
4301 |
|
| - |
|
4302 |
boolean partnerDateWise = partnerDateWiseData.values().stream().allMatch(Objects::isNull);
|
| 4166 |
|
4303 |
|
| 4167 |
//2284
|
- |
|
| 4168 |
|
4304 |
boolean partnerYearMonth = partnerYearMonthData.values().stream().allMatch(Objects::isNull);
|
| - |
|
4305 |
|
| - |
|
4306 |
if (!partnerDateWise && !partnerYearMonth) {
|
| - |
|
4307 |
String sb = this.getMessageHygieneAlertForPartner(partnerYearMonthData, partnerDateWiseData);
|
| - |
|
4308 |
this.sendMailOfHtmlFormat("tejbeer.kaur@smartdukaan.com", sb, null, subject);
|
| - |
|
4309 |
}
|
| - |
|
4310 |
|
| - |
|
4311 |
}
|
| - |
|
4312 |
|
| - |
|
4313 |
}
|
| - |
|
4314 |
|
| - |
|
4315 |
private String getMessageHygieneAlertForPartner(
|
| - |
|
4316 |
Map<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthData,
|
| - |
|
4317 |
Map<Integer, Map<LocalDate, List<HygieneData>>> partnerDateWiseData) {
|
| - |
|
4318 |
|
| - |
|
4319 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
4320 |
|
| - |
|
4321 |
LocalDateTime startDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
|
| - |
|
4322 |
LocalDateTime endDate = LocalDateTime.now();
|
| - |
|
4323 |
|
| - |
|
4324 |
LocalDateTime startYearMonth = LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay();
|
| - |
|
4325 |
LocalDateTime endYearMonth = LocalDate.now().minusMonths(1)
|
| - |
|
4326 |
.withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX);
|
| - |
|
4327 |
|
| - |
|
4328 |
DateTimeFormatter dateYearMonthFormatter = DateTimeFormatter.ofPattern("MMM''uu");
|
| - |
|
4329 |
|
| - |
|
4330 |
List<YearMonth> yearMonthRange = new ArrayList<>();
|
| - |
|
4331 |
yearMonthRange.add(YearMonth.from(startYearMonth));
|
| - |
|
4332 |
|
| - |
|
4333 |
yearMonthRange.add(YearMonth.from(startYearMonth.plusMonths(1)));
|
| - |
|
4334 |
|
| - |
|
4335 |
yearMonthRange.add(YearMonth.from(endYearMonth));
|
| - |
|
4336 |
|
| - |
|
4337 |
long noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate.plusDays(1));
|
| - |
|
4338 |
|
| - |
|
4339 |
List<LocalDate> dateRange = Stream.iterate(startDate.toLocalDate(), date -> date.plusDays(1))
|
| - |
|
4340 |
.limit(noOfDaysBetween).collect(Collectors.toList());
|
| - |
|
4341 |
|
| - |
|
4342 |
StringBuilder sb = new StringBuilder();
|
| - |
|
4343 |
sb.append("<html><body><p>Hi,"
|
| - |
|
4344 |
+ "</p><br/><p>Kindly advise below mentioned partner to input correct details in the system else this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from partner's inventory.\n"
|
| - |
|
4345 |
+ " </p>" + "<p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n"
|
| - |
|
4346 |
+ "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n</p>"
|
| - |
|
4347 |
|
| - |
|
4348 |
+ "<table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
4349 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| - |
|
4350 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
| - |
|
4351 |
|
| - |
|
4352 |
for (YearMonth yearMonth : yearMonthRange) {
|
| - |
|
4353 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + yearMonth.format(dateYearMonthFormatter)
|
| - |
|
4354 |
+ "</th>\n");
|
| - |
|
4355 |
}
|
| - |
|
4356 |
|
| - |
|
4357 |
for (LocalDate localDate : dateRange) {
|
| - |
|
4358 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + localDate + "</th>\n");
|
| - |
|
4359 |
}
|
| - |
|
4360 |
|
| - |
|
4361 |
sb.append("</tr>\n");
|
| - |
|
4362 |
|
| - |
|
4363 |
for (Entry<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthEntry : partnerYearMonthData
|
| - |
|
4364 |
.entrySet()) {
|
| - |
|
4365 |
|
| - |
|
4366 |
int fofoId = partnerYearMonthEntry.getKey();
|
| - |
|
4367 |
|
| - |
|
4368 |
Map<YearMonth, List<HygieneData>> yearMonthData = partnerYearMonthEntry.getValue();
|
| - |
|
4369 |
|
| - |
|
4370 |
Map<LocalDate, List<HygieneData>> dateWiseData = partnerDateWiseData.get(fofoId);
|
| - |
|
4371 |
|
| - |
|
4372 |
if (yearMonthData == null && dateWiseData == null) {
|
| - |
|
4373 |
continue;
|
| - |
|
4374 |
}
|
| - |
|
4375 |
|
| - |
|
4376 |
sb.append("<tr>");
|
| - |
|
4377 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
4378 |
+ customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
| - |
|
4379 |
for (YearMonth yearMonth : yearMonthRange) {
|
| - |
|
4380 |
|
| - |
|
4381 |
if (yearMonthData == null) {
|
| - |
|
4382 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
| - |
|
4383 |
|
| - |
|
4384 |
} else {
|
| - |
|
4385 |
List<HygieneData> hygieneList = yearMonthData.get(yearMonth);
|
| - |
|
4386 |
|
| - |
|
4387 |
if (hygieneList != null) {
|
| - |
|
4388 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + hygieneList.size() + "</td>\n");
|
| - |
|
4389 |
|
| - |
|
4390 |
} else {
|
| - |
|
4391 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
| - |
|
4392 |
|
| - |
|
4393 |
}
|
| - |
|
4394 |
}
|
| - |
|
4395 |
}
|
| - |
|
4396 |
|
| - |
|
4397 |
for (LocalDate localDate : dateRange) {
|
| - |
|
4398 |
|
| - |
|
4399 |
if (dateWiseData == null) {
|
| - |
|
4400 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
| - |
|
4401 |
|
| - |
|
4402 |
} else {
|
| - |
|
4403 |
List<HygieneData> hygieneList = dateWiseData.get(localDate);
|
| - |
|
4404 |
|
| - |
|
4405 |
if (hygieneList != null) {
|
| - |
|
4406 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + hygieneList.size() + "</td>\n");
|
| - |
|
4407 |
|
| - |
|
4408 |
} else {
|
| - |
|
4409 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
| - |
|
4410 |
|
| - |
|
4411 |
}
|
| - |
|
4412 |
}
|
| - |
|
4413 |
}
|
| - |
|
4414 |
sb.append("</tr>");
|
| - |
|
4415 |
|
| - |
|
4416 |
}
|
| - |
|
4417 |
|
| - |
|
4418 |
sb.append("</tbody></table></body></html>");
|
| - |
|
4419 |
|
| - |
|
4420 |
return sb.toString();
|
| - |
|
4421 |
}
|
| - |
|
4422 |
|
| - |
|
4423 |
}
|
| - |
|
4424 |
// 2284'
|
| - |
|
4425 |
|
| 4169 |
|
4426 |
|