Subversion Repositories SmartDukaan

Rev

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

Rev 25170 Rev 25173
Line 171... Line 171...
171
 
171
 
172
	private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
172
	private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
173
		Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
173
		Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
174
		List<InventoryItemAgingModel> models = inventoryService.getItemAgingByInterval(fofoId, Arrays.asList(30));
174
		List<InventoryItemAgingModel> models = inventoryService.getItemAgingByInterval(fofoId, Arrays.asList(30));
175
		
175
		
176
		
-
 
177
		Map<String, Integer> brandWiseQty = models.stream()
-
 
178
				.filter(x -> ItemType.SERIALIZED.toString().equals(x.getItemType())  && x.getValues().get(1)!=null)
-
 
179
				.collect(Collectors.groupingBy(x -> x.getBrand(), Collectors.summingInt(x -> 
-
 
180
				x.getValues().get(1).getQuantity())));
-
 
181
		Map<String, Double> brandWiseValue = models.stream()
-
 
182
				.filter(x -> x.getItemType().equals(ItemType.SERIALIZED.toString()) && x.getValues().get(1)!=null)
-
 
183
				.collect(Collectors.groupingBy(x -> x.getBrand(), Collectors.summingDouble(x -> 
-
 
184
				x.getValues().get(1).getQuantity() * x.getValues().get(1).getPrice())));
-
 
185
 
-
 
186
		List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
176
		List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
187
		List<BrandStockPrice> brandStockPrices = new ArrayList<>();
177
		List<BrandStockPrice> brandStockPrices = new ArrayList<>();
188
 
178
 
189
//		Map<String, Integer> brandWiseQty = new HashMap<String, Integer>();
-
 
190
//		Map<String, Double> brandWiseValue = new HashMap<String, Double>();
-
 
191
		mobileBrands.stream().forEach(x -> {
179
		mobileBrands.stream().forEach(x -> {
192
			String brand = (String) x.get("name");
180
			String brand = (String) x.get("name");
193
			if (brandStockPricesMap.containsKey(brand)) {
181
			if (brandStockPricesMap.containsKey(brand)) {
194
				BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
182
				BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
195
				if (brandWiseQty.get(brand) != null) {
-
 
196
					brandStockPrice.setAgedQty(brandWiseQty.get(brand));
-
 
197
					brandStockPrice.setAgedValue(brandWiseValue.get(brand));
-
 
198
				}
-
 
199
				brandStockPrice.setBrandUrl((String) x.get("url"));
183
				brandStockPrice.setBrandUrl((String) x.get("url"));
200
				brandStockPrice.setRank(((Double) x.get("rank")).intValue());
184
				brandStockPrice.setRank(((Double) x.get("rank")).intValue());
201
				brandStockPrices.add(brandStockPrice);
185
				brandStockPrices.add(brandStockPrice);
202
			} else {
186
			} else {
203
			}
187
			}
204
		});
188
		});
205
 
189
 
206
		return brandStockPrices.stream().sorted((x, y) -> y.getRank() - x.getRank()).collect(Collectors.toList());
190
		return brandStockPrices.stream().filter(x->x.getTotalQty()>0).sorted((x, y) -> x.getRank() - y.getRank()).collect(Collectors.toList());
207
	}
191
	}
208
 
192
 
209
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
193
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
210
	public String dashboard(HttpServletRequest request, Model model) throws Exception {
194
	public String dashboard(HttpServletRequest request, Model model) throws Exception {
211
 
195