Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
22653 ashik.ali 1
package com.spice.profitmandi.service.scheme;
2
 
26403 amit.gupta 3
import java.text.MessageFormat;
25507 amit.gupta 4
import java.time.LocalDate;
22859 ashik.ali 5
import java.time.LocalDateTime;
23019 ashik.ali 6
import java.util.ArrayList;
22653 ashik.ali 7
import java.util.HashMap;
22859 ashik.ali 8
import java.util.HashSet;
22653 ashik.ali 9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
23968 amit.gupta 12
import java.util.stream.Collectors;
22653 ashik.ali 13
 
26332 amit.gupta 14
import javax.persistence.criteria.CriteriaBuilder;
15
import javax.persistence.criteria.CriteriaQuery;
16
import javax.persistence.criteria.Predicate;
17
import javax.persistence.criteria.Root;
18
 
23781 ashik.ali 19
import org.apache.logging.log4j.LogManager;
23568 govind 20
import org.apache.logging.log4j.Logger;
26332 amit.gupta 21
import org.hibernate.Session;
22
import org.hibernate.SessionFactory;
23
import org.hibernate.query.Query;
22653 ashik.ali 24
import org.springframework.beans.factory.annotation.Autowired;
23781 ashik.ali 25
import org.springframework.beans.factory.annotation.Qualifier;
22653 ashik.ali 26
import org.springframework.stereotype.Component;
27
 
24307 amit.gupta 28
import com.spice.profitmandi.common.enumuration.ItemType;
22653 ashik.ali 29
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
30
import com.spice.profitmandi.common.model.ProfitMandiConstants;
23019 ashik.ali 31
import com.spice.profitmandi.common.model.SchemeModel;
22859 ashik.ali 32
import com.spice.profitmandi.common.util.StringUtils;
23339 ashik.ali 33
import com.spice.profitmandi.dao.entity.catalog.Item;
22653 ashik.ali 34
import com.spice.profitmandi.dao.entity.catalog.RetailerScheme;
35
import com.spice.profitmandi.dao.entity.catalog.Scheme;
23365 ashik.ali 36
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
22653 ashik.ali 37
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
25503 amit.gupta 38
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
23339 ashik.ali 39
import com.spice.profitmandi.dao.entity.fofo.Purchase;
25043 amit.gupta 40
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
22859 ashik.ali 41
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
42
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
23527 ashik.ali 43
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
22653 ashik.ali 44
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
25111 amit.gupta 45
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
25503 amit.gupta 46
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
22859 ashik.ali 47
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
22653 ashik.ali 48
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
23995 amit.gupta 49
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
23968 amit.gupta 50
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
23019 ashik.ali 51
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
52
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
23365 ashik.ali 53
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
22653 ashik.ali 54
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
25503 amit.gupta 55
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
23339 ashik.ali 56
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
25043 amit.gupta 57
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
22859 ashik.ali 58
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
59
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
23798 amit.gupta 60
import com.spice.profitmandi.service.authentication.RoleManager;
22859 ashik.ali 61
import com.spice.profitmandi.service.wallet.WalletService;
22653 ashik.ali 62
 
22859 ashik.ali 63
import in.shop2020.model.v1.order.WalletReferenceType;
64
 
