| 23784 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23883 |
ashik.ali |
3 |
import java.util.ArrayList;
|
| 23784 |
ashik.ali |
4 |
import java.util.HashMap;
|
|
|
5 |
import java.util.HashSet;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
import java.util.Map;
|
|
|
8 |
import java.util.Set;
|
|
|
9 |
|
|
|
10 |
import javax.servlet.http.HttpServletRequest;
|
|
|
11 |
|
|
|
12 |
import org.apache.logging.log4j.LogManager;
|
|
|
13 |
import org.apache.logging.log4j.Logger;
|
|
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
15 |
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
16 |
import org.springframework.stereotype.Controller;
|
|
|
17 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
18 |
import org.springframework.ui.Model;
|
|
|
19 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
20 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
21 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
22 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
23 |
|
|
|
24 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
|
|
25 |
import com.spice.profitmandi.common.enumuration.ScanType;
|
|
|
26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
27 |
import com.spice.profitmandi.common.model.CreateItemRequest;
|
| 23883 |
ashik.ali |
28 |
import com.spice.profitmandi.common.model.InstructionItemRequest;
|
| 23784 |
ashik.ali |
29 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
30 |
import com.spice.profitmandi.common.model.ScanInItemRequest;
|
| 23883 |
ashik.ali |
31 |
import com.spice.profitmandi.common.model.ScanInPartnerItemRequest;
|
| 23784 |
ashik.ali |
32 |
import com.spice.profitmandi.common.model.ScanOutItemRequest;
|
| 23883 |
ashik.ali |
33 |
import com.spice.profitmandi.common.model.ScanOutPartnerItemRequest;
|
| 23784 |
ashik.ali |
34 |
import com.spice.profitmandi.dao.entity.nonbillable.AdminCurrentInventorySnapshot;
|
|
|
35 |
import com.spice.profitmandi.dao.entity.nonbillable.AdminDeliveryNote;
|
| 23883 |
ashik.ali |
36 |
import com.spice.profitmandi.dao.entity.nonbillable.InstructionItem;
|
|
|
37 |
import com.spice.profitmandi.dao.entity.nonbillable.InstructionItemDetail;
|
| 23784 |
ashik.ali |
38 |
import com.spice.profitmandi.dao.entity.nonbillable.Item;
|
|
|
39 |
import com.spice.profitmandi.dao.entity.nonbillable.PartnerCurrentInventorySnapshot;
|
| 23883 |
ashik.ali |
40 |
import com.spice.profitmandi.dao.entity.nonbillable.ScanOutPartnerItem;
|
| 23784 |
ashik.ali |
41 |
import com.spice.profitmandi.dao.entity.nonbillable.Vendor;
|
|
|
42 |
import com.spice.profitmandi.dao.entity.nonbillable.Warehouse;
|
| 23883 |
ashik.ali |
43 |
import com.spice.profitmandi.dao.entity.user.Address;
|
|
|
44 |
import com.spice.profitmandi.dao.enumuration.nonbillable.InstructionItemStatus;
|
|
|
45 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 23784 |
ashik.ali |
46 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
|
|
47 |
import com.spice.profitmandi.dao.repository.nonbillable.AdminCurrentInventorySnapshotRepository;
|
| 23883 |
ashik.ali |
48 |
import com.spice.profitmandi.dao.repository.nonbillable.AdminDeliveryNoteDetailRepository;
|
| 23784 |
ashik.ali |
49 |
import com.spice.profitmandi.dao.repository.nonbillable.AdminDeliveryNoteRepository;
|
|
|
50 |
import com.spice.profitmandi.dao.repository.nonbillable.AdminInventoryItemRepository;
|
| 23883 |
ashik.ali |
51 |
import com.spice.profitmandi.dao.repository.nonbillable.InstructionItemDetailRepository;
|
|
|
52 |
import com.spice.profitmandi.dao.repository.nonbillable.InstructionItemRepository;
|
| 23784 |
ashik.ali |
53 |
import com.spice.profitmandi.dao.repository.nonbillable.ItemRepository;
|
|
|
54 |
import com.spice.profitmandi.dao.repository.nonbillable.PartnerCurrentInventorySnapshotRepository;
|
| 23883 |
ashik.ali |
55 |
import com.spice.profitmandi.dao.repository.nonbillable.PartnerInventoryItemRepository;
|
|
|
56 |
import com.spice.profitmandi.dao.repository.nonbillable.ScanOutPartnerItemRepository;
|
| 23784 |
ashik.ali |
57 |
import com.spice.profitmandi.dao.repository.nonbillable.UserWarehouseRepository;
|
|
|
58 |
import com.spice.profitmandi.dao.repository.nonbillable.VendorRepository;
|
|
|
59 |
import com.spice.profitmandi.dao.repository.nonbillable.WarehouseRepository;
|
| 23883 |
ashik.ali |
60 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 23784 |
ashik.ali |
61 |
import com.spice.profitmandi.service.nonbillable.InventoryService;
|
|
|
62 |
import com.spice.profitmandi.service.user.RetailerService;
|
|
|
63 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
64 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
|
|
65 |
|
|
|
66 |
@Controller
|
|
|
67 |
@Transactional
|
|
|
68 |
public class ItemController {
|
|
|
69 |
|
|
|
70 |
private static final Logger LOGGER = LogManager.getLogger(ItemController.class);
|
|
|
71 |
|
|
|
72 |
@Autowired
|
|
|
73 |
@Qualifier("nonbillableItemRepository")
|
|
|
74 |
private ItemRepository itemRepository;
|
|
|
75 |
|
|
|
76 |
@Autowired
|
|
|
77 |
@Qualifier("nonbillableInventoryService")
|
|
|
78 |
private InventoryService inventoryService;
|
|
|
79 |
|
|
|
80 |
@Autowired
|
|
|
81 |
private AdminCurrentInventorySnapshotRepository adminCurrentInventorySnapshotRepository;
|
|
|
82 |
|
|
|
83 |
@Autowired
|
|
|
84 |
private AdminInventoryItemRepository adminInventoryItemRepository;
|
|
|
85 |
|
|
|
86 |
@Autowired
|
|
|
87 |
private PartnerCurrentInventorySnapshotRepository partnerCurrentInventorySnapshotRepository;
|
|
|
88 |
|
|
|
89 |
@Autowired
|
|
|
90 |
private VendorRepository vendorRepository;
|
|
|
91 |
|
|
|
92 |
@Autowired
|
|
|
93 |
private WarehouseRepository warehouseRepository;
|
|
|
94 |
|
|
|
95 |
@Autowired
|
|
|
96 |
private RetailerService retailerService;
|
|
|
97 |
|
|
|
98 |
@Autowired
|
|
|
99 |
@Qualifier(value = "userRepository")
|
|
|
100 |
private UserRepository userRepository;
|
|
|
101 |
|
|
|
102 |
@Autowired
|
|
|
103 |
private UserWarehouseRepository userWarehouseRepository;
|
|
|
104 |
|
|
|
105 |
@Autowired
|
|
|
106 |
private AdminDeliveryNoteRepository adminDeliveryNoteRepository;
|
| 23883 |
ashik.ali |
107 |
|
|
|
108 |
@Autowired
|
|
|
109 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
|
|
110 |
|
|
|
111 |
@Autowired
|
|
|
112 |
private AddressRepository addressRepository;
|
|
|
113 |
|
|
|
114 |
@Autowired
|
|
|
115 |
private PartnerInventoryItemRepository partnerInventoryItemRepository;
|
|
|
116 |
|
|
|
117 |
@Autowired
|
|
|
118 |
private ScanOutPartnerItemRepository scanOutPartnerItemRepository;
|
| 23784 |
ashik.ali |
119 |
|
|
|
120 |
@Autowired
|
| 23883 |
ashik.ali |
121 |
private InstructionItemRepository instructionItemRepository;
|
| 23784 |
ashik.ali |
122 |
|
|
|
123 |
@Autowired
|
| 23883 |
ashik.ali |
124 |
private InstructionItemDetailRepository instructionItemDetailRepository;
|
|
|
125 |
|
|
|
126 |
@Autowired
|
|
|
127 |
private AdminDeliveryNoteDetailRepository adminDeliveryNoteDetailRepository;
|
|
|
128 |
|
|
|
129 |
@Autowired
|
| 23784 |
ashik.ali |
130 |
private CookiesProcessor cookiesProcessor;
|
|
|
131 |
|
|
|
132 |
private Map<Integer, String> itemsToVendorIdNameMap(List<Item> items){
|
|
|
133 |
Map<Integer, String> vendorIdNameMap = new HashMap<>();
|
|
|
134 |
if(items.isEmpty()) {
|
|
|
135 |
return vendorIdNameMap;
|
|
|
136 |
}
|
|
|
137 |
Set<Integer> vendorIds = new HashSet<>();
|
|
|
138 |
for(Item item : items) {
|
|
|
139 |
vendorIds.add(item.getVendorId());
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
List<Vendor> vendors = vendorRepository.selectByIds(vendorIds);
|
|
|
143 |
for(Vendor vendor : vendors) {
|
|
|
144 |
vendorIdNameMap.put(vendor.getId(), vendor.getName());
|
|
|
145 |
}
|
|
|
146 |
return vendorIdNameMap;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
private Map<Integer, String> adminCurrentInventorySnapshotsToItemIdDescriptionMap(List<AdminCurrentInventorySnapshot> currentInventorySnapshots){
|
|
|
150 |
if(currentInventorySnapshots.isEmpty()) {
|
|
|
151 |
return new HashMap<>();
|
|
|
152 |
}
|
|
|
153 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
154 |
for(AdminCurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots) {
|
|
|
155 |
itemIds.add(currentInventorySnapshot.getItemId());
|
|
|
156 |
}
|
|
|
157 |
return itemIdDescriptionMap(itemIds);
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
private Map<Integer, String> adminCurrentInventorySnapshotsToItemIdTypeMap(List<AdminCurrentInventorySnapshot> currentInventorySnapshots){
|
|
|
161 |
if(currentInventorySnapshots.isEmpty()) {
|
|
|
162 |
return new HashMap<>();
|
|
|
163 |
}
|
|
|
164 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
165 |
for(AdminCurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots) {
|
|
|
166 |
itemIds.add(currentInventorySnapshot.getItemId());
|
|
|
167 |
}
|
|
|
168 |
return itemIdTypeMap(itemIds);
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
private Map<Integer, String> partnerCurrentInventorySnapshotsToItemIdDescriptionMap(List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots){
|
|
|
172 |
if(partnerCurrentInventorySnapshots.isEmpty()) {
|
|
|
173 |
return new HashMap<>();
|
|
|
174 |
}
|
|
|
175 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
176 |
for(PartnerCurrentInventorySnapshot partnerCurrentInventorySnapshot : partnerCurrentInventorySnapshots) {
|
|
|
177 |
itemIds.add(partnerCurrentInventorySnapshot.getItemId());
|
|
|
178 |
}
|
|
|
179 |
return itemIdDescriptionMap(itemIds);
|
|
|
180 |
}
|
|
|
181 |
|
| 23883 |
ashik.ali |
182 |
/*private Map<Integer, String> adminDeliveryNotesToItemIdDescriptionMap(List<AdminDeliveryNote> adminDeliveryNotes){
|
| 23784 |
ashik.ali |
183 |
if(adminDeliveryNotes.isEmpty()) {
|
|
|
184 |
return new HashMap<>();
|
|
|
185 |
}
|
|
|
186 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
187 |
for(AdminDeliveryNote adminDeliveryNote : adminDeliveryNotes) {
|
|
|
188 |
itemIds.add(adminDeliveryNote.getItemId());
|
|
|
189 |
}
|
|
|
190 |
return itemIdDescriptionMap(itemIds);
|
| 23883 |
ashik.ali |
191 |
}*/
|
|
|
192 |
|
|
|
193 |
private Map<Integer, String> scanOutPartnerItemsToItemIdDescriptionMap(List<ScanOutPartnerItem> scanOutPartnerItems){
|
|
|
194 |
if(scanOutPartnerItems.isEmpty()) {
|
|
|
195 |
return new HashMap<>();
|
|
|
196 |
}
|
|
|
197 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
198 |
for(ScanOutPartnerItem scanOutPartnerItem : scanOutPartnerItems) {
|
|
|
199 |
itemIds.add(scanOutPartnerItem.getItemId());
|
|
|
200 |
}
|
|
|
201 |
return itemIdDescriptionMap(itemIds);
|
|
|
202 |
}
|
| 23784 |
ashik.ali |
203 |
|
|
|
204 |
private Map<Integer, String> itemIdDescriptionMap(Set<Integer> itemIds){
|
|
|
205 |
Map<Integer, String> itemIdDescriptionMap = new HashMap<>();
|
|
|
206 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
|
|
207 |
for(Item item : items) {
|
|
|
208 |
itemIdDescriptionMap.put(item.getId(), item.getBrand() + " " + item.getDescription());
|
|
|
209 |
}
|
|
|
210 |
return itemIdDescriptionMap;
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
private Map<Integer, String> itemIdTypeMap(Set<Integer> itemIds){
|
|
|
214 |
Map<Integer, String> itemIdTypeMap = new HashMap<>();
|
|
|
215 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
|
|
216 |
for(Item item : items) {
|
|
|
217 |
itemIdTypeMap.put(item.getId(), item.getType().toString());
|
|
|
218 |
}
|
|
|
219 |
return itemIdTypeMap;
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
private Map<Integer, String> warehouseIdNameMap(List<Warehouse> warehouses){
|
|
|
223 |
Map<Integer, String> warehouseIdNameMap = new HashMap<>();
|
|
|
224 |
for(Warehouse warehouse : warehouses) {
|
|
|
225 |
warehouseIdNameMap.put(warehouse.getId(), warehouse.getName());
|
|
|
226 |
}
|
|
|
227 |
return warehouseIdNameMap;
|
|
|
228 |
}
|
|
|
229 |
|
| 23883 |
ashik.ali |
230 |
private Set<Integer> instructionItemsToWarehouseIds(List<InstructionItem> instructionItems){
|
|
|
231 |
Set<Integer> warehouseIds = new HashSet<>();
|
|
|
232 |
for(InstructionItem instructionItem : instructionItems) {
|
|
|
233 |
warehouseIds.add(instructionItem.getWarehouseId());
|
|
|
234 |
}
|
|
|
235 |
return warehouseIds;
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
private Set<Integer> instructionItemsToFofoIds(List<InstructionItem> instructionItems){
|
|
|
239 |
Set<Integer> fofoIds = new HashSet<>();
|
|
|
240 |
for(InstructionItem instructionItem : instructionItems) {
|
|
|
241 |
fofoIds.add(instructionItem.getFofoId());
|
|
|
242 |
}
|
|
|
243 |
return fofoIds;
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
private Set<Integer> instructionItemsToInstructionItemIds(List<InstructionItem> instructionItems){
|
|
|
247 |
Set<Integer> instructionItemIds = new HashSet<>();
|
|
|
248 |
for(InstructionItem instructionItem : instructionItems) {
|
|
|
249 |
instructionItemIds.add(instructionItem.getId());
|
|
|
250 |
}
|
|
|
251 |
return instructionItemIds;
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
private Map<Integer, Integer> instructionItemDetailsToItemIdQuantityMap(List<InstructionItemDetail> instructionItemDetails) {
|
|
|
256 |
Map<Integer, Integer> itemIdQuantityMap = new HashMap<>();
|
|
|
257 |
for(InstructionItemDetail instructionItemDetail : instructionItemDetails) {
|
|
|
258 |
if(!itemIdQuantityMap.containsKey(instructionItemDetail.getItemId())) {
|
|
|
259 |
itemIdQuantityMap.put(instructionItemDetail.getItemId(), instructionItemDetail.getQuantity());
|
|
|
260 |
}else {
|
|
|
261 |
itemIdQuantityMap.put(instructionItemDetail.getItemId(), itemIdQuantityMap.get(instructionItemDetail.getItemId()) + instructionItemDetail.getQuantity());
|
|
|
262 |
}
|
|
|
263 |
}
|
|
|
264 |
return itemIdQuantityMap;
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
private Map<Integer, List<InstructionItemDetail>> instructionItemsToInstructionItemIdInstructionItemDetailsMap(List<InstructionItemDetail> instructionItemDetails){
|
|
|
268 |
//Set<Integer> instructionItemIds = this.instructionItemsToInstructionItemIds(instructionItems);
|
|
|
269 |
//List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository.selectByInstructionItemIds(instructionItemIds);
|
|
|
270 |
Map<Integer, List<InstructionItemDetail>> instructionIdInstructionItemDetailMap = new HashMap<>();
|
|
|
271 |
for(InstructionItemDetail instructionItemDetail : instructionItemDetails) {
|
|
|
272 |
if(!instructionIdInstructionItemDetailMap.containsKey(instructionItemDetail.getInstructionItemId())) {
|
|
|
273 |
List<InstructionItemDetail> instructionItemDetailsList = new ArrayList<>();
|
|
|
274 |
instructionItemDetailsList.add(instructionItemDetail);
|
|
|
275 |
instructionIdInstructionItemDetailMap.put(instructionItemDetail.getInstructionItemId(), instructionItemDetailsList);
|
|
|
276 |
}else {
|
|
|
277 |
instructionIdInstructionItemDetailMap.get(instructionItemDetail.getInstructionItemId()).add(instructionItemDetail);
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
return instructionIdInstructionItemDetailMap;
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
private Set<Integer> instructionItemDetailsToItemIds(List<InstructionItemDetail> instructionItemDetails){
|
|
|
284 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
285 |
for(InstructionItemDetail instructionItemDetail : instructionItemDetails) {
|
|
|
286 |
itemIds.add(instructionItemDetail.getItemId());
|
|
|
287 |
}
|
|
|
288 |
return itemIds;
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
private Set<Integer> adminDeliveryNotesToWarehouseIds(List<AdminDeliveryNote> adminDeliveryNotes){
|
|
|
292 |
Set<Integer> warehouseIds = new HashSet<>();
|
|
|
293 |
for(AdminDeliveryNote adminDeliveryNote : adminDeliveryNotes) {
|
|
|
294 |
warehouseIds.add(adminDeliveryNote.getWarehouseId());
|
|
|
295 |
}
|
|
|
296 |
return warehouseIds;
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
private Set<Integer> adminDeliveryNotesToFofoIds(List<AdminDeliveryNote> adminDeliveryNotes){
|
|
|
300 |
Set<Integer> fofoIds = new HashSet<>();
|
|
|
301 |
for(AdminDeliveryNote adminDeliveryNote : adminDeliveryNotes) {
|
|
|
302 |
fofoIds.add(adminDeliveryNote.getFofoId());
|
|
|
303 |
}
|
|
|
304 |
return fofoIds;
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
|
| 23784 |
ashik.ali |
308 |
@RequestMapping(value = "/createItem", method = RequestMethod.GET)
|
|
|
309 |
public String createItem(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
310 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
311 |
List<Item> items = itemRepository.selectAll(offset, limit);
|
|
|
312 |
long size = itemRepository.selectAllCount();
|
|
|
313 |
Map<Integer, String> vendorIdNameMap = this.itemsToVendorIdNameMap(items);
|
|
|
314 |
List<Vendor> vendors = vendorRepository.selectAll();
|
|
|
315 |
model.addAttribute("vendors", vendors);
|
|
|
316 |
model.addAttribute("items", items);
|
|
|
317 |
model.addAttribute("types", ItemType.values());
|
|
|
318 |
model.addAttribute("vendorIdNameMap", vendorIdNameMap);
|
|
|
319 |
model.addAttribute("start", offset + 1);
|
|
|
320 |
model.addAttribute("size", size);
|
|
|
321 |
if (items.size() < limit){
|
|
|
322 |
model.addAttribute("end", offset + items.size());
|
|
|
323 |
}else{
|
|
|
324 |
model.addAttribute("end", offset + limit);
|
|
|
325 |
}
|
|
|
326 |
return "items";
|
|
|
327 |
}
|
|
|
328 |
|
|
|
329 |
@RequestMapping(value = "/createItem", method = RequestMethod.POST)
|
|
|
330 |
public String createItem(HttpServletRequest request, @RequestBody CreateItemRequest createItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
331 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), createItemRequest);
|
|
|
332 |
inventoryService.createItem(createItemRequest);
|
|
|
333 |
List<Item> items = itemRepository.selectAll(offset, limit);
|
|
|
334 |
Map<Integer, String> vendorIdNameMap = this.itemsToVendorIdNameMap(items);
|
|
|
335 |
long size = itemRepository.selectAllCount();
|
|
|
336 |
List<Vendor> vendors = vendorRepository.selectAll();
|
|
|
337 |
model.addAttribute("vendors", vendors);
|
|
|
338 |
model.addAttribute("items", items);
|
|
|
339 |
model.addAttribute("types", ItemType.values());
|
|
|
340 |
model.addAttribute("vendorIdNameMap", vendorIdNameMap);
|
|
|
341 |
model.addAttribute("start", offset + 1);
|
|
|
342 |
model.addAttribute("size", size);
|
|
|
343 |
if (items.size() < limit){
|
|
|
344 |
model.addAttribute("end", offset + items.size());
|
|
|
345 |
}else{
|
|
|
346 |
model.addAttribute("end", offset + limit);
|
|
|
347 |
}
|
|
|
348 |
return "items";
|
|
|
349 |
}
|
|
|
350 |
|
|
|
351 |
@RequestMapping(value = "/getPaginatedItems", method = RequestMethod.GET)
|
|
|
352 |
public String getPaginatedItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
353 |
List<Item> items = itemRepository.selectAll(offset, limit);
|
|
|
354 |
Map<Integer, String> vendorIdNameMap = this.itemsToVendorIdNameMap(items);
|
|
|
355 |
List<Vendor> vendors = vendorRepository.selectAll();
|
|
|
356 |
model.addAttribute("vendors", vendors);
|
|
|
357 |
model.addAttribute("items", items);
|
|
|
358 |
model.addAttribute("vendorIdNameMap", vendorIdNameMap);
|
|
|
359 |
return "items-paginated";
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
@RequestMapping(value = "/scanInItems", method = RequestMethod.POST)
|
|
|
363 |
public String scanInItems(HttpServletRequest request, @RequestBody ScanInItemRequest scanInItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
364 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanInItemRequest);
|
|
|
365 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23883 |
ashik.ali |
366 |
List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
|
| 23784 |
ashik.ali |
367 |
List<Item> items = itemRepository.selectAll();
|
|
|
368 |
inventoryService.scanInItem(scanInItemRequest, loginDetails.getFofoId());
|
|
|
369 |
List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
|
|
|
370 |
Map<Integer, String> itemIdDescriptionMap = this.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
|
|
|
371 |
long size = adminCurrentInventorySnapshotRepository.selectAllCountByAdminId(loginDetails.getFofoId());
|
| 23883 |
ashik.ali |
372 |
if(!warehouseIds.isEmpty()) {
|
|
|
373 |
model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
|
|
|
374 |
}
|
| 23784 |
ashik.ali |
375 |
model.addAttribute("items", items);
|
|
|
376 |
model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
|
|
|
377 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
378 |
model.addAttribute("start", offset + 1);
|
|
|
379 |
model.addAttribute("size", size);
|
|
|
380 |
if (adminCurrentInventorySnapshots.size() < limit){
|
|
|
381 |
model.addAttribute("end", offset + adminCurrentInventorySnapshots.size());
|
|
|
382 |
}else{
|
|
|
383 |
model.addAttribute("end", offset + limit);
|
|
|
384 |
}
|
|
|
385 |
return "scan-in-items";
|
|
|
386 |
}
|
|
|
387 |
|
|
|
388 |
@RequestMapping(value = "/getScanInItems", method = RequestMethod.GET)
|
|
|
389 |
public String getScanInItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
390 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
391 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23883 |
ashik.ali |
392 |
List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
|
| 23784 |
ashik.ali |
393 |
List<Item> items = itemRepository.selectAll();
|
|
|
394 |
List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
|
|
|
395 |
Map<Integer, String> itemIdDescriptionMap = this.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
|
|
|
396 |
long size = adminCurrentInventorySnapshotRepository.selectAllCountByAdminId(loginDetails.getFofoId());
|
| 23883 |
ashik.ali |
397 |
if(!warehouseIds.isEmpty()) {
|
|
|
398 |
model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
|
|
|
399 |
}
|
| 23784 |
ashik.ali |
400 |
model.addAttribute("items", items);
|
|
|
401 |
model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
|
|
|
402 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
403 |
model.addAttribute("start", offset + 1);
|
|
|
404 |
model.addAttribute("size", size);
|
|
|
405 |
if (adminCurrentInventorySnapshots.size() < limit){
|
|
|
406 |
model.addAttribute("end", offset + adminCurrentInventorySnapshots.size());
|
|
|
407 |
}else{
|
|
|
408 |
model.addAttribute("end", offset + limit);
|
|
|
409 |
}
|
|
|
410 |
return "scan-in-items";
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
@RequestMapping(value = "/getPaginatedScanInItems", method = RequestMethod.GET)
|
|
|
414 |
public String getPaginatedScanInItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
415 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
416 |
List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
|
|
|
417 |
Map<Integer, String> itemIdDescriptionMap = this.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
|
|
|
418 |
model.addAttribute("adminCurrentInventorySnapshots", adminCurrentInventorySnapshots);
|
|
|
419 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
420 |
return "scan-in-items-paginated";
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
@RequestMapping(value = "/getScanInPartnerItems", method = RequestMethod.GET)
|
|
|
424 |
public String getScanInPartnerItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
425 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
426 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
427 |
|
|
|
428 |
//List<Item> items = itemRepository.selectAll();
|
|
|
429 |
List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots = partnerCurrentInventorySnapshotRepository.selectAllByFofoId(loginDetails.getFofoId(), offset, limit);
|
|
|
430 |
Map<Integer, String> itemIdDescriptionMap = this.partnerCurrentInventorySnapshotsToItemIdDescriptionMap(partnerCurrentInventorySnapshots);
|
|
|
431 |
long size = partnerCurrentInventorySnapshotRepository.selectAllCountByFofoId(loginDetails.getFofoId());
|
|
|
432 |
//model.addAttribute("items", items);
|
|
|
433 |
model.addAttribute("partnerCurrentInventorySnapshots", partnerCurrentInventorySnapshots);
|
|
|
434 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
435 |
model.addAttribute("start", offset + 1);
|
|
|
436 |
model.addAttribute("size", size);
|
|
|
437 |
if (partnerCurrentInventorySnapshots.size() < limit){
|
|
|
438 |
model.addAttribute("end", offset + partnerCurrentInventorySnapshots.size());
|
|
|
439 |
}else{
|
|
|
440 |
model.addAttribute("end", offset + limit);
|
|
|
441 |
}
|
|
|
442 |
return "scan-in-partner-items";
|
|
|
443 |
}
|
|
|
444 |
|
| 23883 |
ashik.ali |
445 |
@RequestMapping(value = "/scanInPartnerItems", method = RequestMethod.POST)
|
|
|
446 |
public String getScanInPartnerItems(HttpServletRequest request, @RequestBody ScanInPartnerItemRequest scanInPartnerItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
| 23784 |
ashik.ali |
447 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
448 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23883 |
ashik.ali |
449 |
inventoryService.scanInPartnerItem(scanInPartnerItemRequest, loginDetails.getFofoId());
|
| 23784 |
ashik.ali |
450 |
List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots = partnerCurrentInventorySnapshotRepository.selectAllByFofoId(loginDetails.getFofoId(), offset, limit);
|
|
|
451 |
Map<Integer, String> itemIdDescriptionMap = this.partnerCurrentInventorySnapshotsToItemIdDescriptionMap(partnerCurrentInventorySnapshots);
|
|
|
452 |
long size = partnerCurrentInventorySnapshotRepository.selectAllCountByFofoId(loginDetails.getFofoId());
|
|
|
453 |
model.addAttribute("partnerCurrentInventorySnapshots", partnerCurrentInventorySnapshots);
|
|
|
454 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
455 |
model.addAttribute("start", offset + 1);
|
|
|
456 |
model.addAttribute("size", size);
|
|
|
457 |
if (partnerCurrentInventorySnapshots.size() < limit){
|
|
|
458 |
model.addAttribute("end", offset + partnerCurrentInventorySnapshots.size());
|
|
|
459 |
}else{
|
|
|
460 |
model.addAttribute("end", offset + limit);
|
|
|
461 |
}
|
|
|
462 |
return "scan-in-partner-items";
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
@RequestMapping(value = "/getPaginatedScanInPartnerItems", method = RequestMethod.GET)
|
|
|
466 |
public String getPaginatedScanInPartnerItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
467 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
468 |
List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots = partnerCurrentInventorySnapshotRepository.selectAllByFofoId(loginDetails.getFofoId(), offset, limit);
|
|
|
469 |
Map<Integer, String> itemIdDescriptionMap = this.partnerCurrentInventorySnapshotsToItemIdDescriptionMap(partnerCurrentInventorySnapshots);
|
|
|
470 |
model.addAttribute("partnerCurrentInventorySnapshots", partnerCurrentInventorySnapshots);
|
|
|
471 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
472 |
return "scan-in-partner-items-paginated";
|
|
|
473 |
}
|
|
|
474 |
|
| 23883 |
ashik.ali |
475 |
private Map<Integer, Integer> partnerCurrentInventorySnapshotsItemIdQuantityMap(List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots){
|
|
|
476 |
Map<Integer, Integer> itemIdQuantityMap = new HashMap<>();
|
|
|
477 |
for(PartnerCurrentInventorySnapshot partnerCurrentInventorySnapshot : partnerCurrentInventorySnapshots) {
|
|
|
478 |
itemIdQuantityMap.put(partnerCurrentInventorySnapshot.getItemId(), partnerCurrentInventorySnapshot.getAvailability());
|
|
|
479 |
}
|
|
|
480 |
return itemIdQuantityMap;
|
|
|
481 |
}
|
|
|
482 |
|
|
|
483 |
@RequestMapping(value = "/getScanOutPartnerItems", method = RequestMethod.GET)
|
|
|
484 |
public String getScanOutPartnerItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
485 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
486 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
487 |
|
|
|
488 |
int addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(loginDetails.getFofoId());
|
|
|
489 |
Address address = addressRepository.selectById(addressId);
|
|
|
490 |
|
|
|
491 |
List<PartnerCurrentInventorySnapshot> partnerCurrentInventorySnapshots = partnerCurrentInventorySnapshotRepository.selectByFofoId(loginDetails.getFofoId());
|
|
|
492 |
Map<Integer, Integer> itemIdQuantityMap = this.partnerCurrentInventorySnapshotsItemIdQuantityMap(partnerCurrentInventorySnapshots);
|
|
|
493 |
List<Item> items = itemRepository.selectByIds(itemIdQuantityMap.keySet());
|
|
|
494 |
|
|
|
495 |
List<ScanOutPartnerItem> scanOutPartnerItems = scanOutPartnerItemRepository.selectAllByFofoId(loginDetails.getFofoId(), offset, limit);
|
|
|
496 |
Map<Integer, String> itemIdDescriptionMap = this.scanOutPartnerItemsToItemIdDescriptionMap(scanOutPartnerItems);
|
|
|
497 |
long size = scanOutPartnerItemRepository.selectCountByFofoId(loginDetails.getFofoId());
|
|
|
498 |
model.addAttribute("items", items);
|
|
|
499 |
//model.addAttribute("stateNames", Utils.getAllStateNames());
|
|
|
500 |
model.addAttribute("retailerStateName", address.getState());
|
|
|
501 |
model.addAttribute("scanOutPartnerItems", scanOutPartnerItems);
|
|
|
502 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
503 |
model.addAttribute("itemIdQuantityMap", itemIdQuantityMap);
|
|
|
504 |
model.addAttribute("start", offset + 1);
|
|
|
505 |
model.addAttribute("size", size);
|
|
|
506 |
if (scanOutPartnerItems.size() < limit){
|
|
|
507 |
model.addAttribute("end", offset + scanOutPartnerItems.size());
|
|
|
508 |
}else{
|
|
|
509 |
model.addAttribute("end", offset + limit);
|
|
|
510 |
}
|
|
|
511 |
return "scan-out-partner-items";
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
@RequestMapping(value = "/instructionItem", method = RequestMethod.POST)
|
|
|
515 |
public String instructionItems(HttpServletRequest request, @RequestBody InstructionItemRequest instructionItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
516 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), instructionItemRequest);
|
|
|
517 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
518 |
inventoryService.instructionItem(instructionItemRequest, loginDetails.getFofoId());
|
|
|
519 |
return this.getInstructionItems(request, offset, limit, model);
|
|
|
520 |
}
|
|
|
521 |
|
|
|
522 |
@RequestMapping(value = "/getInstructionItems", method = RequestMethod.GET)
|
|
|
523 |
public String getInstructionItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
524 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
525 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
526 |
|
|
|
527 |
List<InstructionItem> instructionItems = instructionItemRepository.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
|
|
|
528 |
|
|
|
529 |
Set<Integer> instructionItemWarehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
|
|
|
530 |
|
|
|
531 |
List<Warehouse> warehouses = new ArrayList<>();
|
|
|
532 |
if(!instructionItemWarehouseIds.isEmpty()) {
|
|
|
533 |
warehouses = warehouseRepository.selectByIds(instructionItemWarehouseIds);
|
|
|
534 |
}
|
|
|
535 |
Map<Integer, String> warehouseIdNameMap = this.warehouseIdNameMap(warehouses);
|
|
|
536 |
|
|
|
537 |
List<Integer> warehouseIds = userWarehouseRepository.selectWarehouseIdsByUserId(loginDetails.getFofoId());
|
|
|
538 |
if(!warehouseIds.isEmpty()) {
|
|
|
539 |
model.addAttribute("warehouses", warehouseRepository.selectByIds(new HashSet<>(warehouseIds)));
|
|
|
540 |
}
|
|
|
541 |
Map<Integer, String> fofoIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap();
|
|
|
542 |
model.addAttribute("fofoIdEmailIdMap", fofoIdEmailIdMap);
|
|
|
543 |
|
|
|
544 |
long size = instructionItemRepository.selectCountByAdminId(loginDetails.getFofoId());
|
|
|
545 |
model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
|
|
|
546 |
model.addAttribute("instructionItems", instructionItems);
|
|
|
547 |
model.addAttribute("start", offset + 1);
|
|
|
548 |
model.addAttribute("size", size);
|
|
|
549 |
if (instructionItems.size() < limit){
|
|
|
550 |
model.addAttribute("end", offset + instructionItems.size());
|
|
|
551 |
}else{
|
|
|
552 |
model.addAttribute("end", offset + limit);
|
|
|
553 |
}
|
|
|
554 |
|
|
|
555 |
return "instruction-items";
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
@RequestMapping(value = "/getPaginatedInstructionItems", method = RequestMethod.GET)
|
|
|
559 |
public String getPaginatedInstructionItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
560 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
561 |
List<InstructionItem> instructionItems = instructionItemRepository.selectAllByAdminId(loginDetails.getFofoId(), offset, limit);
|
|
|
562 |
|
|
|
563 |
Set<Integer> warehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
|
|
|
564 |
List<Warehouse> warehouses = warehouseRepository.selectByIds(warehouseIds);
|
|
|
565 |
Map<Integer, String> warehouseIdNameMap = this.warehouseIdNameMap(warehouses);
|
|
|
566 |
|
|
|
567 |
model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
|
|
|
568 |
model.addAttribute("instructionItems", instructionItems);
|
|
|
569 |
return "scan-out-partner-items-paginated";
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
@RequestMapping(value = "/scanOutPartnerItem", method = RequestMethod.POST)
|
|
|
573 |
public String scanOutPartnerItems(HttpServletRequest request, @RequestBody ScanOutPartnerItemRequest scanOutPartnerItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
574 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
575 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
576 |
inventoryService.scanOutPartnerItem(scanOutPartnerItemRequest, loginDetails.getFofoId());
|
|
|
577 |
return this.scanOutPartnerItems(request, scanOutPartnerItemRequest, offset, limit, model);
|
|
|
578 |
}
|
|
|
579 |
|
|
|
580 |
@RequestMapping(value = "/getPaginatedScanOutPartnerItems", method = RequestMethod.GET)
|
|
|
581 |
public String getPaginatedScanOutPartnerItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
582 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
583 |
List<ScanOutPartnerItem> scanOutPartnerItems = scanOutPartnerItemRepository.selectAllByFofoId(loginDetails.getFofoId(), offset, limit);
|
|
|
584 |
Map<Integer, String> itemIdDescriptionMap = this.scanOutPartnerItemsToItemIdDescriptionMap(scanOutPartnerItems);
|
|
|
585 |
model.addAttribute("scanOutPartnerItems", scanOutPartnerItems);
|
|
|
586 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
587 |
return "scan-out-partner-items-paginated";
|
|
|
588 |
}
|
|
|
589 |
|
| 23784 |
ashik.ali |
590 |
@RequestMapping(value = "/deliveryNoteDetails", method = RequestMethod.GET)
|
| 23883 |
ashik.ali |
591 |
public String deliveryNoteDetails(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DELIVERY_NOTE_ID) String deliveryNoteId, Model model) throws ProfitMandiBusinessException{
|
| 23784 |
ashik.ali |
592 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
593 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23883 |
ashik.ali |
594 |
AdminDeliveryNote adminDeliveryNote = adminDeliveryNoteRepository.selectByDeliveryNoteIdAndFofoid(deliveryNoteId, loginDetails.getFofoId());
|
|
|
595 |
if(adminDeliveryNote.getCompleteTimestamp() != null) {
|
|
|
596 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DELIVERY_NOTE_ID + ", " + ProfitMandiConstants.FOFO_ID, deliveryNoteId + ", " + loginDetails.getFofoId(), "NNBLBL_ITM_1002");
|
|
|
597 |
}
|
|
|
598 |
Warehouse warehouse = warehouseRepository.selectId(adminDeliveryNote.getWarehouseId());
|
|
|
599 |
List<Integer> instructionItemIds = adminDeliveryNoteDetailRepository.selectInstructionItemIdsByDeliveryNoteId(deliveryNoteId);
|
|
|
600 |
List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository.selectByInstructionItemIds(new HashSet<>(instructionItemIds));
|
|
|
601 |
Map<Integer, Integer> itemIdQuantityMap = this.instructionItemDetailsToItemIdQuantityMap(instructionItemDetails);
|
|
|
602 |
Map<Integer, String> itemIdDescriptionMap = this.itemIdDescriptionMap(itemIdQuantityMap.keySet());
|
|
|
603 |
Map<Integer, String> itemIdTypeMap = this.itemIdTypeMap(itemIdQuantityMap.keySet());
|
|
|
604 |
model.addAttribute("deliveryNoteId", deliveryNoteId);
|
|
|
605 |
model.addAttribute("warehouseName", warehouse.getName());
|
|
|
606 |
model.addAttribute("itemIdQuantityMap", itemIdQuantityMap);
|
|
|
607 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
608 |
model.addAttribute("itemIdTypeMap", itemIdTypeMap);
|
|
|
609 |
return "delivery-note-details";
|
| 23784 |
ashik.ali |
610 |
}
|
|
|
611 |
|
|
|
612 |
@RequestMapping(value = "/getItemsByWarehouseId", method = RequestMethod.GET)
|
|
|
613 |
public String getItemsByWarehouseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId, Model model) throws ProfitMandiBusinessException{
|
|
|
614 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
615 |
List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAllAvailableByWarehouseId(warehouseId);
|
|
|
616 |
Map<Integer, String> itemIdDescriptionMap = this.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
|
|
|
617 |
Map<Integer, String> itemIdTypeMap = this.adminCurrentInventorySnapshotsToItemIdTypeMap(adminCurrentInventorySnapshots);
|
|
|
618 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
619 |
model.addAttribute("itemIdTypeMap", itemIdTypeMap);
|
|
|
620 |
return "warehouse-items";
|
|
|
621 |
}
|
|
|
622 |
|
| 23883 |
ashik.ali |
623 |
@RequestMapping(value = "/getInstructionItemsByWarehouseId", method = RequestMethod.GET)
|
|
|
624 |
public String getInstructionItemsByWarehouseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId, Model model) throws ProfitMandiBusinessException{
|
|
|
625 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
626 |
List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAllAvailableByWarehouseId(warehouseId);
|
|
|
627 |
Map<Integer, String> itemIdDescriptionMap = this.adminCurrentInventorySnapshotsToItemIdDescriptionMap(adminCurrentInventorySnapshots);
|
|
|
628 |
Map<Integer, String> itemIdTypeMap = this.adminCurrentInventorySnapshotsToItemIdTypeMap(adminCurrentInventorySnapshots);
|
|
|
629 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
630 |
model.addAttribute("itemIdTypeMap", itemIdTypeMap);
|
|
|
631 |
return "warehouse-instruction-items";
|
|
|
632 |
}
|
| 23784 |
ashik.ali |
633 |
|
| 23883 |
ashik.ali |
634 |
@RequestMapping(value = "/getPendingInstructionItems", method = RequestMethod.GET)
|
|
|
635 |
public String getPendingInstructionItems(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId, @RequestParam(name = ProfitMandiConstants.USER_ID) int userId, Model model) throws ProfitMandiBusinessException{
|
|
|
636 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
|
|
637 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
638 |
List<InstructionItem> instructionItems = instructionItemRepository.selectByAdminIdWarehouseIdUserIdStatus(loginDetails.getFofoId(), warehouseId, userId, InstructionItemStatus.PENDING);
|
|
|
639 |
Set<Integer> instructionItemIds = this.instructionItemsToInstructionItemIds(instructionItems);
|
|
|
640 |
List<InstructionItemDetail> instructionItemDetails = instructionItemDetailRepository.selectByInstructionItemIds(instructionItemIds);
|
|
|
641 |
Set<Integer> itemIds = this.instructionItemDetailsToItemIds(instructionItemDetails);
|
|
|
642 |
Map<Integer, List<InstructionItemDetail>> instructionItemIdInstructionItemDetailsMap = this.instructionItemsToInstructionItemIdInstructionItemDetailsMap(instructionItemDetails);
|
|
|
643 |
Map<Integer, String> itemIdDescriptionMap = this.itemIdDescriptionMap(itemIds);
|
|
|
644 |
Map<Integer, String> itemIdTypeMap = this.itemIdTypeMap(itemIds);
|
|
|
645 |
model.addAttribute("instructionItems", instructionItems);
|
|
|
646 |
model.addAttribute("instructionItemIdInstructionItemDetailsMap", instructionItemIdInstructionItemDetailsMap);
|
|
|
647 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);
|
|
|
648 |
model.addAttribute("itemIdTypeMap", itemIdTypeMap);
|
|
|
649 |
return "pending-instruction-items";
|
|
|
650 |
}
|
|
|
651 |
|
| 23784 |
ashik.ali |
652 |
@RequestMapping(value = "/getScanOutItems", method = RequestMethod.GET)
|
|
|
653 |
public String getScanOutItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
654 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
| 23883 |
ashik.ali |
655 |
//List<AdminCurrentInventorySnapshot> adminCurrentInventorySnapshots = adminCurrentInventorySnapshotRepository.selectAll();
|
|
|
656 |
//Set<Integer> adminIds = this.getAdminIds(adminCurrentInventorySnapshots);
|
|
|
657 |
//Map<Integer, String> adminIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap(adminIds);
|
|
|
658 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
659 |
List<InstructionItem> instructionItems = instructionItemRepository.selectByAdminIdStatus(loginDetails.getFofoId(), InstructionItemStatus.PENDING);
|
|
|
660 |
|
|
|
661 |
List<Warehouse> warehouses = new ArrayList<>();
|
|
|
662 |
Map<Integer, String> fofoIdEmailIdMap = new HashMap<>();
|
|
|
663 |
if(!instructionItems.isEmpty()) {
|
|
|
664 |
Set<Integer> warehouseIds = this.instructionItemsToWarehouseIds(instructionItems);
|
|
|
665 |
warehouses = warehouseRepository.selectByIds(warehouseIds);
|
|
|
666 |
Set<Integer> fofoIds = this.instructionItemsToFofoIds(instructionItems);
|
|
|
667 |
fofoIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap(fofoIds);
|
|
|
668 |
}
|
|
|
669 |
|
| 23784 |
ashik.ali |
670 |
List<AdminDeliveryNote> adminDeliveryNotes = adminDeliveryNoteRepository.selectAll(offset, limit);
|
| 23883 |
ashik.ali |
671 |
Map<Integer, String> warehouseIdNameMap = new HashMap<>();
|
|
|
672 |
if(!adminDeliveryNotes.isEmpty()) {
|
|
|
673 |
List<Warehouse> adminDeliveryNoteWarehouses = warehouseRepository.selectByIds(this.adminDeliveryNotesToWarehouseIds(adminDeliveryNotes));
|
|
|
674 |
warehouseIdNameMap = this.warehouseIdNameMap(adminDeliveryNoteWarehouses);
|
|
|
675 |
fofoIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap(this.adminDeliveryNotesToFofoIds(adminDeliveryNotes));
|
|
|
676 |
}
|
| 23784 |
ashik.ali |
677 |
long size = adminDeliveryNoteRepository.selectAllCount();
|
| 23883 |
ashik.ali |
678 |
//model.addAttribute("adminIdEmailIdMap", adminIdEmailIdMap);
|
| 23784 |
ashik.ali |
679 |
model.addAttribute("adminDeliveryNotes", adminDeliveryNotes);
|
| 23883 |
ashik.ali |
680 |
model.addAttribute("warehouses", warehouses);
|
| 23784 |
ashik.ali |
681 |
model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
|
|
|
682 |
model.addAttribute("fofoIdEmailIdMap", fofoIdEmailIdMap);
|
|
|
683 |
model.addAttribute("start", offset + 1);
|
|
|
684 |
model.addAttribute("size", size);
|
|
|
685 |
if (adminDeliveryNotes.size() < limit){
|
|
|
686 |
model.addAttribute("end", offset + adminDeliveryNotes.size());
|
|
|
687 |
}else{
|
|
|
688 |
model.addAttribute("end", offset + limit);
|
|
|
689 |
}
|
|
|
690 |
return "scan-out-items";
|
|
|
691 |
}
|
|
|
692 |
|
| 23883 |
ashik.ali |
693 |
|
|
|
694 |
|
| 23784 |
ashik.ali |
695 |
@RequestMapping(value = "/scanOutItems", method = RequestMethod.POST)
|
|
|
696 |
public String scanOutItems(HttpServletRequest request, @RequestBody ScanOutItemRequest scanOutItemRequest, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
697 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), scanOutItemRequest);
|
| 23883 |
ashik.ali |
698 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
699 |
inventoryService.scanOutItem(scanOutItemRequest, loginDetails.getFofoId());
|
|
|
700 |
return this.getScanOutItems(request, offset, limit, model);
|
| 23784 |
ashik.ali |
701 |
}
|
|
|
702 |
|
|
|
703 |
@RequestMapping(value = "/getPaginatedScanOutItems", method = RequestMethod.GET)
|
|
|
704 |
public String getPaginatedScanOutItems(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException{
|
|
|
705 |
LOGGER.info("Request Received at url {}", request.getRequestURI());
|
| 23883 |
ashik.ali |
706 |
/*List<Warehouse> warehouses = warehouseRepository.selectAll();
|
| 23784 |
ashik.ali |
707 |
List<AdminDeliveryNote> adminDeliveryNotes = adminDeliveryNoteRepository.selectAll(offset, limit);
|
|
|
708 |
Map<Integer, String> itemIdDescriptionMap = this.adminDeliveryNotesToItemIdDescriptionMap(adminDeliveryNotes);
|
|
|
709 |
Map<Integer, String> warehouseIdNameMap = this.warehouseIdNameMap(warehouses);
|
|
|
710 |
Map<Integer, String> fofoIdEmailIdMap = retailerService.getAllFofoRetailerIdEmailIdMap();
|
|
|
711 |
model.addAttribute("adminDeliveryNotes", adminDeliveryNotes);
|
|
|
712 |
model.addAttribute("warehouseIdNameMap", warehouseIdNameMap);
|
|
|
713 |
model.addAttribute("fofoIdEmailIdMap", fofoIdEmailIdMap);
|
| 23883 |
ashik.ali |
714 |
model.addAttribute("itemIdDescriptionMap", itemIdDescriptionMap);*/
|
| 23784 |
ashik.ali |
715 |
return "scan-out-items-paginated";
|
|
|
716 |
}
|
|
|
717 |
|
| 23883 |
ashik.ali |
718 |
@RequestMapping(value = "/getSerialNumbersByItemIdWarehouseId", method = RequestMethod.GET)
|
|
|
719 |
public String getSerialNumbersByItemIdWarehouseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId,
|
| 23784 |
ashik.ali |
720 |
@RequestParam(name = ProfitMandiConstants.WAREHOUSE_ID) int warehouseId, Model model) throws ProfitMandiBusinessException{
|
| 23883 |
ashik.ali |
721 |
List<String> itemSerialNumbers = adminInventoryItemRepository.selectSerialNumbersByWarehouseIdItemIdScanType(warehouseId, itemId, ScanType.IN);
|
| 23784 |
ashik.ali |
722 |
model.addAttribute("itemSerialNumbers", itemSerialNumbers);
|
|
|
723 |
return "item-serial-numbers";
|
|
|
724 |
}
|
| 23883 |
ashik.ali |
725 |
|
|
|
726 |
@RequestMapping(value = "/getSerialNumbersByItemId", method = RequestMethod.GET)
|
|
|
727 |
public String getSerialNumbersByItemId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model) throws ProfitMandiBusinessException{
|
|
|
728 |
List<String> itemSerialNumbers = partnerInventoryItemRepository.selectSerialNumbersByItemIdScanType(itemId, ScanType.IN);
|
|
|
729 |
model.addAttribute("itemSerialNumbers", itemSerialNumbers);
|
|
|
730 |
return "item-serial-numbers-single";
|
|
|
731 |
}
|
| 23784 |
ashik.ali |
732 |
|
| 23883 |
ashik.ali |
733 |
|
| 23784 |
ashik.ali |
734 |
}
|