Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
23819 govind 1
package com.spice.profitmandi.web.controller;
2
 
23968 amit.gupta 3
import java.text.MessageFormat;
23819 govind 4
import java.time.LocalDateTime;
5
import java.util.ArrayList;
23884 amit.gupta 6
import java.util.Arrays;
23819 govind 7
import java.util.HashMap;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.stream.Collectors;
11
 
12
import javax.servlet.http.HttpServletRequest;
13
import javax.transaction.Transactional;
14
 
23951 amit.gupta 15
import org.apache.commons.io.output.ByteArrayOutputStream;
16
import org.apache.commons.lang.StringUtils;
23945 amit.gupta 17
import org.apache.http.HttpResponse;
23819 govind 18
import org.apache.logging.log4j.LogManager;
19
import org.apache.logging.log4j.Logger;
23884 amit.gupta 20
import org.json.JSONArray;
23819 govind 21
import org.springframework.beans.factory.annotation.Autowired;
22
import org.springframework.beans.factory.annotation.Qualifier;
23951 amit.gupta 23
import org.springframework.core.io.ByteArrayResource;
24
import org.springframework.http.HttpHeaders;
23819 govind 25
import org.springframework.http.HttpStatus;
26
import org.springframework.http.ResponseEntity;
27
import org.springframework.stereotype.Controller;
28
import org.springframework.ui.Model;
29
import org.springframework.web.bind.annotation.PathVariable;
23884 amit.gupta 30
import org.springframework.web.bind.annotation.RequestBody;
23819 govind 31
import org.springframework.web.bind.annotation.RequestMapping;
32
import org.springframework.web.bind.annotation.RequestMethod;
23951 amit.gupta 33
import org.springframework.web.bind.annotation.RequestParam;
23819 govind 34
 
23951 amit.gupta 35
import com.fasterxml.jackson.databind.JavaType;
23945 amit.gupta 36
import com.fasterxml.jackson.databind.ObjectMapper;
37
import com.fasterxml.jackson.databind.ObjectReader;
38
import com.spice.profitmandi.common.enumuration.ReporticoProject;
23819 govind 39
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
23945 amit.gupta 40
import com.spice.profitmandi.common.model.ClosingStockOnDate;
41
import com.spice.profitmandi.common.model.GrnPendingDataModel;
23951 amit.gupta 42
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
23884 amit.gupta 43
import com.spice.profitmandi.common.model.ItemDescriptionModel;
23945 amit.gupta 44
import com.spice.profitmandi.common.model.PartnerImeiNotSold;
23884 amit.gupta 45
import com.spice.profitmandi.common.model.PriceDropModel;
23968 amit.gupta 46
import com.spice.profitmandi.common.model.PriceDropProcessModel;
23945 amit.gupta 47
import com.spice.profitmandi.common.model.ReporticoResponseModel;
48
import com.spice.profitmandi.common.services.ReporticoService;
23951 amit.gupta 49
import com.spice.profitmandi.common.util.FileUtil;
23945 amit.gupta 50
import com.spice.profitmandi.common.util.FormattingUtils;
23819 govind 51
import com.spice.profitmandi.dao.entity.catalog.Item;
23884 amit.gupta 52
import com.spice.profitmandi.dao.entity.catalog.TagListing;
23968 amit.gupta 53
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
23884 amit.gupta 54
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
23983 amit.gupta 55
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
23819 govind 56
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
57
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
23884 amit.gupta 58
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
23986 amit.gupta 59
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
60
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
23884 amit.gupta 61
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
23983 amit.gupta 62
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
23819 govind 63
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
64
import com.spice.profitmandi.service.inventory.InventoryService;
23983 amit.gupta 65
import com.spice.profitmandi.service.pricing.PriceDropService;
23968 amit.gupta 66
import com.spice.profitmandi.service.scheme.SchemeService;
23884 amit.gupta 67
import com.spice.profitmandi.service.transaction.TransactionService;
23819 govind 68
import com.spice.profitmandi.service.wallet.WalletService;
69
import com.spice.profitmandi.web.util.MVCResponseSender;
70
 