22653 ashik.ali 65
@Component
66
public class SchemeServiceImpl implements SchemeService {
67
 
23568 govind 68
	private static final Logger LOGGER = LogManager.getLogger(SchemeServiceImpl.class);
23444 amit.gupta 69
 
22653 ashik.ali 70
	@Autowired
23781 ashik.ali 71
	@Qualifier("fofoInventoryItemRepository")
22653 ashik.ali 72
	private InventoryItemRepository inventoryItemRepository;
23444 amit.gupta 73
 
22653 ashik.ali 74
	@Autowired
25503 amit.gupta 75
	private PartnerTypeChangeService partnerTypeChangeService;
76
 
77
	@Autowired
25043 amit.gupta 78
	private ScanRecordRepository scanRecordRepository;
23444 amit.gupta 79
 
22653 ashik.ali 80
	@Autowired
26332 amit.gupta 81
	private SessionFactory sessionFactory;
82
 
83
	@Autowired
22653 ashik.ali 84
	private SchemeRepository schemeRepository;
23444 amit.gupta 85
 
22653 ashik.ali 86
	@Autowired
23798 amit.gupta 87
	private RoleManager roleManager;
88
 
89
	@Autowired
22859 ashik.ali 90
	private RetailerRepository retailerRepository;
24562 amit.gupta 91
 
23995 amit.gupta 92
	@Autowired
93
	private TagListingRepository tagListingRepository;
23444 amit.gupta 94
 
22859 ashik.ali 95
	@Autowired
96
	private SchemeInOutRepository schemeInOutRepository;
23444 amit.gupta 97
 
22653 ashik.ali 98
	@Autowired
23781 ashik.ali 99
	@Qualifier("catalogItemRepository")
22859 ashik.ali 100
	private ItemRepository itemRepository;
23444 amit.gupta 101
 
22859 ashik.ali 102
	@Autowired
103
	private SchemeItemRepository schemeItemRepository;
23444 amit.gupta 104
 
22859 ashik.ali 105
	@Autowired
106
	private WalletService walletService;
23444 amit.gupta 107
 
23019 ashik.ali 108
	@Autowired
109
	private FofoOrderItemRepository fofoOrderItemRepository;
23444 amit.gupta 110
 
23019 ashik.ali 111
	@Autowired
112
	private FofoLineItemRepository fofoLineItemRepository;
23444 amit.gupta 113
 
23339 ashik.ali 114
	@Autowired
115
	private PurchaseRepository purchaseRepository;
23444 amit.gupta 116
 
23344 ashik.ali 117
	@Autowired
23365 ashik.ali 118
	private FofoOrderRepository fofoOrderRepository;
23796 amit.gupta 119
 
22653 ashik.ali 120
	@Override
22859 ashik.ali 121
	public void saveScheme(int creatorId, CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
23444 amit.gupta 122
 
23019 ashik.ali 123
		this.validateCreateSchemeRequest(createSchemeRequest);
23444 amit.gupta 124
 
22859 ashik.ali 125
		Scheme scheme = this.toScheme(creatorId, createSchemeRequest);
23444 amit.gupta 126
 
127
		if (scheme.getStartDateTime().isAfter(scheme.getEndDateTime())) {
128
			throw new ProfitMandiBusinessException(
129
					ProfitMandiConstants.START_DATE + ", " + ProfitMandiConstants.END_DATE,
130
					scheme.getStartDateTime() + ", " + scheme.getEndDateTime(), "SCHM_VE_1005");
22653 ashik.ali 131
		}
23444 amit.gupta 132
 
26332 amit.gupta 133
		// this.validateItemIds(createSchemeRequest);
22859 ashik.ali 134
		schemeRepository.persist(scheme);
23444 amit.gupta 135
		for (int itemId : createSchemeRequest.getItemIds()) {
22859 ashik.ali 136
			SchemeItem schemeItem = new SchemeItem();
137
			schemeItem.setSchemeId(scheme.getId());
138
			schemeItem.setItemId(itemId);
139
			schemeItemRepository.persist(schemeItem);
140
		}
23444 amit.gupta 141
 
22653 ashik.ali 142
	}
23444 amit.gupta 143
 
144
	private void validateCreateSchemeRequest(CreateSchemeRequest createSchemeRequest)
145
			throws ProfitMandiBusinessException {
146
		if (createSchemeRequest.getName() == null || createSchemeRequest.getName().isEmpty()) {
147
			throw new ProfitMandiBusinessException(ProfitMandiConstants.NAME, createSchemeRequest.getName(),
148
					"SCHM_VE_1000");
23019 ashik.ali 149
		}
23444 amit.gupta 150
		if (createSchemeRequest.getAmount() <= 0) {
151
			throw new ProfitMandiBusinessException(ProfitMandiConstants.AMOUNT, createSchemeRequest.getAmount(),
152
					"SCHM_VE_1001");
23019 ashik.ali 153
		}
23444 amit.gupta 154
 
25503 amit.gupta 155
		if (createSchemeRequest.getAmountType().equals(AmountType.PERCENTAGE)
23444 amit.gupta 156
				&& createSchemeRequest.getAmount() > 100) {
157
			throw new ProfitMandiBusinessException(ProfitMandiConstants.AMOUNT, createSchemeRequest.getAmount(),
158
					"SCHM_VE_1002");
23019 ashik.ali 159
		}
23444 amit.gupta 160
 
23886 amit.gupta 161
		if (createSchemeRequest.getStartDate() == null) {
23983 amit.gupta 162
			throw new ProfitMandiBusinessException(ProfitMandiConstants.START_DATE, createSchemeRequest.getStartDate(),
163
					"SCHM_VE_1003");
23019 ashik.ali 164
		}
23886 amit.gupta 165
		if (createSchemeRequest.getEndDate() == null) {
23983 amit.gupta 166
			throw new ProfitMandiBusinessException(ProfitMandiConstants.END_DATE, createSchemeRequest.getEndDate(),
167
					"SCHM_VE_1004");
23019 ashik.ali 168
		}
169
	}
23444 amit.gupta 170
 
171
	private Scheme toScheme(int creatorId, CreateSchemeRequest createSchemeRequest) {
22859 ashik.ali 172
		Scheme scheme = new Scheme();
173
		scheme.setName(createSchemeRequest.getName());
174
		scheme.setDescription(createSchemeRequest.getDescription());
25503 amit.gupta 175
		scheme.setType(createSchemeRequest.getType());
176
		scheme.setAmountType(createSchemeRequest.getAmountType());
22859 ashik.ali 177
		scheme.setAmount(createSchemeRequest.getAmount());
25503 amit.gupta 178
		scheme.setPartnerType(createSchemeRequest.getPartnerType());
25517 amit.gupta 179
		scheme.setStartDateTime(createSchemeRequest.getStartDate());
23886 amit.gupta 180
		scheme.setEndDateTime(createSchemeRequest.getEndDate());
22859 ashik.ali 181
		scheme.setCreatedBy(creatorId);
182
		return scheme;
183
	}
23444 amit.gupta 184
 
185
	private void validateItemIds(CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
186
		if (createSchemeRequest.getItemIds() == null || createSchemeRequest.getItemIds().isEmpty()) {
187
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getItemIds(),
188
					"SCHM_1003");
22859 ashik.ali 189
		}
23444 amit.gupta 190
		List<Integer> foundItemIds = itemRepository.selectIdsByIdsAndType(createSchemeRequest.getItemIds(),
191
				ItemType.SERIALIZED);
192
		if (foundItemIds.size() != createSchemeRequest.getItemIds().size()) {
22859 ashik.ali 193
			createSchemeRequest.getItemIds().removeAll(foundItemIds);
23444 amit.gupta 194
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getItemIds(),
195
					"SCHM_1004");
22859 ashik.ali 196
		}
197
	}
23444 amit.gupta 198
 
22859 ashik.ali 199
	@Override
200
	public Scheme getSchemeById(int schemeId) throws ProfitMandiBusinessException {
201
		Scheme scheme = schemeRepository.selectById(schemeId);
202
		List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
23914 govind 203
		if (itemIds.size() > 0) {
204
			List<Item> items = itemRepository.selectByIds(new HashSet<>(itemIds));
205
			scheme.setItemStringMap(this.toItemStringMap(items));
23983 amit.gupta 206
		}
22859 ashik.ali 207
		return scheme;
208
	}
