| 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;
|
| 24739 |
tejbeer |
8 |
import java.util.Arrays;
|
| 24465 |
tejbeer |
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;
|
| 24798 |
tejbeer |
14 |
import java.util.stream.Stream;
|
| 21577 |
ashik.ali |
15 |
|
|
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
17 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
18 |
|
| 23886 |
amit.gupta |
19 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
20 |
import org.apache.logging.log4j.Logger;
|
| 24739 |
tejbeer |
21 |
import org.apache.thrift.TException;
|
| 24465 |
tejbeer |
22 |
import org.json.JSONObject;
|
| 21577 |
ashik.ali |
23 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
24 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
25 |
import org.springframework.beans.factory.annotation.Value;
|
| 22486 |
ashik.ali |
26 |
import org.springframework.core.io.InputStreamResource;
|
|
|
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;
|
| 21612 |
ashik.ali |
40 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
42 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
43 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
| 21577 |
ashik.ali |
44 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22472 |
ashik.ali |
45 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 21987 |
kshitij.so |
46 |
import com.spice.profitmandi.common.util.Utils;
|
| 24123 |
tejbeer |
47 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24106 |
tejbeer |
48 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
| 24465 |
tejbeer |
49 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
|
|
50 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
| 24739 |
tejbeer |
51 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
|
|
52 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 24123 |
tejbeer |
53 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24106 |
tejbeer |
54 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 24465 |
tejbeer |
55 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24203 |
amit.gupta |
56 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24465 |
tejbeer |
57 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
|
|
58 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
| 24658 |
tejbeer |
59 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 24739 |
tejbeer |
60 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 22927 |
ashik.ali |
61 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 24465 |
tejbeer |
62 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22139 |
amit.gupta |
63 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
64 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
65 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
66 |
|
| 24658 |
tejbeer |
67 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 24739 |
tejbeer |
68 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 24658 |
tejbeer |
69 |
|
| 21577 |
ashik.ali |
70 |
@Controller
|
| 24123 |
tejbeer |
71 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
72 |
public class InventoryController {
|
| 21987 |
kshitij.so |
73 |
|
| 23568 |
govind |
74 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 21987 |
kshitij.so |
75 |
|
| 21577 |
ashik.ali |
76 |
@Autowired
|
| 22927 |
ashik.ali |
77 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
78 |
|
| 22354 |
ashik.ali |
79 |
@Autowired
|
| 23784 |
ashik.ali |
80 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
81 |
private InventoryService inventoryService;
|
| 24465 |
tejbeer |
82 |
|
| 24203 |
amit.gupta |
83 |
@Autowired
|
|
|
84 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24123 |
tejbeer |
85 |
|
| 24106 |
tejbeer |
86 |
@Autowired
|
|
|
87 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
88 |
|
| 24106 |
tejbeer |
89 |
@Autowired
|
| 24465 |
tejbeer |
90 |
private InventoryItemRepository inventoryItemRepository;
|
|
|
91 |
|
|
|
92 |
@Autowired
|
|
|
93 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
|
|
94 |
|
|
|
95 |
@Autowired
|
| 24123 |
tejbeer |
96 |
private ItemRepository itemRepository;
|
|
|
97 |
|
|
|
98 |
@Autowired
|
| 24465 |
tejbeer |
99 |
private RetailerService retailerService;
|
|
|
100 |
|
|
|
101 |
@Autowired
|
| 24106 |
tejbeer |
102 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
103 |
|
| 24465 |
tejbeer |
104 |
@Autowired
|
|
|
105 |
FofoStoreRepository fofoStoreRepository;
|
|
|
106 |
|
| 24658 |
tejbeer |
107 |
@Autowired
|
|
|
108 |
private OrderRepository orderRepository;
|
|
|
109 |
|
| 24739 |
tejbeer |
110 |
@Autowired
|
|
|
111 |
private UserRepository userRepository;
|
|
|
112 |
|
| 21987 |
kshitij.so |
113 |
@Value("${saholic.api.host}")
|
|
|
114 |
private String host;
|
| 23786 |
amit.gupta |
115 |
|
| 21987 |
kshitij.so |
116 |
@Value("${saholic.api.port}")
|
|
|
117 |
private int port;
|
| 23786 |
amit.gupta |
118 |
|
| 21987 |
kshitij.so |
119 |
@Value("${saholic.api.webapp}")
|
|
|
120 |
private String webapp;
|
|
|
121 |
|
| 23786 |
amit.gupta |
122 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
123 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
124 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
125 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
126 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
127 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
128 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
129 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
130 |
searchTerm);
|
| 22927 |
ashik.ali |
131 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
132 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
133 |
}
|
| 21987 |
kshitij.so |
134 |
|
| 23786 |
amit.gupta |
135 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
136 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
137 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
138 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
139 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
140 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
141 |
if (searchTerm == null) {
|
|
|
142 |
searchTerm = "";
|
| 24052 |
amit.gupta |
143 |
}
|
| 22927 |
ashik.ali |
144 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
145 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
146 |
searchTerm);
|
| 22927 |
ashik.ali |
147 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
148 |
return "bad-inventory-snapshot";
|
|
|
149 |
}
|
|
|
150 |
|
| 23786 |
amit.gupta |
151 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
152 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
153 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
154 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
155 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
156 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
157 |
if (searchTerm == null) {
|
|
|
158 |
searchTerm = "";
|
| 24052 |
amit.gupta |
159 |
}
|
| 22927 |
ashik.ali |
160 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
161 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
162 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
163 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
164 |
return "inventory-snapshot-paginated";
|
|
|
165 |
}
|
| 23786 |
amit.gupta |
166 |
|
|
|
167 |
@RequestMapping(value = "/getCatalog")
|
|
|
168 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
169 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
170 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
171 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
172 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
173 |
if (searchTerm == null) {
|
|
|
174 |
searchTerm = "";
|
| 24052 |
amit.gupta |
175 |
}
|
| 24739 |
tejbeer |
176 |
|
| 22927 |
ashik.ali |
177 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
|
|
178 |
model.addAllAttributes(map);
|
| 24203 |
amit.gupta |
179 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 24658 |
tejbeer |
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()) {
|
| 24798 |
tejbeer |
348 |
|
|
|
349 |
Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
|
|
350 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
|
|
351 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
|
|
352 |
x -> x.getItemDescription(), (description1, description2) -> description1));
|
|
|
353 |
|
|
|
354 |
LOGGER.info("catalogDescription" + catalogDescription);
|
| 24465 |
tejbeer |
355 |
model.addAttribute("tagRanking", tagRanking);
|
| 24798 |
tejbeer |
356 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 24106 |
tejbeer |
357 |
model.addAttribute("start", offset + 1);
|
|
|
358 |
model.addAttribute("size", size);
|
|
|
359 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
360 |
|
|
|
361 |
} else {
|
|
|
362 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
363 |
model.addAttribute("size", size);
|
|
|
364 |
}
|
|
|
365 |
|
|
|
366 |
return "feature";
|
|
|
367 |
|
|
|
368 |
}
|
| 24123 |
tejbeer |
369 |
|
| 24798 |
tejbeer |
370 |
/*
|
|
|
371 |
* @RequestMapping(value = "/getPaginatedfeature", method =
|
|
|
372 |
* RequestMethod.GET) public String
|
|
|
373 |
* getPaginatedFeaturePanel(HttpServletRequest request,
|
|
|
374 |
*
|
|
|
375 |
* @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
376 |
*
|
|
|
377 |
* @RequestParam(name = "limit", defaultValue = "10") int limit, Model
|
|
|
378 |
* model) throws ProfitMandiBusinessException {
|
|
|
379 |
* LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
380 |
* List<TagRanking> tagRanking = null;
|
|
|
381 |
*
|
|
|
382 |
*
|
|
|
383 |
* long size = 0; tagRanking =
|
|
|
384 |
* tagRankingRepository.selectAllTagRanking(offset, limit); if
|
|
|
385 |
* (!tagRanking.isEmpty()) {
|
|
|
386 |
*
|
|
|
387 |
* model.addAttribute("tagRanking", tagRanking); model.addAttribute("start",
|
|
|
388 |
* offset + 1); model.addAttribute("size", size); model.addAttribute("url",
|
|
|
389 |
* "/getPaginatedfeature");
|
|
|
390 |
*
|
|
|
391 |
* } else { model.addAttribute("tagRanking", tagRanking); } return
|
|
|
392 |
* "feature-paginated"; }
|
|
|
393 |
*/
|
| 24106 |
tejbeer |
394 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
395 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
396 |
Model model) throws Exception {
|
| 24106 |
tejbeer |
397 |
|
|
|
398 |
TagRanking tagRanking = new TagRanking();
|
|
|
399 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
|
|
400 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
401 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 24123 |
tejbeer |
402 |
|
|
|
403 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
404 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
405 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
406 |
return "response";
|
|
|
407 |
}
|
|
|
408 |
|
| 24798 |
tejbeer |
409 |
@RequestMapping(value = "/removeFeature", method = RequestMethod.DELETE)
|
|
|
410 |
public String removeTagRankingEnteries(HttpServletRequest request,
|
|
|
411 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
412 |
|
|
|
413 |
tagRankingRepository.deleteById(id);
|
|
|
414 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
415 |
return "response";
|
|
|
416 |
}
|
|
|
417 |
|
| 24465 |
tejbeer |
418 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
|
|
419 |
public String DemoListbyFofoId(HttpServletRequest request,
|
|
|
420 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
|
|
421 |
|
|
|
422 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
423 |
.collect(Collectors.toList());
|
|
|
424 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
|
|
425 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
|
|
426 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
|
|
427 |
LOGGER.info("serailNumberList" + serailNumberList);
|
|
|
428 |
List<InventoryItem> inventoryItem = null;
|
|
|
429 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
|
|
430 |
if (fofoId > 0) {
|
|
|
431 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
|
|
432 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
433 |
for (Item Item : items) {
|
|
|
434 |
itemIds.add(Item.getId());
|
|
|
435 |
}
|
|
|
436 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
|
|
437 |
|
|
|
438 |
Set<String> serial = new HashSet<>();
|
|
|
439 |
for (InventoryItem invItem : inventoryItem) {
|
| 24658 |
tejbeer |
440 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
| 24465 |
tejbeer |
441 |
inventoryItem1.add(invItem);
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
|
|
447 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
448 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
449 |
|
|
|
450 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
|
|
451 |
|
|
|
452 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
453 |
|
|
|
454 |
}
|
|
|
455 |
|
|
|
456 |
else {
|
|
|
457 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
458 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
return "live_demo_billing";
|
|
|
462 |
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
|
|
466 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
|
|
467 |
Model model) throws Exception {
|
|
|
468 |
|
|
|
469 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
|
|
470 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
|
|
471 |
|
|
|
472 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
|
|
473 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
474 |
return "response";
|
|
|
475 |
}
|
|
|
476 |
|
| 24739 |
tejbeer |
477 |
@RequestMapping(value = "/getInProcessOrder", method = RequestMethod.GET)
|
|
|
478 |
public String getInProcessOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
479 |
|
|
|
480 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
|
|
481 |
.selectAllOrderBeforeTwoDaysByStatus(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
482 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository
|
| 24798 |
tejbeer |
483 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
484 |
OrderStatus.PAYMENT_PENDING);
|
| 24739 |
tejbeer |
485 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository
|
| 24798 |
tejbeer |
486 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
487 |
OrderStatus.PAYMENT_FAILED);
|
| 24658 |
tejbeer |
488 |
pendingPaymentorder.addAll(failedPaymentorder);
|
| 24739 |
tejbeer |
489 |
|
|
|
490 |
model.addAttribute("inProcessorder", inProcessorder);
|
|
|
491 |
model.addAttribute("pendingPaymentorder", pendingPaymentorder);
|
|
|
492 |
|
|
|
493 |
return "review_order";
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
@RequestMapping(value = "/getKeepInTabOrder", method = RequestMethod.GET)
|
|
|
497 |
public String getKeepInTabOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
498 |
|
|
|
499 |
List<com.spice.profitmandi.dao.entity.transaction.Order> keepatab = orderRepository
|
|
|
500 |
.selectAllOrder(OrderStatus.KEEP_A_TAB);
|
|
|
501 |
|
|
|
502 |
model.addAttribute("keepatab", keepatab);
|
|
|
503 |
|
|
|
504 |
return "keep-a-tab";
|
|
|
505 |
}
|
|
|
506 |
|
|
|
507 |
@RequestMapping(value = "/closeOrder", method = RequestMethod.POST)
|
|
|
508 |
public String closeOrder(HttpServletRequest request, @RequestParam int orderId, Model model) throws Exception {
|
| 24798 |
tejbeer |
509 |
|
| 24739 |
tejbeer |
510 |
Order order = orderRepository.selectById(orderId);
|
| 24798 |
tejbeer |
511 |
if (order != null) {
|
| 24739 |
tejbeer |
512 |
order.setStatus(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| 24798 |
tejbeer |
513 |
|
| 24739 |
tejbeer |
514 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
515 |
|
| 24798 |
tejbeer |
516 |
} else {
|
| 24739 |
tejbeer |
517 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
518 |
|
|
|
519 |
}
|
|
|
520 |
return "response";
|
| 24658 |
tejbeer |
521 |
}
|
|
|
522 |
|
| 24739 |
tejbeer |
523 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
|
|
524 |
public String cancelOrder(HttpServletRequest request, @RequestParam int orderId, @RequestParam String reason,
|
|
|
525 |
@RequestParam OrderStatus orderStatus, Model model) throws Exception {
|
|
|
526 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
527 |
User userInfo = userRepository.selectById(loginDetails.getFofoId());
|
|
|
528 |
LOGGER.info("status" + orderStatus);
|
|
|
529 |
try {
|
|
|
530 |
orderRepository.refundOrder(orderId, userInfo.getName(), reason, orderStatus);
|
|
|
531 |
|
|
|
532 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
533 |
|
|
|
534 |
} catch (TransactionServiceException | TException e) {
|
|
|
535 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
536 |
|
|
|
537 |
}
|
|
|
538 |
return "response";
|
|
|
539 |
}
|
|
|
540 |
|
| 21577 |
ashik.ali |
541 |
}
|