| Line 4... |
Line 4... |
| 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.LocalDate;
|
7 |
import java.time.LocalDate;
|
| 8 |
import java.time.LocalDateTime;
|
8 |
import java.time.LocalDateTime;
|
| - |
|
9 |
import java.time.LocalTime;
|
| 9 |
import java.time.temporal.ChronoUnit;
|
10 |
import java.time.temporal.ChronoUnit;
|
| - |
|
11 |
import java.time.temporal.TemporalAmount;
|
| - |
|
12 |
import java.time.temporal.TemporalUnit;
|
| 10 |
import java.util.ArrayList;
|
13 |
import java.util.ArrayList;
|
| 11 |
import java.util.Arrays;
|
14 |
import java.util.Arrays;
|
| 12 |
import java.util.HashMap;
|
15 |
import java.util.HashMap;
|
| 13 |
import java.util.HashSet;
|
16 |
import java.util.HashSet;
|
| 14 |
import java.util.List;
|
17 |
import java.util.List;
|
| Line 400... |
Line 403... |
| 400 |
x.getValue(), userNameMap.get(x.getKey())));
|
403 |
x.getValue(), userNameMap.get(x.getKey())));
|
| 401 |
|
404 |
|
| 402 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
405 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 403 |
Utils.sendMailWithAttachment(googleMailSender, "adeel.yazdani@smartdukaan.com",
|
406 |
Utils.sendMailWithAttachment(googleMailSender, "adeel.yazdani@smartdukaan.com",
|
| 404 |
new String[] { "amit.gupta@shop2020.in" }, "Partner Excess Amount", "PFA"
|
407 |
new String[] { "amit.gupta@shop2020.in" }, "Partner Excess Amount", "PFA"
|
| 405 |
, "ListofSchemes", new ByteArrayResource(baos.toByteArray()));
|
408 |
, "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
|
| 406 |
|
409 |
|
| 407 |
}
|
410 |
}
|
| 408 |
|
411 |
|
| - |
|
412 |
public void processScheme(int offset) throws Exception {
|
| - |
|
413 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30*offset);
|
| - |
|
414 |
LocalDateTime endDate = LocalDateTime.now().minusDays(30);
|
| - |
|
415 |
processScheme(startDate, LocalDateTime.now());
|
| - |
|
416 |
}
|
| - |
|
417 |
|
| 409 |
public void processScheme() throws Exception {
|
418 |
public void processScheme() throws Exception {
|
| 410 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(35);
|
419 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(30);
|
| - |
|
420 |
processScheme(fromDate, LocalDateTime.now());
|
| - |
|
421 |
}
|
| - |
|
422 |
|
| - |
|
423 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate) throws Exception {
|
| 411 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
424 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| 412 |
List<Purchase> purchases = purchaseRepository.selectFromPurchaseCompleteDate(fromDate);
|
425 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
| 413 |
for (Purchase purchase : purchases) {
|
426 |
for (Purchase purchase : purchases) {
|
| 414 |
try {
|
427 |
try {
|
| 415 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
428 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
| 416 |
} catch (Exception e) {
|
429 |
} catch (Exception e) {
|
| 417 |
LOGGER.error("Error while processing purchase {} for scheme In ", purchase.getId());
|
430 |
LOGGER.error("Error while processing purchase {} for scheme In ", purchase.getId());
|
| 418 |
e.printStackTrace();
|
431 |
e.printStackTrace();
|
| 419 |
|
432 |
|
| 420 |
}
|
433 |
}
|
| 421 |
}
|
434 |
}
|
| 422 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectFromSaleDate(fromDate);
|
435 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
| 423 |
for (FofoOrder fofoOrder : fofoOrders) {
|
436 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 424 |
try {
|
437 |
try {
|
| 425 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
438 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
| 426 |
} catch (Exception e) {
|
439 |
} catch (Exception e) {
|
| 427 |
LOGGER.error("Error while processing sale order {} for scheme Out", fofoOrder.getId());
|
440 |
LOGGER.error("Error while processing sale order {} for scheme Out", fofoOrder.getId());
|