23444 amit.gupta 209
 
210
	public Map<Integer, String> toItemStringMap(List<Item> items) {
23339 ashik.ali 211
		Map<Integer, String> itemMap = new HashMap<>();
23444 amit.gupta 212
		for (Item item : items) {
23339 ashik.ali 213
			itemMap.put(item.getId(), this.getItemString(item));
214
		}
215
		return itemMap;
216
	}
23444 amit.gupta 217
 
218
	public String getItemString(Item item) {
23339 ashik.ali 219
		StringBuilder itemString = new StringBuilder();
23444 amit.gupta 220
		if (item.getBrand() != null && !item.getBrand().isEmpty()) {
23339 ashik.ali 221
			itemString.append(item.getBrand().trim());
222
		}
223
		itemString.append(" ");
23444 amit.gupta 224
		if (item.getModelName() != null && !item.getModelName().isEmpty()) {
23339 ashik.ali 225
			itemString.append(item.getModelName().trim());
226
		}
227
		itemString.append(" ");
23444 amit.gupta 228
		if (item.getModelNumber() != null && !item.getModelNumber().isEmpty()) {
23339 ashik.ali 229
			itemString.append(item.getModelNumber().trim());
230
		}
231
		itemString.append(" ");
23444 amit.gupta 232
		if (item.getColor() != null && !item.getColor().isEmpty()) {
23339 ashik.ali 233
			itemString.append(item.getColor().trim());
234
		}
235
		return itemString.toString();
236
	}
23444 amit.gupta 237
 
238
	private Set<Integer> schemeItemsToItemIds(List<SchemeItem> schemeItems) {
23339 ashik.ali 239
		Set<Integer> itemIds = new HashSet<>();
23444 amit.gupta 240
		for (SchemeItem schemeItem : schemeItems) {
23339 ashik.ali 241
			itemIds.add(schemeItem.getItemId());
242
		}
243
		return itemIds;
244
	}
23444 amit.gupta 245
 
23019 ashik.ali 246
	@Override
247
	public List<SchemeModel> getAllSchemeModels(LocalDateTime startDateTime, LocalDateTime endDateTime) {
248
		List<Scheme> schemes = schemeRepository.selectAllBetweenCreateTimestamp(startDateTime, endDateTime);
249
		Map<Integer, Scheme> schemeIdSchemeMap = this.toSchemeIdSchemeMap(schemes);
250
		List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(schemeIdSchemeMap.keySet());
23339 ashik.ali 251
		Set<Integer> itemIds = this.schemeItemsToItemIds(schemeItems);
252
		List<Item> items = itemRepository.selectByIds(itemIds);
253
		Map<Integer, String> itemStringMap = this.toItemStringMap(items);
254
		this.addItemIdsToSchemes(schemeItems, schemeIdSchemeMap, itemStringMap);
23019 ashik.ali 255
		return this.toSchemeModels(schemeIdSchemeMap);
256
	}
23444 amit.gupta 257
 
258
	private void addItemIdsToSchemes(List<SchemeItem> schemeItems, Map<Integer, Scheme> schemeIdSchemeMap,
259
			Map<Integer, String> itemStringMap) {
260
		for (SchemeItem schemeItem : schemeItems) {
261
			schemeIdSchemeMap.get(schemeItem.getSchemeId()).getItemStringMap().put(schemeItem.getItemId(),
262
					itemStringMap.get(schemeItem.getItemId()));
23019 ashik.ali 263
		}
264
	}
23444 amit.gupta 265
 
266
	private void addRetailerIdsToSchemes(List<RetailerScheme> retailerSchemes, Map<Integer, Scheme> schemeIdSchemeMap) {
267
		for (RetailerScheme retailerScheme : retailerSchemes) {
268
			schemeIdSchemeMap.get(retailerScheme.getSchemeId()).getRetailerIds().add(retailerScheme.getRetailerId());
23019 ashik.ali 269
		}
270
	}
23444 amit.gupta 271
 
272
	private List<SchemeModel> toSchemeModels(Map<Integer, Scheme> schemeIdSchemeMap) {
23019 ashik.ali 273
		List<SchemeModel> schemeModels = new ArrayList<>();
23444 amit.gupta 274
		for (Map.Entry<Integer, Scheme> schemeIdSchemeEntry : schemeIdSchemeMap.entrySet()) {
23019 ashik.ali 275
			schemeModels.add(this.toSchemeModel(schemeIdSchemeEntry.getValue()));
276
		}
277
		return schemeModels;
278
	}
23444 amit.gupta 279
 
280
	private SchemeModel toSchemeModel(Scheme scheme) {
23019 ashik.ali 281
		SchemeModel schemeModel = new SchemeModel();
282
		schemeModel.setSchemeId(scheme.getId());
283
		schemeModel.setName(scheme.getName());
284
		schemeModel.setDescription(scheme.getDescription());
285
		schemeModel.setSchemeType(scheme.getType().toString());
286
		schemeModel.setAmountType(scheme.getAmountType().toString());
287
		schemeModel.setAmount(scheme.getAmount());
288
		schemeModel.setStartDateTime(StringUtils.toString(scheme.getStartDateTime()));
289
		schemeModel.setEndDateTime(StringUtils.toString(scheme.getEndDateTime()));
290
		schemeModel.setCreateTimestamp(StringUtils.toString(scheme.getCreateTimestamp()));
291
		schemeModel.setActiveTimestamp(StringUtils.toString(scheme.getActiveTimestamp()));
292
		schemeModel.setExpireTimestamp(StringUtils.toString(scheme.getExpireTimestamp()));
293
		schemeModel.setCreatedBy(scheme.getCreatedBy());
23339 ashik.ali 294
		schemeModel.setItemStringMap(scheme.getItemStringMap());
23019 ashik.ali 295
		schemeModel.setRetailerIds(scheme.getRetailerIds());
296
		return schemeModel;
297
	}
