| Line 3... |
Line 3... |
| 3 |
import java.time.LocalDate;
|
3 |
import java.time.LocalDate;
|
| 4 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.LocalTime;
|
5 |
import java.time.LocalTime;
|
| 6 |
import java.util.ArrayList;
|
6 |
import java.util.ArrayList;
|
| 7 |
import java.util.Arrays;
|
7 |
import java.util.Arrays;
|
| 8 |
import java.util.HashMap;
|
- |
|
| 9 |
import java.util.HashSet;
|
8 |
import java.util.HashSet;
|
| 10 |
import java.util.List;
|
9 |
import java.util.List;
|
| 11 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 12 |
import java.util.stream.Collectors;
|
11 |
import java.util.stream.Collectors;
|
| 13 |
|
12 |
|
| 14 |
import javax.servlet.http.HttpServletRequest;
|
13 |
import javax.servlet.http.HttpServletRequest;
|
| 15 |
|
14 |
|
| 16 |
import org.apache.logging.log4j.LogManager;
|
15 |
import org.apache.logging.log4j.LogManager;
|
| 17 |
import org.apache.logging.log4j.Logger;
|
16 |
import org.apache.logging.log4j.Logger;
|
| - |
|
17 |
import org.json.JSONObject;
|
| 18 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 19 |
import org.springframework.stereotype.Controller;
|
19 |
import org.springframework.stereotype.Controller;
|
| 20 |
import org.springframework.transaction.annotation.Transactional;
|
20 |
import org.springframework.transaction.annotation.Transactional;
|
| 21 |
import org.springframework.ui.Model;
|
21 |
import org.springframework.ui.Model;
|
| 22 |
import org.springframework.web.bind.annotation.RequestBody;
|
22 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
25 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 25 |
|
26 |
|
| 26 |
import com.spice.profitmandi.common.enumuration.IndentStatus;
|
27 |
import com.spice.profitmandi.common.enumuration.IndentStatus;
|
| 27 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 28 |
import com.spice.profitmandi.common.model.ItemIdQuantity;
|
29 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
| 29 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
30 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 30 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
31 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
32 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 32 |
import com.spice.profitmandi.dao.entity.fofo.Indent;
|
- |
|
| 33 |
import com.spice.profitmandi.dao.entity.fofo.IndentItem;
|
33 |
import com.spice.profitmandi.dao.entity.fofo.IndentItem;
|
| 34 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
34 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
35 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
36 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| - |
|
37 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.dtr.IndentItemRepository;
|
38 |
import com.spice.profitmandi.dao.repository.dtr.IndentItemRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.dtr.IndentRepository;
|
39 |
import com.spice.profitmandi.dao.repository.dtr.IndentRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
40 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
41 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 41 |
import com.spice.profitmandi.service.indent.IndentService;
|
42 |
import com.spice.profitmandi.service.indent.IndentService;
|
| - |
|
43 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
| - |
|
44 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 42 |
import com.spice.profitmandi.web.model.LoginDetails;
|
45 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 43 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
46 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 44 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
47 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 45 |
|
48 |
|
| 46 |
@Controller
|
49 |
@Controller
|
| Line 49... |
Line 52... |
| 49 |
|
52 |
|
| 50 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
53 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
| 51 |
|
54 |
|
| 52 |
@Autowired
|
55 |
@Autowired
|
| 53 |
private CookiesProcessor cookiesProcessor;
|
56 |
private CookiesProcessor cookiesProcessor;
|
| - |
|
57 |
|
| - |
|
58 |
@Autowired
|
| - |
|
59 |
FofoStoreRepository fofoStoreRepository;
|
| 54 |
|
60 |
|
| 55 |
@Autowired
|
61 |
@Autowired
|
| 56 |
private CategoryRepository categoryRepository;
|
62 |
private CategoryRepository categoryRepository;
|
| 57 |
|
63 |
|
| 58 |
@Autowired
|
64 |
@Autowired
|
| Line 60... |
Line 66... |
| 60 |
|
66 |
|
| 61 |
@Autowired
|
67 |
@Autowired
|
| 62 |
private IndentRepository indentRepository;
|
68 |
private IndentRepository indentRepository;
|
| 63 |
|
69 |
|
| 64 |
@Autowired
|
70 |
@Autowired
|
| - |
|
71 |
private StockAllocationService stockAllocationService;
|
| - |
|
72 |
|
| - |
|
73 |
@Autowired
|
| 65 |
private IndentItemRepository indentItemRepository;
|
74 |
private IndentItemRepository indentItemRepository;
|
| - |
|
75 |
|
| - |
|
76 |
@Autowired
|
| - |
|
77 |
private RetailerService retailerService;
|
| 66 |
|
78 |
|
| 67 |
@Autowired
|
79 |
@Autowired
|
| 68 |
private IndentService indentService;
|
80 |
private IndentService indentService;
|
| 69 |
|
81 |
|
| 70 |
@Autowired
|
82 |
@Autowired
|
| Line 77... |
Line 89... |
| 77 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
89 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 78 |
|
90 |
|
| 79 |
@Autowired
|
91 |
@Autowired
|
| 80 |
private MVCResponseSender mvcResponseSender;
|
92 |
private MVCResponseSender mvcResponseSender;
|
| 81 |
|
93 |
|
| 82 |
@RequestMapping(value = "/indent-item/save", method = RequestMethod.PUT)
|
94 |
/*@RequestMapping(value = "/indent-item/save", method = RequestMethod.PUT)
|
| 83 |
public String saveIndentItem(HttpServletRequest request, @RequestBody ItemIdQuantity itemIdQuantity, Model model)
|
95 |
public String saveIndentItem(HttpServletRequest request, @RequestBody ItemIdQuantity itemIdQuantity, Model model)
|
| 84 |
throws Exception {
|
96 |
throws Exception {
|
| 85 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
97 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 86 |
LOGGER.info("Item id is {}, And quantity is {}", itemIdQuantity.getItemId(), itemIdQuantity.getItemId());
|
98 |
LOGGER.info("Item id is {}, And quantity is {}", itemIdQuantity.getItemId(), itemIdQuantity.getItemId());
|
| - |
|
99 |
boolean response = false;
|
| 87 |
int fofoId = loginDetails.getFofoId();
|
100 |
if(loginDetails.isAdmin()) {
|
| - |
|
101 |
StockAllocationModel stockAllocationModel = new StockAllocationModel();
|
| - |
|
102 |
stockAllocationModel.setQuantity(itemIdQuantity.getQuantity());
|
| 88 |
boolean response = indentService.updateOpenIndentItem(fofoId, itemIdQuantity.getItemId(),
|
103 |
stockAllocationModel.setItemId(itemIdQuantity.getItemId());
|
| - |
|
104 |
response = stockAllocationService.addToAllocation(stockAllocationModel);
|
| - |
|
105 |
}
|
| 89 |
itemIdQuantity.getQuantity());
|
106 |
//int fofoId = loginDetails.getFofoId();
|
| 90 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
107 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 91 |
return "response";
|
108 |
return "response";
|
| 92 |
}
|
109 |
}*/
|
| 93 |
|
110 |
|
| 94 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.PUT)
|
111 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 95 |
public String saveOpenIndent(HttpServletRequest request, Model model) throws Exception {
|
112 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestBody List<StockAllocationModel> stockAllocationModelList) throws Exception {
|
| 96 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
113 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 97 |
int fofoId = loginDetails.getFofoId();
|
114 |
boolean response = false;
|
| 98 |
List<Indent> openIndents = indentRepository.selectIndentByStatus(fofoId, IndentStatus.OPEN);
|
- |
|
| 99 |
if (openIndents.size() > 0) {
|
115 |
if(loginDetails.isAdmin()) {
|
| 100 |
Indent openIndent = openIndents.get(0);
|
- |
|
| 101 |
if (indentItemRepository.selectIndentItems(Arrays.asList(openIndent.getId())).size() == 0) {
|
- |
|
| 102 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
116 |
response = stockAllocationService.addToAllocation(stockAllocationModelList);
|
| 103 |
}
|
- |
|
| 104 |
openIndent.setCreateTimestamp(LocalDateTime.now());
|
- |
|
| 105 |
openIndent.setStatus(IndentStatus.ALLOCATED);
|
- |
|
| 106 |
indentRepository.persist(openIndent);
|
- |
|
| 107 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
117 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 108 |
}
|
118 |
}
|
| 109 |
return "response";
|
119 |
return "response";
|
| 110 |
}
|
120 |
}
|
| 111 |
|
121 |
|
| 112 |
@RequestMapping(value = "/migrate", method = RequestMethod.PUT)
|
122 |
@RequestMapping(value = "/migrate", method = RequestMethod.PUT)
|
| 113 |
public String migrate(HttpServletRequest request, Model model) throws Exception {
|
123 |
public String migrate(HttpServletRequest request, Model model) throws Exception {
|
| 114 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
124 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 115 |
int fofoId = loginDetails.getFofoId();
|
125 |
int fofoId = loginDetails.getFofoId();
|
| 116 |
List<TagListing> tagListings = tagListingRepository.selectAll();
|
126 |
List<TagListing> tagListings = tagListingRepository.selectAll();
|
| 117 |
for(TagListing tagListing : tagListings) {
|
127 |
for (TagListing tagListing : tagListings) {
|
| 118 |
int itemId = tagListing.getItemId();
|
128 |
int itemId = tagListing.getItemId();
|
| 119 |
}
|
129 |
}
|
| 120 |
return "";
|
130 |
return "";
|
| 121 |
}
|
131 |
}
|
| 122 |
|
132 |
|
| 123 |
@RequestMapping(value = "/indent/inProcess")
|
133 |
@RequestMapping(value = "/indent/inProcess")
|
| 124 |
public String loadInProcessIndents(HttpServletRequest request, Model model) throws ProfitMandiBusinessException{
|
134 |
public String loadInProcessIndents(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 125 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
135 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 126 |
int fofoId = loginDetails.getFofoId();
|
136 |
int fofoId = loginDetails.getFofoId();
|
| 127 |
|
137 |
|
| 128 |
List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream().map(x->x.getId()).collect(Collectors.toList());
|
138 |
List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream()
|
| - |
|
139 |
.map(x -> x.getId()).collect(Collectors.toList());
|
| 129 |
List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED).stream().map(x->x.getId()).collect(Collectors.toList());
|
140 |
List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED)
|
| - |
|
141 |
.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 130 |
pendingIndentIds.addAll(allocatedIndentIds);
|
142 |
pendingIndentIds.addAll(allocatedIndentIds);
|
| 131 |
|
143 |
|
| 132 |
if(pendingIndentIds.size() > 0) {
|
144 |
if (pendingIndentIds.size() > 0) {
|
| 133 |
Map<Integer, IndentItem> pendingIndentItemIdMap = indentItemRepository.selectIndentItems(pendingIndentIds).stream().collect(Collectors.toMap(x->x.getItemId(), x->x));
|
145 |
Map<Integer, IndentItem> pendingIndentItemIdMap = indentItemRepository.selectIndentItems(pendingIndentIds)
|
| - |
|
146 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| - |
|
147 |
List<TagListing> tagListings = tagListingRepository
|
| 134 |
List<TagListing> tagListings = tagListingRepository.selectByItemIdsAndTagIds(pendingIndentItemIdMap.keySet(), new HashSet<>(Arrays.asList(4)));
|
148 |
.selectByItemIdsAndTagIds(pendingIndentItemIdMap.keySet(), new HashSet<>(Arrays.asList(4)));
|
| 135 |
|
149 |
|
| 136 |
List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, pendingIndentIds, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
|
150 |
List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, pendingIndentIds,
|
| - |
|
151 |
LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
|
| 137 |
Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
|
152 |
Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
|
| 138 |
Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
|
153 |
Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
|
| 139 |
|
154 |
|
| 140 |
List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
|
155 |
List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
|
| 141 |
Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream().collect(Collectors.toMap(x->x.getItemId(), x->x));
|
156 |
Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream()
|
| - |
|
157 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 142 |
|
158 |
|
| 143 |
for(TagListing tagListing : tagListings){
|
159 |
for (TagListing tagListing : tagListings) {
|
| 144 |
Integer itemId = tagListing.getItemId();
|
160 |
Integer itemId = tagListing.getItemId();
|
| 145 |
tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
|
161 |
tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
|
| 146 |
if(itemQuantity.containsKey(itemId)) {
|
162 |
if (itemQuantity.containsKey(itemId)) {
|
| 147 |
tagListing.setLast30DaysSale(itemQuantity.get(itemId));
|
163 |
tagListing.setLast30DaysSale(itemQuantity.get(itemId));
|
| 148 |
}
|
164 |
}
|
| 149 |
if(itemIdSnapshotMap.containsKey(itemId)){
|
165 |
if (itemIdSnapshotMap.containsKey(itemId)) {
|
| 150 |
tagListing.setStockInHand(itemIdSnapshotMap.get(itemId).getAvailability());
|
166 |
tagListing.setStockInHand(itemIdSnapshotMap.get(itemId).getAvailability());
|
| 151 |
}
|
167 |
}
|
| 152 |
}
|
168 |
}
|
| 153 |
|
169 |
|
| 154 |
model.addAttribute("pendingIndentItemIdMap", pendingIndentItemIdMap);
|
170 |
model.addAttribute("pendingIndentItemIdMap", pendingIndentItemIdMap);
|
| 155 |
model.addAttribute("tagListings", tagListings);
|
171 |
model.addAttribute("tagListings", tagListings);
|
| 156 |
}
|
172 |
}
|
| 157 |
return "pending-indent";
|
173 |
return "pending-indent";
|
| 158 |
}
|
174 |
}
|
| 159 |
|
175 |
|
| 160 |
@RequestMapping(value = "/indent/loadIndent")
|
176 |
@RequestMapping(value = "/indent/loadIndent")
|
| 161 |
public String loadOpenIndent(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
177 |
public String loadOpenIndent(HttpServletRequest request, Model model, @RequestParam(required=false, defaultValue="0") int fofoId ) throws ProfitMandiBusinessException {
|
| 162 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
178 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 163 |
int fofoId = loginDetails.getFofoId();
|
179 |
if (loginDetails.isAdmin()) {
|
| 164 |
List<Indent> openIndents = indentRepository.selectIndentByStatus(fofoId, IndentStatus.OPEN);
|
- |
|
| 165 |
Indent openIndent = null;
|
180 |
List<StockAllocationModel> stockAllocationList;
|
| 166 |
if (openIndents.size() > 0) {
|
181 |
if(fofoId > 0) {
|
| 167 |
openIndent = openIndents.get(0);
|
182 |
stockAllocationList = stockAllocationService.getStockAllocation(fofoId, true);
|
| 168 |
} else {
|
183 |
} else {
|
| 169 |
LOGGER.info("Indent does not exist");
|
- |
|
| 170 |
}
|
- |
|
| 171 |
Map<Integer, IndentItem> itemIndentMap = new HashMap<>();
|
- |
|
| 172 |
if (openIndent != null) {
|
- |
|
| 173 |
List<IndentItem> openIndentItems = indentItemRepository
|
- |
|
| 174 |
.selectIndentItems(Arrays.asList(openIndent.getId()));
|
184 |
stockAllocationList = stockAllocationService.getStockAllocation(true);
|
| 175 |
if (openIndentItems.size() > 0) {
|
- |
|
| 176 |
itemIndentMap = openIndentItems.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
- |
|
| 177 |
}
|
185 |
}
|
| 178 |
}
|
- |
|
| 179 |
|
- |
|
| 180 |
List<TagListing> tagListings = tagListingRepository.selectAll();
|
- |
|
| 181 |
|
186 |
|
| 182 |
List<Integer> itemIds = new ArrayList<>();
|
- |
|
| 183 |
for (TagListing tagListing : tagListings) {
|
- |
|
| 184 |
itemIds.add(tagListing.getItemId());
|
- |
|
| 185 |
}
|
- |
|
| 186 |
|
- |
|
| 187 |
List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, itemIds,
|
- |
|
| 188 |
LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
|
- |
|
| 189 |
Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
|
- |
|
| 190 |
Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
|
- |
|
| 191 |
|
- |
|
| 192 |
List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
|
- |
|
| 193 |
Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream()
|
187 |
Map<Integer, StockAllocationModel> itemStockAllocationMap = stockAllocationList.stream()
|
| 194 |
.collect(Collectors.toMap(x->x.getItemId(), x->x));
|
188 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 195 |
|
- |
|
| 196 |
List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream()
|
- |
|
| 197 |
.map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 198 |
List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED)
|
- |
|
| 199 |
.stream().map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 200 |
pendingIndentIds.addAll(allocatedIndentIds);
|
- |
|
| 201 |
|
189 |
|
| 202 |
if (pendingIndentIds.size() > 0) {
|
- |
|
| 203 |
List<Integer> pendingItemIds = indentItemRepository.selectIndentItems(pendingIndentIds).stream()
|
- |
|
| 204 |
.map(x -> x.getItemId()).collect(Collectors.toList());
|
- |
|
| 205 |
tagListings = tagListings.stream().filter(x -> pendingItemIds.indexOf(x.getItemId()) == -1)
|
190 |
List<TagListing> tagListings = tagListingRepository.selectAll();
|
| 206 |
.collect(Collectors.toList());
|
- |
|
| 207 |
}
|
- |
|
| 208 |
|
191 |
|
| 209 |
for (TagListing tagListing : tagListings) {
|
192 |
for (TagListing tagListing : tagListings) {
|
| 210 |
Integer itemId = tagListing.getItemId();
|
- |
|
| 211 |
tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
|
193 |
StockAllocationModel stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
| 212 |
if (itemQuantity.containsKey(itemId)) {
|
194 |
if(stockAllocationModel!= null ) {
|
| 213 |
tagListing.setLast30DaysSale(itemQuantity.get(itemId));
|
195 |
tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
| 214 |
}
|
196 |
}
|
| 215 |
if (itemIdSnapshotMap.containsKey(itemId)) {
|
- |
|
| 216 |
tagListing.setStockInHand(itemIdSnapshotMap.get(itemId).getAvailability());
|
197 |
tagListing.setItemDescription(itemRepository.selectById(tagListing.getItemId()).getItemDescription());
|
| 217 |
}
|
198 |
}
|
| 218 |
}
|
- |
|
| 219 |
|
199 |
|
| - |
|
200 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x->x.getId()).collect(Collectors.toList());
|
| 220 |
model.addAttribute("tagListings", tagListings);
|
201 |
model.addAttribute("tagListings", tagListings);
|
| - |
|
202 |
String customRetailers = JSONObject.valueToString(retailerService.getFofoRetailers(fofoIds).values());
|
| - |
|
203 |
LOGGER.info("Custom retailesr {}", customRetailers);
|
| 221 |
model.addAttribute("itemIndentMap", itemIndentMap);
|
204 |
model.addAttribute("customRetailers", customRetailers);
|
| 222 |
return "open-indent";
|
205 |
return "open-indent";
|
| - |
|
206 |
} else {
|
| - |
|
207 |
throw new ProfitMandiBusinessException("Unauthorised", loginDetails.getEmailId(),
|
| - |
|
208 |
"Can't access the resource");
|
| - |
|
209 |
}
|
| 223 |
}
|
210 |
}
|
| 224 |
}
|
211 |
}
|