Subversion Repositories SmartDukaan

Rev

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

Rev 23884 Rev 23945
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.io.ByteArrayInputStream;
-
 
4
import java.io.ByteArrayOutputStream;
-
 
5
import java.io.InputStream;
-
 
6
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
7
import java.util.ArrayList;
4
import java.util.ArrayList;
8
import java.util.Arrays;
5
import java.util.Arrays;
9
import java.util.HashMap;
6
import java.util.HashMap;
10
import java.util.LinkedHashMap;
7
import java.util.LinkedHashMap;
Line 13... Line 10...
13
import java.util.stream.Collectors;
10
import java.util.stream.Collectors;
14
 
11
 
15
import javax.servlet.http.HttpServletRequest;
12
import javax.servlet.http.HttpServletRequest;
16
import javax.transaction.Transactional;
13
import javax.transaction.Transactional;
17
 
14
 
-
 
15
import org.apache.http.HttpResponse;
18
import org.apache.logging.log4j.LogManager;
16
import org.apache.logging.log4j.LogManager;
19
import org.apache.logging.log4j.Logger;
17
import org.apache.logging.log4j.Logger;
20
import org.json.JSONArray;
18
import org.json.JSONArray;
21
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.beans.factory.annotation.Autowired;
22
import org.springframework.beans.factory.annotation.Qualifier;
20
import org.springframework.beans.factory.annotation.Qualifier;
23
import org.springframework.core.io.InputStreamResource;
-
 
24
import org.springframework.http.HttpHeaders;
-
 
25
import org.springframework.http.HttpStatus;
21
import org.springframework.http.HttpStatus;
26
import org.springframework.http.ResponseEntity;
22
import org.springframework.http.ResponseEntity;
27
import org.springframework.stereotype.Controller;
23
import org.springframework.stereotype.Controller;
28
import org.springframework.ui.Model;
24
import org.springframework.ui.Model;
29
import org.springframework.web.bind.annotation.PathVariable;
25
import org.springframework.web.bind.annotation.PathVariable;
30
import org.springframework.web.bind.annotation.RequestBody;
26
import org.springframework.web.bind.annotation.RequestBody;
31
import org.springframework.web.bind.annotation.RequestMapping;
27
import org.springframework.web.bind.annotation.RequestMapping;
32
import org.springframework.web.bind.annotation.RequestMethod;
28
import org.springframework.web.bind.annotation.RequestMethod;
33
 
29
 
-
 
30
import com.fasterxml.jackson.core.type.TypeReference;
-
 
31
import com.fasterxml.jackson.databind.ObjectMapper;
-
 
32
import com.fasterxml.jackson.databind.ObjectReader;
-
 
33
import com.spice.profitmandi.common.enumuration.ReporticoProject;
34
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
34
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
35
import com.spice.profitmandi.common.model.ClosingStockOnDate;
-
 
36
import com.spice.profitmandi.common.model.GrnPendingDataModel;
35
import com.spice.profitmandi.common.model.ItemDescriptionModel;
37
import com.spice.profitmandi.common.model.ItemDescriptionModel;
-
 
38
import com.spice.profitmandi.common.model.PartnerImeiNotSold;
36
import com.spice.profitmandi.common.model.PriceDropModel;
39
import com.spice.profitmandi.common.model.PriceDropModel;
-
 
40
import com.spice.profitmandi.common.model.ReporticoResponseModel;
-
 
41
import com.spice.profitmandi.common.services.ReporticoService;
37
import com.spice.profitmandi.common.util.ExcelUtils;
42
import com.spice.profitmandi.common.util.FormattingUtils;
38
import com.spice.profitmandi.dao.entity.catalog.Item;
43
import com.spice.profitmandi.dao.entity.catalog.Item;
39
import com.spice.profitmandi.dao.entity.catalog.TagListing;
44
import com.spice.profitmandi.dao.entity.catalog.TagListing;
40
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
45
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
41
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
46
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
42
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
47
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
Line 63... Line 68...
63
	private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
