Subversion Repositories SmartDukaan

Rev

Rev 27884 | Rev 27895 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27884 Rev 27893
Line 137... Line 137...
137
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
137
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
138
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
138
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
139
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
139
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
140
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
140
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
141
import com.spice.profitmandi.dao.repository.inventory.SaholicInventorySnapshotRepository;
141
import com.spice.profitmandi.dao.repository.inventory.SaholicInventorySnapshotRepository;
-
 
142
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
142
import com.spice.profitmandi.service.PartnerInvestmentService;
143
import com.spice.profitmandi.service.PartnerInvestmentService;
143
import com.spice.profitmandi.service.PartnerStatsService;
144
import com.spice.profitmandi.service.PartnerStatsService;
144
import com.spice.profitmandi.service.authentication.RoleManager;
145
import com.spice.profitmandi.service.authentication.RoleManager;
145
import com.spice.profitmandi.service.inventory.InventoryService;
146
import com.spice.profitmandi.service.inventory.InventoryService;
146
import com.spice.profitmandi.service.offers.OfferService;
147
import com.spice.profitmandi.service.offers.OfferService;
Line 303... Line 304...
303
	private TagListingRepository tagListingRepository;
304
	private TagListingRepository tagListingRepository;
304
 
305
 
305
	@Autowired
306
	@Autowired
306
	private TicketAssignedRepository ticketAssignedRepository;
307
	private TicketAssignedRepository ticketAssignedRepository;
307
 
308
 
-
 
309
	@Autowired
-
 
310
	private OrderRepository orderRepository;
308
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
311
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
309
 
312
 
310
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
313
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
311
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
314
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
312
		boolean isAdmin = false;
315
		boolean isAdmin = false;
Line 990... Line 993...
990
			{
993
			{
991
				menus = menuRepository.selectAll();
994
				menus = menuRepository.selectAll();
992
			} else if (positions.size() > 0) {
995
			} else if (positions.size() > 0) {
993
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
996
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
994
					menus = menuRepository.selectAll();
997
					menus = menuRepository.selectAll();
995
				} else if (positions.size() > 0) {
-
 
996
					if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L5)).count() > 0) {
-
 
997
						menus = menuRepository.selectAll();
-
 
998
					} else {
998
				} else {
999
						List<Integer> menuIds = menuCategoryRepository.selectAllByPositions(positions).stream()
999
					List<Integer> menuIds = menuCategoryRepository.selectAllByPositions(positions).stream()
1000
								.map(x -> x.getMenuId()).collect(Collectors.toList());
1000
							.map(x -> x.getMenuId()).collect(Collectors.toList());
1001
						if (menuIds.size() > 0) {
1001
					if (menuIds.size() > 0) {
1002
							menus = menuRepository.selectAllByIds(menuIds);
1002
						menus = menuRepository.selectAllByIds(menuIds);
1003
						}
-
 
1004
					}
-
 
1005
					List<Position> salesPositions = positions.stream()
-
 
1006
							.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
-
 
1007
							.collect(Collectors.toList());
-
 
1008
					if (salesPositions.size() > 0) {
-
 
1009
						Set<CustomRetailer> positionRetailers = new HashSet<>();
-
 
1010
						csService.getPositionCustomRetailerMap(salesPositions).values().forEach(customRetailers -> {
-
 
1011
							positionRetailers.addAll(customRetailers);
-
 
1012
						});
-
 
1013
						model.addAttribute("retailers", gson.toJson(positionRetailers));
-
 
1014
						model.addAttribute("reporticoProjectMap", ReporticoProject.salesReporticoProjectMap);
-
 
1015
						model.addAttribute("warehouses", getWarehouses(positionRetailers));
-
 
1016
					}
-
 
1017
					List<Position> warehousePositions = positions.stream()
-
 
1018
							.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_WAREHOUSE)
-
 
1019
							.collect(Collectors.toList());
-
 
1020
					if (warehousePositions.size() > 0) {
-
 
1021
						Set<CustomRetailer> positionRetailers = new HashSet<>();
-
 
1022
						csService.getPositionCustomRetailerMap(warehousePositions).values().forEach(customRetailers -> {
-
 
1023
							positionRetailers.addAll(customRetailers);
-
 
1024
						});
-
 
1025
						model.addAttribute("reporticoProjectMap", ReporticoProject.warehouseReporticoMap);
-
 
1026
						model.addAttribute("retailers", gson.toJson(positionRetailers));
-
 
1027
						model.addAttribute("warehouses", getWarehouses(positionRetailers));
-
 
1028
					}
1003
					}
1029
					model.addAttribute("authId", authUser.getId());
-
 
1030
 
-
 
1031
				}
1004
				}
1032
				List<Position> salesPositions = positions.stream()
1005
				List<Position> salesPositions = positions.stream()
1033
						.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
1006
						.filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES)
1034
						.collect(Collectors.toList());
1007
						.collect(Collectors.toList());
