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