22653 ashik.ali 298
 
299
	@Override
300
	public void activeSchemeById(int schemeId) throws ProfitMandiBusinessException {
301
		Scheme scheme = schemeRepository.selectById(schemeId);
23444 amit.gupta 302
		if (scheme.getActiveTimestamp() != null) {
303
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
304
					"SCHM_1005");
22653 ashik.ali 305
		}
23444 amit.gupta 306
		if (scheme.getExpireTimestamp() != null) {
307
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
308
					"SCHM_1006");
22653 ashik.ali 309
		}
22859 ashik.ali 310
		scheme.setActiveTimestamp(LocalDateTime.now());
311
		schemeRepository.persist(scheme);
25438 amit.gupta 312
		/*
313
		 * if (scheme.getType() == SchemeType.IN) {
314
		 * this.processPreviousPurchases(scheme); } else if (scheme.getType() ==
315
		 * SchemeType.OUT) { this.processPreviousSales(scheme); }
316
		 */
22653 ashik.ali 317
	}
23444 amit.gupta 318
 
22653 ashik.ali 319
	@Override
25069 amit.gupta 320
	public void expireSchemeById(int schemeId, LocalDateTime expiryTime) throws ProfitMandiBusinessException {
22653 ashik.ali 321
		Scheme scheme = schemeRepository.selectById(schemeId);
25111 amit.gupta 322
		if (scheme == null || scheme.getActiveTimestamp() == null) {
23444 amit.gupta 323
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
324
					"SCHM_1007");
22653 ashik.ali 325
		}
23444 amit.gupta 326
		if (scheme.getExpireTimestamp() != null) {
327
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
328
					"SCHM_1008");
22653 ashik.ali 329
		}
22859 ashik.ali 330
		scheme.setExpireTimestamp(LocalDateTime.now());
25069 amit.gupta 331
		scheme.setEndDateTime(expiryTime);
22859 ashik.ali 332
		schemeRepository.persist(scheme);
22653 ashik.ali 333
	}
23444 amit.gupta 334
 
335
	private Map<Integer, Scheme> toSchemeIdSchemeMap(List<Scheme> schemes) {
23019 ashik.ali 336
		Map<Integer, Scheme> schemeIdSchemeMap = new HashMap<>();
23444 amit.gupta 337
		for (Scheme scheme : schemes) {
23019 ashik.ali 338
			schemeIdSchemeMap.put(scheme.getId(), scheme);
22859 ashik.ali 339
		}
23019 ashik.ali 340
		return schemeIdSchemeMap;
22859 ashik.ali 341
	}
23444 amit.gupta 342
 
343
	private Set<Integer> inventoryItemsToItemIds(List<InventoryItem> inventoryItems) {
22859 ashik.ali 344
		Set<Integer> itemIds = new HashSet<>();
23444 amit.gupta 345
		for (InventoryItem inventoryItem : inventoryItems) {
22859 ashik.ali 346
			itemIds.add(inventoryItem.getItemId());
347
		}
348
		return itemIds;
349
	}
23444 amit.gupta 350
 
351
	private Map<Integer, Set<Scheme>> toItemIdSchemesMap(List<SchemeItem> schemeItems, List<Scheme> schemes) {
23019 ashik.ali 352
		Map<Integer, Scheme> schemeIdSchemesMap = this.toSchemeIdSchemeMap(schemes);
22859 ashik.ali 353
		Map<Integer, Set<Scheme>> itemIdSchemesMap = new HashMap<>();
23444 amit.gupta 354
		for (SchemeItem schemeItem : schemeItems) {
355
			if (!itemIdSchemesMap.containsKey(schemeItem.getItemId())) {
22859 ashik.ali 356
				Set<Scheme> schemesSet = new HashSet<>();
357
				schemesSet.add(schemeIdSchemesMap.get(schemeItem.getSchemeId()));
358
				itemIdSchemesMap.put(schemeItem.getItemId(), schemesSet);
23444 amit.gupta 359
			} else {
22859 ashik.ali 360
				itemIdSchemesMap.get(schemeItem.getItemId()).add(schemeIdSchemesMap.get(schemeItem.getSchemeId()));
361
			}
362
		}
363
		return itemIdSchemesMap;
364
	}
22653 ashik.ali 365
 
23444 amit.gupta 366
	private Map<InventoryItem, Set<Scheme>> toInventoryItemSchemesMap(List<Scheme> schemes,
367
			List<InventoryItem> inventoryItems) {
22859 ashik.ali 368
		Set<Integer> schemeIds = new HashSet<>();
23444 amit.gupta 369
		for (Scheme scheme : schemes) {
22859 ashik.ali 370
			schemeIds.add(scheme.getId());
371
		}
372
		Set<Integer> itemIds = this.inventoryItemsToItemIds(inventoryItems);
373
		List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIdsAndItemIds(schemeIds, itemIds);
23444 amit.gupta 374
 
22859 ashik.ali 375
		Map<Integer, Set<Scheme>> itemIdSchemesMap = this.toItemIdSchemesMap(schemeItems, schemes);
376
		Map<InventoryItem, Set<Scheme>> inventoryItemSchemsMap = new HashMap<>();
23444 amit.gupta 377
		for (InventoryItem inventoryItem : inventoryItems) {
378
			if (itemIdSchemesMap.containsKey(inventoryItem.getItemId())) {
22859 ashik.ali 379
				inventoryItemSchemsMap.put(inventoryItem, itemIdSchemesMap.get(inventoryItem.getItemId()));
380
			}
381
		}
382
		return inventoryItemSchemsMap;
383
	}
