Subversion Repositories SmartDukaan

Rev

Rev 12889 | Rev 12948 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7283 kshitij.so 1
package in.shop2020.support.controllers;
2
 
8362 kshitij.so 3
import java.io.BufferedInputStream;
12449 kshitij.so 4
import java.io.BufferedReader;
7524 kshitij.so 5
import java.io.File;
7741 kshitij.so 6
import java.io.FileInputStream;
12449 kshitij.so 7
import java.io.FileNotFoundException;
8
import java.io.FileReader;
8362 kshitij.so 9
import java.io.FileWriter;
7524 kshitij.so 10
import java.io.IOException;
8362 kshitij.so 11
import java.io.InputStream;
12449 kshitij.so 12
import java.text.ParseException;
13
import java.util.ArrayList;
8620 kshitij.so 14
import java.util.Arrays;
12449 kshitij.so 15
import java.util.Calendar;
16
import java.util.Date;
17
import java.util.GregorianCalendar;
7365 kshitij.so 18
import java.util.HashMap;
7283 kshitij.so 19
import java.util.List;
20
import java.util.Map;
21
 
7591 kshitij.so 22
import javax.servlet.ServletContext;
8362 kshitij.so 23
import javax.servlet.ServletOutputStream;
7283 kshitij.so 24
import javax.servlet.ServletRequest;
25
import javax.servlet.http.HttpServletRequest;
8168 kshitij.so 26
import javax.servlet.http.HttpServletResponse;
7591 kshitij.so 27
import javax.servlet.http.HttpSession;
7283 kshitij.so 28
 
12449 kshitij.so 29
import in.shop2020.model.v1.catalog.AmazonPromotionType;
7283 kshitij.so 30
import in.shop2020.model.v1.catalog.Amazonlisted;
31
import in.shop2020.model.v1.catalog.CatalogServiceException;
32
import in.shop2020.model.v1.catalog.Item;
11197 kshitij.so 33
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
7283 kshitij.so 34
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
12449 kshitij.so 35
import in.shop2020.model.v1.catalog.AmazonPromotion;
7283 kshitij.so 36
import in.shop2020.model.v1.catalog.CatalogService.Client;
37
import in.shop2020.model.v1.inventory.InventoryServiceException;
7741 kshitij.so 38
import in.shop2020.model.v1.order.AmazonOrder;
7591 kshitij.so 39
import in.shop2020.support.utils.ReportsUtils;
12449 kshitij.so 40
import in.shop2020.support.utils.PromotionFeed;
7283 kshitij.so 41
import in.shop2020.thrift.clients.CatalogClient;
42
import in.shop2020.thrift.clients.InventoryClient;
7365 kshitij.so 43
import in.shop2020.thrift.clients.LogisticsClient;
7741 kshitij.so 44
import in.shop2020.thrift.clients.TransactionClient;
7365 kshitij.so 45
import in.shop2020.logistics.DeliveryType;
46
import in.shop2020.logistics.LogisticsInfo;
47
import in.shop2020.logistics.LogisticsServiceException;
48
import in.shop2020.logistics.PickUpType;
7283 kshitij.so 49
 
7524 kshitij.so 50
import org.apache.commons.io.FileUtils;
7365 kshitij.so 51
import org.apache.commons.lang.xwork.StringUtils;
7741 kshitij.so 52
import org.apache.poi.hssf.usermodel.HSSFSheet;
53
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
8168 kshitij.so 54
import org.apache.poi.ss.usermodel.Cell;
7591 kshitij.so 55
import org.apache.struts2.convention.annotation.InterceptorRef;
56
import org.apache.struts2.convention.annotation.InterceptorRefs;
7283 kshitij.so 57
import org.apache.struts2.convention.annotation.Result;
58
import org.apache.struts2.convention.annotation.Results;
59
import org.apache.struts2.interceptor.ServletRequestAware;
8168 kshitij.so 60
import org.apache.struts2.interceptor.ServletResponseAware;
61
import org.apache.struts2.util.ServletContextAware;
7283 kshitij.so 62
import org.apache.thrift.TException;
7741 kshitij.so 63
import org.apache.thrift.transport.TTransportException;
7283 kshitij.so 64
import org.slf4j.Logger;
65
import org.slf4j.LoggerFactory;
66
 
12449 kshitij.so 67
import com.amazonaws.mws.MarketplaceWebServiceException;
68
import com.ibm.icu.text.SimpleDateFormat;
7283 kshitij.so 69
import com.opensymphony.xwork2.ValidationAwareSupport;
70
 
71
@SuppressWarnings("serial")
8620 kshitij.so 72
 
7591 kshitij.so 73
@InterceptorRefs({
12449 kshitij.so 74
    @InterceptorRef("defaultStack"),
75
    @InterceptorRef("login")
7591 kshitij.so 76
})
7283 kshitij.so 77
@Results({
12449 kshitij.so 78
    @Result(name = "redirect", location = "${url}", type = "redirect"),
79
    @Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
7524 kshitij.so 80
})
8168 kshitij.so 81
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
7283 kshitij.so 82
 
12449 kshitij.so 83
    private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
7283 kshitij.so 84
 
12449 kshitij.so 85
    private HttpServletRequest request;
86
    private HttpSession session;
87
    private ServletContext context;
88
    private HttpServletResponse response;
89
    private String url;
90
    private String id;
91
    private String itemId;
92
    private String isFba;
93
    private String isNonFba;
94
    private String isInventoryOverride;
95
    private String fbaPrice;
96
    private String sellingPrice;
97
    private String saholicPrice;
98
    private String isTime;
99
    private String handlingTime;
100
    private String customHandlingTime;
101
    private String holdInventory;
102
    private String defaultInventory;
103
    private String fileUploadFileName;
104
    private String fileUploadContentType;
105
    private String suppressMfnPriceUpdate;
106
    private String suppressFbaPriceUpdate;
107
    private File file;
108
    private String errMsg;
109
    private String next;
110
    private List<Amazonlisted> amazonItems;
111
    private String searchText;
112
    private long searchCount;
113
    private long totalCount;
114
    private String taxCode;
115
    private String fbbTaxCode;
116
    private String isFbb;
117
    private String fbbPrice;
118
    private String suppressFbbPriceUpdate;
119
    private String startDate;
120
    private String endDate;
121
    private List<AmazonPromotion> promotionResult;
122
    private String promotionType;
123
    private String overrrideWanlc;
124
    private String exceptionalWanlc;
125
    private String autoDecrement;
126
    private String autoIncrement;
127
    private String autoFavourite;
128
    private String manualFavourite;
129
    private String otherCost;
12673 kshitij.so 130
    private String isFbaPromotionActive;
131
    private String isFbbPromotionActive;
12661 kshitij.so 132
    private String fbaPromoPrice;
133
    private String fbbPromoPrice;
134
    private String promoItemId;
