| 7283 |
kshitij.so |
1 |
package in.shop2020.support.controllers;
|
|
|
2 |
|
| 7524 |
kshitij.so |
3 |
import java.io.File;
|
| 7741 |
kshitij.so |
4 |
import java.io.FileInputStream;
|
| 7524 |
kshitij.so |
5 |
import java.io.IOException;
|
| 7365 |
kshitij.so |
6 |
import java.util.HashMap;
|
| 7283 |
kshitij.so |
7 |
import java.util.List;
|
|
|
8 |
import java.util.Map;
|
|
|
9 |
|
| 7591 |
kshitij.so |
10 |
import javax.servlet.ServletContext;
|
| 7283 |
kshitij.so |
11 |
import javax.servlet.ServletRequest;
|
|
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 8168 |
kshitij.so |
13 |
import javax.servlet.http.HttpServletResponse;
|
| 7591 |
kshitij.so |
14 |
import javax.servlet.http.HttpSession;
|
| 7283 |
kshitij.so |
15 |
|
|
|
16 |
import in.shop2020.model.v1.catalog.Amazonlisted;
|
|
|
17 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
|
|
18 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
19 |
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
|
|
|
20 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
|
|
21 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 7741 |
kshitij.so |
22 |
import in.shop2020.model.v1.order.AmazonOrder;
|
| 7591 |
kshitij.so |
23 |
import in.shop2020.support.utils.ReportsUtils;
|
| 7283 |
kshitij.so |
24 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
25 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 7365 |
kshitij.so |
26 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 7741 |
kshitij.so |
27 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 7365 |
kshitij.so |
28 |
import in.shop2020.logistics.DeliveryType;
|
|
|
29 |
import in.shop2020.logistics.LogisticsInfo;
|
|
|
30 |
import in.shop2020.logistics.LogisticsServiceException;
|
|
|
31 |
import in.shop2020.logistics.PickUpType;
|
| 7283 |
kshitij.so |
32 |
|
| 7524 |
kshitij.so |
33 |
import org.apache.commons.io.FileUtils;
|
| 7365 |
kshitij.so |
34 |
import org.apache.commons.lang.xwork.StringUtils;
|
| 7741 |
kshitij.so |
35 |
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
36 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| 8168 |
kshitij.so |
37 |
import org.apache.poi.ss.usermodel.Cell;
|
| 7591 |
kshitij.so |
38 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
39 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 7283 |
kshitij.so |
40 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
41 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
42 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 8168 |
kshitij.so |
43 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
|
|
44 |
import org.apache.struts2.util.ServletContextAware;
|
| 7283 |
kshitij.so |
45 |
import org.apache.thrift.TException;
|
| 7741 |
kshitij.so |
46 |
import org.apache.thrift.transport.TTransportException;
|
| 7283 |
kshitij.so |
47 |
import org.slf4j.Logger;
|
|
|
48 |
import org.slf4j.LoggerFactory;
|
|
|
49 |
|
|
|
50 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
|
|
51 |
|
|
|
52 |
@SuppressWarnings("serial")
|
| 7591 |
kshitij.so |
53 |
@InterceptorRefs({
|
|
|
54 |
@InterceptorRef("defaultStack"),
|
|
|
55 |
@InterceptorRef("login")
|
|
|
56 |
})
|
| 7283 |
kshitij.so |
57 |
@Results({
|
| 7524 |
kshitij.so |
58 |
@Result(name = "redirect", location = "${url}", type = "redirect"),
|
|
|
59 |
@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
|
|
|
60 |
})
|
| 8168 |
kshitij.so |
61 |
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
|
| 7283 |
kshitij.so |
62 |
|
|
|
63 |
private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
|
|
|
64 |
|
| 7591 |
kshitij.so |
65 |
private HttpServletRequest request;
|
|
|
66 |
private HttpSession session;
|
|
|
67 |
private ServletContext context;
|
| 7283 |
kshitij.so |
68 |
private String url;
|
|
|
69 |
private String id;
|
|
|
70 |
private String itemId;
|
|
|
71 |
private String isFba;
|
|
|
72 |
private String isNonFba;
|
|
|
73 |
private String isInventoryOverride;
|
|
|
74 |
private String fbaPrice;
|
|
|
75 |
private String sellingPrice;
|
|
|
76 |
private String saholicPrice;
|
| 7365 |
kshitij.so |
77 |
private String isTime;
|
|
|
78 |
private String handlingTime;
|
|
|
79 |
private String customHandlingTime;
|
| 7461 |
kshitij.so |
80 |
private String holdInventory;
|
|
|
81 |
private String defaultInventory;
|
| 7524 |
kshitij.so |
82 |
private String fileUploadFileName;
|
|
|
83 |
private String fileUploadContentType;
|
| 8168 |
kshitij.so |
84 |
private String suppressMfnPriceUpdate;
|
|
|
85 |
private String suppressFbaPriceUpdate;
|
| 7524 |
kshitij.so |
86 |
private File file;
|
| 7283 |
kshitij.so |
87 |
|
|
|
88 |
public String index() {
|
| 7591 |
kshitij.so |
89 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
|
|
|
90 |
return "authfail";
|
|
|
91 |
}
|
| 7283 |
kshitij.so |
92 |
return "index";
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public List<Amazonlisted> fetchItems() throws TException {
|
| 7408 |
kshitij.so |
96 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 7283 |
kshitij.so |
97 |
return CatalogClient.getAllAmazonListedItems();
|
|
|
98 |
}
|
|
|
99 |
|
| 7408 |
kshitij.so |
100 |
public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
|
|
|
101 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 7283 |
kshitij.so |
102 |
return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
|
|
|
103 |
}
|
|
|
104 |
|
| 7408 |
kshitij.so |
105 |
public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
|
|
|
106 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 7283 |
kshitij.so |
107 |
return CatalogClient.getItem(Long.valueOf(id));
|
|
|
108 |
}
|
| 7365 |
kshitij.so |
109 |
|
|
|
110 |
|
|
|
111 |
|
| 7283 |
kshitij.so |
112 |
public String update() throws NumberFormatException, TException{
|
| 7408 |
kshitij.so |
113 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 8168 |
kshitij.so |
114 |
boolean flag=false;
|
|
|
115 |
boolean commit=false;
|
|
|
116 |
long delay = Long.valueOf(customHandlingTime);
|
|
|
117 |
if ( Boolean.valueOf(isTime)) {
|
|
|
118 |
flag = true;
|
|
|
119 |
}
|
|
|
120 |
changeItemInventory();
|
|
|
121 |
Amazonlisted amazonlisted = CatalogClient.getAmazonItemDetails(Long.valueOf(itemId));
|
|
|
122 |
if (amazonlisted.getSellingPrice()!=Double.valueOf(sellingPrice)){
|
|
|
123 |
amazonlisted.setSellingPrice(Double.valueOf(sellingPrice));
|
|
|
124 |
commit=true;
|
|
|
125 |
}
|
|
|
126 |
if (amazonlisted.getFbaPrice()!=Double.valueOf(fbaPrice)){
|
|
|
127 |
amazonlisted.setFbaPrice(Double.valueOf(fbaPrice));
|
|
|
128 |
commit=true;
|
|
|
129 |
}
|
|
|
130 |
if (amazonlisted.isIsFba()!=Boolean.valueOf(isFba)){
|
|
|
131 |
amazonlisted.setIsFba(Boolean.valueOf(isFba));
|
|
|
132 |
commit=true;
|
|
|
133 |
}
|
|
|
134 |
if (amazonlisted.isIsNonFba()!=Boolean.valueOf(isNonFba)){
|
|
|
135 |
amazonlisted.setIsNonFba(Boolean.valueOf(isNonFba));
|
|
|
136 |
commit=true;
|
|
|
137 |
}
|
|
|
138 |
if (amazonlisted.isIsCustomTime()!=flag){
|
|
|
139 |
amazonlisted.setIsCustomTime(flag);
|
|
|
140 |
commit=true;
|
|
|
141 |
}
|
|
|
142 |
if (amazonlisted.getHandlingTime()!=delay){
|
|
|
143 |
amazonlisted.setHandlingTime(delay);
|
|
|
144 |
commit=true;
|
|
|
145 |
}
|
|
|
146 |
if(amazonlisted.isIsInventoryOverride()!=Boolean.valueOf(isInventoryOverride)){
|
|
|
147 |
amazonlisted.setIsInventoryOverride(Boolean.valueOf(isInventoryOverride));
|
|
|
148 |
commit=true;
|
|
|
149 |
}
|
|
|
150 |
if(amazonlisted.isSuppressMfnPriceUpdate()!=Boolean.valueOf(suppressMfnPriceUpdate)){
|
|
|
151 |
amazonlisted.setSuppressMfnPriceUpdate(Boolean.valueOf(suppressMfnPriceUpdate));
|
|
|
152 |
commit=true;
|
|
|
153 |
}
|
|
|
154 |
if(amazonlisted.isSuppressFbaPriceUpdate()!=Boolean.valueOf(suppressFbaPriceUpdate)){
|
|
|
155 |
amazonlisted.setSuppressFbaPriceUpdate(Boolean.valueOf(suppressFbaPriceUpdate));
|
|
|
156 |
commit=true;
|
|
|
157 |
}
|
|
|
158 |
if(commit){
|
|
|
159 |
CatalogClient.updateAmazonItemDetails(amazonlisted);
|
|
|
160 |
}
|
|
|
161 |
else{
|
|
|
162 |
logger.info("Nothing new to commit");
|
|
|
163 |
}
|
| 7591 |
kshitij.so |
164 |
//setUrl("/amazon-list/");
|
|
|
165 |
return "index";
|
| 7283 |
kshitij.so |
166 |
|
|
|
167 |
}
|
|
|
168 |
|
| 8168 |
kshitij.so |
169 |
public void upload() throws IOException, TException {
|
| 7524 |
kshitij.so |
170 |
File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
|
|
|
171 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 7741 |
kshitij.so |
172 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
|
|
173 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
|
|
174 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 7762 |
kshitij.so |
175 |
Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
|
| 7741 |
kshitij.so |
176 |
for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
|
|
|
177 |
TransactionClient tcl = new TransactionClient();
|
|
|
178 |
List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
|
|
|
179 |
for (AmazonOrder order : orders){
|
| 7753 |
kshitij.so |
180 |
if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
|
| 7762 |
kshitij.so |
181 |
Map<String,String> dateMap = new HashMap<String,String>();
|
|
|
182 |
dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
|
|
|
183 |
amazonOrderMap.put(order.getOrderId(), dateMap);
|
| 7741 |
kshitij.so |
184 |
}
|
|
|
185 |
}
|
|
|
186 |
}
|
|
|
187 |
TransactionClient tcl = new TransactionClient();
|
|
|
188 |
tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
|
| 7524 |
kshitij.so |
189 |
}
|
|
|
190 |
|
| 7461 |
kshitij.so |
191 |
private void changeItemInventory() throws NumberFormatException, TException {
|
|
|
192 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 7524 |
kshitij.so |
193 |
|
| 7461 |
kshitij.so |
194 |
if (StringUtils.isEmpty(holdInventory)) {
|
|
|
195 |
holdInventory = "0";
|
|
|
196 |
}
|
|
|
197 |
if (StringUtils.isEmpty(defaultInventory)) {
|
|
|
198 |
defaultInventory = "0";
|
|
|
199 |
}
|
| 7524 |
kshitij.so |
200 |
|
| 7461 |
kshitij.so |
201 |
CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
|
| 7283 |
kshitij.so |
205 |
public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
|
|
|
206 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
207 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
208 |
in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
|
|
|
209 |
return thriftItemInventory.getAvailability();
|
|
|
210 |
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
public Map<Long, Long> getReservedItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
|
|
|
214 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
215 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
216 |
in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
|
|
|
217 |
return thriftItemInventory.getReserved();
|
|
|
218 |
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
public String getWarehouseName(String warehouseId) throws NumberFormatException, TException {
|
|
|
222 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
223 |
return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
|
|
|
227 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 7365 |
kshitij.so |
228 |
try {
|
|
|
229 |
return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
|
|
|
230 |
}
|
|
|
231 |
catch (Exception e){
|
|
|
232 |
return null;
|
|
|
233 |
}
|
| 7283 |
kshitij.so |
234 |
}
|
|
|
235 |
|
| 7365 |
kshitij.so |
236 |
public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
|
|
|
237 |
LogisticsClient logisticsClient = new LogisticsClient();
|
|
|
238 |
return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
|
|
|
239 |
|
|
|
240 |
}
|
|
|
241 |
|
| 7762 |
kshitij.so |
242 |
public Map<Long, Item> getAliveItemMap() throws TTransportException, InterruptedException{
|
| 7753 |
kshitij.so |
243 |
List<Item> itemList = null;
|
|
|
244 |
int retry=0;
|
|
|
245 |
while(true){
|
| 7762 |
kshitij.so |
246 |
try {
|
|
|
247 |
if (retry==3)
|
|
|
248 |
break;
|
|
|
249 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
|
|
250 |
itemList = CatalogClient.getAllAliveItems();
|
| 7753 |
kshitij.so |
251 |
break;
|
| 7762 |
kshitij.so |
252 |
} catch ( NullPointerException e) {
|
|
|
253 |
retry++;
|
|
|
254 |
System.out.println("Unable to fetch alive items.Retrying");
|
|
|
255 |
Thread.sleep(3000);
|
|
|
256 |
e.printStackTrace();
|
|
|
257 |
} catch (TException e) {
|
|
|
258 |
retry++;
|
|
|
259 |
System.out.println("Unable to fetch alive items.Retrying");
|
|
|
260 |
Thread.sleep(3000);
|
|
|
261 |
e.printStackTrace();
|
|
|
262 |
}
|
| 7753 |
kshitij.so |
263 |
}
|
| 7603 |
kshitij.so |
264 |
Map<Long, Item> itemMap = new HashMap<Long, Item>();
|
| 7365 |
kshitij.so |
265 |
for (Item o : itemList) {
|
| 7603 |
kshitij.so |
266 |
itemMap.put((Long) o.getId(), o);
|
| 7365 |
kshitij.so |
267 |
}
|
|
|
268 |
return itemMap;
|
|
|
269 |
}
|
|
|
270 |
|
| 8168 |
kshitij.so |
271 |
public String runAsinJob() throws IOException, InterruptedException {
|
|
|
272 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
|
|
273 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
|
|
274 |
return "authfail";
|
|
|
275 |
}
|
|
|
276 |
ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
|
|
|
277 |
String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/Test.sh"};
|
|
|
278 |
testProcess.command(command);
|
|
|
279 |
logger.info(testProcess.command().toString());
|
|
|
280 |
Process process = testProcess.start();
|
|
|
281 |
process.waitFor();
|
|
|
282 |
logger.info(String.valueOf(process.exitValue()));
|
|
|
283 |
return "asinjob";
|
| 8070 |
kshitij.so |
284 |
|
| 8168 |
kshitij.so |
285 |
}
|
| 8073 |
kshitij.so |
286 |
|
| 8168 |
kshitij.so |
287 |
public void uploadBulkFile() throws IOException, TException{
|
|
|
288 |
File fileToCreate = new File("/tmp/", "Amazon-bulk-upload.xls");
|
|
|
289 |
FileUtils.copyFile(this.file, fileToCreate);
|
|
|
290 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
|
|
291 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
|
|
292 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
293 |
Map<Long,Amazonlisted> amazonBulkUpdate = new HashMap<Long,Amazonlisted>();
|
|
|
294 |
Client CatalogClient=null;
|
|
|
295 |
try {
|
|
|
296 |
CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
|
|
297 |
} catch (TTransportException e) {
|
|
|
298 |
// TODO Auto-generated catch block
|
|
|
299 |
e.printStackTrace();
|
|
|
300 |
}
|
|
|
301 |
for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
|
|
|
302 |
Amazonlisted amazonlisted =null;
|
|
|
303 |
Long sku;
|
|
|
304 |
if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
|
|
|
305 |
continue;
|
|
|
306 |
}
|
|
|
307 |
else {
|
|
|
308 |
sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
|
|
309 |
amazonlisted = CatalogClient.getAmazonItemDetails(sku);
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
|
|
|
313 |
double mfnPrice = sheet.getRow(iterator).getCell(1).getNumericCellValue();
|
|
|
314 |
amazonlisted.setSellingPrice(mfnPrice);
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
|
|
|
318 |
double fbaSellingPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
|
|
|
319 |
amazonlisted.setFbaPrice(fbaSellingPrice);
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
|
|
|
323 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==1){
|
|
|
324 |
amazonlisted.setIsNonFba(true);
|
|
|
325 |
}
|
|
|
326 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
|
|
|
327 |
amazonlisted.setIsNonFba(false);
|
|
|
328 |
}
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
|
|
|
332 |
if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==1){
|
|
|
333 |
amazonlisted.setIsFba(true);
|
|
|
334 |
}
|
|
|
335 |
if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==0){
|
|
|
336 |
amazonlisted.setIsFba(false);
|
|
|
337 |
}
|
|
|
338 |
}
|
|
|
339 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
|
|
|
340 |
if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
|
|
|
341 |
amazonlisted.setIsInventoryOverride(true);
|
|
|
342 |
}
|
|
|
343 |
if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
|
|
|
344 |
amazonlisted.setIsInventoryOverride(false);
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
|
|
|
348 |
if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
|
|
|
349 |
amazonlisted.setSuppressMfnPriceUpdate(true);
|
|
|
350 |
}
|
|
|
351 |
if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
|
|
|
352 |
amazonlisted.setSuppressMfnPriceUpdate(false);
|
|
|
353 |
}
|
|
|
354 |
}
|
|
|
355 |
|
|
|
356 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
|
|
|
357 |
if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
|
|
|
358 |
amazonlisted.setSuppressFbaPriceUpdate(true);
|
|
|
359 |
}
|
|
|
360 |
if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
|
|
|
361 |
amazonlisted.setSuppressFbaPriceUpdate(false);
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
amazonBulkUpdate.put(sku, amazonlisted);
|
|
|
365 |
}
|
|
|
366 |
logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
|
|
|
367 |
CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
|
|
368 |
CatalogClient.updateAmazonAttributesInBulk(amazonBulkUpdate);
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
|
|
|
372 |
public boolean checkEmptyString(Cell cell){
|
|
|
373 |
if (cell==null){
|
|
|
374 |
return true;
|
|
|
375 |
}
|
|
|
376 |
return false;
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
public String uploadSheet(){
|
|
|
380 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
|
|
381 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
|
|
382 |
return "authfail";
|
|
|
383 |
}
|
|
|
384 |
return "amazon-shipping-upload";
|
|
|
385 |
}
|
|
|
386 |
|
|
|
387 |
public String uploadBulkSheet(){
|
|
|
388 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
|
|
389 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
|
|
390 |
return "authfail";
|
|
|
391 |
}
|
|
|
392 |
return "amazon-bulk-upload";
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
|
| 7283 |
kshitij.so |
396 |
public String edit() {
|
| 7591 |
kshitij.so |
397 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
|
|
398 |
return "authfail";
|
|
|
399 |
}
|
| 7283 |
kshitij.so |
400 |
return "edit";
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
public String show() {
|
| 8168 |
kshitij.so |
404 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
|
|
405 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
|
|
|
406 |
return "authfail";
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
if (StringUtils.equals(id, "options")){
|
|
|
410 |
return "options";
|
|
|
411 |
}
|
|
|
412 |
return "id";
|
| 7283 |
kshitij.so |
413 |
}
|
|
|
414 |
|
|
|
415 |
public String editNew() {
|
|
|
416 |
return "editNew";
|
| 8168 |
kshitij.so |
417 |
}
|
| 7283 |
kshitij.so |
418 |
|
|
|
419 |
public void setId(String id) {
|
| 8168 |
kshitij.so |
420 |
logger.info(id);
|
| 7283 |
kshitij.so |
421 |
this.id = id;
|
|
|
422 |
}
|
|
|
423 |
|
|
|
424 |
public void setUrl(String url) {
|
|
|
425 |
this.url = url;
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
public String getUrl() {
|
|
|
429 |
return url;
|
|
|
430 |
}
|
|
|
431 |
|
|
|
432 |
public String getId() {
|
|
|
433 |
return id;
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
public void setItemId(String itemId) {
|
|
|
437 |
this.itemId = itemId;
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
public String getItemId() {
|
|
|
441 |
return itemId;
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
public void setIsFba(String isFba) {
|
|
|
445 |
this.isFba = isFba;
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
public String getIsFba() {
|
|
|
449 |
return isFba;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
public void setIsNonFba(String isNonFba) {
|
|
|
453 |
this.isNonFba = isNonFba;
|
|
|
454 |
}
|
|
|
455 |
|
|
|
456 |
public String getIsNonFba() {
|
|
|
457 |
return isNonFba;
|
|
|
458 |
}
|
|
|
459 |
|
|
|
460 |
public void setIsInventoryOverride(String isInventoryOverride) {
|
|
|
461 |
this.isInventoryOverride = isInventoryOverride;
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
public String getIsInventoryOverride() {
|
|
|
465 |
return isInventoryOverride;
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
public void setSellingPrice(String sellingPrice) {
|
|
|
469 |
this.sellingPrice = sellingPrice;
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
public String getSellingPrice() {
|
|
|
473 |
return sellingPrice;
|
|
|
474 |
}
|
|
|
475 |
|
|
|
476 |
public void setFbaPrice(String fbaPrice) {
|
|
|
477 |
this.fbaPrice = fbaPrice;
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
public String getFbaPrice() {
|
|
|
481 |
return fbaPrice;
|
|
|
482 |
}
|
| 7365 |
kshitij.so |
483 |
|
| 7283 |
kshitij.so |
484 |
public void setSaholicPrice(String saholicPrice) {
|
|
|
485 |
this.saholicPrice = saholicPrice;
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
public String getSaholicPrice() {
|
|
|
489 |
return saholicPrice;
|
|
|
490 |
}
|
|
|
491 |
|
| 7365 |
kshitij.so |
492 |
public void setIsTime(String isTime){
|
|
|
493 |
this.isTime = isTime;
|
|
|
494 |
}
|
|
|
495 |
|
| 7461 |
kshitij.so |
496 |
public String getIsTime(){
|
| 7365 |
kshitij.so |
497 |
return isTime;
|
|
|
498 |
}
|
|
|
499 |
|
|
|
500 |
public void setHandlingTime(String handlingTime){
|
|
|
501 |
this.handlingTime = handlingTime;
|
|
|
502 |
}
|
|
|
503 |
|
| 7461 |
kshitij.so |
504 |
public String getHandlingTime(){
|
| 7365 |
kshitij.so |
505 |
return handlingTime;
|
|
|
506 |
}
|
| 8168 |
kshitij.so |
507 |
|
| 7365 |
kshitij.so |
508 |
public void setCustomHandlingTime(String customHandlingTime){
|
|
|
509 |
this.customHandlingTime = customHandlingTime;
|
|
|
510 |
}
|
|
|
511 |
|
| 7461 |
kshitij.so |
512 |
public String getCustomHandlingTime(){
|
| 7365 |
kshitij.so |
513 |
return customHandlingTime;
|
|
|
514 |
}
|
| 7524 |
kshitij.so |
515 |
|
| 7461 |
kshitij.so |
516 |
public void setHoldInventory(String holdInventory){
|
|
|
517 |
this.holdInventory = holdInventory;
|
|
|
518 |
}
|
| 7365 |
kshitij.so |
519 |
|
| 7461 |
kshitij.so |
520 |
public String getHoldInventory(){
|
|
|
521 |
return holdInventory;
|
|
|
522 |
}
|
| 7524 |
kshitij.so |
523 |
|
| 7461 |
kshitij.so |
524 |
public void setDefaultInventory(String defaultInventory){
|
|
|
525 |
this.defaultInventory = defaultInventory;
|
|
|
526 |
}
|
|
|
527 |
|
|
|
528 |
public String getDefaultInventory(){
|
|
|
529 |
return defaultInventory;
|
|
|
530 |
}
|
|
|
531 |
|
| 7524 |
kshitij.so |
532 |
public File getFile() {
|
|
|
533 |
return file;
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
public void setFile(File file) {
|
|
|
537 |
this.file = file;
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
public String getFileUploadContentType() {
|
|
|
541 |
return fileUploadContentType;
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
public void setFileUploadContentType(String fileUploadContentType) {
|
|
|
545 |
this.fileUploadContentType = fileUploadContentType;
|
|
|
546 |
}
|
|
|
547 |
|
|
|
548 |
public String getFileUploadFileName() {
|
|
|
549 |
return fileUploadFileName;
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
public void setFileUploadFileName(String fileUploadFileName) {
|
|
|
553 |
this.fileUploadFileName = fileUploadFileName;
|
|
|
554 |
}
|
|
|
555 |
|
| 7591 |
kshitij.so |
556 |
public void setServletRequest(HttpServletRequest req) {
|
|
|
557 |
this.request = req;
|
|
|
558 |
this.session = req.getSession();
|
| 7283 |
kshitij.so |
559 |
}
|
|
|
560 |
|
| 8070 |
kshitij.so |
561 |
public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException, IOException {
|
| 7283 |
kshitij.so |
562 |
AmazonListController call = new AmazonListController();
|
| 8070 |
kshitij.so |
563 |
//System.out.println(call.runAsinJob());
|
| 7283 |
kshitij.so |
564 |
}
|
| 8168 |
kshitij.so |
565 |
|
|
|
566 |
@Override
|
|
|
567 |
public void setServletContext(ServletContext arg0) {
|
|
|
568 |
// TODO Auto-generated method stub
|
|
|
569 |
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
@Override
|
|
|
573 |
public void setServletResponse(HttpServletResponse arg0) {
|
|
|
574 |
// TODO Auto-generated method stub
|
|
|
575 |
|
|
|
576 |
}
|
|
|
577 |
|
|
|
578 |
public void setSuppressMfnPriceUpdate(String suppressMfnPriceUpdate) {
|
|
|
579 |
this.suppressMfnPriceUpdate = suppressMfnPriceUpdate;
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
public String getSuppressMfnPriceUpdate() {
|
|
|
583 |
return suppressMfnPriceUpdate;
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
public void setSuppressFbaPriceUpdate(String suppressFbaPriceUpdate) {
|
|
|
587 |
this.suppressFbaPriceUpdate = suppressFbaPriceUpdate;
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
public String getSuppressFbaPriceUpdate() {
|
|
|
591 |
return suppressFbaPriceUpdate;
|
|
|
592 |
}
|
| 7283 |
kshitij.so |
593 |
}
|