68
	private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
64
 
69
 
65
	@Autowired
70
	@Autowired
66
	private PriceDropRepository priceDropRepository;
71
	private PriceDropRepository priceDropRepository;
67
 
72
 
-
 
73
	private ObjectMapper objectMapper = new ObjectMapper();
-
 
74
 
68
	@Autowired
75
	@Autowired
69
	private PriceDropIMEIRepository priceDropIMEIRepository;
76
	private PriceDropIMEIRepository priceDropIMEIRepository;
70
	
77
 
71
	@Autowired
78
	@Autowired
72
	private VendorItemPricingRepository vendorItemPricingRepository;
79
	private VendorItemPricingRepository vendorItemPricingRepository;
73
 
80
 
74
	@Autowired
81
	@Autowired
75
	private PriceDropService priceDropService;
82
	private PriceDropService priceDropService;
76
 
83
 
77
	@Autowired
84
	@Autowired
78
	@Qualifier("fofoInventoryService")
85
	@Qualifier("fofoInventoryService")
79
	private InventoryService inventoryService;
86
	private InventoryService inventoryService;
80
	
87
 
81
	@Autowired
88
	@Autowired
82
	private MVCResponseSender mvcResponseSender;
89
	private MVCResponseSender mvcResponseSender;
83
 
90
 
84
	@Autowired
91
	@Autowired
85
	private WalletService walletService;
92
	private WalletService walletService;
86
 
93
 
87
	@Autowired
94
	@Autowired
88
	private LineItemImeisRepository lineItemImeisRepository;
95
	private LineItemImeisRepository lineItemImeisRepository;
89
	
96
 
90
	@Autowired
97
	@Autowired
91
	private TagListingRepository tagListingRepository;
98
	private TagListingRepository tagListingRepository;
92
	
99
 
93
	@Autowired
100
	@Autowired
94
	private TransactionService transactionService;
101
	private TransactionService transactionService;
95
 
102
 
96
	@Autowired
103
	@Autowired
97
	@Qualifier("catalogItemRepository")
104
	@Qualifier("catalogItemRepository")
98
	private ItemRepository itemRepository;
105
	private ItemRepository itemRepository;
99
 
106
 
-
 
107
	@Autowired
-
 
108
	ReporticoService reporticoService;
-
 
109
 
100
	@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
110
	@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
101
	public String getItemDescription(HttpServletRequest request, Model model) throws Throwable{
111
	public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
102
 
112
 
103
		List<TagListing> tagListings = tagListingRepository.selectAll(false);
113
		List<TagListing> tagListings = tagListingRepository.selectAll(false);
104
		Map<Integer, TagListing> tagListingMap = new HashMap<>();
114
		Map<Integer, TagListing> tagListingMap = new HashMap<>();
105
		List<ItemDescriptionModel> customItems = new ArrayList<>();
115
		List<ItemDescriptionModel> customItems = new ArrayList<>();
106
		for(TagListing tagListing : tagListings) {
116
		for (TagListing tagListing : tagListings) {
107
			tagListing.setItemDescription(itemRepository.selectById(tagListing.getItemId()).getItemDescription());
117
			tagListing.setItemDescription(itemRepository.selectById(tagListing.getItemId()).getItemDescription());
108
			tagListingMap.put(tagListing.getItemId(), tagListing);
118
			tagListingMap.put(tagListing.getItemId(), tagListing);
109
			ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
119
			ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
110
			itemDescriptionModel.setItemId(tagListing.getItemId());
120
			itemDescriptionModel.setItemId(tagListing.getItemId());
-
 
121
			itemDescriptionModel
111
			itemDescriptionModel.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId()	 +")");
122
					.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
112
			customItems.add(itemDescriptionModel);	
123
			customItems.add(itemDescriptionModel);
113
		}
124
		}
114
		
125
 
115
		List<PriceDrop> priceDrops = priceDropRepository.selectAll();
126
		List<PriceDrop> priceDrops = priceDropRepository.selectAll();