12889 kshitij.so 135
    private String fbgTaxCode;
136
    private String isFbg;
137
    private String fbgPrice;
138
    private String suppressFbgPriceUpdate;
139
    private String fbgPromoPrice;
140
    private String isFbgPromotionActive;
12449 kshitij.so 141
 
142
    public String getOtherCost() {
143
        return otherCost;
144
    }
7283 kshitij.so 145
 
12449 kshitij.so 146
    public void setOtherCost(String otherCost) {
147
        this.otherCost = otherCost;
148
    }
7283 kshitij.so 149
 
12449 kshitij.so 150
    public String getAutoDecrement() {
151
        return autoDecrement;
152
    }
7283 kshitij.so 153
 
12449 kshitij.so 154
    public void setAutoDecrement(String autoDecrement) {
155
        this.autoDecrement = autoDecrement;
156
    }
8620 kshitij.so 157
 
12449 kshitij.so 158
    public String getAutoIncrement() {
159
        return autoIncrement;
160
    }
7283 kshitij.so 161
 
12449 kshitij.so 162
    public void setAutoIncrement(String autoIncrement) {
163
        this.autoIncrement = autoIncrement;
164
    }
7365 kshitij.so 165
 
12449 kshitij.so 166
    public String getAutoFavourite() {
167
        return autoFavourite;
168
    }
7365 kshitij.so 169
 
12449 kshitij.so 170
    public void setAutoFavourite(String autoFavourite) {
171
        this.autoFavourite = autoFavourite;
172
    }
7365 kshitij.so 173
 
12449 kshitij.so 174
    public String getManualFavourite() {
175
        return manualFavourite;
176
    }
8620 kshitij.so 177
 
12449 kshitij.so 178
    public void setManualFavourite(String manualFavourite) {
179
        this.manualFavourite = manualFavourite;
180
    }
181
 
182
 
183
    public String index() {
184
        if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
185
            return "authfail";
186
        }
187
        return "index";
188
    }
189
 
190
    public String fetchItems() throws TException {
191
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
192
        if (searchText.length() == 0) {
193
            amazonItems = CatalogClient.getAmazonListedItems(Long.valueOf(next), 10);
194
            totalCount = CatalogClient.getCountForAmazonlistedItems();
195
            setSearchCount(totalCount);
196
        } else {
197
            List<String> subString = Arrays.asList(searchText.split(" "));
198
            amazonItems = CatalogClient.searchAmazonItems(subString,Long.valueOf(next), 10);
199
            totalCount = CatalogClient.getCountForAmazonlistedItems();
200
            searchCount = CatalogClient.getAmazonSearchResultCount(subString);
201
        }
202
        return "amazon-item-table";
203
    }
204
 
205
 
206
    public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
207
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
12661 kshitij.so 208
        long now = getTimeInMilliseconds();
209
        Amazonlisted amazonItemDetails = CatalogClient.getAmazonItemDetails(Long.valueOf(id));
210
        return amazonItemDetails;
12449 kshitij.so 211
    }
212
 
213
    public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
214
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
215
        return CatalogClient.getItem(Long.valueOf(id));
216
    }
217
 
218
 
219
 
220
    public String update() throws NumberFormatException, TException{
221
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
222
        boolean flag=false;
223
        boolean commit=false;
224
        long delay = Long.valueOf(customHandlingTime);
225
        if ( Boolean.valueOf(isTime)) {
226
            flag = true;
227
        }
228
        changeItemInventory();
229
        Amazonlisted amazonlisted = CatalogClient.getAmazonItemDetails(Long.valueOf(itemId));
230
        if (amazonlisted.getSellingPrice()!=Double.valueOf(sellingPrice)){
231
            amazonlisted.setSellingPrice(Double.valueOf(sellingPrice));
232
            commit=true;
233
        }
234
        if (amazonlisted.getFbaPrice()!=Double.valueOf(fbaPrice)){
235
            amazonlisted.setFbaPrice(Double.valueOf(fbaPrice));
236
            commit=true;
237
        }
238
        if (amazonlisted.isIsFba()!=Boolean.valueOf(isFba)){
239
            amazonlisted.setIsFba(Boolean.valueOf(isFba));
240
            commit=true;
241
        }
242
        if (amazonlisted.isIsNonFba()!=Boolean.valueOf(isNonFba)){
243
            amazonlisted.setIsNonFba(Boolean.valueOf(isNonFba));
244
            commit=true;
245
        }
246
        if (amazonlisted.isIsCustomTime()!=flag){
247
            amazonlisted.setIsCustomTime(flag);
248
            commit=true;
249
        }
250
        if (amazonlisted.getHandlingTime()!=delay){
251
            amazonlisted.setHandlingTime(delay);
252
            commit=true;
253
        }
254
        if(amazonlisted.isIsInventoryOverride()!=Boolean.valueOf(isInventoryOverride)){
255
            amazonlisted.setIsInventoryOverride(Boolean.valueOf(isInventoryOverride));
256
            commit=true;
257
        }
258
        if(amazonlisted.isSuppressMfnPriceUpdate()!=Boolean.valueOf(suppressMfnPriceUpdate)){
259
            amazonlisted.setSuppressMfnPriceUpdate(Boolean.valueOf(suppressMfnPriceUpdate));
260
            commit=true;
261
        }
262
        if(amazonlisted.isSuppressFbaPriceUpdate()!=Boolean.valueOf(suppressFbaPriceUpdate)){
263
            amazonlisted.setSuppressFbaPriceUpdate(Boolean.valueOf(suppressFbaPriceUpdate));
264
            commit=true;
265
        }
266
 
267
        if(!StringUtils.equals(amazonlisted.getTaxCode(), taxCode)){
268
            amazonlisted.setTaxCode(taxCode);
269
            commit=true;
270
        }
271
 
272
        if(!StringUtils.equals(amazonlisted.getFbbtaxCode(), fbbTaxCode)){
10922 kshitij.so 273
            amazonlisted.setFbbtaxCode(fbbTaxCode);
274
            commit=true;
275
        }
12449 kshitij.so 276
 
277
        if(amazonlisted.isSuppressFbbPriceUpdate()!=Boolean.valueOf(suppressFbbPriceUpdate)){
10922 kshitij.so 278
            amazonlisted.setSuppressFbbPriceUpdate(Boolean.valueOf(suppressFbbPriceUpdate));
279
            commit=true;
280
        }
12449 kshitij.so 281
 
282
        if (amazonlisted.getFbbPrice()!=Double.valueOf(fbbPrice)){
10922 kshitij.so 283
            amazonlisted.setFbbPrice(Double.valueOf(fbbPrice));
284
            commit=true;
285
        }
12449 kshitij.so 286
 
287
        if (amazonlisted.isIsFbb()!=Boolean.valueOf(isFbb)){
10922 kshitij.so 288
            amazonlisted.setIsFbb(Boolean.valueOf(isFbb));
289
            commit=true;
290
        }
8620 kshitij.so 291
 
12449 kshitij.so 292
        if (amazonlisted.isAutoDecrement()!=Boolean.valueOf(autoDecrement)){
293
            amazonlisted.setAutoDecrement(Boolean.valueOf(autoDecrement));
294
            commit=true;
295
        }
296
 
297
        if (amazonlisted.isAutoIncrement()!=Boolean.valueOf(autoIncrement)){
298
            amazonlisted.setAutoIncrement(Boolean.valueOf(autoIncrement));
299
            commit=true;
300
        }
301
 
302
        if (amazonlisted.isManualFavourite()!=Boolean.valueOf(manualFavourite)){
303
            amazonlisted.setManualFavourite(Boolean.valueOf(manualFavourite));
304
            commit=true;
305
        }
7283 kshitij.so 306
 
307
 
12449 kshitij.so 308
        if (amazonlisted.isOverrrideWanlc()!=Boolean.valueOf(overrrideWanlc)){
309
            amazonlisted.setOverrrideWanlc(Boolean.valueOf(overrrideWanlc));
310
            commit=true;
311
        }
7524 kshitij.so 312
 
12449 kshitij.so 313
        if (amazonlisted.getExceptionalWanlc()!=Double.valueOf(exceptionalWanlc)){
314
            amazonlisted.setExceptionalWanlc(Double.valueOf(exceptionalWanlc));
315
            commit=true;
316
        }
317
 
318
        if (amazonlisted.getOtherCost()!=Double.valueOf(otherCost)){
319
            amazonlisted.setOtherCost(Double.valueOf(otherCost));
320
            commit=true;
321
        }
12889 kshitij.so 322
 
323
        if(!StringUtils.equals(amazonlisted.getFbgtaxCode(), fbgTaxCode)){
324
            amazonlisted.setFbgtaxCode(fbgTaxCode);
325
            commit=true;
326
        }
8620 kshitij.so 327
 
12889 kshitij.so 328
        if(amazonlisted.isSuppressFbgPriceUpdate()!=Boolean.valueOf(suppressFbgPriceUpdate)){
329
            amazonlisted.setSuppressFbgPriceUpdate(Boolean.valueOf(suppressFbgPriceUpdate));
330
            commit=true;
331
        }
332
 
333
        if (amazonlisted.getFbgPrice()!=Double.valueOf(fbgPrice)){
334
            amazonlisted.setFbgPrice(Double.valueOf(fbgPrice));
335
            commit=true;
336
        }
337
 
338
        if (amazonlisted.isIsFbg()!=Boolean.valueOf(isFbg)){
339
            amazonlisted.setIsFbg(Boolean.valueOf(isFbg));
340
            commit=true;
341
        }
342
 
12449 kshitij.so 343
        if(commit){
344
            CatalogClient.updateAmazonItemDetails(amazonlisted);
345
        }
346
        else{
347
            logger.info("Nothing new to commit");
348
        }
349
        return "index";
8620 kshitij.so 350
 
12449 kshitij.so 351
    }
