| Line 7... |
Line 7... |
| 7 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| 8 |
import java.time.LocalTime;
|
8 |
import java.time.LocalTime;
|
| 9 |
import java.time.temporal.TemporalAdjusters;
|
9 |
import java.time.temporal.TemporalAdjusters;
|
| 10 |
import java.util.ArrayList;
|
10 |
import java.util.ArrayList;
|
| 11 |
import java.util.HashMap;
|
11 |
import java.util.HashMap;
|
| - |
|
12 |
import java.util.LinkedHashMap;
|
| 12 |
import java.util.List;
|
13 |
import java.util.List;
|
| 13 |
import java.util.Map;
|
14 |
import java.util.Map;
|
| 14 |
import java.util.Set;
|
15 |
import java.util.Set;
|
| 15 |
import java.util.function.IntFunction;
|
16 |
import java.util.function.IntFunction;
|
| 16 |
import java.util.function.IntPredicate;
|
17 |
import java.util.function.IntPredicate;
|
| Line 104... |
Line 105... |
| 104 |
@Autowired
|
105 |
@Autowired
|
| 105 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
106 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 106 |
|
107 |
|
| 107 |
@Autowired
|
108 |
@Autowired
|
| 108 |
private TransactionService transactionService;
|
109 |
private TransactionService transactionService;
|
| 109 |
|
110 |
|
| 110 |
@Autowired
|
111 |
@Autowired
|
| 111 |
private InventoryService inventoryService;
|
112 |
private InventoryService inventoryService;
|
| 112 |
|
113 |
|
| 113 |
@Autowired
|
114 |
@Autowired
|
| 114 |
private MVCResponseSender mvcResponseSender;
|
115 |
private MVCResponseSender mvcResponseSender;
|
| Line 122... |
Line 123... |
| 122 |
@Autowired
|
123 |
@Autowired
|
| 123 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
124 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 124 |
|
125 |
|
| 125 |
@Autowired
|
126 |
@Autowired
|
| 126 |
private InsuranceProviderRepository insuranceProviderRepository;
|
127 |
private InsuranceProviderRepository insuranceProviderRepository;
|
| 127 |
|
128 |
|
| 128 |
@Autowired
|
129 |
@Autowired
|
| 129 |
private Mongo mongoClient;
|
130 |
private Mongo mongoClient;
|
| 130 |
|
131 |
|
| 131 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
132 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 132 |
|
133 |
|
| - |
|
134 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| - |
|
135 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
136 |
LOGGER.info("In Dashboard1");
|
| - |
|
137 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
138 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices());
|
| - |
|
139 |
model.addAttribute("salesMap", this.getSales());
|
| - |
|
140 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| - |
|
141 |
return "dashboard1";
|
| - |
|
142 |
}
|
| - |
|
143 |
|
| - |
|
144 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
| - |
|
145 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| - |
|
146 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| - |
|
147 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
| - |
|
148 |
LocalDate lastMonthStart = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
| - |
|
149 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
| - |
|
150 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
| - |
|
151 |
if (yesterdayInvestment == null) {
|
| - |
|
152 |
yesterdayInvestment = new PartnerDailyInvestment();
|
| - |
|
153 |
}
|
| - |
|
154 |
List<PartnerDailyInvestment> lastMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
| - |
|
155 |
lastMonthStart, lastMonthStart.withDayOfMonth(lastMonthStart.lengthOfMonth()));
|
| - |
|
156 |
|
| - |
|
157 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
| - |
|
158 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
| - |
|
159 |
|
| - |
|
160 |
long lastMonthShortDays = lastMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
| - |
|
161 |
.collect(Collectors.counting());
|
| - |
|
162 |
long mtdShortDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() > 10)
|
| - |
|
163 |
.collect(Collectors.counting());
|
| - |
|
164 |
investments.put("Today", investment.getTotalInvestment());
|
| - |
|
165 |
investments.put("Yesterday", yesterdayInvestment.getTotalInvestment());
|
| - |
|
166 |
investments.put("Short MTD", mtdShortDays);
|
| - |
|
167 |
investments.put("Short Last Month", lastMonthShortDays);
|
| - |
|
168 |
return investments;
|
| - |
|
169 |
}
|
| - |
|
170 |
|
| - |
|
171 |
private Map<String, Float> getSales() {
|
| - |
|
172 |
Map<String, Float> salesMap = new LinkedHashMap<>();
|
| - |
|
173 |
salesMap.put("Today", 10000f);
|
| - |
|
174 |
salesMap.put("Yesterday", 100000f);
|
| - |
|
175 |
salesMap.put("MTD", 100000f);
|
| - |
|
176 |
return salesMap;
|
| - |
|
177 |
}
|
| - |
|
178 |
|
| - |
|
179 |
private List<BrandStockPrice> getBrandStockPrices() {
|
| - |
|
180 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| - |
|
181 |
BrandStockPrice brandStockPrice = new BrandStockPrice();
|
| - |
|
182 |
brandStockPrice.setBrand("Nokia");
|
| - |
|
183 |
brandStockPrice.setBrandUrl("");
|
| - |
|
184 |
brandStockPrice.setRank(1);
|
| - |
|
185 |
brandStockPrice.setTotalQty(10);
|
| - |
|
186 |
brandStockPrice.setTotalValue(10000);
|
| - |
|
187 |
BrandStockPrice brandStockPrice1 = new BrandStockPrice();
|
| - |
|
188 |
brandStockPrice1.setBrand("Samsung");
|
| - |
|
189 |
brandStockPrice1.setBrandUrl("");
|
| - |
|
190 |
brandStockPrice1.setRank(1);
|
| - |
|
191 |
brandStockPrice1.setTotalQty(10);
|
| - |
|
192 |
brandStockPrice1.setTotalValue(10000);
|
| - |
|
193 |
BrandStockPrice brandStockPrice2 = new BrandStockPrice();
|
| - |
|
194 |
brandStockPrice2.setBrand("Oppo");
|
| - |
|
195 |
brandStockPrice2.setBrandUrl("");
|
| - |
|
196 |
brandStockPrice2.setRank(1);
|
| - |
|
197 |
brandStockPrice2.setTotalQty(10);
|
| - |
|
198 |
brandStockPrice2.setTotalValue(10000);
|
| - |
|
199 |
BrandStockPrice brandStockPrice3 = new BrandStockPrice();
|
| - |
|
200 |
brandStockPrice3.setBrand("Vivo");
|
| - |
|
201 |
brandStockPrice3.setBrandUrl("");
|
| - |
|
202 |
brandStockPrice3.setRank(1);
|
| - |
|
203 |
brandStockPrice3.setTotalQty(10);
|
| - |
|
204 |
brandStockPrice3.setTotalValue(10000);
|
| - |
|
205 |
brandStockPrices.add(brandStockPrice);
|
| - |
|
206 |
brandStockPrices.add(brandStockPrice1);
|
| - |
|
207 |
brandStockPrices.add(brandStockPrice2);
|
| - |
|
208 |
brandStockPrices.add(brandStockPrice3);
|
| - |
|
209 |
return brandStockPrices;
|
| - |
|
210 |
}
|
| - |
|
211 |
|
| 133 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
212 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 134 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
213 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 135 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
214 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 136 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
215 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
| 137 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
216 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
| Line 245... |
Line 324... |
| 245 |
.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
324 |
.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
| 246 |
|
325 |
|
| 247 |
} catch (Exception e) {
|
326 |
} catch (Exception e) {
|
| 248 |
LOGGER.error("partner Investment can't exists");
|
327 |
LOGGER.error("partner Investment can't exists");
|
| 249 |
}
|
328 |
}
|
| 250 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(loginDetails.getFofoId());
|
329 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService
|
| - |
|
330 |
.getBrandWiseStockValue(loginDetails.getFofoId());
|
| 251 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(loginDetails.getFofoId(), loginDetails.getEmailId(), 3);
|
331 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(loginDetails.getFofoId(), loginDetails.getEmailId(),
|
| - |
|
332 |
3);
|
| 252 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
333 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 253 |
mobileBrands.stream().forEach(x->{
|
334 |
mobileBrands.stream().forEach(x -> {
|
| 254 |
String brand = (String)x.get("name");
|
335 |
String brand = (String) x.get("name");
|
| 255 |
if(brandStockPricesMap.containsKey(brand)) {
|
336 |
if (brandStockPricesMap.containsKey(brand)) {
|
| 256 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
337 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
| 257 |
brandStockPrice.setBrandUrl((String)x.get("url"));
|
338 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
| 258 |
brandStockPrice.setRank(((Double)x.get("rank")).intValue());
|
339 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
| 259 |
brandStockPrices.add(brandStockPrice);
|
340 |
brandStockPrices.add(brandStockPrice);
|
| 260 |
} else {
|
341 |
} else {
|
| 261 |
}
|
342 |
}
|
| 262 |
});
|
343 |
});
|
| - |
|
344 |
model.addAttribute("brandStockPrices",
|
| 263 |
model.addAttribute("brandStockPrices", brandStockPrices.stream().sorted((x,y)-> y.getRank() - x.getRank()).collect(Collectors.toList()));
|
345 |
brandStockPrices.stream().sorted((x, y) -> y.getRank() - x.getRank()).collect(Collectors.toList()));
|
| 264 |
model.addAttribute("isInvestmentOk", isInvestmentOk || roleManager.isAdmin(loginDetails.getRoleIds()));
|
346 |
model.addAttribute("isInvestmentOk", isInvestmentOk || roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 265 |
model.addAttribute("partnerInvestment", partnerInvestments.get(0));
|
347 |
model.addAttribute("partnerInvestment", partnerInvestments.get(0));
|
| - |
|
348 |
// model.addAttribute("investmentChart",
|
| 266 |
//model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
|
349 |
// this.getInvestmentChartData(partnerInvestments));
|
| 267 |
model.addAttribute("fofoStore", fofoStore);
|
350 |
model.addAttribute("fofoStore", fofoStore);
|
| 268 |
model.addAttribute("walletAmount");
|
351 |
model.addAttribute("walletAmount");
|
| 269 |
model.addAttribute("appContextPath", request.getContextPath());
|
352 |
model.addAttribute("appContextPath", request.getContextPath());
|
| - |
|
353 |
// model.addAttribute("isAdmin",
|
| 270 |
//model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
354 |
// roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 271 |
model.addAttribute("isAdmin", false);
|
355 |
model.addAttribute("isAdmin", false);
|
| 272 |
model.addAttribute("webApiHost", webApiHost);
|
356 |
model.addAttribute("webApiHost", webApiHost);
|
| 273 |
model.addAttribute("webApiPort", webApiPort);
|
357 |
model.addAttribute("webApiPort", webApiPort);
|
| 274 |
model.addAttribute("webApiScheme", webApiScheme);
|
358 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 275 |
model.addAttribute("webApiRoot", webApiRoot);
|
359 |
model.addAttribute("webApiRoot", webApiRoot);
|
| Line 621... |
Line 705... |
| 621 |
|
705 |
|
| 622 |
Map<String, Object> map = new HashMap<>();
|
706 |
Map<String, Object> map = new HashMap<>();
|
| 623 |
|
707 |
|
| 624 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
708 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
| 625 |
previousMonthFirstDay, currentDayEnd);
|
709 |
previousMonthFirstDay, currentDayEnd);
|
| 626 |
|
710 |
|
| 627 |
Double currentMonthTotalSale = fofoOrderItems.stream()
|
711 |
Double currentMonthTotalSale = fofoOrderItems.stream()
|
| 628 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
712 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
| 629 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
713 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
| 630 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
714 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
| 631 |
|
715 |
|
| Line 748... |
Line 832... |
| 748 |
Map<String, Double> previousMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
832 |
Map<String, Double> previousMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
| 749 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
833 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
| 750 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
834 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
| 751 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
835 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
| 752 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
836 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
| 753 |
|
837 |
|
| 754 |
map.put("brands", brands);
|
838 |
map.put("brands", brands);
|
| 755 |
map.put("accessories", accessories);
|
839 |
map.put("accessories", accessories);
|
| 756 |
map.put("currentMonthTotalSale", currentMonthTotalSale);
|
840 |
map.put("currentMonthTotalSale", currentMonthTotalSale);
|
| 757 |
map.put("previousMonthTotalSale", previousMonthTotalSale);
|
841 |
map.put("previousMonthTotalSale", previousMonthTotalSale);
|
| 758 |
map.put("currentDayTotalSale", currentDayTotalSale);
|
842 |
map.put("currentDayTotalSale", currentDayTotalSale);
|