Subversion Repositories SmartDukaan

Rev

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