Subversion Repositories SmartDukaan

Rev

Rev 27030 | Rev 27032 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21339 kshitij.so 1
package com.spice.profitmandi.web.controller;
2
 
3
import java.util.ArrayList;
22336 amit.gupta 4
import java.util.Arrays;
27005 amit.gupta 5
import java.util.Comparator;
21339 kshitij.so 6
import java.util.HashMap;
23814 amit.gupta 7
import java.util.HashSet;
22952 amit.gupta 8
import java.util.Iterator;
21339 kshitij.so 9
import java.util.List;
10
import java.util.Map;
25875 amit.gupta 11
import java.util.Optional;
25959 amit.gupta 12
import java.util.Set;
25010 amit.gupta 13
import java.util.concurrent.atomic.AtomicInteger;
23814 amit.gupta 14
import java.util.stream.Collectors;
21339 kshitij.so 15
 
16
import javax.servlet.http.HttpServletRequest;
17
 
22319 amit.gupta 18
import org.apache.commons.lang3.StringUtils;
23532 amit.gupta 19
import org.apache.http.conn.HttpHostConnectException;
23786 amit.gupta 20
import org.apache.logging.log4j.LogManager;
21
import org.apache.logging.log4j.Logger;
22319 amit.gupta 22
import org.json.JSONArray;
23
import org.json.JSONObject;
22273 amit.gupta 24
import org.springframework.beans.factory.annotation.Autowired;
21339 kshitij.so 25
import org.springframework.beans.factory.annotation.Value;
26
import org.springframework.http.HttpStatus;
27
import org.springframework.http.MediaType;
28
import org.springframework.http.ResponseEntity;
29
import org.springframework.stereotype.Controller;
22286 amit.gupta 30
import org.springframework.transaction.annotation.Transactional;
21339 kshitij.so 31
import org.springframework.web.bind.annotation.PathVariable;
32
import org.springframework.web.bind.annotation.RequestMapping;
33
import org.springframework.web.bind.annotation.RequestMethod;
34
import org.springframework.web.bind.annotation.RequestParam;
35
 
36
import com.eclipsesource.json.Json;
37
import com.eclipsesource.json.JsonArray;
38
import com.eclipsesource.json.JsonObject;
39
import com.eclipsesource.json.JsonValue;
40
import com.google.gson.Gson;
21356 kshitij.so 41
import com.google.gson.reflect.TypeToken;
25010 amit.gupta 42
import com.mongodb.BasicDBObject;
24163 amit.gupta 43
import com.mongodb.DBObject;
21643 ashik.ali 44
import com.spice.profitmandi.common.enumuration.SchemeType;
21339 kshitij.so 45
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
46
import com.spice.profitmandi.common.model.ProfitMandiConstants;
22289 amit.gupta 47
import com.spice.profitmandi.common.model.UserInfo;
27030 amit.gupta 48
import com.spice.profitmandi.common.solr.SolrService;
21643 ashik.ali 49
import com.spice.profitmandi.common.web.client.RestClient;
22319 amit.gupta 50
import com.spice.profitmandi.common.web.util.ResponseSender;
25010 amit.gupta 51
import com.spice.profitmandi.dao.entity.catalog.Category;
23426 amit.gupta 52
import com.spice.profitmandi.dao.entity.catalog.Item;
23814 amit.gupta 53
import com.spice.profitmandi.dao.entity.catalog.TagListing;
26847 tejbeer 54
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
26846 tejbeer 55
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
27030 amit.gupta 56
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
22361 amit.gupta 57
import com.spice.profitmandi.dao.model.UserCart;
25010 amit.gupta 58
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
23426 amit.gupta 59
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
23814 amit.gupta 60
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
27030 amit.gupta 61
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
22333 amit.gupta 62
import com.spice.profitmandi.dao.repository.dtr.Mongo;
22361 amit.gupta 63
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
26889 amit.gupta 64
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
26846 tejbeer 65
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
26847 tejbeer 66
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
23798 amit.gupta 67
import com.spice.profitmandi.service.authentication.RoleManager;
25880 amit.gupta 68
import com.spice.profitmandi.service.inventory.AvailabilityInfo;
25882 amit.gupta 69
import com.spice.profitmandi.service.inventory.Bucket;
25880 amit.gupta 70
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
71
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
26924 amit.gupta 72
import com.spice.profitmandi.service.inventory.InventoryService;
25875 amit.gupta 73
import com.spice.profitmandi.service.inventory.ItemBucketService;
25879 amit.gupta 74
import com.spice.profitmandi.service.inventory.ItemQuantityPojo;
26889 amit.gupta 75
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
22287 amit.gupta 76
import com.spice.profitmandi.service.pricing.PricingService;
26695 amit.gupta 77
import com.spice.profitmandi.service.scheme.SchemeService;
21356 kshitij.so 78
import com.spice.profitmandi.web.res.DealBrands;
21339 kshitij.so 79
import com.spice.profitmandi.web.res.DealObjectResponse;
80
import com.spice.profitmandi.web.res.DealsResponse;
81
 