23968 amit.gupta 71
import in.shop2020.model.v1.order.WalletReferenceType;
72
 
23819 govind 73
@Controller
74
@Transactional
75
public class PriceDropController {
76
 
77
	private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
78
 
79
	@Autowired
80
	private PriceDropRepository priceDropRepository;
81
 
23951 amit.gupta 82
	@Autowired
83
	private ObjectMapper objectMapper;
23945 amit.gupta 84
 
23819 govind 85
	@Autowired
23884 amit.gupta 86
	private VendorItemPricingRepository vendorItemPricingRepository;
23819 govind 87
 
88
	@Autowired
23884 amit.gupta 89
	@Qualifier("fofoInventoryService")
90
	private InventoryService inventoryService;
23945 amit.gupta 91
 
23884 amit.gupta 92
	@Autowired
23819 govind 93
	private MVCResponseSender mvcResponseSender;
94
 
95
	@Autowired
23983 amit.gupta 96
	private PriceDropService priceDropService;
97
 
98
	@Autowired
23986 amit.gupta 99
	private InventoryItemRepository inventoryItemRepository;
100
 
101
	@Autowired
23819 govind 102
	private WalletService walletService;
103
 
104
	@Autowired
23884 amit.gupta 105
	private TagListingRepository tagListingRepository;
23945 amit.gupta 106
 
23884 amit.gupta 107
	@Autowired
108
	private TransactionService transactionService;
23819 govind 109
 
110
	@Autowired
111
	@Qualifier("catalogItemRepository")
112
	private ItemRepository itemRepository;
113
 
23945 amit.gupta 114
	@Autowired
23968 amit.gupta 115
	private SchemeService schemeService;
23986 amit.gupta 116
 
117
	@Autowired
118
	private SchemeInOutRepository schemeInOutRepository;
23968 amit.gupta 119
 
120
	@Autowired
23945 amit.gupta 121
	ReporticoService reporticoService;
23983 amit.gupta 122
 
123
	@Autowired
124
	LineItemImeisRepository lineItemImeisRepository;
23945 amit.gupta 125
 
23819 govind 126
	@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
23945 amit.gupta 127
	public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
23819 govind 128
 
23884 amit.gupta 129
		List<TagListing> tagListings = tagListingRepository.selectAll(false);
130
		Map<Integer, TagListing> tagListingMap = new HashMap<>();
131
		List<ItemDescriptionModel> customItems = new ArrayList<>();
23968 amit.gupta 132
		Map<Integer, String> catalogDescription = new HashMap<>();
23945 amit.gupta 133
		for (TagListing tagListing : tagListings) {
23968 amit.gupta 134
			Item item = itemRepository.selectById(tagListing.getItemId());
135
			tagListing.setItemDescription(item.getItemDescription());
23884 amit.gupta 136
			tagListingMap.put(tagListing.getItemId(), tagListing);
137
			ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
138
			itemDescriptionModel.setItemId(tagListing.getItemId());
23945 amit.gupta 139
			itemDescriptionModel
140
					.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
141
			customItems.add(itemDescriptionModel);
23968 amit.gupta 142
			catalogDescription.put(item.getCatalogItemId(), item.getItemDescriptionNoColor());
23884 amit.gupta 143
		}
23945 amit.gupta 144
 
23819 govind 145
		List<PriceDrop> priceDrops = priceDropRepository.selectAll();
23884 amit.gupta 146
		model.addAttribute("tagListingMap", tagListingMap);
147
		model.addAttribute("customItems", new JSONArray(customItems).toString());
23819 govind 148
		model.addAttribute("priceDrops", priceDrops);
23968 amit.gupta 149
		model.addAttribute("catalogDescription", catalogDescription);
23819 govind 150
		return "price-drop";
151
 
152
	}
23986 amit.gupta 153
 
