| 21577 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 22486 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
|
|
5 |
import java.io.InputStream;
|
| 23886 |
amit.gupta |
6 |
import java.time.LocalDateTime;
|
| 21577 |
ashik.ali |
7 |
import java.util.List;
|
| 21654 |
ashik.ali |
8 |
import java.util.Map;
|
| 21577 |
ashik.ali |
9 |
|
|
|
10 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
11 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
12 |
|
| 23886 |
amit.gupta |
13 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
14 |
import org.apache.logging.log4j.Logger;
|
| 21577 |
ashik.ali |
15 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
17 |
import org.springframework.beans.factory.annotation.Value;
|
| 22486 |
ashik.ali |
18 |
import org.springframework.core.io.InputStreamResource;
|
| 23886 |
amit.gupta |
19 |
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
20 |
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
| 22486 |
ashik.ali |
21 |
import org.springframework.http.HttpHeaders;
|
|
|
22 |
import org.springframework.http.HttpStatus;
|
| 22472 |
ashik.ali |
23 |
import org.springframework.http.ResponseEntity;
|
| 21577 |
ashik.ali |
24 |
import org.springframework.stereotype.Controller;
|
| 21654 |
ashik.ali |
25 |
import org.springframework.transaction.annotation.Transactional;
|
| 21577 |
ashik.ali |
26 |
import org.springframework.ui.Model;
|
| 22472 |
ashik.ali |
27 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21577 |
ashik.ali |
28 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22472 |
ashik.ali |
29 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21577 |
ashik.ali |
30 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
31 |
|
| 21987 |
kshitij.so |
32 |
import com.google.gson.Gson;
|
| 21577 |
ashik.ali |
33 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21612 |
ashik.ali |
34 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
35 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
36 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
37 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
|
|
38 |
import com.spice.profitmandi.common.model.NotificationDataModel;
|
| 21577 |
ashik.ali |
39 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22472 |
ashik.ali |
40 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 21987 |
kshitij.so |
41 |
import com.spice.profitmandi.common.util.Utils;
|
| 24123 |
tejbeer |
42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24106 |
tejbeer |
43 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
|
|
44 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
|
|
45 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
|
|
46 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 24123 |
tejbeer |
47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24106 |
tejbeer |
48 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 24203 |
amit.gupta |
49 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 22927 |
ashik.ali |
50 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22139 |
amit.gupta |
51 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
52 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
53 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
54 |
|
|
|
55 |
@Controller
|
| 24123 |
tejbeer |
56 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
57 |
public class InventoryController {
|
| 21987 |
kshitij.so |
58 |
|
| 23568 |
govind |
59 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 21987 |
kshitij.so |
60 |
|
| 21577 |
ashik.ali |
61 |
@Autowired
|
| 22927 |
ashik.ali |
62 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
63 |
|
| 22354 |
ashik.ali |
64 |
@Autowired
|
| 23784 |
ashik.ali |
65 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
66 |
private InventoryService inventoryService;
|
| 24203 |
amit.gupta |
67 |
|
|
|
68 |
@Autowired
|
|
|
69 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24123 |
tejbeer |
70 |
|
| 24106 |
tejbeer |
71 |
@Autowired
|
|
|
72 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
73 |
|
| 24106 |
tejbeer |
74 |
@Autowired
|
| 24123 |
tejbeer |
75 |
private ItemRepository itemRepository;
|
|
|
76 |
|
|
|
77 |
@Autowired
|
| 24106 |
tejbeer |
78 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
79 |
|
| 21987 |
kshitij.so |
80 |
@Value("${saholic.api.host}")
|
|
|
81 |
private String host;
|
| 23786 |
amit.gupta |
82 |
|
| 21987 |
kshitij.so |
83 |
@Value("${saholic.api.port}")
|
|
|
84 |
private int port;
|
| 23786 |
amit.gupta |
85 |
|
| 21987 |
kshitij.so |
86 |
@Value("${saholic.api.webapp}")
|
|
|
87 |
private String webapp;
|
|
|
88 |
|
| 23786 |
amit.gupta |
89 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
90 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
91 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
92 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
93 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
94 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
95 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
96 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
97 |
searchTerm);
|
| 22927 |
ashik.ali |
98 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
99 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
100 |
}
|
| 21987 |
kshitij.so |
101 |
|
| 23786 |
amit.gupta |
102 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
103 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
104 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
105 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
106 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
107 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
108 |
if (searchTerm == null) {
|
|
|
109 |
searchTerm = "";
|
| 24052 |
amit.gupta |
110 |
}
|
| 22927 |
ashik.ali |
111 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
112 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
113 |
searchTerm);
|
| 22927 |
ashik.ali |
114 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
115 |
return "bad-inventory-snapshot";
|
|
|
116 |
}
|
|
|
117 |
|
| 23786 |
amit.gupta |
118 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
119 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
120 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
121 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
122 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
123 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
124 |
if (searchTerm == null) {
|
|
|
125 |
searchTerm = "";
|
| 24052 |
amit.gupta |
126 |
}
|
| 22927 |
ashik.ali |
127 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
128 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
129 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
130 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
131 |
return "inventory-snapshot-paginated";
|
|
|
132 |
}
|
| 23786 |
amit.gupta |
133 |
|
|
|
134 |
@RequestMapping(value = "/getCatalog")
|
|
|
135 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
136 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
137 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
138 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
139 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
140 |
if (searchTerm == null) {
|
|
|
141 |
searchTerm = "";
|
| 24052 |
amit.gupta |
142 |
}
|
| 24203 |
amit.gupta |
143 |
|
| 22927 |
ashik.ali |
144 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
|
|
145 |
model.addAllAttributes(map);
|
| 24203 |
amit.gupta |
146 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 21987 |
kshitij.so |
147 |
return "catalog";
|
|
|
148 |
}
|
| 24203 |
amit.gupta |
149 |
|
| 23786 |
amit.gupta |
150 |
|
| 24203 |
amit.gupta |
151 |
//This method is currently hardcoded to faciliate watches sold as gift.
|
|
|
152 |
private boolean hasGift(int fofoId) {
|
|
|
153 |
try {
|
|
|
154 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
|
|
155 |
} catch (ProfitMandiBusinessException e) {
|
|
|
156 |
return false;
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
|
| 23786 |
amit.gupta |
160 |
@RequestMapping(value = "/getPaginatedCatalog")
|
|
|
161 |
public String getCatalogPaginated(HttpServletRequest request,
|
|
|
162 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
163 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
164 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
165 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
166 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
167 |
if (searchTerm == null) {
|
|
|
168 |
searchTerm = "";
|
| 24052 |
amit.gupta |
169 |
}
|
| 23786 |
amit.gupta |
170 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
|
|
171 |
searchTerm);
|
| 22927 |
ashik.ali |
172 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
173 |
return "catalog-paginated";
|
|
|
174 |
}
|
|
|
175 |
|
| 23786 |
amit.gupta |
176 |
@RequestMapping(value = "/checkItemAvailability")
|
|
|
177 |
public String getItemAvailability(HttpServletRequest request,
|
|
|
178 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
|
|
179 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
180 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
181 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
|
|
182 |
loginDetails.getFofoId());
|
|
|
183 |
customCurrentInventorySnapshot
|
|
|
184 |
.setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(), host, port, webapp));
|
| 22927 |
ashik.ali |
185 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
|
|
186 |
return "current-item-availability";
|
| 23786 |
amit.gupta |
187 |
|
| 21577 |
ashik.ali |
188 |
}
|
| 23786 |
amit.gupta |
189 |
|
| 23192 |
ashik.ali |
190 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
191 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
192 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
193 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
194 |
|
| 22927 |
ashik.ali |
195 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
|
|
196 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
197 |
return "cart";
|
|
|
198 |
}
|
| 23786 |
amit.gupta |
199 |
|
| 23192 |
ashik.ali |
200 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
201 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
|
|
202 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
203 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
204 |
|
| 22927 |
ashik.ali |
205 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
|
|
206 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
207 |
return "validate-cart";
|
|
|
208 |
}
|
|
|
209 |
|
| 23786 |
amit.gupta |
210 |
@RequestMapping(value = "/grnHistory")
|
| 24123 |
tejbeer |
211 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
| 23886 |
amit.gupta |
212 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
213 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
214 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
215 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
216 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
217 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
218 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
219 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
220 |
limit, purchaseReference, searchType);
|
| 22927 |
ashik.ali |
221 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
222 |
return "grn-history";
|
| 21636 |
ashik.ali |
223 |
}
|
| 21987 |
kshitij.so |
224 |
|
| 23786 |
amit.gupta |
225 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
|
|
226 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
| 23886 |
amit.gupta |
227 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
228 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
229 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
230 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
231 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
232 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
233 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
234 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
235 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
|
|
236 |
offset, limit);
|
| 22927 |
ashik.ali |
237 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
238 |
return "grn-history-paginated";
|
|
|
239 |
}
|
|
|
240 |
|
| 23786 |
amit.gupta |
241 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
|
|
242 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
|
|
243 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
|
|
244 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
245 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
246 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
|
|
247 |
webapp);
|
| 22927 |
ashik.ali |
248 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
249 |
return "grn-details";
|
| 21636 |
ashik.ali |
250 |
}
|
| 21987 |
kshitij.so |
251 |
|
| 23786 |
amit.gupta |
252 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
|
|
253 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
|
|
254 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
|
|
255 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
256 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
257 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
|
|
258 |
host, port, webapp);
|
| 22927 |
ashik.ali |
259 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
260 |
return "grn-details";
|
| 21654 |
ashik.ali |
261 |
}
|
| 23786 |
amit.gupta |
262 |
|
| 22472 |
ashik.ali |
263 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
264 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
|
|
265 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
|
|
266 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
267 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
268 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
269 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
|
|
270 |
searchContent, offset, limit);
|
| 22927 |
ashik.ali |
271 |
model.addAllAttributes(map);
|
| 22523 |
ashik.ali |
272 |
return "item-aging";
|
|
|
273 |
}
|
| 23786 |
amit.gupta |
274 |
|
| 22523 |
ashik.ali |
275 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
276 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
|
|
277 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
278 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
|
|
279 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
280 |
|
|
|
281 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
|
|
282 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
|
|
283 |
|
| 22486 |
ashik.ali |
284 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
285 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
286 |
|
|
|
287 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
288 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
289 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
290 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
291 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| 22486 |
ashik.ali |
292 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| 23786 |
amit.gupta |
293 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
294 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
295 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
296 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
297 |
|
| 24123 |
tejbeer |
298 |
// return
|
|
|
299 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 22472 |
ashik.ali |
300 |
}
|
| 24123 |
tejbeer |
301 |
|
| 24106 |
tejbeer |
302 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| 24123 |
tejbeer |
303 |
public String FeaturePanel(HttpServletRequest request,
|
|
|
304 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24106 |
tejbeer |
305 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 21987 |
kshitij.so |
306 |
|
| 24106 |
tejbeer |
307 |
List<TagRanking> tagRanking = null;
|
|
|
308 |
|
|
|
309 |
long size = 0;
|
| 24123 |
tejbeer |
310 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
|
|
311 |
size = tagRankingRepository.selectAllCount();
|
| 24106 |
tejbeer |
312 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
313 |
if (!tagRanking.isEmpty()) {
|
| 24123 |
tejbeer |
314 |
model.addAttribute("tagRanking", tagRanking);
|
| 24106 |
tejbeer |
315 |
model.addAttribute("start", offset + 1);
|
|
|
316 |
model.addAttribute("size", size);
|
|
|
317 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
318 |
|
|
|
319 |
if (tagRanking.size() < limit) {
|
|
|
320 |
model.addAttribute("end", offset + tagRanking.size());
|
|
|
321 |
} else {
|
|
|
322 |
model.addAttribute("end", offset + limit);
|
|
|
323 |
}
|
|
|
324 |
} else {
|
|
|
325 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
326 |
model.addAttribute("size", size);
|
|
|
327 |
}
|
|
|
328 |
|
|
|
329 |
return "feature";
|
|
|
330 |
|
|
|
331 |
}
|
| 24123 |
tejbeer |
332 |
|
| 24106 |
tejbeer |
333 |
@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
|
|
|
334 |
public String getPaginatedFeaturePanel(HttpServletRequest request,
|
|
|
335 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
336 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
337 |
throws ProfitMandiBusinessException {
|
|
|
338 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
339 |
List<TagRanking> tagRanking = null;
|
|
|
340 |
|
|
|
341 |
long size = 0;
|
| 24123 |
tejbeer |
342 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
| 24106 |
tejbeer |
343 |
if (!tagRanking.isEmpty()) {
|
| 24123 |
tejbeer |
344 |
|
| 24106 |
tejbeer |
345 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
346 |
model.addAttribute("start", offset + 1);
|
|
|
347 |
model.addAttribute("size", size);
|
|
|
348 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
349 |
|
|
|
350 |
} else {
|
|
|
351 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
352 |
}
|
|
|
353 |
return "feature-paginated";
|
|
|
354 |
}
|
| 24123 |
tejbeer |
355 |
|
| 24106 |
tejbeer |
356 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
357 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
358 |
Model model) throws Exception {
|
| 24106 |
tejbeer |
359 |
|
|
|
360 |
TagRanking tagRanking = new TagRanking();
|
|
|
361 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
|
|
362 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
363 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 24123 |
tejbeer |
364 |
|
|
|
365 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
366 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
367 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
368 |
return "response";
|
|
|
369 |
}
|
|
|
370 |
|
| 21577 |
ashik.ali |
371 |
}
|