| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.server;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.catalog.dashboard.client.CatalogService;
|
| 6530 |
vikram.rag |
4 |
|
| 7190 |
amar.kumar |
5 |
import in.shop2020.catalog.dashboard.shared.FreebieItem;
|
| 1961 |
ankur.sing |
6 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 4431 |
phani.kuma |
7 |
import in.shop2020.catalog.dashboard.shared.ItemInventory;
|
| 3850 |
chandransh |
8 |
import in.shop2020.catalog.dashboard.shared.ItemStatus;
|
| 2068 |
ankur.sing |
9 |
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
|
| 3558 |
rajveer |
10 |
import in.shop2020.catalog.dashboard.shared.SourcePricings;
|
| 2119 |
ankur.sing |
11 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
|
|
12 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 5504 |
phani.kuma |
13 |
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
|
| 2378 |
ankur.sing |
14 |
import in.shop2020.config.ConfigException;
|
| 3907 |
chandransh |
15 |
import in.shop2020.content.ContentService;
|
|
|
16 |
import in.shop2020.content.ContentServiceException;
|
| 5946 |
rajveer |
17 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 10484 |
vikram.rag |
18 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| 6838 |
vikram.rag |
19 |
import in.shop2020.model.v1.catalog.Insurer;
|
| 5706 |
amit.gupta |
20 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 2105 |
ankur.sing |
21 |
import in.shop2020.model.v1.catalog.status;
|
| 6096 |
amit.gupta |
22 |
import in.shop2020.model.v1.inventory.InventoryService;
|
| 6813 |
amar.kumar |
23 |
import in.shop2020.model.v1.inventory.ItemStockPurchaseParams;
|
| 9687 |
rajveer |
24 |
import in.shop2020.model.v1.inventory.OOSStatus;
|
| 5504 |
phani.kuma |
25 |
import in.shop2020.model.v1.user.VoucherType;
|
| 3129 |
rajveer |
26 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 3907 |
chandransh |
27 |
import in.shop2020.thrift.clients.ContentClient;
|
| 5946 |
rajveer |
28 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 2378 |
ankur.sing |
29 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 2119 |
ankur.sing |
30 |
import in.shop2020.utils.CategoryManager;
|
| 2359 |
ankur.sing |
31 |
import in.shop2020.utils.ConfigClientKeys;
|
| 6530 |
vikram.rag |
32 |
import in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems;
|
|
|
33 |
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
|
| 2427 |
ankur.sing |
34 |
import java.io.BufferedReader;
|
|
|
35 |
import java.io.FileReader;
|
| 2359 |
ankur.sing |
36 |
import java.io.IOException;
|
| 2427 |
ankur.sing |
37 |
import java.text.DateFormat;
|
|
|
38 |
import java.text.SimpleDateFormat;
|
| 1961 |
ankur.sing |
39 |
import java.util.ArrayList;
|
| 4957 |
phani.kuma |
40 |
import java.util.Arrays;
|
| 2105 |
ankur.sing |
41 |
import java.util.Calendar;
|
| 2068 |
ankur.sing |
42 |
import java.util.Collections;
|
| 2427 |
ankur.sing |
43 |
import java.util.Date;
|
| 1992 |
ankur.sing |
44 |
import java.util.HashMap;
|
| 5118 |
mandeep.dh |
45 |
import java.util.HashSet;
|
| 1961 |
ankur.sing |
46 |
import java.util.List;
|
| 1992 |
ankur.sing |
47 |
import java.util.Map;
|
| 2359 |
ankur.sing |
48 |
import java.util.Map.Entry;
|
| 5118 |
mandeep.dh |
49 |
import java.util.Set;
|
| 1961 |
ankur.sing |
50 |
|
| 2427 |
ankur.sing |
51 |
import org.apache.log4j.Logger;
|
| 3907 |
chandransh |
52 |
import org.apache.thrift.TException;
|
|
|
53 |
import org.apache.thrift.transport.TTransportException;
|
| 2359 |
ankur.sing |
54 |
|
| 1961 |
ankur.sing |
55 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
56 |
|
|
|
57 |
@SuppressWarnings("serial")
|
|
|
58 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
|
|
59 |
|
| 3354 |
chandransh |
60 |
private static Logger logger = Logger.getLogger(CatalogServiceImpl.class);
|
|
|
61 |
|
| 3922 |
chandransh |
62 |
private static Logger pushToProdLogger = Logger.getLogger("pushToProdLogger");
|
|
|
63 |
|
| 2427 |
ankur.sing |
64 |
private static Date pushToProdDate;
|
|
|
65 |
|
| 3922 |
chandransh |
66 |
private static String logFile;
|
|
|
67 |
|
|
|
68 |
private static int maxCount;
|
|
|
69 |
|
| 9640 |
amar.kumar |
70 |
private static final int EBAYSOURCE = 6;
|
|
|
71 |
private static final int SNAPDEALSOURCE = 7;
|
|
|
72 |
private static final int FLIPKARTSOURCE = 8;
|
|
|
73 |
|
| 3922 |
chandransh |
74 |
static {
|
|
|
75 |
try {
|
|
|
76 |
logFile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
|
|
|
77 |
maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
|
|
|
78 |
} catch(ConfigException ce) {
|
|
|
79 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
80 |
logFile = "/var/log/services/pushToProductionCount/pushToProd.log";
|
|
|
81 |
maxCount = 5;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
}
|
|
|
85 |
|
| 3850 |
chandransh |
86 |
@Override
|
|
|
87 |
public int getItemCountByStatus(boolean useStatus, ItemStatus itemStatus){
|
|
|
88 |
int count = 0;
|
|
|
89 |
try{
|
|
|
90 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
91 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3850 |
chandransh |
92 |
|
|
|
93 |
status stat = status.findByValue(itemStatus.getValue());
|
|
|
94 |
count = catalogClient.getItemCountByStatus(useStatus, stat);
|
|
|
95 |
}catch(Exception e){
|
|
|
96 |
logger.error("Error while getting the count of items from the catalog service", e);
|
|
|
97 |
}
|
|
|
98 |
return count;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
@Override
|
| 6530 |
vikram.rag |
102 |
public List<Item> getInventoryOutofSyncItems(int offset, int limit){
|
|
|
103 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
104 |
|
|
|
105 |
try {
|
|
|
106 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
107 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
108 |
|
|
|
109 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllIgnoredInventoryUpdateItemsList(offset, limit);
|
|
|
110 |
|
|
|
111 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
112 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 6530 |
vikram.rag |
113 |
}
|
|
|
114 |
} catch (Exception e) {
|
|
|
115 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
116 |
}
|
|
|
117 |
return itemList;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
@Override
|
|
|
121 |
public int getInventoryOutofSyncItemsCount(){
|
|
|
122 |
int count=0;
|
|
|
123 |
try {
|
|
|
124 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
125 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
126 |
|
|
|
127 |
count = inventoryClient.getAllIgnoredInventoryupdateItemsCount();
|
|
|
128 |
|
|
|
129 |
} catch (Exception e) {
|
|
|
130 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
131 |
}
|
|
|
132 |
return count;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
@Override
|
| 3850 |
chandransh |
136 |
public List<Item> getAllItems(int start, int limit) {
|
| 1961 |
ankur.sing |
137 |
List<Item> itemList = new ArrayList<Item>();
|
| 2359 |
ankur.sing |
138 |
|
| 1961 |
ankur.sing |
139 |
try {
|
| 3129 |
rajveer |
140 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
141 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
142 |
|
| 3850 |
chandransh |
143 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
|
| 2359 |
ankur.sing |
144 |
|
| 2119 |
ankur.sing |
145 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
146 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 2119 |
ankur.sing |
147 |
}
|
|
|
148 |
} catch (Exception e) {
|
| 3354 |
chandransh |
149 |
logger.error("Error while getting all items from the catalog service", e);
|
| 2119 |
ankur.sing |
150 |
}
|
|
|
151 |
return itemList;
|
|
|
152 |
}
|
| 2208 |
ankur.sing |
153 |
|
| 3850 |
chandransh |
154 |
public List<Item> getAllActiveItems(int start, int limit){
|
|
|
155 |
return getItemsByStatus(status.ACTIVE, start, limit);
|
| 2208 |
ankur.sing |
156 |
}
|
| 2359 |
ankur.sing |
157 |
|
|
|
158 |
@Override
|
| 3850 |
chandransh |
159 |
public List<Item> getAllPhasedOutItems(int start, int limit){
|
|
|
160 |
return getItemsByStatus(status.PHASED_OUT, start, limit);
|
| 2359 |
ankur.sing |
161 |
}
|
|
|
162 |
|
|
|
163 |
@Override
|
| 3850 |
chandransh |
164 |
public List<Item> getAllPausedItems(int start, int limit){
|
|
|
165 |
return getItemsByStatus(status.PAUSED, start, limit);
|
| 2208 |
ankur.sing |
166 |
}
|
| 2359 |
ankur.sing |
167 |
|
|
|
168 |
@Override
|
| 3850 |
chandransh |
169 |
public List<Item> getAllInProcessItems(int start, int limit) {
|
|
|
170 |
return getItemsByStatus(status.IN_PROCESS, start, limit);
|
| 2359 |
ankur.sing |
171 |
}
|
|
|
172 |
|
|
|
173 |
@Override
|
| 3850 |
chandransh |
174 |
public List<Item> getAllContentCompleteItems(int start, int limit) {
|
|
|
175 |
return getItemsByStatus(status.CONTENT_COMPLETE, start, limit);
|
| 2359 |
ankur.sing |
176 |
}
|
|
|
177 |
|
|
|
178 |
public List<Item> getBestDeals(){
|
| 2119 |
ankur.sing |
179 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
180 |
try {
|
| 3129 |
rajveer |
181 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
182 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
183 |
|
|
|
184 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
| 1992 |
ankur.sing |
185 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
186 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 1992 |
ankur.sing |
187 |
}
|
| 2359 |
ankur.sing |
188 |
} catch(Exception e){
|
| 3354 |
chandransh |
189 |
logger.error("Error while getting the best deals from the catalog service", e);
|
| 1961 |
ankur.sing |
190 |
}
|
| 2562 |
chandransh |
191 |
//Collections.sort(itemList, new ItemsComparator());
|
| 1961 |
ankur.sing |
192 |
return itemList;
|
|
|
193 |
}
|
|
|
194 |
|
| 2359 |
ankur.sing |
195 |
@Override
|
|
|
196 |
public List<Item> getRiskyItems() {
|
| 1961 |
ankur.sing |
197 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
198 |
try {
|
| 3129 |
rajveer |
199 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
200 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
201 |
|
|
|
202 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
|
| 1992 |
ankur.sing |
203 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
204 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 1992 |
ankur.sing |
205 |
}
|
| 1961 |
ankur.sing |
206 |
} catch(Exception e){
|
| 3354 |
chandransh |
207 |
logger.error("Error while getting the risky items from the catalog service", e);
|
| 1961 |
ankur.sing |
208 |
}
|
| 2068 |
ankur.sing |
209 |
Collections.sort(itemList, new ItemsComparator());
|
| 1961 |
ankur.sing |
210 |
return itemList;
|
|
|
211 |
}
|
| 2359 |
ankur.sing |
212 |
|
| 1961 |
ankur.sing |
213 |
public List<Item> getBestSellers(){
|
|
|
214 |
List<Item> itemList = new ArrayList<Item>();
|
| 2359 |
ankur.sing |
215 |
|
| 1961 |
ankur.sing |
216 |
try {
|
| 3129 |
rajveer |
217 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
218 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
219 |
|
| 1961 |
ankur.sing |
220 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
| 1992 |
ankur.sing |
221 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
222 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 1992 |
ankur.sing |
223 |
}
|
| 1961 |
ankur.sing |
224 |
} catch(Exception e){
|
| 3354 |
chandransh |
225 |
logger.error("Error while getting the best sellers from the catalog service", e);
|
| 1961 |
ankur.sing |
226 |
}
|
|
|
227 |
return itemList;
|
|
|
228 |
}
|
| 6530 |
vikram.rag |
229 |
|
|
|
230 |
@Override
|
|
|
231 |
public boolean addtoIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
|
|
|
232 |
try {
|
|
|
233 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
234 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
235 |
return inventoryClient.insertItemtoIgnoreInventoryUpdatelist(itemId, warehouseId);
|
|
|
236 |
} catch (Exception e) {
|
|
|
237 |
logger.error("Error while inserting item to ignore inventory update list", e);
|
|
|
238 |
}
|
|
|
239 |
return false;
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
@Override
|
|
|
243 |
public boolean deleteFromIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
|
|
|
244 |
try {
|
|
|
245 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
246 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
247 |
return inventoryClient.deleteItemFromIgnoredInventoryUpdateList(itemId,warehouseId);
|
|
|
248 |
|
|
|
249 |
} catch (Exception e) {
|
| 6532 |
amit.gupta |
250 |
logger.error("Error while inserting item to ignore inventory update list", e);
|
| 6530 |
vikram.rag |
251 |
}
|
|
|
252 |
return false;
|
|
|
253 |
}
|
| 2359 |
ankur.sing |
254 |
|
| 6530 |
vikram.rag |
255 |
|
|
|
256 |
|
| 3872 |
chandransh |
257 |
@Override
|
| 1961 |
ankur.sing |
258 |
public List<Item> getLatestArrivals(){
|
|
|
259 |
List<Item> itemList = new ArrayList<Item>();
|
| 2359 |
ankur.sing |
260 |
|
| 1961 |
ankur.sing |
261 |
try {
|
| 3129 |
rajveer |
262 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
263 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
264 |
|
| 1961 |
ankur.sing |
265 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
| 1992 |
ankur.sing |
266 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 5946 |
rajveer |
267 |
//List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 9835 |
rajveer |
268 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 1992 |
ankur.sing |
269 |
}
|
| 1961 |
ankur.sing |
270 |
} catch(Exception e){
|
| 3354 |
chandransh |
271 |
logger.error("Error while getting the latest arrivals from the catalog service", e);
|
| 1961 |
ankur.sing |
272 |
}
|
|
|
273 |
return itemList;
|
|
|
274 |
}
|
| 2359 |
ankur.sing |
275 |
|
| 3872 |
chandransh |
276 |
@Override
|
|
|
277 |
public List<Item> searchItems(int start, int limit, List<String> searchTerms) {
|
|
|
278 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
279 |
|
|
|
280 |
try {
|
|
|
281 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
282 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3872 |
chandransh |
283 |
|
|
|
284 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
|
|
|
285 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
286 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null,null));
|
| 3872 |
chandransh |
287 |
}
|
|
|
288 |
} catch(Exception e){
|
|
|
289 |
logger.error("Error while getting the search results from the catalog service", e);
|
|
|
290 |
}
|
|
|
291 |
return itemList;
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
@Override
|
|
|
295 |
public int getSearchResultCount(List<String> searchTerms){
|
|
|
296 |
int count = 0;
|
|
|
297 |
try {
|
|
|
298 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
299 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3872 |
chandransh |
300 |
|
|
|
301 |
count = catalogClient.getSearchResultCount(searchTerms);
|
|
|
302 |
} catch(Exception e){
|
|
|
303 |
logger.error("Error while getting the search results from the catalog service", e);
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
return count;
|
|
|
307 |
}
|
|
|
308 |
|
| 1961 |
ankur.sing |
309 |
public Item getItem(long itemId){
|
|
|
310 |
try{
|
| 3129 |
rajveer |
311 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
312 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
313 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
314 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 1961 |
ankur.sing |
315 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
| 5427 |
amit.gupta |
316 |
Long catalogItemId = thriftItem.getCatalogItemId();
|
|
|
317 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByCatalogId(catalogItemId);
|
|
|
318 |
List <Long> sameItemsWithDifferentColors = new ArrayList<Long>();
|
|
|
319 |
if(thriftItems.size()>1){
|
|
|
320 |
for(in.shop2020.model.v1.catalog.Item tItem : thriftItems ){
|
|
|
321 |
Long id = tItem.getId();
|
|
|
322 |
if(!id.equals(itemId)){
|
|
|
323 |
sameItemsWithDifferentColors.add(id);
|
|
|
324 |
}
|
|
|
325 |
}
|
|
|
326 |
}
|
| 5946 |
rajveer |
327 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
| 10484 |
vikram.rag |
328 |
Map<Long,String> stateIdNameMap = inventoryClient.getStateMaster();
|
|
|
329 |
|
| 5946 |
rajveer |
330 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
| 3558 |
rajveer |
331 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
|
| 4423 |
phani.kuma |
332 |
List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
|
| 5946 |
rajveer |
333 |
in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
|
| 6813 |
amar.kumar |
334 |
ItemStockPurchaseParams stockPurchaseParams = inventoryClient.getItemStockPurchaseParams(thriftItem.getId());
|
| 9835 |
rajveer |
335 |
Map<Long, String> saleHistory = new HashMap<Long, String>();
|
|
|
336 |
List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 0, 5);
|
|
|
337 |
String lastNdaySale = getOosString(oosStatuses);
|
|
|
338 |
saleHistory.put(0L,lastNdaySale);
|
|
|
339 |
List<OOSStatus> webOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 1, 5);
|
|
|
340 |
String webLastNdaySale = getOosString(webOosStatuses);
|
|
|
341 |
saleHistory.put(1L,webLastNdaySale);
|
|
|
342 |
List<OOSStatus> amzOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 3, 5);
|
|
|
343 |
String amzLastNdaySale = getOosString(amzOosStatuses);
|
|
|
344 |
saleHistory.put(3L,amzLastNdaySale);
|
|
|
345 |
List<OOSStatus> ebayOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 6, 5);
|
|
|
346 |
String ebayLastNdaySale = getOosString(ebayOosStatuses);
|
|
|
347 |
saleHistory.put(6L,ebayLastNdaySale);
|
|
|
348 |
List<OOSStatus> spdOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 7, 5);
|
|
|
349 |
String spdLastNdaySale = getOosString(spdOosStatuses);
|
|
|
350 |
saleHistory.put(7L,spdLastNdaySale);
|
|
|
351 |
List<OOSStatus> fktOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 8, 5);
|
|
|
352 |
String fktLastNdaySale = getOosString(fktOosStatuses);
|
|
|
353 |
saleHistory.put(8L,fktLastNdaySale);
|
| 7190 |
amar.kumar |
354 |
Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
|
| 5504 |
phani.kuma |
355 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
|
| 10484 |
vikram.rag |
356 |
Map<String,String> stateNameVatPercentageMap = new HashMap<String,String>();
|
|
|
357 |
catalogClient = new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
|
|
|
358 |
double vatrate;
|
|
|
359 |
for(Entry<Long, String> entry:stateIdNameMap.entrySet()){
|
|
|
360 |
try{
|
|
|
361 |
vatrate= catalogClient.getVatPercentageForItem(thriftItem.getId(),entry.getKey(),thriftItem.getSellingPrice());
|
|
|
362 |
}
|
|
|
363 |
catch(CatalogServiceException cex){
|
|
|
364 |
vatrate = -1.0;
|
|
|
365 |
}
|
|
|
366 |
stateNameVatPercentageMap.put(entry.getValue(),String.valueOf(vatrate));
|
|
|
367 |
}
|
|
|
368 |
Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, saleHistory, freebieItemId , stateNameVatPercentageMap);
|
| 5427 |
amit.gupta |
369 |
it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
|
|
|
370 |
return it;
|
| 1961 |
ankur.sing |
371 |
}catch(Exception e){
|
| 3354 |
chandransh |
372 |
logger.error("Error while getting the item from the catalog service", e);
|
| 1961 |
ankur.sing |
373 |
}
|
|
|
374 |
return null;
|
|
|
375 |
}
|
| 9835 |
rajveer |
376 |
|
|
|
377 |
private String getOosString(List<OOSStatus> oosStatuses){
|
|
|
378 |
String lastNdaySale = "";
|
|
|
379 |
for(OOSStatus oosStatus : oosStatuses){
|
|
|
380 |
if(oosStatus.isIs_oos()){
|
|
|
381 |
lastNdaySale += "X-";
|
|
|
382 |
}else{
|
|
|
383 |
lastNdaySale += oosStatus.getNum_orders() + "-";
|
|
|
384 |
}
|
|
|
385 |
}
|
| 9873 |
amit.gupta |
386 |
if(lastNdaySale!=""){
|
|
|
387 |
lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
|
|
|
388 |
}
|
| 9835 |
rajveer |
389 |
return lastNdaySale;
|
|
|
390 |
}
|
| 2359 |
ankur.sing |
391 |
|
| 1961 |
ankur.sing |
392 |
@Override
|
| 1992 |
ankur.sing |
393 |
public boolean updateItem(Item item) {
|
| 3354 |
chandransh |
394 |
logger.info("Updating item with Id: " + item.getId());
|
| 1961 |
ankur.sing |
395 |
try{
|
| 3129 |
rajveer |
396 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
397 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
398 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
399 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
400 |
|
| 1992 |
ankur.sing |
401 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
| 2126 |
ankur.sing |
402 |
setThriftItemParams(tItem, item);
|
| 2359 |
ankur.sing |
403 |
|
| 2105 |
ankur.sing |
404 |
long rItemId;
|
|
|
405 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
| 3354 |
chandransh |
406 |
logger.error("Error updating item, returned Item Id: " + rItemId);
|
| 2105 |
ankur.sing |
407 |
return false;
|
|
|
408 |
}
|
| 3354 |
chandransh |
409 |
logger.info("Successfully updated item with id: " + item.getId());
|
| 2359 |
ankur.sing |
410 |
|
|
|
411 |
Map<String, VendorItemMapping> vendorMappings = item.getVendorKeysMap();
|
| 2119 |
ankur.sing |
412 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
| 5946 |
rajveer |
413 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
| 2359 |
ankur.sing |
414 |
|
|
|
415 |
for(Entry<String, VendorItemMapping> e : vendorMappings.entrySet()) {
|
| 5946 |
rajveer |
416 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
| 2359 |
ankur.sing |
417 |
VendorItemMapping v = e.getValue();
|
| 2119 |
ankur.sing |
418 |
tVendorMapping.setVendorId(v.getVendorId());
|
|
|
419 |
tVendorMapping.setItemKey(v.getItemKey());
|
|
|
420 |
tVendorMapping.setItemId(item.getId());
|
| 5946 |
rajveer |
421 |
inventoryClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 3354 |
chandransh |
422 |
logger.info("Updates VendorItemMapping: " + tVendorMapping.toString());
|
| 2119 |
ankur.sing |
423 |
}
|
|
|
424 |
}
|
| 2359 |
ankur.sing |
425 |
|
| 6813 |
amar.kumar |
426 |
if(item.getMinStockLevel()!=0 || item.getNumOfDaysStock()!=0) {
|
|
|
427 |
inventoryClient.updateItemStockPurchaseParams(item.getId(), item.getNumOfDaysStock(),
|
|
|
428 |
item.getMinStockLevel());
|
|
|
429 |
}
|
|
|
430 |
|
| 7239 |
amar.kumar |
431 |
if(item.getFreebieItemId()!=null) {
|
| 7190 |
amar.kumar |
432 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem = new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
433 |
freebieItem.setItemId(item.getId());
|
|
|
434 |
freebieItem.setFreebieItemId(item.getFreebieItemId());
|
|
|
435 |
catalogClient.addOrUpdateFreebieForItem(freebieItem);
|
|
|
436 |
}
|
|
|
437 |
|
| 2119 |
ankur.sing |
438 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
|
|
439 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| 5946 |
rajveer |
440 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
| 2119 |
ankur.sing |
441 |
for(VendorPricings v : vendorPricings.values()) {
|
| 5946 |
rajveer |
442 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
| 2105 |
ankur.sing |
443 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
444 |
tVendorPricing.setItemId(item.getId());
|
|
|
445 |
tVendorPricing.setMop(v.getMop());
|
|
|
446 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
|
|
447 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 6759 |
amar.kumar |
448 |
tVendorPricing.setNlc(v.getNlc());
|
| 5946 |
rajveer |
449 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
| 3354 |
chandransh |
450 |
logger.info("Updated VendorItemPricing: " + tVendorPricing.toString());
|
| 2105 |
ankur.sing |
451 |
}
|
|
|
452 |
}
|
| 3558 |
rajveer |
453 |
|
|
|
454 |
Map<Long, SourcePricings> sourcePricings = item.getSourcePricesMap();
|
|
|
455 |
if(sourcePricings != null && !sourcePricings.isEmpty()) {
|
|
|
456 |
in.shop2020.model.v1.catalog.SourceItemPricing tSourcePricings;
|
|
|
457 |
for(SourcePricings s : sourcePricings.values()) {
|
|
|
458 |
tSourcePricings = new in.shop2020.model.v1.catalog.SourceItemPricing();
|
|
|
459 |
tSourcePricings.setSourceId(s.getSourceId());
|
|
|
460 |
tSourcePricings.setItemId(item.getId());
|
|
|
461 |
tSourcePricings.setMrp(s.getMrp());
|
|
|
462 |
tSourcePricings.setSellingPrice(s.getSellingPrice());
|
|
|
463 |
catalogClient.addSourceItemPricing(tSourcePricings);
|
|
|
464 |
logger.info("Updated SourceItemPricing: " + tSourcePricings.toString());
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
|
| 2105 |
ankur.sing |
468 |
}catch(Exception e){
|
| 3354 |
chandransh |
469 |
logger.error("Error while updating item: ", e);
|
| 2427 |
ankur.sing |
470 |
return false;
|
| 2105 |
ankur.sing |
471 |
}
|
|
|
472 |
return true;
|
| 1961 |
ankur.sing |
473 |
}
|
| 2359 |
ankur.sing |
474 |
|
| 6530 |
vikram.rag |
475 |
@Override
|
|
|
476 |
public List<Long> getMonitoredWarehouseIdsForVendors(List<Long> vendorIds){
|
|
|
477 |
List<Long> monitoredWarehouseids=null;
|
|
|
478 |
try {
|
|
|
479 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
480 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
481 |
monitoredWarehouseids = inventoryClient.getMonitoredWarehouseForVendors(vendorIds);
|
|
|
482 |
} catch (Exception e) {
|
|
|
483 |
logger.error("Error while getting Monitored warehouse for vendor: ", e);
|
|
|
484 |
}
|
|
|
485 |
return monitoredWarehouseids;
|
|
|
486 |
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
@Override
|
|
|
490 |
public List<ItemWarehouse> getignoredInventoryUpdateItemsIdsWarehouseIds(){
|
|
|
491 |
List<ItemWarehouse> ignoredItemIdwarehouseIdList = new ArrayList<ItemWarehouse>();
|
|
|
492 |
try {
|
| 2359 |
ankur.sing |
493 |
|
| 6530 |
vikram.rag |
494 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
495 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
496 |
List<IgnoredInventoryUpdateItems> ignoredInventoryUpdateItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
|
|
|
497 |
for(IgnoredInventoryUpdateItems ignoredInventoryUpdateItem:ignoredInventoryUpdateItems){
|
|
|
498 |
ignoredItemIdwarehouseIdList.add(new ItemWarehouse(ignoredInventoryUpdateItem.getItemId(),ignoredInventoryUpdateItem.getWarehouseId()));
|
|
|
499 |
}
|
|
|
500 |
|
|
|
501 |
|
|
|
502 |
} catch (Exception e) {
|
|
|
503 |
logger.error("Error while getting Monitored warehouseid and itemid : ", e);
|
|
|
504 |
}
|
|
|
505 |
return ignoredItemIdwarehouseIdList;
|
|
|
506 |
|
|
|
507 |
}
|
| 2066 |
ankur.sing |
508 |
@Override
|
|
|
509 |
public Map<Long, String> getAllVendors() {
|
|
|
510 |
Map<Long, String> vendorMap = new HashMap<Long, String>();
|
|
|
511 |
try {
|
| 5946 |
rajveer |
512 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
513 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
514 |
|
|
|
515 |
List<in.shop2020.model.v1.inventory.Vendor> vendors = inventoryClient.getAllVendors();
|
| 2359 |
ankur.sing |
516 |
|
| 5946 |
rajveer |
517 |
for(in.shop2020.model.v1.inventory.Vendor v : vendors) {
|
| 2066 |
ankur.sing |
518 |
vendorMap.put(v.getId(), v.getName());
|
|
|
519 |
}
|
|
|
520 |
} catch (Exception e) {
|
| 3354 |
chandransh |
521 |
logger.error("Error while getting all the vendors: ", e);
|
| 2066 |
ankur.sing |
522 |
}
|
|
|
523 |
return vendorMap;
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
@Override
|
| 3558 |
rajveer |
527 |
public Map<Long, String> getAllSources() {
|
|
|
528 |
Map<Long, String> sourceMap = new HashMap<Long, String>();
|
|
|
529 |
try {
|
|
|
530 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
531 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3558 |
rajveer |
532 |
|
|
|
533 |
List<in.shop2020.model.v1.catalog.Source> sources = catalogClient.getAllSources();
|
|
|
534 |
|
|
|
535 |
for(in.shop2020.model.v1.catalog.Source s : sources) {
|
|
|
536 |
sourceMap.put(s.getId(), s.getName());
|
|
|
537 |
}
|
|
|
538 |
} catch (Exception e) {
|
|
|
539 |
logger.error("Error while getting all the vendors: ", e);
|
|
|
540 |
}
|
|
|
541 |
return sourceMap;
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
@Override
|
| 5118 |
mandeep.dh |
545 |
public Map<Long, String> getShippingWarehouses() {
|
|
|
546 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
|
|
547 |
Set<Long> shippingLocations = new HashSet<Long>();
|
|
|
548 |
try {
|
| 5946 |
rajveer |
549 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
550 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
551 |
|
|
|
552 |
List<in.shop2020.model.v1.inventory.Warehouse> warehouses = inventoryClient.getAllWarehouses(true);
|
| 5118 |
mandeep.dh |
553 |
|
| 5946 |
rajveer |
554 |
for(in.shop2020.model.v1.inventory.Warehouse warehouse : warehouses) {
|
| 5118 |
mandeep.dh |
555 |
shippingLocations.add(warehouse.getShippingWarehouseId());
|
|
|
556 |
}
|
|
|
557 |
|
| 5946 |
rajveer |
558 |
for(in.shop2020.model.v1.inventory.Warehouse warehouse : warehouses) {
|
| 5118 |
mandeep.dh |
559 |
if (shippingLocations.contains(warehouse.getId())) {
|
|
|
560 |
warehouseMap.put(warehouse.getId(), warehouse.getDisplayName());
|
|
|
561 |
}
|
|
|
562 |
}
|
|
|
563 |
} catch (Exception e) {
|
|
|
564 |
logger.error("Error while getting all the warehouses:", e );
|
|
|
565 |
}
|
|
|
566 |
return warehouseMap;
|
|
|
567 |
}
|
|
|
568 |
|
|
|
569 |
@Override
|
| 2066 |
ankur.sing |
570 |
public Map<Long, String> getAllWarehouses() {
|
|
|
571 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
|
|
572 |
try {
|
| 5946 |
rajveer |
573 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
574 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2359 |
ankur.sing |
575 |
|
| 5946 |
rajveer |
576 |
List<in.shop2020.model.v1.inventory.Warehouse> warehouses = inventoryClient.getAllWarehouses(true);
|
| 2359 |
ankur.sing |
577 |
|
| 5946 |
rajveer |
578 |
for(in.shop2020.model.v1.inventory.Warehouse w : warehouses) {
|
| 2066 |
ankur.sing |
579 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
|
|
580 |
}
|
|
|
581 |
} catch (Exception e) {
|
| 3354 |
chandransh |
582 |
logger.error("Error while getting all the warehouses:", e );
|
| 2066 |
ankur.sing |
583 |
}
|
|
|
584 |
return warehouseMap;
|
|
|
585 |
}
|
| 2105 |
ankur.sing |
586 |
|
|
|
587 |
@Override
|
|
|
588 |
public long addItem(Item item) {
|
|
|
589 |
long itemId = 0;
|
|
|
590 |
try {
|
| 3129 |
rajveer |
591 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
592 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
593 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
594 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2126 |
ankur.sing |
595 |
|
| 2105 |
ankur.sing |
596 |
in.shop2020.model.v1.catalog.Item tItem = new in.shop2020.model.v1.catalog.Item();
|
| 2126 |
ankur.sing |
597 |
setThriftItemParams(tItem, item);
|
| 2105 |
ankur.sing |
598 |
itemId = catalogClient.addItem(tItem);
|
|
|
599 |
|
| 2119 |
ankur.sing |
600 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
|
|
601 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| 5946 |
rajveer |
602 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
| 2119 |
ankur.sing |
603 |
for(VendorPricings v : vendorPricings.values()) {
|
| 5946 |
rajveer |
604 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
| 2119 |
ankur.sing |
605 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
606 |
tVendorPricing.setItemId(itemId);
|
|
|
607 |
tVendorPricing.setMop(v.getMop());
|
|
|
608 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| 6759 |
amar.kumar |
609 |
tVendorPricing.setNlc(v.getNlc());
|
| 2119 |
ankur.sing |
610 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 5946 |
rajveer |
611 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
| 2119 |
ankur.sing |
612 |
}
|
|
|
613 |
}
|
| 2359 |
ankur.sing |
614 |
|
|
|
615 |
Map<String, VendorItemMapping> vendorKeysMap = item.getVendorKeysMap();
|
| 2119 |
ankur.sing |
616 |
if(vendorKeysMap != null && !vendorKeysMap.isEmpty()) {
|
| 5946 |
rajveer |
617 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
| 2359 |
ankur.sing |
618 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()) {
|
| 5946 |
rajveer |
619 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
| 2359 |
ankur.sing |
620 |
VendorItemMapping v = e.getValue();
|
| 2105 |
ankur.sing |
621 |
tVendorMapping.setVendorId(v.getVendorId());
|
|
|
622 |
tVendorMapping.setItemKey(v.getItemKey());
|
|
|
623 |
tVendorMapping.setItemId(itemId);
|
| 5946 |
rajveer |
624 |
inventoryClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 2105 |
ankur.sing |
625 |
}
|
|
|
626 |
}
|
| 6813 |
amar.kumar |
627 |
|
|
|
628 |
inventoryClient.updateItemStockPurchaseParams(itemId, item.getNumOfDaysStock(),
|
|
|
629 |
item.getMinStockLevel());
|
| 7190 |
amar.kumar |
630 |
|
|
|
631 |
if(item.getFreebieItemId()!=null && item.getFreebieItemId()!=0) {
|
|
|
632 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem =
|
|
|
633 |
new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
634 |
freebieItem.setItemId(itemId);
|
|
|
635 |
freebieItem.setFreebieItemId(item.getFreebieItemId());
|
|
|
636 |
catalogClient.addOrUpdateFreebieForItem(freebieItem);
|
|
|
637 |
}
|
|
|
638 |
|
| 2105 |
ankur.sing |
639 |
} catch (Exception e) {
|
| 3354 |
chandransh |
640 |
logger.error("Error while adding an item: ", e);
|
| 2105 |
ankur.sing |
641 |
}
|
|
|
642 |
return itemId;
|
|
|
643 |
}
|
| 2119 |
ankur.sing |
644 |
|
|
|
645 |
@Override
|
| 4725 |
phani.kuma |
646 |
public long checkSimilarItem(String brand, String modelNumber, String modelName, String color) {
|
| 2359 |
ankur.sing |
647 |
|
| 2119 |
ankur.sing |
648 |
try {
|
| 3129 |
rajveer |
649 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
650 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4725 |
phani.kuma |
651 |
return catalogClient.checkSimilarItem(brand, modelNumber, modelName, color);
|
| 2119 |
ankur.sing |
652 |
} catch (Exception e) {
|
| 3354 |
chandransh |
653 |
logger.error("Error while checking for a similar item: ", e);
|
| 2119 |
ankur.sing |
654 |
}
|
|
|
655 |
return 0;
|
|
|
656 |
}
|
| 2359 |
ankur.sing |
657 |
|
| 2126 |
ankur.sing |
658 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
|
|
659 |
tItem.setId(tItem.getId());
|
|
|
660 |
tItem.setProductGroup(item.getProductGroup());
|
|
|
661 |
tItem.setBrand(item.getBrand());
|
|
|
662 |
tItem.setModelName(item.getModelName());
|
|
|
663 |
tItem.setModelNumber(item.getModelNumber());
|
|
|
664 |
tItem.setColor(item.getColor());
|
| 6241 |
amit.gupta |
665 |
tItem.setShowSellingPrice(item.isShowSellingPrice());
|
| 9841 |
rajveer |
666 |
tItem.setHoldOverride(item.isHoldOverride());
|
| 2359 |
ankur.sing |
667 |
tItem.setStatus_description(item.getItemStatusDesc());
|
| 2126 |
ankur.sing |
668 |
tItem.setComments(item.getComments());
|
| 2359 |
ankur.sing |
669 |
|
| 2489 |
ankur.sing |
670 |
if(item.getMrp() != null) {
|
| 2126 |
ankur.sing |
671 |
tItem.setMrp(item.getMrp());
|
|
|
672 |
}
|
| 3354 |
chandransh |
673 |
|
| 5586 |
phani.kuma |
674 |
if(item.getCatalogItemId() != null) {
|
|
|
675 |
tItem.setCatalogItemId(item.getCatalogItemId());
|
|
|
676 |
}
|
|
|
677 |
|
| 2489 |
ankur.sing |
678 |
if(item.getSellingPrice() != null) {
|
| 2126 |
ankur.sing |
679 |
tItem.setSellingPrice(item.getSellingPrice());
|
|
|
680 |
}
|
| 3354 |
chandransh |
681 |
|
| 2489 |
ankur.sing |
682 |
if(item.getWeight() != null) {
|
| 2126 |
ankur.sing |
683 |
tItem.setWeight(item.getWeight());
|
|
|
684 |
}
|
| 3354 |
chandransh |
685 |
|
| 3359 |
chandransh |
686 |
if(item.getExpectedDelay() != null) {
|
|
|
687 |
tItem.setExpectedDelay(item.getExpectedDelay());
|
| 2489 |
ankur.sing |
688 |
}
|
| 3354 |
chandransh |
689 |
|
| 4413 |
anupam.sin |
690 |
tItem.setIsWarehousePreferenceSticky(item.isWarehouseStickiness());
|
|
|
691 |
|
| 4506 |
phani.kuma |
692 |
if(item.getPreferredVendor() != null) {
|
|
|
693 |
tItem.setPreferredVendor(item.getPreferredVendor());
|
|
|
694 |
}
|
| 6838 |
vikram.rag |
695 |
tItem.setPreferredInsurer(item.getPreferredInsurer());
|
| 7291 |
vikram.rag |
696 |
|
|
|
697 |
if(item.getAsin() != null) {
|
|
|
698 |
tItem.setAsin(item.getAsin());
|
|
|
699 |
}
|
| 7305 |
amit.gupta |
700 |
if(item.getHoldInventory()!= null) {
|
|
|
701 |
tItem.setHoldInventory(item.getHoldInventory());
|
|
|
702 |
}
|
|
|
703 |
else{
|
|
|
704 |
tItem.setHoldInventory(0);
|
|
|
705 |
}
|
|
|
706 |
if(item.getDefaultInventory()!=null){
|
|
|
707 |
tItem.setDefaultInventory(item.getDefaultInventory());
|
|
|
708 |
}
|
|
|
709 |
else{
|
|
|
710 |
tItem.setDefaultInventory(0);
|
|
|
711 |
}
|
| 2126 |
ankur.sing |
712 |
tItem.setBestDealText(item.getBestDealsText());
|
| 6777 |
vikram.rag |
713 |
tItem.setBestDealsDetailsText(item.getBestDealsDetailsText());
|
|
|
714 |
tItem.setBestDealsDetailsLink(item.getBestDealsDetailsLink());
|
| 2489 |
ankur.sing |
715 |
if(item.getBestDealsValue() != null) {
|
| 2126 |
ankur.sing |
716 |
tItem.setBestDealValue(item.getBestDealsValue());
|
|
|
717 |
}
|
| 3354 |
chandransh |
718 |
|
| 2489 |
ankur.sing |
719 |
if(item.getBestSellingRank() != null) {
|
| 2126 |
ankur.sing |
720 |
tItem.setBestSellingRank(item.getBestSellingRank());
|
|
|
721 |
}
|
| 3354 |
chandransh |
722 |
|
| 2126 |
ankur.sing |
723 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
| 2252 |
ankur.sing |
724 |
tItem.setRisky(item.isRisky());
|
| 5384 |
phani.kuma |
725 |
tItem.setHasItemNo(item.isHasItemNo());
|
|
|
726 |
|
|
|
727 |
if(item.isItemType()) {
|
|
|
728 |
tItem.setType(ItemType.SERIALIZED);
|
|
|
729 |
}
|
|
|
730 |
else {
|
|
|
731 |
tItem.setType(ItemType.NON_SERIALIZED);
|
|
|
732 |
}
|
|
|
733 |
|
| 2489 |
ankur.sing |
734 |
if(item.getStartDate() != null) {
|
|
|
735 |
tItem.setStartDate(item.getStartDate());
|
|
|
736 |
}
|
| 3354 |
chandransh |
737 |
|
| 5217 |
amit.gupta |
738 |
if(item.getExpectedArrivalDate() != null) {
|
|
|
739 |
tItem.setExpectedArrivalDate(item.getExpectedArrivalDate());
|
|
|
740 |
} else {
|
|
|
741 |
tItem.unsetComingSoonStartDate();
|
|
|
742 |
tItem.unsetExpectedArrivalDate();
|
|
|
743 |
if(status.COMING_SOON.equals(tItem.getItemStatus())){
|
| 6277 |
amit.gupta |
744 |
tItem.setItemStatus(status.CONTENT_COMPLETE);
|
|
|
745 |
tItem.setStatus_description("Content generation completed");
|
| 5217 |
amit.gupta |
746 |
}
|
|
|
747 |
}
|
|
|
748 |
|
|
|
749 |
if(item.getComingSoonStartDate() != null) {
|
|
|
750 |
tItem.setComingSoonStartDate(item.getComingSoonStartDate());
|
|
|
751 |
} else {
|
|
|
752 |
tItem.unsetComingSoonStartDate();
|
|
|
753 |
}
|
|
|
754 |
|
| 2489 |
ankur.sing |
755 |
if(item.getRetireDate() != null) {
|
|
|
756 |
tItem.setRetireDate(item.getRetireDate());
|
|
|
757 |
}
|
| 3354 |
chandransh |
758 |
|
| 2126 |
ankur.sing |
759 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
|
|
760 |
}
|
|
|
761 |
|
|
|
762 |
@Override
|
|
|
763 |
public void pauseItem(long itemId) {
|
|
|
764 |
try {
|
| 3129 |
rajveer |
765 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
766 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
767 |
|
| 2126 |
ankur.sing |
768 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
|
|
769 |
} catch (Exception e) {
|
| 3354 |
chandransh |
770 |
logger.error("Error while pausing the item: " + itemId, e);
|
| 2126 |
ankur.sing |
771 |
}
|
| 2359 |
ankur.sing |
772 |
|
| 2126 |
ankur.sing |
773 |
}
|
|
|
774 |
|
|
|
775 |
@Override
|
|
|
776 |
public void markInProcess(long itemId) {
|
|
|
777 |
try {
|
| 3129 |
rajveer |
778 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
779 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
780 |
|
| 2126 |
ankur.sing |
781 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
|
|
782 |
} catch (Exception e) {
|
| 3354 |
chandransh |
783 |
logger.error("Error while marking in-process the item: " + itemId, e);
|
| 2126 |
ankur.sing |
784 |
}
|
|
|
785 |
}
|
| 2359 |
ankur.sing |
786 |
|
| 2126 |
ankur.sing |
787 |
@Override
|
|
|
788 |
public void phaseoutItem(long itemId) {
|
|
|
789 |
try {
|
| 3129 |
rajveer |
790 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
791 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
792 |
|
| 2126 |
ankur.sing |
793 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
|
|
794 |
} catch (Exception e) {
|
| 3354 |
chandransh |
795 |
logger.error("Error while phasing out the item: " + itemId, e);
|
| 2126 |
ankur.sing |
796 |
}
|
|
|
797 |
}
|
| 2359 |
ankur.sing |
798 |
|
| 2126 |
ankur.sing |
799 |
@Override
|
|
|
800 |
public void activateItem(long itemId) {
|
|
|
801 |
try {
|
| 3129 |
rajveer |
802 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
803 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
804 |
|
| 2126 |
ankur.sing |
805 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
|
|
806 |
} catch (Exception e) {
|
| 3354 |
chandransh |
807 |
logger.error("Error while activating the item: " + itemId, e);
|
| 2126 |
ankur.sing |
808 |
}
|
|
|
809 |
}
|
| 2359 |
ankur.sing |
810 |
|
|
|
811 |
@Override
|
|
|
812 |
public boolean changeItemRiskyFlag(long itemId, boolean risky) {
|
|
|
813 |
try {
|
| 4354 |
mandeep.dh |
814 |
logger.info("Updating risky flag for item id: " + itemId + " to " + risky);
|
| 2359 |
ankur.sing |
815 |
// Initialize client for staging server
|
| 3129 |
rajveer |
816 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
817 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
818 |
|
|
|
819 |
// Initialize client for production server
|
| 3165 |
chandransh |
820 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
| 2359 |
ankur.sing |
821 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| 5946 |
rajveer |
822 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| 2359 |
ankur.sing |
823 |
catalogClient.changeItemRiskyFlag(itemId, risky);
|
|
|
824 |
|
|
|
825 |
try{
|
|
|
826 |
catalogClient_Prod.changeItemRiskyFlag(itemId, risky);
|
|
|
827 |
}catch(Exception e){
|
| 3354 |
chandransh |
828 |
logger.error("Error while updating item's risky flag on production", e);
|
| 2359 |
ankur.sing |
829 |
// If not able to change risky flag on production, revert on staging and return false (to show error to user).
|
|
|
830 |
catalogClient.changeItemRiskyFlag(itemId, !risky);
|
|
|
831 |
return false;
|
|
|
832 |
}
|
|
|
833 |
} catch (Exception e) {
|
| 3354 |
chandransh |
834 |
logger.error("Error while updating item's risky flag on staging", e);
|
| 2359 |
ankur.sing |
835 |
return false;
|
|
|
836 |
}
|
|
|
837 |
return true;
|
|
|
838 |
}
|
|
|
839 |
|
| 2427 |
ankur.sing |
840 |
|
|
|
841 |
/**
|
| 4762 |
phani.kuma |
842 |
* Retuns list of Items filtered by category (column is product_group in catalog.item table)
|
| 2427 |
ankur.sing |
843 |
* This list is used to generate master sheet (excel sheet)
|
|
|
844 |
* @param category
|
| 4957 |
phani.kuma |
845 |
* @param brand
|
| 2427 |
ankur.sing |
846 |
* @return
|
|
|
847 |
*/
|
| 4957 |
phani.kuma |
848 |
public List<Item> getItemsForMasterSheet(String category, String brand) {
|
| 2359 |
ankur.sing |
849 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
850 |
try {
|
| 3129 |
rajveer |
851 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
852 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
853 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
854 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2359 |
ankur.sing |
855 |
|
| 4957 |
phani.kuma |
856 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsForMasterSheet(category, brand);
|
| 2359 |
ankur.sing |
857 |
|
|
|
858 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 5946 |
rajveer |
859 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
|
|
860 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
| 3558 |
rajveer |
861 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
|
| 9836 |
rajveer |
862 |
itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null, null, null, null, null));
|
| 2359 |
ankur.sing |
863 |
}
|
|
|
864 |
} catch (Exception e) {
|
| 4762 |
phani.kuma |
865 |
logger.error("Error while getting items by category: " + category, e);
|
| 2359 |
ankur.sing |
866 |
}
|
|
|
867 |
Collections.sort(itemList, new ItemsComparator());
|
|
|
868 |
return itemList;
|
|
|
869 |
}
|
|
|
870 |
|
|
|
871 |
@Override
|
| 2427 |
ankur.sing |
872 |
public String updateItemOnProduction(Item item) {
|
| 5706 |
amit.gupta |
873 |
if(!canPushToProduction()) {
|
|
|
874 |
// If we can't push to production, then return that message to user
|
|
|
875 |
// else move forward with update.
|
|
|
876 |
return "Maximum push to production count reached for today";
|
|
|
877 |
}
|
|
|
878 |
List<Long> itemIds = item.getSameItemsWithDifferentColors();
|
|
|
879 |
List<Item> items = new ArrayList<Item>();
|
|
|
880 |
items.add(item);
|
|
|
881 |
for(Long itemId : itemIds) {
|
|
|
882 |
try {
|
|
|
883 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
884 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
885 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
886 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
887 |
|
| 5706 |
amit.gupta |
888 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
| 5946 |
rajveer |
889 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
|
|
890 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
| 5706 |
amit.gupta |
891 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
|
| 9836 |
rajveer |
892 |
items.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null, null, null, null, null));
|
| 5706 |
amit.gupta |
893 |
} catch (Exception e) {
|
|
|
894 |
logger.error("Could not fetch item for : " + itemId, e);
|
|
|
895 |
return "Could not push to production. No item got pushed.";
|
|
|
896 |
}
|
|
|
897 |
}
|
|
|
898 |
for (Item it : items) {
|
|
|
899 |
logger.info("Update item on production call, Item Id: " + it.getId());
|
|
|
900 |
|
|
|
901 |
try{
|
|
|
902 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(
|
|
|
903 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
904 |
ConfigClientKeys.catalog_service_server_port.toString());
|
|
|
905 |
|
| 5946 |
rajveer |
906 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| 5706 |
amit.gupta |
907 |
|
|
|
908 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(it.getId());
|
|
|
909 |
|
| 5946 |
rajveer |
910 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
911 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
912 |
|
| 5706 |
amit.gupta |
913 |
if(it.getMrp() != null) {
|
|
|
914 |
tItem.setMrp(it.getMrp());
|
|
|
915 |
}
|
|
|
916 |
|
|
|
917 |
if(it.getSellingPrice() != null) {
|
|
|
918 |
tItem.setSellingPrice(it.getSellingPrice());
|
|
|
919 |
}
|
|
|
920 |
|
| 7700 |
amit.gupta |
921 |
tItem.setBestDealText(it.getBestDealsText());
|
| 7198 |
amar.kumar |
922 |
|
| 6826 |
amit.gupta |
923 |
if (it.getItemStatusValue() == ItemStatus.ACTIVE.getValue() || it.getItemStatusValue() == ItemStatus.PAUSED.getValue()) {
|
|
|
924 |
tItem.setItemStatus(status.findByValue(it.getItemStatusValue()));
|
|
|
925 |
tItem.setStartDate(it.getStartDate());
|
|
|
926 |
}
|
| 5706 |
amit.gupta |
927 |
long rItemId;
|
|
|
928 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != it.getId()) {
|
|
|
929 |
logger.error("Error updating item on production, returned Item Id: " + rItemId);
|
|
|
930 |
return "Error updating item prices on production";
|
|
|
931 |
}
|
| 7198 |
amar.kumar |
932 |
if(it.getFreebieItemId() !=null && it.getFreebieItemId()!=0) {
|
|
|
933 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem = new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
934 |
freebieItem.setItemId(it.getId());
|
|
|
935 |
freebieItem.setFreebieItemId(it.getFreebieItemId());
|
|
|
936 |
catalogClient_Prod.addOrUpdateFreebieForItem(freebieItem);
|
|
|
937 |
}
|
| 5706 |
amit.gupta |
938 |
logger.info("Successfully updated item: " + it.getId());
|
|
|
939 |
|
|
|
940 |
StringBuilder sb = new StringBuilder();
|
|
|
941 |
|
|
|
942 |
Map<Long, VendorPricings> vendorPricings = it.getVendorPricesMap();
|
|
|
943 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| 5946 |
rajveer |
944 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
| 5706 |
amit.gupta |
945 |
for(VendorPricings v : vendorPricings.values()) {
|
| 5946 |
rajveer |
946 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
| 5706 |
amit.gupta |
947 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
948 |
tVendorPricing.setItemId(it.getId());
|
|
|
949 |
tVendorPricing.setMop(v.getMop());
|
|
|
950 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| 6759 |
amar.kumar |
951 |
tVendorPricing.setNlc(v.getNlc());
|
| 5706 |
amit.gupta |
952 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 5946 |
rajveer |
953 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
| 5706 |
amit.gupta |
954 |
logger.info("VendorItemPricing updated. " + tVendorPricing.toString());
|
| 6759 |
amar.kumar |
955 |
sb.append("[VId:" + v.getVendorId() + ",MOP=" + v.getMop() + ",TP=" + v.getTransferPrice() + ",NLC= " +v.getNlc() + ",DP=" + v.getDealerPrice() + "], ");
|
| 5706 |
amit.gupta |
956 |
}
|
|
|
957 |
}
|
|
|
958 |
|
|
|
959 |
Map<String, VendorItemMapping> vendorMappings = it.getVendorKeysMap();
|
|
|
960 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
| 5946 |
rajveer |
961 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
| 5706 |
amit.gupta |
962 |
for(VendorItemMapping vendorItemMapping : vendorMappings.values()) {
|
| 5946 |
rajveer |
963 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
| 5706 |
amit.gupta |
964 |
tVendorMapping.setVendorId(vendorItemMapping.getVendorId());
|
|
|
965 |
tVendorMapping.setItemId(it.getId());
|
|
|
966 |
tVendorMapping.setItemKey(vendorItemMapping.getItemKey());
|
| 5946 |
rajveer |
967 |
inventoryClient.addVendorItemMapping(vendorItemMapping.getItemKey(), tVendorMapping);
|
| 5706 |
amit.gupta |
968 |
logger.info("VendorItemMapping updated. " + tVendorMapping.toString());
|
|
|
969 |
sb.append("[VId:" + vendorItemMapping.getVendorId() + ",ItemKey=" + vendorItemMapping.getItemKey() + "], ");
|
|
|
970 |
}
|
|
|
971 |
}
|
|
|
972 |
|
|
|
973 |
Map<Long, SourcePricings> sourcePricings = it.getSourcePricesMap();
|
|
|
974 |
if(sourcePricings != null && !sourcePricings.isEmpty()){
|
|
|
975 |
in.shop2020.model.v1.catalog.SourceItemPricing tSourcePricing;
|
|
|
976 |
for(SourcePricings s : sourcePricings.values()){
|
|
|
977 |
tSourcePricing = new in.shop2020.model.v1.catalog.SourceItemPricing();
|
|
|
978 |
tSourcePricing.setSourceId(s.getSourceId());
|
|
|
979 |
tSourcePricing.setItemId(it.getId());
|
|
|
980 |
tSourcePricing.setMrp(s.getMrp());
|
|
|
981 |
tSourcePricing.setSellingPrice(s.getSellingPrice());
|
|
|
982 |
catalogClient_Prod.addSourceItemPricing(tSourcePricing);
|
|
|
983 |
logger.info("SourceItemPricing updated. " + tSourcePricing.toString());
|
|
|
984 |
sb.append("[SId:" + s.getSourceId() + ",MRP=" + s.getMrp() + ",SP=" + s.getSellingPrice() + "], ");
|
|
|
985 |
}
|
|
|
986 |
}
|
|
|
987 |
|
|
|
988 |
pushToProdLogger.info("Id=" + it.getId() + ",MRP=" + it.getMrp() + ",SP=" + " " + it.getSellingPrice() + sb.toString());
|
|
|
989 |
} catch (Exception e) {
|
|
|
990 |
logger.error("Error while updating prices on production", e);
|
|
|
991 |
return "Error while updating all prices on production. Some of the prices may not have been updated";
|
|
|
992 |
}
|
|
|
993 |
}
|
| 2427 |
ankur.sing |
994 |
|
| 3907 |
chandransh |
995 |
try {
|
|
|
996 |
ContentClient contentServiceClient = new ContentClient();
|
|
|
997 |
ContentService.Client contentClient = contentServiceClient.getClient();
|
|
|
998 |
|
| 5706 |
amit.gupta |
999 |
contentClient.pushContentToProduction(items.get(0).getCatalogItemId());
|
| 3907 |
chandransh |
1000 |
} catch (TTransportException e) {
|
|
|
1001 |
logger.error("Error while establishing connection to the content server", e);
|
|
|
1002 |
return "Error generating content. Prices updated successfully.";
|
|
|
1003 |
} catch (TException e) {
|
|
|
1004 |
logger.error("Error while pushing content to production", e);
|
|
|
1005 |
return "Error generating content. Prices updated successfully.";
|
|
|
1006 |
} catch (ContentServiceException e) {
|
|
|
1007 |
logger.error("Error while pushing content to production", e);
|
|
|
1008 |
return "Error generating content. Prices updated successfully.";
|
|
|
1009 |
}
|
|
|
1010 |
|
| 2427 |
ankur.sing |
1011 |
return "Prices updated and content generated successfully";
|
| 2359 |
ankur.sing |
1012 |
}
|
| 2427 |
ankur.sing |
1013 |
|
| 2489 |
ankur.sing |
1014 |
/**
|
| 3354 |
chandransh |
1015 |
* Returns list of items with a particular status.
|
|
|
1016 |
* @param st
|
|
|
1017 |
* @return
|
|
|
1018 |
*/
|
| 3850 |
chandransh |
1019 |
private List<Item> getItemsByStatus(status st, int start, int limit) {
|
| 3354 |
chandransh |
1020 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
1021 |
try {
|
|
|
1022 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1023 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3354 |
chandransh |
1024 |
|
| 3850 |
chandransh |
1025 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
|
| 3354 |
chandransh |
1026 |
|
|
|
1027 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 9835 |
rajveer |
1028 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
|
| 3354 |
chandransh |
1029 |
}
|
|
|
1030 |
} catch (Exception e) {
|
|
|
1031 |
logger.error("Error while getting items by status: " + st, e);
|
|
|
1032 |
}
|
|
|
1033 |
return itemList;
|
|
|
1034 |
}
|
|
|
1035 |
|
|
|
1036 |
/**
|
|
|
1037 |
* Creates a new Item object and populates its attributes from thrift item passed as parameter.
|
| 4423 |
phani.kuma |
1038 |
* Also creates a Map each for VendorItemPricing, VendorItemMapping, SourceItemPricing and SimilarItems and adds these maps to the
|
| 3354 |
chandransh |
1039 |
* new Item object.
|
|
|
1040 |
* @param thriftItem
|
|
|
1041 |
* @param tVendorPricings
|
|
|
1042 |
* @param tVendorMappings
|
| 4423 |
phani.kuma |
1043 |
* @param tSourceMappings
|
|
|
1044 |
* @param tSimilarItems
|
| 5504 |
phani.kuma |
1045 |
* @param tVoucherMappings
|
| 6813 |
amar.kumar |
1046 |
* @param stockPurchaseParams
|
| 3354 |
chandransh |
1047 |
* @return item object with attributes copied from thrift item object.
|
|
|
1048 |
*/
|
|
|
1049 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
| 5946 |
rajveer |
1050 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> tVendorPricings,
|
|
|
1051 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
|
| 4423 |
phani.kuma |
1052 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
|
| 6813 |
amar.kumar |
1053 |
List<in.shop2020.model.v1.catalog.Item> tSimilarItems,
|
|
|
1054 |
in.shop2020.model.v1.inventory.ItemInventory tItemInventory,
|
|
|
1055 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings,
|
| 9835 |
rajveer |
1056 |
ItemStockPurchaseParams tStockPurchaseParams, Map<Long,String> saleHistory, Long freebieItemId){
|
| 3354 |
chandransh |
1057 |
|
|
|
1058 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
|
|
1059 |
VendorItemMapping vItemMapping;
|
|
|
1060 |
if(tVendorMappings != null) {
|
| 5946 |
rajveer |
1061 |
for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
|
| 3354 |
chandransh |
1062 |
vItemMapping = new VendorItemMapping();
|
|
|
1063 |
vItemMapping.setVendorId(vim.getVendorId());
|
|
|
1064 |
vItemMapping.setItemKey(vim.getItemKey());
|
|
|
1065 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
|
|
1066 |
}
|
|
|
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
|
|
1070 |
VendorPricings vPricings;
|
|
|
1071 |
if(tVendorPricings != null) {
|
| 5946 |
rajveer |
1072 |
for(in.shop2020.model.v1.inventory.VendorItemPricing vip : tVendorPricings) {
|
| 3354 |
chandransh |
1073 |
vPricings = new VendorPricings();
|
|
|
1074 |
vPricings.setVendorId(vip.getVendorId());
|
|
|
1075 |
vPricings.setMop(vip.getMop());
|
|
|
1076 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
|
|
1077 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
| 6759 |
amar.kumar |
1078 |
vPricings.setNlc(vip.getNlc());
|
| 3354 |
chandransh |
1079 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
|
|
1080 |
}
|
|
|
1081 |
}
|
|
|
1082 |
|
| 3558 |
rajveer |
1083 |
Map<Long, SourcePricings> sourcePricingMap = new HashMap<Long, SourcePricings>();
|
|
|
1084 |
SourcePricings sPricings;
|
|
|
1085 |
if(tSourceMappings != null) {
|
|
|
1086 |
for(in.shop2020.model.v1.catalog.SourceItemPricing sip : tSourceMappings) {
|
|
|
1087 |
sPricings = new SourcePricings();
|
|
|
1088 |
sPricings.setSourceId(sip.getSourceId());
|
|
|
1089 |
sPricings.setMrp(sip.getMrp());
|
|
|
1090 |
sPricings.setSellingPrice(sip.getSellingPrice());
|
|
|
1091 |
sourcePricingMap.put(sPricings.getSourceId(), sPricings);
|
|
|
1092 |
}
|
|
|
1093 |
}
|
| 4423 |
phani.kuma |
1094 |
|
|
|
1095 |
Map<Long, Item> SimilarItemslist = new HashMap<Long, Item>();
|
|
|
1096 |
Item sItems;
|
|
|
1097 |
if(tSimilarItems != null) {
|
|
|
1098 |
for(in.shop2020.model.v1.catalog.Item sit : tSimilarItems) {
|
|
|
1099 |
sItems = new Item();
|
|
|
1100 |
sItems.setCatalogItemId(sit.getCatalogItemId());
|
|
|
1101 |
sItems.setProductGroup(sit.getProductGroup());
|
|
|
1102 |
sItems.setBrand(sit.getBrand());
|
|
|
1103 |
sItems.setModelNumber(sit.getModelNumber());
|
|
|
1104 |
sItems.setModelName(sit.getModelName());
|
|
|
1105 |
sItems.setContentCategory(CategoryManager.getCategoryManager().getCategoryLabel(sit.getCategory()));
|
|
|
1106 |
SimilarItemslist.put(sit.getCatalogItemId(), sItems);
|
|
|
1107 |
}
|
|
|
1108 |
}
|
| 3558 |
rajveer |
1109 |
|
| 4431 |
phani.kuma |
1110 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1111 |
ItemInventory warehousedata;
|
| 5309 |
rajveer |
1112 |
if(tItemInventory != null) {
|
|
|
1113 |
Map<Long, Long> availabilityMap = tItemInventory.getAvailability();
|
|
|
1114 |
Map<Long, Long> reservedMap = tItemInventory.getReserved();
|
| 8709 |
amar.kumar |
1115 |
Map<Long, Long> heldMap = tItemInventory.getHeld();
|
| 4431 |
phani.kuma |
1116 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
| 9640 |
amar.kumar |
1117 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
| 4431 |
phani.kuma |
1118 |
warehousedata = new ItemInventory();
|
|
|
1119 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1120 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1121 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
| 8709 |
amar.kumar |
1122 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
| 9640 |
amar.kumar |
1123 |
try {
|
|
|
1124 |
if(warehousedata.getHeld()>0) {
|
|
|
1125 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
1126 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(thriftItem.getId(), availability.getKey());
|
|
|
1127 |
}
|
|
|
1128 |
if(heldInventoryMap.size()>0) {
|
|
|
1129 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1130 |
switch(source) {
|
|
|
1131 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
| 9650 |
amar.kumar |
1132 |
break;
|
| 9640 |
amar.kumar |
1133 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
| 9650 |
amar.kumar |
1134 |
break;
|
| 9640 |
amar.kumar |
1135 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1136 |
}
|
|
|
1137 |
}
|
|
|
1138 |
}
|
|
|
1139 |
} catch (Exception e) {
|
|
|
1140 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + thriftItem.getId() +
|
|
|
1141 |
" and warehouse " +availability.getKey());
|
|
|
1142 |
}
|
| 4431 |
phani.kuma |
1143 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1144 |
}
|
|
|
1145 |
}
|
|
|
1146 |
else {
|
|
|
1147 |
itemInventoryMap = null;
|
|
|
1148 |
}
|
| 5504 |
phani.kuma |
1149 |
|
|
|
1150 |
Map<String, VoucherItemMapping> voucherMap = new HashMap<String, VoucherItemMapping>();
|
|
|
1151 |
VoucherItemMapping voucher;
|
|
|
1152 |
if(tVoucherMappings != null) {
|
|
|
1153 |
for(in.shop2020.model.v1.catalog.VoucherItemMapping tvoucher : tVoucherMappings) {
|
| 5516 |
phani.kuma |
1154 |
voucher = new VoucherItemMapping(tvoucher.getAmount(), VoucherType.findByValue((int) tvoucher.getVoucherType()).name());
|
|
|
1155 |
voucherMap.put(VoucherType.findByValue((int) tvoucher.getVoucherType()).name(), voucher);
|
| 5504 |
phani.kuma |
1156 |
}
|
|
|
1157 |
}
|
| 6813 |
amar.kumar |
1158 |
|
|
|
1159 |
in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams stockPurchaseParams =
|
|
|
1160 |
new in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams();
|
|
|
1161 |
if(tStockPurchaseParams != null) {
|
|
|
1162 |
stockPurchaseParams.setItem_id(tStockPurchaseParams.getItem_id());
|
|
|
1163 |
stockPurchaseParams.setMinStockLevel(tStockPurchaseParams.getMinStockLevel());
|
|
|
1164 |
stockPurchaseParams.setNumOfDaysStock(tStockPurchaseParams.getNumOfDaysStock());
|
|
|
1165 |
}
|
|
|
1166 |
|
| 3354 |
chandransh |
1167 |
Item item = new Item(thriftItem.getId(),
|
|
|
1168 |
thriftItem.getProductGroup(),
|
|
|
1169 |
thriftItem.getBrand(),
|
|
|
1170 |
thriftItem.getModelNumber(),
|
|
|
1171 |
thriftItem.getModelName(),
|
|
|
1172 |
thriftItem.getColor(),
|
|
|
1173 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
|
|
1174 |
thriftItem.getCategory(),
|
|
|
1175 |
thriftItem.getComments(),
|
|
|
1176 |
thriftItem.getCatalogItemId(),
|
|
|
1177 |
thriftItem.getFeatureId(),
|
|
|
1178 |
thriftItem.getFeatureDescription(),
|
|
|
1179 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
|
|
1180 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
|
|
1181 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
|
|
1182 |
thriftItem.getAddedOn(),
|
|
|
1183 |
thriftItem.getStartDate(),
|
| 5217 |
amit.gupta |
1184 |
thriftItem.isSetComingSoonStartDate() ? thriftItem.getComingSoonStartDate() : null ,
|
|
|
1185 |
thriftItem.isSetExpectedArrivalDate() ? thriftItem.getExpectedArrivalDate() : null ,
|
| 3354 |
chandransh |
1186 |
thriftItem.getRetireDate(),
|
|
|
1187 |
thriftItem.getUpdatedOn(),
|
|
|
1188 |
thriftItem.getItemStatus().name(),
|
|
|
1189 |
thriftItem.getItemStatus().getValue(),
|
|
|
1190 |
thriftItem.getStatus_description(),
|
|
|
1191 |
thriftItem.getBestDealText(),
|
| 6777 |
vikram.rag |
1192 |
thriftItem.getBestDealsDetailsText(),
|
|
|
1193 |
thriftItem.getBestDealsDetailsLink(),
|
| 3354 |
chandransh |
1194 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
|
|
1195 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
|
|
1196 |
thriftItem.isDefaultForEntity(),
|
|
|
1197 |
thriftItem.isRisky(),
|
| 3359 |
chandransh |
1198 |
thriftItem.isSetExpectedDelay() ? thriftItem.getExpectedDelay() : null,
|
| 4506 |
phani.kuma |
1199 |
thriftItem.isIsWarehousePreferenceSticky(),
|
| 5384 |
phani.kuma |
1200 |
thriftItem.isHasItemNo(),
|
|
|
1201 |
ItemType.SERIALIZED.equals(thriftItem.getType()),
|
| 6241 |
amit.gupta |
1202 |
thriftItem.isSetShowSellingPrice() ? thriftItem.isShowSellingPrice() : false,
|
| 9845 |
rajveer |
1203 |
thriftItem.isHoldOverride(),
|
| 4506 |
phani.kuma |
1204 |
thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
|
| 6838 |
vikram.rag |
1205 |
thriftItem.isSetPreferredInsurer() ? thriftItem.getPreferredInsurer() : null,
|
| 4431 |
phani.kuma |
1206 |
itemInventoryMap,
|
| 3354 |
chandransh |
1207 |
vendorPricingMap,
|
| 3558 |
rajveer |
1208 |
vItemMap,
|
| 4423 |
phani.kuma |
1209 |
sourcePricingMap,
|
| 5504 |
phani.kuma |
1210 |
SimilarItemslist,
|
| 7972 |
amar.kumar |
1211 |
voucherMap,
|
|
|
1212 |
stockPurchaseParams.getNumOfDaysStock(),
|
|
|
1213 |
stockPurchaseParams.getMinStockLevel(),
|
| 9835 |
rajveer |
1214 |
saleHistory,
|
| 7972 |
amar.kumar |
1215 |
freebieItemId,
|
| 7291 |
vikram.rag |
1216 |
thriftItem.getAsin(),
|
|
|
1217 |
thriftItem.getHoldInventory(),
|
|
|
1218 |
thriftItem.getDefaultInventory());
|
| 3354 |
chandransh |
1219 |
return item;
|
|
|
1220 |
}
|
|
|
1221 |
|
|
|
1222 |
/**
|
| 2489 |
ankur.sing |
1223 |
*
|
| 3922 |
chandransh |
1224 |
* @return True if push to production count is less than maximum allowed.
|
| 2489 |
ankur.sing |
1225 |
*/
|
| 3922 |
chandransh |
1226 |
private boolean canPushToProduction() {
|
|
|
1227 |
int count = getPushToProdCount(logFile);
|
|
|
1228 |
return count < maxCount;
|
| 2427 |
ankur.sing |
1229 |
}
|
| 3922 |
chandransh |
1230 |
|
| 2489 |
ankur.sing |
1231 |
/**
|
|
|
1232 |
* If this is the first attempt to push to production for current date, returns 0
|
|
|
1233 |
* else reads number of lines from daily rolling log file to get the count.
|
|
|
1234 |
* @return push to production count for current date
|
|
|
1235 |
*/
|
| 2498 |
ankur.sing |
1236 |
private int getPushToProdCount(String logfile) {
|
|
|
1237 |
// logfile is "/var/log/services/pushToProductionCount/pushToProd.log"
|
|
|
1238 |
// this should also be set in log4j.properties
|
| 2427 |
ankur.sing |
1239 |
int lineCount = 0;
|
| 2498 |
ankur.sing |
1240 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
| 2427 |
ankur.sing |
1241 |
Date currentDate = Calendar.getInstance().getTime();
|
|
|
1242 |
if(pushToProdDate == null || !dateFormat.format(pushToProdDate).equals(dateFormat.format(currentDate))) {
|
|
|
1243 |
pushToProdDate = currentDate;
|
|
|
1244 |
return lineCount;
|
|
|
1245 |
}
|
|
|
1246 |
try {
|
| 2498 |
ankur.sing |
1247 |
BufferedReader br = new BufferedReader(new FileReader(logfile));
|
| 2427 |
ankur.sing |
1248 |
while (br.readLine() != null) {
|
|
|
1249 |
lineCount++;
|
|
|
1250 |
}
|
|
|
1251 |
} catch (IOException e) {
|
| 3354 |
chandransh |
1252 |
logger.error("Error while reading the log file", e);
|
| 2427 |
ankur.sing |
1253 |
}
|
|
|
1254 |
return lineCount;
|
|
|
1255 |
}
|
| 4423 |
phani.kuma |
1256 |
|
|
|
1257 |
@Override
|
|
|
1258 |
public boolean deleteSimilarItem(long itemId, long catalogItemId) {
|
|
|
1259 |
try{
|
|
|
1260 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1261 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4423 |
phani.kuma |
1262 |
|
|
|
1263 |
return catalogClient.deleteSimilarItem(itemId, catalogItemId);
|
|
|
1264 |
|
|
|
1265 |
}catch(Exception e){
|
|
|
1266 |
logger.error("Error while deleting the SimilarItems for: " + itemId, e);
|
|
|
1267 |
}
|
|
|
1268 |
return false;
|
|
|
1269 |
}
|
|
|
1270 |
|
|
|
1271 |
@Override
|
|
|
1272 |
public Item addSimilarItem(long itemId, long catalogItemId) {
|
|
|
1273 |
try{
|
|
|
1274 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1275 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4423 |
phani.kuma |
1276 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
|
|
|
1277 |
|
| 9836 |
rajveer |
1278 |
return getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null);
|
| 4423 |
phani.kuma |
1279 |
}catch(Exception e){
|
|
|
1280 |
logger.error("Error while adding the SimilarItems for: " + itemId, e);
|
|
|
1281 |
}
|
|
|
1282 |
return null;
|
|
|
1283 |
}
|
| 4431 |
phani.kuma |
1284 |
|
|
|
1285 |
@Override
|
|
|
1286 |
public Map<Long, ItemInventory> getProdItemInventory(long itemId) {
|
|
|
1287 |
try {
|
|
|
1288 |
// Initialize client for production server
|
|
|
1289 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
1290 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| 5946 |
rajveer |
1291 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
|
|
1292 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
1293 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
1294 |
in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(itemId);
|
| 4431 |
phani.kuma |
1295 |
|
|
|
1296 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1297 |
ItemInventory warehousedata;
|
|
|
1298 |
if(thriftItemInventory != null) {
|
|
|
1299 |
Map<Long, Long> availabilityMap = thriftItemInventory.getAvailability();
|
|
|
1300 |
Map<Long, Long> reservedMap = thriftItemInventory.getReserved();
|
| 8708 |
amar.kumar |
1301 |
Map<Long, Long> heldMap = thriftItemInventory.getHeld();
|
| 4431 |
phani.kuma |
1302 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
| 9640 |
amar.kumar |
1303 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
| 4431 |
phani.kuma |
1304 |
warehousedata = new ItemInventory();
|
|
|
1305 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1306 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1307 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
| 8708 |
amar.kumar |
1308 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
| 9640 |
amar.kumar |
1309 |
try {
|
|
|
1310 |
if(warehousedata.getHeld()>0) {
|
|
|
1311 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(itemId, availability.getKey());
|
|
|
1312 |
}
|
|
|
1313 |
if(heldInventoryMap.size()>0) {
|
|
|
1314 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1315 |
switch(source) {
|
|
|
1316 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
| 9649 |
amar.kumar |
1317 |
break;
|
| 9640 |
amar.kumar |
1318 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
| 9649 |
amar.kumar |
1319 |
break;
|
| 9640 |
amar.kumar |
1320 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1321 |
}
|
|
|
1322 |
}
|
|
|
1323 |
}
|
|
|
1324 |
}catch (Exception e) {
|
|
|
1325 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + itemId +
|
|
|
1326 |
" and warehouse " +availability.getKey());
|
|
|
1327 |
}
|
| 4431 |
phani.kuma |
1328 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1329 |
}
|
|
|
1330 |
}
|
|
|
1331 |
else {
|
|
|
1332 |
itemInventoryMap = null;
|
|
|
1333 |
}
|
|
|
1334 |
return itemInventoryMap;
|
|
|
1335 |
} catch (Exception e) {
|
|
|
1336 |
logger.error("Error while updating item's risky flag on staging", e);
|
|
|
1337 |
}
|
|
|
1338 |
return null;
|
|
|
1339 |
}
|
| 4649 |
phani.kuma |
1340 |
|
|
|
1341 |
@Override
|
|
|
1342 |
public boolean addAuthorizationLog(long itemId, String username, String message) {
|
|
|
1343 |
try{
|
|
|
1344 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1345 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4649 |
phani.kuma |
1346 |
|
|
|
1347 |
return catalogClient.addAuthorizationLog(itemId, username, message);
|
|
|
1348 |
|
|
|
1349 |
}catch(Exception e){
|
|
|
1350 |
logger.error("Error while adding the event for: " + itemId, e);
|
|
|
1351 |
}
|
|
|
1352 |
return false;
|
|
|
1353 |
}
|
|
|
1354 |
|
|
|
1355 |
@Override
|
|
|
1356 |
public Map<String, String> getConfigdataforPriceCompare() {
|
|
|
1357 |
Map<String, String> ConfigMap = new HashMap<String, String>();
|
|
|
1358 |
try {
|
|
|
1359 |
ConfigMap.put("courier_cost_factor", ConfigClient.getClient().get(ConfigClientKeys.courier_cost_factor.toString()));
|
|
|
1360 |
ConfigMap.put("courier_weight_factor", ConfigClient.getClient().get(ConfigClientKeys.courier_weight_factor.toString()));
|
|
|
1361 |
ConfigMap.put("breakeven_divisor", ConfigClient.getClient().get(ConfigClientKeys.breakeven_divisor.toString()));
|
|
|
1362 |
ConfigMap.put("breakeven_additon_factor", ConfigClient.getClient().get(ConfigClientKeys.breakeven_additon_factor.toString()));
|
|
|
1363 |
ConfigMap.put("transfer_price_percentage", ConfigClient.getClient().get(ConfigClientKeys.transfer_price_percentage.toString()));
|
|
|
1364 |
ConfigMap.put("transfer_price_factor", ConfigClient.getClient().get(ConfigClientKeys.transfer_price_factor.toString()));
|
|
|
1365 |
} catch(ConfigException ce) {
|
|
|
1366 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
1367 |
ConfigMap.put("courier_cost_factor", "60");
|
|
|
1368 |
ConfigMap.put("courier_weight_factor", "500");
|
|
|
1369 |
ConfigMap.put("breakeven_divisor", "0.98");
|
|
|
1370 |
ConfigMap.put("breakeven_additon_factor", "50");
|
|
|
1371 |
ConfigMap.put("transfer_price_percentage", "2");
|
|
|
1372 |
ConfigMap.put("transfer_price_factor", "50");
|
|
|
1373 |
}
|
|
|
1374 |
return ConfigMap;
|
|
|
1375 |
}
|
| 4957 |
phani.kuma |
1376 |
|
|
|
1377 |
@Override
|
|
|
1378 |
public List<String> getAllCategories() {
|
|
|
1379 |
List<String> categoryList = new ArrayList<String>();
|
|
|
1380 |
List<Long> parentCategoryIDs = Arrays.asList(new Long[] {(long) 0,(long) 10001,(long) 10009,(long) 10049});
|
|
|
1381 |
try {
|
|
|
1382 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1383 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4957 |
phani.kuma |
1384 |
|
|
|
1385 |
List<in.shop2020.model.v1.catalog.Category> categories = catalogClient.getAllCategories();
|
|
|
1386 |
|
|
|
1387 |
for(in.shop2020.model.v1.catalog.Category category : categories) {
|
|
|
1388 |
if(!parentCategoryIDs.contains(category.getParent_category_id())){
|
|
|
1389 |
categoryList.add(category.getDisplay_name());
|
|
|
1390 |
}
|
|
|
1391 |
else{
|
|
|
1392 |
continue;
|
|
|
1393 |
}
|
|
|
1394 |
}
|
|
|
1395 |
} catch (Exception e) {
|
|
|
1396 |
logger.error("Error while getting all the categories: ", e);
|
|
|
1397 |
}
|
|
|
1398 |
return categoryList;
|
|
|
1399 |
}
|
|
|
1400 |
|
|
|
1401 |
@Override
|
|
|
1402 |
public List<String> getAllBrands() {
|
|
|
1403 |
List<String> brandsList = new ArrayList<String>();
|
|
|
1404 |
try {
|
|
|
1405 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1406 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4957 |
phani.kuma |
1407 |
|
|
|
1408 |
brandsList = catalogClient.getAllBrands();
|
|
|
1409 |
} catch (Exception e) {
|
|
|
1410 |
logger.error("Error while getting all the categories: ", e);
|
|
|
1411 |
}
|
|
|
1412 |
return brandsList;
|
|
|
1413 |
}
|
| 5427 |
amit.gupta |
1414 |
|
| 5504 |
phani.kuma |
1415 |
@Override
|
| 5516 |
phani.kuma |
1416 |
public boolean deleteVoucher(Long catalogItemId, Long voucherType) {
|
| 5504 |
phani.kuma |
1417 |
try{
|
|
|
1418 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1419 |
Client catalogClient = catalogServiceClient.getClient();
|
| 5504 |
phani.kuma |
1420 |
|
|
|
1421 |
return catalogClient.deleteVoucherForItem(catalogItemId, voucherType);
|
|
|
1422 |
|
|
|
1423 |
}catch(Exception e){
|
|
|
1424 |
logger.error("Error while deleting the Voucher for: " + catalogItemId, e);
|
|
|
1425 |
}
|
|
|
1426 |
return false;
|
|
|
1427 |
}
|
|
|
1428 |
|
|
|
1429 |
@Override
|
| 5516 |
phani.kuma |
1430 |
public boolean addVoucher(Long catalogItemId, Long voucherType, long voucherAmount) {
|
| 5504 |
phani.kuma |
1431 |
try{
|
|
|
1432 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 5946 |
rajveer |
1433 |
Client catalogClient = catalogServiceClient.getClient();
|
| 5504 |
phani.kuma |
1434 |
|
|
|
1435 |
return catalogClient.addupdateVoucherForItem(catalogItemId, voucherType, voucherAmount);
|
|
|
1436 |
|
|
|
1437 |
}catch(Exception e){
|
|
|
1438 |
logger.error("Error while adding the Voucher for: " + catalogItemId, e);
|
|
|
1439 |
}
|
|
|
1440 |
return false;
|
|
|
1441 |
}
|
|
|
1442 |
@Override
|
| 5516 |
phani.kuma |
1443 |
public Map<Long, String> getvoucherTypes() {
|
|
|
1444 |
Map<Long, String> voucherType = new HashMap<Long, String>();
|
| 5504 |
phani.kuma |
1445 |
for(VoucherType voucher : VoucherType.values())
|
|
|
1446 |
{
|
| 5516 |
phani.kuma |
1447 |
voucherType.put((long) voucher.getValue(), voucher.name());
|
| 5504 |
phani.kuma |
1448 |
}
|
|
|
1449 |
return voucherType;
|
|
|
1450 |
}
|
|
|
1451 |
|
| 5586 |
phani.kuma |
1452 |
@Override
|
|
|
1453 |
public boolean getConfigforentityIdMandatory() {
|
|
|
1454 |
try {
|
|
|
1455 |
String entityId_mandatory = ConfigClient.getClient().get(ConfigClientKeys.entityId_mandatory.toString());
|
|
|
1456 |
if (entityId_mandatory.equals("TRUE")) {
|
|
|
1457 |
return true;
|
|
|
1458 |
}
|
|
|
1459 |
} catch(ConfigException ce) {
|
|
|
1460 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
1461 |
}
|
|
|
1462 |
return false;
|
|
|
1463 |
}
|
|
|
1464 |
|
|
|
1465 |
@Override
|
|
|
1466 |
public boolean checkEntityId(long entityId) {
|
|
|
1467 |
try {
|
|
|
1468 |
CatalogClient catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_master.toString(), ConfigClientKeys.catalog_service_server_port.toString());
|
| 5946 |
rajveer |
1469 |
Client catalogClient = catalogServiceClient.getClient();
|
| 5586 |
phani.kuma |
1470 |
return catalogClient.isValidCatalogItemId(entityId);
|
|
|
1471 |
} catch (Exception e) {
|
|
|
1472 |
logger.error("Error while checking for a Catalog Item Id: ", e);
|
|
|
1473 |
}
|
|
|
1474 |
return false;
|
|
|
1475 |
}
|
|
|
1476 |
|
| 6096 |
amit.gupta |
1477 |
@Override
|
|
|
1478 |
public String updateExpectedDelayOnProd(Item item) {
|
|
|
1479 |
try{
|
|
|
1480 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(
|
|
|
1481 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
1482 |
ConfigClientKeys.catalog_service_server_port.toString());
|
|
|
1483 |
|
|
|
1484 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
|
|
1485 |
|
|
|
1486 |
|
|
|
1487 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
|
|
|
1488 |
if(item.getExpectedDelay() != null) {
|
|
|
1489 |
tItem.setExpectedDelay(item.getExpectedDelay());
|
| 7182 |
amit.gupta |
1490 |
if(item.isItemType()) {
|
|
|
1491 |
tItem.setType(ItemType.SERIALIZED);
|
|
|
1492 |
}
|
|
|
1493 |
else {
|
|
|
1494 |
tItem.setType(ItemType.NON_SERIALIZED);
|
|
|
1495 |
}
|
| 6096 |
amit.gupta |
1496 |
long rItemId;
|
|
|
1497 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != item.getId()) {
|
|
|
1498 |
logger.error("Error updating item on production, returned Item Id: " + rItemId);
|
|
|
1499 |
return "Error updating expected delay on production";
|
|
|
1500 |
}
|
| 6241 |
amit.gupta |
1501 |
InventoryClient inventoryServiceClient= new InventoryClient();
|
|
|
1502 |
InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 6096 |
amit.gupta |
1503 |
inventoryClient.clearItemAvailabilityCacheForItem(rItemId);
|
|
|
1504 |
logger.info("Successfully updated item: " + item.getId());
|
|
|
1505 |
return "Expected delay successfully updated on prod";
|
|
|
1506 |
} else {
|
|
|
1507 |
return "Error:expected delay should not be null";
|
|
|
1508 |
}
|
|
|
1509 |
} catch (Exception e) {
|
| 6098 |
amit.gupta |
1510 |
logger.error("Error while updating expected delay on production", e);
|
|
|
1511 |
return "Error while updating expected delay on production";
|
| 6096 |
amit.gupta |
1512 |
}
|
|
|
1513 |
}
|
|
|
1514 |
|
| 6838 |
vikram.rag |
1515 |
@Override
|
|
|
1516 |
public Map<Long, String> getAllInsurers() {
|
|
|
1517 |
Map<Long, String> insurersMap = new HashMap<Long, String>();
|
|
|
1518 |
try {
|
|
|
1519 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1520 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
|
|
1521 |
|
|
|
1522 |
List<Insurer> insurers = catalogClient.getAllInsurers();
|
| 6096 |
amit.gupta |
1523 |
|
| 6838 |
vikram.rag |
1524 |
for(in.shop2020.model.v1.catalog.Insurer i : insurers) {
|
|
|
1525 |
insurersMap.put(i.getId(), i.getName());
|
|
|
1526 |
}
|
|
|
1527 |
} catch (Exception e) {
|
|
|
1528 |
logger.error("Error while getting all the vendors: ", e);
|
|
|
1529 |
}
|
|
|
1530 |
return insurersMap;
|
|
|
1531 |
}
|
| 10484 |
vikram.rag |
1532 |
|
|
|
1533 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
|
|
1534 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> tVendorPricings,
|
|
|
1535 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
|
|
|
1536 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
|
|
|
1537 |
List<in.shop2020.model.v1.catalog.Item> tSimilarItems,
|
|
|
1538 |
in.shop2020.model.v1.inventory.ItemInventory tItemInventory,
|
|
|
1539 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings,
|
|
|
1540 |
ItemStockPurchaseParams tStockPurchaseParams, Map<Long,String> saleHistory, Long freebieItemId,Map<String,String> stateNameVatPercentageMap){
|
| 6838 |
vikram.rag |
1541 |
|
| 10484 |
vikram.rag |
1542 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
|
|
1543 |
VendorItemMapping vItemMapping;
|
|
|
1544 |
if(tVendorMappings != null) {
|
|
|
1545 |
for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
|
|
|
1546 |
vItemMapping = new VendorItemMapping();
|
|
|
1547 |
vItemMapping.setVendorId(vim.getVendorId());
|
|
|
1548 |
vItemMapping.setItemKey(vim.getItemKey());
|
|
|
1549 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
|
|
1550 |
}
|
|
|
1551 |
}
|
| 6838 |
vikram.rag |
1552 |
|
| 10484 |
vikram.rag |
1553 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
|
|
1554 |
VendorPricings vPricings;
|
|
|
1555 |
if(tVendorPricings != null) {
|
|
|
1556 |
for(in.shop2020.model.v1.inventory.VendorItemPricing vip : tVendorPricings) {
|
|
|
1557 |
vPricings = new VendorPricings();
|
|
|
1558 |
vPricings.setVendorId(vip.getVendorId());
|
|
|
1559 |
vPricings.setMop(vip.getMop());
|
|
|
1560 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
|
|
1561 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
|
|
1562 |
vPricings.setNlc(vip.getNlc());
|
|
|
1563 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
|
|
1564 |
}
|
|
|
1565 |
}
|
| 6096 |
amit.gupta |
1566 |
|
| 10484 |
vikram.rag |
1567 |
Map<Long, SourcePricings> sourcePricingMap = new HashMap<Long, SourcePricings>();
|
|
|
1568 |
SourcePricings sPricings;
|
|
|
1569 |
if(tSourceMappings != null) {
|
|
|
1570 |
for(in.shop2020.model.v1.catalog.SourceItemPricing sip : tSourceMappings) {
|
|
|
1571 |
sPricings = new SourcePricings();
|
|
|
1572 |
sPricings.setSourceId(sip.getSourceId());
|
|
|
1573 |
sPricings.setMrp(sip.getMrp());
|
|
|
1574 |
sPricings.setSellingPrice(sip.getSellingPrice());
|
|
|
1575 |
sourcePricingMap.put(sPricings.getSourceId(), sPricings);
|
|
|
1576 |
}
|
|
|
1577 |
}
|
|
|
1578 |
|
|
|
1579 |
Map<Long, Item> SimilarItemslist = new HashMap<Long, Item>();
|
|
|
1580 |
Item sItems;
|
|
|
1581 |
if(tSimilarItems != null) {
|
|
|
1582 |
for(in.shop2020.model.v1.catalog.Item sit : tSimilarItems) {
|
|
|
1583 |
sItems = new Item();
|
|
|
1584 |
sItems.setCatalogItemId(sit.getCatalogItemId());
|
|
|
1585 |
sItems.setProductGroup(sit.getProductGroup());
|
|
|
1586 |
sItems.setBrand(sit.getBrand());
|
|
|
1587 |
sItems.setModelNumber(sit.getModelNumber());
|
|
|
1588 |
sItems.setModelName(sit.getModelName());
|
|
|
1589 |
sItems.setContentCategory(CategoryManager.getCategoryManager().getCategoryLabel(sit.getCategory()));
|
|
|
1590 |
SimilarItemslist.put(sit.getCatalogItemId(), sItems);
|
|
|
1591 |
}
|
|
|
1592 |
}
|
|
|
1593 |
|
|
|
1594 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1595 |
ItemInventory warehousedata;
|
|
|
1596 |
if(tItemInventory != null) {
|
|
|
1597 |
Map<Long, Long> availabilityMap = tItemInventory.getAvailability();
|
|
|
1598 |
Map<Long, Long> reservedMap = tItemInventory.getReserved();
|
|
|
1599 |
Map<Long, Long> heldMap = tItemInventory.getHeld();
|
|
|
1600 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
|
|
1601 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
|
|
1602 |
warehousedata = new ItemInventory();
|
|
|
1603 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1604 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1605 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
|
|
1606 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
|
|
1607 |
try {
|
|
|
1608 |
if(warehousedata.getHeld()>0) {
|
|
|
1609 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
1610 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(thriftItem.getId(), availability.getKey());
|
|
|
1611 |
}
|
|
|
1612 |
if(heldInventoryMap.size()>0) {
|
|
|
1613 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1614 |
switch(source) {
|
|
|
1615 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
|
|
1616 |
break;
|
|
|
1617 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
|
|
1618 |
break;
|
|
|
1619 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1620 |
}
|
|
|
1621 |
}
|
|
|
1622 |
}
|
|
|
1623 |
} catch (Exception e) {
|
|
|
1624 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + thriftItem.getId() +
|
|
|
1625 |
" and warehouse " +availability.getKey());
|
|
|
1626 |
}
|
|
|
1627 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1628 |
}
|
|
|
1629 |
}
|
|
|
1630 |
else {
|
|
|
1631 |
itemInventoryMap = null;
|
|
|
1632 |
}
|
|
|
1633 |
|
|
|
1634 |
Map<String, VoucherItemMapping> voucherMap = new HashMap<String, VoucherItemMapping>();
|
|
|
1635 |
VoucherItemMapping voucher;
|
|
|
1636 |
if(tVoucherMappings != null) {
|
|
|
1637 |
for(in.shop2020.model.v1.catalog.VoucherItemMapping tvoucher : tVoucherMappings) {
|
|
|
1638 |
voucher = new VoucherItemMapping(tvoucher.getAmount(), VoucherType.findByValue((int) tvoucher.getVoucherType()).name());
|
|
|
1639 |
voucherMap.put(VoucherType.findByValue((int) tvoucher.getVoucherType()).name(), voucher);
|
|
|
1640 |
}
|
|
|
1641 |
}
|
|
|
1642 |
|
|
|
1643 |
in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams stockPurchaseParams =
|
|
|
1644 |
new in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams();
|
|
|
1645 |
if(tStockPurchaseParams != null) {
|
|
|
1646 |
stockPurchaseParams.setItem_id(tStockPurchaseParams.getItem_id());
|
|
|
1647 |
stockPurchaseParams.setMinStockLevel(tStockPurchaseParams.getMinStockLevel());
|
|
|
1648 |
stockPurchaseParams.setNumOfDaysStock(tStockPurchaseParams.getNumOfDaysStock());
|
|
|
1649 |
}
|
|
|
1650 |
|
|
|
1651 |
Item item = new Item(thriftItem.getId(),
|
|
|
1652 |
thriftItem.getProductGroup(),
|
|
|
1653 |
thriftItem.getBrand(),
|
|
|
1654 |
thriftItem.getModelNumber(),
|
|
|
1655 |
thriftItem.getModelName(),
|
|
|
1656 |
thriftItem.getColor(),
|
|
|
1657 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
|
|
1658 |
thriftItem.getCategory(),
|
|
|
1659 |
thriftItem.getComments(),
|
|
|
1660 |
thriftItem.getCatalogItemId(),
|
|
|
1661 |
thriftItem.getFeatureId(),
|
|
|
1662 |
thriftItem.getFeatureDescription(),
|
|
|
1663 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
|
|
1664 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
|
|
1665 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
|
|
1666 |
thriftItem.getAddedOn(),
|
|
|
1667 |
thriftItem.getStartDate(),
|
|
|
1668 |
thriftItem.isSetComingSoonStartDate() ? thriftItem.getComingSoonStartDate() : null ,
|
|
|
1669 |
thriftItem.isSetExpectedArrivalDate() ? thriftItem.getExpectedArrivalDate() : null ,
|
|
|
1670 |
thriftItem.getRetireDate(),
|
|
|
1671 |
thriftItem.getUpdatedOn(),
|
|
|
1672 |
thriftItem.getItemStatus().name(),
|
|
|
1673 |
thriftItem.getItemStatus().getValue(),
|
|
|
1674 |
thriftItem.getStatus_description(),
|
|
|
1675 |
thriftItem.getBestDealText(),
|
|
|
1676 |
thriftItem.getBestDealsDetailsText(),
|
|
|
1677 |
thriftItem.getBestDealsDetailsLink(),
|
|
|
1678 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
|
|
1679 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
|
|
1680 |
thriftItem.isDefaultForEntity(),
|
|
|
1681 |
thriftItem.isRisky(),
|
|
|
1682 |
thriftItem.isSetExpectedDelay() ? thriftItem.getExpectedDelay() : null,
|
|
|
1683 |
thriftItem.isIsWarehousePreferenceSticky(),
|
|
|
1684 |
thriftItem.isHasItemNo(),
|
|
|
1685 |
ItemType.SERIALIZED.equals(thriftItem.getType()),
|
|
|
1686 |
thriftItem.isSetShowSellingPrice() ? thriftItem.isShowSellingPrice() : false,
|
|
|
1687 |
thriftItem.isHoldOverride(),
|
|
|
1688 |
thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
|
|
|
1689 |
thriftItem.isSetPreferredInsurer() ? thriftItem.getPreferredInsurer() : null,
|
|
|
1690 |
itemInventoryMap,
|
|
|
1691 |
vendorPricingMap,
|
|
|
1692 |
vItemMap,
|
|
|
1693 |
sourcePricingMap,
|
|
|
1694 |
SimilarItemslist,
|
|
|
1695 |
voucherMap,
|
|
|
1696 |
stockPurchaseParams.getNumOfDaysStock(),
|
|
|
1697 |
stockPurchaseParams.getMinStockLevel(),
|
|
|
1698 |
saleHistory,
|
|
|
1699 |
freebieItemId,
|
|
|
1700 |
thriftItem.getAsin(),
|
|
|
1701 |
thriftItem.getHoldInventory(),
|
|
|
1702 |
thriftItem.getDefaultInventory(),stateNameVatPercentageMap);
|
|
|
1703 |
return item;
|
|
|
1704 |
}
|
| 6530 |
vikram.rag |
1705 |
}
|