116
		model.addAttribute("tagListingMap", tagListingMap);
127
		model.addAttribute("tagListingMap", tagListingMap);
117
		model.addAttribute("customItems", new JSONArray(customItems).toString());
128
		model.addAttribute("customItems", new JSONArray(customItems).toString());
118
		model.addAttribute("priceDrops", priceDrops);
129
		model.addAttribute("priceDrops", priceDrops);
119
		return "price-drop";
130
		return "price-drop";
120
 
131
 
121
	}
132
	}
122
 
133
 
-
 
134
	/*
123
	@RequestMapping(value = "/downloadPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
135
	 * @RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method =
-
 
136
	 * RequestMethod.GET) public ResponseEntity<?>
124
	public ResponseEntity<?> downloadPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
137
	 * downloadPriceDropIMEI(HttpServletRequest request, @PathVariable int
125
			Model model) throws ProfitMandiBusinessException {
138
	 * priceDropId, Model model) throws ProfitMandiBusinessException {
126
 
139
	 * 
127
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
140
	 * PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
-
 
141
	 * List<PriceDropIMEI> priceDropIMEIs =
128
		List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByPriceDropId(priceDrop.getId());
142
	 * priceDropIMEIRepository.selectByPriceDropId(priceDrop.getId()); List<String>
129
		List<String> imeis = priceDropIMEIs.stream().map(x -> x.getImei()).collect(Collectors.toList());
143
	 * imeis = priceDropIMEIs.stream().map(x ->
-
 
144
	 * x.getImei()).collect(Collectors.toList()); List<LineItemImei> lineItemImeis =
130
		List<LineItemImei> lineItemImeis = lineItemImeisRepository.selectByIMEI(imeis);
145
	 * lineItemImeisRepository.selectByIMEI(imeis); Map<String, String>
131
		Map<String, String> priceDropIMEIfofoId = priceDropService.getIMEIandRetailerName(lineItemImeis, priceDrop);
146
	 * priceDropIMEIfofoId = priceDropService.getIMEIandRetailerName(lineItemImeis,
132
		if (priceDropIMEIfofoId.size() > 0) {
147
	 * priceDrop); if (priceDropIMEIfofoId.size() > 0) { ByteArrayOutputStream
133
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
148
	 * byteArrayOutputStream = new ByteArrayOutputStream();
134
			ExcelUtils.writePriceDrop(priceDropIMEIfofoId, priceDrop.getItemId(), byteArrayOutputStream);
149
	 * ExcelUtils.writePriceDrop(priceDropIMEIfofoId, priceDrop.getItemId(),
135
			final HttpHeaders headers = new HttpHeaders();
150
	 * byteArrayOutputStream); final HttpHeaders headers = new HttpHeaders(); //
136
			// private static final String CONTENT_TYPE_XLSX =
151
	 * private static final String CONTENT_TYPE_XLSX = //
137
			// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
152
	 * "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-
 
153
	 * headers.set("Content-Type",
138
			headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
154
	 * "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); //
139
			// headers.set("Content-Type", "application/vnd.ms-excel");
155
	 * headers.set("Content-Type", "application/vnd.ms-excel");
140
			headers.set("Content-disposition", "inline; filename=priceDrop" + priceDrop.getId() + ".xlsx");
156
	 * headers.set("Content-disposition", "inline; filename=priceDrop" +
-
 
157
	 * priceDrop.getId() + ".xlsx");
141
			headers.setContentLength(byteArrayOutputStream.toByteArray().length);
158
	 * headers.setContentLength(byteArrayOutputStream.toByteArray().length); final
-
 
159
	 * InputStream inputStream = new
142
			final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
160
	 * ByteArrayInputStream(byteArrayOutputStream.toByteArray()); final
143
			final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
161
	 * InputStreamResource inputStreamResource = new
-
 
162
	 * InputStreamResource(inputStream); return new
144
			return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
163
	 * ResponseEntity<InputStreamResource>(inputStreamResource, headers,
145
		} else {
164
	 * HttpStatus.OK); } else { throw new
146
			throw new ProfitMandiBusinessException("priceDropId", priceDropId, "No IMEI is Eligible For PriceDrop");
165
	 * ProfitMandiBusinessException("priceDropId", priceDropId,
-
 
166
	 * "No IMEI is Eligible For PriceDrop"); }
147
		}
167
	 * 
148
 
168
	 * }
149
	}
169
	 */
