Subversion Repositories SmartDukaan

Rev

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

Rev 27042 Rev 27051
Line 99... Line 99...
99
	@Value("${python.api.port}")
99
	@Value("${python.api.port}")
100
	private int port;
100
	private int port;
101
 
101
 
102
	@Autowired
102
	@Autowired
103
	RestClient restClient;
103
	RestClient restClient;
104
	
104
 
105
	@Autowired
105
	@Autowired
106
	SolrService solrService;
106
	SolrService solrService;
107
 
107
 
108
	@Autowired
108
	@Autowired
109
	InventoryService inventoryService;
109
	InventoryService inventoryService;
Line 133... Line 133...
133
	@Autowired
133
	@Autowired
134
	private ItemBucketService itemBucketService;
134
	private ItemBucketService itemBucketService;
135
 
135
 
136
	@Autowired
136
	@Autowired
137
	private UserAccountRepository userAccountRepository;
137
	private UserAccountRepository userAccountRepository;
138
	
138
 
139
	@Autowired
139
	@Autowired
140
	private FofoStoreRepository fofoStoreRepository;
140
	private FofoStoreRepository fofoStoreRepository;
141
 
141
 
142
	@Autowired
142
	@Autowired
143
	private ResponseSender<?> responseSender;
143
	private ResponseSender<?> responseSender;
Line 149... Line 149...
149
	private ItemRepository itemRepository;
149
	private ItemRepository itemRepository;
150
 
150
 
151
	@Autowired
151
	@Autowired
152
	private RoleManager roleManagerService;
152
	private RoleManager roleManagerService;
153
 
153
 
154
	
-
 
155
	@Autowired
154
	@Autowired
156
	private SuggestedPoDetailRepository monthlyPoDetailRepository;
155
	private SuggestedPoDetailRepository monthlyPoDetailRepository;
157
 
156
 
158
	@Autowired
157
	@Autowired
159
	private SuggestedPoRepository suggestedPoRepository;
158
	private SuggestedPoRepository suggestedPoRepository;
Line 268... Line 267...
268
			@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
267
			@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
269
			@RequestParam(value = "q", required = false) String queryTerm,
268
			@RequestParam(value = "q", required = false) String queryTerm,
270
			@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
269
			@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
271
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
270
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
272
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
271
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
272
		dealResponse = this.getCatalogResponse(
273
		dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset,
273
				solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal),
274
				limit, sort, brand, subCategoryId, hotDeal), hotDeal, userInfo.getRetailerId());
274
				hotDeal, userInfo.getRetailerId());
275
		return responseSender.ok(dealResponse);
275
		return responseSender.ok(dealResponse);
276
	}
276
	}
277
 
277
 
278
	/*private JSONArray getSolrDocs(int fofoId, String queryTerm, String categoryId, String offset, String limit,
-
 
279
			String sort, String brand, int subCategoryId, boolean hotDeal) throws Throwable {
-
 
280
		List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(fofoId);
-
 
281
		List<String> parentFilter = new ArrayList<>();
-
 
282
		parentFilter.add("categoryId_i:" + categoryId);
-
 
283
 
-
 
284
		List<String> childFilter = new ArrayList<>();
-
 
285
		childFilter.add("itemId_i:*");
-
 
286
 
-
 
287
		Map<String, String> params = new HashMap<>();
-
 
288
		if (queryTerm == null || queryTerm.equals("null")) {
-
 
289
			queryTerm = "";
-
 
290
		} else {
-
 
291
			queryTerm = "(" + queryTerm + ")";
-
 
292
		}
-
 
293
		if (hotDeal) {
-
 
294
			childFilter.add("hot_deal_b:true");
-
 
295
		} else {
-
 
296
			childFilter.add("active_b:true");
-
 
297
		}
-
 
298
		if (subCategoryId != 0) {
-
 
299
			parentFilter.add("subCategoryId_i:" + subCategoryId);
-
 
300
		}
-
 
301
		if (StringUtils.isNotBlank(brand)) {
-
 
302
			parentFilter.add("brand_ss:" + brand);
-
 
303
		}
-
 
304
		if (queryTerm == "") {
-
 
305
			params.put("sort", "create_s desc");
-
 
306
		} else {
-
 
307
			parentFilter.addAll(Arrays.asList(queryTerm.split(" ")));
-
 
308
		}
-
 
309
		String parentFilterString = "\"" + String.join(" AND ", parentFilter) + "\"";
-
 
310
		String childFilterString = String.join(" AND ", childFilter);
-
 
311
		logger.info(parentFilterString);
-
 
312
		params.put("q", String.format("{!parent which=%s}%s", parentFilterString, childFilterString));
-
 
313
		params.put("fl",
-
 
314
				String.format("*, [child parentFilter=id:catalog* childFilter=%s]", "\"" + childFilterString + "\""));
-
 
315
		params.put("start", String.valueOf(offset));
-
 
316
		params.put("rows", String.valueOf(limit));
-
 
317
		params.put("wt", "json");
-
 
318
		String response = null;
-
 
319
		try {
-
 
320
			response = restClient.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
-
 
321
		} catch (HttpHostConnectException e) {
-
 
322
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
-
 
323
		}
-
 
324
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
-
 
325
		JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
-
 
326
		return docs;
-
 
327
	}*/
