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