154
	/*@RequestMapping(value = "/price-drop/imes1/download")
155
	public ResponseEntity<ByteArrayResource> downloadPriceDropImeis1(HttpServletRequest request,
156
			@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
157
		Item item = itemRepository.selectById(itemId);
158
		List<ImeiDropSummaryModel> imeiDropSummaryModelList = this.getAllSerialNumbersByAffectedDate(affectedDate, item.getCatalogItemId());
159
		List<String> imeis = imeiDropSummaryModelList.stream().map(x->x.getSerialNumber()).collect(Collectors.toList());
160
		Map<String, ImeiDropSummaryModel> imeisDropMap = imeiDropSummaryModelList.stream().collect(Collectors.toMap(ImeiDropSummaryModel::getSerialNumber, x->x));
161
		List<InventoryItem> inventoryItems = inventoryItemRepository.selectBySerialNumbers(new HashSet<>(imeis));
162
		List<Integer> inventoryItemIds = inventoryItems.stream().map(InventoryItem::getId).collect(Collectors.toList());
163
 
164
		List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(inventoryItemIds));
165
 
166
		Set<ItemQuantity> itemSchemes = new HashSet<>();
167
		Map<ItemQuantity, SchemeInOut> itemSchemeInOutMap = new HashMap<>(); 
168
		for(SchemeInOut schemeInOut : schemeInOuts) {
169
		}
170
		List<List<Object>> rows = new ArrayList<>();
171
		for (ImeiDropSummaryModel imeiDropSummaryModel : imeiDropSummaryModelList) {
172
			List<Object> row = this.getRow(imeiDropSummaryModel);
173
 
174
			rows.add(this.getRow(imeiDropSummaryModel));
175
		}
176
 
177
		FileUtil.getCSVByteStream(Arrays.asList("IMEI Number", "Store Name", "Store Code", "Item ID", "Brand",
178
				"Model Name", "Model Number", "Color", "Last Scanned"), 
179
				rows);
180
		final HttpHeaders headers = new HttpHeaders();
181
		headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
182
		headers.set("Content-disposition", "inline; filename=imei-" + item.getItemDescriptionNoColor() + ".csv");
183
		return new ResponseEntity<ByteArrayResource>(null, headers, HttpStatus.OK);
184
 
185
	}*/
23951 amit.gupta 186
	@RequestMapping(value = "/price-drop/imes/download")
187
	public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
188
			@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
189
		Item item = itemRepository.selectById(itemId);
23968 amit.gupta 190
		ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate, item.getCatalogItemId());
23951 amit.gupta 191
		final HttpHeaders headers = new HttpHeaders();
192
		headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
193
		headers.set("Content-disposition", "inline; filename=imei-" + item.getItemDescriptionNoColor() + ".csv");
194
		byte[] byteArray = baos.toByteArray();
195
		headers.setContentLength(byteArray.length);
196
		return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
197
	}
198
 
23968 amit.gupta 199
	@RequestMapping(value = "/processPriceDrop", method = RequestMethod.POST)
200
	public String processPriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcess,
201
			Model model) throws Exception {
202
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcess.getPriceDropId());
203
		boolean response = false;
204
		if (priceDrop.getProcessTimestamp() == null) {
205
			priceDrop.setPartnerPayout(priceDropProcess.getPartnerPayout());
206
			priceDrop.setPriceDropIn(priceDropProcess.getPriceDropIn());
207
			priceDrop.setProcessTimestamp(LocalDateTime.now());
208
			priceDropRepository.persist(priceDrop);
23983 amit.gupta 209
			String description = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId()).get(0)
210
					.getItemDescriptionNoColor();
211
			List<ImeiDropSummaryModel> imeiDropSummaryModels = this.getAllSerialNumbersByAffectedDate(priceDrop.getAffectedOn(),
23968 amit.gupta 212
					priceDrop.getCatalogItemId());
23983 amit.gupta 213
 
214
 
