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