150
 
170
 
151
	@RequestMapping(value = "/paymentAgainstPriceDrop/{priceDropId}/{processedamount}", method = RequestMethod.POST)
171
	@RequestMapping(value = "/paymentAgainstPriceDrop/{priceDropId}/{processedamount}", method = RequestMethod.POST)
152
	public String paymentAgainstPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
172
	public String paymentAgainstPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
153
			@PathVariable int processedamount, Model model) throws Exception {
173
			@PathVariable int processedamount, Model model) throws Exception {
154
 
174
 
155
		
-
 
156
		int noOfIMEIForPartner = 1;
175
		int noOfIMEIForPartner = 1;
157
		Map<Integer, Integer> noOfPriceDropToPartners = new HashMap<>();
176
		Map<Integer, Integer> noOfPriceDropToPartners = new HashMap<>();
158
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
177
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
159
		Item item = itemRepository.selectById(priceDrop.getItemId());
178
		Item item = itemRepository.selectById(priceDrop.getItemId());
160
		List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByPriceDropId(priceDrop.getId());
179
		List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByPriceDropId(priceDrop.getId());
Line 194... Line 213...
194
			return "false";
213
			return "false";
195
		}
214
		}
196
	}
215
	}
197
 
216
 
198
	@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
217
	@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