12661 kshitij.so 352
 
353
    public String updatePromo() throws NumberFormatException, TException{
354
 
355
        Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
356
        Amazonlisted amazonlisted = catalogClient.getAmazonItemDetails(Long.valueOf(promoItemId));
357
 
12674 kshitij.so 358
        logger.info(isFbaPromotionActive);
359
        logger.info(isFbbPromotionActive);
360
 
12661 kshitij.so 361
        if(Boolean.valueOf(isFbaPromotionActive)){
362
            amazonlisted.setFbaPromoPrice(Double.valueOf(fbaPromoPrice));
363
        }
364
 
365
        if(Boolean.valueOf(isFbbPromotionActive)){
366
            amazonlisted.setFbbPromoPrice(Double.valueOf(fbbPromoPrice));
367
        }
368
 
12889 kshitij.so 369
        if(Boolean.valueOf(isFbgPromotionActive)){
370
            amazonlisted.setFbgPromoPrice(Double.valueOf(fbgPromoPrice));
371
        }
372
 
12661 kshitij.so 373
        catalogClient.updateAmazonItemDetails(amazonlisted);
374
        return "index";
375
    }
7524 kshitij.so 376
 
12449 kshitij.so 377
    public void upload() throws IOException, TException {
378
        File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
379
        FileUtils.copyFile(this.file, fileToCreate);
380
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
381
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
382
        HSSFSheet sheet = workbook.getSheetAt(0);
383
        Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
384
        for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
385
            TransactionClient tcl = new TransactionClient();
386
            List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
387
            for (AmazonOrder order : orders){
388
                if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
389
                    Map<String,String> dateMap = new HashMap<String,String>();
390
                    dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
391
                    amazonOrderMap.put(order.getOrderId(), dateMap);
392
                }
393
            }
394
        }
395
        TransactionClient tcl = new TransactionClient();
396
        tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
397
    }
7461 kshitij.so 398
 
12661 kshitij.so 399
    public void uploadPromotionSheet() throws IOException, ParseException, TException, CatalogServiceException, InterruptedException{
12449 kshitij.so 400
        Map<String,AmazonPromotion> amazonPromoMap = new HashMap<String,AmazonPromotion>();
401
        SimpleDateFormat dateFormatter;
12661 kshitij.so 402
        long timeNow = Long.valueOf(getTimeInMilliseconds());
12449 kshitij.so 403
        if (promotionType.equalsIgnoreCase("SHORTTERM")){
12586 kshitij.so 404
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
12449 kshitij.so 405
        }
406
        else{
407
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
408
        }
12661 kshitij.so 409
        File fileToCreate = new File("/tmp/", "Amazon-Promotion-"+String.valueOf(getTimeInMilliseconds()));
12449 kshitij.so 410
        FileUtils.copyFile(this.file, fileToCreate);
411
        BufferedReader reader = null;
412
        try {
413
            reader = new BufferedReader(new FileReader(file.getAbsolutePath()));
414
        } catch (FileNotFoundException e1) {
415
            // TODO Auto-generated catch block
416
            e1.printStackTrace();
417
        }
418
        String str;
419
        int lineNumber = 0;
420
        while ((str = reader.readLine()) != null) {
421
            lineNumber++;
12504 kshitij.so 422
            if (str.trim().length() == 0 || lineNumber<2) {
12449 kshitij.so 423
                continue;
424
            }
12661 kshitij.so 425
            timeNow +=1500;
12449 kshitij.so 426
            String[] values = str.split("\t");
427
            AmazonPromotion amazonPromotion = new AmazonPromotion();
428
            amazonPromotion.setSku(values[0]);
12460 kshitij.so 429
            amazonPromotion.setStandardPrice(Double.valueOf(values[1]));
430
            amazonPromotion.setSalePrice(Double.valueOf(values[2]));
431
            amazonPromotion.setSubsidyAmount(Double.valueOf(values[3]));
432
            Date startDate = dateFormatter.parse(values[4]);
433
            Date endDate = dateFormatter.parse(values[5]);
12449 kshitij.so 434
            amazonPromotion.setStartDate(startDate.getTime());
435
            amazonPromotion.setEndDate(endDate.getTime());
12661 kshitij.so 436
            amazonPromotion.setAddedOn(timeNow);
12449 kshitij.so 437
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
438
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
439
        }
440
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
441
        if (!cc.addAmazonPromotion(amazonPromoMap)){
442
            throw new CatalogServiceException();
443
        }
12661 kshitij.so 444
 
445
        if (promotionType.equalsIgnoreCase("LONGTERM")){
446
            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
447
            PromotionFeed pm = new PromotionFeed(list);
448
            pm.start();
449
        }
12449 kshitij.so 450
    }
