Subversion Repositories SmartDukaan

Rev

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

Rev 9326 Rev 9328
Line 2... Line 2...
2
 
2
 
3
import java.io.File;
3
import java.io.File;
4
import java.io.FileInputStream;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
5
import java.io.FileNotFoundException;
6
import java.io.IOException;
6
import java.io.IOException;
-
 
7
import java.util.Collection;
7
import java.util.List;
8
import java.util.List;
8
 
9
 
9
 
10
 
10
import in.shop2020.model.v1.catalog.CatalogServiceException;
11
import in.shop2020.model.v1.catalog.CatalogServiceException;
11
import in.shop2020.model.v1.catalog.Item;
12
import in.shop2020.model.v1.catalog.Item;
Line 96... Line 97...
96
        
97
        
97
        InventoryClient isc = null;
98
        InventoryClient isc = null;
98
        CatalogClient csc = null;
99
        CatalogClient csc = null;
99
        try {
100
        try {
100
            isc = new InventoryClient();
101
            isc = new InventoryClient();
101
            csc = new CatalogClient();
102
            csc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
102
        } catch (TTransportException e) {
103
        } catch (TTransportException e) {
103
            logger.error("Unable to establish connection to the transaction service", e);
104
            logger.error("Unable to establish connection to the transaction service", e);
104
            addActionError("Unable to establish connection to the transaction service");
105
            addActionError("Unable to establish connection to the transaction service");
105
        }
106
        }
106
        Client invClient = isc.getClient();
107
        Client invClient = isc.getClient();
Line 113... Line 114...
113
                continue;
114
                continue;
114
            logger.info("Row no. " + row.getRowNum());
115
            logger.info("Row no. " + row.getRowNum());
115
            long itemId = (long)row.getCell(0).getNumericCellValue();
116
            long itemId = (long)row.getCell(0).getNumericCellValue();
116
            double mrp = row.getCell(1).getNumericCellValue();
117
            double mrp = row.getCell(1).getNumericCellValue();
117
            double sellingPrice = row.getCell(2).getNumericCellValue();
118
            double sellingPrice = row.getCell(2).getNumericCellValue();
118
            double dealerPrice = row.getCell(3).getNumericCellValue();
119
            double mop = row.getCell(3).getNumericCellValue();
119
            double mop = row.getCell(4).getNumericCellValue();
120
            double dealerPrice = row.getCell(4).getNumericCellValue();
120
            double transferPrice = row.getCell(5).getNumericCellValue();
121
            double transferPrice = row.getCell(5).getNumericCellValue();
121
            double nlc = row.getCell(6).getNumericCellValue();
122
            double nlc = row.getCell(6).getNumericCellValue();
122
            Item item = catClient.getItem(itemId);
123
            Item item = catClient.getItem(itemId);
-
 
124
            if(sellingPrice != item.getSellingPrice() || mrp != item.getMrp()){
123
            item.setSellingPrice(sellingPrice);
125
            	item.setSellingPrice(sellingPrice);
124
            item.setMrp(mrp);
126
            	item.setMrp(mrp);
125
            catClient.updateItem(item);
127
            	catClient.updateItem(item);
-
 
128
            }
126
            VendorItemPricing pricing = invClient.getItemPricing(itemId, vendorId);
129
            VendorItemPricing pricing = invClient.getItemPricing(itemId, vendorId);
127
            pricing.setNlc(nlc);
130
            pricing.setNlc(nlc);
128
            pricing.setTransferPrice(transferPrice);
131
            pricing.setTransferPrice(transferPrice);
129
            pricing.setDealerPrice(dealerPrice);
132
            pricing.setDealerPrice(dealerPrice);
130
            pricing.setMop(mop);
133
            pricing.setMop(mop);
131
            invClient.addVendorItemPricing(pricing);
134
            invClient.addVendorItemPricing(pricing);
132
        }
135
        }
-
 
136
        addActionMessage("Updated pricing for " +sheet.getLastRowNum() + " items");
133
        return "authsuccess";
137
        return "authsuccess";
134
	}
138
	}
135
 
139
 
136
	public File getPricingFile() {
140
	public File getPricingFile() {
137
        return pricingFile;
141
        return pricingFile;
Line 153... Line 157...
153
	public void setServletRequest(HttpServletRequest request) {
157
	public void setServletRequest(HttpServletRequest request) {
154
		this.request = request;
158
		this.request = request;
155
		this.session = request.getSession();
159
		this.session = request.getSession();
156
	}
160
	}
157
 
161
 
158
 
-
 
159
	public String getErrorMsg(){
162
	public String getErrorMsg(){
-
 
163
		Collection<String> actionErrors = getActionErrors();
-
 
164
        if(actionErrors != null && !actionErrors.isEmpty()){
-
 
165
            for (String str : actionErrors) {
-
 
166
                errorMsg += "<BR/>" + str;
-
 
167
            }   
-
 
168
        }
160
		return this.errorMsg;
169
        return this.errorMsg;
-
 
170
	}
-
 
171
 
-
 
172
	public String getSuccessMsg(){
-
 
173
		String successMsg = "";
-
 
174
		Collection<String> actionMessages = getActionMessages();
-
 
175
        if(actionMessages != null && !actionMessages.isEmpty()){
-
 
176
            for (String str : actionMessages) {
-
 
177
            	successMsg += "<BR/>" + str;
-
 
178
            }   
-
 
179
        }
-
 
180
        return successMsg;
161
	}
181
	}
162
 
182
 
163
	public long getVendorId() {
183
	public long getVendorId() {
164
		return vendorId;
184
		return vendorId;
165
	}
185
	}
166
 
186
 
167
	public void setVendorId(long vendorId) {
187
	public void setVendorId(long vendorId) {
168
		this.vendorId = vendorId;
188
		this.vendorId = vendorId;
169
	}
189
	}
170
 
190
 
171
 
-
 
172
	public void setId(String id) {
191
	public void setId(String id) {
173
		this.id = id;
192
		this.id = id;
174
	}
193
	}
175
 
194
 
176
	public String getId() {
195
	public String getId() {