| Line 337... |
Line 337... |
| 337 |
|
337 |
|
| 338 |
}
|
338 |
}
|
| 339 |
}
|
339 |
}
|
| 340 |
|
340 |
|
| 341 |
// Temporary Method
|
341 |
// Temporary Method
|
| 342 |
public void evaluateExcessSchemeOut() {
|
342 |
public void evaluateExcessSchemeOut() throws Exception {
|
| 343 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
343 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
| 344 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
344 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| - |
|
345 |
|
| - |
|
346 |
List<List<Object>> rows = new ArrayList<>();
|
| 345 |
LOGGER.info("{}\t{}\t{}\t{}", "Scheme Id", "Item Id", "Item", "Partner", "Amount", "Credited On", "Sale On",
|
347 |
List<String> headers = Arrays.asList("Scheme Id", "Item Id", "Item", "Partner", "Amount", "Credited On",
|
| 346 |
"Scheme", "Start", "End", "Active On", "Expired On");
|
348 |
"Sale On", "Scheme", "Start", "End", "Active On", "Expired On");
|
| 347 |
schemeRepository.selectAll().stream().forEach(x -> {
|
349 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| 348 |
if (x.getType().equals(SchemeType.OUT)) {
|
350 |
if (x.getType().equals(SchemeType.OUT)) {
|
| 349 |
List<SchemeInOut> sioList = schemeInOutRepository
|
351 |
List<SchemeInOut> sioList = schemeInOutRepository
|
| 350 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
352 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
| 351 |
if (x.getActiveTimestamp() != null) {
|
353 |
if (x.getActiveTimestamp() != null) {
|
| Line 370... |
Line 372... |
| 370 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
372 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
| 371 |
if (!userAmountMap.containsKey(fofoId)) {
|
373 |
if (!userAmountMap.containsKey(fofoId)) {
|
| 372 |
userAmountMap.put(fofoId, 0f);
|
374 |
userAmountMap.put(fofoId, 0f);
|
| 373 |
}
|
375 |
}
|
| 374 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
376 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
| 375 |
/*
|
- |
|
| 376 |
* LOGGER.
|
- |
|
| 377 |
* info("Scheme disbursed to user {} for inventoryItem {} and scheme {} for amount {}"
|
- |
|
| 378 |
* , userNameMap.get(fofoId), sio.getInventoryItemId(), sio.getSchemeId(),
|
- |
|
| 379 |
* sio.getAmount());
|
- |
|
| 380 |
*/
|
- |
|
| 381 |
try {
|
377 |
try {
|
| 382 |
LOGGER.info("{}\t{}\t{}\t{}\t{}\t{}\t{}", x.getDescription(),
|
378 |
rows.add(Arrays.asList(x.getDescription(),
|
| 383 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
379 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
| - |
|
380 |
userNameMap.get(fofoId), sio.getAmount(),
|
| 384 |
userNameMap.get(fofoId), sio.getAmount(), FormattingUtils.formatReporitcoDate(sio.getCreateTimestamp()),
|
381 |
FormattingUtils.formatReporitcoDate(sio.getCreateTimestamp()),
|
| 385 |
FormattingUtils.formatReporitcoDate(record.get().getCreateTimestamp()), FormattingUtils.formatReporitcoDate(x.getStartDateTime()),
|
382 |
FormattingUtils.formatReporitcoDate(record.get().getCreateTimestamp()),
|
| - |
|
383 |
FormattingUtils.formatReporitcoDate(x.getStartDateTime()),
|
| 386 |
FormattingUtils.formatReporitcoDate(x.getEndDateTime()),
|
384 |
FormattingUtils.formatReporitcoDate(x.getEndDateTime()),
|
| - |
|
385 |
FormattingUtils.formatReporitcoDate(x.getActiveTimestamp()),
|
| 387 |
FormattingUtils.formatReporitcoDate(x.getActiveTimestamp()), FormattingUtils.formatReporitcoDate(x.getExpireTimestamp()));
|
386 |
FormattingUtils.formatReporitcoDate(x.getExpireTimestamp())));
|
| 388 |
} catch (Exception e) {
|
387 |
} catch (Exception e) {
|
| 389 |
e.printStackTrace();
|
388 |
e.printStackTrace();
|
| 390 |
}
|
389 |
}
|
| 391 |
}
|
390 |
}
|
| 392 |
}
|
391 |
}
|
| Line 396... |
Line 395... |
| 396 |
});
|
395 |
});
|
| 397 |
userAmountMap.entrySet().stream()
|
396 |
userAmountMap.entrySet().stream()
|
| 398 |
.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
|
397 |
.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
|
| 399 |
x.getValue(), userNameMap.get(x.getKey())));
|
398 |
x.getValue(), userNameMap.get(x.getKey())));
|
| 400 |
|
399 |
|
| - |
|
400 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| - |
|
401 |
Utils.sendMailWithAttachment(googleMailSender, "adeel.yazdani@smartdukaan.com",
|
| - |
|
402 |
new String[] { "amit.gupta@shop2020.in" }, "Partner Excess Amount", "PFA"
|
| - |
|
403 |
, "ListofSchemes", new ByteArrayResource(baos.toByteArray()));
|
| - |
|
404 |
|
| 401 |
}
|
405 |
}
|
| 402 |
|
406 |
|
| 403 |
public void processScheme() throws Exception {
|
407 |
public void processScheme() throws Exception {
|
| 404 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(35);
|
408 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(35);
|
| 405 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
409 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|