Subversion Repositories SmartDukaan

Rev

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

Rev 24106 Rev 24123
Line 37... Line 37...
37
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
37
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
38
import com.spice.profitmandi.common.model.NotificationDataModel;
38
import com.spice.profitmandi.common.model.NotificationDataModel;
39
import com.spice.profitmandi.common.model.ProfitMandiConstants;
39
import com.spice.profitmandi.common.model.ProfitMandiConstants;
40
import com.spice.profitmandi.common.util.ExcelUtils;
40
import com.spice.profitmandi.common.util.ExcelUtils;
41
import com.spice.profitmandi.common.util.Utils;
41
import com.spice.profitmandi.common.util.Utils;
-
 
42
import com.spice.profitmandi.dao.entity.catalog.Item;
42
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
43
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
43
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
44
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
44
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
45
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
45
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
46
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
-
 
47
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
46
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
48
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
47
import com.spice.profitmandi.service.inventory.InventoryService;
49
import com.spice.profitmandi.service.inventory.InventoryService;
48
import com.spice.profitmandi.web.model.LoginDetails;
50
import com.spice.profitmandi.web.model.LoginDetails;
49
import com.spice.profitmandi.web.util.CookiesProcessor;
51
import com.spice.profitmandi.web.util.CookiesProcessor;
50
import com.spice.profitmandi.web.util.MVCResponseSender;
52
import com.spice.profitmandi.web.util.MVCResponseSender;
51
 
53
 