1035
				if (salesPositions.size() > 0) {
1008
				if (salesPositions.size() > 0) {
Line 1785... Line 1758...
1785
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1758
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1786
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1759
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1787
		int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1760
		int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
1788
 
1761
 
1789
		Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
1762
		Map<String, Double> brandLMSAmount = fofoOrderItemRepository.selectSumAmountGroupByBrand(
1790
				curDate.withDayOfMonth(1).minusMonths(1),
-
 
1791
				curDate.with(LocalTime.MAX).minusMonths(1).withDayOfMonth(lengthOfMonth), fofoId);
1763
				curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
1792
		Map<String, Long> brandLmsQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
1764
		Map<String, Long> brandLmsQty = fofoOrderItemRepository.selectSumQuantityGroupByBrand(
1793
				curDate.withDayOfMonth(1).minusMonths(1),
-
 
1794
				curDate.with(LocalTime.MAX).minusMonths(1).withDayOfMonth(lengthOfMonth), fofoId);
1765
				curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), fofoId);
1795
 
1766
 
1796
		Double accesorieslmssale = fofoOrderRepository
1767
		Double accesorieslmssale = fofoOrderRepository.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId,
1797
				.selectSumSaleGroupByFofoIdsForMobileOrAccessories(fofoId, curDate.withDayOfMonth(1).minusMonths(1),
-
 
1798
						curDate.with(LocalTime.MAX).minusMonths(1).withDayOfMonth(lengthOfMonth), Optional.of(false))
1768
				curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false)).get(fofoId);
1799
				.get(fofoId);
-
 
1800
		Long accesorieslmsqty = fofoOrderRepository
1769
		Long accesorieslmsqty = fofoOrderRepository
1801
				.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
1770
				.selectSumSaleQuantityGroupByFofoIdsForMobileOrAccessories(fofoId,
1802
						curDate.withDayOfMonth(1).minusMonths(1),
-
 
1803
						curDate.with(LocalTime.MAX).minusMonths(1).withDayOfMonth(lengthOfMonth), Optional.of(false))
1771
						curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), Optional.of(false))
1804
				.get(fofoId);
1772
				.get(fofoId);
1805
 
1773
 
1806
		model.addAttribute("brandLMSAmount", brandLMSAmount);
1774
		model.addAttribute("brandLMSAmount", brandLMSAmount);
1807
		model.addAttribute("brandLmsQty", brandLmsQty);
1775
		model.addAttribute("brandLmsQty", brandLmsQty);
1808
		model.addAttribute("accesorieslmssale", accesorieslmssale);
1776
		model.addAttribute("accesorieslmssale", accesorieslmssale);
Line 1852... Line 1820...
1852
		model.addAttribute("ticketAssigns", ticketAssigns);
1820
		model.addAttribute("ticketAssigns", ticketAssigns);
1853
		model.addAttribute("customRetailer", customRetailer);
1821
		model.addAttribute("customRetailer", customRetailer);
1854
		return "open-ticket";
1822
		return "open-ticket";
1855
	}
1823
	}
1856
 
1824
 
-
 
1825
	@RequestMapping(value = "/getPartnerSecondarySale", method = RequestMethod.GET)
-
 
1826
	public String getPartnerSecondarySale(HttpServletRequest request,
-
 
1827
			@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, @RequestParam String timeValue, Model model)
-
 
1828
			throws Exception {
-
 
1829
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
1830
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
-
 
1831
		int lengthOfMonth = YearMonth.from(curDate.minusMonths(1)).lengthOfMonth();
-
 
1832
		LocalDateTime startDate = null;
-
 
1833
		LocalDateTime endDate = null;
-
 
1834
		List<InStockBrandModel> secondarySale = null;
-
 
1835
		Map<String, List<InStockBrandItemModel>> secondaryItemSale = null;
-
 
1836
 
-
 
1837
		if (timeValue.equals("mtd")) {
-
 
1838
			startDate = curDate.withDayOfMonth(1);
-
 
1839
			endDate = curDate.with(LocalTime.MAX);
-
 
1840
			secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
-
 
1841
			secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
-
 
1842
					.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
-
 
1843
			LOGGER.info("secondarySalemtd" + secondarySale);
-
 
1844
		} else if (timeValue.equals("lmtd")) {
-
 
1845
			startDate = curDate.withDayOfMonth(1).minusMonths(1);
-
 
1846
			endDate = curDate.with(LocalTime.MAX).minusMonths(1);
-
 
1847
			secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
-
 
1848
					.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
-
 
1849
 
-
 
1850
			secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
-
 
1851
			LOGGER.info("secondarySalelmtd" + secondarySale);
-
 
1852
 
-
 
1853
		} else {
-
 
1854
			startDate = curDate.withDayOfMonth(1).minusMonths(1);
-
 
1855
			endDate = curDate.withDayOfMonth(1);
-
 
1856
			secondaryItemSale = orderRepository.selectAllBilledOrderBrandItemByFofoId(startDate, endDate, fofoId)
-
 
1857
					.stream().collect(Collectors.groupingBy(InStockBrandItemModel::getBrand));
-
 
1858
 
-
 
1859
			secondarySale = orderRepository.selectAllBilledOrderBrandByFofoId(startDate, endDate, fofoId);
-
 
1860
			LOGGER.info("secondarySalelms" + secondarySale);
-
 
1861
 
-
 
1862
		}
-
 
1863
 
-
 
1864
		LOGGER.info("secondarySale" + secondarySale);
-
 
1865
		model.addAttribute("secondarySale", secondarySale);
-
 
1866
		model.addAttribute("secondaryItemSale", secondaryItemSale);
-
 
1867
		model.addAttribute("customRetailer", customRetailer);
-
 
1868
 
-
 
1869
		return "partner-secondary-order";
-
 
1870
	}
-
 
1871
 
1857
}
1872
}