Subversion Repositories SmartDukaan

Rev

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

Rev 31640 Rev 31651
Line 4635... Line 4635...
4635
			}
4635
			}
4636
 
4636
 
4637
		}
4637
		}
4638
 
4638
 
4639
	}
4639
	}
4640
	
4640
 
4641
	@Autowired
4641
	@Autowired
4642
	WarehouseInventoryItemRepository warehouseInventoryItemRepository;
4642
	WarehouseInventoryItemRepository warehouseInventoryItemRepository;
-
 
4643
 
4643
	public void test() throws Exception {
4644
	public void test() throws Exception {
4644
		this.sendMailForSamsungRebilling();
4645
		this.sendMailForSamsungRebilling();
4645
	}
4646
	}
4646
 
4647
 
4647
	public void sendMailForSamsungRebilling() throws Exception {
4648
	public void sendMailForSamsungRebilling() throws Exception {
4648
		List<BilledImeiModel> samsungModels = warehouseInventoryItemRepository.findByBillingDateBrand(LocalDate.now(), "Samsung");
4649
		List<BilledImeiModel> samsungModels = warehouseInventoryItemRepository.findByBillingDateBrand(LocalDate.now(),
-
 
4650
				"Samsung");
4649
		LOGGER.info("SamsungModels {}", samsungModels);
4651
		LOGGER.info("SamsungModels {}", samsungModels);
4650
		samsungModels = samsungModels.stream().sorted(Comparator.comparing(x-> x.getPcmDate()==null ? -1:1)).collect(Collectors.toList());
4652
		samsungModels = samsungModels.stream().sorted(Comparator.comparing(x -> x.getPcmDate() == null ? -1 : 1))
-
 
4653
				.collect(Collectors.toList());
4651
		if(samsungModels.size() > 0) {
4654
		if (samsungModels.size() > 0) {
4652
			List<String> headers = Arrays.asList("Partner Id", "Code", "Name", "City", "Brand", "Model Name", "Model Number", "Color", "Serial Number", "Remarks");
4655
			List<String> headers = Arrays.asList("Partner Id", "Code", "Name", "City", "Brand", "Model Name",
-
 
4656
					"Model Number", "Color", "Serial Number", "Remarks");
4653
			List<List<?>> rows = new ArrayList<>();
4657
			List<List<?>> rows = new ArrayList<>();
4654
			for(BilledImeiModel billedImeiModel : samsungModels) {
4658
			for (BilledImeiModel billedImeiModel : samsungModels) {
4655
				List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(),
4659
				List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(),
-
 
4660
						billedImeiModel.getStoreName(), billedImeiModel.getStoreCity(), billedImeiModel.getBrand(),
4656
						billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(),
4661
						billedImeiModel.getModelName(), billedImeiModel.getModelNumber(), billedImeiModel.getColor(),
-
 
4662
						billedImeiModel.getSerialNumber(),
4657
						billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate()==null ? "PCM date Missing" : "Rebill Imeis");
4663
						billedImeiModel.getPcmDate() == null ? "PCM date Missing" : "Rebill Imeis");
4658
				rows.add(row);
4664
				rows.add(row);
4659
			}
4665
			}
4660
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
4666
			ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
4661
			String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com"};
4667
			String[] sendToArray = new String[] { "kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com" };
4662
			String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
4668
			String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
4663
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA",
4669
			Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[] { "tarun.verma@smartdukaan.com" },
4664
					fileName, new ByteArrayResource(baos.toByteArray()));
4670
					"Samsung Rebilling IMEI Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
4665
		}
4671
		}
4666
	}
4672
	}
4667
 
4673
 
4668
 
4674
 
4669
 
4675
 
Line 4801... Line 4807...
4801
	}
4807
	}
4802
 
4808
 
