| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service;
|
1 |
package com.spice.profitmandi.service;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.spice.profitmandi.service.warehouse.BillingWarehouseService;
|
| - |
|
4 |
|
| 3 |
import com.google.gson.Gson;
|
5 |
import com.google.gson.Gson;
|
| 4 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
6 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.model.*;
|
8 |
import com.spice.profitmandi.common.model.*;
|
| 7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| Line 48... |
Line 50... |
| 48 |
import java.util.stream.LongStream;
|
50 |
import java.util.stream.LongStream;
|
| 49 |
|
51 |
|
| 50 |
@Component
|
52 |
@Component
|
| 51 |
public class AdminUser {
|
53 |
public class AdminUser {
|
| 52 |
|
54 |
|
| - |
|
55 |
@Autowired
|
| - |
|
56 |
private BillingWarehouseService billingWarehouseService;
|
| - |
|
57 |
|
| - |
|
58 |
|
| 53 |
// These users see every sidebar menu regardless of auth.menu_category (as do L5 position holders).
|
59 |
// These users see every sidebar menu regardless of auth.menu_category (as do L5 position holders).
|
| 54 |
public static final List<String> ALL_MENU_EMAILS = Arrays.asList("amit.gupta@smartdukaan.com", "ranu.rajput@smartdukaan.com",
|
60 |
public static final List<String> ALL_MENU_EMAILS = Arrays.asList("amit.gupta@smartdukaan.com", "ranu.rajput@smartdukaan.com",
|
| 55 |
"vikas.jangra@smartdukaan.com", "tanay.gupta@smartdukaan.com", "rudy.kanwar@smartdukaan.com");
|
61 |
"vikas.jangra@smartdukaan.com", "tanay.gupta@smartdukaan.com", "rudy.kanwar@smartdukaan.com");
|
| 56 |
@Autowired
|
62 |
@Autowired
|
| 57 |
private Gson gson;
|
63 |
private Gson gson;
|
| Line 323... |
Line 329... |
| 323 |
public Map<String, Object> getFilter(int warehouseId, String email, LocalDateTime date, LocalDateTime endDate)
|
329 |
public Map<String, Object> getFilter(int warehouseId, String email, LocalDateTime date, LocalDateTime endDate)
|
| 324 |
throws ProfitMandiBusinessException {
|
330 |
throws ProfitMandiBusinessException {
|
| 325 |
Map<String, Object> map = new HashMap<>();
|
331 |
Map<String, Object> map = new HashMap<>();
|
| 326 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
332 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 327 |
Map<Integer, CustomRetailer> crm = null;
|
333 |
Map<Integer, CustomRetailer> crm = null;
|
| 328 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
334 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 329 |
|
335 |
|
| 330 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
336 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 331 |
|
337 |
|
| 332 |
if (warehouseId != 0) {
|
338 |
if (warehouseId != 0) {
|
| 333 |
|
339 |
|
| Line 477... |
Line 483... |
| 477 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
483 |
Map<Integer, PartnerDetailModel> warehousePartnerDetailMap = null;
|
| 478 |
|
484 |
|
| 479 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap;
|
485 |
Map<Integer, WarehouseWiseStockModel> warehouseStockMap;
|
| 480 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
486 |
LinkedHashMap<Integer, WarehouseWiseStockModel> warehouseStockSortedMap = new LinkedHashMap<>();
|
| 481 |
|
487 |
|
| 482 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
488 |
Map<Integer, String> warehouseMap = billingWarehouseService.getActiveWarehouses();
|
| 483 |
Map<Integer, String> wm = new LinkedHashMap<>();
|
489 |
Map<Integer, String> wm = new LinkedHashMap<>();
|
| 484 |
|
490 |
|
| 485 |
Map<AuthUser, Long> authUserTicketCount = null;
|
491 |
Map<AuthUser, Long> authUserTicketCount = null;
|
| 486 |
LoanSummary loanSummary = sdCreditService.getLoanSummary();
|
492 |
LoanSummary loanSummary = sdCreditService.getLoanSummary();
|
| 487 |
|
493 |
|
| Line 841... |
Line 847... |
| 841 |
private Map<Integer, List<Integer>> getWarehouseIdFofoIdMap(Set<Integer> fofoIds) throws ProfitMandiBusinessException {
|
847 |
private Map<Integer, List<Integer>> getWarehouseIdFofoIdMap(Set<Integer> fofoIds) throws ProfitMandiBusinessException {
|
| 842 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
848 |
Map<Integer, List<Integer>> warehouseIdFofoIdMap = fofoStoreRepository
|
| 843 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream()
|
849 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds)).stream()
|
| 844 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
850 |
.collect(Collectors.groupingBy(FofoStore::getWarehouseId,
|
| 845 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
851 |
Collectors.mapping(FofoStore::getId, Collectors.toList())));
|
| 846 |
// Every warehouse holding stock gets a row, even with no franchise store of its own - a hub such as the
|
852 |
// Dashboards list the ACTIVE warehouses: each gets a row even with no franchise store of its own (a hub such
|
| 847 |
// HR warehouses carries only internal movement stores, so the store grouping above never lists it.
|
853 |
// as the HR warehouses carries only internal movement stores), and a suspended or closed one gets none even
|
| - |
|
854 |
// while it still holds stock.
|
| 848 |
for (Integer stockWarehouseId : saholicInventoryCISRepository.selectWarehouseIdsWithStock()) {
|
855 |
Set<Integer> activeWarehouseIds = billingWarehouseService.getActiveWarehouses().keySet();
|
| - |
|
856 |
for (Integer activeWarehouseId : activeWarehouseIds) {
|
| 849 |
warehouseIdFofoIdMap.putIfAbsent(stockWarehouseId, new ArrayList<>());
|
857 |
warehouseIdFofoIdMap.putIfAbsent(activeWarehouseId, new ArrayList<>());
|
| 850 |
}
|
858 |
}
|
| - |
|
859 |
warehouseIdFofoIdMap.keySet().retainAll(activeWarehouseIds);
|
| 851 |
return warehouseIdFofoIdMap;
|
860 |
return warehouseIdFofoIdMap;
|
| 852 |
}
|
861 |
}
|
| 853 |
|
862 |
|
| 854 |
private List<Menu> prepareMenu(List<Menu> menus) {
|
863 |
private List<Menu> prepareMenu(List<Menu> menus) {
|
| 855 |
List<Menu> returnMenu = new ArrayList<>();
|
864 |
List<Menu> returnMenu = new ArrayList<>();
|
| Line 939... |
Line 948... |
| 939 |
|
948 |
|
| 940 |
private String getWarehouses(Set<CustomRetailer> positionRetailers) {
|
949 |
private String getWarehouses(Set<CustomRetailer> positionRetailers) {
|
| 941 |
Map<Integer, String> warehouses = new HashMap<>();
|
950 |
Map<Integer, String> warehouses = new HashMap<>();
|
| 942 |
positionRetailers.stream().forEach(x -> {
|
951 |
positionRetailers.stream().forEach(x -> {
|
| 943 |
if (x.getWarehouseId() != 0) {
|
952 |
if (x.getWarehouseId() != 0) {
|
| 944 |
warehouses.put(x.getWarehouseId(), ProfitMandiConstants.WAREHOUSE_MAP.get(x.getWarehouseId()));
|
953 |
warehouses.put(x.getWarehouseId(), billingWarehouseService.getName(x.getWarehouseId()));
|
| 945 |
}
|
954 |
}
|
| 946 |
});
|
955 |
});
|
| 947 |
return gson.toJson(warehouses);
|
956 |
return gson.toJson(warehouses);
|
| 948 |
|
957 |
|
| 949 |
}
|
958 |
}
|