7283 kshitij.so 451
 
12449 kshitij.so 452
    private void changeItemInventory() throws NumberFormatException, TException {
453
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
7283 kshitij.so 454
 
12449 kshitij.so 455
        if (StringUtils.isEmpty(holdInventory)) {
456
            holdInventory = "0";
457
        }
458
        if (StringUtils.isEmpty(defaultInventory)) {
459
            defaultInventory = "0";
460
        }
461
        CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
462
    }
7283 kshitij.so 463
 
464
 
12449 kshitij.so 465
    public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
466
        InventoryClient inventoryServiceClient = new InventoryClient();
467
        in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
468
        in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
469
        return thriftItemInventory.getAvailability();
8620 kshitij.so 470
 
12449 kshitij.so 471
    }
7365 kshitij.so 472
 
12449 kshitij.so 473
    public Map<Long, Long> getReservedItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
474
        InventoryClient inventoryServiceClient = new InventoryClient();
475
        in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
476
        in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
477
        return thriftItemInventory.getReserved();
7365 kshitij.so 478
 
12449 kshitij.so 479
    }
8070 kshitij.so 480
 
12449 kshitij.so 481
    public String getWarehouseName(String warehouseId) throws NumberFormatException, TException { 
482
        InventoryClient inventoryServiceClient = new InventoryClient();
483
        return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
484
    }
485
 
486
    public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
487
        InventoryClient inventoryServiceClient = new InventoryClient();
488
        try { 
489
            return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
490
        }
491
        catch (Exception e){
492
            return null;
493
        }
494
    }
495
 
496
    public List<AmazonFbaInventorySnapshot> getFbaInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
497
        InventoryClient inventoryServiceClient = new InventoryClient();
498
        try { 
499
            return inventoryServiceClient.getClient().getAmazonFbaItemInventory(Long.valueOf(itemId));
500
        }
501
        catch (Exception e){
502
            return null;
503
        }
504
    }
505
 
12453 kshitij.so 506
    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
12920 kshitij.so 507
        LogisticsClient logisticsClient = new LogisticsClient();
508
        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
509
        //return 0L;
12453 kshitij.so 510
    }
511
 
12449 kshitij.so 512
 
513
    public double getWanlcForItem(String itemId){
514
        InventoryClient inventoryServiceClient;
515
        try {
516
            inventoryServiceClient = new InventoryClient();
517
        } catch (TTransportException e1) {
518
            // TODO Auto-generated catch block
519
            return 0.0;
520
        }
521
        try { 
522
            return inventoryServiceClient.getClient().getWanNlcForSource(Long.valueOf(itemId), 3);
523
        }
524
        catch (Exception e){
525
            return 0.0;
526
        }
527
    }
528
 
529
    public long getTimeInMilliseconds(){
530
        Calendar cal=GregorianCalendar.getInstance();
531
        return cal.getTimeInMillis();
532
    }
533
 
534
    public String runAsinJob() throws IOException, InterruptedException {
10925 kshitij.so 535
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
536
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
537
            return "authfail";
538
        }
539
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
12449 kshitij.so 540
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunAsinJob.sh"};
541
        testProcess.command(command);
542
        logger.info(testProcess.command().toString());
543
        Process process = testProcess.start();
544
        process.waitFor();
545
        logger.info(String.valueOf(process.exitValue()));
546
        return "asinjob";
547
 
548
    }
549
 
550
    public String runFbbListingJob() throws IOException, InterruptedException {
551
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
552
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
553
            return "authfail";
554
        }
555
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
10925 kshitij.so 556
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbbListingJob.sh"};
557
        testProcess.command(command);
558
        logger.info(testProcess.command().toString());
559
        Process process = testProcess.start();
560
        process.waitFor();
561
        logger.info(String.valueOf(process.exitValue()));
562
        return "asinjob";
563
    }
12920 kshitij.so 564
 
565
    public String runFbgListingJob() throws IOException, InterruptedException {
566
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
567
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
568
            return "authfail";
569
        }
570
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
571
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbgListingJob.sh"};
572
        testProcess.command(command);
573
        logger.info(testProcess.command().toString());
574
        Process process = testProcess.start();
575
        process.waitFor();
576
        logger.info(String.valueOf(process.exitValue()));
577
        return "asinjob";
578
    }
8620 kshitij.so 579
 
580
 
12449 kshitij.so 581
    public String runFbaListingJob() throws IOException, InterruptedException {
582
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
583
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
584
            return "authfail";
585
        }
586
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
587
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbaListingJob.sh"};
588
        testProcess.command(command);
589
        logger.info(testProcess.command().toString());
590
        Process process = testProcess.start();
591
        process.waitFor();
592
        logger.info(String.valueOf(process.exitValue()));
593
        return "asinjob";
594
    }
8073 kshitij.so 595
 
12449 kshitij.so 596
    public String runNonFbaListingJob() throws IOException, InterruptedException {
597
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
598
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
599
            return "authfail";
600
        }
601
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
602
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunNonFbaListingJob.sh"};
603
        testProcess.command(command);
604
        logger.info(testProcess.command().toString());
605
        Process process = testProcess.start();
606
        process.waitFor();
607
        logger.info(String.valueOf(process.exitValue()));
608
        return "asinjob";
609
    }
8620 kshitij.so 610
 
12449 kshitij.so 611
    public void runFbaInventoryJob() throws IOException, InterruptedException {
612
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
613
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/SubmitFBAInventoryFeed.sh"};
614
        testProcess.command(command);
615
        logger.info(testProcess.command().toString());
616
        Process process = testProcess.start();
617
        process.waitFor();
618
        logger.info(String.valueOf(process.exitValue()));
619
    }
8620 kshitij.so 620
 