23444 amit.gupta 384
 
22859 ashik.ali 385
	@Override
23365 ashik.ali 386
	public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
23369 ashik.ali 387
		LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
23344 ashik.ali 388
		Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
25503 amit.gupta 389
		PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId,
390
				purchase.getCreateTimestamp().toLocalDate());
23369 ashik.ali 391
		LOGGER.info("purchase is completed = {}", (purchase.getCompleteTimestamp() != null));
23444 amit.gupta 392
		if (purchase.getCompleteTimestamp() != null) {
25507 amit.gupta 393
			List<Scheme> schemes = schemeRepository.selectActiveAll(SchemeType.IN, partnerType,
394
					purchase.getCompleteTimestamp());
23365 ashik.ali 395
			float totalCashback = 0;
23444 amit.gupta 396
			if (schemes.isEmpty()) {
23365 ashik.ali 397
				return;
398
			}
399
			List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
26332 amit.gupta 400
 
401
			// Only consider inventory items that were not returned
26296 amit.gupta 402
			inventoryItems = inventoryItems.stream().filter(x -> !x.getLastScanType().equals(ScanType.PURCHASE_RET_BAD)
403
					&& !x.getLastScanType().equals(ScanType.PURCHASE_RET)).collect(Collectors.toList());
25487 amit.gupta 404
			LOGGER.info(inventoryItems);
25438 amit.gupta 405
			if (inventoryItems.size() == 0)
406
				return;
23444 amit.gupta 407
			Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap = this.toInventoryItemSchemesMap(schemes,
408
					inventoryItems);
409
 
410
			if (inventoryItemSchemesMap.isEmpty()) {
23365 ashik.ali 411
				return;
412
			}
413
			Map<InventoryItem, Set<Scheme>> allInventoryItemSchemesMap = new HashMap<>();
414
			Set<Integer> itemIds = new HashSet<>();
23444 amit.gupta 415
 
416
			for (Map.Entry<InventoryItem, Set<Scheme>> inventoryItemSchemesEntry : inventoryItemSchemesMap.entrySet()) {
23365 ashik.ali 417
				Set<Scheme> allSchemes = new HashSet<>();
23444 amit.gupta 418
				for (Scheme scheme : inventoryItemSchemesEntry.getValue()) {
25503 amit.gupta 419
					allSchemes.add(scheme);
22859 ashik.ali 420
				}
23365 ashik.ali 421
				allInventoryItemSchemesMap.put(inventoryItemSchemesEntry.getKey(), allSchemes);
422
				itemIds.add(inventoryItemSchemesEntry.getKey().getItemId());
22859 ashik.ali 423
			}
23444 amit.gupta 424
 
425
			int itemsCount = 0;
426
			for (Map.Entry<InventoryItem, Set<Scheme>> allInventoryItemSchemesEntry : allInventoryItemSchemesMap
427
					.entrySet()) {
428
				float inventoryItemCashback = 0;
429
				for (Scheme scheme : allInventoryItemSchemesEntry.getValue()) {
23365 ashik.ali 430
					InventoryItem inventoryItem = allInventoryItemSchemesEntry.getKey();
431
					float cashback = this.createSchemeInOut(scheme, inventoryItem);
23444 amit.gupta 432
					inventoryItemCashback += cashback;
23339 ashik.ali 433
				}
23444 amit.gupta 434
				if (inventoryItemCashback > 0) {
435
					totalCashback += inventoryItemCashback;
436
					itemsCount++;
437
				}
22859 ashik.ali 438
			}
23444 amit.gupta 439
 
23511 amit.gupta 440
			LOGGER.info("Items count for purchase id {} is {}", purchaseId, itemsCount);
23796 amit.gupta 441
			if (itemsCount > 0) {
23508 amit.gupta 442
				walletService.addAmountToWallet(retailerId, purchaseId, WalletReferenceType.SCHEME_IN,
23796 amit.gupta 443
						"Added for SCHEME IN against invoice " + purchase.getPurchaseReference() + " (total "
444
								+ itemsCount + " pcs)",
445
						totalCashback);
446
				LOGGER.info("Added Rs.{} for SCHEME IN against invoice {} total pcs({}) {}", totalCashback,
447
						purchase.getPurchaseReference(), itemsCount);
23508 amit.gupta 448
				purchase.setCashback(purchase.getCashback() + totalCashback);
449
				purchaseRepository.persist(purchase);
450
			}
22653 ashik.ali 451
		}
452
	}
23444 amit.gupta 453
 
454
	private float createSchemeInOut(Scheme scheme, InventoryItem inventoryItem) {
24562 amit.gupta 455
		List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByScheme(scheme.getId(), inventoryItem.getId());
23443 amit.gupta 456
		float amount = 0;
24581 amit.gupta 457
		if (schemeInOuts.stream().filter(x -> x.getRolledBackTimestamp() == null).collect(Collectors.toList())
24562 amit.gupta 458
				.size() == 0) {
459
			SchemeInOut schemeInOut = new SchemeInOut();
23443 amit.gupta 460
			amount = this.getAmount(inventoryItem, scheme);
461
			schemeInOut.setSchemeId(scheme.getId());
462
			schemeInOut.setInventoryItemId(inventoryItem.getId());
463
			schemeInOut.setAmount(amount);
464
			schemeInOutRepository.persist(schemeInOut);
465
		}
22859 ashik.ali 466
		return amount;
467
	}
23444 amit.gupta 468
 
25049 amit.gupta 469
	// We are maintaining price drop after grn