52
@Controller
54
@Controller
53
@Transactional(rollbackFor=Throwable.class)
55
@Transactional(rollbackFor = Throwable.class)
54
public class InventoryController {
56
public class InventoryController {
55
 
57
 
56
	private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
58
	private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
57
 
59
 
58
	@Autowired
60
	@Autowired
59
	private CookiesProcessor cookiesProcessor;
61
	private CookiesProcessor cookiesProcessor;
60
	
62
 
61
	@Autowired
63
	@Autowired
62
	@Qualifier("fofoInventoryService")
64
	@Qualifier("fofoInventoryService")
63
	private InventoryService inventoryService;
65
	private InventoryService inventoryService;
64
	
66
 
65
	@Autowired
67
	@Autowired
66
	private TagRankingRepository tagRankingRepository;
68
	private TagRankingRepository tagRankingRepository;
-
 
69
 
-
 
70
	@Autowired
-
 
71
	private ItemRepository itemRepository;
67
	
72
 
68
	@Autowired
73
	@Autowired
69
	private MVCResponseSender mvcResponseSender;
74
	private MVCResponseSender mvcResponseSender;
70
	
75
 
71
	@Value("${saholic.api.host}")
76
	@Value("${saholic.api.host}")
72
	private String host;
77
	private String host;
73
 
78
 
74
	@Value("${saholic.api.port}")
79
	@Value("${saholic.api.port}")
75
	private int port;
80
	private int port;
Line 79... Line 84...
79
 
84
 
80
	@RequestMapping(value = "/getCurrentInventorySnapshot")
85
	@RequestMapping(value = "/getCurrentInventorySnapshot")
81
	public String getCurrentAvailability(HttpServletRequest request,
86
	public String getCurrentAvailability(HttpServletRequest request,
82
			@RequestParam(name = "offset", defaultValue = "0") int offset,
87
			@RequestParam(name = "offset", defaultValue = "0") int offset,
83
			@RequestParam(name = "limit", defaultValue = "10") int limit,
88
			@RequestParam(name = "limit", defaultValue = "10") int limit,
84
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, 
89
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
85
			Model model)
-
 
86
			throws ProfitMandiBusinessException {
90
			throws ProfitMandiBusinessException {
87
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
91
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
88
		Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
92
		Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
89
				searchTerm);
93
				searchTerm);
90
		model.addAllAttributes(map);
94
		model.addAllAttributes(map);
Line 95... Line 99...
95
	public String getBadAvailability(HttpServletRequest request,
99
	public String getBadAvailability(HttpServletRequest request,
96
			@RequestParam(name = "offset", defaultValue = "0") int offset,
100
			@RequestParam(name = "offset", defaultValue = "0") int offset,
97
			@RequestParam(name = "limit", defaultValue = "10") int limit,
101
			@RequestParam(name = "limit", defaultValue = "10") int limit,
98
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
102
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
99
			throws ProfitMandiBusinessException {
103
			throws ProfitMandiBusinessException {
100
		if(searchTerm==null) {
104
		if (searchTerm == null) {
101
			searchTerm="";
105
			searchTerm = "";
102
		}
106
		}
103
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
107
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
104
		Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
108
		Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
105
				searchTerm);
109
				searchTerm);
106
		model.addAllAttributes(map);
110
		model.addAllAttributes(map);
Line 111... Line 115...
111
	public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
115
	public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
112
			@RequestParam(name = "offset", defaultValue = "0") int offset,
116
			@RequestParam(name = "offset", defaultValue = "0") int offset,
113
			@RequestParam(name = "limit", defaultValue = "10") int limit,
117
			@RequestParam(name = "limit", defaultValue = "10") int limit,
114
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
118
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
115
			throws ProfitMandiBusinessException {
119
			throws ProfitMandiBusinessException {
116
		if(searchTerm==null) {
120
		if (searchTerm == null) {
117
			searchTerm="";
121
			searchTerm = "";
118
		}
122
		}
119
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
123
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
120
		Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
124
		Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
121
				offset, limit, searchTerm);
125
				offset, limit, searchTerm);
122
		model.addAllAttributes(map);
126
		model.addAllAttributes(map);
Line 127... Line 131...
127
	public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
131
	public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
128
			@RequestParam(name = "limit", defaultValue = "10") int limit,
132
			@RequestParam(name = "limit", defaultValue = "10") int limit,
129
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
133
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
130
			throws ProfitMandiBusinessException {
134
			throws ProfitMandiBusinessException {
131
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
135
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
132
		if(searchTerm==null) {
136
		if (searchTerm == null) {
133
			searchTerm="";
137
			searchTerm = "";
134
		}
138
		}
135
		Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
139
		Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
136
		model.addAllAttributes(map);
140
		model.addAllAttributes(map);
137
		return "catalog";
141
		return "catalog";
138
	}
142
	}
Line 142... Line 146...
142
			@RequestParam(name = "offset", defaultValue = "0") int offset,
146
			@RequestParam(name = "offset", defaultValue = "0") int offset,
143
			@RequestParam(name = "limit", defaultValue = "10") int limit,
147
			@RequestParam(name = "limit", defaultValue = "10") int limit,
144
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
148
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
145
			throws ProfitMandiBusinessException {
149
			throws ProfitMandiBusinessException {
146
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
150
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
147
		if(searchTerm==null) {
151
		if (searchTerm == null) {
148
			searchTerm="";
152
			searchTerm = "";
149
		}
153
		}
150
		Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
154
		Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
151
				searchTerm);
155
				searchTerm);
152
		model.addAllAttributes(map);
156
		model.addAllAttributes(map);
153
		return "catalog-paginated";
157
		return "catalog-paginated";
Line 186... Line 190...
186
		model.addAllAttributes(map);
190
		model.addAllAttributes(map);
187
		return "validate-cart";
191
		return "validate-cart";
188
	}
192
	}
189
 
193
 
190
	@RequestMapping(value = "/grnHistory")
194
	@RequestMapping(value = "/grnHistory")
191
	public String getGrnHistory(HttpServletRequest request,
-
 
192
			@RequestParam(required = false) LocalDateTime startTime,
195
	public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
193
			@RequestParam(required = false) LocalDateTime endTime,
196
			@RequestParam(required = false) LocalDateTime endTime,
194
			@RequestParam(name = "offset", defaultValue = "0") int offset,
197
			@RequestParam(name = "offset", defaultValue = "0") int offset,
195
			@RequestParam(name = "limit", defaultValue = "10") int limit,
198
			@RequestParam(name = "limit", defaultValue = "10") int limit,
196
			@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
199
			@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
197
			@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
200
			@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
198
			throws ProfitMandiBusinessException {
201
			throws ProfitMandiBusinessException {
199
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
202
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
200
		Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime,
203
		Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
201
				endTime, offset, limit, purchaseReference, searchType);
204
				limit, purchaseReference, searchType);
202
		model.addAllAttributes(map);
205
		model.addAllAttributes(map);
203
		return "grn-history";
206
		return "grn-history";
204
	}
207
	}
205
 
208
 
206
	@RequestMapping(value = "/getPaginatedGrnHistory")
209
	@RequestMapping(value = "/getPaginatedGrnHistory")
Line 211... Line 214...
211
			@RequestParam(name = "limit", defaultValue = "10") int limit,
214
			@RequestParam(name = "limit", defaultValue = "10") int limit,
212
			@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
215
			@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
213
			@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
216
			@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
214
			throws ProfitMandiBusinessException {
217
			throws ProfitMandiBusinessException {
215
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
218
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
216
		Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime,
219
		Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
217
				endTime, offset, limit);
220
				offset, limit);
218
		model.addAllAttributes(map);
221
		model.addAllAttributes(map);
219
		return "grn-history-paginated";
222
		return "grn-history-paginated";
220
	}
223
	}
