| Line 107... |
Line 107... |
| 107 |
import java.time.temporal.ChronoUnit;
|
107 |
import java.time.temporal.ChronoUnit;
|
| 108 |
import java.util.*;
|
108 |
import java.util.*;
|
| 109 |
import java.util.Map.Entry;
|
109 |
import java.util.Map.Entry;
|
| 110 |
import java.util.stream.Collectors;
|
110 |
import java.util.stream.Collectors;
|
| 111 |
|
111 |
|
| 112 |
;
|
- |
|
| 113 |
|
- |
|
| 114 |
@Component
|
112 |
@Component
|
| 115 |
@Transactional(rollbackFor = Throwable.class)
|
113 |
@Transactional(rollbackFor = Throwable.class)
|
| 116 |
public class ScheduledTasks {
|
114 |
public class ScheduledTasks {
|
| 117 |
|
115 |
|
| 118 |
@Value("${oxigen.recharge.transaction.url}")
|
116 |
@Value("${oxigen.recharge.transaction.url}")
|
| Line 733... |
Line 731... |
| 733 |
|
731 |
|
| 734 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
732 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
| 735 |
for (FofoStore store : stores) {
|
733 |
for (FofoStore store : stores) {
|
| 736 |
int fofoId = store.getId();
|
734 |
int fofoId = store.getId();
|
| 737 |
|
735 |
|
| 738 |
PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfPreviousMonth);
|
736 |
PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfPreviousMonth).getPartnerType();
|
| 739 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId,
|
737 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId,
|
| 740 |
YearMonth.from(startOfPreviousMonth.atStartOfDay()));
|
738 |
YearMonth.from(startOfPreviousMonth.atStartOfDay()));
|
| 741 |
if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
739 |
if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
| 742 |
continue;
|
740 |
continue;
|
| 743 |
}
|
741 |
}
|
| Line 761... |
Line 759... |
| 761 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
759 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
| 762 |
StringBuilder sb = new StringBuilder();
|
760 |
StringBuilder sb = new StringBuilder();
|
| 763 |
for (FofoStore store : stores) {
|
761 |
for (FofoStore store : stores) {
|
| 764 |
int fofoId = store.getId();
|
762 |
int fofoId = store.getId();
|
| 765 |
|
763 |
|
| 766 |
PartnerType yesterdayPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, yesterday);
|
764 |
PartnerType yesterdayPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, yesterday).getPartnerType();
|
| 767 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, today);
|
765 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, today).getPartnerType();
|
| 768 |
if (!yesterdayPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
766 |
if (!yesterdayPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
| 769 |
continue;
|
767 |
continue;
|
| 770 |
}
|
768 |
}
|
| 771 |
if (!yesterdayPartnerType.equals(todayPartnerType)) {
|
769 |
if (!yesterdayPartnerType.equals(todayPartnerType)) {
|
| 772 |
upgradedCount++;
|
770 |
upgradedCount++;
|
| Line 980... |
Line 978... |
| 980 |
}
|
978 |
}
|
| 981 |
|
979 |
|
| 982 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
980 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 983 |
|
981 |
|
| 984 |
if (sendTo == null) {
|
982 |
if (sendTo == null) {
|
| 985 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
983 |
for (Map.Entry<String, List<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 986 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
984 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
| 987 |
.filter(x -> x != null).collect(Collectors.toList());
|
985 |
.filter(x -> x != null).collect(Collectors.toList());
|
| 988 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
986 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| 989 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
987 |
String[] sendToArray = new String[]{storeGuyEntry.getKey()};
|
| 990 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
988 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
| 991 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
989 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 992 |
}
|
990 |
}
|
| 993 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
991 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 994 |
"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
|
992 |
"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
|
| Line 2421... |
Line 2419... |
| 2421 |
*/
|
2419 |
*/
|
| 2422 |
|
2420 |
|
| 2423 |
}
|
2421 |
}
|
| 2424 |
if (!focusedModelShortageReportMap.isEmpty()) {
|
2422 |
if (!focusedModelShortageReportMap.isEmpty()) {
|
| 2425 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
2423 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 2426 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
2424 |
Map<String, List<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 2427 |
Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
|
2425 |
Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
|
| 2428 |
|
2426 |
|
| 2429 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
2427 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
| 2430 |
storeGuyMap.entrySet().forEach(y -> {
|
2428 |
storeGuyMap.entrySet().forEach(y -> {
|
| 2431 |
|
2429 |
|