23444 amit.gupta 470
	private float getAmount(InventoryItem inventoryItem, Scheme scheme) {
22653 ashik.ali 471
		float amount = 0;
25049 amit.gupta 472
		float dpForCalc = 0;
473
		float taxableSellingPrice = 0;
22859 ashik.ali 474
		float totalTaxRate = inventoryItem.getIgstRate() + inventoryItem.getSgstRate() + inventoryItem.getCgstRate();
23527 ashik.ali 475
		if (scheme.getAmountType() == AmountType.PERCENTAGE) {
24562 amit.gupta 476
			if (scheme.getType().equals(SchemeType.IN)) {
25049 amit.gupta 477
				dpForCalc = inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount();
23995 amit.gupta 478
			} else {
479
				try {
25049 amit.gupta 480
					dpForCalc = tagListingRepository.selectByItemId(inventoryItem.getItemId()).getSellingPrice();
24562 amit.gupta 481
				} catch (Exception e) {
23995 amit.gupta 482
					LOGGER.info("Could not find tag Listing entry in {}", inventoryItem.getItemId());
483
					e.printStackTrace();
484
				}
485
			}
25049 amit.gupta 486
			taxableSellingPrice = dpForCalc / (1 + totalTaxRate / 100);
22859 ashik.ali 487
			amount = taxableSellingPrice * scheme.getAmount() / 100;
25517 amit.gupta 488
			System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t%f\t%f\t%f\t%f", inventoryItem.getId(),
25050 amit.gupta 489
					inventoryItem.getSerialNumber(), inventoryItem.getItemId(), scheme.getId(), scheme.getName(),
26332 amit.gupta 490
					scheme.getType(), scheme.getAmountType(), scheme.getPartnerType(), dpForCalc, taxableSellingPrice,
491
					scheme.getAmount(), amount));
23444 amit.gupta 492
		} else {
22653 ashik.ali 493
			amount = scheme.getAmount();
25517 amit.gupta 494
			System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t%f\t%f\t%d\t%f", inventoryItem.getId(),
25050 amit.gupta 495
					inventoryItem.getSerialNumber(), inventoryItem.getItemId(), scheme.getId(), scheme.getName(),
26332 amit.gupta 496
					scheme.getType(), scheme.getAmountType(), scheme.getPartnerType(), dpForCalc, taxableSellingPrice,
497
					0, amount));
22653 ashik.ali 498
		}
25049 amit.gupta 499
 
22859 ashik.ali 500
		return amount;
22653 ashik.ali 501
	}
23444 amit.gupta 502
 
22653 ashik.ali 503
	@Override
23365 ashik.ali 504
	public void processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {
505
		FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(retailerId, fofoOrderId);
23444 amit.gupta 506
 
25507 amit.gupta 507
		PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId,
508
				fofoOrder.getCreateTimestamp().toLocalDate());
509
 
25043 amit.gupta 510
		List<ScanRecord> scanRecords = scanRecordRepository.selectAllByOrderId(fofoOrderId);
511
		Set<Integer> inventoryItemIds = scanRecords.stream().map(x -> x.getInventoryItemId())
512
				.collect(Collectors.toSet());
513
		Set<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIds).stream()
514
				.filter(x -> x.getSerialNumber() != null && !x.getSerialNumber().equals(""))
515
				.collect(Collectors.toSet());
23444 amit.gupta 516
 
25043 amit.gupta 517
		if (inventoryItems.size() == 0) {
23365 ashik.ali 518
			return;
22859 ashik.ali 519
		}
23444 amit.gupta 520
 
25043 amit.gupta 521
		float totalCashback = 0;
522
		int count = 0;
23444 amit.gupta 523
 
25507 amit.gupta 524
		Set<Scheme> allFixedSchemes = schemeRepository
525
				.selectActiveAll(SchemeType.OUT, partnerType, fofoOrder.getCreateTimestamp()).stream()
526
				.filter(scheme -> scheme.getAmountType().equals(AmountType.FIXED)).collect(Collectors.toSet());
25050 amit.gupta 527
 
25043 amit.gupta 528
		for (InventoryItem inventoryItem : inventoryItems) {
25710 amit.gupta 529
			float itemCashback = 0;
25043 amit.gupta 530
			Purchase purchase = purchaseRepository.selectByIdAndFofoId(inventoryItem.getPurchaseId(), retailerId);
531
			Set<Integer> schemeIds = new HashSet<>(
532
					schemeItemRepository.selectSchemeIdByItemId(inventoryItem.getItemId()));
25507 amit.gupta 533
			List<Scheme> schemes = null;
26332 amit.gupta 534
			if (purchase.getCompleteTimestamp() == null) {
25579 amit.gupta 535
				continue;
536
			}
25507 amit.gupta 537
			if (purchase.getCompleteTimestamp().isAfter(LocalDate.of(2019, 9, 1).atStartOfDay())) {
538
				schemes = schemeRepository.selectActiveAll(SchemeType.OUT, partnerType, fofoOrder.getCreateTimestamp());
539
			} else {
540
				schemes = schemeRepository.selectActiveAll(SchemeType.OUT, partnerType,
541
						purchase.getCompleteTimestamp());
542
			}
543
			Set<Scheme> schemesSet = schemes.stream().filter(x -> x.getAmountType().equals(AmountType.PERCENTAGE))
544
					.collect(Collectors.toSet());
545
			schemesSet.addAll(allFixedSchemes);
546
			schemesSet = schemesSet.stream().filter(x -> schemeIds.contains(x.getId())).collect(Collectors.toSet());
547
			for (Scheme scheme : schemesSet) {
25043 amit.gupta 548
				itemCashback += this.createSchemeInOut(scheme, inventoryItem);
22653 ashik.ali 549
			}
25043 amit.gupta 550
			if (itemCashback > 0) {
551
				count++;
552
				totalCashback += itemCashback;
22859 ashik.ali 553
			}
22653 ashik.ali 554
		}