4803
	public void getPriceDrop() throws ProfitMandiBusinessException {
4809
	public void getPriceDrop() throws ProfitMandiBusinessException {
4804
		WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
4810
		WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
4805
 
4811
 
4806
		List<WebProductListing> webProductListings = webProductListingRepository
-
 
4807
				.selectAllByWebListingId(webListing.getId());
-
 
4808
 
-
 
4809
		Set<Integer> catalogItemIds = priceDropRepository
4812
		List<Integer> catalogItemIds = priceDropRepository
4810
				.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
4813
				.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now().plusDays(1))
4811
				.map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
4814
				.stream().map(x -> x.getCatalogItemId()).distinct().collect(Collectors.toList());
4812
 
4815
 
4813
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4816
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4814
		if (!catalogItemIds.isEmpty()) {
4817
		if (!catalogItemIds.isEmpty()) {
4815
			webProductListingRepository.deleteByEqual(webListing.getId());
4818
			webProductListingRepository.deleteByEqual(webListing.getId());
4816
			int count = 0;
4819
			int count = 0;
Line 4829... Line 4832...
4829
	}
4832
	}
4830
 
4833
 
4831
	public void getNewLaunches() throws ProfitMandiBusinessException {
4834
	public void getNewLaunches() throws ProfitMandiBusinessException {
4832
		WebListing webListing = webListingRepository.selectByUrl("new-launches");
4835
		WebListing webListing = webListingRepository.selectByUrl("new-launches");
4833
 
4836
 
4834
		Set<Integer> itemIds = tagListingRepository
-
 
4835
				.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
4837
		List<Integer> catalogItemIds = tagListingRepository.getRecentLanuch(LocalDate.now().minusDays(30),
4836
				.map(x -> x.getItemId()).collect(Collectors.toSet());
4838
				LocalDate.now().plusDays(1));
4837
 
4839
 
4838
		LOGGER.info("itemIds {}", itemIds);
-
 
4839
 
-
 
4840
		List<Integer> catalogItemIds = itemRepository.selectByIds(itemIds).stream().map(x -> x.getCatalogItemId())
-
 
4841
				.distinct().collect(Collectors.toList());
-
 
4842
 
-
 
4843
		LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4844
		if (!catalogItemIds.isEmpty()) {
4840
		if (!catalogItemIds.isEmpty()) {
4845
			webProductListingRepository.deleteByEqual(webListing.getId());
4841
			webProductListingRepository.deleteByEqual(webListing.getId());
4846
			int count = 0;
4842
			int count = 0;
4847
			for (Integer catalogItemId : catalogItemIds) {
4843
			for (Integer catalogItemId : catalogItemIds) {
4848
 
4844
 
Line 4859... Line 4855...
4859
	}
4855
	}
4860
 
4856
 
4861
	public void getSpecialSupport() throws ProfitMandiBusinessException {
4857
	public void getSpecialSupport() throws ProfitMandiBusinessException {
4862
		WebListing webListing = webListingRepository.selectByUrl("special-support");
4858
		WebListing webListing = webListingRepository.selectByUrl("special-support");
4863
 
4859
 
4864
		Set<Integer> schemeIds = schemeRepository.selectActiveAll(Arrays.asList(SchemeType.SPECIAL_SUPPORT),
4860
		List<Integer> catalogItemIds = schemeRepository.getActiveScheme(SchemeType.SPECIAL_SUPPORT, LocalDate.now());
4865
				LocalDate.now().minusDays(30), LocalDate.now().plusDays(1), false).stream().map(x -> x.getId())
-
 
4866
				.collect(Collectors.toSet());
-
 
4867
 
-
 
4868
		Set<Integer> catalogItemIds = schemeItemRepository.selectBySchemeIds(schemeIds).stream()
-
 
4869
				.map(x -> x.getCatalogId()).collect(Collectors.toSet());
-
 
4870
 
4861
 
4871
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4862
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4872
		if (!catalogItemIds.isEmpty()) {
4863
		if (!catalogItemIds.isEmpty()) {
4873
			webProductListingRepository.deleteByEqual(webListing.getId());
4864
			webProductListingRepository.deleteByEqual(webListing.getId());
4874
			int count = 0;
4865
			int count = 0;
Line 4887... Line 4878...
4887
	}
4878
	}
4888
 
4879
 
4889
	public void getUpgradeOffer() throws ProfitMandiBusinessException {
4880
	public void getUpgradeOffer() throws ProfitMandiBusinessException {
4890
		WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
4881
		WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
4891
 
4882
 
4892
		List<Integer> customerOfferIds = customerOfferRepository
4883
		List<Integer> customerOfferIds = customerOfferRepository.selectOffers(LocalDate.now()).stream()
4893
				.selectOffers(LocalDateTime.now().minusDays(30), LocalDateTime.now().plusDays(1)).stream()
-
 
4894
				.map(x -> x.getId()).collect(Collectors.toList());
4884
				.map(x -> x.getId()).collect(Collectors.toList());
4895
 
4885
 
4896
		Set<Integer> catalogItemIds = customerOfferItemRepository
4886
		List<Integer> catalogItemIds = customerOfferItemRepository
4897
				.selectByOfferIdsRange(customerOfferIds, LocalDate.now().minusDays(30), LocalDate.now().plusDays(1))
4887
				.selectByOfferIdsRange(customerOfferIds, LocalDate.now().minusDays(30), LocalDate.now().plusDays(1))
4898
				.stream().map(x -> x.getCatalogId()).collect(Collectors.toSet());
4888
				.stream().map(x -> x.getCatalogId()).distinct().collect(Collectors.toList());
4899
 
4889
 
4900
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4890
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4901
		if (!catalogItemIds.isEmpty()) {
4891
		if (!catalogItemIds.isEmpty()) {
4902
			webProductListingRepository.deleteByEqual(webListing.getId());
4892
			webProductListingRepository.deleteByEqual(webListing.getId());
4903
			int count = 0;
4893
			int count = 0;