-
 
328
 
278
 
329
	@ApiImplicitParams({
279
	@ApiImplicitParams({
330
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
280
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
331
	@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
281
	@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
332
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
282
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
Line 339... Line 289...
339
			@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
289
			@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
340
			throws Throwable {
290
			throws Throwable {
341
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
291
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
342
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
292
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
343
		UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
293
		UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
-
 
294
		dealResponse = this.getCatalogResponse(
344
		dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset, limit,
295
				solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, false), false,
345
				sort, brand, subCategoryId, false), false, userInfo.getRetailerId());
296
				userInfo.getRetailerId());
346
		return responseSender.ok(dealResponse);
297
		return responseSender.ok(dealResponse);
347
	}
298
	}
348
 
299
 
349
	@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
300
	@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
350
	@ApiImplicitParams({
301
	@ApiImplicitParams({
Line 617... Line 568...
617
				return dealResponse;
568
				return dealResponse;
618
			}
569
			}
619
		}
570
		}
620
		//get warehouse Id
571
		//get warehouse Id
621
		int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
572
		int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
622
		Map<Integer, SaholicCIS> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId); 
573
		Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId); 
623
		Map<Integer, SaholicPOItem> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId); 
574
		Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId); 
624
		
575
		
625
		for (int i = 0; i < docs.length(); i++) {
576
		for (int i = 0; i < docs.length(); i++) {
626
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
577
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
627
			JSONObject doc = docs.getJSONObject(i);
578
			JSONObject doc = docs.getJSONObject(i);
628
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
579
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
Line 648... Line 599...
648
							fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
599
							fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
649
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
600
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
650
						}
601
						}
651
					} else {
602
					} else {
652
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
603
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
653
						SaholicCIS currentAvailability = itemAvailabilityMap.get(itemId);
604
						List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
654
						SaholicPOItem poItemAvailability = poItemAvailabilityMap.get(itemId); 
605
						List<SaholicPOItem> poItemAvailability = poItemAvailabilityMap.get(itemId); 
655
						String poColor = "grey";
606
						String poColor = "grey";
656
						boolean active = false;
607
						boolean active = false;
657
						if(currentAvailability != null && currentAvailability.getNetavailability() > 0) {
608
						if(currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability)) > 0) {
658
							poColor = "green";
609
								poColor = "green";
659
							modelColorClass = "green";
610
								modelColorClass = "green";
660
						} else if (poItemAvailability != null && poItemAvailability.getUnfulfilledQty() > 0) {
611
						} else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
661
							if(currentAvailability != null 
612
							if(currentAvailability != null 
-
 
613
							&& poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) 
662
							&& poItemAvailability.getUnfulfilledQty() + currentAvailability.getNetavailability() <= 0) {
614
								+ currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability))
-
 
615
							<= 0) {
663
								poColor = "grey";
616
								poColor = "grey";
664
							} else {
617
							} else {
665
								poColor = "yellow";
618
								poColor = "yellow";
666
								if(modelColorClass!="green") {
619
								if(modelColorClass!="green") {
667
									modelColorClass = poColor;
620
									modelColorClass = poColor;
Line 706... Line 659...
706
				List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values()
659
				List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values()
707
				.stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
660
				.stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
708
				ffdr.setItems(availabilityList);
661
				ffdr.setItems(availabilityList);
709
				dealResponse.add(ffdr);
662
				dealResponse.add(ffdr);
710
			}
663
			}
711
		}
-
 
712
		return dealResponse;
664
		}return dealResponse;
713
 
665
 
714
	}
666
	}
715
 
667
 
716
	private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
668
	private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
717
			boolean hotDeal) throws ProfitMandiBusinessException {
669
			boolean hotDeal) throws ProfitMandiBusinessException {