25043 amit.gupta 555
		if (count > 0) {
23444 amit.gupta 556
			walletService.addAmountToWallet(retailerId, fofoOrderId, WalletReferenceType.SCHEME_OUT,
23796 amit.gupta 557
					"Sales margin for invoice number " + fofoOrder.getInvoiceNumber() + ". Total " + count + " pc(s)",
558
					totalCashback);
23365 ashik.ali 559
			fofoOrder.setCashback(totalCashback);
560
			fofoOrderRepository.persist(fofoOrder);
22859 ashik.ali 561
		}
22653 ashik.ali 562
	}
23444 amit.gupta 563
 
23508 amit.gupta 564
	@Override
23796 amit.gupta 565
	public void rollbackSchemes(List<Integer> inventoryItemIds, int rollbackReference, String rollbackReason)
566
			throws Exception {
23638 amit.gupta 567
		Set<Integer> inventoryItemIdSet = new HashSet<>(inventoryItemIds);
23508 amit.gupta 568
		float amountToRollback = 0;
569
		List<SchemeInOut> schemes = schemeInOutRepository.selectByInventoryItemIds(inventoryItemIdSet);
23796 amit.gupta 570
		for (SchemeInOut schemeInOut : schemes) {
23983 amit.gupta 571
			if (schemeInOut.getRolledBackTimestamp() == null) {
572
				schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
573
				schemeInOutRepository.persist(schemeInOut);
574
				amountToRollback += schemeInOut.getAmount();
575
			}
23508 amit.gupta 576
		}
23983 amit.gupta 577
		if (amountToRollback > 0) {
23638 amit.gupta 578
			int inventoryItemId = inventoryItemIds.get(0);
579
			Integer fofoId = inventoryItemRepository.selectById(inventoryItemId).getFofoId();
23796 amit.gupta 580
			walletService.rollbackAmountFromWallet(fofoId, amountToRollback, rollbackReference,
581
					WalletReferenceType.SCHEME_IN, rollbackReason);
23638 amit.gupta 582
		}
23508 amit.gupta 583
	}
23884 amit.gupta 584
 
23781 ashik.ali 585
	@Override
23796 amit.gupta 586
	public Map<String, Object> getSchemes(Set<Integer> roleIds, int offset, int limit)
587
			throws ProfitMandiBusinessException {
23781 ashik.ali 588
		Map<String, Object> map = new HashMap<>();
589
		List<Scheme> schemes = null;
590
		long size = 0;
23798 amit.gupta 591
		if (roleManager.isAdmin(roleIds)) {
23781 ashik.ali 592
			schemes = schemeRepository.selectAll(offset, limit);
593
			size = schemeRepository.selectAllCount();
23796 amit.gupta 594
		} else {
23781 ashik.ali 595
			schemes = schemeRepository.selectActiveAll(offset, limit);
596
			size = schemeRepository.selectAllActiveCount();
597
		}
598
		map.put("schemes", schemes);
599
		map.put("start", offset + 1);
600
		map.put("size", size);
23796 amit.gupta 601
		if (schemes.size() < limit) {
23781 ashik.ali 602
			map.put("end", offset + schemes.size());
23796 amit.gupta 603
		} else {
23781 ashik.ali 604
			map.put("end", offset + limit);
605
		}
606
		return map;
607
	}
23796 amit.gupta 608
 
23781 ashik.ali 609
	@Override
23796 amit.gupta 610
	public List<Scheme> getPaginatedSchemes(Set<Integer> roleIds, int offset, int limit)
611
			throws ProfitMandiBusinessException {
23781 ashik.ali 612
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
613
		List<Scheme> schemes = null;
23798 amit.gupta 614
		if (roleManager.isAdmin(roleIds)) {
23781 ashik.ali 615
			schemes = schemeRepository.selectAll(offset, limit);
23796 amit.gupta 616
		} else {
23781 ashik.ali 617
			schemes = schemeRepository.selectActiveAll(offset, limit);
618
		}
619
		return schemes;
620
	}
23508 amit.gupta 621
 
23968 amit.gupta 622
	@Override
24976 amit.gupta 623
	public void reverseSchemes(List<InventoryItem> inventoryItems, int priceDropId, String reversalReason)