12449 kshitij.so 621
    public void uploadAsinFile() throws IOException, TException{
622
        File fileToCreate = new File("/tmp/", "Amazon-asin-upload.xls");
623
        FileUtils.copyFile(this.file, fileToCreate);
624
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
625
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
626
        HSSFSheet sheet = workbook.getSheetAt(0);
627
        Map<Long,Item> amazonAsin = new HashMap<Long,Item>();
628
        StringBuilder sb =new StringBuilder();
629
        Client CatalogClient=null;
630
        try {
631
            CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
632
        } catch (TTransportException e) {
633
            e.printStackTrace();
634
        }
635
        for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
636
            Item item=null;
637
            Long sku;
638
            String asin;
639
            if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
640
                continue;
641
            }
642
            else {
643
                sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
644
                try {
645
                    item = CatalogClient.getItem(sku);
646
                } catch (Exception e) {
647
                    logger.info("Unable to fetch item details ID= "+sku);
648
                    logger.info("Unable to fetch item. "+e);
649
                    sb.append("Service exception ItemId not updated Id= "+sku+"\n");
650
                    continue;
651
                } 
652
            }
8620 kshitij.so 653
 
12449 kshitij.so 654
            if(item.getId() == 0){
655
                logger.info("Item Id doesn't exist in catalog Id= "+sku);
656
                sb.append("Item Id doesn't exist in catalog Id= "+sku+"\n");
657
                continue;
658
            }
8620 kshitij.so 659
 
12449 kshitij.so 660
            if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
661
                asin = sheet.getRow(iterator).getCell(1).getStringCellValue();
662
                item.setAsin(asin);
663
            }
8620 kshitij.so 664
 
12449 kshitij.so 665
            if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
666
                long virtualInventory =(long) sheet.getRow(iterator).getCell(2).getNumericCellValue();
667
                item.setDefaultInventory(virtualInventory);
668
            }
8620 kshitij.so 669
 
12449 kshitij.so 670
            if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
671
                long riskyInventory =(long) sheet.getRow(iterator).getCell(3).getNumericCellValue();
672
                item.setHoldInventory(riskyInventory);
673
            }
8620 kshitij.so 674
 
12449 kshitij.so 675
            amazonAsin.put(sku, item);
676
        }
677
        CatalogClient.updateAsin(amazonAsin);
8620 kshitij.so 678
 
12449 kshitij.so 679
        logger.info("Amazon Asin Map "+amazonAsin.toString());
680
        CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
681
        CatalogClient.updateAsin(amazonAsin);
682
        File file = new File("/tmp/asinfile");
683
        FileWriter writer = new FileWriter(file);
684
        writer.append(sb.toString());
685
        writer.close();
686
        byte[] buffer = new byte[(int)file.length()];
687
        InputStream input = null;
688
        try {
689
            int totalBytesRead = 0;
690
            input = new BufferedInputStream(new FileInputStream(file));
691
            while(totalBytesRead < buffer.length){
692
                int bytesRemaining = buffer.length - totalBytesRead;
693
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
694
                if (bytesRead > 0){
695
                    totalBytesRead = totalBytesRead + bytesRead;
696
                }
697
            }
698
        }
699
        finally {
700
            input.close();
701
            file.delete();
702
        }
8620 kshitij.so 703
 
12449 kshitij.so 704
        response.setHeader("Content-Type", "text/javascript");
8168 kshitij.so 705
 
12449 kshitij.so 706
        ServletOutputStream sos;
707
        try {
708
            sos = response.getOutputStream();
709
            sos.write(buffer);
710
            sos.flush();
711
        } catch (IOException e) {
712
            System.out.println("Unable to stream the manifest file");
713
        }   
714
    }
8168 kshitij.so 715
 
12449 kshitij.so 716
    public void uploadBulkFile() throws IOException, TException{
717
        File fileToCreate = new File("/tmp/", "Amazon-bulk-upload.xls");
718
        FileUtils.copyFile(this.file, fileToCreate);
719
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
720
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
721
 
722
        HSSFSheet sheet = workbook.getSheetAt(0);
723
        Map<Long,Amazonlisted> amazonBulkUpdate = new HashMap<Long,Amazonlisted>();
724
        Client CatalogClient=null;
725
        StringBuilder sb = new StringBuilder();
726
        try {
727
            CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
728
        } catch (TTransportException e) {
729
            // TODO Auto-generated catch block
730
            e.printStackTrace();
731
        }
732
        for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
733
            Amazonlisted amazonlisted =null;
734
            Long sku;
735
            if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
736
                continue;
737
            }
738
            else {
739
                sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
740
                try {
741
                    amazonlisted = CatalogClient.getAmazonItemDetails(sku);
742
                } catch (TException e) {
743
                    logger.info("Unable to fetch item details ID= "+sku);
744
                    sb.append("Service exception ItemId not updated Id= "+sku+"\n");
745
                    continue;
746
                }
747
            }
748
 
749
            if(amazonlisted.getItemid() == 0){
750
                logger.info("Item Id doesn't exist in amazonlisted Id= "+sku);
751
                sb.append("Item Id doesn't exist in amazonlisted Id= "+sku+"\n");
752
                continue;
753
            }
754
 
755
            if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
756
                double mfnPrice = sheet.getRow(iterator).getCell(1).getNumericCellValue();
757
                amazonlisted.setSellingPrice(mfnPrice);
758
            }
759
 
760
            if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
761
                double fbaSellingPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
762
                amazonlisted.setFbaPrice(fbaSellingPrice);
763
            }
764
 
765
            if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
10922 kshitij.so 766
                double fbbSellingPrice = sheet.getRow(iterator).getCell(3).getNumericCellValue();
767
                amazonlisted.setFbbPrice(fbbSellingPrice);
768
            }
8168 kshitij.so 769
 
12449 kshitij.so 770
            if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
771
                if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==1){
772
                    amazonlisted.setIsNonFba(true);
773
                }
774
                if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==0){
775
                    amazonlisted.setIsNonFba(false);
776
                }
777
            }
8168 kshitij.so 778
 
12449 kshitij.so 779
            if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
780
                if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
781
                    amazonlisted.setIsFba(true);
782
                }
783
                if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
784
                    amazonlisted.setIsFba(false);
785
                }
786
            }
787
 
788
            if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
10922 kshitij.so 789
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
790
                    amazonlisted.setIsFbb(true);
791
                }
792
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
793
                    amazonlisted.setIsFbb(false);
794
                }
795
            }
8168 kshitij.so 796
 
12449 kshitij.so 797
            if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
798
                if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
799
                    amazonlisted.setIsInventoryOverride(true);
800
                }
801
                if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
802
                    amazonlisted.setIsInventoryOverride(false);
803
                }
804
            }
805
            if (!checkEmptyString(sheet.getRow(iterator).getCell(8))){
806
                if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==1){
807
                    amazonlisted.setSuppressMfnPriceUpdate(true);
808
                }
809
                if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==0){
810
                    amazonlisted.setSuppressMfnPriceUpdate(false);
811
                }
812
            }
813
 
814
            if (!checkEmptyString(sheet.getRow(iterator).getCell(9))){
815
                if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==1){
816
                    amazonlisted.setSuppressFbaPriceUpdate(true);
817
                }
