Subversion Repositories SmartDukaan

Rev

Rev 9331 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9331 Rev 9332
Line 71... Line 71...
71
	public String show() {
71
	public String show() {
72
		return "authsuccess";
72
		return "authsuccess";
73
	}
73
	}
74
	
74
	
75
	
75
	
76
	public String create() throws InventoryServiceException, TException, CatalogServiceException {
76
	public String create(){
77
		File fileToCreate = null;
77
		File fileToCreate = null;
78
        try {
78
        try {
79
            fileToCreate = new File("/tmp/", this.pricingFileFileName);
79
            fileToCreate = new File("/tmp/", this.pricingFileFileName);
80
            FileUtils.copyFile(this.pricingFile, fileToCreate);
80
            FileUtils.copyFile(this.pricingFile, fileToCreate);
81
        } catch (Exception e) {
81
        } catch (Exception e) {
Line 107... Line 107...
107
        Client invClient = isc.getClient();
107
        Client invClient = isc.getClient();
108
        in.shop2020.model.v1.catalog.CatalogService.Client catClient = csc.getClient(); 
108
        in.shop2020.model.v1.catalog.CatalogService.Client catClient = csc.getClient(); 
109
        Sheet sheet = wb.getSheetAt(0);
109
        Sheet sheet = wb.getSheetAt(0);
110
        Row firstRow = sheet.getRow(0);
110
        Row firstRow = sheet.getRow(0);
111
        logger.info("Last row number is:" + sheet.getLastRowNum());
111
        logger.info("Last row number is:" + sheet.getLastRowNum());
-
 
112
        int successful = 0, failed = 0;
112
        for (Row row : sheet) {
113
        for (Row row : sheet) {
113
            if(row.equals(firstRow))
114
            if(row.equals(firstRow))
114
                continue;
115
                continue;
115
            logger.info("Row no. " + row.getRowNum());
116
            logger.info("Row no. " + row.getRowNum());
116
            long itemId = (long)row.getCell(0).getNumericCellValue();
117
            long itemId = (long)row.getCell(0).getNumericCellValue();
Line 118... Line 119...
118
            double sellingPrice = Math.round(row.getCell(2).getNumericCellValue());
119
            double sellingPrice = Math.round(row.getCell(2).getNumericCellValue());
119
            double mop = Math.round(row.getCell(3).getNumericCellValue());
120
            double mop = Math.round(row.getCell(3).getNumericCellValue());
120
            double dealerPrice = Math.round(row.getCell(4).getNumericCellValue());
121
            double dealerPrice = Math.round(row.getCell(4).getNumericCellValue());
121
            double transferPrice = Math.round(row.getCell(5).getNumericCellValue());
122
            double transferPrice = Math.round(row.getCell(5).getNumericCellValue());
122
            double nlc = Math.round(row.getCell(6).getNumericCellValue());
123
            double nlc = Math.round(row.getCell(6).getNumericCellValue());
-
 
124
            try{
123
            Item item = catClient.getItem(itemId);
125
            	Item item = catClient.getItem(itemId);
124
            if(sellingPrice != item.getSellingPrice() || mrp != item.getMrp()){
126
            	if(sellingPrice != item.getSellingPrice() || mrp != item.getMrp()){
125
            	item.setSellingPrice(sellingPrice);
127
            		item.setSellingPrice(sellingPrice);
126
            	item.setMrp(mrp);
128
            		item.setMrp(mrp);
127
            	catClient.updateItem(item);
129
            		catClient.updateItem(item);
128
            }
130
            	}
129
            VendorItemPricing pricing = invClient.getItemPricing(itemId, vendorId);
131
            	VendorItemPricing pricing = invClient.getItemPricing(itemId, vendorId);
130
            pricing.setNlc(nlc);
132
            	pricing.setNlc(nlc);
131
            pricing.setTransferPrice(transferPrice);
133
            	pricing.setTransferPrice(transferPrice);
132
            pricing.setDealerPrice(dealerPrice);
134
            	pricing.setDealerPrice(dealerPrice);
133
            pricing.setMop(mop);
135
            	pricing.setMop(mop);
134
            invClient.addVendorItemPricing(pricing);
136
            	invClient.addVendorItemPricing(pricing);
-
 
137
            	successful++;
-
 
138
            } catch (Exception e) {
-
 
139
            	failed++;
-
 
140
            	addActionError(e.getMessage());
-
 
141
			}
135
        }
142
        }
136
        addActionMessage("Updated pricing for " +sheet.getLastRowNum() + " items");
143
        addActionMessage("Updated pricing for " + successful + " items");
-
 
144
        addActionError("Unable to update " + failed + " items and received following errors.");
137
        return "authsuccess";
145
        return "authsuccess";
138
	}
146
	}
139
 
147
 
140
	public File getPricingFile() {
148
	public File getPricingFile() {
141
        return pricingFile;
149
        return pricingFile;