82
import io.swagger.annotations.ApiImplicitParam;
83
import io.swagger.annotations.ApiImplicitParams;
84
import io.swagger.annotations.ApiOperation;
85
 
86
@Controller
22319 amit.gupta 87
@Transactional(rollbackFor = Throwable.class)
21339 kshitij.so 88
public class DealsController {
89
 
23568 govind 90
	private static final Logger logger = LogManager.getLogger(DealsController.class);
21339 kshitij.so 91
 
92
	@Value("${python.api.host}")
93
	private String host;
23816 amit.gupta 94
 
26889 amit.gupta 95
	@Value("${new.solr.url}")
96
	private String solrUrl;
97
 
21339 kshitij.so 98
	@Value("${python.api.port}")
99
	private int port;
23816 amit.gupta 100
 
26889 amit.gupta 101
	@Autowired
102
	RestClient restClient;
27030 amit.gupta 103
 
104
	@Autowired
105
	SolrService solrService;
26889 amit.gupta 106
 
26924 amit.gupta 107
	@Autowired
108
	InventoryService inventoryService;
109
 
23816 amit.gupta 110
	// This is now unused as we are not supporting multiple companies.
23300 amit.gupta 111
	@Value("${gadgetCops.invoice.cc}")
23816 amit.gupta 112
	private String[] ccGadgetCopInvoiceTo;
22319 amit.gupta 113
 
114
	@Autowired
115
	private PricingService pricingService;
23816 amit.gupta 116
 
22273 amit.gupta 117
	@Autowired
26889 amit.gupta 118
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
119
 
120
	@Autowired
25010 amit.gupta 121
	private CategoryRepository categoryRepository;
122
 
123
	@Autowired
26695 amit.gupta 124
	private SchemeService schemeService;
125
 
126
	@Autowired
26889 amit.gupta 127
	private SaholicInventoryService saholicInventoryService;
128
 
129
	@Autowired
22333 amit.gupta 130
	private Mongo mongoClient;
25879 amit.gupta 131
 
25875 amit.gupta 132
	@Autowired
133
	private ItemBucketService itemBucketService;
23816 amit.gupta 134
 
22333 amit.gupta 135
	@Autowired
22361 amit.gupta 136
	private UserAccountRepository userAccountRepository;
27030 amit.gupta 137
 
138
	@Autowired
139
	private FofoStoreRepository fofoStoreRepository;
23816 amit.gupta 140
 
22989 amit.gupta 141
	@Autowired
22931 ashik.ali 142
	private ResponseSender<?> responseSender;
23816 amit.gupta 143
 
22554 amit.gupta 144
	@Autowired
23814 amit.gupta 145
	private TagListingRepository tagListingRepository;
23816 amit.gupta 146
 
23814 amit.gupta 147
	@Autowired
23426 amit.gupta 148
	private ItemRepository itemRepository;
23816 amit.gupta 149
 
23786 amit.gupta 150
	@Autowired
23798 amit.gupta 151
	private RoleManager roleManagerService;
23816 amit.gupta 152
 
27030 amit.gupta 153
 
26846 tejbeer 154
	@Autowired
155
	private SuggestedPoDetailRepository monthlyPoDetailRepository;
156
 
26847 tejbeer 157
	@Autowired
158
	private SuggestedPoRepository suggestedPoRepository;
159
 
22336 amit.gupta 160
	List<String> filterableParams = Arrays.asList("brand");
24949 amit.gupta 161
 
25876 amit.gupta 162
	@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
25879 amit.gupta 163
	public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
25875 amit.gupta 164
		logger.info("Request " + request.getParameterMap());
165
		return responseSender.ok(itemBucketService.getBuckets(Optional.of(true)));
166
	}
25879 amit.gupta 167
 
