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