818
                if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==0){
819
                    amazonlisted.setSuppressFbaPriceUpdate(false);
820
                }
821
            }
822
 
823
            if (!checkEmptyString(sheet.getRow(iterator).getCell(10))){
10922 kshitij.so 824
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==1){
825
                    amazonlisted.setSuppressFbbPriceUpdate(true);
826
                }
827
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==0){
828
                    amazonlisted.setSuppressFbbPriceUpdate(false);
829
                }
830
            }
8620 kshitij.so 831
 
12449 kshitij.so 832
            if (!checkEmptyString(sheet.getRow(iterator).getCell(11))){
833
                String taxCode = sheet.getRow(iterator).getCell(11).getStringCellValue();
834
                amazonlisted.setTaxCode(taxCode);
835
            }
836
 
837
            if (!checkEmptyString(sheet.getRow(iterator).getCell(12))){
10922 kshitij.so 838
                String fbbTaxCode = sheet.getRow(iterator).getCell(12).getStringCellValue();
839
                amazonlisted.setFbbtaxCode(fbbTaxCode);
840
            }
12504 kshitij.so 841
 
842
            if (!checkEmptyString(sheet.getRow(iterator).getCell(13))){
843
                double otherCost = sheet.getRow(iterator).getCell(13).getNumericCellValue();
844
                amazonlisted.setOtherCost(otherCost);
845
            }
8362 kshitij.so 846
 
12449 kshitij.so 847
            amazonBulkUpdate.put(sku, amazonlisted);
848
        }
849
        logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
850
        CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
851
        boolean result = CatalogClient.updateAmazonAttributesInBulk(amazonBulkUpdate);
852
        if (!result){
853
            sb = new StringBuilder();
854
            sb.append("Error : Unable to update");
855
        }
856
        File file = new File("/tmp/amazonbulk");
857
        FileWriter writer = new FileWriter(file);
858
        writer.append(sb.toString());
859
        writer.close();
860
        byte[] buffer = new byte[(int)file.length()];
861
        InputStream input = null;
862
        try {
863
            int totalBytesRead = 0;
864
            input = new BufferedInputStream(new FileInputStream(file));
865
            while(totalBytesRead < buffer.length){
866
                int bytesRemaining = buffer.length - totalBytesRead;
867
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
868
                if (bytesRead > 0){
869
                    totalBytesRead = totalBytesRead + bytesRead;
870
                }
871
            }
872
        }
873
        finally {
874
            input.close();
875
            file.delete();
876
        }
8362 kshitij.so 877
 
12449 kshitij.so 878
        response.setHeader("Content-Type", "text/javascript");
8168 kshitij.so 879
 
12449 kshitij.so 880
        ServletOutputStream sos;
881
        try {
882
            sos = response.getOutputStream();
883
            sos.write(buffer);
884
            sos.flush();
885
        } catch (IOException e) {
886
            System.out.println("Unable to stream the manifest file");
887
        }   
888
    }
8168 kshitij.so 889
 
12449 kshitij.so 890
    public boolean checkEmptyString(Cell cell){
891
        if (cell==null){
892
            return true;
893
        }
894
        return false;
895
    }
8168 kshitij.so 896
 
12449 kshitij.so 897
    public String uploadSheet(){
898
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
899
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
900
            return "authfail";
901
        }
902
        return "amazon-shipping-upload";
903
    }
8620 kshitij.so 904
 
12449 kshitij.so 905
    public String uploadPromotion(){
906
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
907
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
908
            return "authfail";
909
        }
910
        return "amazon-promotion-upload";
911
    }
8168 kshitij.so 912
 
12449 kshitij.so 913
    public String uploadAsin(){
914
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
915
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
916
            return "authfail";
917
        }
918
        return "amazon-asin-upload";
919
    }
8168 kshitij.so 920
 
12449 kshitij.so 921
    public String uploadBulkSheet(){
922
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
923
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
924
            return "authfail";
925
        }
926
        return "amazon-bulk-upload";
927
    }
7283 kshitij.so 928
 
8168 kshitij.so 929
 
12449 kshitij.so 930
    public String edit() {
931
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
932
            return "authfail";
933
        }
934
        return "edit";
935
    }
8620 kshitij.so 936
 
12449 kshitij.so 937
    public String viewPromotionDetails() throws ParseException, TException{
938
        logger.info(startDate);
939
        logger.info(endDate);
940
        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
941
        Date start = dateFormatter.parse(startDate);
942
        Date end = dateFormatter.parse(endDate);
943
        logger.info(start.getTime()+"");
944
        logger.info(end.getTime()+"");
945
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
946
        setPromotionResult(cc.getAmazonPromotion(start.getTime(),end.getTime()));
947
        return "amazon-promotion-result";
948
    }
8620 kshitij.so 949
 
12449 kshitij.so 950
    public String getDate(long timestamp){
951
        return new java.util.Date(timestamp).toLocaleString();
952
    }
7283 kshitij.so 953
 
12449 kshitij.so 954
    public String show() {
955
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
956
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
957
            return "authfail";
958
        }
7283 kshitij.so 959
 
12449 kshitij.so 960
        if (StringUtils.equals(id, "options")){
961
            return "options";
962
        }
7283 kshitij.so 963
 
12449 kshitij.so 964
        if (StringUtils.equals(id, "item-table")){
965
            return "amazon-item-table";
966
        }
7283 kshitij.so 967
 
12449 kshitij.so 968
        if (StringUtils.equals(id, "promotion")){
969
            return "amazon-promotion";
970
        }
7283 kshitij.so 971
 
12449 kshitij.so 972
        return "id";
973
    }
7283 kshitij.so 974
 
12449 kshitij.so 975
    public String editNew() {
976
        return "editNew";
977
    }	
7283 kshitij.so 978
 
12449 kshitij.so 979
    public void setId(String id) {
980
        logger.info(id);
981
        this.id = id;
982
    }
7283 kshitij.so 983
 
12449 kshitij.so 984
    public void setUrl(String url) {
985
        this.url = url;
986
    }
7283 kshitij.so 987
 
12449 kshitij.so 988
    public String getUrl() {
989
        return url;
990
    }
7283 kshitij.so 991
 
12449 kshitij.so 992
    public String getId() {
993
        return id;
994
    }
7283 kshitij.so 995
 
12449 kshitij.so 996
    public void setItemId(String itemId) {
997
        this.itemId = itemId;
998
    }
7283 kshitij.so 999
 
12449 kshitij.so 1000
    public String getItemId() {
1001
        return itemId;
1002
    }
7283 kshitij.so 1003
 
12449 kshitij.so 1004
    public void setIsFba(String isFba) {
1005
        this.isFba = isFba;
1006
    }
7283 kshitij.so 1007
 
12449 kshitij.so 1008
    public String getIsFba() {
1009
        return isFba;
1010
    }