215
			if (imeiDropSummaryModels.size() > 0) {
216
				List<String> serialNumbers = imeiDropSummaryModels.stream().map(x->x.getSerialNumber()).collect(Collectors.toList());
217
				List<LineItemImei> lineItemImeis = lineItemImeisRepository.selectByIMEI(serialNumbers);
218
				Map<Integer, List<InventoryItem>> pendingPartnerInventoryMap = priceDropService.getInventoryForPriceDrop(lineItemImeis, priceDrop).
219
						stream().collect(Collectors.groupingBy(InventoryItem::getFofoId));
23819 govind 220
 
23983 amit.gupta 221
				for (Map.Entry<Integer, List<InventoryItem>> pendingPartnerInventory : pendingPartnerInventoryMap.entrySet()) {
222
					List<InventoryItem> fofoInventoryList = pendingPartnerInventory.getValue();
223
					int fofoId = pendingPartnerInventory.getKey();
224
 
23968 amit.gupta 225
					String reversalReason = MessageFormat.format(
23983 amit.gupta 226
							"Scheme  differential for Price Drop of Rs.{0} on {1}, on {3}. Total {2} item(s)",
227
							priceDrop.getAmount(), description, fofoInventoryList.size(),
23968 amit.gupta 228
							FormattingUtils.formatDate(priceDrop.getAffectedOn()));
229
					String aReason = MessageFormat.format(
23983 amit.gupta 230
							"Payout of Rs.{4} per unit for Price Drop of Rs.{0} on {1}, on {3}. Total {2} item(s)",
231
							priceDrop.getAmount(), description, fofoInventoryList.size(),
23968 amit.gupta 232
							FormattingUtils.formatDate(priceDrop.getAffectedOn()), priceDropProcess.getPartnerPayout());
23983 amit.gupta 233
					inventoryService.updatePriceDrop(fofoInventoryList, priceDrop.getAmount());
234
					schemeService.reverseSchemes(fofoInventoryList, priceDropProcess.getPriceDropId(), reversalReason);
235
					walletService.addAmountToWallet(fofoId, priceDrop.getId(), WalletReferenceType.PRICE_DROP, aReason,
23995 amit.gupta 236
							priceDrop.getPartnerPayout() * fofoInventoryList.size());
23819 govind 237
				}
238
 
239
			}
23968 amit.gupta 240
			response = true;
23819 govind 241
		}
23968 amit.gupta 242
		model.addAttribute("response", mvcResponseSender.createResponseString(response));
243
		return "response";
23819 govind 244
	}
245
 
23884 amit.gupta 246
	@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
23945 amit.gupta 247
	public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
