| Line 43... |
Line 43... |
| 43 |
Map<Integer, List<SchemeInOut>> inventoryItemIdSchemeMap = schemeInOuts.stream().collect(Collectors.groupingBy(x->x.getInventoryItemId()));
|
43 |
Map<Integer, List<SchemeInOut>> inventoryItemIdSchemeMap = schemeInOuts.stream().collect(Collectors.groupingBy(x->x.getInventoryItemId()));
|
| 44 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIdSchemeMap.keySet());
|
44 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIdSchemeMap.keySet());
|
| 45 |
Map<Integer, List<Integer>> retailerInventoryItemIdMap = inventoryItems.stream()
|
45 |
Map<Integer, List<Integer>> retailerInventoryItemIdMap = inventoryItems.stream()
|
| 46 |
.collect(Collectors.groupingBy(x->x.getFofoId(), Collectors.mapping(x->x.getId(), Collectors.toList())));
|
46 |
.collect(Collectors.groupingBy(x->x.getFofoId(), Collectors.mapping(x->x.getId(), Collectors.toList())));
|
| 47 |
System.out.println("fofoId\tInvestment Short Days\tEligible payout");
|
47 |
System.out.println("fofoId\tInvestment Short Days\tEligible payout");
|
| 48 |
for(Map.Entry<Integer, List<Integer>> retailerEntry : retailerInventoryItemIdMap.entrySet()) {
|
48 |
for(Map.Entry<Integer, List<Integer>> retailerEntry : retailerInventoryItemIdMap.entrySet()) {
|
| 49 |
int fofoId = retailerEntry.getKey();
|
49 |
int fofoId = retailerEntry.getKey();
|
| 50 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x->inventoryItemIdSchemeMap.get(x)).flatMap(List::stream).collect(Collectors.toList());
|
50 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x->inventoryItemIdSchemeMap.get(x)).flatMap(List::stream).collect(Collectors.toList());
|
| 51 |
double totalAmount = schemeInouts.stream().filter(x->x.getRolledBackTimestamp()!=null).collect(Collectors.summingDouble(x->x.getAmount()));
|
51 |
double totalAmount = schemeInouts.stream().filter(x->x.getRolledBackTimestamp()!=null).collect(Collectors.summingDouble(x->x.getAmount()));
|
| 52 |
long daysShort = investmentShortDaysMap.get(fofoId);
|
52 |
long daysShort = investmentShortDaysMap.get(fofoId);
|
| 53 |
if(daysShort >= 12) {
|
53 |
if(daysShort >= 12) {
|
| - |
|
54 |
totalAmount = 0;
|
| 54 |
//do nothing
|
55 |
//do nothing
|
| 55 |
} else if(daysShort >= 8) {
|
56 |
} else if(daysShort >= 8) {
|
| 56 |
totalAmount = totalAmount/2;
|
57 |
totalAmount = totalAmount/2;
|
| 57 |
} else {
|
- |
|
| 58 |
totalAmount = 0;
|
- |
|
| 59 |
}
|
58 |
}
|
| 60 |
System.out.printf("%d\t%d\t%f%n", fofoId, daysShort, totalAmount);
|
59 |
System.out.printf("%d\t%d\t%f%n", fofoId, daysShort, totalAmount);
|
| 61 |
}
|
60 |
}
|
| 62 |
}
|
61 |
}
|
| 63 |
}
|
62 |
}
|
| 64 |
|
63 |
|