| 21577 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 22486 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
| 26482 |
tejbeer |
5 |
import java.io.IOException;
|
| 22486 |
ashik.ali |
6 |
import java.io.InputStream;
|
| 26279 |
amit.gupta |
7 |
import java.io.InputStreamReader;
|
| 26482 |
tejbeer |
8 |
import java.net.URISyntaxException;
|
| 23886 |
amit.gupta |
9 |
import java.time.LocalDateTime;
|
| 26279 |
amit.gupta |
10 |
import java.time.format.DateTimeFormatter;
|
| 24465 |
tejbeer |
11 |
import java.util.ArrayList;
|
| 25873 |
tejbeer |
12 |
import java.util.Arrays;
|
| 26979 |
amit.gupta |
13 |
import java.util.Collection;
|
| 24917 |
tejbeer |
14 |
import java.util.HashMap;
|
| 24465 |
tejbeer |
15 |
import java.util.HashSet;
|
| 24917 |
tejbeer |
16 |
import java.util.Iterator;
|
| 21577 |
ashik.ali |
17 |
import java.util.List;
|
| 21654 |
ashik.ali |
18 |
import java.util.Map;
|
| 24917 |
tejbeer |
19 |
import java.util.Optional;
|
| 24465 |
tejbeer |
20 |
import java.util.Set;
|
|
|
21 |
import java.util.stream.Collectors;
|
| 21577 |
ashik.ali |
22 |
|
|
|
23 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
24 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
25 |
|
| 26279 |
amit.gupta |
26 |
import org.apache.commons.csv.CSVFormat;
|
|
|
27 |
import org.apache.commons.csv.CSVParser;
|
|
|
28 |
import org.apache.commons.csv.CSVRecord;
|
| 27544 |
amit.gupta |
29 |
import org.apache.commons.io.FileUtils;
|
| 26299 |
amit.gupta |
30 |
import org.apache.commons.lang3.StringUtils;
|
| 23886 |
amit.gupta |
31 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
32 |
import org.apache.logging.log4j.Logger;
|
| 24739 |
tejbeer |
33 |
import org.apache.thrift.TException;
|
| 27583 |
tejbeer |
34 |
import org.hibernate.type.CurrencyType;
|
| 24465 |
tejbeer |
35 |
import org.json.JSONObject;
|
| 21577 |
ashik.ali |
36 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
37 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
38 |
import org.springframework.beans.factory.annotation.Value;
|
| 27544 |
amit.gupta |
39 |
import org.springframework.core.io.ClassPathResource;
|
| 22486 |
ashik.ali |
40 |
import org.springframework.core.io.InputStreamResource;
|
|
|
41 |
import org.springframework.http.HttpHeaders;
|
|
|
42 |
import org.springframework.http.HttpStatus;
|
| 25140 |
amit.gupta |
43 |
import org.springframework.http.MediaType;
|
| 22472 |
ashik.ali |
44 |
import org.springframework.http.ResponseEntity;
|
| 24917 |
tejbeer |
45 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 21577 |
ashik.ali |
46 |
import org.springframework.stereotype.Controller;
|
| 21654 |
ashik.ali |
47 |
import org.springframework.transaction.annotation.Transactional;
|
| 21577 |
ashik.ali |
48 |
import org.springframework.ui.Model;
|
| 26279 |
amit.gupta |
49 |
import org.springframework.web.bind.annotation.PostMapping;
|
| 22472 |
ashik.ali |
50 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21577 |
ashik.ali |
51 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22472 |
ashik.ali |
52 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21577 |
ashik.ali |
53 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 26279 |
amit.gupta |
54 |
import org.springframework.web.bind.annotation.RequestPart;
|
|
|
55 |
import org.springframework.web.multipart.MultipartFile;
|
| 21577 |
ashik.ali |
56 |
|
| 21987 |
kshitij.so |
57 |
import com.google.gson.Gson;
|
| 25698 |
tejbeer |
58 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 21577 |
ashik.ali |
59 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21612 |
ashik.ali |
60 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
61 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
62 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
63 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
| 24917 |
tejbeer |
64 |
import com.spice.profitmandi.common.model.NotifyItemIdModel;
|
|
|
65 |
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
|
|
|
66 |
import com.spice.profitmandi.common.model.NotifyOrderModel;
|
| 25640 |
tejbeer |
67 |
import com.spice.profitmandi.common.model.OrderCancellationModel;
|
| 25140 |
amit.gupta |
68 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 21577 |
ashik.ali |
69 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25851 |
amit.gupta |
70 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 22472 |
ashik.ali |
71 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 25140 |
amit.gupta |
72 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 24123 |
tejbeer |
73 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24950 |
tejbeer |
74 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 24106 |
tejbeer |
75 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
| 27583 |
tejbeer |
76 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 25140 |
amit.gupta |
77 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 24917 |
tejbeer |
78 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24465 |
tejbeer |
79 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
|
|
80 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
| 26031 |
tejbeer |
81 |
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
|
| 24917 |
tejbeer |
82 |
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
|
| 25066 |
tejbeer |
83 |
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
|
| 24917 |
tejbeer |
84 |
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
|
| 24739 |
tejbeer |
85 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 27723 |
tejbeer |
86 |
import com.spice.profitmandi.dao.model.BrandWiseTertiaryModel;
|
| 26482 |
tejbeer |
87 |
import com.spice.profitmandi.dao.model.ContentPojo;
|
| 27723 |
tejbeer |
88 |
import com.spice.profitmandi.dao.model.OpenPoModel;
|
|
|
89 |
import com.spice.profitmandi.dao.model.OurPurchaseModel;
|
|
|
90 |
import com.spice.profitmandi.dao.model.SecondaryOrderBillingModel;
|
| 26498 |
amit.gupta |
91 |
import com.spice.profitmandi.dao.model.Specification;
|
|
|
92 |
import com.spice.profitmandi.dao.model.SpecificationGroup;
|
| 24123 |
tejbeer |
93 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24950 |
tejbeer |
94 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 24106 |
tejbeer |
95 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 24465 |
tejbeer |
96 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26482 |
tejbeer |
97 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 24917 |
tejbeer |
98 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 24203 |
amit.gupta |
99 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 27723 |
tejbeer |
100 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 24465 |
tejbeer |
101 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
|
|
102 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
| 24917 |
tejbeer |
103 |
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
|
| 26031 |
tejbeer |
104 |
import com.spice.profitmandi.dao.repository.transaction.NotifyCancelOrderRepository;
|
| 24917 |
tejbeer |
105 |
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
|
|
|
106 |
import com.spice.profitmandi.dao.repository.transaction.NotifyItemRepository;
|
| 25066 |
tejbeer |
107 |
import com.spice.profitmandi.dao.repository.transaction.NotifyMessageRepository;
|
| 24917 |
tejbeer |
108 |
import com.spice.profitmandi.dao.repository.transaction.NotifyOrderRespository;
|
| 24658 |
tejbeer |
109 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 27723 |
tejbeer |
110 |
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
|
|
|
111 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
|
| 25851 |
amit.gupta |
112 |
import com.spice.profitmandi.service.NotificationService;
|
| 22927 |
ashik.ali |
113 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27516 |
amit.gupta |
114 |
import com.spice.profitmandi.service.order.OrderService;
|
| 24465 |
tejbeer |
115 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22139 |
amit.gupta |
116 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
117 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
118 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
119 |
|
| 24658 |
tejbeer |
120 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 24739 |
tejbeer |
121 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 24658 |
tejbeer |
122 |
|
| 21577 |
ashik.ali |
123 |
@Controller
|
| 24123 |
tejbeer |
124 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
125 |
public class InventoryController {
|
| 21987 |
kshitij.so |
126 |
|
| 23568 |
govind |
127 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 26482 |
tejbeer |
128 |
|
| 26292 |
amit.gupta |
129 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
| 21987 |
kshitij.so |
130 |
|
| 27583 |
tejbeer |
131 |
private static final List<String> imeis = Arrays.asList("351030944216680", "351030944217183", "351030944217886",
|
|
|
132 |
"351030944507286", "351081710231270", "351081710238713", "351081710238796", "351081710241279",
|
|
|
133 |
"351081710244737", "355777112655976");
|
|
|
134 |
|
| 21577 |
ashik.ali |
135 |
@Autowired
|
| 22927 |
ashik.ali |
136 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
137 |
|
| 22354 |
ashik.ali |
138 |
@Autowired
|
| 23784 |
ashik.ali |
139 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
140 |
private InventoryService inventoryService;
|
| 24465 |
tejbeer |
141 |
|
| 24203 |
amit.gupta |
142 |
@Autowired
|
| 24950 |
tejbeer |
143 |
TagListingRepository tagListingRepository;
|
|
|
144 |
|
|
|
145 |
@Autowired
|
| 24203 |
amit.gupta |
146 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24123 |
tejbeer |
147 |
|
| 24106 |
tejbeer |
148 |
@Autowired
|
|
|
149 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
150 |
|
| 24106 |
tejbeer |
151 |
@Autowired
|
| 24465 |
tejbeer |
152 |
private InventoryItemRepository inventoryItemRepository;
|
|
|
153 |
|
|
|
154 |
@Autowired
|
|
|
155 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
|
|
156 |
|
|
|
157 |
@Autowired
|
| 24123 |
tejbeer |
158 |
private ItemRepository itemRepository;
|
|
|
159 |
|
|
|
160 |
@Autowired
|
| 26512 |
amit.gupta |
161 |
private Gson gson;
|
|
|
162 |
|
|
|
163 |
@Autowired
|
| 24465 |
tejbeer |
164 |
private RetailerService retailerService;
|
|
|
165 |
|
|
|
166 |
@Autowired
|
| 24106 |
tejbeer |
167 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
168 |
|
| 24465 |
tejbeer |
169 |
@Autowired
|
|
|
170 |
FofoStoreRepository fofoStoreRepository;
|
|
|
171 |
|
| 24658 |
tejbeer |
172 |
@Autowired
|
|
|
173 |
private OrderRepository orderRepository;
|
|
|
174 |
|
| 24739 |
tejbeer |
175 |
@Autowired
|
| 24917 |
tejbeer |
176 |
private NotifyItemRepository notifyItemRepository;
|
| 24739 |
tejbeer |
177 |
|
| 24917 |
tejbeer |
178 |
@Autowired
|
|
|
179 |
private NotifyColorChangeRepository notifyColorChangeRepository;
|
|
|
180 |
|
|
|
181 |
@Autowired
|
|
|
182 |
private NotifyOrderRespository notifyOrderRespository;
|
|
|
183 |
|
|
|
184 |
@Autowired
|
| 25851 |
amit.gupta |
185 |
private NotificationService notificationService;
|
|
|
186 |
|
|
|
187 |
@Autowired
|
| 25066 |
tejbeer |
188 |
private NotifyMessageRepository notifyMessageRepository;
|
|
|
189 |
|
|
|
190 |
@Autowired
|
| 24917 |
tejbeer |
191 |
private UserAccountRepository userAccountRepository;
|
|
|
192 |
|
| 27516 |
amit.gupta |
193 |
@Autowired
|
|
|
194 |
private OrderService orderService;
|
| 27583 |
tejbeer |
195 |
|
| 21987 |
kshitij.so |
196 |
@Value("${saholic.api.host}")
|
|
|
197 |
private String host;
|
| 23786 |
amit.gupta |
198 |
|
| 21987 |
kshitij.so |
199 |
@Value("${saholic.api.port}")
|
|
|
200 |
private int port;
|
| 23786 |
amit.gupta |
201 |
|
| 21987 |
kshitij.so |
202 |
@Value("${saholic.api.webapp}")
|
|
|
203 |
private String webapp;
|
|
|
204 |
|
| 24917 |
tejbeer |
205 |
@Autowired
|
|
|
206 |
JavaMailSender mailSender;
|
|
|
207 |
|
| 26031 |
tejbeer |
208 |
@Autowired
|
|
|
209 |
private NotifyCancelOrderRepository notifyCancelOrderRepository;
|
|
|
210 |
|
| 26482 |
tejbeer |
211 |
@Autowired
|
| 27723 |
tejbeer |
212 |
private WarehousePurchaseOrderRepository warehousePurchaseOrderRepository;
|
|
|
213 |
|
|
|
214 |
@Autowired
|
|
|
215 |
private WarehouseScanRepository warehouseScanRepository;
|
|
|
216 |
|
|
|
217 |
@Autowired
|
|
|
218 |
private FofoOrderRepository fofoOrderRepository;
|
|
|
219 |
@Autowired
|
| 26482 |
tejbeer |
220 |
private Mongo mongoClient;
|
|
|
221 |
|
| 23786 |
amit.gupta |
222 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
223 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
224 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
225 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
226 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
227 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
228 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
229 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
230 |
searchTerm);
|
| 22927 |
ashik.ali |
231 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
232 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
233 |
}
|
| 21987 |
kshitij.so |
234 |
|
| 23786 |
amit.gupta |
235 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
236 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
237 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
238 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
239 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
240 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
241 |
if (searchTerm == null) {
|
|
|
242 |
searchTerm = "";
|
| 24052 |
amit.gupta |
243 |
}
|
| 22927 |
ashik.ali |
244 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
245 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
246 |
searchTerm);
|
| 22927 |
ashik.ali |
247 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
248 |
return "bad-inventory-snapshot";
|
|
|
249 |
}
|
|
|
250 |
|
| 23786 |
amit.gupta |
251 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
252 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
253 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
254 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
255 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
256 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
257 |
if (searchTerm == null) {
|
|
|
258 |
searchTerm = "";
|
| 24052 |
amit.gupta |
259 |
}
|
| 22927 |
ashik.ali |
260 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
261 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
262 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
263 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
264 |
return "inventory-snapshot-paginated";
|
|
|
265 |
}
|
| 23786 |
amit.gupta |
266 |
|
|
|
267 |
@RequestMapping(value = "/getCatalog")
|
|
|
268 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 27583 |
tejbeer |
269 |
@RequestParam(name = "limit", defaultValue = "20") int limit,
|
|
|
270 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
| 27618 |
tejbeer |
271 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId,
|
|
|
272 |
@RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories,
|
| 27596 |
tejbeer |
273 |
|
| 27618 |
tejbeer |
274 |
@RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model)
|
|
|
275 |
|
| 23786 |
amit.gupta |
276 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
277 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
278 |
if (searchTerm == null) {
|
|
|
279 |
searchTerm = "";
|
| 24052 |
amit.gupta |
280 |
}
|
| 24739 |
tejbeer |
281 |
|
| 27583 |
tejbeer |
282 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm,
|
| 27618 |
tejbeer |
283 |
itemId, brand, accesories);
|
| 22927 |
ashik.ali |
284 |
model.addAllAttributes(map);
|
| 24203 |
amit.gupta |
285 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 24658 |
tejbeer |
286 |
|
| 21987 |
kshitij.so |
287 |
return "catalog";
|
|
|
288 |
}
|
| 23786 |
amit.gupta |
289 |
|
| 24465 |
tejbeer |
290 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
291 |
private boolean hasGift(int fofoId) {
|
|
|
292 |
try {
|
| 24465 |
tejbeer |
293 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
294 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
295 |
} catch (ProfitMandiBusinessException e) {
|
|
|
296 |
return false;
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
|
| 27583 |
tejbeer |
300 |
/*
|
|
|
301 |
* @RequestMapping(value = "/getSimilarItem") public String
|
|
|
302 |
* getCatalog(HttpServletRequest request, @RequestParam(name = "offset",
|
|
|
303 |
* defaultValue = "0") int offset,
|
|
|
304 |
*
|
|
|
305 |
* @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam
|
|
|
306 |
* int catalogItemId,
|
|
|
307 |
*
|
|
|
308 |
* @RequestParam(name = "searchTerm", required = false, defaultValue = "")
|
|
|
309 |
* String searchTerm, Model model) throws ProfitMandiBusinessException
|
|
|
310 |
*
|
|
|
311 |
* { LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
312 |
*
|
|
|
313 |
* if (catalogItemId != 0) { TagListing tagListing = null; List<Item> items =
|
|
|
314 |
* itemRepository.selectAllByCatalogItemId(catalogItemId); Map<Integer, Float>
|
|
|
315 |
* itemPriceing = new HashMap<>(); List<CustomCurrentInventorySnapshot>
|
|
|
316 |
* inventoryList = new ArrayList<>();
|
|
|
317 |
*
|
|
|
318 |
* for (Item item : items) { tagListing =
|
|
|
319 |
* tagListingRepository.selectByItemId(item.getId());
|
|
|
320 |
* CustomCurrentInventorySnapshot customCurrentInventorySnapshot =
|
|
|
321 |
* inventoryService .checkItemAvailability(item.getId(),
|
|
|
322 |
* loginDetails.getFofoId()); inventoryList.add(customCurrentInventorySnapshot);
|
|
|
323 |
* itemPriceing.put(item.getId(), tagListing.getMop()); } if (tagListing !=
|
|
|
324 |
* null) {
|
|
|
325 |
*
|
|
|
326 |
* float tagStartPrice = tagListing.getMop() - 1000; float tagEndPrice =
|
|
|
327 |
* tagListing.getMop() + 2000; List<TagListing> tagMoplists =
|
|
|
328 |
* tagListingRepository.selectAllBetweenMopPrice(tagStartPrice, tagEndPrice);
|
|
|
329 |
*
|
|
|
330 |
* for (TagListing tagListings : tagMoplists) {
|
|
|
331 |
*
|
|
|
332 |
* int TagListingItemid = tagListings.getItemId();
|
|
|
333 |
*
|
|
|
334 |
* itemPriceing.put(TagListingItemid, tagListings.getMop());
|
|
|
335 |
* CustomCurrentInventorySnapshot customCurrentInventorySnapshotMopPrice =
|
|
|
336 |
* inventoryService .checkItemAvailability(TagListingItemid,
|
|
|
337 |
* loginDetails.getFofoId());
|
|
|
338 |
*
|
|
|
339 |
* inventoryList.add(customCurrentInventorySnapshotMopPrice); }
|
|
|
340 |
*
|
|
|
341 |
* }
|
|
|
342 |
*
|
|
|
343 |
* else { LOGGER.info("tagBrandlist is null"); }
|
|
|
344 |
*
|
|
|
345 |
* model.addAttribute("inventoryLists", inventoryList);
|
|
|
346 |
* model.addAttribute("itemPriceing", itemPriceing);
|
|
|
347 |
*
|
|
|
348 |
* }
|
|
|
349 |
*
|
|
|
350 |
* return "catalog-similar-Id"; }
|
|
|
351 |
*/
|
| 23786 |
amit.gupta |
352 |
@RequestMapping(value = "/getPaginatedCatalog")
|
|
|
353 |
public String getCatalogPaginated(HttpServletRequest request,
|
|
|
354 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 27583 |
tejbeer |
355 |
@RequestParam(name = "limit", defaultValue = "20") int limit,
|
|
|
356 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm,
|
| 27596 |
tejbeer |
357 |
@RequestParam(name = "itemId", required = false, defaultValue = "0") int itemId,
|
| 27618 |
tejbeer |
358 |
@RequestParam(name = "accesories", required = false, defaultValue = "0") boolean accesories,
|
|
|
359 |
@RequestParam(name = "brand", required = false, defaultValue = "") String brand, Model model)
|
| 23786 |
amit.gupta |
360 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
361 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
362 |
if (searchTerm == null) {
|
|
|
363 |
searchTerm = "";
|
| 24052 |
amit.gupta |
364 |
}
|
| 23786 |
amit.gupta |
365 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
| 27618 |
tejbeer |
366 |
searchTerm, itemId, brand, accesories);
|
| 22927 |
ashik.ali |
367 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
368 |
return "catalog-paginated";
|
|
|
369 |
}
|
|
|
370 |
|
| 23786 |
amit.gupta |
371 |
@RequestMapping(value = "/checkItemAvailability")
|
|
|
372 |
public String getItemAvailability(HttpServletRequest request,
|
|
|
373 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
|
|
374 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
375 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
376 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
|
|
377 |
loginDetails.getFofoId());
|
| 25812 |
amit.gupta |
378 |
/*
|
|
|
379 |
* customCurrentInventorySnapshot
|
|
|
380 |
* .setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(
|
|
|
381 |
* ), host, port, webapp));
|
|
|
382 |
*/
|
| 22927 |
ashik.ali |
383 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
|
|
384 |
return "current-item-availability";
|
| 23786 |
amit.gupta |
385 |
|
| 21577 |
ashik.ali |
386 |
}
|
| 23786 |
amit.gupta |
387 |
|
| 23192 |
ashik.ali |
388 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
389 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
390 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
391 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
392 |
|
| 22927 |
ashik.ali |
393 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
|
|
394 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
395 |
return "cart";
|
|
|
396 |
}
|
| 23786 |
amit.gupta |
397 |
|
| 23192 |
ashik.ali |
398 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
399 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
|
|
400 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
401 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
402 |
|
| 22927 |
ashik.ali |
403 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
|
|
404 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
405 |
return "validate-cart";
|
|
|
406 |
}
|
|
|
407 |
|
| 23786 |
amit.gupta |
408 |
@RequestMapping(value = "/grnHistory")
|
| 24123 |
tejbeer |
409 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
| 23886 |
amit.gupta |
410 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
411 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
412 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
413 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
414 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
415 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
416 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
417 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
418 |
limit, purchaseReference, searchType);
|
| 22927 |
ashik.ali |
419 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
420 |
return "grn-history";
|
| 21636 |
ashik.ali |
421 |
}
|
| 21987 |
kshitij.so |
422 |
|
| 25140 |
amit.gupta |
423 |
@RequestMapping(value = "/downloadPurchaseInvoices")
|
|
|
424 |
public ResponseEntity<?> downloadPurchaseInvoices(HttpServletRequest request,
|
|
|
425 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
426 |
@RequestParam(required = false) LocalDateTime endTime,
|
|
|
427 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
428 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
429 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
430 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
431 |
throws ProfitMandiBusinessException {
|
|
|
432 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
433 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
434 |
limit, purchaseReference, searchType);
|
|
|
435 |
|
|
|
436 |
List<FofoOrder> fofoOrders = (List<FofoOrder>) map.get("saleHistories");
|
|
|
437 |
|
|
|
438 |
if (fofoOrders.size() == 0) {
|
|
|
439 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
443 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
444 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
|
|
445 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
446 |
List<PdfModel> pdfModels = new ArrayList<>();
|
| 25371 |
tejbeer |
447 |
/*
|
|
|
448 |
* for (FofoOrder fofoOrder : fofoOrders) { try {
|
|
|
449 |
* pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId())); } catch
|
|
|
450 |
* (Exception e) {
|
|
|
451 |
* LOGGER.info("could not create invoice for {}, invoice number {}",
|
|
|
452 |
* fofoOrder.getId(), fofoOrder.getInvoiceNumber()); } }
|
|
|
453 |
*/
|
| 25140 |
amit.gupta |
454 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
|
|
455 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
456 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
457 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
458 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
459 |
}
|
|
|
460 |
|
| 23786 |
amit.gupta |
461 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
|
|
462 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
| 23886 |
amit.gupta |
463 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
464 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
465 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
466 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
467 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
468 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
469 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
470 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
471 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
|
|
472 |
offset, limit);
|
| 22927 |
ashik.ali |
473 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
474 |
return "grn-history-paginated";
|
|
|
475 |
}
|
|
|
476 |
|
| 23786 |
amit.gupta |
477 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
|
|
478 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
|
|
479 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
|
|
480 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
481 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
482 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
|
|
483 |
webapp);
|
| 22927 |
ashik.ali |
484 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
485 |
return "grn-details";
|
| 21636 |
ashik.ali |
486 |
}
|
| 21987 |
kshitij.so |
487 |
|
| 23786 |
amit.gupta |
488 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
|
|
489 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
|
|
490 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
|
|
491 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
492 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
493 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
|
|
494 |
host, port, webapp);
|
| 22927 |
ashik.ali |
495 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
496 |
return "grn-details";
|
| 21654 |
ashik.ali |
497 |
}
|
| 23786 |
amit.gupta |
498 |
|
| 26248 |
amit.gupta |
499 |
@RequestMapping(value = "/activatedImeis")
|
|
|
500 |
public String activatedImeis(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
501 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
502 |
|
|
|
503 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(loginDetails.getFofoId());
|
|
|
504 |
inventoryItems.stream().forEach(x -> {
|
|
|
505 |
try {
|
|
|
506 |
x.setItem(itemRepository.selectById(x.getItemId()));
|
|
|
507 |
} catch (Exception e) {
|
|
|
508 |
e.printStackTrace();
|
|
|
509 |
}
|
|
|
510 |
});
|
|
|
511 |
model.addAttribute("inventoryItems", inventoryItems);
|
|
|
512 |
return "activated-imeis";
|
|
|
513 |
}
|
| 27583 |
tejbeer |
514 |
|
| 27516 |
amit.gupta |
515 |
@RequestMapping(value = "/view-invoices")
|
|
|
516 |
public String viewInvoices(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
517 |
return "view-dummy-invoices";
|
|
|
518 |
}
|
| 27583 |
tejbeer |
519 |
|
| 27516 |
amit.gupta |
520 |
@RequestMapping(value = "/dummy-invoices")
|
| 27583 |
tejbeer |
521 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request, @RequestParam String serialNumber,
|
|
|
522 |
Model model) throws ProfitMandiBusinessException {
|
| 27544 |
amit.gupta |
523 |
byte[] bytes = null;
|
| 27583 |
tejbeer |
524 |
if (!imeis.contains(serialNumber)) {
|
|
|
525 |
|
| 27544 |
amit.gupta |
526 |
PdfModel pdfModel = orderService.getDummyPdfModel(serialNumber);
|
|
|
527 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
528 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
|
|
529 |
bytes = byteArrayOutputStream.toByteArray();
|
|
|
530 |
} else {
|
|
|
531 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
|
|
532 |
try {
|
|
|
533 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
| 27583 |
tejbeer |
534 |
} catch (Exception e) {
|
|
|
535 |
|
| 27544 |
amit.gupta |
536 |
}
|
|
|
537 |
}
|
| 27516 |
amit.gupta |
538 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
539 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| 27544 |
amit.gupta |
540 |
headers.set("Content-disposition", "inline; filename=invoice-" + serialNumber + ".pdf");
|
|
|
541 |
headers.setContentLength(bytes.length);
|
|
|
542 |
final InputStream inputStream = new ByteArrayInputStream(bytes);
|
| 27516 |
amit.gupta |
543 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
544 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
545 |
}
|
| 26248 |
amit.gupta |
546 |
|
| 22472 |
ashik.ali |
547 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
548 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
|
|
549 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
|
|
550 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
551 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
552 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
553 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
|
|
554 |
searchContent, offset, limit);
|
| 22927 |
ashik.ali |
555 |
model.addAllAttributes(map);
|
| 22523 |
ashik.ali |
556 |
return "item-aging";
|
|
|
557 |
}
|
| 23786 |
amit.gupta |
558 |
|
| 22523 |
ashik.ali |
559 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
560 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
|
|
561 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
562 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
|
|
563 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
564 |
|
|
|
565 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
|
|
566 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
|
|
567 |
|
| 22486 |
ashik.ali |
568 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
569 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
570 |
|
|
|
571 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
572 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
573 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
574 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
575 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| 22486 |
ashik.ali |
576 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| 23786 |
amit.gupta |
577 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
578 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
579 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
580 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 22472 |
ashik.ali |
581 |
}
|
| 27583 |
tejbeer |
582 |
|
| 26968 |
amit.gupta |
583 |
@RequestMapping(value = "/aging-report", method = RequestMethod.GET)
|
| 27583 |
tejbeer |
584 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request)
|
|
|
585 |
throws ProfitMandiBusinessException {
|
|
|
586 |
|
|
|
587 |
List<Integer> intervals = Arrays.asList(5, 15, 30, 45);
|
| 26961 |
amit.gupta |
588 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(intervals)
|
| 26979 |
amit.gupta |
589 |
.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
590 |
LOGGER.info("Fofo Id {}", inventoryItemAgingModels.get(0).getFofoId());
|
| 26961 |
amit.gupta |
591 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
592 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 27583 |
tejbeer |
593 |
|
| 26961 |
amit.gupta |
594 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
595 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
596 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
597 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
598 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
|
|
599 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
|
|
600 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
601 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
602 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
603 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
604 |
}
|
| 24123 |
tejbeer |
605 |
|
| 24106 |
tejbeer |
606 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| 25371 |
tejbeer |
607 |
public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
|
| 21987 |
kshitij.so |
608 |
|
| 24106 |
tejbeer |
609 |
List<TagRanking> tagRanking = null;
|
| 25362 |
tejbeer |
610 |
tagRanking = tagRankingRepository.getAllTagRanking();
|
| 24106 |
tejbeer |
611 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
612 |
if (!tagRanking.isEmpty()) {
|
| 25371 |
tejbeer |
613 |
Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| 24798 |
tejbeer |
614 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
|
|
615 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
|
|
616 |
x -> x.getItemDescription(), (description1, description2) -> description1));
|
|
|
617 |
|
|
|
618 |
LOGGER.info("catalogDescription" + catalogDescription);
|
| 24465 |
tejbeer |
619 |
model.addAttribute("tagRanking", tagRanking);
|
| 24798 |
tejbeer |
620 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 24106 |
tejbeer |
621 |
|
|
|
622 |
} else {
|
|
|
623 |
model.addAttribute("tagRanking", tagRanking);
|
| 25362 |
tejbeer |
624 |
|
| 24106 |
tejbeer |
625 |
}
|
|
|
626 |
|
|
|
627 |
return "feature";
|
|
|
628 |
|
|
|
629 |
}
|
| 24123 |
tejbeer |
630 |
|
| 26279 |
amit.gupta |
631 |
@PostMapping(value = "/imei/upload")
|
| 26294 |
amit.gupta |
632 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
| 26279 |
amit.gupta |
633 |
throws Exception {
|
| 26482 |
tejbeer |
634 |
/*
|
|
|
635 |
* if(brand==null) { throw new
|
|
|
636 |
* ProfitMandiBusinessException("Please select brand", "Brand empty",
|
|
|
637 |
* "Brand required"); }
|
|
|
638 |
*/
|
| 26279 |
amit.gupta |
639 |
List<CSVRecord> masterDataList = readFile(file);
|
|
|
640 |
|
| 26482 |
tejbeer |
641 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream()
|
|
|
642 |
.collect(Collectors.toMap(x -> x.get(0).trim(), x -> {
|
|
|
643 |
if (!StringUtils.isEmpty(x.get(1).trim())) {
|
|
|
644 |
return LocalDateTime.parse((String) (x.get(1).trim()), formatter);
|
| 26299 |
amit.gupta |
645 |
} else {
|
|
|
646 |
return null;
|
|
|
647 |
}
|
|
|
648 |
}));
|
|
|
649 |
inventoryService.addActivatedImeis(imeisActivationMap);
|
|
|
650 |
model.addAttribute("response", true);
|
| 26294 |
amit.gupta |
651 |
return "response";
|
| 26279 |
amit.gupta |
652 |
}
|
|
|
653 |
|
|
|
654 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
|
|
655 |
List<CSVRecord> records = null;
|
|
|
656 |
try (CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT)) {
|
|
|
657 |
records = parser.getRecords();
|
|
|
658 |
if (records.size() < 2) {
|
|
|
659 |
throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
|
|
|
660 |
}
|
|
|
661 |
records.remove(0);
|
| 26482 |
tejbeer |
662 |
} catch (Exception e) {
|
| 26279 |
amit.gupta |
663 |
throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
|
|
|
664 |
}
|
|
|
665 |
return records;
|
|
|
666 |
}
|
|
|
667 |
|
| 24106 |
tejbeer |
668 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
669 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
670 |
Model model) throws Exception {
|
| 25371 |
tejbeer |
671 |
TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
672 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
673 |
if (tagRanking == null) {
|
|
|
674 |
tagRanking = new TagRanking();
|
|
|
675 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
| 25363 |
tejbeer |
676 |
}
|
| 24106 |
tejbeer |
677 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 25363 |
tejbeer |
678 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
| 25371 |
tejbeer |
679 |
|
| 24123 |
tejbeer |
680 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
681 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
682 |
return "response";
|
|
|
683 |
}
|
|
|
684 |
|
| 24798 |
tejbeer |
685 |
@RequestMapping(value = "/removeFeature", method = RequestMethod.DELETE)
|
|
|
686 |
public String removeTagRankingEnteries(HttpServletRequest request,
|
|
|
687 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| 24917 |
tejbeer |
688 |
|
| 24798 |
tejbeer |
689 |
tagRankingRepository.deleteById(id);
|
|
|
690 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
691 |
return "response";
|
|
|
692 |
}
|
|
|
693 |
|
| 24465 |
tejbeer |
694 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
|
|
695 |
public String DemoListbyFofoId(HttpServletRequest request,
|
|
|
696 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
|
|
697 |
|
|
|
698 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
699 |
.collect(Collectors.toList());
|
|
|
700 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
|
|
701 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
|
|
702 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
|
|
703 |
LOGGER.info("serailNumberList" + serailNumberList);
|
|
|
704 |
List<InventoryItem> inventoryItem = null;
|
|
|
705 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
|
|
706 |
if (fofoId > 0) {
|
|
|
707 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
|
|
708 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
709 |
for (Item Item : items) {
|
|
|
710 |
itemIds.add(Item.getId());
|
|
|
711 |
}
|
|
|
712 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
|
|
713 |
|
|
|
714 |
Set<String> serial = new HashSet<>();
|
|
|
715 |
for (InventoryItem invItem : inventoryItem) {
|
| 24658 |
tejbeer |
716 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
| 24465 |
tejbeer |
717 |
inventoryItem1.add(invItem);
|
| 25371 |
tejbeer |
718 |
|
| 24465 |
tejbeer |
719 |
}
|
|
|
720 |
|
|
|
721 |
}
|
|
|
722 |
|
|
|
723 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
|
|
724 |
model.addAttribute("customRetailers", customRetailers);
|
| 25371 |
tejbeer |
725 |
|
| 24465 |
tejbeer |
726 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
727 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
|
|
728 |
|
|
|
729 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
730 |
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
else {
|
|
|
734 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
735 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
736 |
}
|
|
|
737 |
|
|
|
738 |
return "live_demo_billing";
|
|
|
739 |
|
|
|
740 |
}
|
|
|
741 |
|
|
|
742 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
|
|
743 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
|
|
744 |
Model model) throws Exception {
|
|
|
745 |
|
|
|
746 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
|
|
747 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
|
|
748 |
|
|
|
749 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
|
|
750 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
751 |
return "response";
|
|
|
752 |
}
|
|
|
753 |
|
| 24739 |
tejbeer |
754 |
@RequestMapping(value = "/getInProcessOrder", method = RequestMethod.GET)
|
|
|
755 |
public String getInProcessOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
756 |
|
|
|
757 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
| 25067 |
tejbeer |
758 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 24917 |
tejbeer |
759 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
760 |
List<Integer> orderIds = new ArrayList<>();
|
|
|
761 |
if (!inProcessorder.isEmpty()) {
|
|
|
762 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
|
|
763 |
retailerIds.add(order.getRetailerId());
|
|
|
764 |
orderIds.add(order.getId());
|
| 24739 |
tejbeer |
765 |
|
| 24917 |
tejbeer |
766 |
}
|
| 24739 |
tejbeer |
767 |
|
| 25640 |
tejbeer |
768 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
|
|
769 |
for (NotifyOrder notifyOrder : notify) {
|
| 25449 |
tejbeer |
770 |
|
| 25640 |
tejbeer |
771 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
| 25449 |
tejbeer |
772 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
| 25640 |
tejbeer |
773 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 25449 |
tejbeer |
774 |
}
|
| 25640 |
tejbeer |
775 |
}
|
| 24950 |
tejbeer |
776 |
|
| 24917 |
tejbeer |
777 |
Map<Integer, Optional<NotifyOrder>> notifyOrders = notifyOrderRespository.selectByorderIds(orderIds)
|
|
|
778 |
.stream().collect(Collectors.groupingBy(NotifyOrder::getOrderId,
|
|
|
779 |
Collectors.maxBy((x1, x2) -> x1.getId() - x2.getId())));
|
| 24950 |
tejbeer |
780 |
|
| 26110 |
tejbeer |
781 |
Map<Integer, NotifyCancel> notifyCancelOrders = notifyCancelOrderRepository.selectByOrderIds(orderIds)
|
|
|
782 |
.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
| 24917 |
tejbeer |
783 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
784 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
785 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository
|
|
|
786 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
787 |
OrderStatus.PAYMENT_PENDING);
|
|
|
788 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository
|
|
|
789 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
790 |
OrderStatus.PAYMENT_FAILED);
|
|
|
791 |
pendingPaymentorder.addAll(failedPaymentorder);
|
|
|
792 |
|
|
|
793 |
model.addAttribute("inProcessorder", inProcessorder);
|
|
|
794 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
795 |
model.addAttribute("pendingPaymentorder", pendingPaymentorder);
|
|
|
796 |
model.addAttribute("latestNotifyOrders", notifyOrders);
|
| 26110 |
tejbeer |
797 |
model.addAttribute("notifyCancelOrders", notifyCancelOrders);
|
| 24917 |
tejbeer |
798 |
} else {
|
|
|
799 |
model.addAttribute("inProcessorder", inProcessorder);
|
|
|
800 |
}
|
| 24739 |
tejbeer |
801 |
return "review_order";
|
|
|
802 |
}
|
|
|
803 |
|
|
|
804 |
@RequestMapping(value = "/getKeepInTabOrder", method = RequestMethod.GET)
|
|
|
805 |
public String getKeepInTabOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
806 |
|
|
|
807 |
List<com.spice.profitmandi.dao.entity.transaction.Order> keepatab = orderRepository
|
|
|
808 |
.selectAllOrder(OrderStatus.KEEP_A_TAB);
|
|
|
809 |
|
|
|
810 |
model.addAttribute("keepatab", keepatab);
|
|
|
811 |
|
|
|
812 |
return "keep-a-tab";
|
|
|
813 |
}
|
|
|
814 |
|
|
|
815 |
@RequestMapping(value = "/closeOrder", method = RequestMethod.POST)
|
|
|
816 |
public String closeOrder(HttpServletRequest request, @RequestParam int orderId, Model model) throws Exception {
|
| 24798 |
tejbeer |
817 |
|
| 24739 |
tejbeer |
818 |
Order order = orderRepository.selectById(orderId);
|
| 24798 |
tejbeer |
819 |
if (order != null) {
|
| 24739 |
tejbeer |
820 |
order.setStatus(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| 24798 |
tejbeer |
821 |
|
| 24739 |
tejbeer |
822 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
823 |
|
| 24798 |
tejbeer |
824 |
} else {
|
| 24739 |
tejbeer |
825 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
826 |
|
|
|
827 |
}
|
|
|
828 |
return "response";
|
| 24658 |
tejbeer |
829 |
}
|
|
|
830 |
|
| 25640 |
tejbeer |
831 |
@RequestMapping(value = "/getcancelOrderItems", method = RequestMethod.GET)
|
|
|
832 |
public String getcancelOrderItems(HttpServletRequest request, @RequestParam int itemId, Model model)
|
|
|
833 |
throws Exception {
|
|
|
834 |
|
|
|
835 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
|
|
836 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
837 |
|
|
|
838 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
839 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
|
|
840 |
retailerIds.add(order.getRetailerId());
|
|
|
841 |
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
845 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
846 |
|
|
|
847 |
model.addAttribute("inProcessCancelOrder", inProcessselectedOrder);
|
|
|
848 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
849 |
|
|
|
850 |
return "cancel-order-modal";
|
|
|
851 |
}
|
|
|
852 |
|
| 24739 |
tejbeer |
853 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
| 25640 |
tejbeer |
854 |
public String cancelOrder(HttpServletRequest request, @RequestBody OrderCancellationModel orderCancellationModel,
|
|
|
855 |
Model model) throws Exception {
|
| 24739 |
tejbeer |
856 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 25640 |
tejbeer |
857 |
LOGGER.info("orderId" + orderCancellationModel.getOrderIds());
|
|
|
858 |
|
| 24739 |
tejbeer |
859 |
try {
|
| 25699 |
tejbeer |
860 |
// List<Order> orders =
|
|
|
861 |
// orderRepository.selectByOrderIds(orderCancellationModel.getOrderIds());
|
| 25640 |
tejbeer |
862 |
|
| 25699 |
tejbeer |
863 |
List<Order> orders = orderRepository.selectByOrderIdsOrdersStatus(orderCancellationModel.getOrderIds(),
|
|
|
864 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
865 |
if (!orders.isEmpty()) {
|
|
|
866 |
for (Order order : orders) {
|
| 25640 |
tejbeer |
867 |
|
| 25699 |
tejbeer |
868 |
orderRepository.refundOrder(order.getId(), loginDetails.getEmailId(),
|
|
|
869 |
orderCancellationModel.getReason(), OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
|
|
870 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(order.getId());
|
|
|
871 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
|
|
872 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
|
|
873 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
|
|
874 |
}
|
| 25449 |
tejbeer |
875 |
}
|
| 25699 |
tejbeer |
876 |
sendCancellationNotificationToPartner(order, orderCancellationModel.getReason());
|
|
|
877 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
878 |
|
| 25640 |
tejbeer |
879 |
}
|
|
|
880 |
}
|
| 24739 |
tejbeer |
881 |
} catch (TransactionServiceException | TException e) {
|
|
|
882 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
883 |
|
|
|
884 |
}
|
| 25640 |
tejbeer |
885 |
|
| 24739 |
tejbeer |
886 |
return "response";
|
|
|
887 |
}
|
|
|
888 |
|
| 25039 |
amit.gupta |
889 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
|
|
890 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|
| 25383 |
tejbeer |
891 |
|
| 25851 |
amit.gupta |
892 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
893 |
sendNotificationModel.setCampaignName("Order Cancellation");
|
|
|
894 |
sendNotificationModel.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
|
| 25140 |
amit.gupta |
895 |
order.getLineItem().getQuantity()));
|
| 25851 |
amit.gupta |
896 |
sendNotificationModel.setType("url");
|
|
|
897 |
sendNotificationModel.setMessage(reason);
|
| 26482 |
tejbeer |
898 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/orderDetails");
|
| 25851 |
amit.gupta |
899 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
900 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 25857 |
tejbeer |
901 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| 25873 |
tejbeer |
902 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 25851 |
amit.gupta |
903 |
notificationService.sendNotification(sendNotificationModel);
|
| 25140 |
amit.gupta |
904 |
|
| 25039 |
amit.gupta |
905 |
}
|
|
|
906 |
|
| 24917 |
tejbeer |
907 |
@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
|
|
|
908 |
public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId,
|
|
|
909 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
|
|
910 |
|
| 24950 |
tejbeer |
911 |
List<Item> availableColorItems = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
|
|
912 |
Iterator<Item> itemsIterator = availableColorItems.iterator();
|
| 24917 |
tejbeer |
913 |
|
| 24950 |
tejbeer |
914 |
while (itemsIterator.hasNext()) {
|
|
|
915 |
Item item = itemsIterator.next();
|
|
|
916 |
TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
|
|
|
917 |
|
|
|
918 |
if (itemTagListing == null) {
|
|
|
919 |
itemsIterator.remove();
|
|
|
920 |
|
|
|
921 |
}
|
|
|
922 |
|
|
|
923 |
else if (!itemTagListing.isActive()) {
|
|
|
924 |
itemsIterator.remove();
|
|
|
925 |
|
|
|
926 |
}
|
|
|
927 |
}
|
|
|
928 |
|
| 24917 |
tejbeer |
929 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
|
|
930 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
931 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
932 |
|
|
|
933 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
|
|
934 |
retailerIds.add(order.getRetailerId());
|
|
|
935 |
|
|
|
936 |
}
|
|
|
937 |
|
|
|
938 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
939 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| 24950 |
tejbeer |
940 |
LOGGER.info("item" + availableColorItems);
|
|
|
941 |
model.addAttribute("item", availableColorItems);
|
| 24917 |
tejbeer |
942 |
model.addAttribute("inProcessselectedOrder", inProcessselectedOrder);
|
|
|
943 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
944 |
|
|
|
945 |
return "notify-order-modal";
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
@RequestMapping(value = "/notifyOrder", method = RequestMethod.POST)
|
|
|
949 |
public String NotifyOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model)
|
|
|
950 |
throws Exception {
|
|
|
951 |
|
|
|
952 |
com.spice.profitmandi.dao.entity.transaction.NotifyItem notifyItem = null;
|
|
|
953 |
List<Integer> orderIds = new ArrayList<>();
|
|
|
954 |
|
|
|
955 |
NotifyColorChange notifytimestamp = new NotifyColorChange();
|
|
|
956 |
notifytimestamp.setCreated(LocalDateTime.now());
|
|
|
957 |
notifyColorChangeRepository.persist(notifytimestamp);
|
| 25066 |
tejbeer |
958 |
NotifyMessage notifyMessage = new NotifyMessage();
|
|
|
959 |
notifyMessage.setNotifyId(notifytimestamp.getId());
|
|
|
960 |
notifyMessage.setNotifyMessages(notifyOrderModel.getMessage());
|
| 25140 |
amit.gupta |
961 |
notifyMessageRepository.persist(notifyMessage);
|
| 24917 |
tejbeer |
962 |
for (NotifyItemIdModel itemid : notifyOrderModel.getItemIds()) {
|
|
|
963 |
|
|
|
964 |
notifyItem = new com.spice.profitmandi.dao.entity.transaction.NotifyItem();
|
|
|
965 |
notifyItem.setItemId(itemid.getItemId());
|
|
|
966 |
notifyItem.setResponseTime(itemid.getResponseTime());
|
|
|
967 |
notifyItem.setProcuredDate(itemid.getProcuredTime());
|
|
|
968 |
notifyItem.setNotifyColorchangeId(notifytimestamp.getId());
|
|
|
969 |
notifyItemRepository.persist(notifyItem);
|
|
|
970 |
LOGGER.info("notifyItem" + notifyItem);
|
|
|
971 |
}
|
|
|
972 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
|
|
973 |
List<NotifyOrder> existingOrder = notifyOrderRespository.selectByOrder(st.getOrderId());
|
| 24950 |
tejbeer |
974 |
if (!existingOrder.isEmpty()) {
|
| 24917 |
tejbeer |
975 |
LOGGER.info("existingOrder" + existingOrder);
|
| 24950 |
tejbeer |
976 |
for (NotifyOrder notifyOrder : existingOrder) {
|
|
|
977 |
if (NotifyStatus.pending == notifyOrder.getStatus()) {
|
|
|
978 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 26105 |
tejbeer |
979 |
notifyOrder.setUpdateTimestamp(LocalDateTime.now());
|
| 24950 |
tejbeer |
980 |
}
|
| 24917 |
tejbeer |
981 |
}
|
|
|
982 |
}
|
|
|
983 |
NotifyOrder orderStatus = new NotifyOrder();
|
|
|
984 |
orderStatus.setOrderId(st.getOrderId());
|
|
|
985 |
orderStatus.setNotifyId(notifytimestamp.getId());
|
|
|
986 |
orderStatus.setItemId(st.getOlditemId());
|
|
|
987 |
Order id = orderRepository.selectById(st.getOrderId());
|
|
|
988 |
orderStatus.setFofoId(id.getRetailerId());
|
|
|
989 |
orderStatus.setStatus(NotifyStatus.pending);
|
|
|
990 |
notifyOrderRespository.persist(orderStatus);
|
|
|
991 |
|
|
|
992 |
LOGGER.info("itemStatus" + orderStatus);
|
|
|
993 |
orderIds.add(st.getOrderId());
|
|
|
994 |
}
|
|
|
995 |
|
|
|
996 |
LOGGER.info("orderIds" + orderIds);
|
|
|
997 |
List<Order> orders = orderRepository.selectByOrderIds(orderIds);
|
|
|
998 |
for (Order order : orders) {
|
|
|
999 |
LOGGER.info("order" + order.getId());
|
|
|
1000 |
|
| 25140 |
amit.gupta |
1001 |
NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
|
|
|
1002 |
|
| 25851 |
amit.gupta |
1003 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
1004 |
sendNotificationModel.setCampaignName("Notify Partner");
|
|
|
1005 |
sendNotificationModel.setMessage(message.getNotifyMessages());
|
|
|
1006 |
sendNotificationModel.setType("url");
|
|
|
1007 |
sendNotificationModel.setTitle("Alert");
|
| 26959 |
tejbeer |
1008 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyOrder");
|
| 25851 |
amit.gupta |
1009 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
1010 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 25857 |
tejbeer |
1011 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| 25873 |
tejbeer |
1012 |
|
|
|
1013 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 25851 |
amit.gupta |
1014 |
notificationService.sendNotification(sendNotificationModel);
|
| 25140 |
amit.gupta |
1015 |
|
| 24917 |
tejbeer |
1016 |
}
|
|
|
1017 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1018 |
return "response";
|
|
|
1019 |
}
|
|
|
1020 |
|
|
|
1021 |
@RequestMapping(value = "/getAllNotifyOrder", method = RequestMethod.GET)
|
|
|
1022 |
public String getAllNotifyOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 24950 |
tejbeer |
1023 |
List<NotifyOrder> notifyOrders = null;
|
| 24917 |
tejbeer |
1024 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
| 25067 |
tejbeer |
1025 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 24950 |
tejbeer |
1026 |
|
| 24917 |
tejbeer |
1027 |
List<Integer> orderIds = new ArrayList<>();
|
| 24950 |
tejbeer |
1028 |
if (!inProcessorder.isEmpty()) {
|
| 24917 |
tejbeer |
1029 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
| 24950 |
tejbeer |
1030 |
|
| 24917 |
tejbeer |
1031 |
orderIds.add(order.getId());
|
|
|
1032 |
|
| 24950 |
tejbeer |
1033 |
}
|
|
|
1034 |
notifyOrders = notifyOrderRespository.selectByorderIds(orderIds);
|
|
|
1035 |
Set<Integer> oldItemIds = new HashSet<>();
|
|
|
1036 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
1037 |
List<Integer> notifyIds = new ArrayList<>();
|
|
|
1038 |
if (!notifyOrders.isEmpty()) {
|
|
|
1039 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
|
|
1040 |
oldItemIds.add(notifyOrder.getItemId());
|
|
|
1041 |
fofoIds.add(notifyOrder.getFofoId());
|
|
|
1042 |
notifyIds.add(notifyOrder.getNotifyId());
|
| 24917 |
tejbeer |
1043 |
}
|
|
|
1044 |
|
| 24950 |
tejbeer |
1045 |
List<NotifyColorChange> notifyColorChanges = notifyColorChangeRepository.selectByNotifyId(notifyIds);
|
|
|
1046 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = this
|
|
|
1047 |
.notifyOrdersToNotifyId(notifyColorChanges);
|
|
|
1048 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerService.getFofoRetailers(fofoIds);
|
|
|
1049 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(oldItemIds);
|
| 24917 |
tejbeer |
1050 |
|
| 24950 |
tejbeer |
1051 |
model.addAttribute("notifyOrders", notifyOrders);
|
|
|
1052 |
model.addAttribute("notifyIdNotifyColorMap", notifyIdNotifyColorMap);
|
|
|
1053 |
model.addAttribute("itemdescription", itemdescription);
|
|
|
1054 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| 24917 |
tejbeer |
1055 |
|
| 24950 |
tejbeer |
1056 |
} else {
|
|
|
1057 |
model.addAttribute("notifyOrders", notifyOrders);
|
|
|
1058 |
}
|
| 24917 |
tejbeer |
1059 |
} else {
|
|
|
1060 |
model.addAttribute("notifyOrders", notifyOrders);
|
| 24950 |
tejbeer |
1061 |
}
|
| 24917 |
tejbeer |
1062 |
return "notify_order";
|
|
|
1063 |
}
|
|
|
1064 |
|
|
|
1065 |
private Map<Integer, NotifyColorChange> notifyOrdersToNotifyId(List<NotifyColorChange> notifyColorChanges) {
|
|
|
1066 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = new HashMap<>();
|
|
|
1067 |
for (NotifyColorChange notifyColorChange : notifyColorChanges) {
|
|
|
1068 |
notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
|
|
|
1069 |
}
|
|
|
1070 |
return notifyIdNotifyColorMap;
|
|
|
1071 |
}
|
|
|
1072 |
|
| 26031 |
tejbeer |
1073 |
@RequestMapping(value = "/getItems", method = RequestMethod.GET)
|
|
|
1074 |
public String getItems(HttpServletRequest request, @RequestParam int catalogItemId, Model model) throws Exception {
|
|
|
1075 |
|
|
|
1076 |
Set<Integer> itemIds = itemRepository.selectAllByCatalogItemId(catalogItemId).stream().map(x -> x.getId())
|
|
|
1077 |
.collect(Collectors.toSet());
|
|
|
1078 |
|
|
|
1079 |
List<Order> notAvailableProcessingOrder = orderRepository.selectByItemIdsOrderStatus(itemIds,
|
|
|
1080 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
1081 |
LOGGER.info("notAvailableProcessingOrder" + notAvailableProcessingOrder);
|
|
|
1082 |
|
|
|
1083 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1084 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : notAvailableProcessingOrder) {
|
|
|
1085 |
retailerIds.add(order.getRetailerId());
|
|
|
1086 |
|
|
|
1087 |
}
|
|
|
1088 |
|
|
|
1089 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
1090 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
1091 |
|
|
|
1092 |
model.addAttribute("notAvailableProcessingOrder", notAvailableProcessingOrder);
|
|
|
1093 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
1094 |
|
|
|
1095 |
return "partner-cancel-order-modal";
|
|
|
1096 |
}
|
|
|
1097 |
|
|
|
1098 |
@RequestMapping(value = "/notifyCancelOrder", method = RequestMethod.POST)
|
|
|
1099 |
public String NotifyCancelOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
|
|
1100 |
Model model) throws Exception {
|
|
|
1101 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
|
|
1102 |
LOGGER.info("orderId" + st.getOrderId());
|
|
|
1103 |
Order order = orderRepository.selectById(st.getOrderId());
|
| 26110 |
tejbeer |
1104 |
NotifyCancel nc = notifyCancelOrderRepository.selectByOrderId(st.getOrderId());
|
|
|
1105 |
if (nc == null) {
|
|
|
1106 |
nc = new NotifyCancel();
|
|
|
1107 |
nc.setOrderId(st.getOrderId());
|
|
|
1108 |
nc.setItemId(st.getOlditemId());
|
|
|
1109 |
nc.setFofoId(order.getRetailerId());
|
|
|
1110 |
nc.setCancellation(false);
|
|
|
1111 |
nc.setCreatedTimestamp(LocalDateTime.now());
|
|
|
1112 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1113 |
notifyCancelOrderRepository.persist(nc);
|
|
|
1114 |
} else {
|
|
|
1115 |
nc.setOrderId(st.getOrderId());
|
|
|
1116 |
nc.setItemId(st.getOlditemId());
|
|
|
1117 |
nc.setFofoId(order.getRetailerId());
|
|
|
1118 |
nc.setCancellation(false);
|
|
|
1119 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1120 |
notifyCancelOrderRepository.persist(nc);
|
|
|
1121 |
}
|
| 26031 |
tejbeer |
1122 |
|
|
|
1123 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
1124 |
sendNotificationModel.setCampaignName("Notify Partner");
|
|
|
1125 |
sendNotificationModel.setMessage(notifyOrderModel.getMessage());
|
|
|
1126 |
sendNotificationModel.setType("url");
|
|
|
1127 |
sendNotificationModel.setTitle("Alert");
|
| 26482 |
tejbeer |
1128 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyCancelOrder");
|
| 26031 |
tejbeer |
1129 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
1130 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
1131 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
|
|
1132 |
|
|
|
1133 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
|
|
1134 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
1135 |
|
|
|
1136 |
}
|
|
|
1137 |
|
|
|
1138 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1139 |
return "response";
|
|
|
1140 |
}
|
| 26039 |
tejbeer |
1141 |
|
|
|
1142 |
@RequestMapping(value = "/getNotifiedCancelOrder", method = RequestMethod.GET)
|
|
|
1143 |
public String getNotifiedCancelOrder(HttpServletRequest request, Model model) throws Exception {
|
|
|
1144 |
|
|
|
1145 |
List<NotifyCancel> notifyCancels = notifyCancelOrderRepository.selectAllNonCancelOrder();
|
|
|
1146 |
if (!notifyCancels.isEmpty()) {
|
|
|
1147 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1148 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
1149 |
for (NotifyCancel nc : notifyCancels) {
|
|
|
1150 |
retailerIds.add(nc.getFofoId());
|
|
|
1151 |
itemIds.add(nc.getItemId());
|
|
|
1152 |
}
|
|
|
1153 |
|
|
|
1154 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerService.getFofoRetailers(retailerIds);
|
|
|
1155 |
|
|
|
1156 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(itemIds);
|
|
|
1157 |
model.addAttribute("notifyCancels", notifyCancels);
|
|
|
1158 |
model.addAttribute("itemdescription", itemdescription);
|
|
|
1159 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
1160 |
} else {
|
|
|
1161 |
|
|
|
1162 |
model.addAttribute("notifyCancels", notifyCancels);
|
|
|
1163 |
|
|
|
1164 |
}
|
|
|
1165 |
return "notify_cancel";
|
|
|
1166 |
}
|
|
|
1167 |
|
|
|
1168 |
@RequestMapping(value = "/getNotifyItems", method = RequestMethod.GET)
|
|
|
1169 |
public String getNotifyItems(HttpServletRequest request, @RequestParam int itemId, Model model) throws Exception {
|
|
|
1170 |
Item item = itemRepository.selectById(itemId);
|
|
|
1171 |
|
|
|
1172 |
List<Integer> itemIds = itemRepository.selectAllByCatalogItemId(item.getCatalogItemId()).stream()
|
|
|
1173 |
.map(x -> x.getId()).collect(Collectors.toList());
|
|
|
1174 |
|
|
|
1175 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByItemIdsAndStatus(itemIds);
|
|
|
1176 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1177 |
Map<Integer, Object> orders = new HashMap<>();
|
|
|
1178 |
for (NotifyCancel nc : ncs) {
|
|
|
1179 |
retailerIds.add(nc.getFofoId());
|
|
|
1180 |
Order od = orderRepository.selectById(nc.getOrderId());
|
|
|
1181 |
orders.put(nc.getOrderId(), od);
|
|
|
1182 |
}
|
|
|
1183 |
|
|
|
1184 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
1185 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
1186 |
|
|
|
1187 |
model.addAttribute("notifyItems", ncs);
|
|
|
1188 |
model.addAttribute("orders", orders);
|
|
|
1189 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
1190 |
|
|
|
1191 |
return "notify_cancel_order_modal";
|
|
|
1192 |
}
|
|
|
1193 |
|
|
|
1194 |
@RequestMapping(value = "/changeNotifyCancelRequest", method = RequestMethod.POST)
|
|
|
1195 |
public String changeNotifyCancelRequest(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
|
|
1196 |
Model model) throws Exception {
|
|
|
1197 |
List<Integer> orderIds = notifyOrderModel.getOrderIds().stream().map(x -> x.getOrderId())
|
|
|
1198 |
.collect(Collectors.toList());
|
|
|
1199 |
|
|
|
1200 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByOrderIds(orderIds);
|
|
|
1201 |
for (NotifyCancel nc : ncs) {
|
|
|
1202 |
nc.setCancellation(true);
|
|
|
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1206 |
return "response";
|
|
|
1207 |
}
|
| 26482 |
tejbeer |
1208 |
|
|
|
1209 |
@RequestMapping(value = "/getProducts", method = RequestMethod.GET)
|
|
|
1210 |
public String getProducts(HttpServletRequest request, Model model)
|
|
|
1211 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
1212 |
|
|
|
1213 |
return "product-detail";
|
|
|
1214 |
}
|
|
|
1215 |
|
|
|
1216 |
@RequestMapping(value = "/getProductInfo", method = RequestMethod.GET)
|
|
|
1217 |
public String getProductInfo(HttpServletRequest request, long catalogId, Model model) throws Exception {
|
|
|
1218 |
ContentPojo cp = mongoClient.getEntityById(catalogId);
|
| 26493 |
tejbeer |
1219 |
model.addAttribute("cp", cp);
|
|
|
1220 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 26482 |
tejbeer |
1221 |
return "product-info";
|
|
|
1222 |
}
|
| 26493 |
tejbeer |
1223 |
|
|
|
1224 |
@RequestMapping(value = "/getProductCompareInfo", method = RequestMethod.GET)
|
| 26512 |
amit.gupta |
1225 |
public String getProductCompareInfo(HttpServletRequest request, @RequestParam List<Long> catalogIds, Model model)
|
| 26493 |
tejbeer |
1226 |
throws Exception {
|
|
|
1227 |
List<ContentPojo> cps = new ArrayList<>();
|
| 27583 |
tejbeer |
1228 |
Set<Integer> cataogIds = catalogIds.stream().mapToInt(Long::intValue).boxed().collect(Collectors.toSet());
|
| 27596 |
tejbeer |
1229 |
LOGGER.info("tagListingMOP" + cataogIds);
|
| 26512 |
amit.gupta |
1230 |
for (Long cId : catalogIds) {
|
|
|
1231 |
ContentPojo cp = mongoClient.getEntityById(cId);
|
| 26959 |
tejbeer |
1232 |
if (cp.getName() == null) {
|
| 26512 |
amit.gupta |
1233 |
cp.setName(itemRepository.selectAllByCatalogItemId(cId.intValue()).get(0).getItemDescriptionNoColor());
|
|
|
1234 |
}
|
| 27583 |
tejbeer |
1235 |
List<Item> items = itemRepository.selectAllByCatalogItemId(cId.intValue());
|
| 27596 |
tejbeer |
1236 |
LOGGER.info("itemsMop" + items);
|
| 27618 |
tejbeer |
1237 |
int i = 0;
|
|
|
1238 |
for (Item item : items) {
|
|
|
1239 |
TagListing tagListing = tagListingRepository.selectByItemId(items.get(i).getId());
|
|
|
1240 |
|
|
|
1241 |
if (tagListing != null) {
|
|
|
1242 |
cp.setPrice(tagListing.getMop());
|
|
|
1243 |
|
|
|
1244 |
LOGGER.info("tagListingMOP" + tagListing);
|
|
|
1245 |
|
|
|
1246 |
break;
|
|
|
1247 |
|
|
|
1248 |
}
|
|
|
1249 |
i++;
|
| 27596 |
tejbeer |
1250 |
}
|
| 27618 |
tejbeer |
1251 |
cps.add(cp);
|
| 27583 |
tejbeer |
1252 |
|
| 26493 |
tejbeer |
1253 |
}
|
| 26959 |
tejbeer |
1254 |
|
| 26498 |
amit.gupta |
1255 |
List<Map<String, String>> entityList = new ArrayList<>();
|
| 26959 |
tejbeer |
1256 |
for (ContentPojo cp : cps) {
|
| 26498 |
amit.gupta |
1257 |
Map<String, String> specsMap = new HashMap<>();
|
| 26959 |
tejbeer |
1258 |
for (SpecificationGroup sg : cp.getDetailedSpecs()) {
|
| 26498 |
amit.gupta |
1259 |
String title = sg.getTitle();
|
| 26959 |
tejbeer |
1260 |
for (Specification s : sg.getSpecs()) {
|
| 26498 |
amit.gupta |
1261 |
String key = title + s.getName();
|
|
|
1262 |
specsMap.put(key, String.join(", ", s.getValues()));
|
|
|
1263 |
}
|
|
|
1264 |
}
|
|
|
1265 |
entityList.add(specsMap);
|
| 27723 |
tejbeer |
1266 |
|
| 26498 |
amit.gupta |
1267 |
}
|
| 26959 |
tejbeer |
1268 |
|
| 26493 |
tejbeer |
1269 |
LOGGER.info("cps" + cps);
|
| 26959 |
tejbeer |
1270 |
model.addAttribute("cps", cps);
|
|
|
1271 |
model.addAttribute("catalogIds", gson.toJson(catalogIds, List.class));
|
|
|
1272 |
model.addAttribute("entityList", entityList);
|
| 26493 |
tejbeer |
1273 |
return "product-compare";
|
|
|
1274 |
}
|
| 27723 |
tejbeer |
1275 |
|
|
|
1276 |
@RequestMapping(value = "/inventory", method = RequestMethod.GET)
|
|
|
1277 |
public String Inventory(HttpServletRequest request,
|
|
|
1278 |
@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
|
|
|
1279 |
Model model) throws Exception {
|
|
|
1280 |
model.addAttribute("warehouseId", warehouseIds);
|
|
|
1281 |
LOGGER.info("warehouseIds" + warehouseIds);
|
|
|
1282 |
|
|
|
1283 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
1284 |
if (warehouseIds.contains(0)) {
|
|
|
1285 |
warehouseIds.addAll(warehouseMap.keySet());
|
|
|
1286 |
}
|
|
|
1287 |
|
|
|
1288 |
List<OpenPoModel> openPO = warehousePurchaseOrderRepository.selectOpenPol(warehouseIds);
|
|
|
1289 |
List<OurPurchaseModel> purchase = warehouseScanRepository.selectOurPurchase(warehouseIds);
|
|
|
1290 |
List<BrandWiseTertiaryModel> tertiary = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds);
|
|
|
1291 |
List<SecondaryOrderBillingModel> billing = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds);
|
|
|
1292 |
LOGGER.info("openPO" + openPO);
|
|
|
1293 |
LOGGER.info("purchase" + purchase);
|
|
|
1294 |
LOGGER.info("tertiary" + tertiary);
|
|
|
1295 |
LOGGER.info("billing" + billing);
|
|
|
1296 |
|
|
|
1297 |
LOGGER.info("warehouseIds" + warehouseIds);
|
|
|
1298 |
model.addAttribute("warehouseMap", warehouseMap);
|
|
|
1299 |
model.addAttribute("openPO", openPO);
|
|
|
1300 |
model.addAttribute("purchase", purchase);
|
|
|
1301 |
model.addAttribute("tertiary", tertiary);
|
|
|
1302 |
model.addAttribute("billing", billing);
|
|
|
1303 |
|
|
|
1304 |
return "inventory-listing";
|
|
|
1305 |
|
|
|
1306 |
}
|
| 24917 |
tejbeer |
1307 |
}
|