7283 kshitij.so 1011
 
12449 kshitij.so 1012
    public void setIsNonFba(String isNonFba) {
1013
        this.isNonFba = isNonFba;
1014
    }
7283 kshitij.so 1015
 
12449 kshitij.so 1016
    public String getIsNonFba() {
1017
        return isNonFba;
1018
    }
7283 kshitij.so 1019
 
12449 kshitij.so 1020
    public void setIsInventoryOverride(String isInventoryOverride) {
1021
        this.isInventoryOverride = isInventoryOverride;
1022
    }
7365 kshitij.so 1023
 
12449 kshitij.so 1024
    public String getIsInventoryOverride() {
1025
        return isInventoryOverride;
1026
    }
7283 kshitij.so 1027
 
12449 kshitij.so 1028
    public void setSellingPrice(String sellingPrice) {
1029
        this.sellingPrice = sellingPrice;
1030
    }
7283 kshitij.so 1031
 
12449 kshitij.so 1032
    public String getSellingPrice() {
1033
        return sellingPrice;
1034
    }
7365 kshitij.so 1035
 
12449 kshitij.so 1036
    public void setFbaPrice(String fbaPrice) {
1037
        this.fbaPrice = fbaPrice;
1038
    }
7365 kshitij.so 1039
 
12449 kshitij.so 1040
    public String getFbaPrice() {
1041
        return fbaPrice;
1042
    }
7365 kshitij.so 1043
 
12449 kshitij.so 1044
    public void setSaholicPrice(String saholicPrice) {
1045
        this.saholicPrice = saholicPrice;
1046
    }
8168 kshitij.so 1047
 
12449 kshitij.so 1048
    public String getSaholicPrice() {
1049
        return saholicPrice;
1050
    }
7365 kshitij.so 1051
 
12449 kshitij.so 1052
    public void setIsTime(String isTime){
1053
        logger.info("set istime"+isTime);
1054
        this.isTime = isTime;
1055
    }
7524 kshitij.so 1056
 
12449 kshitij.so 1057
    public String getIsTime(){
1058
        return isTime;
1059
    }
7365 kshitij.so 1060
 
12449 kshitij.so 1061
    public void setHandlingTime(String handlingTime){
1062
        this.handlingTime = handlingTime;
1063
    }
7524 kshitij.so 1064
 
12449 kshitij.so 1065
    public String getHandlingTime(){
1066
        return handlingTime;
1067
    }
7461 kshitij.so 1068
 
12449 kshitij.so 1069
    public void setCustomHandlingTime(String customHandlingTime){
1070
        logger.info("set custom handling time"+customHandlingTime);
1071
        this.customHandlingTime = customHandlingTime;
1072
    }
7461 kshitij.so 1073
 
12449 kshitij.so 1074
    public String getCustomHandlingTime(){
1075
        return customHandlingTime;
1076
    }
7524 kshitij.so 1077
 
12449 kshitij.so 1078
    public void setHoldInventory(String holdInventory){
1079
        this.holdInventory = holdInventory;
1080
    }
7524 kshitij.so 1081
 
12449 kshitij.so 1082
    public String getHoldInventory(){
1083
        return holdInventory;
1084
    }
7524 kshitij.so 1085
 
12449 kshitij.so 1086
    public void setDefaultInventory(String defaultInventory){
1087
        this.defaultInventory = defaultInventory;
1088
    }
7524 kshitij.so 1089
 
12449 kshitij.so 1090
    public String getDefaultInventory(){
1091
        return defaultInventory;
1092
    }
7524 kshitij.so 1093
 
12449 kshitij.so 1094
    public File getFile() {
1095
        return file;
1096
    }
7524 kshitij.so 1097
 
12449 kshitij.so 1098
    public void setFile(File file) {
1099
        this.file = file;
1100
    }
7283 kshitij.so 1101
 
12449 kshitij.so 1102
    public String getFileUploadContentType() {
1103
        return fileUploadContentType;
1104
    }
8168 kshitij.so 1105
 
12449 kshitij.so 1106
    public void setFileUploadContentType(String fileUploadContentType) {
1107
        this.fileUploadContentType = fileUploadContentType;
1108
    }
8168 kshitij.so 1109
 
12449 kshitij.so 1110
    public String getFileUploadFileName() {
1111
        return fileUploadFileName;
1112
    }
8168 kshitij.so 1113
 
12449 kshitij.so 1114
    public void setFileUploadFileName(String fileUploadFileName) {
1115
        this.fileUploadFileName = fileUploadFileName;
1116
    }
8168 kshitij.so 1117
 
12449 kshitij.so 1118
    public void setServletRequest(HttpServletRequest req) {
1119
        this.request = req;
1120
        this.session = req.getSession();        
1121
    }
8168 kshitij.so 1122
 
12449 kshitij.so 1123
    @Override
1124
    public void setServletContext(ServletContext arg0) {
1125
        // TODO Auto-generated method stub
8168 kshitij.so 1126
 
12449 kshitij.so 1127
    }
8362 kshitij.so 1128
 
1129
 
12449 kshitij.so 1130
    public void setSuppressMfnPriceUpdate(String suppressMfnPriceUpdate) {
1131
        this.suppressMfnPriceUpdate = suppressMfnPriceUpdate;
1132
    }
8620 kshitij.so 1133
 
12449 kshitij.so 1134
    public String getSuppressMfnPriceUpdate() {
1135
        return suppressMfnPriceUpdate;
1136
    }
8362 kshitij.so 1137
 
12449 kshitij.so 1138
    public void setSuppressFbaPriceUpdate(String suppressFbaPriceUpdate) {
1139
        this.suppressFbaPriceUpdate = suppressFbaPriceUpdate;
1140
    }
8620 kshitij.so 1141
 
12449 kshitij.so 1142
    public String getSuppressFbaPriceUpdate() {
1143
        return suppressFbaPriceUpdate;
1144
    }
8620 kshitij.so 1145
 
12449 kshitij.so 1146
    public void setErrMsg(String errMsg) {
1147
        this.errMsg = errMsg;
1148
    }
8620 kshitij.so 1149
 
12449 kshitij.so 1150
    public String getErrMsg() {
1151
        return errMsg;
1152
    }
8620 kshitij.so 1153
 
12449 kshitij.so 1154
    public void setServletResponse(HttpServletResponse response) {
1155
        this.response = response;
1156
    }
8620 kshitij.so 1157
 
12449 kshitij.so 1158
    public void setNext(String next) {
1159
        logger.info("next is"+next);
1160
        this.next = next;
1161
    }
8620 kshitij.so 1162
 
12449 kshitij.so 1163
    public String getNext() {
1164
        return next;
1165
    }
8620 kshitij.so 1166
 
12449 kshitij.so 1167
    public void setAmazonItems(List<Amazonlisted> amazonItems) {
1168
        this.amazonItems = amazonItems;
1169
    }
