| 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;
|
| 24465 |
tejbeer |
7 |
import java.util.ArrayList;
|
|
|
8 |
import java.util.Comparator;
|
|
|
9 |
import java.util.HashSet;
|
| 21577 |
ashik.ali |
10 |
import java.util.List;
|
| 21654 |
ashik.ali |
11 |
import java.util.Map;
|
| 24465 |
tejbeer |
12 |
import java.util.Set;
|
|
|
13 |
import java.util.stream.Collectors;
|
| 21577 |
ashik.ali |
14 |
|
|
|
15 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
16 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
17 |
|
| 23886 |
amit.gupta |
18 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
19 |
import org.apache.logging.log4j.Logger;
|
| 24465 |
tejbeer |
20 |
import org.json.JSONObject;
|
| 21577 |
ashik.ali |
21 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
22 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
23 |
import org.springframework.beans.factory.annotation.Value;
|
| 22486 |
ashik.ali |
24 |
import org.springframework.core.io.InputStreamResource;
|
| 23886 |
amit.gupta |
25 |
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
26 |
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
| 22486 |
ashik.ali |
27 |
import org.springframework.http.HttpHeaders;
|
|
|
28 |
import org.springframework.http.HttpStatus;
|
| 22472 |
ashik.ali |
29 |
import org.springframework.http.ResponseEntity;
|
| 21577 |
ashik.ali |
30 |
import org.springframework.stereotype.Controller;
|
| 21654 |
ashik.ali |
31 |
import org.springframework.transaction.annotation.Transactional;
|
| 21577 |
ashik.ali |
32 |
import org.springframework.ui.Model;
|
| 22472 |
ashik.ali |
33 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21577 |
ashik.ali |
34 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22472 |
ashik.ali |
35 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21577 |
ashik.ali |
36 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
37 |
|
| 21987 |
kshitij.so |
38 |
import com.google.gson.Gson;
|
| 21577 |
ashik.ali |
39 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24465 |
tejbeer |
40 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
| 21612 |
ashik.ali |
41 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
42 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
43 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
44 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
|
|
45 |
import com.spice.profitmandi.common.model.NotificationDataModel;
|
| 21577 |
ashik.ali |
46 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22472 |
ashik.ali |
47 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 21987 |
kshitij.so |
48 |
import com.spice.profitmandi.common.util.Utils;
|
| 24123 |
tejbeer |
49 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24106 |
tejbeer |
50 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
|
|
51 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| 24465 |
tejbeer |
52 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
|
|
53 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
| 24106 |
tejbeer |
54 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
|
|
55 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 24123 |
tejbeer |
56 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24106 |
tejbeer |
57 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 24465 |
tejbeer |
58 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24203 |
amit.gupta |
59 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24465 |
tejbeer |
60 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
|
|
61 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
| 24658 |
tejbeer |
62 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 22927 |
ashik.ali |
63 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 24465 |
tejbeer |
64 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22139 |
amit.gupta |
65 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
66 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
67 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
68 |
|
| 24658 |
tejbeer |
69 |
import in.shop2020.model.v1.order.Order;
|
|
|
70 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
71 |
|
| 21577 |
ashik.ali |
72 |
@Controller
|
| 24123 |
tejbeer |
73 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
74 |
public class InventoryController {
|
| 21987 |
kshitij.so |
75 |
|
| 23568 |
govind |
76 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 21987 |
kshitij.so |
77 |
|
| 21577 |
ashik.ali |
78 |
@Autowired
|
| 22927 |
ashik.ali |
79 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
80 |
|
| 22354 |
ashik.ali |
81 |
@Autowired
|
| 23784 |
ashik.ali |
82 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
83 |
private InventoryService inventoryService;
|
| 24465 |
tejbeer |
84 |
|
| 24203 |
amit.gupta |
85 |
@Autowired
|
|
|
86 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24123 |
tejbeer |
87 |
|
| 24106 |
tejbeer |
88 |
@Autowired
|
|
|
89 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
90 |
|
| 24106 |
tejbeer |
91 |
@Autowired
|
| 24465 |
tejbeer |
92 |
private InventoryItemRepository inventoryItemRepository;
|
|
|
93 |
|
|
|
94 |
@Autowired
|
|
|
95 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
|
|
96 |
|
|
|
97 |
@Autowired
|
| 24123 |
tejbeer |
98 |
private ItemRepository itemRepository;
|
|
|
99 |
|
|
|
100 |
@Autowired
|
| 24465 |
tejbeer |
101 |
private RetailerService retailerService;
|
|
|
102 |
|
|
|
103 |
@Autowired
|
| 24106 |
tejbeer |
104 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
105 |
|
| 24465 |
tejbeer |
106 |
@Autowired
|
|
|
107 |
FofoStoreRepository fofoStoreRepository;
|
|
|
108 |
|
| 24658 |
tejbeer |
109 |
@Autowired
|
|
|
110 |
private OrderRepository orderRepository;
|
|
|
111 |
|
| 21987 |
kshitij.so |
112 |
@Value("${saholic.api.host}")
|
|
|
113 |
private String host;
|
| 23786 |
amit.gupta |
114 |
|
| 21987 |
kshitij.so |
115 |
@Value("${saholic.api.port}")
|
|
|
116 |
private int port;
|
| 23786 |
amit.gupta |
117 |
|
| 21987 |
kshitij.so |
118 |
@Value("${saholic.api.webapp}")
|
|
|
119 |
private String webapp;
|
|
|
120 |
|
| 23786 |
amit.gupta |
121 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
122 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
123 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
124 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
125 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
126 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
127 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
128 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
129 |
searchTerm);
|
| 22927 |
ashik.ali |
130 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
131 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
132 |
}
|
| 21987 |
kshitij.so |
133 |
|
| 23786 |
amit.gupta |
134 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
135 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
136 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
137 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
138 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
139 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
140 |
if (searchTerm == null) {
|
|
|
141 |
searchTerm = "";
|
| 24052 |
amit.gupta |
142 |
}
|
| 22927 |
ashik.ali |
143 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
144 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
145 |
searchTerm);
|
| 22927 |
ashik.ali |
146 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
147 |
return "bad-inventory-snapshot";
|
|
|
148 |
}
|
|
|
149 |
|
| 23786 |
amit.gupta |
150 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
151 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
152 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
153 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
154 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
155 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
156 |
if (searchTerm == null) {
|
|
|
157 |
searchTerm = "";
|
| 24052 |
amit.gupta |
158 |
}
|
| 22927 |
ashik.ali |
159 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
160 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
161 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
162 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
163 |
return "inventory-snapshot-paginated";
|
|
|
164 |
}
|
| 23786 |
amit.gupta |
165 |
|
|
|
166 |
@RequestMapping(value = "/getCatalog")
|
|
|
167 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
168 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
169 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
170 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
171 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
172 |
if (searchTerm == null) {
|
|
|
173 |
searchTerm = "";
|
| 24052 |
amit.gupta |
174 |
}
|
| 24658 |
tejbeer |
175 |
|
| 22927 |
ashik.ali |
176 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
|
|
177 |
model.addAllAttributes(map);
|
| 24203 |
amit.gupta |
178 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 24658 |
tejbeer |
179 |
|
|
|
180 |
|
| 21987 |
kshitij.so |
181 |
return "catalog";
|
|
|
182 |
}
|
| 23786 |
amit.gupta |
183 |
|
| 24465 |
tejbeer |
184 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
185 |
private boolean hasGift(int fofoId) {
|
|
|
186 |
try {
|
| 24465 |
tejbeer |
187 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
188 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
189 |
} catch (ProfitMandiBusinessException e) {
|
|
|
190 |
return false;
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
| 23786 |
amit.gupta |
194 |
@RequestMapping(value = "/getPaginatedCatalog")
|
|
|
195 |
public String getCatalogPaginated(HttpServletRequest request,
|
|
|
196 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
197 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
198 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
199 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
200 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
201 |
if (searchTerm == null) {
|
|
|
202 |
searchTerm = "";
|
| 24052 |
amit.gupta |
203 |
}
|
| 23786 |
amit.gupta |
204 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
|
|
205 |
searchTerm);
|
| 22927 |
ashik.ali |
206 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
207 |
return "catalog-paginated";
|
|
|
208 |
}
|
|
|
209 |
|
| 23786 |
amit.gupta |
210 |
@RequestMapping(value = "/checkItemAvailability")
|
|
|
211 |
public String getItemAvailability(HttpServletRequest request,
|
|
|
212 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
|
|
213 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
214 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
215 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
|
|
216 |
loginDetails.getFofoId());
|
|
|
217 |
customCurrentInventorySnapshot
|
|
|
218 |
.setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(), host, port, webapp));
|
| 22927 |
ashik.ali |
219 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
|
|
220 |
return "current-item-availability";
|
| 23786 |
amit.gupta |
221 |
|
| 21577 |
ashik.ali |
222 |
}
|
| 23786 |
amit.gupta |
223 |
|
| 23192 |
ashik.ali |
224 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
225 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
226 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
227 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
228 |
|
| 22927 |
ashik.ali |
229 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
|
|
230 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
231 |
return "cart";
|
|
|
232 |
}
|
| 23786 |
amit.gupta |
233 |
|
| 23192 |
ashik.ali |
234 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
235 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
|
|
236 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
237 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
238 |
|
| 22927 |
ashik.ali |
239 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
|
|
240 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
241 |
return "validate-cart";
|
|
|
242 |
}
|
|
|
243 |
|
| 23786 |
amit.gupta |
244 |
@RequestMapping(value = "/grnHistory")
|
| 24123 |
tejbeer |
245 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
| 23886 |
amit.gupta |
246 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
247 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
248 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
249 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
250 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
251 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
252 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
253 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
254 |
limit, purchaseReference, searchType);
|
| 22927 |
ashik.ali |
255 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
256 |
return "grn-history";
|
| 21636 |
ashik.ali |
257 |
}
|
| 21987 |
kshitij.so |
258 |
|
| 23786 |
amit.gupta |
259 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
|
|
260 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
| 23886 |
amit.gupta |
261 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
262 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
263 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
264 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
265 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
266 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
267 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
268 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
269 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
|
|
270 |
offset, limit);
|
| 22927 |
ashik.ali |
271 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
272 |
return "grn-history-paginated";
|
|
|
273 |
}
|
|
|
274 |
|
| 23786 |
amit.gupta |
275 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
|
|
276 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
|
|
277 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
|
|
278 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
279 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
280 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
|
|
281 |
webapp);
|
| 22927 |
ashik.ali |
282 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
283 |
return "grn-details";
|
| 21636 |
ashik.ali |
284 |
}
|
| 21987 |
kshitij.so |
285 |
|
| 23786 |
amit.gupta |
286 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
|
|
287 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
|
|
288 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
|
|
289 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
290 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
291 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
|
|
292 |
host, port, webapp);
|
| 22927 |
ashik.ali |
293 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
294 |
return "grn-details";
|
| 21654 |
ashik.ali |
295 |
}
|
| 23786 |
amit.gupta |
296 |
|
| 22472 |
ashik.ali |
297 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
298 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
|
|
299 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
|
|
300 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
301 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
302 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
303 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
|
|
304 |
searchContent, offset, limit);
|
| 22927 |
ashik.ali |
305 |
model.addAllAttributes(map);
|
| 22523 |
ashik.ali |
306 |
return "item-aging";
|
|
|
307 |
}
|
| 23786 |
amit.gupta |
308 |
|
| 22523 |
ashik.ali |
309 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
310 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
|
|
311 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
312 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
|
|
313 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
314 |
|
|
|
315 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
|
|
316 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
|
|
317 |
|
| 22486 |
ashik.ali |
318 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
319 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
320 |
|
|
|
321 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
322 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
323 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
324 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
325 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| 22486 |
ashik.ali |
326 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| 23786 |
amit.gupta |
327 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
328 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
329 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
330 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
331 |
|
| 24123 |
tejbeer |
332 |
// return
|
|
|
333 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 22472 |
ashik.ali |
334 |
}
|
| 24123 |
tejbeer |
335 |
|
| 24106 |
tejbeer |
336 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| 24123 |
tejbeer |
337 |
public String FeaturePanel(HttpServletRequest request,
|
|
|
338 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24106 |
tejbeer |
339 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 21987 |
kshitij.so |
340 |
|
| 24106 |
tejbeer |
341 |
List<TagRanking> tagRanking = null;
|
|
|
342 |
|
|
|
343 |
long size = 0;
|
| 24123 |
tejbeer |
344 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
|
|
345 |
size = tagRankingRepository.selectAllCount();
|
| 24106 |
tejbeer |
346 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
347 |
if (!tagRanking.isEmpty()) {
|
| 24465 |
tejbeer |
348 |
model.addAttribute("tagRanking", tagRanking);
|
| 24106 |
tejbeer |
349 |
model.addAttribute("start", offset + 1);
|
|
|
350 |
model.addAttribute("size", size);
|
|
|
351 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
352 |
|
|
|
353 |
if (tagRanking.size() < limit) {
|
|
|
354 |
model.addAttribute("end", offset + tagRanking.size());
|
|
|
355 |
} else {
|
|
|
356 |
model.addAttribute("end", offset + limit);
|
|
|
357 |
}
|
|
|
358 |
} else {
|
|
|
359 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
360 |
model.addAttribute("size", size);
|
|
|
361 |
}
|
|
|
362 |
|
|
|
363 |
return "feature";
|
|
|
364 |
|
|
|
365 |
}
|
| 24123 |
tejbeer |
366 |
|
| 24106 |
tejbeer |
367 |
@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
|
|
|
368 |
public String getPaginatedFeaturePanel(HttpServletRequest request,
|
|
|
369 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
370 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
371 |
throws ProfitMandiBusinessException {
|
|
|
372 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
373 |
List<TagRanking> tagRanking = null;
|
|
|
374 |
|
|
|
375 |
long size = 0;
|
| 24123 |
tejbeer |
376 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
| 24106 |
tejbeer |
377 |
if (!tagRanking.isEmpty()) {
|
| 24123 |
tejbeer |
378 |
|
| 24106 |
tejbeer |
379 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
380 |
model.addAttribute("start", offset + 1);
|
|
|
381 |
model.addAttribute("size", size);
|
|
|
382 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
383 |
|
|
|
384 |
} else {
|
|
|
385 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
386 |
}
|
|
|
387 |
return "feature-paginated";
|
|
|
388 |
}
|
| 24123 |
tejbeer |
389 |
|
| 24106 |
tejbeer |
390 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
391 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
392 |
Model model) throws Exception {
|
| 24106 |
tejbeer |
393 |
|
|
|
394 |
TagRanking tagRanking = new TagRanking();
|
|
|
395 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
|
|
396 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
397 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 24123 |
tejbeer |
398 |
|
|
|
399 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
400 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
401 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
402 |
return "response";
|
|
|
403 |
}
|
|
|
404 |
|
| 24465 |
tejbeer |
405 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
|
|
406 |
public String DemoListbyFofoId(HttpServletRequest request,
|
|
|
407 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
|
|
408 |
|
|
|
409 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
410 |
.collect(Collectors.toList());
|
|
|
411 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
|
|
412 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
|
|
413 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
|
|
414 |
LOGGER.info("serailNumberList" + serailNumberList);
|
|
|
415 |
List<InventoryItem> inventoryItem = null;
|
|
|
416 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
|
|
417 |
if (fofoId > 0) {
|
|
|
418 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
|
|
419 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
420 |
for (Item Item : items) {
|
|
|
421 |
itemIds.add(Item.getId());
|
|
|
422 |
}
|
|
|
423 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
|
|
424 |
|
|
|
425 |
Set<String> serial = new HashSet<>();
|
|
|
426 |
for (InventoryItem invItem : inventoryItem) {
|
| 24658 |
tejbeer |
427 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
| 24465 |
tejbeer |
428 |
inventoryItem1.add(invItem);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
|
|
434 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
435 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
436 |
|
|
|
437 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
|
|
438 |
|
|
|
439 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
440 |
|
|
|
441 |
}
|
|
|
442 |
|
|
|
443 |
else {
|
|
|
444 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
445 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
return "live_demo_billing";
|
|
|
449 |
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
|
|
453 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
|
|
454 |
Model model) throws Exception {
|
|
|
455 |
|
|
|
456 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
|
|
457 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
|
|
458 |
|
|
|
459 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
|
|
460 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
461 |
return "response";
|
|
|
462 |
}
|
|
|
463 |
|
| 24658 |
tejbeer |
464 |
@RequestMapping(value = "/getCurrentOrder")
|
|
|
465 |
public String getCurrentOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
466 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository.selectAllOrderBeforeTwoDaysByStatus(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
467 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository.selectAllOrderofOneMonthByStatus(OrderStatus.PAYMENT_PENDING);
|
|
|
468 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository.selectAllOrderofOneMonthByStatus(OrderStatus.PAYMENT_FAILED);
|
|
|
469 |
pendingPaymentorder.addAll(failedPaymentorder);
|
|
|
470 |
|
|
|
471 |
model.addAttribute("inProcessorder",inProcessorder);
|
|
|
472 |
model.addAttribute("pendingPaymentorder",pendingPaymentorder);
|
|
|
473 |
|
|
|
474 |
LOGGER.info("failedPaymentorder" + failedPaymentorder);
|
|
|
475 |
return "review_order";
|
|
|
476 |
}
|
|
|
477 |
|
| 21577 |
ashik.ali |
478 |
}
|