199
	public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel) throws Exception {
218
	public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
-
 
219
			throws Exception {
200
		boolean response = false;
220
		boolean response = false;
201
		if(this.validatePriceDrop(priceDropModel)) {
221
		if (this.validatePriceDrop(priceDropModel)) {
202
			TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
222
			TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
203
			float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
223
			float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
204
			if(newDp > 0) {
224
			if (newDp > 0) {
205
				List<Item> allItems = null;
225
				List<Item> allItems = null;
206
				Item currentItem = itemRepository.selectById(priceDropModel.getItemId());
226
				Item currentItem = itemRepository.selectById(priceDropModel.getItemId());
207
				if(priceDropModel.isAllColors()) {
227
				if (priceDropModel.isAllColors()) {
208
					allItems = itemRepository.selectAllByCatalogItemId(currentItem.getCatalogItemId());
228
					allItems = itemRepository.selectAllByCatalogItemId(currentItem.getCatalogItemId());
209
					
229
 
210
				} else {
230
				} else {
211
					allItems=Arrays.asList(currentItem);
231
					allItems = Arrays.asList(currentItem);
212
				}
232
				}
213
				for(Item item : allItems) {
233
				for (Item item : allItems) {
214
					TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
234
					TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
215
					if(itemTagListing == null) continue;
235
					if (itemTagListing == null)
-
 
236
						continue;
216
					itemTagListing.setSellingPrice(newDp);
237
					itemTagListing.setSellingPrice(newDp);
217
					itemTagListing.setMop(priceDropModel.getMop());
238
					itemTagListing.setMop(priceDropModel.getMop());
218
					tagListingRepository.persist(tagListing);
239
					tagListingRepository.persist(tagListing);
219
					List<VendorItemPricing> vipList = vendorItemPricingRepository.selectAll(item.getId());
240
					List<VendorItemPricing> vipList = vendorItemPricingRepository.selectAll(item.getId());
220
					for(VendorItemPricing vip : vipList) {
241
					for (VendorItemPricing vip : vipList) {
221
						vip.setDp(newDp);
242
						vip.setDp(newDp);
222
						vip.setMop(priceDropModel.getMop());
243
						vip.setMop(priceDropModel.getMop());
223
						vip.setNlc(priceDropModel.getNlc());
244
						vip.setNlc(priceDropModel.getNlc());
224
						vip.setTp(priceDropModel.getTp());
245
						vip.setTp(priceDropModel.getTp());
225
						vendorItemPricingRepository.persist(vip);
246
						vendorItemPricingRepository.persist(vip);
Line 232... Line 253...
232
					priceDropRepository.persist(priceDrop);
253
					priceDropRepository.persist(priceDrop);
233
					transactionService.updatePriceDrop(item.getId(), newDp);
254
					transactionService.updatePriceDrop(item.getId(), newDp);
234
				}
255
				}
235
				response = true;
256
				response = true;
236
			} else {
257
			} else {
237
				throw new ProfitMandiBusinessException("Price Drop", priceDropModel.getPd(), "Price Drop Cannot be more than Current DP");
258
				throw new ProfitMandiBusinessException("Price Drop", priceDropModel.getPd(),
-
 
259
						"Price Drop Cannot be more than Current DP");
238
			}
260
			}
239
		}
261
		}
240
		model.addAttribute("response", mvcResponseSender.createResponseString(response));
262
		model.addAttribute("response", mvcResponseSender.createResponseString(response));
241
		return "response";
263
		return "response";
242
	}
264
	}
-
 
265
 
243
	@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
266
	@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
244
	public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
267
	public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
245
			Model model) throws ProfitMandiBusinessException {
268
			Model model) throws ProfitMandiBusinessException, Exception {
246
 
269
 
247
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
270
		PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
-
 
271
		Map<String, String> params = new HashMap<>();
-
 
272
		params.put("MANUAL_criteria1_FROMDATE", FormattingUtils.formatReporitcoDate(priceDrop.getAffectedOn()));
-
 
273
		params.put("MANUAL_itemId", String.valueOf(priceDrop.getItemId()));
-
 
274
		Map<String, String> params1 = new HashMap<>();
-
 
275
		params1.put("MANUAL_criteriaDate_FROMDATE", FormattingUtils.formatReporitcoDate(priceDrop.getAffectedOn()));
248
		Map<String, String> priceDropIMEIAndItemId = this.getpriceDropIMEIAndItemDescription(priceDrop);
276
		params1.put("MANUAL_criteriaItemId", String.valueOf(priceDrop.getItemId()));
-
 
277
 
249
		if (priceDropIMEIAndItemId.size() > 0) {
278
		Map<String, String> params2 = new HashMap<>();
-
 
279
		params2.put("MANUAL_Criteria2_FROMDATE", FormattingUtils.formatReporitcoDate(priceDrop.getAffectedOn()));
-
 
280
		params2.put("MANUAL_Criteria1", String.valueOf(priceDrop.getItemId()));
-
 
281
		List<GrnPendingDataModel> grnPendingList = getReports(GrnPendingDataModel.class, ReporticoProject.FOCO, "imeispendinggrn.xml", params);
-
 
282
		List<PartnerImeiNotSold> partnerImeiNotSoldList = getReports(PartnerImeiNotSold.class, ReporticoProject.FOCO, "PartnerIMEINotSold.xml", params1);
-
 
283
		List<ClosingStockOnDate> itemStockOnDateList = getReports(ClosingStockOnDate.class, ReporticoProject.WAREHOUSENEW, "itemstockondate.xml", params2);
-
 
284
		return new ResponseEntity<Boolean>(true, null, HttpStatus.OK);
-
 
285
		//List<Strng> 
-
 
286
		/*
250
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
287
		 * ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
251
			ExcelUtils.writePriceDropForAllIMEI(priceDropIMEIAndItemId, byteArrayOutputStream);
288
		 * ExcelUtils.writePriceDropForAllIMEI(priceDropIMEIAndItemId,
252
			final HttpHeaders headers = new HttpHeaders();
289
		 * byteArrayOutputStream); final HttpHeaders headers = new HttpHeaders();
-
 
290
		 * headers.set("Content-Type",
253
			headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
291
		 * "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
254
			headers.set("Content-disposition", "inline; filename=totalPriceDropIMEI" + priceDrop.getItemId() + ".xlsx");
292
		 * headers.set("Content-disposition", "inline; filename=totalPriceDropIMEI" +
-
 
293
		 * priceDrop.getItemId() + ".xlsx");
255
			headers.setContentLength(byteArrayOutputStream.toByteArray().length);
294
		 * headers.setContentLength(byteArrayOutputStream.toByteArray().length); final
-
 
295
		 * InputStream inputStream = new
256
			final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
296
		 * ByteArrayInputStream(byteArrayOutputStream.toByteArray()); final
257
			final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
297
		 * InputStreamResource inputStreamResource = new
-
 
298
		 * InputStreamResource(inputStream); return new
258
			return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
299
		 * ResponseEntity<InputStreamResource>(inputStreamResource, headers,
-
 
300
		 * HttpStatus.OK); } else { priceDrop.setProcessTimestamp(LocalDateTime.now());
-
 
301
		 * throw new ProfitMandiBusinessException("IMEI", 1,
-
 
302
		 * "IMEI not Found For PriceDrop"); }
259
		} else {
303
		 */
-
 
304
	}
-
 
305
 
-
 
306
	private <T> List<T> getReports(Class<T> className, ReporticoProject project, String reportName,
260
			priceDrop.setProcessTimestamp(LocalDateTime.now());
307
			Map<String, String> params) throws Exception {
261
			throw new ProfitMandiBusinessException("IMEI", 1, "IMEI not Found For PriceDrop");
308
		HttpResponse reportResponse = reporticoService.getJsonFile(project, reportName, params);
-
 
309
		TypeReference<ReporticoResponseModel<T>> typeReference = new TypeReference<ReporticoResponseModel<T>>() {
262
		}
310
		};
-
 
311
		ObjectReader or = objectMapper.readerFor(typeReference);
-
 
312
		ReporticoResponseModel<T> responseObj = or.readValue(reportResponse.getEntity().getContent());
-
 
313
		return responseObj.getData();
263
	}
314
	}