168
	@RequestMapping(value = "/fofo/bucket", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
25880 amit.gupta 169
	public ResponseEntity<?> getBucketDetails(HttpServletRequest request, @RequestParam int id)
25879 amit.gupta 170
			throws ProfitMandiBusinessException {
25880 amit.gupta 171
		List<ItemQuantityPojo> iqPojo = itemBucketService.getBucketDetails(id);
25968 amit.gupta 172
		Map<Integer, Integer> itemIdsQtyMap = iqPojo.stream()
173
				.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
174
		Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream()
175
				.map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
25879 amit.gupta 176
		RestClient rc = new RestClient();
177
		Map<String, String> params = new HashMap<>();
178
		List<String> mandatoryQ = new ArrayList<>();
25968 amit.gupta 179
		mandatoryQ.add(
180
				String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
25959 amit.gupta 181
		params.put("start", "0");
182
		params.put("rows", "100");
25879 amit.gupta 183
		params.put("q", StringUtils.join(mandatoryQ, " "));
184
		params.put("fl", "*, [child parentFilter=id:catalog*]");
185
 
186
		params.put("wt", "json");
187
		String response = null;
188
		try {
26889 amit.gupta 189
			response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
25879 amit.gupta 190
		} catch (HttpHostConnectException e) {
191
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
192
		}
193
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
194
		JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
25968 amit.gupta 195
		List<FofoCatalogResponse> dealResponse = getCatalogSingleSkuResponse(docs, itemIdsQtyMap, false);
26051 amit.gupta 196
 
26589 amit.gupta 197
		Bucket bucket = itemBucketService.getBuckets(Optional.of(true)).stream().filter(x -> x.getId() == id)
198
				.collect(Collectors.toList()).get(0);
25882 amit.gupta 199
		bucket.setFofoCatalogResponses(dealResponse);
200
		return responseSender.ok(bucket);
25879 amit.gupta 201
	}
202
 
26846 tejbeer 203
	@RequestMapping(value = "/fofo/suggestedPo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
204
	public ResponseEntity<?> getSuggestedPo(HttpServletRequest request, @RequestParam int id)
205
			throws ProfitMandiBusinessException {
206
 
207
		List<SuggestedPoDetail> mpd = monthlyPoDetailRepository.selectByPoId(id);
208
		Map<Integer, Integer> itemIdsQtyMap = mpd.stream()
209
				.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
210
 
211
		Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream()
212
				.map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
213
		RestClient rc = new RestClient();
214
		Map<String, String> params = new HashMap<>();
215
		List<String> mandatoryQ = new ArrayList<>();
216
		mandatoryQ.add(
217
				String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
218
		params.put("start", "0");
219
		params.put("rows", "100");
220
		params.put("q", StringUtils.join(mandatoryQ, " "));
221
		params.put("fl", "*, [child parentFilter=id:catalog*]");
222
 
223
		params.put("wt", "json");
224
		String response = null;
225
		try {
26889 amit.gupta 226
			response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
26846 tejbeer 227
		} catch (HttpHostConnectException e) {
228
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
229
		}
230
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
231
		JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
232
		List<FofoCatalogResponse> dealResponse = getCatalogSingleSkuResponse(docs, itemIdsQtyMap, false);
233
 
234
		return responseSender.ok(dealResponse);
235
	}
236
 
26847 tejbeer 237
	@RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
26848 tejbeer 238
	@ApiImplicitParams({
239
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
240
	@ApiOperation(value = "")
26847 tejbeer 241
	public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id)
242
			throws ProfitMandiBusinessException {
243
		SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
244
		suggestedPo.setStatus("closed");
245
 
246
		return responseSender.ok(true);
247
	}
248
 
23816 amit.gupta 249
	private String getCommaSeparateTags(int userId) {
22361 amit.gupta 250
		UserCart uc = userAccountRepository.getUserCart(userId);
251
		List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
22287 amit.gupta 252
		List<String> strTagIds = new ArrayList<>();
253
		for (Integer tagId : tagIds) {
254
			strTagIds.add(String.valueOf(tagId));
22273 amit.gupta 255
		}
22287 amit.gupta 256
		return String.join(",", strTagIds);
22273 amit.gupta 257
	}
258
 
22319 amit.gupta 259
	@ApiImplicitParams({
260
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
261
	@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
24091 tejbeer 262
	public ResponseEntity<?> getFofo(HttpServletRequest request,
26758 amit.gupta 263
			@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
22319 amit.gupta 264
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
23816 amit.gupta 265
			@RequestParam(value = "sort", required = false) String sort,
266
			@RequestParam(value = "brand", required = false) String brand,
25011 amit.gupta 267
			@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
24946 amit.gupta 268
			@RequestParam(value = "q", required = false) String queryTerm,
24091 tejbeer 269
			@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
22328 amit.gupta 270
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
22319 amit.gupta 271
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
27030 amit.gupta 272
		dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset,
273
				limit, sort, brand, subCategoryId, hotDeal), hotDeal, userInfo.getRetailerId());
26889 amit.gupta 274
		return responseSender.ok(dealResponse);
275
	}
25015 amit.gupta 276
 
27030 amit.gupta 277
	/*private JSONArray getSolrDocs(int fofoId, String queryTerm, String categoryId, String offset, String limit,
26889 amit.gupta 278
			String sort, String brand, int subCategoryId, boolean hotDeal) throws Throwable {
279
		List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(fofoId);
280
		List<String> parentFilter = new ArrayList<>();
281
		parentFilter.add("categoryId_i:" + categoryId);
25015 amit.gupta 282
 
26889 amit.gupta 283
		List<String> childFilter = new ArrayList<>();
284
		childFilter.add("itemId_i:*");
285
 
286
		Map<String, String> params = new HashMap<>();
287
		if (queryTerm == null || queryTerm.equals("null")) {
288
			queryTerm = "";
27030 amit.gupta 289
		} else {
290
			queryTerm = "(" + queryTerm + ")";
26589 amit.gupta 291
		}
26889 amit.gupta 292
		if (hotDeal) {
293
			childFilter.add("hot_deal_b:true");
294
		} else {
295
			childFilter.add("active_b:true");
296
		}
297
		if (subCategoryId != 0) {
298
			parentFilter.add("subCategoryId_i:" + subCategoryId);
299
		}
300
		if (StringUtils.isNotBlank(brand)) {
301
			parentFilter.add("brand_ss:" + brand);
302
		}
27017 amit.gupta 303
		if (queryTerm == "") {
304
			params.put("sort", "create_s desc");
305
		} else {
27020 amit.gupta 306
			parentFilter.addAll(Arrays.asList(queryTerm.split(" ")));
27017 amit.gupta 307
		}
26889 amit.gupta 308
		String parentFilterString = "\"" + String.join(" AND ", parentFilter) + "\"";
309
		String childFilterString = String.join(" AND ", childFilter);
310
		logger.info(parentFilterString);
27017 amit.gupta 311
		params.put("q", String.format("{!parent which=%s}%s", parentFilterString, childFilterString));
26897 amit.gupta 312
		params.put("fl",
27019 amit.gupta 313
				String.format("*, [child parentFilter=id:catalog* childFilter=%s]", "\"" + childFilterString + "\""));
26889 amit.gupta 314
		params.put("start", String.valueOf(offset));
315
		params.put("rows", String.valueOf(limit));
316
		params.put("wt", "json");
317
		String response = null;
318
		try {
319
			response = restClient.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
320
		} catch (HttpHostConnectException e) {
321
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
322
		}
323
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
324
		JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
325
		return docs;
27030 amit.gupta 326
	}*/
26589 amit.gupta 327
 
328
	@ApiImplicitParams({
329
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
330
	@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
331
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
26758 amit.gupta 332
			@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
26589 amit.gupta 333
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
334
			@RequestParam(value = "sort", required = false) String sort,
335
			@RequestParam(value = "brand", required = false) String brand,
336
			@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
337
			@RequestParam(value = "q", required = false) String queryTerm,
338
			@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
339
			throws Throwable {
340
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
341
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
342
		UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
27030 amit.gupta 343
		dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset, limit,
26889 amit.gupta 344
				sort, brand, subCategoryId, false), false, userInfo.getRetailerId());
22319 amit.gupta 345
		return responseSender.ok(dealResponse);
346
	}
22273 amit.gupta 347
 
22319 amit.gupta 348
	@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22272 amit.gupta 349
	@ApiImplicitParams({
22319 amit.gupta 350
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
22272 amit.gupta 351
	@ApiOperation(value = "Get online deals")
22319 amit.gupta 352
	public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
353
			@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
354
			@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
355
			@RequestParam(value = "direction", required = false) String direction,
356
			@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
357
		logger.info("Request " + request.getParameterMap());
22272 amit.gupta 358
		String response = null;
22319 amit.gupta 359
		int userId = (int) request.getAttribute("userId");
22289 amit.gupta 360
 
22319 amit.gupta 361
		String uri = "/deals/" + userId;
23532 amit.gupta 362
		RestClient rc = new RestClient();
22272 amit.gupta 363
		Map<String, String> params = new HashMap<>();
364
		params.put("offset", offset);
365
		params.put("limit", limit);
366
		params.put("categoryId", categoryId);
367
		params.put("direction", direction);
368
		params.put("sort", sort);
369
		params.put("source", "online");
370
		params.put("filterData", filterData);
23816 amit.gupta 371
		/*
372
		 * if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
373
		 * params.put("tag_ids", getCommaSeparateTags(userId)); }
374
		 */
22272 amit.gupta 375
		List<Object> responseObject = new ArrayList<>();
23532 amit.gupta 376
		try {
377
			response = rc.get(SchemeType.HTTP, host, port, uri, params);
378
		} catch (HttpHostConnectException e) {
379
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
380
		}
22931 ashik.ali 381
 
22272 amit.gupta 382
		JsonArray result_json = Json.parse(response).asArray();
22319 amit.gupta 383
		for (JsonValue j : result_json) {
23816 amit.gupta 384
			// logger.info("res " + j.asArray());
22272 amit.gupta 385
			List<Object> innerObject = new ArrayList<>();
22319 amit.gupta 386
			for (JsonValue jsonObject : j.asArray()) {
22272 amit.gupta 387
				innerObject.add(toDealObject(jsonObject.asObject()));
388
			}
22319 amit.gupta 389
			if (innerObject.size() > 0) {
22272 amit.gupta 390
				responseObject.add(innerObject);
391
			}
392
		}
23022 ashik.ali 393
		return responseSender.ok(responseObject);
22272 amit.gupta 394
	}
395
 
22319 amit.gupta 396
	private Object toDealObject(JsonObject jsonObject) {
397
		if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
21339 kshitij.so 398
			return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
399
		}
400
		return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
401
	}
22319 amit.gupta 402
 
403
	@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
21356 kshitij.so 404
	@ApiImplicitParams({
22319 amit.gupta 405
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
21356 kshitij.so 406
	@ApiOperation(value = "Get brand list and count for category")
22319 amit.gupta 407
	public ResponseEntity<?> getBrands(HttpServletRequest request,
23816 amit.gupta 408
			@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
22319 amit.gupta 409
		logger.info("Request " + request.getParameterMap());
21356 kshitij.so 410
		String response = null;
22319 amit.gupta 411
		// TODO: move to properties
21356 kshitij.so 412
		String uri = ProfitMandiConstants.URL_BRANDS;
23532 amit.gupta 413
		RestClient rc = new RestClient();
21356 kshitij.so 414
		Map<String, String> params = new HashMap<>();
415
		params.put("category_id", category_id);
21358 kshitij.so 416
		List<DealBrands> dealBrandsResponse = null;
23532 amit.gupta 417
		try {
418
			response = rc.get(SchemeType.HTTP, host, port, uri, params);
419
		} catch (HttpHostConnectException e) {
420
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
421
		}
23816 amit.gupta 422
 
22319 amit.gupta 423
		dealBrandsResponse = new Gson().fromJson(response, new TypeToken<List<DealBrands>>() {
424
		}.getType());
23022 ashik.ali 425
 
426
		return responseSender.ok(dealBrandsResponse);
21356 kshitij.so 427
	}
22319 amit.gupta 428
 
429
	@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
21445 kshitij.so 430
	@ApiImplicitParams({
22319 amit.gupta 431
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
21445 kshitij.so 432
	@ApiOperation(value = "Get unit deal object")
23816 amit.gupta 433
	public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
434
			throws ProfitMandiBusinessException {
21445 kshitij.so 435
		String response = null;
22319 amit.gupta 436
		// TODO: move to properties
437
		String uri = "getDealById/" + id;
438
		System.out.println("Unit deal " + uri);
23532 amit.gupta 439
		RestClient rc = new RestClient();
21445 kshitij.so 440
		Map<String, String> params = new HashMap<>();
441
		DealsResponse dealsResponse = null;
23532 amit.gupta 442
		try {
443
			response = rc.get(SchemeType.HTTP, host, port, uri, params);
444
		} catch (HttpHostConnectException e) {
445
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
446
		}
23816 amit.gupta 447
 
21445 kshitij.so 448
		JsonObject result_json = Json.parse(response).asObject();
22319 amit.gupta 449
		if (!result_json.isEmpty()) {
21445 kshitij.so 450
			dealsResponse = new Gson().fromJson(response, DealsResponse.class);
22952 amit.gupta 451
			Iterator<AvailabilityInfo> iter = dealsResponse.getAvailabilityInfo().iterator();
23816 amit.gupta 452
			while (iter.hasNext()) {
22952 amit.gupta 453
				AvailabilityInfo ai = iter.next();
23816 amit.gupta 454
				if (ai.getAvailability() <= 0)
22952 amit.gupta 455
					iter.remove();
456
			}
21445 kshitij.so 457
		}
22952 amit.gupta 458
		return responseSender.ok(dealsResponse);
21445 kshitij.so 459
	}
23816 amit.gupta 460
 
24091 tejbeer 461
	@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
462
	@ApiImplicitParams({
463
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
464
	@ApiOperation(value = "Get unit deal object")
465
	public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
27030 amit.gupta 466
			throws Exception {
24091 tejbeer 467
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
468
		List<Integer> tagIds = Arrays.asList(4);
469
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
470
		if (roleManagerService.isPartner(userInfo.getRoleIds())) {
471
			String categoryId = "(3 OR 6)";
472
			UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
473
			RestClient rc = new RestClient();
474
			Map<String, String> params = new HashMap<>();
475
			List<String> mandatoryQ = new ArrayList<>();
476
			String catalogString = "catalog" + id;
477
 
24149 amit.gupta 478
			mandatoryQ.add(String.format("+(categoryId_i:%s) +(id:%s) +{!parent which=\"id:%s\"} tagId_i:(%s)",
479
					categoryId, catalogString, catalogString, StringUtils.join(tagIds, " ")));
480
 
24091 tejbeer 481
			params.put("q", StringUtils.join(mandatoryQ, " "));
482
			params.put("fl", "*, [child parentFilter=id:catalog*]");
483
			params.put("sort", "rank_i asc, create_s desc");
484
			params.put("wt", "json");
485
			String response = null;
486
			try {
26575 amit.gupta 487
				response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
24091 tejbeer 488
			} catch (HttpHostConnectException e) {
489
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
490
			}
491
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
492
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
26889 amit.gupta 493
			dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
24091 tejbeer 494
		} else {
495
			return responseSender.badRequest(
496
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
497
		}
498
		return responseSender.ok(dealResponse.get(0));
499
	}
500
 
22333 amit.gupta 501
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
24949 amit.gupta 502
	public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
25010 amit.gupta 503
			@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
24163 amit.gupta 504
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
25543 amit.gupta 505
		logger.info("userInfo [{}]", userInfo);
25879 amit.gupta 506
		List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(),
507
				categoryId);
24163 amit.gupta 508
		return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
22333 amit.gupta 509
	}
25879 amit.gupta 510
 
25813 amit.gupta 511
	@RequestMapping(value = "/fofo/accessory/all-categories", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
512
	public ResponseEntity<?> getSubCategoriesToDisplay(HttpServletRequest request) throws Exception {
513
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
514
		logger.info("userInfo [{}]", userInfo);
26889 amit.gupta 515
		List<DBObject> subCategoriesDisplay = this.getSubCategoriesToDisplay();
516
		return new ResponseEntity<>(subCategoriesDisplay, HttpStatus.OK);
25813 amit.gupta 517
	}
23816 amit.gupta 518
 
25011 amit.gupta 519
	private List<DBObject> getSubCategoriesToDisplay() throws Exception {
25010 amit.gupta 520
		List<DBObject> subCategories = new ArrayList<>();
521
		RestClient rc = new RestClient();
522
		Map<String, String> params = new HashMap<>();
523
		params.put("q", "categoryId_i:6");
524
		params.put("group", "true");
525
		params.put("group.field", "subCategoryId_i");
526
		params.put("wt", "json");
25126 amit.gupta 527
		params.put("rows", "50");
25014 amit.gupta 528
		params.put("fl", "subCategoryId_i");
25010 amit.gupta 529
		String response = null;
530
		try {
26575 amit.gupta 531
			response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
25010 amit.gupta 532
		} catch (HttpHostConnectException e) {
533
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
534
		}
535
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("grouped");
536
		JSONArray groups = solrResponseJSONObj.getJSONObject("subCategoryId_i").getJSONArray("groups");
537
		List<Integer> categoryIds = new ArrayList<>();
25015 amit.gupta 538
		for (int i = 0; i < groups.length(); i++) {
539
			JSONObject groupObject = groups.getJSONObject(i);
540
			int subCategoryId = groupObject.getInt("groupValue");
25010 amit.gupta 541
			int quantity = groupObject.getJSONObject("doclist").getInt("numFound");
25013 amit.gupta 542
			categoryIds.add(subCategoryId);
25010 amit.gupta 543
		}
25015 amit.gupta 544
 
25010 amit.gupta 545
		List<Category> categories = categoryRepository.selectByIds(categoryIds);
25015 amit.gupta 546
		AtomicInteger i = new AtomicInteger(0);
547
		categories.forEach(x -> {
25011 amit.gupta 548
			DBObject dbObject = new BasicDBObject();
549
			dbObject.put("name", x.getLabel());
550
			dbObject.put("subCategoryId", x.getId());
551
			dbObject.put("rank", i.incrementAndGet());
552
			dbObject.put("categoryId", 6);
26441 tejbeer 553
			dbObject.put("url", "https://images.smartdukaan.com/uploads/campaigns/" + x.getId() + ".png");
25011 amit.gupta 554
			subCategories.add(dbObject);
25010 amit.gupta 555
		});
25015 amit.gupta 556
 
25011 amit.gupta 557
		return subCategories;
25015 amit.gupta 558
 
25010 amit.gupta 559
	}
560
 
22446 amit.gupta 561
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22448 amit.gupta 562
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
22447 amit.gupta 563
		return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
22446 amit.gupta 564
	}
23816 amit.gupta 565
 
23793 tejbeer 566
	@RequestMapping(value = "/deals/subCategories", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
567
	public ResponseEntity<?> getSubcategoriesToDisplay() {
568
		return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
569
	}
23816 amit.gupta 570
 
22406 amit.gupta 571
	@ApiImplicitParams({
23816 amit.gupta 572
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
22401 amit.gupta 573
	@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22931 ashik.ali 574
	public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
22401 amit.gupta 575
		StringBuffer sb = new StringBuffer("/getDealsForNotification/");
576
		String uri = sb.append(skus).toString();
23532 amit.gupta 577
		RestClient rc = new RestClient();
578
		String response;
579
		try {
580
			response = rc.get(SchemeType.HTTP, host, port, uri, new HashMap<>());
23816 amit.gupta 581
		} catch (HttpHostConnectException e) {
23532 amit.gupta 582
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
583
		}
22406 amit.gupta 584
		JsonArray result_json = Json.parse(response).asArray();
22407 amit.gupta 585
		List<Object> responseObject = new ArrayList<>();
586
		for (JsonValue j : result_json) {
23816 amit.gupta 587
			// logger.info("res " + j.asArray());
22407 amit.gupta 588
			List<Object> innerObject = new ArrayList<>();
589
			for (JsonValue jsonObject : j.asArray()) {
590
				innerObject.add(toDealObject(jsonObject.asObject()));
591
			}
592
			if (innerObject.size() > 0) {
593
				responseObject.add(innerObject);
594
			}
595
		}
22408 amit.gupta 596
		return responseSender.ok(responseObject);
22401 amit.gupta 597
	}
21339 kshitij.so 598
 
26889 amit.gupta 599
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
27030 amit.gupta 600
			throws Exception {
24091 tejbeer 601
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
602
		List<Integer> tagIds = Arrays.asList(4);
26924 amit.gupta 603
		List<Integer> itemIds = new ArrayList<>();
24091 tejbeer 604
		if (docs.length() > 0) {
605
			for (int i = 0; i < docs.length(); i++) {
606
				JSONObject doc = docs.getJSONObject(i);
26589 amit.gupta 607
				if (doc.has("_childDocuments_")) {
26515 amit.gupta 608
					for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
609
						JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
610
						int itemId = childItem.getInt("itemId_i");
26924 amit.gupta 611
						itemIds.add(itemId);
26515 amit.gupta 612
					}
24091 tejbeer 613
				}
614
			}
26924 amit.gupta 615
			if (itemIds.size() == 0) {
26573 amit.gupta 616
				return dealResponse;
617
			}
24091 tejbeer 618
		}
27030 amit.gupta 619
		//get warehouse Id
620
		int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
621
		Map<Integer, SaholicCIS> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId); 
26924 amit.gupta 622
 
24091 tejbeer 623
		for (int i = 0; i < docs.length(); i++) {
624
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
625
			JSONObject doc = docs.getJSONObject(i);
626
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
627
			ffdr.setCatalogId(doc.getInt("catalogId_i"));
628
			ffdr.setImageUrl(doc.getString("imageUrl_s"));
629
			ffdr.setTitle(doc.getString("title_s"));
24117 amit.gupta 630
			try {
631
				ffdr.setFeature(doc.getString("feature_s"));
24149 amit.gupta 632
			} catch (Exception e) {
24117 amit.gupta 633
				ffdr.setFeature(null);
24149 amit.gupta 634
				logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
24117 amit.gupta 635
			}
24091 tejbeer 636
			ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
26589 amit.gupta 637
			if (doc.has("_childDocuments_")) {
26515 amit.gupta 638
				for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
639
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
640
					int itemId = childItem.getInt("itemId_i");
641
					float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
642
					if (fofoAvailabilityInfoMap.containsKey(itemId)) {
643
						if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
644
							fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
645
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
646
						}
24091 tejbeer 647
					} else {
26515 amit.gupta 648
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
27030 amit.gupta 649
						SaholicCIS currentAvailability = itemAvailabilityMap.get(itemId);
27031 amit.gupta 650
						boolean active =false;
651
						if(currentAvailability != null && currentAvailability.getNetavailability() > 0) {
652
							active = true;
653
						}
26889 amit.gupta 654
						fdi.setSellingPrice(sellingPrice);
27031 amit.gupta 655
						fdi.setActive(active);
26889 amit.gupta 656
						fdi.setMrp(childItem.getDouble("mrp_f"));
26515 amit.gupta 657
						fdi.setMop((float) childItem.getDouble("mop_f"));
658
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
659
						fdi.setTagId(childItem.getInt("tagId_i"));
660
						fdi.setItem_id(itemId);
26696 amit.gupta 661
						Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
26846 tejbeer 662
						cashBack = cashBack == null ? 0 : cashBack;
26696 amit.gupta 663
						fdi.setCashback(cashBack);
26897 amit.gupta 664
						fdi.setMinBuyQuantity(1);
26889 amit.gupta 665
						if (hotDeal) {
27030 amit.gupta 666
							fdi.setAvailability(currentAvailability.getNetavailability());
667
						} else {
26889 amit.gupta 668
							fdi.setAvailability(100);
669
							Item item = itemRepository.selectById(itemId);
670
							// In case its tampered glass moq should be 5
671
							if (item.getCategoryId() == 10020) {
672
								fdi.setMinBuyQuantity(5);
26515 amit.gupta 673
							}
24091 tejbeer 674
						}
26515 amit.gupta 675
						fdi.setQuantityStep(1);
676
						fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
677
						fofoAvailabilityInfoMap.put(itemId, fdi);
24091 tejbeer 678
					}
679
				}
680
			}
681
			if (fofoAvailabilityInfoMap.values().size() > 0) {
27005 amit.gupta 682
				List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values()
27006 amit.gupta 683
				.stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
27005 amit.gupta 684
				ffdr.setItems(availabilityList);
24091 tejbeer 685
				dealResponse.add(ffdr);
686
			}
687
		}
688
		return dealResponse;
689
 
690
	}
691
 
25968 amit.gupta 692
	private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
693
			boolean hotDeal) throws ProfitMandiBusinessException {
25879 amit.gupta 694
		Map<Integer, TagListing> itemTagListingMap = null;
695
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
696
		List<Integer> tagIds = Arrays.asList(4);
26589 amit.gupta 697
 
25968 amit.gupta 698
		itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds))
699
				.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
25880 amit.gupta 700
 
25879 amit.gupta 701
		for (int i = 0; i < docs.length(); i++) {
702
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
703
			JSONObject doc = docs.getJSONObject(i);
25880 amit.gupta 704
 
25879 amit.gupta 705
			for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
706
				JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
707
				int itemId = childItem.getInt("itemId_i");
708
				TagListing tl = itemTagListingMap.get(itemId);
26589 amit.gupta 709
				if (tl == null) {
25968 amit.gupta 710
					continue;
711
				}
25879 amit.gupta 712
				if (hotDeal) {
713
					if (!tl.isHotDeals()) {
714
						continue;
715
					}
716
				}
717
				float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
718
				if (fofoAvailabilityInfoMap.containsKey(itemId)) {
719
					if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
720
						fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
721
						fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
722
					}
723
				} else {
724
					FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
725
					fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
726
					fdi.setMop((float) childItem.getDouble("mop_f"));
26665 amit.gupta 727
					fdi.setMop((float) tl.getMrp());
25879 amit.gupta 728
					fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
729
					fdi.setTagId(childItem.getInt("tagId_i"));
730
					fdi.setItem_id(itemId);
731
					Item item = itemRepository.selectById(itemId);
732
					// In case its tampered glass moq should be 5
733
					if (item.getCategoryId() == 10020) {
734
						fdi.setMinBuyQuantity(10);
735
					} else {
736
						fdi.setMinBuyQuantity(1);
737
					}
26050 amit.gupta 738
					fdi.setAvailability(itemFilter.get(itemId));
25879 amit.gupta 739
					fdi.setQuantityStep(1);
740
					fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
741
					fofoAvailabilityInfoMap.put(itemId, fdi);
742
				}
743
			}
744
			if (fofoAvailabilityInfoMap.values().size() > 0) {
25880 amit.gupta 745
				for (FofoAvailabilityInfo fofoAvailabilityInfo : fofoAvailabilityInfoMap.values()) {
25879 amit.gupta 746
					FofoCatalogResponse ffdr = new FofoCatalogResponse();
747
					ffdr.setCatalogId(doc.getInt("catalogId_i"));
748
					ffdr.setImageUrl(doc.getString("imageUrl_s"));
749
					ffdr.setTitle(doc.getString("title_s"));
750
					try {
751
						ffdr.setFeature(doc.getString("feature_s"));
752
					} catch (Exception e) {
753
						ffdr.setFeature(null);
754
						logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
755
					}
756
					ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
757
					ffdr.setItems(Arrays.asList(fofoAvailabilityInfo));
758
					dealResponse.add(ffdr);
759
				}
760
			}
761
		}
762
		return dealResponse;
25880 amit.gupta 763
 
25879 amit.gupta 764
	}
25967 amit.gupta 765
}