8620 kshitij.so 1170
 
12449 kshitij.so 1171
    public List<Amazonlisted> getAmazonItems() {
1172
        return amazonItems;
1173
    }
8620 kshitij.so 1174
 
12449 kshitij.so 1175
    public void setSearchText(String searchText) {
1176
        this.searchText = searchText;
1177
    }
8620 kshitij.so 1178
 
12449 kshitij.so 1179
    public String getSearchText() {
1180
        return searchText;
1181
    }
8620 kshitij.so 1182
 
12449 kshitij.so 1183
    public long getSearchCount() {
1184
        return searchCount;
1185
    }
1186
 
1187
    public long getTotalCount() {
1188
        return totalCount;
1189
    }
1190
 
1191
    public void setSearchCount(long count) {
1192
        this.searchCount = count;
1193
    }
1194
 
1195
    public void setTaxCode(String taxCode) {
1196
        this.taxCode = taxCode;
1197
    }
1198
 
1199
    public String getTaxCode() {
1200
        return taxCode;
1201
    }
1202
 
10922 kshitij.so 1203
    public void setFbbTaxCode(String fbbTaxCode) {
1204
        this.fbbTaxCode = fbbTaxCode;
1205
    }
1206
 
1207
    public String get() {
1208
        return fbbTaxCode;
1209
    }
1210
 
1211
    public void setIsFbb(String isFbb) {
1212
        this.isFbb = isFbb;
1213
    }
1214
 
1215
    public String getIsFbb() {
1216
        return isFbb;
1217
    }
1218
 
1219
    public void setFbbPrice(String fbbPrice) {
1220
        this.fbbPrice = fbbPrice;
1221
    }
1222
 
1223
    public String getFbbPrice() {
1224
        return fbbPrice;
1225
    }
1226
 
1227
    public void setSuppressFbbPriceUpdate(String suppressFbbPriceUpdate) {
1228
        this.suppressFbbPriceUpdate = suppressFbbPriceUpdate;
1229
    }
1230
 
1231
    public String getSuppressFbbPriceUpdate() {
1232
        return suppressFbbPriceUpdate;
1233
    }
1234
 
12449 kshitij.so 1235
    public String getStartDate() {
1236
        return startDate;
1237
    }
1238
 
1239
    public void setStartDate(String startDate) {
1240
        this.startDate = startDate;
1241
    }
1242
 
1243
    public String getEndDate() {
1244
        return endDate;
1245
    }
1246
 
1247
    public void setEndDate(String endDate) {
1248
        this.endDate = endDate;
1249
    }
1250
 
1251
    public void setPromotionResult(List<AmazonPromotion> promotionResult) {
1252
        this.promotionResult = promotionResult;
1253
    }
1254
 
1255
    public List<AmazonPromotion> getPromotionResult() {
1256
        return promotionResult;
1257
    }
1258
 
1259
    public String getPromotionType() {
1260
        return promotionType;
1261
    }
1262
 
1263
    public void setPromotionType(String promotionType) {
1264
        this.promotionType = promotionType;
1265
    }
1266
 
1267
    public String getOverrrideWanlc() {
1268
        return overrrideWanlc;
1269
    }
1270
 
1271
    public void setOverrrideWanlc(String overrrideWanlc) {
1272
        this.overrrideWanlc = overrrideWanlc;
1273
    }
1274
 
1275
    public String getExceptionalWanlc() {
1276
        return exceptionalWanlc;
1277
    }
1278
 
1279
    public void setExceptionalWanlc(String exceptionalWanlc) {
1280
        this.exceptionalWanlc = exceptionalWanlc;
1281
    }
1282
 
12661 kshitij.so 1283
    public void setFbaPromoPrice(String fbaPromoPrice) {
1284
        this.fbaPromoPrice = fbaPromoPrice;
1285
    }
1286
 
1287
    public String getFbaPromoPrice() {
1288
        return fbaPromoPrice;
1289
    }
1290
 
1291
    public void setFbbPromoPrice(String fbbPromoPrice) {
1292
        this.fbbPromoPrice = fbbPromoPrice;
1293
    }
1294
 
1295
    public String getFbbPromoPrice() {
1296
        return fbbPromoPrice;
1297
    }
1298
 
1299
    public void setPromoItemId(String promoItemId) {
1300
        this.promoItemId = promoItemId;
1301
    }
1302
 
1303
    public String getPromoItemId() {
1304
        return promoItemId;
1305
    }
12675 kshitij.so 1306
 
1307
    public String getIsFbaPromotionActive() {
1308
        return isFbaPromotionActive;
1309
    }
12661 kshitij.so 1310
 
12675 kshitij.so 1311
    public void setIsFbaPromotionActive(String isFbaPromotionActive) {
1312
        this.isFbaPromotionActive = isFbaPromotionActive;
1313
    }
1314
 
1315
    public String getIsFbbPromotionActive() {
1316
        return isFbbPromotionActive;
1317
    }
1318
 
1319
    public void setIsFbbPromotionActive(String isFbbPromotionActive) {
1320
        this.isFbbPromotionActive = isFbbPromotionActive;
1321
    }
1322
 
12889 kshitij.so 1323
    public void setFbgTaxCode(String fbgTaxCode) {
1324
        this.fbgTaxCode = fbgTaxCode;
1325
    }
1326
 
1327
    public String getFbgTaxCode() {
1328
        return fbgTaxCode;
1329
    }
1330
 
1331
    public void setIsFbg(String isFbg) {
1332
        this.isFbg = isFbg;
1333
    }
1334
 
1335
    public String getIsFbg() {
1336
        return isFbg;
1337
    }
1338
 
1339
    public void setFbgPrice(String fbgPrice) {
1340
        this.fbgPrice = fbgPrice;
1341
    }
1342
 
1343
    public String getFbgPrice() {
1344
        return fbgPrice;
1345
    }
1346
 
1347
    public void setSuppressFbgPriceUpdate(String suppressFbgPriceUpdate) {
1348
        this.suppressFbgPriceUpdate = suppressFbgPriceUpdate;
1349
    }
1350
 
1351
    public String getSuppressFbgPriceUpdate() {
1352
        return suppressFbgPriceUpdate;
1353
    }
1354
 
1355
    public void setFbgPromoPrice(String fbgPromoPrice) {
1356
        this.fbgPromoPrice = fbgPromoPrice;
1357
    }
1358
 
1359
    public String getFbgPromoPrice() {
1360
        return fbgPromoPrice;
1361
    }
1362
 
1363
    public void setIsFbgPromotionActive(String isFbgPromotionActive) {
1364
        this.isFbgPromotionActive = isFbgPromotionActive;
1365
    }
1366
 
1367
    public String getIsFbgPromotionActive() {
1368
        return isFbgPromotionActive;
1369
    }
1370
 
7283 kshitij.so 1371
}