Subversion Repositories SmartDukaan

Rev

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

Rev 7735 Rev 7784
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
-
 
3
import in.shop2020.logistics.LogisticsLocationInfo;
3
import in.shop2020.logistics.LogisticsService.Client;
4
import in.shop2020.logistics.LogisticsService.Client;
4
//Start:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
5
//Start:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
5
import in.shop2020.support.utils.ReportsUtils;
6
import in.shop2020.support.utils.ReportsUtils;
6
//End:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
7
//End:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
7
import in.shop2020.thrift.clients.LogisticsClient;
8
import in.shop2020.thrift.clients.LogisticsClient;
Line 26... Line 27...
26
//Start:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
27
//Start:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
27
import java.io.File;
28
import java.io.File;
28
import java.io.FileInputStream;
29
import java.io.FileInputStream;
29
import java.io.FileNotFoundException;
30
import java.io.FileNotFoundException;
30
import java.io.IOException;
31
import java.io.IOException;
-
 
32
import java.util.ArrayList;
31
import java.util.Collection;
33
import java.util.Collection;
32
import java.util.Iterator;
34
import java.util.Iterator;
33
//End:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
35
//End:- Added/Modified by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
-
 
36
import java.util.List;
34
 
37
 
35
@SuppressWarnings("serial")
38
@SuppressWarnings("serial")
36
public class PincodeController extends ActionSupport implements ServletRequestAware {
39
public class PincodeController extends ActionSupport implements ServletRequestAware {
37
	
40
	
38
	private Long provider;
41
	private Long provider;
Line 110... Line 113...
110
	        	logger.error("Supplied Data is not in specified form. Please check the file format",e);
113
	        	logger.error("Supplied Data is not in specified form. Please check the file format",e);
111
	        	addActionError("Supplied Data is not in specified form. Please check the file format");
114
	        	addActionError("Supplied Data is not in specified form. Please check the file format");
112
	        }
115
	        }
113
	        if(checkForErrors())
116
	        if(checkForErrors())
114
	            return "Error in updation";
117
	            return "Error in updation";
115
	        try{
-
 
116
		        Client logisticsClient = new LogisticsClient().getClient();
-
 
117
		        if(runCompleteUpdateValue){
-
 
118
		        	logisticsClient.runCompleteUpdateForPincode();
-
 
119
		        }
-
 
120
	        }
118
	        
121
	        catch (TException e) {
-
 
122
                logger.error("Unable to complete the operation", e);
-
 
123
                addActionError(e.getMessage());
-
 
124
            }
-
 
125
	        if(checkForErrors())
-
 
126
	            return "Error in updation";
-
 
127
	        HSSFSheet sheet= wb.getSheetAt(0);
119
	        HSSFSheet sheet= wb.getSheetAt(0);
128
	        Iterator<Row> rowIterator = sheet.rowIterator();
120
	        Iterator<Row> rowIterator = sheet.rowIterator();
129
	        int rowCount = 0;
121
	        int rowCount = 0;
-
 
122
	        List<LogisticsLocationInfo> logisticsLocationInfoList;
-
 
123
	        logisticsLocationInfoList = new ArrayList<LogisticsLocationInfo>();