26332 amit.gupta 624
			throws ProfitMandiBusinessException {
24976 amit.gupta 625
		Map<Integer, List<InventoryItem>> purchaseInventoryListMap = inventoryItems.stream()
626
				.collect(Collectors.groupingBy(InventoryItem::getPurchaseId, Collectors.toList()));
627
 
628
		for (Map.Entry<Integer, List<InventoryItem>> purchaseEntry : purchaseInventoryListMap.entrySet()) {
629
			float amountToCredit = 0;
630
			float amountToDebit = 0;
631
			int purchaseId = purchaseEntry.getKey();
632
			List<InventoryItem> purchaseInventoryItemList = purchaseEntry.getValue();
633
 
634
			Map<Integer, InventoryItem> inventoryItemsMap = purchaseInventoryItemList.stream()
635
					.collect(Collectors.toMap(x -> x.getId(), x -> x));
636
 
637
			List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(inventoryItemsMap.keySet());
638
			List<Integer> schemeIds = schemeInOuts.stream().map(x -> x.getSchemeId()).collect(Collectors.toList());
639
			Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIds, 0, schemeIds.size())
640
					.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
641
			for (SchemeInOut schemeInOut : schemeInOuts) {
642
				InventoryItem ii = inventoryItemsMap.get(schemeInOut.getInventoryItemId());
643
				Scheme scheme = schemesMap.get(schemeInOut.getSchemeId());
644
				if (scheme.getType().equals(SchemeType.OUT))
645
					continue;
646
				if (scheme.getAmountType().equals(AmountType.FIXED)) {
647
					continue;
23995 amit.gupta 648
				}
24976 amit.gupta 649
				if (schemeInOut.getRolledBackTimestamp() == null) {
650
					float newAmount = getAmount(ii, scheme);
651
					if (schemeInOut.getAmount() - newAmount >= 0.01f) {
652
						schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
653
						schemeInOutRepository.persist(schemeInOut);
654
						SchemeInOut sioNew = new SchemeInOut();
655
						sioNew.setAmount(newAmount);
656
						sioNew.setInventoryItemId(schemeInOut.getInventoryItemId());
657
						sioNew.setSchemeId(schemeInOut.getSchemeId());
658
						schemeInOutRepository.persist(sioNew);
659
						amountToCredit += sioNew.getAmount();
660
						amountToDebit += schemeInOut.getAmount();
661
					}
24562 amit.gupta 662
 
24976 amit.gupta 663
				}
23986 amit.gupta 664
			}
24976 amit.gupta 665
			int fofoId = inventoryItems.get(0).getFofoId();
666
			if (amountToDebit > 0) {
26403 amit.gupta 667
				walletService.addAmountToWallet(fofoId, purchaseId, WalletReferenceType.SCHEME_IN, 
668
						MessageFormat.format(reversalReason, purchaseInventoryItemList.size()),
24976 amit.gupta 669
						-amountToDebit);
670
			}
671
			if (amountToCredit > 0) {
26403 amit.gupta 672
				walletService.addAmountToWallet(fofoId, purchaseId, WalletReferenceType.SCHEME_IN,
673
						MessageFormat.format(reversalReason, purchaseInventoryItemList.size()),
24976 amit.gupta 674
						amountToCredit);
675
			}
23968 amit.gupta 676
		}
677
	}
24562 amit.gupta 678
 
24264 amit.gupta 679
	@Override
24562 amit.gupta 680
	public void reverseSchemes(List<InventoryItem> inventoryItems, int reversalReference, String reversalReason,
681
			SchemeType schemeType) throws ProfitMandiBusinessException {
24264 amit.gupta 682
		Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
683
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
684
		List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(inventoryItemsMap.keySet());
685
		List<Integer> schemeIds = schemeInOuts.stream().map(x -> x.getSchemeId()).collect(Collectors.toList());
686
		float amount = 0;
687
		Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIds, 0, schemeIds.size()).stream()
688
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
689
		for (SchemeInOut schemeInOut : schemeInOuts) {
690
			Scheme scheme = schemesMap.get(schemeInOut.getSchemeId());
24562 amit.gupta 691
			if (scheme.getType().equals(schemeType)) {
692
				if (schemeInOut.getRolledBackTimestamp() == null) {
24264 amit.gupta 693
					schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
694
					schemeInOutRepository.persist(schemeInOut);
695
					amount += schemeInOut.getAmount();
696
				}
697
			}
698
		}
699
		int fofoId = inventoryItems.get(0).getFofoId();
24562 amit.gupta 700
		WalletReferenceType walletReferenceType = schemeType.equals(SchemeType.OUT) ? WalletReferenceType.SCHEME_OUT
701
				: WalletReferenceType.SCHEME_IN;
702
		if (amount > 0) {
703
			walletService.rollbackAmountFromWallet(fofoId, amount, reversalReference, walletReferenceType,
704
					reversalReason);
24268 amit.gupta 705
		}
24264 amit.gupta 706
	}
23968 amit.gupta 707
 
26332 amit.gupta 708
	@Override
709
	public double getTotalMargin(int itemId, PartnerType partnerType, LocalDateTime dateTime) {
710
		Session session = sessionFactory.getCurrentSession();
711
		CriteriaBuilder cb = session.getCriteriaBuilder();
712
		CriteriaQuery<Double> criteriaQuery = cb.createQuery(Double.class);
713
		Root<SchemeItem> schemeItem = criteriaQuery.from(SchemeItem.class);
714
		Root<Scheme> scheme = criteriaQuery.from(Scheme.class);
715
		Predicate schemePredicate = cb.equal(scheme.get(ProfitMandiConstants.AMOUNT_TYPE), AmountType.PERCENTAGE);
716
		Predicate lessThanPredicate = cb.lessThanOrEqualTo(scheme.get(ProfitMandiConstants.END_DATE_TIME), dateTime);
717
		Predicate greaterThanPredicate = cb.greaterThanOrEqualTo(scheme.get(ProfitMandiConstants.START_DATE_TIME),
718
				dateTime);
719
		Predicate joinPredicate = cb.equal(scheme.get("id"), schemeItem.get("schemeId"));
720
		Predicate schemeItemPredicate = cb.equal(schemeItem.get(ProfitMandiConstants.ITEM_ID), itemId);
721
		criteriaQuery.select(cb.sum(scheme.get(ProfitMandiConstants.AMOUNT))).where(schemePredicate, lessThanPredicate,
722
				greaterThanPredicate, schemeItemPredicate, joinPredicate);
723
 
724
		Query<Double> query = session.createQuery(criteriaQuery);
725
		return query.getSingleResult() + ProfitMandiConstants.SCHEME_INVESTMENT_MARGIN;
726
 
727
	}
728
 
24976 amit.gupta 729
	/*
730
	 * @Override public void updateSchmesForModel(int catalogId) throws
731
	 * ProfitMandiBusinessException { List<Item> items =
732
	 * itemRepository.selectAllByCatalogItemId(catalogId); Map<Integer, Scheme>
733
	 * schemes = schemeRepository .selectAllByItemIds(items.stream().map(x ->
734
	 * x.getId()).collect(Collectors.toList()));
735
	 * 
736
	 * }
737
	 */
24562 amit.gupta 738
 
22653 ashik.ali 739
}