264
 
315
 
265
	private boolean validatePriceDrop(PriceDropModel priceDropModel) throws ProfitMandiBusinessException {
316
	private boolean validatePriceDrop(PriceDropModel priceDropModel) throws ProfitMandiBusinessException {
266
		if(priceDropModel.getMop() > 0 && priceDropModel.getMop() > 0 && priceDropModel.getNlc() > 0 && priceDropModel.getTp() > 0 && priceDropModel.getNlc() > 0) {
317
		if (priceDropModel.getMop() > 0 && priceDropModel.getMop() > 0 && priceDropModel.getNlc() > 0
-
 
318
				&& priceDropModel.getTp() > 0 && priceDropModel.getNlc() > 0) {
267
			return true;
319
			return true;
268
		}
320
		}
269
		return false;
321
		return false;
270
	}
322
	}
-
 
323
 
271
	private Map<String, String> getpriceDropIMEIAndItemDescription(PriceDrop priceDrop)
324
	private Map<String, String> getpriceDropIMEIAndItemDescription(PriceDrop priceDrop)
272
			throws ProfitMandiBusinessException {
325
			throws ProfitMandiBusinessException {
273
		Map<String, String> priceDropIMEIAndItemId = new LinkedHashMap<>();
326
		Map<String, String> priceDropIMEIAndItemId = new LinkedHashMap<>();
274
		List<InventoryItem> inventoryInStock = inventoryService.getInventoryInStock(priceDrop.getItemId(), priceDrop.getAffectedOn());
327
		List<InventoryItem> inventoryInStock = inventoryService.getInventoryInStock(priceDrop.getItemId(),
-
 
328
				priceDrop.getAffectedOn());
275
		return priceDropIMEIAndItemId;
329
		return priceDropIMEIAndItemId;
276
	}
330
	}
277
 
331
 
278
}
332
}