| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDate;
|
- |
|
| 4 |
import java.time.LocalDateTime;
|
- |
|
| 5 |
import java.time.LocalTime;
|
- |
|
| 6 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
| 7 |
import java.util.Arrays;
|
4 |
import java.util.Arrays;
|
| 8 |
import java.util.Collections;
|
5 |
import java.util.Collections;
|
| 9 |
import java.util.Comparator;
|
6 |
import java.util.Comparator;
|
| 10 |
import java.util.DoubleSummaryStatistics;
|
7 |
import java.util.DoubleSummaryStatistics;
|
| 11 |
import java.util.HashMap;
|
8 |
import java.util.HashMap;
|
| 12 |
import java.util.HashSet;
|
- |
|
| 13 |
import java.util.Iterator;
|
9 |
import java.util.Iterator;
|
| 14 |
import java.util.List;
|
10 |
import java.util.List;
|
| 15 |
import java.util.Map;
|
11 |
import java.util.Map;
|
| - |
|
12 |
import java.util.Optional;
|
| 16 |
import java.util.Set;
|
13 |
import java.util.Set;
|
| 17 |
import java.util.stream.Collectors;
|
14 |
import java.util.stream.Collectors;
|
| 18 |
|
15 |
|
| 19 |
import javax.servlet.http.HttpServletRequest;
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| 20 |
|
17 |
|
| - |
|
18 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 21 |
import org.apache.logging.log4j.LogManager;
|
19 |
import org.apache.logging.log4j.LogManager;
|
| 22 |
import org.apache.logging.log4j.Logger;
|
20 |
import org.apache.logging.log4j.Logger;
|
| 23 |
import org.apache.thrift.TException;
|
21 |
import org.apache.thrift.TException;
|
| 24 |
import org.json.JSONObject;
|
22 |
import org.json.JSONObject;
|
| 25 |
import org.springframework.beans.factory.annotation.Autowired;
|
23 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
24 |
import org.springframework.core.io.ByteArrayResource;
|
| - |
|
25 |
import org.springframework.http.HttpHeaders;
|
| - |
|
26 |
import org.springframework.http.HttpStatus;
|
| - |
|
27 |
import org.springframework.http.ResponseEntity;
|
| 26 |
import org.springframework.stereotype.Controller;
|
28 |
import org.springframework.stereotype.Controller;
|
| 27 |
import org.springframework.transaction.annotation.Transactional;
|
29 |
import org.springframework.transaction.annotation.Transactional;
|
| 28 |
import org.springframework.ui.Model;
|
30 |
import org.springframework.ui.Model;
|
| 29 |
import org.springframework.web.bind.annotation.PathVariable;
|
31 |
import org.springframework.web.bind.annotation.PathVariable;
|
| 30 |
import org.springframework.web.bind.annotation.RequestBody;
|
32 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 31 |
import org.springframework.web.bind.annotation.RequestMapping;
|
33 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 32 |
import org.springframework.web.bind.annotation.RequestMethod;
|
34 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 33 |
import org.springframework.web.bind.annotation.RequestParam;
|
35 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 34 |
|
36 |
|
| 35 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
37 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 36 |
import com.spice.profitmandi.common.enumuration.IndentStatus;
|
- |
|
| 37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 38 |
import com.spice.profitmandi.common.model.BrandPerformance;
|
39 |
import com.spice.profitmandi.common.model.BrandPerformance;
|
| - |
|
40 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
| 39 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 40 |
import com.spice.profitmandi.common.model.ItemIdAvailability;
|
42 |
import com.spice.profitmandi.common.model.ItemIdAvailability;
|
| 41 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
43 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
| - |
|
44 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
45 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 43 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
46 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
47 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
48 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 47 |
import com.spice.profitmandi.dao.entity.fofo.IndentItem;
|
- |
|
| 48 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
49 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 49 |
import com.spice.profitmandi.dao.entity.user.User;
|
50 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 50 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
51 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
52 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
53 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.dtr.IndentItemRepository;
|
- |
|
| 54 |
import com.spice.profitmandi.dao.repository.dtr.IndentRepository;
|
- |
|
| 55 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
54 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
- |
|
| 57 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
55 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
56 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
57 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
58 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 61 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
59 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| Line 93... |
Line 91... |
| 93 |
private final List<OrderStatus> validOrderStatusList = Arrays.asList(OrderStatus.ACCEPTED,
|
91 |
private final List<OrderStatus> validOrderStatusList = Arrays.asList(OrderStatus.ACCEPTED,
|
| 94 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
92 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
| 95 |
OrderStatus.DELIVERY_SUCCESS, OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
93 |
OrderStatus.DELIVERY_SUCCESS, OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
| 96 |
OrderStatus.REACHED_DESTINATION_CITY);
|
94 |
OrderStatus.REACHED_DESTINATION_CITY);
|
| 97 |
|
95 |
|
| - |
|
96 |
private final List<OrderStatus> partnerPendingOrderList = Arrays.asList(OrderStatus.ACCEPTED,
|
| - |
|
97 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
| - |
|
98 |
OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
| - |
|
99 |
OrderStatus.REACHED_DESTINATION_CITY);
|
| - |
|
100 |
|
| 98 |
@Autowired
|
101 |
@Autowired
|
| 99 |
private CookiesProcessor cookiesProcessor;
|
102 |
private CookiesProcessor cookiesProcessor;
|
| 100 |
|
103 |
|
| 101 |
@Autowired
|
104 |
@Autowired
|
| 102 |
private UserWalletRepository userWalletRepository;
|
105 |
private UserWalletRepository userWalletRepository;
|
| 103 |
|
106 |
|
| 104 |
@Autowired
|
107 |
@Autowired
|
| 105 |
private UserRepository userRepository;
|
108 |
private UserRepository userRepository;
|
| Line 112... |
Line 115... |
| 112 |
|
115 |
|
| 113 |
@Autowired
|
116 |
@Autowired
|
| 114 |
private ItemRepository itemRepository;
|
117 |
private ItemRepository itemRepository;
|
| 115 |
|
118 |
|
| 116 |
@Autowired
|
119 |
@Autowired
|
| 117 |
private IndentRepository indentRepository;
|
- |
|
| 118 |
|
- |
|
| 119 |
@Autowired
|
- |
|
| 120 |
private StockAllocationService stockAllocationService;
|
120 |
private StockAllocationService stockAllocationService;
|
| 121 |
|
121 |
|
| 122 |
@Autowired
|
122 |
@Autowired
|
| 123 |
private IndentItemRepository indentItemRepository;
|
- |
|
| 124 |
|
- |
|
| 125 |
@Autowired
|
- |
|
| 126 |
private RetailerService retailerService;
|
123 |
private RetailerService retailerService;
|
| 127 |
|
124 |
|
| 128 |
@Autowired
|
125 |
@Autowired
|
| 129 |
private TagListingRepository tagListingRepository;
|
126 |
private TagListingRepository tagListingRepository;
|
| 130 |
|
127 |
|
| 131 |
@Autowired
|
128 |
@Autowired
|
| 132 |
private FofoOrderRepository fofoOrderRepository;
|
- |
|
| 133 |
|
- |
|
| 134 |
@Autowired
|
- |
|
| 135 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
129 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 136 |
|
130 |
|
| 137 |
@Autowired
|
131 |
@Autowired
|
| 138 |
private PurchaseRepository purchaseRepository;
|
132 |
private PurchaseRepository purchaseRepository;
|
| 139 |
|
133 |
|
| Line 166... |
Line 160... |
| 166 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
160 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 167 |
}
|
161 |
}
|
| 168 |
return "response";
|
162 |
return "response";
|
| 169 |
}
|
163 |
}
|
| 170 |
|
164 |
|
| 171 |
@RequestMapping(value = "/migrate", method = RequestMethod.PUT)
|
165 |
@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
|
| 172 |
public String migrate(HttpServletRequest request, Model model) throws Exception {
|
166 |
public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
|
| 173 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
167 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 174 |
int fofoId = loginDetails.getFofoId();
|
168 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 175 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
169 |
Set<Integer> roleIds = cookiesProcessor.getCookiesObject(request).getRoleIds();
|
| 176 |
for (TagListing tagListing : tagListings) {
|
170 |
LOGGER.info("Counter size is {}", counterSize);
|
| 177 |
int itemId = tagListing.getItemId();
|
171 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 178 |
}
|
- |
|
| 179 |
return "";
|
- |
|
| 180 |
}
|
- |
|
| 181 |
|
- |
|
| 182 |
@RequestMapping(value = "/indent/inProcess")
|
172 |
if (roleManager.isAdmin(roleIds)) {
|
| 183 |
public String loadInProcessIndents(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
173 |
List<StockAllocationModel> stockAllocationList = stockAllocationService.getStockAllocation(counterSize,
|
| 184 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 185 |
int fofoId = loginDetails.getFofoId();
|
174 |
true);
|
| 186 |
|
- |
|
| 187 |
List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream()
|
175 |
Map<Integer, StockAllocationModel> modelStockAllocationMap = stockAllocationList.stream()
|
| 188 |
.map(x -> x.getId()).collect(Collectors.toList());
|
176 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 189 |
List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED)
|
177 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
| 190 |
.stream().map(x -> x.getId()).collect(Collectors.toList());
|
178 |
.collect(Collectors.toList());
|
| 191 |
pendingIndentIds.addAll(allocatedIndentIds);
|
179 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
| 192 |
|
180 |
|
| 193 |
if (pendingIndentIds.size() > 0) {
|
- |
|
| 194 |
Map<Integer, IndentItem> pendingIndentItemIdMap = indentItemRepository.selectIndentItems(pendingIndentIds)
|
181 |
Map<String, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 195 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
182 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 196 |
List<TagListing> tagListings = tagListingRepository
|
183 |
Iterator<TagListing> iterator = tagListings.iterator();
|
| 197 |
.selectByItemIdsAndTagIds(pendingIndentItemIdMap.keySet(), new HashSet<>(Arrays.asList(4)));
|
184 |
Map<Integer, List<CurrentInventorySnapshot>> itemListSnapshot = new HashMap<>();
|
| 198 |
|
185 |
|
| 199 |
List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, pendingIndentIds,
|
186 |
currentInventorySnapshotRepository.selectAll(Optional.of(true)).stream().forEach(x -> {
|
| 200 |
LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
|
- |
|
| 201 |
Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
|
187 |
if (!itemListSnapshot.containsKey(x.getItemId())) {
|
| 202 |
Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
|
188 |
itemListSnapshot.put(x.getItemId(), new ArrayList<>());
|
| 203 |
|
189 |
}
|
| 204 |
List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
|
- |
|
| 205 |
Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream()
|
- |
|
| 206 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
190 |
itemListSnapshot.get(x.getItemId()).add(x);
|
| - |
|
191 |
});
|
| 207 |
|
192 |
|
| - |
|
193 |
List<Order> inTransitOrders = orderRepository.selectOrders(fofoIds, partnerPendingOrderList);
|
| 208 |
for (TagListing tagListing : tagListings) {
|
194 |
Map<String, Integer> itemsInTransit = inTransitOrders.stream()
|
| 209 |
Integer itemId = tagListing.getItemId();
|
195 |
.collect(Collectors.groupingBy(
|
| 210 |
tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
|
196 |
x -> new String(x.getLineItem().getItemId() + "-" + x.getRetailerId()),
|
| - |
|
197 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| - |
|
198 |
|
| 211 |
if (itemQuantity.containsKey(itemId)) {
|
199 |
while (iterator.hasNext()) {
|
| 212 |
tagListing.setLast30DaysSale(itemQuantity.get(itemId));
|
200 |
TagListing tagListing = iterator.next();
|
| - |
|
201 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
| - |
|
202 |
if (item.getCategoryId() != 10006) {
|
| - |
|
203 |
continue;
|
| 213 |
}
|
204 |
}
|
| - |
|
205 |
int catalogId = item.getCatalogItemId();
|
| - |
|
206 |
if ((modelStockAllocationMap.containsKey(catalogId)
|
| - |
|
207 |
&& modelStockAllocationMap.get(catalogId).getQuantity() > 0)
|
| 214 |
if (itemIdSnapshotMap.containsKey(itemId)) {
|
208 |
|| itemListSnapshot.containsKey(item.getId())) {
|
| - |
|
209 |
List<CurrentInventorySnapshot> cisList = itemListSnapshot.get(item.getId());
|
| - |
|
210 |
if (cisList != null) {
|
| - |
|
211 |
for (CurrentInventorySnapshot cis : cisList) {
|
| - |
|
212 |
if (!catalogListingMap.containsKey(catalogId + "-" + cis.getFofoId())) {
|
| - |
|
213 |
CatalogListingModel catalogListingModel = new CatalogListingModel();
|
| - |
|
214 |
catalogListingModel.setFofoId(cis.getFofoId());
|
| - |
|
215 |
catalogListingModel.setModelName(item.getModelName());
|
| - |
|
216 |
catalogListingModel.setModelNumber(item.getModelNumber());
|
| - |
|
217 |
catalogListingModel.setCatalogId(catalogId);
|
| - |
|
218 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| - |
|
219 |
catalogListingModel.setMop(tagListing.getMop());
|
| - |
|
220 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| - |
|
221 |
StockAllocationModel stockAllocationModel = modelStockAllocationMap.get(item.getCatalogItemId());
|
| - |
|
222 |
int stockAllocationQuantity = stockAllocationModel == null ? 0
|
| - |
|
223 |
: stockAllocationModel.getQuantity();
|
| - |
|
224 |
catalogListingModel.setAllocatedQuantity(stockAllocationQuantity);
|
| - |
|
225 |
catalogListingModel.setToBeOrdered(stockAllocationQuantity);
|
| - |
|
226 |
catalogListingModel.setBrand(item.getBrand());
|
| - |
|
227 |
if (item.getCategoryId() == 10006) {
|
| - |
|
228 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| - |
|
229 |
}
|
| - |
|
230 |
catalogListingMap.put(catalogId + "-" + cis.getFofoId(), catalogListingModel);
|
| - |
|
231 |
}
|
| - |
|
232 |
CatalogListingModel catalogListingModel = catalogListingMap
|
| - |
|
233 |
.get(catalogId + "-" + cis.getFofoId());
|
| - |
|
234 |
|
| - |
|
235 |
int itemAvailability = cis.getAvailability();
|
| 215 |
tagListing.setStockInHand(itemIdSnapshotMap.get(itemId).getAvailability());
|
236 |
catalogListingModel.setStockInHand(catalogListingModel.getStockInHand() + itemAvailability);
|
| - |
|
237 |
|
| - |
|
238 |
Integer inTransitQuantity = itemsInTransit.get(item.getId() + "-" + cis.getFofoId());
|
| - |
|
239 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
| - |
|
240 |
catalogListingModel
|
| - |
|
241 |
.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
| - |
|
242 |
|
| - |
|
243 |
if (catalogListingModel.getAllocatedQuantity() > 0) {
|
| - |
|
244 |
int toBeOrdered = Math
|
| - |
|
245 |
.max(catalogListingModel.getToBeOrdered() - inTransitQty - itemAvailability, 0);
|
| - |
|
246 |
catalogListingModel.setToBeOrdered(toBeOrdered);
|
| - |
|
247 |
}
|
| - |
|
248 |
}
|
| - |
|
249 |
}
|
| 216 |
}
|
250 |
}
|
| 217 |
}
|
251 |
}
|
| - |
|
252 |
List<List<Object>> listOfRows = new ArrayList<>();
|
| - |
|
253 |
for (CatalogListingModel clm : catalogListingMap.values()) {
|
| - |
|
254 |
CustomRetailer cr = customRetailersMap.get(clm.getFofoId());
|
| - |
|
255 |
listOfRows
|
| - |
|
256 |
.add(Arrays.asList(cr.getPartnerId(), cr.getBusinessName(), clm.getBrand(), clm.getCatalogId(),
|
| - |
|
257 |
clm.getItemDescription(), clm.getDp(), clm.getMop(), clm.getAllocatedQuantity(),
|
| - |
|
258 |
clm.getInTransitQuantity(), clm.getStockInHand(), clm.getToBeOrdered()));
|
| 218 |
|
259 |
}
|
| - |
|
260 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("StoreId", "StoreName", "Catalog Id", "Brand", "Model", "DP", "MOP",
|
| 219 |
model.addAttribute("pendingIndentItemIdMap", pendingIndentItemIdMap);
|
261 |
"Allocated Quantity", "In Transit", "Stock In hand", "Shortage"), listOfRows);
|
| 220 |
model.addAttribute("tagListings", tagListings);
|
262 |
HttpHeaders headers = new HttpHeaders();
|
| - |
|
263 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| - |
|
264 |
headers.set("Content-disposition", "inline; filename=retailer-allocation.csv");
|
| - |
|
265 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(baos.toByteArray()), headers, HttpStatus.OK);
|
| 221 |
}
|
266 |
}
|
| 222 |
return "pending-indent";
|
267 |
return null;
|
| 223 |
}
|
268 |
}
|
| 224 |
|
269 |
|
| 225 |
@RequestMapping(value = "/indent/loadIndent")
|
270 |
@RequestMapping(value = "/indent/loadIndent")
|
| 226 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
271 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
| 227 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
272 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| Line 259... |
Line 304... |
| 259 |
stockAllocationList = stockAllocationService.getStockAllocation(counterSize, true);
|
304 |
stockAllocationList = stockAllocationService.getStockAllocation(counterSize, true);
|
| 260 |
}
|
305 |
}
|
| 261 |
LOGGER.info("Stock Allocation list is {}", stockAllocationList);
|
306 |
LOGGER.info("Stock Allocation list is {}", stockAllocationList);
|
| 262 |
|
307 |
|
| 263 |
Map<Integer, StockAllocationModel> itemStockAllocationMap = stockAllocationList.stream()
|
308 |
Map<Integer, StockAllocationModel> itemStockAllocationMap = stockAllocationList.stream()
|
| 264 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
309 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 265 |
Map<Integer, Integer> itemsInTransit = null;
|
310 |
Map<Integer, Integer> itemsInTransit = null;
|
| 266 |
LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
311 |
LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
| 267 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
312 |
List<TagListing> tagListings = tagListingRepository.selectAll(true);
|
| 268 |
if (!roleManager.isAdmin(roleIds)) {
|
313 |
if (!roleManager.isAdmin(roleIds)) {
|
| 269 |
tagListings = new ArrayList<>(tagListings);
|
314 |
tagListings = new ArrayList<>(tagListings);
|
| Line 276... |
Line 321... |
| 276 |
}
|
321 |
}
|
| 277 |
Iterator<TagListing> iterator = tagListings.iterator();
|
322 |
Iterator<TagListing> iterator = tagListings.iterator();
|
| 278 |
int totalPcs = 0;
|
323 |
int totalPcs = 0;
|
| 279 |
int toBeOrdered = 0;
|
324 |
int toBeOrdered = 0;
|
| 280 |
float totalAmount = 0;
|
325 |
float totalAmount = 0;
|
| - |
|
326 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 281 |
while (iterator.hasNext()) {
|
327 |
while (iterator.hasNext()) {
|
| 282 |
TagListing tagListing = iterator.next();
|
328 |
TagListing tagListing = iterator.next();
|
| 283 |
LOGGER.info(" tagListing.setAllocatedQuantity {}", tagListing.getAllocatedQuantity());
|
- |
|
| - |
|
329 |
|
| 284 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
330 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
| - |
|
331 |
// itemRepository.select
|
| - |
|
332 |
// catalogTagListingMap
|
| 285 |
if (roleManager.isAdmin(roleIds)) {
|
333 |
if (roleManager.isAdmin(roleIds)) {
|
| 286 |
if (item.getBrand() == null || item.getCategoryId() == 0) {
|
334 |
if (item.getBrand() == null || item.getCategoryId() != 10006) {
|
| 287 |
iterator.remove();
|
335 |
iterator.remove();
|
| 288 |
continue;
|
336 |
continue;
|
| 289 |
}
|
337 |
}
|
| 290 |
} else {
|
338 |
} else {
|
| 291 |
if (!itemCisMap.containsKey(tagListing.getItemId())
|
339 |
if (!(itemCisMap.containsKey(tagListing.getItemId())
|
| 292 |
&& !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
340 |
|| itemStockAllocationMap.containsKey(tagListing.getItemId()))
|
| - |
|
341 |
) {
|
| 293 |
iterator.remove();
|
342 |
iterator.remove();
|
| 294 |
continue;
|
343 |
continue;
|
| 295 |
}
|
344 |
}
|
| 296 |
}
|
345 |
}
|
| 297 |
ItemIdAvailability itemIdAvailability = itemCisMap.get(tagListing.getItemId());
|
346 |
int catalogId = item.getCatalogItemId();
|
| 298 |
tagListing.setStockInHand(itemIdAvailability == null ? 0 : itemIdAvailability.getAvailability());
|
- |
|
| 299 |
StockAllocationModel stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
- |
|
| 300 |
|
347 |
|
| 301 |
if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
348 |
CatalogListingModel catalogListingModel = catalogListingMap.get(catalogId);
|
| 302 |
tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
349 |
if (!catalogListingMap.containsKey(catalogId)) {
|
| 303 |
} else {
|
- |
|
| 304 |
tagListing.setInTransitQuantity(0);
|
350 |
catalogListingModel = new CatalogListingModel();
|
| 305 |
}
|
- |
|
| 306 |
if (stockAllocationModel != null) {
|
351 |
catalogListingModel.setCatalogId(catalogId);
|
| 307 |
tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
352 |
catalogListingModel.setDp(tagListing.getSellingPrice());
|
| 308 |
toBeOrdered = Math.max(tagListing.getAllocatedQuantity() - tagListing.getInTransitQuantity()
|
353 |
catalogListingModel.setMop(tagListing.getMop());
|
| 309 |
- tagListing.getStockInHand(), 0);
|
354 |
catalogListingModel.setItemDescription(item.getItemDescriptionNoColor());
|
| 310 |
totalPcs += toBeOrdered;
|
355 |
StockAllocationModel stockAllocationModel = itemStockAllocationMap.get(item.getCatalogItemId());
|
| 311 |
totalAmount += toBeOrdered * tagListing.getSellingPrice();
|
356 |
int stockAllocationQuantity = stockAllocationModel == null ? 0 : stockAllocationModel.getQuantity();
|
| 312 |
tagListing.setToBeOrdered(toBeOrdered);
|
357 |
catalogListingModel.setAllocatedQuantity(stockAllocationQuantity);
|
| 313 |
} else {
|
- |
|
| 314 |
tagListing.setAllocatedQuantity(0);
|
358 |
catalogListingModel.setToBeOrdered(stockAllocationQuantity);
|
| 315 |
}
|
- |
|
| 316 |
tagListing.setBrand(item.getBrand());
|
359 |
catalogListingModel.setBrand(item.getBrand());
|
| 317 |
tagListing.setItemDescription(item.getItemDescription());
|
- |
|
| 318 |
if (item.getCategoryId() == 10006) {
|
360 |
if (item.getCategoryId() == 10006) {
|
| 319 |
tagListing.setCategoryId(item.getCategoryId());
|
361 |
catalogListingModel.setCategoryId(item.getCategoryId());
|
| - |
|
362 |
}
|
| - |
|
363 |
catalogListingMap.put(catalogId, catalogListingModel);
|
| 320 |
}
|
364 |
}
|
| 321 |
// LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
- |
|
| 322 |
// tagListing.getAllocatedQuantity());
|
- |
|
| 323 |
}
|
- |
|
| 324 |
|
365 |
|
| - |
|
366 |
ItemIdAvailability itemIdAvailability = itemCisMap.get(tagListing.getItemId());
|
| - |
|
367 |
int itemAvailability = itemIdAvailability == null ? 0 : itemIdAvailability.getAvailability();
|
| - |
|
368 |
catalogListingModel.setStockInHand(catalogListingModel.getStockInHand() + itemAvailability);
|
| - |
|
369 |
|
| - |
|
370 |
Integer inTransitQuantity = itemsInTransit.get(item.getId());
|
| - |
|
371 |
int inTransitQty = (inTransitQuantity == null ? 0 : inTransitQuantity);
|
| - |
|
372 |
catalogListingModel.setInTransitQuantity(catalogListingModel.getInTransitQuantity() + inTransitQty);
|
| - |
|
373 |
|
| - |
|
374 |
if (catalogListingModel.getAllocatedQuantity() > 0) {
|
| - |
|
375 |
toBeOrdered = Math.max(catalogListingModel.getToBeOrdered() - inTransitQty - itemAvailability, 0);
|
| - |
|
376 |
catalogListingModel.setToBeOrdered(toBeOrdered);
|
| - |
|
377 |
}
|
| - |
|
378 |
}
|
| - |
|
379 |
List<CatalogListingModel> catalogModelList = new ArrayList<>(catalogListingMap.values());
|
| - |
|
380 |
|
| 325 |
Map<Integer, List<TagListing>> performanceMap = tagListings.stream()
|
381 |
Map<Boolean, List<CatalogListingModel>> performanceMap = catalogModelList.stream()
|
| 326 |
.collect(Collectors.groupingBy(x -> x.getCategoryId()));
|
382 |
.collect(Collectors.groupingBy(x -> x.getCategoryId() == 10006));
|
| 327 |
List<TagListing> accsListing = performanceMap.get(0);
|
383 |
List<CatalogListingModel> mobileListing = performanceMap.get(true) == null ? new ArrayList<>()
|
| - |
|
384 |
: performanceMap.get(true);
|
| 328 |
List<TagListing> mobileListing = performanceMap.get(10006);
|
385 |
List<CatalogListingModel> accsListing = performanceMap.get(false) == null ? new ArrayList<>()
|
| - |
|
386 |
: performanceMap.get(false);
|
| 329 |
|
387 |
|
| 330 |
Map<String, DoubleSummaryStatistics> accsStats = accsListing.stream().collect(Collectors.groupingBy(
|
388 |
Map<String, DoubleSummaryStatistics> accsStats = accsListing.stream().collect(Collectors.groupingBy(
|
| 331 |
x -> x.getBrand(), Collectors.summarizingDouble(x -> x.getAllocatedQuantity() * x.getMop())));
|
389 |
x -> x.getBrand(), Collectors.summarizingDouble(x -> x.getAllocatedQuantity() * x.getMop())));
|
| 332 |
Map<String, DoubleSummaryStatistics> mobStats = mobileListing.stream().collect(Collectors.groupingBy(
|
390 |
Map<String, DoubleSummaryStatistics> mobStats = mobileListing.stream().collect(Collectors.groupingBy(
|
| 333 |
x -> x.getBrand(), Collectors.summarizingDouble(x -> x.getAllocatedQuantity() * x.getMop())));
|
391 |
x -> x.getBrand(), Collectors.summarizingDouble(x -> x.getAllocatedQuantity() * x.getMop())));
|
| Line 364... |
Line 422... |
| 364 |
} else {
|
422 |
} else {
|
| 365 |
model.addAttribute("counterSize", counterSize.toString());
|
423 |
model.addAttribute("counterSize", counterSize.toString());
|
| 366 |
}
|
424 |
}
|
| 367 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
425 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 368 |
LOGGER.info("Custom retailers {}", customRetailers);
|
426 |
LOGGER.info("Custom retailers {}", customRetailers);
|
| 369 |
Comparator<TagListing> firstCmp = Comparator
|
427 |
// Lits<CatalogTagListing> catalog
|
| 370 |
.comparing(x -> ((x.getAllocatedQuantity() - x.getStockInHand() - x.getInTransitQuantity() == 0)
|
428 |
Comparator<CatalogListingModel> firstCmp = Comparator.comparing(CatalogListingModel::getToBeOrdered,
|
| 371 |
? Integer.MIN_VALUE
|
429 |
Comparator.reverseOrder());
|
| 372 |
: (x.getAllocatedQuantity() - x.getStockInHand())), Comparator.reverseOrder());
|
430 |
model.addAttribute("catalogTagListings",
|
| 373 |
model.addAttribute("tagListings", tagListings.stream().sorted(firstCmp).collect(Collectors.toList()));
|
431 |
catalogModelList.stream().sorted(firstCmp).collect(Collectors.toList()));
|
| 374 |
model.addAttribute("customRetailers", customRetailers);
|
432 |
model.addAttribute("customRetailers", customRetailers);
|
| 375 |
model.addAttribute("brandPerformanceList", brandPerformanceList);
|
433 |
model.addAttribute("brandPerformanceList", brandPerformanceList);
|
| 376 |
model.addAttribute("accsBrandPerformanceList", accsBrandPerformanceList);
|
434 |
model.addAttribute("accsBrandPerformanceList", accsBrandPerformanceList);
|
| 377 |
model.addAttribute("counterSizes", CounterSize.values());
|
435 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 378 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
436 |
model.addAttribute("isAdmin", roleManager.isAdmin(roleIds));
|
| Line 398... |
Line 456... |
| 398 |
}
|
456 |
}
|
| 399 |
}
|
457 |
}
|
| 400 |
return lastOrdersList;
|
458 |
return lastOrdersList;
|
| 401 |
}
|
459 |
}
|
| 402 |
|
460 |
|
| 403 |
@RequestMapping(value = "/indent/confirm-pause/{tagId}", method=RequestMethod.POST)
|
461 |
@RequestMapping(value = "/indent/confirm-pause/{tagId}", method = RequestMethod.POST)
|
| 404 |
public String raisePO(HttpServletRequest request, Model model, @PathVariable int tagId) throws Exception {
|
462 |
public String raisePO(HttpServletRequest request, Model model, @PathVariable int tagId) throws Exception {
|
| 405 |
tagListingRepository.updateActiveById(tagId, false);
|
463 |
tagListingRepository.updateActiveById(tagId, false);
|
| 406 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
464 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 407 |
return "response";
|
465 |
return "response";
|
| 408 |
}
|
466 |
}
|
| - |
|
467 |
|
| 409 |
@RequestMapping(value = "/indent/create-po", method=RequestMethod.POST)
|
468 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
| 410 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
469 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
| 411 |
boolean success = false;
|
470 |
boolean success = false;
|
| 412 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
471 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 413 |
int fofoId = loginDetails.getFofoId();
|
472 |
int fofoId = loginDetails.getFofoId();
|
| 414 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
473 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
| 415 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(Arrays.asList(fofoId)).get(fofoId);
|
474 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(Arrays.asList(fofoId)).get(fofoId);
|
| 416 |
Client userClient = new UserClient().getClient();
|
475 |
Client userClient = new UserClient().getClient();
|
| 417 |
double totalAmount = itemQuantities.stream().mapToDouble(x->x.getQty()*x.getPrice()).sum();
|
476 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
| 418 |
|
477 |
|
| 419 |
if(totalAmount > 0) {
|
478 |
if (totalAmount > 0) {
|
| 420 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
479 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
| 421 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
480 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
| 422 |
userClient = new UserClient().getClient();
|
481 |
userClient = new UserClient().getClient();
|
| 423 |
LOGGER.info("Setting wallet amount in cart");
|
482 |
LOGGER.info("Setting wallet amount in cart");
|
| 424 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(), 7890,
|
483 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
| 425 |
OrderSource.WEBSITE.getValue(), true);
|
484 |
7890, OrderSource.WEBSITE.getValue(), true);
|
| 426 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
485 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
| 427 |
createPayment(user, totalAmount, transactionId);
|
486 |
createPayment(user, totalAmount, transactionId);
|
| 428 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
487 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
| 429 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
488 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
| 430 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B,
|
489 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| 431 |
OrderSource.WEBSITE);
|
- |
|
| 432 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
490 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
| 433 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B,
|
491 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| 434 |
OrderSource.WEBSITE);
|
- |
|
| 435 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
492 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
| 436 |
transactionClient = new TransactionClient().getClient();
|
493 |
transactionClient = new TransactionClient().getClient();
|
| 437 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
494 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
| 438 |
try {
|
495 |
try {
|
| 439 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
496 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
| Line 444... |
Line 501... |
| 444 |
resetCart(transactionClient.getTransaction(transactionId));
|
501 |
resetCart(transactionClient.getTransaction(transactionId));
|
| 445 |
}
|
502 |
}
|
| 446 |
model.addAttribute("response", mvcResponseSender.createResponseString(success));
|
503 |
model.addAttribute("response", mvcResponseSender.createResponseString(success));
|
| 447 |
return "response";
|
504 |
return "response";
|
| 448 |
}
|
505 |
}
|
| 449 |
|
506 |
|
| 450 |
private void createPayment(User user, double totalAmount, long transactionId) throws NumberFormatException, PaymentException, TException {
|
507 |
private void createPayment(User user, double totalAmount, long transactionId)
|
| - |
|
508 |
throws NumberFormatException, PaymentException, TException {
|
| 451 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
509 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
| 452 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
510 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
| 453 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
511 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
| 454 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId, false);
|
512 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
| - |
|
513 |
false);
|
| 455 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.SUCCESS, null,
|
514 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
| 456 |
paymentAttributes);
|
515 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
| 457 |
}
|
516 |
}
|
| - |
|
517 |
|
| 458 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
518 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
| 459 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
519 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
| - |
|
520 |
/*
|
| 460 |
Map<Integer, ItemIdAvailability> itemCisMap = null;
|
521 |
* Map<Integer, ItemIdAvailability> itemCisMap = null; List<ItemIdAvailability>
|
| 461 |
List<ItemIdAvailability> currentInventorySnapshots = currentInventorySnapshotRepository
|
522 |
* currentInventorySnapshots = currentInventorySnapshotRepository
|
| 462 |
.selectItemsStock(fofoId);
|
523 |
* .selectItemsStock(fofoId); itemCisMap =
|
| 463 |
itemCisMap = currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
524 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
| 464 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
525 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| - |
|
526 |
* List<StockAllocationModel> stockAllocationList =
|
| 465 |
List<StockAllocationModel> stockAllocationList = stockAllocationService.getStockAllocation(fofoId, true);
|
527 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
| 466 |
|
528 |
*
|
| 467 |
Map<Integer, StockAllocationModel> itemStockAllocationMap = stockAllocationList.stream()
|
529 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
| 468 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
530 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
| 469 |
Map<Integer, Integer> itemsInTransit = null;
|
531 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
| 470 |
LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
532 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
| 471 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
533 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
| 472 |
List<Order> inTransitOrders = orderRepository.selectOrders(fofoId, validOrderStatusList);
|
534 |
* List<Order> inTransitOrders = orderRepository.selectOrders(fofoId,
|
| - |
|
535 |
* validOrderStatusList); inTransitOrders =
|
| 473 |
inTransitOrders = this.filterValidOrders(inTransitOrders);
|
536 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
| 474 |
itemsInTransit = inTransitOrders.stream().collect(Collectors.groupingBy(x -> x.getLineItem().getItemId(),
|
537 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
| - |
|
538 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
| 475 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
539 |
* x.getLineItem().getQuantity())));
|
| 476 |
|
540 |
*
|
| 477 |
Iterator<TagListing> iterator = tagListings.iterator();
|
541 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
| 478 |
|
542 |
*
|
| 479 |
int toBeOrdered = 0;
|
- |
|
| 480 |
while (iterator.hasNext()) {
|
543 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
| 481 |
TagListing tagListing = iterator.next();
|
544 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
| 482 |
LOGGER.info(" tagListing.setAllocatedQuantity {}", tagListing.getAllocatedQuantity());
|
545 |
* tagListing.getAllocatedQuantity()); if
|
| 483 |
if (!itemCisMap.containsKey(tagListing.getItemId())
|
546 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
| 484 |
&& !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
547 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
| 485 |
iterator.remove();
|
548 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
| 486 |
continue;
|
- |
|
| 487 |
}
|
- |
|
| 488 |
ItemIdAvailability itemIdAvailability = itemCisMap.get(tagListing.getItemId());
|
549 |
* itemCisMap.get(tagListing.getItemId());
|
| 489 |
tagListing.setStockInHand(itemIdAvailability == null ? 0 : itemIdAvailability.getAvailability());
|
550 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
| - |
|
551 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
| 490 |
StockAllocationModel stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
552 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
| 491 |
|
553 |
*
|
| 492 |
if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
554 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
| 493 |
tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
555 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
| 494 |
} else {
|
- |
|
| 495 |
tagListing.setInTransitQuantity(0);
|
556 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
| 496 |
}
|
- |
|
| 497 |
if (stockAllocationModel != null) {
|
- |
|
| 498 |
tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
557 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
| 499 |
toBeOrdered = Math.max(tagListing.getAllocatedQuantity() - tagListing.getInTransitQuantity()
|
558 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
| 500 |
- tagListing.getStockInHand(), 0);
|
559 |
* tagListing.getInTransitQuantity() - tagListing.getStockInHand(), 0); if
|
| 501 |
if (toBeOrdered > 0) {
|
- |
|
| 502 |
ItemPriceQuantity ipq = new ItemPriceQuantity();
|
560 |
* (toBeOrdered > 0) { ItemPriceQuantity ipq = new ItemPriceQuantity();
|
| 503 |
ipq.setItemId(tagListing.getItemId());
|
561 |
* ipq.setItemId(tagListing.getItemId()); ipq.setQty((long) toBeOrdered);
|
| 504 |
ipq.setQty((long)toBeOrdered);
|
- |
|
| 505 |
ipq.setPrice(tagListing.getSellingPrice());
|
562 |
* ipq.setPrice(tagListing.getSellingPrice()); itemQuantities.add(ipq); } } }
|
| 506 |
itemQuantities.add(ipq);
|
- |
|
| 507 |
}
|
563 |
*/
|
| 508 |
}
|
- |
|
| 509 |
}
|
- |
|
| 510 |
return itemQuantities;
|
564 |
return itemQuantities;
|
| 511 |
|
565 |
|
| 512 |
}
|
566 |
}
|
| 513 |
|
567 |
|
| 514 |
private long resetCart(Transaction transaction) {
|
568 |
private long resetCart(Transaction transaction) {
|
| 515 |
long sum = 0;
|
569 |
long sum = 0;
|
| 516 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
570 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
| 517 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
571 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
| 518 |
sum += order.getGvAmount();
|
572 |
sum += order.getGvAmount();
|