248
			throws Exception {
23884 amit.gupta 249
		boolean response = false;
23968 amit.gupta 250
		priceDropModel.setAllColors(true);
23945 amit.gupta 251
		if (this.validatePriceDrop(priceDropModel)) {
23884 amit.gupta 252
			TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
253
			float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
23945 amit.gupta 254
			if (newDp > 0) {
23884 amit.gupta 255
				List<Item> allItems = null;
256
				Item currentItem = itemRepository.selectById(priceDropModel.getItemId());
23945 amit.gupta 257
				if (priceDropModel.isAllColors()) {
23884 amit.gupta 258
					allItems = itemRepository.selectAllByCatalogItemId(currentItem.getCatalogItemId());
23945 amit.gupta 259
 
23884 amit.gupta 260
				} else {
23945 amit.gupta 261
					allItems = Arrays.asList(currentItem);
23884 amit.gupta 262
				}
23945 amit.gupta 263
				for (Item item : allItems) {
23884 amit.gupta 264
					TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
23945 amit.gupta 265
					if (itemTagListing == null)
266
						continue;
23884 amit.gupta 267
					itemTagListing.setSellingPrice(newDp);
268
					itemTagListing.setMop(priceDropModel.getMop());
269
					tagListingRepository.persist(tagListing);
270
					List<VendorItemPricing> vipList = vendorItemPricingRepository.selectAll(item.getId());
23945 amit.gupta 271
					for (VendorItemPricing vip : vipList) {
23884 amit.gupta 272
						vip.setDp(newDp);
273
						vip.setMop(priceDropModel.getMop());
274
						vip.setNlc(priceDropModel.getNlc());
275
						vip.setTp(priceDropModel.getTp());
276
						vendorItemPricingRepository.persist(vip);
277
					}
278
					transactionService.updatePriceDrop(item.getId(), newDp);
279
				}
23951 amit.gupta 280
				PriceDrop priceDrop = new PriceDrop();
281
				priceDrop.setAffectedOn(priceDropModel.getAffectedDate());
23968 amit.gupta 282
				priceDrop.setOldDp(newDp + priceDropModel.getPd());
23951 amit.gupta 283
				priceDrop.setAmount(priceDropModel.getPd());
23968 amit.gupta 284
				priceDrop.setNewDp(newDp);
285
				priceDrop.setNlc(priceDropModel.getNlc());
286
				priceDrop.setTp(priceDropModel.getTp());
23951 amit.gupta 287
				priceDrop.setCreatedOn(LocalDateTime.now());
288
				priceDrop.setCatalogItemId(currentItem.getCatalogItemId());
289
				priceDropRepository.persist(priceDrop);
23884 amit.gupta 290
				response = true;
291
			} else {
23945 amit.gupta 292
				throw new ProfitMandiBusinessException("Price Drop", priceDropModel.getPd(),
293
						"Price Drop Cannot be more than Current DP");
23884 amit.gupta 294
			}
295
		}
296
		model.addAttribute("response", mvcResponseSender.createResponseString(response));
297
		return "response";
298
	}
23945 amit.gupta 299
 
23819 govind 300
	@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
301
	public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
23945 amit.gupta 302
			Model model) throws ProfitMandiBusinessException, Exception {
23819 govind 303
 
304
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
23968 amit.gupta 305
		Item item = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId()).get(0);
306
		ByteArrayOutputStream baos = getByteArrayOutputStream(priceDrop.getAffectedOn(), priceDrop.getCatalogItemId());
307
		final HttpHeaders headers = new HttpHeaders();
308
		headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
23983 amit.gupta 309
		headers.set("Content-disposition",
310
				"inline; filename=pricedrop-" + item.getItemDescriptionNoColor().replaceAll("\\s?,\\s?", " ") + "-"
311
						+ FormattingUtils.formatDate(priceDrop.getAffectedOn()) + ".csv");
23968 amit.gupta 312
		byte[] byteArray = baos.toByteArray();
313
		headers.setContentLength(byteArray.length);
314
		return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
23951 amit.gupta 315
 
316
	}
317
 
23983 amit.gupta 318
	private List<ImeiDropSummaryModel> getAllSerialNumbersByAffectedDate(LocalDateTime affectedOn,
319
			Integer catalogItemId) throws Exception {
23951 amit.gupta 320
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogItemId);
321
		List<String> itemIds = items.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList());
23945 amit.gupta 322
 
23968 amit.gupta 323
		Map<String, String> params = new HashMap<>();