130
	        while(rowIterator.hasNext()) {
124
	        while(rowIterator.hasNext()) {
131
	            Row row = rowIterator.next();
125
	            Row row = rowIterator.next();
132
	            if(rowCount++==0)
126
	            if(rowCount++==0)
133
	            	continue;
127
	            	continue;
134
	            Iterator<Cell> cellIterator = row.cellIterator();
128
	            Iterator<Cell> cellIterator = row.cellIterator();
135
	            int cellCount= 0;
129
	            int cellCount= 0;
-
 
130
	            LogisticsLocationInfo logisticsLocationInfo = new LogisticsLocationInfo();
136
	            while(cellIterator.hasNext()) {
131
	            while(cellIterator.hasNext()) {
137
	                 
132
	                 
138
	                Cell cell = cellIterator.next();
133
	                Cell cell = cellIterator.next();
139
	                String cellVal_Str ="";
134
	                String cellVal_Str ="";
140
	                Long cellVal_Num  = 0L;
135
	                Long cellVal_Num  = 0L;
Line 154... Line 149...
154
	                        System.out.print(cell.getStringCellValue() + "\t\t");
149
	                        System.out.print(cell.getStringCellValue() + "\t\t");
155
	                        break;
150
	                        break;
156
	                }
151
	                }
157
	                switch(cellCount) {
152
	                switch(cellCount) {
158
	                	case 0:
153
	                	case 0:
159
	                		provider = (long) cellVal_Num;
154
	                		logisticsLocationInfo.setProviderId((long) cellVal_Num);
160
	                		break;
155
	                		break;
161
	                	case 1:
156
	                	case 1:
162
	                		pincode = cellVal_Str.length() > 0 ? cellVal_Str : cellVal_Num +"";
157
	                		pincode = cellVal_Str.length() > 0 ? cellVal_Str : cellVal_Num +"";
-
 
158
	                		logisticsLocationInfo.setPinCode(pincode);
163
	                		break;
159
	                		break;
164
	                	case 2:
160
	                	case 2:
165
	                		destCode = cellVal_Str.length() > 0 ? cellVal_Str : cellVal_Num +"";
161
	                		destCode = cellVal_Str.length() > 0 ? cellVal_Str : cellVal_Num +"";
-
 
162
	                		logisticsLocationInfo.setDestinationCode(destCode);
166
	                		break;
163
	                		break;
167
	                	case 3:
164
	                	case 3:
168
	                		if(cellVal_Num==0L)
165
	                		if(cellVal_Num==0L)
169
	                			expService = false;
166
	                			expService = false;
170
	                		else if(cellVal_Num==1L)
167
	                		else if(cellVal_Num==1L)
171
	                			expService = true;
168
	                			expService = true;
172
	                		else 
169
	                		else 
173
	                			expService = false;
170
	                			expService = false;
-
 
171
	                		logisticsLocationInfo.setExpAvailable(expService);
174
	                		break;
172
	                		break;
175
	                	case 4:
173
	                	case 4:
176
	                		if(cellVal_Num==0L)
174
	                		if(cellVal_Num==0L)
177
	                			codService = false;
175
	                			codService = false;
178
	                		else if(cellVal_Num==1L)
176
	                		else if(cellVal_Num==1L)
179
	                			codService = true;
177
	                			codService = true;
180
	                		else 
178
	                		else 
181
	                			codService = false;
179
	                			codService = false;
-
 
180
	                		logisticsLocationInfo.setCodAvailable(codService);
182
	                		break;
181
	                		break;
183
	                	case 5:
182
	                	case 5:
184
	                		stationType_int = Integer.parseInt(cellVal_Num.toString());
-
 
185
	                		break;
-
 
186
	                	case 6:
-
 
187
	                		if(cellVal_Num==0L)
183
	                		if(cellVal_Num==0L)
188
	                			otgService = false;
184
	                			otgService = false;
189
	                		else if(cellVal_Num==1L)
185
	                		else if(cellVal_Num==1L)
190
	                			otgService = true;
186
	                			otgService = true;
191
	                		else 
187
	                		else 
192
	                			otgService = false;
188
	                			otgService = false;
-
 
189
	                		logisticsLocationInfo.setOtgAvailable(otgService);
-
 
190
	                		break;
-
 
191
	                	case 6:
-
 
192
	                		logisticsLocationInfo.setCodLimit((long) cellVal_Num);
-
 
193
	                		break;
-
 
194
	                	case 7:
-
 
195
	                		logisticsLocationInfo.setPrepaidLimit((long) cellVal_Num);
-
 
196
	                		break;
-
 
197
	                	case 8:
-
 
198
	                		logisticsLocationInfo.setWarehouseId((long) cellVal_Num);
-
 
199
	                		break;
-
 
200
	                	case 9:
-
 
201
	                		logisticsLocationInfo.setDeliveryTime((long) cellVal_Num);
-
 
202
	                		break;
-
 
203
	                	case 10:
-
 
204
	                		logisticsLocationInfo.setDelivery_delay((long) cellVal_Num);
193
	                		break;
205
	                		break;
194
	                }
206
	                }
195
	               cellCount++;
207
	               cellCount++;
196
	            }
208
	            }
197
	            try{
-
 
198
	            	Client logisticsClient = new LogisticsClient().getClient();
209
	            logisticsLocationInfoList.add(logisticsLocationInfo);
199
		            boolean isRecordAvaliable = logisticsClient.getServiceableLocationAsPerProviderIdAndPincode(provider, pincode);
-
 
200
	                if(isRecordAvaliable){
-
 
201
	                	logisticsClient.updatePincode(provider, pincode, expService, codService, otgService);
-
 
202
	                }
-
 
203
	                else{
-
 
204
	                	logisticsClient.addPincode(provider, pincode, destCode, expService, codService, stationType_int, otgService);
-
 
205
	                }
-
 
206
	            }
-
 
207
	            catch (TException e) {
-
 
208
	                logger.error("Unable to update data", e);
-
 
209
	                addActionError(e.getMessage());
-
 
210
	            }
-
 
211
	            if(checkForErrors())
-
 
212
		            return "Error in updation";
-
 
213
	        }
210
	        }
-
 
211
	        try{
-
 
212
            	Client logisticsClient = new LogisticsClient().getClient();
-
 
213
	            logisticsClient.runLogisticsLocationInfoUpdate(logisticsLocationInfoList, runCompleteUpdateValue);
-
 
214
            }
-
 
215
            catch (TException e) {
-
 
216
                logger.error("Unable to update data", e);
-
 
217
                addActionError(e.getMessage());
-
 
218
            }
-
 
219
            if(checkForErrors())
-
 
220
	            return "Error in updation";
-
 
221
	        
214
		}
222
		}
215
		else{
223
		else{
216
			addActionError("Uncompatible File Format !!!");
224
			addActionError("Uncompatible File Format !!!");
217
			if(checkForErrors())
225
			if(checkForErrors())
218
	            return "Error in updation";
226
	            return "Error in updation";