| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service;
|
1 |
package com.spice.profitmandi.service;
|
| 2 |
|
2 |
|
| 3 |
import java.io.FileInputStream;
|
- |
|
| 4 |
import java.io.ObjectInputStream;
|
- |
|
| 5 |
import java.time.LocalDate;
|
- |
|
| 6 |
import java.time.LocalDateTime;
|
- |
|
| 7 |
import java.time.Period;
|
- |
|
| 8 |
import java.time.YearMonth;
|
- |
|
| 9 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 10 |
import java.time.temporal.ChronoUnit;
|
- |
|
| 11 |
import java.util.ArrayList;
|
- |
|
| 12 |
import java.util.Arrays;
|
- |
|
| 13 |
import java.util.Comparator;
|
- |
|
| 14 |
import java.util.HashMap;
|
- |
|
| 15 |
import java.util.HashSet;
|
- |
|
| 16 |
import java.util.LinkedHashMap;
|
- |
|
| 17 |
import java.util.LinkedHashSet;
|
- |
|
| 18 |
import java.util.List;
|
- |
|
| 19 |
import java.util.Map;
|
- |
|
| 20 |
import java.util.Map.Entry;
|
- |
|
| 21 |
import java.util.Optional;
|
- |
|
| 22 |
import java.util.Set;
|
- |
|
| 23 |
import java.util.TreeMap;
|
- |
|
| 24 |
import java.util.stream.Collectors;
|
- |
|
| 25 |
import java.util.stream.LongStream;
|
- |
|
| 26 |
|
- |
|
| 27 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 28 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 29 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 30 |
import org.springframework.stereotype.Component;
|
- |
|
| 31 |
import org.springframework.ui.Model;
|
- |
|
| 32 |
|
- |
|
| 33 |
import com.google.gson.Gson;
|
3 |
import com.google.gson.Gson;
|
| 34 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
4 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 36 |
import com.spice.profitmandi.common.model.ChartInvestmentModel;
|
- |
|
| 37 |
import com.spice.profitmandi.common.model.ChartModel;
|
- |
|
| 38 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
- |
|
| 39 |
import com.spice.profitmandi.common.model.Data;
|
6 |
import com.spice.profitmandi.common.model.*;
|
| 40 |
import com.spice.profitmandi.common.model.DataInvestmentModel;
|
- |
|
| 41 |
import com.spice.profitmandi.common.model.Legend;
|
- |
|
| 42 |
import com.spice.profitmandi.common.model.OptionModel;
|
- |
|
| 43 |
import com.spice.profitmandi.common.model.PieLables;
|
- |
|
| 44 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
- |
|
| 45 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 46 |
import com.spice.profitmandi.dao.entity.auth.Menu;
|
8 |
import com.spice.profitmandi.dao.entity.auth.Menu;
|
| 47 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
9 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 48 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
10 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 49 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
11 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| Line 62... |
Line 24... |
| 62 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
24 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
25 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
26 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
27 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 66 |
import com.spice.profitmandi.service.user.RetailerService;
|
28 |
import com.spice.profitmandi.service.user.RetailerService;
|
| - |
|
29 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
30 |
import org.apache.logging.log4j.Logger;
|
| - |
|
31 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
32 |
import org.springframework.stereotype.Component;
|
| - |
|
33 |
import org.springframework.ui.Model;
|
| - |
|
34 |
|
| - |
|
35 |
import java.io.FileInputStream;
|
| - |
|
36 |
import java.io.ObjectInputStream;
|
| - |
|
37 |
import java.time.LocalDate;
|
| - |
|
38 |
import java.time.LocalDateTime;
|
| - |
|
39 |
import java.time.Period;
|
| - |
|
40 |
import java.time.YearMonth;
|
| - |
|
41 |
import java.time.format.DateTimeFormatter;
|
| - |
|
42 |
import java.time.temporal.ChronoUnit;
|
| - |
|
43 |
import java.util.*;
|
| - |
|
44 |
import java.util.Map.Entry;
|
| - |
|
45 |
import java.util.stream.Collectors;
|
| - |
|
46 |
import java.util.stream.LongStream;
|
| 67 |
|
47 |
|
| 68 |
@Component
|
48 |
@Component
|
| 69 |
public class AdminUser {
|
49 |
public class AdminUser {
|
| 70 |
@Autowired
|
50 |
@Autowired
|
| 71 |
private Gson gson;
|
51 |
private Gson gson;
|
| Line 490... |
Line 470... |
| 490 |
List<Menu> menus = null;
|
470 |
List<Menu> menus = null;
|
| 491 |
try {
|
471 |
try {
|
| 492 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
472 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 493 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
473 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| 494 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
474 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
| 495 |
ReporticoCacheTable rctSaholic = null;
|
- |
|
| 496 |
ReporticoCacheTable rctPartneStat = null;
|
- |
|
| 497 |
|
475 |
|
| 498 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap = new HashMap<>();
|
476 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap = new HashMap<>();
|
| 499 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
477 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
| 500 |
|
478 |
|
| 501 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
479 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 502 |
LinkedHashMap<Integer, String> wm = new LinkedHashMap<Integer, String>();
|
480 |
Map<Integer, String> wm = new LinkedHashMap<>();
|
| 503 |
|
481 |
|
| 504 |
Map<AuthUser, Long> authUserTicketCount = null;
|
482 |
Map<AuthUser, Long> authUserTicketCount = null;
|
| 505 |
|
483 |
|
| 506 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
484 |
for (Map.Entry<Integer, String> entry : warehouseMap.entrySet()) {
|
| 507 |
wm.put(entry.getKey(), entry.getValue());
|
485 |
wm.put(entry.getKey(), entry.getValue());
|
| Line 558... |
Line 536... |
| 558 |
}
|
536 |
}
|
| 559 |
|
537 |
|
| 560 |
warehouseStockMap.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder()))
|
538 |
warehouseStockMap.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder()))
|
| 561 |
.forEachOrdered(x -> warehouseStockSortedMap.put(x.getKey(), x.getValue()));
|
539 |
.forEachOrdered(x -> warehouseStockSortedMap.put(x.getKey(), x.getValue()));
|
| 562 |
|
540 |
|
| 563 |
rctSaholic = reporticoCacheTableRepository.selectByTableName("SaholicInventoryCIS");
|
541 |
ReporticoCacheTable rctSaholic = reporticoCacheTableRepository.selectByTableName("SaholicInventoryCIS");
|
| - |
|
542 |
model.addAttribute("reporticoDate", rctSaholic);
|
| 564 |
|
543 |
|
| 565 |
// warehouseStock
|
544 |
// warehouseStock
|
| 566 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
|
545 |
warehousePartnerDetailMap = this.getWarehousePartnerDetail(warehouseIdFofoIdMap);
|
| 567 |
rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
546 |
ReporticoCacheTable rctPartneStat = reporticoCacheTableRepository.selectByTableName("partnerStat");
|
| 568 |
|
547 |
|
| 569 |
Set<CustomRetailer> positionRetailers = fofoIds.stream()
|
548 |
Set<CustomRetailer> positionRetailers = fofoIds.stream()
|
| 570 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
549 |
.map(x -> retailerService.getAllFofoRetailers().get(x)).filter(x -> x != null)
|
| 571 |
.collect(Collectors.toSet());
|
550 |
.collect(Collectors.toSet());
|
| 572 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
551 |
model.addAttribute("retailers", gson.toJson(positionRetailers));
|
| 573 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
552 |
model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
|
| 574 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
553 |
model.addAttribute("warehouses", getWarehouses(positionRetailers));
|
| - |
|
554 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
| 575 |
} else {
|
555 |
} else {
|
| 576 |
List<Position> warehousePositions = positions.stream()
|
556 |
List<Position> warehousePositions = positions.stream()
|
| 577 |
.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
|
557 |
.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
|
| 578 |
.collect(Collectors.toList());
|
558 |
.collect(Collectors.toList());
|
| 579 |
if (warehousePositions.size() > 0) {
|
559 |
if (warehousePositions.size() > 0) {
|
| Line 624... |
Line 604... |
| 624 |
}
|
604 |
}
|
| 625 |
}
|
605 |
}
|
| 626 |
|
606 |
|
| 627 |
model.addAttribute("authId", authUser.getId());
|
607 |
model.addAttribute("authId", authUser.getId());
|
| 628 |
|
608 |
|
| 629 |
model.addAttribute("rctPartneStat", rctPartneStat);
|
- |
|
| 630 |
|
609 |
|
| 631 |
model.addAttribute("reporticoDate", rctSaholic);
|
- |
|
| 632 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
610 |
model.addAttribute("warehousePartnerDetailMap", warehousePartnerDetailMap);
|
| 633 |
model.addAttribute("warehouseMap", wm);
|
611 |
model.addAttribute("warehouseMap", wm);
|
| 634 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
612 |
model.addAttribute("authUserTicketCount", authUserTicketCount);
|
| 635 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
613 |
model.addAttribute("warehouseStockMap", warehouseStockSortedMap);
|
| 636 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
614 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|