221
 
224
 
222
	@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
225
	@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
Line 274... Line 277...
274
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
277
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
275
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
278
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
276
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
279
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
277
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
280
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
278
 
281
 
-
 
282
		// return
279
		// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
283
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
280
	}
284
	}
281
	
285
 
282
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
286
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
-
 
287
	public String FeaturePanel(HttpServletRequest request,
283
	public String FeaturePanel(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
288
			@RequestParam(name = "offset", defaultValue = "0") int offset,
284
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
289
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
285
 
290
 
286
		
-
 
287
		List<TagRanking> tagRanking = null;
291
		List<TagRanking> tagRanking = null;
288
 
292
 
289
		long size = 0;
293
		long size = 0;
290
		tagRanking =tagRankingRepository.selectAllTagRanking(offset, limit);
294
		tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
291
		size =tagRankingRepository.selectAllCount();
295
		size = tagRankingRepository.selectAllCount();
292
		LOGGER.info("tagRanking" + tagRanking);
296
		LOGGER.info("tagRanking" + tagRanking);
293
		if (!tagRanking.isEmpty()) {
297
		if (!tagRanking.isEmpty()) {
294
			
-
 
295
			model.addAttribute("tagRanking", tagRanking);
298
            model.addAttribute("tagRanking", tagRanking);
296
			model.addAttribute("start", offset + 1);
299
			model.addAttribute("start", offset + 1);
297
			model.addAttribute("size", size);
300
			model.addAttribute("size", size);
298
			model.addAttribute("url", "/getPaginatedfeature");
301
			model.addAttribute("url", "/getPaginatedfeature");
299
 
302
 
300
			if (tagRanking.size() < limit) {
303
			if (tagRanking.size() < limit) {
Line 308... Line 311...
308
		}
311
		}
309
 
312
 
310
		return "feature";
313
		return "feature";
311
 
314
 
312
	}
315
	}
313
	
316
 
314
	@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
317
	@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
315
	public String getPaginatedFeaturePanel(HttpServletRequest request,
318
	public String getPaginatedFeaturePanel(HttpServletRequest request,
316
			@RequestParam(name = "offset", defaultValue = "0") int offset,
319
			@RequestParam(name = "offset", defaultValue = "0") int offset,
317
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
320
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
318
			throws ProfitMandiBusinessException {
321
			throws ProfitMandiBusinessException {
319
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
322
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
320
		List<TagRanking> tagRanking = null;
323
		List<TagRanking> tagRanking = null;
321
 
324
 
322
		long size = 0;
325
		long size = 0;
323
		tagRanking =tagRankingRepository.selectAllTagRanking(offset, limit);
326
		tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
324
		if (!tagRanking.isEmpty()) {
327
		if (!tagRanking.isEmpty()) {
325
					
328
 
326
			model.addAttribute("tagRanking", tagRanking);
329
			model.addAttribute("tagRanking", tagRanking);
327
			model.addAttribute("start", offset + 1);
330
			model.addAttribute("start", offset + 1);
328
			model.addAttribute("size", size);
331
			model.addAttribute("size", size);
329
			model.addAttribute("url", "/getPaginatedfeature");
332
			model.addAttribute("url", "/getPaginatedfeature");
330
 
333
 
331
		} else {
334
		} else {
332
			model.addAttribute("tagRanking", tagRanking);
335
			model.addAttribute("tagRanking", tagRanking);
333
		}
336
		}
334
		return "feature-paginated";
337
		return "feature-paginated";
335
	}
338
	}
336
	
339
 
337
	@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
340
	@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
338
	public String Itemfeature(HttpServletRequest request,
341
	public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
339
			@RequestBody  ItemFeatureDataModel itemFeatureDatatModel, Model model) throws Exception {
342
			Model model) throws Exception {
340
 
343
 
341
		TagRanking tagRanking = new TagRanking();
344
		TagRanking tagRanking = new TagRanking();
342
		tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
345
		tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
343
		tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
346
		tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
344
		tagRanking.setFeature(itemFeatureDatatModel.getFeature());
347
		tagRanking.setFeature(itemFeatureDatatModel.getFeature());
345
		
348
 
346
		LOGGER.info("tagRanking"+ tagRanking);
349
		LOGGER.info("tagRanking" + tagRanking);
347
        tagRankingRepository.persist(tagRanking);
350
		tagRankingRepository.persist(tagRanking);
348
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
351
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
349
		return "response";
352
		return "response";
350
	}
353
	}
351
 
354
 
352
}
355
}