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