| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.util.ArrayList;
|
| 4 |
import java.util.HashMap;
|
5 |
import java.util.HashMap;
|
| 5 |
import java.util.HashSet;
|
6 |
import java.util.HashSet;
|
| - |
|
7 |
import java.util.Iterator;
|
| 6 |
import java.util.List;
|
8 |
import java.util.List;
|
| 7 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| 8 |
import java.util.Set;
|
10 |
import java.util.Set;
|
| 9 |
|
11 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
13 |
import javax.servlet.http.HttpServletResponse;
|
| 11 |
|
14 |
|
| - |
|
15 |
import org.json.JSONObject;
|
| 12 |
import org.slf4j.Logger;
|
16 |
import org.slf4j.Logger;
|
| 13 |
import org.slf4j.LoggerFactory;
|
17 |
import org.slf4j.LoggerFactory;
|
| 14 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
19 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.stereotype.Controller;
|
20 |
import org.springframework.stereotype.Controller;
|
| 16 |
import org.springframework.transaction.annotation.Transactional;
|
21 |
import org.springframework.transaction.annotation.Transactional;
|
| 17 |
import org.springframework.ui.Model;
|
22 |
import org.springframework.ui.Model;
|
| 18 |
import org.springframework.ui.ModelMap;
|
- |
|
| 19 |
import org.springframework.web.bind.annotation.ModelAttribute;
|
- |
|
| 20 |
import org.springframework.web.bind.annotation.RequestMapping;
|
23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 21 |
import org.springframework.web.bind.annotation.RequestParam;
|
24 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 22 |
|
25 |
|
| - |
|
26 |
import com.google.gson.Gson;
|
| 23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
27 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
28 |
import com.spice.profitmandi.common.model.CartFofo;
|
| 24 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
29 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 25 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
30 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 26 |
import com.spice.profitmandi.common.util.StringUtils;
|
31 |
import com.spice.profitmandi.common.util.StringUtils;
|
| - |
|
32 |
import com.spice.profitmandi.common.util.Utils;
|
| 27 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
33 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| - |
|
34 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 28 |
import com.spice.profitmandi.dao.entity.fofo.FofoItemId;
|
35 |
import com.spice.profitmandi.dao.entity.fofo.FofoItemId;
|
| 29 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
36 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 30 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
37 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 31 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
38 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 32 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
39 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| Line 34... |
Line 41... |
| 34 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
41 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
42 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
43 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
44 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 38 |
import com.spice.profitmandi.web.model.FofoDetails;
|
45 |
import com.spice.profitmandi.web.model.FofoDetails;
|
| - |
|
46 |
import com.spice.profitmandi.web.response.ValidateCart;
|
| 39 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
47 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
| 40 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
48 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 41 |
|
49 |
|
| 42 |
@Controller
|
50 |
@Controller
|
| 43 |
@Transactional
|
51 |
@Transactional
|
| 44 |
public class InventoryController {
|
52 |
public class InventoryController {
|
| 45 |
|
53 |
|
| 46 |
private static final Logger LOGGER = LoggerFactory.getLogger(InventoryController.class);
|
54 |
private static final Logger LOGGER = LoggerFactory.getLogger(InventoryController.class);
|
| 47 |
|
55 |
|
| 48 |
@Autowired
|
56 |
@Autowired
|
| 49 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
57 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 50 |
|
58 |
|
| 51 |
@Autowired
|
59 |
@Autowired
|
| 52 |
InventoryItemRepository inventoryItemRepository;
|
60 |
InventoryItemRepository inventoryItemRepository;
|
| 53 |
|
61 |
|
| 54 |
@Autowired
|
62 |
@Autowired
|
| 55 |
PurchaseRepository purchaseRepository;
|
63 |
PurchaseRepository purchaseRepository;
|
| 56 |
|
64 |
|
| 57 |
@Autowired
|
65 |
@Autowired
|
| 58 |
ItemRepository itemRepository;
|
66 |
ItemRepository itemRepository;
|
| 59 |
|
67 |
|
| 60 |
@Autowired
|
68 |
@Autowired
|
| 61 |
OrderRepository orderRepository;
|
69 |
OrderRepository orderRepository;
|
| 62 |
|
70 |
|
| 63 |
@Autowired
|
71 |
@Autowired
|
| 64 |
MVCResponseSender mvcResponseSender;
|
72 |
MVCResponseSender mvcResponseSender;
|
| 65 |
|
73 |
|
| 66 |
@Autowired
|
74 |
@Autowired
|
| 67 |
CookiesFetcher cookiesFetcher;
|
75 |
CookiesFetcher cookiesFetcher;
|
| 68 |
|
76 |
|
| - |
|
77 |
@Value("${saholic.api.host}")
|
| - |
|
78 |
private String host;
|
| - |
|
79 |
@Value("${saholic.api.port}")
|
| - |
|
80 |
private int port;
|
| - |
|
81 |
@Value("${saholic.api.webapp}")
|
| - |
|
82 |
private String webapp;
|
| - |
|
83 |
|
| - |
|
84 |
|
| 69 |
@RequestMapping(value = "/checkCurrentAvailability")
|
85 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
| 70 |
public String getCurrentAvailability(HttpServletRequest request, @ModelAttribute ModelMap model) throws Exception{
|
86 |
public String getCurrentAvailability(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit , @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm ,Model model) throws Exception{
|
| 71 |
FofoDetails fofoDetails;
|
87 |
FofoDetails fofoDetails;
|
| 72 |
try {
|
88 |
try {
|
| 73 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
89 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| 74 |
} catch (ProfitMandiBusinessException e) {
|
90 |
} catch (ProfitMandiBusinessException e) {
|
| 75 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
91 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 76 |
return "response";
|
92 |
return "response";
|
| 77 |
}
|
93 |
}
|
| - |
|
94 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository.getCurrentInventorySnapshot(fofoDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
95 |
long countItems = currentInventorySnapshotRepository.getCurrentInventorySnapshotCount(fofoDetails.getFofoId(), searchTerm);
|
| - |
|
96 |
model.addAttribute("currentInventorySnapshot",currentInventorySnapshot);
|
| - |
|
97 |
model.addAttribute("start",offset+1);
|
| - |
|
98 |
model.addAttribute("size",countItems);
|
| - |
|
99 |
model.addAttribute("searchTerm",searchTerm);
|
| - |
|
100 |
if (currentInventorySnapshot.size() < limit){
|
| - |
|
101 |
model.addAttribute("end",offset+currentInventorySnapshot.size());
|
| - |
|
102 |
}
|
| - |
|
103 |
else{
|
| - |
|
104 |
model.addAttribute("end",offset+limit);
|
| - |
|
105 |
}
|
| - |
|
106 |
return "inventory-snapshot";
|
| - |
|
107 |
}
|
| - |
|
108 |
|
| - |
|
109 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
| 78 |
List<Object[]> rows = currentInventorySnapshotRepository.selectCustomByFofoId(fofoDetails.getFofoId());
|
110 |
public String getBadAvailability(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit , @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm ,Model model) throws Exception{
|
| - |
|
111 |
FofoDetails fofoDetails;
|
| - |
|
112 |
try {
|
| - |
|
113 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
114 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
115 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
116 |
return "response";
|
| 79 |
|
117 |
}
|
| - |
|
118 |
model.addAttribute("badInventorySnapshot",new ArrayList<>());
|
| - |
|
119 |
model.addAttribute("searchTerm",searchTerm);
|
| - |
|
120 |
return "bad-inventory-snapshot";
|
| - |
|
121 |
}
|
| - |
|
122 |
|
| - |
|
123 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
| 80 |
model.addAttribute("currentInventorySnapshots", this.getCustomCurrentInventorySnapshots(rows));
|
124 |
public String getCurrentAvailabilityPaginated(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm , Model model) throws Exception{
|
| - |
|
125 |
FofoDetails fofoDetails;
|
| - |
|
126 |
try {
|
| - |
|
127 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
128 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
129 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 81 |
return "dashboard";
|
130 |
return "response";
|
| - |
|
131 |
}
|
| - |
|
132 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository.getCurrentInventorySnapshot(fofoDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
133 |
model.addAttribute("currentInventorySnapshot",currentInventorySnapshot);
|
| - |
|
134 |
return "inventory-snapshot-paginated";
|
| 82 |
}
|
135 |
}
|
| 83 |
|
136 |
|
| - |
|
137 |
@RequestMapping(value = "/getCatalog")
|
| - |
|
138 |
public String getCatalog(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit , @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm ,Model model) throws Exception{
|
| - |
|
139 |
FofoDetails fofoDetails;
|
| - |
|
140 |
try {
|
| - |
|
141 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
142 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
143 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
144 |
return "response";
|
| - |
|
145 |
}
|
| - |
|
146 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository.getCurrentInventorySnapshot(fofoDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
147 |
long countItems = currentInventorySnapshotRepository.getCurrentInventorySnapshotCount(fofoDetails.getFofoId(), searchTerm);
|
| - |
|
148 |
model.addAttribute("currentInventorySnapshot",currentInventorySnapshot);
|
| - |
|
149 |
model.addAttribute("start",offset+1);
|
| - |
|
150 |
model.addAttribute("size",countItems);
|
| - |
|
151 |
model.addAttribute("searchTerm",searchTerm);
|
| - |
|
152 |
if (currentInventorySnapshot.size() < limit){
|
| - |
|
153 |
model.addAttribute("end",offset+currentInventorySnapshot.size());
|
| - |
|
154 |
}
|
| - |
|
155 |
else{
|
| - |
|
156 |
model.addAttribute("end",offset+limit);
|
| - |
|
157 |
}
|
| - |
|
158 |
return "catalog";
|
| - |
|
159 |
}
|
| - |
|
160 |
|
| - |
|
161 |
@RequestMapping(value = "/getPaginatedCatalog")
|
| - |
|
162 |
public String getCatalogPaginated(HttpServletRequest request,@RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = "searchTerm", required=false, defaultValue="") String searchTerm , Model model) throws Exception{
|
| - |
|
163 |
FofoDetails fofoDetails;
|
| - |
|
164 |
try {
|
| - |
|
165 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
166 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
167 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
168 |
return "response";
|
| - |
|
169 |
}
|
| - |
|
170 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository.getCurrentInventorySnapshot(fofoDetails.getFofoId(), offset, limit, searchTerm);
|
| - |
|
171 |
model.addAttribute("currentInventorySnapshot",currentInventorySnapshot);
|
| - |
|
172 |
return "catalog-paginated";
|
| - |
|
173 |
}
|
| - |
|
174 |
|
| - |
|
175 |
|
| - |
|
176 |
|
| 84 |
private Set<CustomCurrentInventorySnapshot> getCustomCurrentInventorySnapshots(List<Object[]> rows){
|
177 |
private Set<CustomCurrentInventorySnapshot> getCustomCurrentInventorySnapshots(List<Object[]> rows){
|
| 85 |
Set<CustomCurrentInventorySnapshot> currentInventorySnapshots = new HashSet<>();
|
178 |
Set<CustomCurrentInventorySnapshot> currentInventorySnapshots = new HashSet<>();
|
| 86 |
for(Object[] row : rows){
|
179 |
for(Object[] row : rows){
|
| 87 |
currentInventorySnapshots.add(this.createCustomCurrentInventorySnapshop(row));
|
180 |
currentInventorySnapshots.add(this.createCustomCurrentInventorySnapshop(row));
|
| 88 |
}
|
181 |
}
|
| 89 |
return currentInventorySnapshots;
|
182 |
return currentInventorySnapshots;
|
| 90 |
}
|
183 |
}
|
| 91 |
|
184 |
|
| - |
|
185 |
private String getVaildName(String name){
|
| - |
|
186 |
return name!=null?name:"";
|
| - |
|
187 |
}
|
| - |
|
188 |
|
| 92 |
private CustomCurrentInventorySnapshot createCustomCurrentInventorySnapshop(Object[] row)
|
189 |
private CustomCurrentInventorySnapshot createCustomCurrentInventorySnapshop(Object[] row)
|
| 93 |
{
|
190 |
{
|
| 94 |
CustomCurrentInventorySnapshot currentInventorySnapshot = new CustomCurrentInventorySnapshot();
|
191 |
CustomCurrentInventorySnapshot currentInventorySnapshot = new CustomCurrentInventorySnapshot();
|
| 95 |
currentInventorySnapshot.setItemId((Integer)row[0]);
|
192 |
currentInventorySnapshot.setItemId((Integer)row[0]);
|
| 96 |
currentInventorySnapshot.setAvailability((Integer)row[1]);
|
193 |
currentInventorySnapshot.setAvailability((Integer)row[1]);
|
| 97 |
currentInventorySnapshot.setBrand((String)row[2]);
|
194 |
currentInventorySnapshot.setBrand((String)row[2]);
|
| 98 |
currentInventorySnapshot.setModelName((String)row[3]);
|
195 |
currentInventorySnapshot.setModelName((String)row[3]);
|
| 99 |
currentInventorySnapshot.setModelNumber((String)row[4]);
|
196 |
currentInventorySnapshot.setModelNumber((String)row[4]);
|
| 100 |
currentInventorySnapshot.setColor((String)row[5]);
|
197 |
currentInventorySnapshot.setColor((String)row[5]);
|
| - |
|
198 |
currentInventorySnapshot.setCatalogItemId((Integer)row[6]);
|
| - |
|
199 |
currentInventorySnapshot.setDisplayName((getVaildName((String)row[2])+" "+getVaildName((String)row[3])+" "+getVaildName((String)row[4])+" "+getVaildName((String)row[5])).replaceAll("\\s+", " "));
|
| - |
|
200 |
currentInventorySnapshot.setIconUrl(Utils.getIconUrl(currentInventorySnapshot.getCatalogItemId(), host, port, webapp));
|
| 101 |
return currentInventorySnapshot;
|
201 |
return currentInventorySnapshot;
|
| 102 |
}
|
202 |
}
|
| 103 |
@RequestMapping(value = "/checkItemAvailability")
|
203 |
@RequestMapping(value = "/checkItemAvailability")
|
| 104 |
public String getItemAvailability(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, @ModelAttribute Model model) throws Exception{
|
204 |
public String getItemAvailability(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model) throws Exception{
|
| 105 |
FofoDetails fofoDetails;
|
205 |
FofoDetails fofoDetails;
|
| 106 |
try {
|
206 |
try {
|
| 107 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
207 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| 108 |
} catch (ProfitMandiBusinessException e) {
|
208 |
} catch (ProfitMandiBusinessException e) {
|
| 109 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
209 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| Line 112... |
Line 212... |
| 112 |
try{
|
212 |
try{
|
| 113 |
FofoItemId fofoItemId = new FofoItemId();
|
213 |
FofoItemId fofoItemId = new FofoItemId();
|
| 114 |
fofoItemId.setFofoId(fofoDetails.getFofoId());
|
214 |
fofoItemId.setFofoId(fofoDetails.getFofoId());
|
| 115 |
fofoItemId.setItemId(itemId);
|
215 |
fofoItemId.setItemId(itemId);
|
| 116 |
Object[] row = currentInventorySnapshotRepository.selectCustomByFofoItemId(fofoItemId);
|
216 |
Object[] row = currentInventorySnapshotRepository.selectCustomByFofoItemId(fofoItemId);
|
| 117 |
model.addAttribute("currentInventorySnapshots", this.createCustomCurrentInventorySnapshop(row));
|
217 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(this.createCustomCurrentInventorySnapshop(row)));
|
| 118 |
return "dashboard";
|
218 |
return "current-item-availability";
|
| 119 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
219 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 120 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("INVNTRY_SNPSHT", false, "/dashboard"));
|
220 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("INVNTRY_SNPSHT", false, "/dashboard"));
|
| 121 |
return "response";
|
221 |
return "response";
|
| 122 |
}
|
222 |
}
|
| 123 |
}
|
223 |
}
|
| 124 |
|
224 |
|
| 125 |
@RequestMapping(value = "/grnHistoryByFofoId")
|
225 |
@RequestMapping(value = "/cart")
|
| 126 |
public String grnHistoryByFofoId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString, @RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize, Model model) throws Exception{
|
226 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
| 127 |
FofoDetails fofoDetails;
|
227 |
FofoDetails fofoDetails;
|
| 128 |
try {
|
228 |
try {
|
| 129 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
229 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| 130 |
} catch (ProfitMandiBusinessException e) {
|
230 |
} catch (ProfitMandiBusinessException e) {
|
| 131 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
231 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| 132 |
return "response";
|
232 |
return "response";
|
| 133 |
}
|
233 |
}
|
| 134 |
|
234 |
|
| - |
|
235 |
JSONObject cartObject = new JSONObject(cartData);
|
| - |
|
236 |
Iterator<?> keys = cartObject.keys();
|
| - |
|
237 |
|
| - |
|
238 |
Set<Integer> itemIds = new HashSet<>();
|
| - |
|
239 |
List<CartFofo> cartItems = new ArrayList<CartFofo>();
|
| - |
|
240 |
|
| - |
|
241 |
while( keys.hasNext() ) {
|
| - |
|
242 |
String key = (String)keys.next();
|
| - |
|
243 |
if ( cartObject.get(key) instanceof JSONObject ) {
|
| - |
|
244 |
System.out.println(cartObject.get(key));
|
| - |
|
245 |
}
|
| - |
|
246 |
CartFofo cf = new CartFofo();
|
| - |
|
247 |
cf.setItemId(cartObject.getJSONObject(key).getInt("itemId"));
|
| - |
|
248 |
cf.setQuantity(cartObject.getJSONObject(key).getInt("quantity"));
|
| - |
|
249 |
cf.setDisplayName(cartObject.getJSONObject(key).getString("displayName"));
|
| - |
|
250 |
cf.setIconUrl(cartObject.getJSONObject(key).getString("iconUrl"));
|
| - |
|
251 |
cf.setAvailability(0);
|
| - |
|
252 |
cartItems.add(cf);
|
| - |
|
253 |
itemIds.add(cartObject.getJSONObject(key).getInt("itemId"));
|
| - |
|
254 |
}
|
| - |
|
255 |
if (itemIds.size() > 0){
|
| - |
|
256 |
List<CurrentInventorySnapshot> cisList = currentInventorySnapshotRepository.selectByFofoItemIds(fofoDetails.getFofoId(), itemIds);
|
| - |
|
257 |
for (CurrentInventorySnapshot cis: cisList ){
|
| - |
|
258 |
for (CartFofo cartItem : cartItems){
|
| - |
|
259 |
if (cartItem.getItemId() == cis.getItem().getId()){
|
| - |
|
260 |
cartItem.setAvailability(cis.getAvailability());
|
| - |
|
261 |
}
|
| - |
|
262 |
}
|
| - |
|
263 |
}
|
| - |
|
264 |
for (CartFofo cartItem : cartItems){
|
| - |
|
265 |
if (cartItem.getAvailability() < cartItem.getQuantity() && cartItem.getAvailability()!=0){
|
| - |
|
266 |
cartItem.setQuantity(cartItem.getAvailability());
|
| - |
|
267 |
cartItem.setMessage("Item quantity changed.Less stock available");
|
| - |
|
268 |
}
|
| - |
|
269 |
if (cartItem.getAvailability() == 0){
|
| - |
|
270 |
cartItem.setQuantity(0);
|
| - |
|
271 |
cartItem.setMessage("You don't have stock for this item");
|
| - |
|
272 |
}
|
| - |
|
273 |
}
|
| - |
|
274 |
}
|
| - |
|
275 |
model.addAttribute("cartObj", cartItems);
|
| - |
|
276 |
return "cart";
|
| - |
|
277 |
}
|
| - |
|
278 |
|
| - |
|
279 |
@RequestMapping(value = "/validate-cart")
|
| - |
|
280 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,@RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
| - |
|
281 |
FofoDetails fofoDetails = null;
|
| - |
|
282 |
try {
|
| - |
|
283 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
284 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
285 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
286 |
return "response";
|
| - |
|
287 |
}
|
| - |
|
288 |
|
| - |
|
289 |
JSONObject cartObject = new JSONObject(cartData);
|
| - |
|
290 |
Iterator<?> keys = cartObject.keys();
|
| - |
|
291 |
|
| - |
|
292 |
Set<Integer> itemIds = new HashSet<>();
|
| - |
|
293 |
List<CartFofo> cartItems = new ArrayList<CartFofo>();
|
| - |
|
294 |
|
| - |
|
295 |
if (cartObject.keySet().size() == 0){
|
| - |
|
296 |
model.addAttribute("validateCartResponse",new Gson().toJson(new ValidateCart("POST", "/cart", false, cartData)));
|
| - |
|
297 |
return "validate-cart";
|
| - |
|
298 |
}
|
| - |
|
299 |
|
| - |
|
300 |
while( keys.hasNext() ) {
|
| - |
|
301 |
String key = (String)keys.next();
|
| - |
|
302 |
if ( cartObject.get(key) instanceof JSONObject ) {
|
| - |
|
303 |
System.out.println(cartObject.get(key));
|
| - |
|
304 |
}
|
| - |
|
305 |
CartFofo cf = new CartFofo();
|
| - |
|
306 |
cf.setItemId(cartObject.getJSONObject(key).getInt("itemId"));
|
| - |
|
307 |
cf.setQuantity(cartObject.getJSONObject(key).getInt("quantity"));
|
| - |
|
308 |
cf.setDisplayName(cartObject.getJSONObject(key).getString("displayName"));
|
| - |
|
309 |
cf.setIconUrl(cartObject.getJSONObject(key).getString("iconUrl"));
|
| - |
|
310 |
cf.setAvailability(0);
|
| - |
|
311 |
cartItems.add(cf);
|
| - |
|
312 |
itemIds.add(cartObject.getJSONObject(key).getInt("itemId"));
|
| - |
|
313 |
}
|
| - |
|
314 |
if (itemIds.size() > 0){
|
| - |
|
315 |
List<CurrentInventorySnapshot> cisList = currentInventorySnapshotRepository.selectByFofoItemIds(fofoDetails.getFofoId(), itemIds);
|
| - |
|
316 |
for (CurrentInventorySnapshot cis: cisList ){
|
| - |
|
317 |
for (CartFofo cartItem : cartItems){
|
| - |
|
318 |
if (cartItem.getItemId() == cis.getItem().getId()){
|
| - |
|
319 |
cartItem.setAvailability(cis.getAvailability());
|
| - |
|
320 |
}
|
| - |
|
321 |
}
|
| - |
|
322 |
}
|
| - |
|
323 |
for (CartFofo cartItem : cartItems){
|
| - |
|
324 |
if (cartItem.getAvailability() < cartItem.getQuantity()){
|
| - |
|
325 |
model.addAttribute("validateCartResponse",new Gson().toJson(new ValidateCart("POST", "/cart", false, cartData)));
|
| - |
|
326 |
return "validate-cart";
|
| - |
|
327 |
}
|
| - |
|
328 |
}
|
| - |
|
329 |
}
|
| - |
|
330 |
else{
|
| - |
|
331 |
model.addAttribute("validateCartResponse",new Gson().toJson(new ValidateCart("POST", "/cart", false, cartData)));
|
| - |
|
332 |
return "validate-cart";
|
| - |
|
333 |
}
|
| - |
|
334 |
model.addAttribute("validateCartResponse",new Gson().toJson(new ValidateCart("POST", "/order", true, cartData)));
|
| - |
|
335 |
return "validate-cart";
|
| - |
|
336 |
}
|
| - |
|
337 |
|
| - |
|
338 |
@RequestMapping(value = "/grnHistory")
|
| - |
|
339 |
public String grnHistoryByFofoId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString, @RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString, @RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE,defaultValue="") String purchaseReference, @RequestParam(name = "searchType",defaultValue="") String searchType,Model model) throws Exception{
|
| - |
|
340 |
FofoDetails fofoDetails;
|
| - |
|
341 |
try {
|
| - |
|
342 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
343 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
344 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
345 |
return "response";
|
| - |
|
346 |
}
|
| - |
|
347 |
|
| 135 |
LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
|
348 |
LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
|
| 136 |
LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
|
349 |
LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
|
| 137 |
|
350 |
|
| - |
|
351 |
List<Purchase> grnHistory = new ArrayList<Purchase>();
|
| - |
|
352 |
long countItems = 0;
|
| - |
|
353 |
if (searchType.equalsIgnoreCase("purchaseReference") && purchaseReference.trim().length() > 0){
|
| - |
|
354 |
try{
|
| - |
|
355 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(purchaseReference);
|
| - |
|
356 |
grnHistory.add(purchase);
|
| - |
|
357 |
countItems = 1;
|
| - |
|
358 |
}
|
| - |
|
359 |
catch(Exception | ProfitMandiBusinessException e){
|
| - |
|
360 |
LOGGER.info("Unable to get purchase reference "+purchaseReference);
|
| - |
|
361 |
}
|
| - |
|
362 |
}
|
| - |
|
363 |
else{
|
| 138 |
model.addAttribute("grnHistories", purchaseRepository.selectByFofoId(fofoDetails.getFofoId(), startDateTime, endDateTime, pageNumber, pageSize));
|
364 |
grnHistory = purchaseRepository.selectByFofoId(fofoDetails.getFofoId(), startDateTime, endDateTime, offset, limit);
|
| - |
|
365 |
countItems = purchaseRepository.getPurchaseCount(fofoDetails.getFofoId(), startDateTime, endDateTime, purchaseReference, searchType);
|
| - |
|
366 |
}
|
| - |
|
367 |
model.addAttribute("grnHistories", grnHistory);
|
| - |
|
368 |
model.addAttribute("start",offset+1);
|
| - |
|
369 |
model.addAttribute("size",countItems);
|
| - |
|
370 |
model.addAttribute("searchType",searchType);
|
| - |
|
371 |
model.addAttribute(ProfitMandiConstants.START_TIME, startTimeString);
|
| - |
|
372 |
model.addAttribute(ProfitMandiConstants.END_TIME, endTimeString);
|
| - |
|
373 |
if (grnHistory.size() < limit){
|
| - |
|
374 |
model.addAttribute("end",offset+grnHistory.size());
|
| - |
|
375 |
}
|
| - |
|
376 |
else{
|
| - |
|
377 |
model.addAttribute("end",offset+limit);
|
| - |
|
378 |
}
|
| 139 |
return "";
|
379 |
return "grn-history";
|
| 140 |
}
|
380 |
}
|
| - |
|
381 |
|
| - |
|
382 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
| 141 |
|
383 |
public String getGrnHistoryPaginated(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString, @RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString, @RequestParam(name = "offset",defaultValue="0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE,defaultValue="") String purchaseReference, @RequestParam(name = "searchType",defaultValue="") String searchType,Model model) throws Exception{
|
| - |
|
384 |
FofoDetails fofoDetails;
|
| - |
|
385 |
try {
|
| - |
|
386 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
387 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
388 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
| - |
|
389 |
return "response";
|
| - |
|
390 |
}
|
| - |
|
391 |
LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
|
| - |
|
392 |
LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
|
| - |
|
393 |
|
| - |
|
394 |
List<Purchase> grnHistory = purchaseRepository.selectByFofoId(fofoDetails.getFofoId(), startDateTime, endDateTime, offset, limit);
|
| - |
|
395 |
model.addAttribute("grnHistories", grnHistory);
|
| - |
|
396 |
return "grn-history-paginated";
|
| - |
|
397 |
}
|
| - |
|
398 |
|
| 142 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
399 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
| 143 |
public String grnHistoryByPurchaseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model) throws Exception{
|
400 |
public String grnHistoryByPurchaseId(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model) throws Exception{
|
| 144 |
FofoDetails fofoDetails;
|
401 |
FofoDetails fofoDetails;
|
| 145 |
try {
|
402 |
try {
|
| 146 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
403 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| Line 150... |
Line 407... |
| 150 |
}
|
407 |
}
|
| 151 |
Purchase purchase = null;
|
408 |
Purchase purchase = null;
|
| 152 |
try {
|
409 |
try {
|
| 153 |
purchase = purchaseRepository.selectById(purchaseId);
|
410 |
purchase = purchaseRepository.selectById(purchaseId);
|
| 154 |
} catch (ProfitMandiBusinessException e) {
|
411 |
} catch (ProfitMandiBusinessException e) {
|
| 155 |
|
412 |
|
| 156 |
}
|
413 |
}
|
| 157 |
model.addAttribute("grnHistories", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
414 |
model.addAttribute("grnDetails", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
| - |
|
415 |
model.addAttribute("purchaseId",purchase.getId());
|
| - |
|
416 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
| 158 |
return "";
|
417 |
return "grn-details";
|
| 159 |
}
|
418 |
}
|
| 160 |
|
419 |
|
| 161 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
420 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
| 162 |
public String grnHistoryByPurchaseReference(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model) throws Exception{
|
421 |
public String grnHistoryByPurchaseReference(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model) throws Exception{
|
| 163 |
FofoDetails fofoDetails;
|
422 |
FofoDetails fofoDetails;
|
| 164 |
try {
|
423 |
try {
|
| 165 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
424 |
fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| Line 169... |
Line 428... |
| 169 |
}
|
428 |
}
|
| 170 |
Purchase purchase = null;
|
429 |
Purchase purchase = null;
|
| 171 |
try {
|
430 |
try {
|
| 172 |
purchase = purchaseRepository.selectByPurchaseReference(purchaseReference);
|
431 |
purchase = purchaseRepository.selectByPurchaseReference(purchaseReference);
|
| 173 |
} catch (ProfitMandiBusinessException e) {
|
432 |
} catch (ProfitMandiBusinessException e) {
|
| 174 |
|
433 |
|
| 175 |
}
|
434 |
}
|
| 176 |
model.addAttribute("grnHistories", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
435 |
model.addAttribute("grnDetails", this.grnHistoryDetails(purchase, fofoDetails.getFofoId()));
|
| - |
|
436 |
model.addAttribute("purchaseId",purchase.getId());
|
| - |
|
437 |
model.addAttribute("purchaseReference",purchase.getPurchaseReference());
|
| 177 |
return "";
|
438 |
return "grn-details";
|
| 178 |
}
|
439 |
}
|
| 179 |
|
440 |
|
| 180 |
private Map<Integer, Map<String, Object>> grnHistoryDetails(Purchase purchase, int fofoId){
|
441 |
private Map<Integer, Map<String, Object>> grnHistoryDetails(Purchase purchase, int fofoId){
|
| 181 |
Set<Integer> itemIds = new HashSet<>();
|
442 |
Set<Integer> itemIds = new HashSet<>();
|
| 182 |
Set<Item> inventoryItemDetails = new HashSet<>();
|
443 |
Set<Item> inventoryItemDetails = new HashSet<>();
|
| 183 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
444 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
| 184 |
for(InventoryItem inventoryItem : inventoryItems){
|
445 |
for(InventoryItem inventoryItem : inventoryItems){
|
| Line 186... |
Line 447... |
| 186 |
itemIds.add(inventoryItem.getItemId());
|
447 |
itemIds.add(inventoryItem.getItemId());
|
| 187 |
}
|
448 |
}
|
| 188 |
|
449 |
|
| 189 |
Map<Integer, Map<String, Object>> grnHistoryDetails = new HashMap<>();
|
450 |
Map<Integer, Map<String, Object>> grnHistoryDetails = new HashMap<>();
|
| 190 |
this.createGrnHistoryDetails(grnHistoryDetails, inventoryItems);
|
451 |
this.createGrnHistoryDetails(grnHistoryDetails, inventoryItems);
|
| 191 |
Map<Integer, Map<String, Object>> completedItemDetails = this.toMap(inventoryItemDetails);
|
452 |
Map<Integer, Map<String, Object>> completedItemDetails = this.toMap(inventoryItemDetails, purchase);
|
| 192 |
|
453 |
|
| 193 |
this.writeItemDetailstoGrnHistories(grnHistoryDetails, completedItemDetails);
|
454 |
this.writeItemDetailstoGrnHistories(grnHistoryDetails, completedItemDetails);
|
| 194 |
|
455 |
|
| 195 |
if(!purchase.isCompleted()){
|
456 |
if(!purchase.isCompleted()){
|
| 196 |
List<Order> orders = orderRepository.selectByInvoiceNumberRetailerIdNotItemIds(purchase.getPurchaseReference(), fofoId, itemIds);
|
457 |
List<Order> orders = orderRepository.selectByInvoiceNumberRetailerIdNotItemIds(purchase.getPurchaseReference(), fofoId, itemIds);
|
| 197 |
for(Order order : orders){
|
458 |
for(Order order : orders){
|
| 198 |
LineItem lineItem = order.getLineItem();
|
459 |
LineItem lineItem = order.getLineItem();
|
| 199 |
//orderItemDetails.add(lineItem.getItem());
|
460 |
//orderItemDetails.add(lineItem.getItem());
|
| Line 203... |
Line 464... |
| 203 |
grnHistoryDetail.put(ProfitMandiConstants.QUANTITY, lineItem.getQuantity());
|
464 |
grnHistoryDetail.put(ProfitMandiConstants.QUANTITY, lineItem.getQuantity());
|
| 204 |
grnHistoryDetail.put(ProfitMandiConstants.BRAND, item.getBrand());
|
465 |
grnHistoryDetail.put(ProfitMandiConstants.BRAND, item.getBrand());
|
| 205 |
grnHistoryDetail.put(ProfitMandiConstants.MODEL_NAME, item.getModelName());
|
466 |
grnHistoryDetail.put(ProfitMandiConstants.MODEL_NAME, item.getModelName());
|
| 206 |
grnHistoryDetail.put(ProfitMandiConstants.MODEL_NUMBER, item.getModelNumber());
|
467 |
grnHistoryDetail.put(ProfitMandiConstants.MODEL_NUMBER, item.getModelNumber());
|
| 207 |
grnHistoryDetail.put(ProfitMandiConstants.COLOR, item.getColor());
|
468 |
grnHistoryDetail.put(ProfitMandiConstants.COLOR, item.getColor());
|
| - |
|
469 |
grnHistoryDetail.put(ProfitMandiConstants.CATALOG_ITEM_ID, item.getCatalogItemId());
|
| - |
|
470 |
grnHistoryDetail.put("iconUrl",Utils.getIconUrl(item.getCatalogItemId(), host, port, webapp));
|
| 208 |
grnHistoryDetail.put(ProfitMandiConstants.COMPLETED, false);
|
471 |
grnHistoryDetail.put(ProfitMandiConstants.COMPLETED, false);
|
| - |
|
472 |
grnHistoryDetail.put("purchaseReference", purchase.getPurchaseReference());
|
| 209 |
if(lineItem.getSerialNumber() == null || lineItem.getSerialNumber().equals("")){
|
473 |
if(lineItem.getSerialNumber() == null || lineItem.getSerialNumber().equals("")){
|
| 210 |
grnHistoryDetail.put(ProfitMandiConstants.SERIALIZED, false);
|
474 |
grnHistoryDetail.put(ProfitMandiConstants.SERIALIZED, false);
|
| 211 |
}else{
|
475 |
}else{
|
| 212 |
grnHistoryDetail.put(ProfitMandiConstants.SERIALIZED, true);
|
476 |
grnHistoryDetail.put(ProfitMandiConstants.SERIALIZED, true);
|
| 213 |
Set<String> serialNumbers = new HashSet<>();
|
477 |
Set<String> serialNumbers = new HashSet<>();
|
| Line 218... |
Line 482... |
| 218 |
}else{
|
482 |
}else{
|
| 219 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(item.getId());
|
483 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(item.getId());
|
| 220 |
if((boolean)grnHistoryDetail.get(ProfitMandiConstants.SERIALIZED)){
|
484 |
if((boolean)grnHistoryDetail.get(ProfitMandiConstants.SERIALIZED)){
|
| 221 |
@SuppressWarnings("unchecked")
|
485 |
@SuppressWarnings("unchecked")
|
| 222 |
Set<String> serialNumbers = (Set<String>)grnHistoryDetail.get(ProfitMandiConstants.SERIAL_NUMBERS);
|
486 |
Set<String> serialNumbers = (Set<String>)grnHistoryDetail.get(ProfitMandiConstants.SERIAL_NUMBERS);
|
| 223 |
serialNumbers.add(lineItem.getSerialNumber());
|
487 |
serialNumbers.add(lineItem.getSerialNumber());
|
| 224 |
}
|
488 |
}
|
| 225 |
}
|
489 |
}
|
| 226 |
}
|
490 |
}
|
| 227 |
}
|
491 |
}
|
| 228 |
return grnHistoryDetails;
|
492 |
return grnHistoryDetails;
|
| 229 |
}
|
493 |
}
|
| 230 |
|
494 |
|
| 231 |
private void writeItemDetailstoGrnHistories(Map<Integer, Map<String, Object>> grnHistoryDetails, Map<Integer, Map<String, Object>> itemDetails){
|
495 |
private void writeItemDetailstoGrnHistories(Map<Integer, Map<String, Object>> grnHistoryDetails, Map<Integer, Map<String, Object>> itemDetails){
|
| 232 |
for(int key : grnHistoryDetails.keySet()){
|
496 |
for(int key : grnHistoryDetails.keySet()){
|
| 233 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(key);
|
497 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(key);
|
| 234 |
grnHistoryDetail.putAll(itemDetails.get(key));
|
498 |
grnHistoryDetail.putAll(itemDetails.get(key));
|
| 235 |
}
|
499 |
}
|
| 236 |
}
|
500 |
}
|
| 237 |
|
501 |
|
| 238 |
private Map<Integer, Map<String, Object>> toMap(Set<Item> items){
|
502 |
private Map<Integer, Map<String, Object>> toMap(Set<Item> items, Purchase purchase){
|
| 239 |
Map<Integer, Map<String, Object>> map = new HashMap<>();
|
503 |
Map<Integer, Map<String, Object>> map = new HashMap<>();
|
| 240 |
for(Item item : items){
|
504 |
for(Item item : items){
|
| 241 |
Map<String, Object> detailMap = new HashMap<>();
|
505 |
Map<String, Object> detailMap = new HashMap<>();
|
| 242 |
detailMap.put(ProfitMandiConstants.BRAND, item.getBrand());
|
506 |
detailMap.put(ProfitMandiConstants.BRAND, item.getBrand());
|
| 243 |
detailMap.put(ProfitMandiConstants.MODEL_NAME, item.getModelName());
|
507 |
detailMap.put(ProfitMandiConstants.MODEL_NAME, item.getModelName());
|
| 244 |
detailMap.put(ProfitMandiConstants.MODEL_NUMBER, item.getModelNumber());
|
508 |
detailMap.put(ProfitMandiConstants.MODEL_NUMBER, item.getModelNumber());
|
| 245 |
detailMap.put(ProfitMandiConstants.COLOR, item.getColor());
|
509 |
detailMap.put(ProfitMandiConstants.COLOR, item.getColor());
|
| - |
|
510 |
detailMap.put(ProfitMandiConstants.CATALOG_ITEM_ID, item.getCatalogItemId());
|
| - |
|
511 |
detailMap.put("iconUrl",Utils.getIconUrl(item.getCatalogItemId(), host, port, webapp));
|
| - |
|
512 |
detailMap.put("purchaseReference", purchase.getPurchaseReference());
|
| 246 |
map.put(item.getId(), detailMap);
|
513 |
map.put(item.getId(), detailMap);
|
| 247 |
}
|
514 |
}
|
| 248 |
return map;
|
515 |
return map;
|
| 249 |
}
|
516 |
}
|
| 250 |
|
517 |
|
| 251 |
private void createGrnHistoryDetails(Map<Integer, Map<String, Object>> grnHistoryDetails, List<InventoryItem> inventoryItems){
|
518 |
private void createGrnHistoryDetails(Map<Integer, Map<String, Object>> grnHistoryDetails, List<InventoryItem> inventoryItems){
|
| 252 |
//Map<Integer, Map<String, Object>> grnHistoryDetails = new HashMap<>();
|
519 |
//Map<Integer, Map<String, Object>> grnHistoryDetails = new HashMap<>();
|
| 253 |
for(InventoryItem inventoryItem : inventoryItems){
|
520 |
for(InventoryItem inventoryItem : inventoryItems){
|
| 254 |
if(!grnHistoryDetails.containsKey(inventoryItem.getItemId())){
|
521 |
if(!grnHistoryDetails.containsKey(inventoryItem.getItemId())){
|
| 255 |
Map<String, Object> grnHistoryDetail = new HashMap<>();
|
522 |
Map<String, Object> grnHistoryDetail = new HashMap<>();
|
| Line 269... |
Line 536... |
| 269 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(inventoryItem.getItemId());
|
536 |
Map<String, Object> grnHistoryDetail = grnHistoryDetails.get(inventoryItem.getItemId());
|
| 270 |
if((boolean)grnHistoryDetail.get(ProfitMandiConstants.SERIALIZED)){
|
537 |
if((boolean)grnHistoryDetail.get(ProfitMandiConstants.SERIALIZED)){
|
| 271 |
@SuppressWarnings("unchecked")
|
538 |
@SuppressWarnings("unchecked")
|
| 272 |
Set<String> serialNumbers = (Set<String>)grnHistoryDetail.get(ProfitMandiConstants.SERIAL_NUMBERS);
|
539 |
Set<String> serialNumbers = (Set<String>)grnHistoryDetail.get(ProfitMandiConstants.SERIAL_NUMBERS);
|
| 273 |
LOGGER.info("serialNumbers {}", serialNumbers);
|
540 |
LOGGER.info("serialNumbers {}", serialNumbers);
|
| 274 |
serialNumbers.add(inventoryItem.getSerialNumber());
|
541 |
serialNumbers.add(inventoryItem.getSerialNumber());
|
| 275 |
grnHistoryDetail.put(ProfitMandiConstants.QUANTITY, (int)grnHistoryDetail.get(ProfitMandiConstants.QUANTITY) + inventoryItem.getInitialQuantity());
|
542 |
grnHistoryDetail.put(ProfitMandiConstants.QUANTITY, (int)grnHistoryDetail.get(ProfitMandiConstants.QUANTITY) + inventoryItem.getInitialQuantity());
|
| 276 |
}
|
543 |
}
|
| 277 |
}
|
544 |
}
|
| 278 |
|
545 |
|
| 279 |
}
|
546 |
}
|
| 280 |
//return null;
|
547 |
//return null;
|
| 281 |
}
|
548 |
}
|
| 282 |
|
549 |
|
| 283 |
public List<Item> getItemsByItemIds(Set<Integer> itemIds){
|
550 |
public List<Item> getItemsByItemIds(Set<Integer> itemIds){
|
| 284 |
return null;
|
551 |
return null;
|
| 285 |
}
|
552 |
}
|
| 286 |
|
553 |
|
| 287 |
/*@RequestMapping(value = "/grnHist")
|
554 |
/*@RequestMapping(value = "/grnHist")
|
| 288 |
public String grnHist(HttpServletRequest request) throws Exception{
|
555 |
public String grnHist(HttpServletRequest request) throws Exception{
|
| 289 |
LOGGER.info("result {}", orderRepository.selectByInvoiceNumber("58400149931", 963490));
|
556 |
LOGGER.info("result {}", orderRepository.selectByInvoiceNumber("58400149931", 963490));
|
| 290 |
return null;
|
557 |
return null;
|
| 291 |
}*/
|
558 |
}*/
|
| 292 |
|
559 |
|
| 293 |
@RequestMapping(value = "/grnHist")
|
560 |
@RequestMapping(value = "/grnHist")
|
| 294 |
public String grnHist(HttpServletRequest request ) throws Exception{
|
561 |
public String grnHist(HttpServletRequest request ) throws Exception{
|
| 295 |
Purchase purchase = null;
|
562 |
Purchase purchase = null;
|
| 296 |
try {
|
563 |
try {
|
| 297 |
purchase = purchaseRepository.selectById(2);
|
564 |
purchase = purchaseRepository.selectById(2);
|
| Line 300... |
Line 567... |
| 300 |
e.printStackTrace();
|
567 |
e.printStackTrace();
|
| 301 |
}
|
568 |
}
|
| 302 |
LOGGER.info("grnHistoryDetails {}", StringUtils.toString(this.grnHistoryDetails(purchase, 963490)));
|
569 |
LOGGER.info("grnHistoryDetails {}", StringUtils.toString(this.grnHistoryDetails(purchase, 963490)));
|
| 303 |
return null;
|
570 |
return null;
|
| 304 |
}
|
571 |
}
|
| 305 |
|
572 |
|
| 306 |
}
|
573 |
}
|