324
		params.put("MANUAL_criteria1_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn));
325
		params.put("MANUAL_itemId", StringUtils.join(itemIds, ","));
326
 
327
		Map<String, String> params1 = new HashMap<>();
23979 amit.gupta 328
		params1.put("MANUAL_criteriaDate_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn.minusDays(1)));
23968 amit.gupta 329
		params1.put("MANUAL_criteriaItemId", StringUtils.join(itemIds, ","));
330
 
23970 amit.gupta 331
		Map<String, String> params2 = new HashMap<>();
23981 amit.gupta 332
		params2.put("MANUAL_Criteria2_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn.minusDays(1)));
23970 amit.gupta 333
		params2.put("MANUAL_Criteria1", StringUtils.join(itemIds, ","));
334
 
23968 amit.gupta 335
		List<? extends ImeiDropSummaryModel> grnPendingList = getReports(GrnPendingDataModel.class,
336
				ReporticoProject.FOCO, "imeispendinggrn.xml", params);
337
		List<? extends ImeiDropSummaryModel> partnerImeiNotSoldList = getReports(PartnerImeiNotSold.class,
338
				ReporticoProject.FOCO, "PartnerIMEINotSold.xml", params1);
23970 amit.gupta 339
		List<? extends ImeiDropSummaryModel> itemStockOnDateList = getReports(ClosingStockOnDate.class,
340
				ReporticoProject.WAREHOUSENEW, "itemstockondate.xml", params2);
23983 amit.gupta 341
 
23968 amit.gupta 342
		List<ImeiDropSummaryModel> mergedImeis = new ArrayList<>();
343
		mergedImeis.addAll(grnPendingList);
344
		mergedImeis.addAll(partnerImeiNotSoldList);
23970 amit.gupta 345
		mergedImeis.addAll(itemStockOnDateList);
23983 amit.gupta 346
		return mergedImeis;
347
	}
23968 amit.gupta 348
 
23983 amit.gupta 349
	private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId)
350
			throws Exception {
351
		List<ImeiDropSummaryModel> imeiDropSummaryModelList = this.getAllSerialNumbersByAffectedDate(affectedOn, catalogItemId);
23951 amit.gupta 352
		List<List<Object>> rows = new ArrayList<>();
23983 amit.gupta 353
		for (ImeiDropSummaryModel imeiDropSummaryModel : imeiDropSummaryModelList) {
23986 amit.gupta 354
			rows.add(this.getRow(imeiDropSummaryModel));
23951 amit.gupta 355
		}
356
		return FileUtil.getCSVByteStream(Arrays.asList("IMEI Number", "Store Name", "Store Code", "Item ID", "Brand",
357
				"Model Name", "Model Number", "Color", "Last Scanned"), rows);
23819 govind 358
	}
23986 amit.gupta 359
 
360
	private List<Object> getRow(ImeiDropSummaryModel imeiDropSummaryModel) {
361
		List<Object> row = new ArrayList<>();
362
		row.add(imeiDropSummaryModel.getSerialNumber());
363
		row.add(imeiDropSummaryModel.getStoreName());
364
		row.add(imeiDropSummaryModel.getPartnerCode());
365
		row.add(imeiDropSummaryModel.getItemId());
366
		row.add(imeiDropSummaryModel.getBrand());
367
		row.add(imeiDropSummaryModel.getModelName());
368
		row.add(imeiDropSummaryModel.getModelNumber());
369
		row.add(imeiDropSummaryModel.getColor());
370
		row.add(FormattingUtils.formatReporitcoDate(imeiDropSummaryModel.getLastScanned()));
371
		return row;
372
	}
23819 govind 373
 
23945 amit.gupta 374
	private <T> List<T> getReports(Class<T> className, ReporticoProject project, String reportName,
375
			Map<String, String> params) throws Exception {
376
		HttpResponse reportResponse = reporticoService.getJsonFile(project, reportName, params);
23951 amit.gupta 377
		JavaType type = objectMapper.getTypeFactory().constructParametricType(ReporticoResponseModel.class, className);
378
		ObjectReader or = objectMapper.readerFor(type);
23945 amit.gupta 379
		ReporticoResponseModel<T> responseObj = or.readValue(reportResponse.getEntity().getContent());
380
		return responseObj.getData();
381
	}
382
 
23884 amit.gupta 383
	private boolean validatePriceDrop(PriceDropModel priceDropModel) throws ProfitMandiBusinessException {
23945 amit.gupta 384
		if (priceDropModel.getMop() > 0 && priceDropModel.getMop() > 0 && priceDropModel.getNlc() > 0
385
				&& priceDropModel.getTp() > 0 && priceDropModel.getNlc() > 0) {
23884 amit.gupta 386
			return true;
387
		}
388
		return false;
389
	}
23945 amit.gupta 390
 
23819 govind 391
}