| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.logistics.DeliveryType;
|
3 |
import in.shop2020.logistics.DeliveryType;
|
| 4 |
import in.shop2020.logistics.LogisticsServiceException;
|
4 |
import in.shop2020.logistics.LogisticsServiceException;
|
| - |
|
5 |
import in.shop2020.logistics.PickupStore;
|
| 5 |
import in.shop2020.logistics.Provider;
|
6 |
import in.shop2020.logistics.Provider;
|
| - |
|
7 |
import in.shop2020.logistics.ProviderDetails;
|
| 6 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
8 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 7 |
import in.shop2020.model.v1.inventory.Warehouse;
|
9 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 8 |
import in.shop2020.model.v1.order.LineItem;
|
10 |
import in.shop2020.model.v1.order.LineItem;
|
| 9 |
import in.shop2020.model.v1.order.Order;
|
11 |
import in.shop2020.model.v1.order.Order;
|
| 10 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
12 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| Line 14... |
Line 16... |
| 14 |
import in.shop2020.thrift.clients.InventoryClient;
|
16 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 15 |
import in.shop2020.thrift.clients.LogisticsClient;
|
17 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 16 |
import in.shop2020.thrift.clients.TransactionClient;
|
18 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 17 |
import in.shop2020.utils.LogisticsUser;
|
19 |
import in.shop2020.utils.LogisticsUser;
|
| 18 |
|
20 |
|
| - |
|
21 |
import java.io.BufferedReader;
|
| 19 |
import java.io.ByteArrayOutputStream;
|
22 |
import java.io.ByteArrayOutputStream;
|
| 20 |
import java.io.File;
|
23 |
import java.io.File;
|
| - |
|
24 |
import java.io.FileNotFoundException;
|
| - |
|
25 |
import java.io.FileReader;
|
| 21 |
import java.io.IOException;
|
26 |
import java.io.IOException;
|
| - |
|
27 |
import java.text.ParseException;
|
| - |
|
28 |
import java.text.SimpleDateFormat;
|
| 22 |
import java.util.ArrayList;
|
29 |
import java.util.ArrayList;
|
| 23 |
import java.util.Calendar;
|
30 |
import java.util.Calendar;
|
| 24 |
import java.util.Date;
|
31 |
import java.util.Date;
|
| 25 |
import java.util.GregorianCalendar;
|
32 |
import java.util.GregorianCalendar;
|
| 26 |
import java.util.HashMap;
|
33 |
import java.util.HashMap;
|
| 27 |
import java.util.List;
|
34 |
import java.util.List;
|
| - |
|
35 |
import java.util.Locale;
|
| 28 |
import java.util.Map;
|
36 |
import java.util.Map;
|
| 29 |
|
37 |
|
| 30 |
import javax.servlet.ServletContext;
|
38 |
import javax.servlet.ServletContext;
|
| 31 |
import javax.servlet.ServletOutputStream;
|
39 |
import javax.servlet.ServletOutputStream;
|
| 32 |
import javax.servlet.http.HttpServletRequest;
|
40 |
import javax.servlet.http.HttpServletRequest;
|
| 33 |
import javax.servlet.http.HttpServletResponse;
|
41 |
import javax.servlet.http.HttpServletResponse;
|
| 34 |
import javax.servlet.http.HttpSession;
|
42 |
import javax.servlet.http.HttpSession;
|
| 35 |
|
43 |
|
| - |
|
44 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| - |
|
45 |
import org.apache.poi.ss.usermodel.Cell;
|
| - |
|
46 |
import org.apache.poi.ss.usermodel.CellStyle;
|
| - |
|
47 |
import org.apache.poi.ss.usermodel.CreationHelper;
|
| - |
|
48 |
import org.apache.poi.ss.usermodel.Row;
|
| - |
|
49 |
import org.apache.poi.ss.usermodel.Sheet;
|
| - |
|
50 |
import org.apache.poi.ss.usermodel.Workbook;
|
| 36 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
51 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 37 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
52 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
| 38 |
import org.apache.struts2.util.ServletContextAware;
|
53 |
import org.apache.struts2.util.ServletContextAware;
|
| 39 |
import org.apache.thrift.TException;
|
54 |
import org.apache.thrift.TException;
|
| 40 |
import org.apache.thrift.transport.TTransportException;
|
55 |
import org.apache.thrift.transport.TTransportException;
|
| Line 51... |
Line 66... |
| 51 |
public class CourierDetailsController implements ServletResponseAware,
|
66 |
public class CourierDetailsController implements ServletResponseAware,
|
| 52 |
ServletRequestAware, ServletContextAware {
|
67 |
ServletRequestAware, ServletContextAware {
|
| 53 |
|
68 |
|
| 54 |
private static Logger logger = LoggerFactory.getLogger(CourierDetailsController.class);
|
69 |
private static Logger logger = LoggerFactory.getLogger(CourierDetailsController.class);
|
| 55 |
|
70 |
|
| - |
|
71 |
private static final String EMPTY_STRING = "-";
|
| - |
|
72 |
|
| 56 |
private String id;
|
73 |
private String id;
|
| 57 |
private int daysToSubtract;
|
74 |
private int daysToSubtract;
|
| 58 |
|
75 |
|
| 59 |
//FIXME: Read this configuration from the config client
|
76 |
//FIXME: Read this configuration from the config client
|
| 60 |
private String courierDetailsPath = "/CourierDetailReports";
|
77 |
private String courierDetailsPath = "/CourierDetailReports";
|
| Line 66... |
Line 83... |
| 66 |
|
83 |
|
| 67 |
private String awbNumbers;
|
84 |
private String awbNumbers;
|
| 68 |
private List<AwbDetails> detailedAWBs;
|
85 |
private List<AwbDetails> detailedAWBs;
|
| 69 |
|
86 |
|
| 70 |
private String errorMsg = "";
|
87 |
private String errorMsg = "";
|
| - |
|
88 |
|
| - |
|
89 |
private File awbFile;
|
| - |
|
90 |
private String awbFileContentType;
|
| - |
|
91 |
private String awbFileFileName;
|
| 71 |
|
92 |
|
| 72 |
public String index(){
|
93 |
public String index(){
|
| 73 |
if(getSessionUserName()==null)
|
94 |
if(getSessionUserName()==null)
|
| 74 |
return "authfail";
|
95 |
return "authfail";
|
| 75 |
else
|
96 |
else
|
| Line 116... |
Line 137... |
| 116 |
response.setContentType("application/vnd.ms-excel");
|
137 |
response.setContentType("application/vnd.ms-excel");
|
| 117 |
|
138 |
|
| 118 |
Calendar date = new GregorianCalendar();
|
139 |
Calendar date = new GregorianCalendar();
|
| 119 |
date.add(Calendar.DAY_OF_MONTH, daysToSubtract);
|
140 |
date.add(Calendar.DAY_OF_MONTH, daysToSubtract);
|
| 120 |
int year = date.get(Calendar.YEAR);
|
141 |
int year = date.get(Calendar.YEAR);
|
| 121 |
int month = date.get(Calendar.MONTH) +1;
|
142 |
int month = date.get(Calendar.MONTH) + 1;
|
| 122 |
int day = date.get(Calendar.DAY_OF_MONTH);
|
143 |
int day = date.get(Calendar.DAY_OF_MONTH);
|
| 123 |
String fileName = courierDetailsPath + "/courier-details-" + deliveryType + "-" + warehouseId + "-" + providerId + "-" + year + "-" + month + "-" + day +".xls";
|
144 |
String fileName = courierDetailsPath + "/courier-details-" + deliveryType + "-" + warehouseId + "-" + providerId + "-" + year + "-" + month + "-" + day +".xls";
|
| 124 |
response.setHeader("Content-disposition", "inline; filename=courier-details-" + deliveryType + "-" + warehouseId + "-" + providerId + "-" + year + "-"+ month + "-" + day +".xls" );
|
145 |
response.setHeader("Content-disposition", "inline; filename=courier-details-" + deliveryType + "-" + warehouseId + "-" + providerId + "-" + year + "-"+ month + "-" + day +".xls" );
|
| 125 |
|
146 |
|
| 126 |
ServletOutputStream sos;
|
147 |
ServletOutputStream sos;
|
| Line 138... |
Line 159... |
| 138 |
logger.error("Unable to parse the warehouse id", nfe);
|
159 |
logger.error("Unable to parse the warehouse id", nfe);
|
| 139 |
}
|
160 |
}
|
| 140 |
return "authfail";
|
161 |
return "authfail";
|
| 141 |
}
|
162 |
}
|
| 142 |
|
163 |
|
| 143 |
public static void main(String[] args) {
|
- |
|
| 144 |
CourierDetailsController cdc = new CourierDetailsController();
|
- |
|
| 145 |
cdc.setAwbNumbers("4340987735");
|
- |
|
| 146 |
String msg = cdc.getAwbDetails();
|
- |
|
| 147 |
System.out.println(msg);
|
- |
|
| 148 |
//58539182004
|
- |
|
| 149 |
//43726980393
|
- |
|
| 150 |
}
|
- |
|
| 151 |
|
- |
|
| 152 |
/**
|
164 |
/**
|
| 153 |
* Use this method to get details of a given awb number
|
165 |
* Use this method to view details of a given awb number
|
| 154 |
*/
|
166 |
*/
|
| 155 |
public String getAwbDetails() {
|
167 |
public String viewAwbDetails() {
|
| 156 |
Order order = null;
|
- |
|
| 157 |
if(awbNumbers.isEmpty()) {
|
168 |
if(awbNumbers.isEmpty()) {
|
| 158 |
setErrorMsg("Field cannot be empty");
|
169 |
setErrorMsg("Field cannot be empty");
|
| 159 |
return "info";
|
170 |
return "info";
|
| 160 |
}
|
171 |
}
|
| 161 |
List<AwbDetails> tempList = new ArrayList<AwbDetails>() ;
|
- |
|
| 162 |
String [] awbArray = awbNumbers.split(",");
|
172 |
String [] awbArray = awbNumbers.split(",");
|
| - |
|
173 |
createAwbDetailList(awbArray);
|
| - |
|
174 |
return "info";
|
| - |
|
175 |
}
|
| - |
|
176 |
|
| - |
|
177 |
/**
|
| - |
|
178 |
* Use this method to download details of given comma separated list of awb numbers
|
| - |
|
179 |
*/
|
| - |
|
180 |
|
| - |
|
181 |
public String getAwbDetails() {
|
| - |
|
182 |
if(awbNumbers.isEmpty()) {
|
| - |
|
183 |
setErrorMsg("Field cannot be empty");
|
| - |
|
184 |
return "info";
|
| - |
|
185 |
}
|
| - |
|
186 |
String [] awbArray = awbNumbers.split(",");
|
| - |
|
187 |
createAwbDetailList(awbArray);
|
| - |
|
188 |
ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
|
| - |
|
189 |
response.setContentType("application/vnd.ms-excel");
|
| - |
|
190 |
response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
|
| - |
|
191 |
ServletOutputStream sos;
|
| - |
|
192 |
try {
|
| - |
|
193 |
sos = response.getOutputStream();
|
| - |
|
194 |
baos.writeTo(sos);
|
| - |
|
195 |
sos.flush();
|
| - |
|
196 |
} catch (IOException e) {
|
| - |
|
197 |
logger.error("Encountered error while sending invoice response: ", e);
|
| - |
|
198 |
}
|
| - |
|
199 |
return "info";
|
| - |
|
200 |
}
|
| - |
|
201 |
|
| - |
|
202 |
/**
|
| - |
|
203 |
* Use this method to download details of given list of awb numbers uploaded in a text file
|
| - |
|
204 |
*/
|
| - |
|
205 |
|
| - |
|
206 |
public String getAwbDetailsByFile() {
|
| - |
|
207 |
if(awbFile == null) {
|
| - |
|
208 |
return null;
|
| - |
|
209 |
}
|
| - |
|
210 |
|
| - |
|
211 |
List<String> awbList = new ArrayList<String>();
|
| - |
|
212 |
|
| - |
|
213 |
try {
|
| - |
|
214 |
BufferedReader in = new BufferedReader(new FileReader(awbFile));
|
| - |
|
215 |
String line;
|
| - |
|
216 |
while((line = in.readLine()) != null) {
|
| - |
|
217 |
awbList.add(line.trim());
|
| - |
|
218 |
}
|
| - |
|
219 |
} catch (FileNotFoundException e1) {
|
| - |
|
220 |
logger.error("File not found", e1);
|
| - |
|
221 |
return null;
|
| - |
|
222 |
} catch (IOException e) {
|
| - |
|
223 |
logger.error("Unable to read file", e);
|
| - |
|
224 |
return null;
|
| - |
|
225 |
}
|
| - |
|
226 |
|
| - |
|
227 |
String[] awbArray = awbList.toArray(new String [awbList.size()]);
|
| - |
|
228 |
createAwbDetailList(awbArray);
|
| - |
|
229 |
|
| - |
|
230 |
ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
|
| - |
|
231 |
response.setContentType("application/vnd.ms-excel");
|
| - |
|
232 |
response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
|
| - |
|
233 |
ServletOutputStream sos;
|
| - |
|
234 |
try {
|
| - |
|
235 |
sos = response.getOutputStream();
|
| - |
|
236 |
baos.writeTo(sos);
|
| - |
|
237 |
sos.flush();
|
| - |
|
238 |
} catch (IOException e) {
|
| - |
|
239 |
logger.error("Encountered error while sending invoice response: ", e);
|
| - |
|
240 |
}
|
| - |
|
241 |
return "info";
|
| - |
|
242 |
}
|
| - |
|
243 |
|
| - |
|
244 |
private void createAwbDetailList(String[] awbArray) {
|
| - |
|
245 |
Order order = null;
|
| - |
|
246 |
List<AwbDetails> tempList = new ArrayList<AwbDetails>() ;
|
| 163 |
for(String awbNumber : awbArray) {
|
247 |
for(String awbNumber : awbArray) {
|
| 164 |
try {
|
248 |
try {
|
| 165 |
LogisticsClient lsc = new LogisticsClient();
|
249 |
LogisticsClient lsc = new LogisticsClient();
|
| 166 |
TransactionClient tsc = new TransactionClient();
|
250 |
TransactionClient tsc = new TransactionClient();
|
| 167 |
InventoryClient isc = new InventoryClient();
|
251 |
InventoryClient isc = new InventoryClient();
|
| Line 175... |
Line 259... |
| 175 |
*/
|
259 |
*/
|
| 176 |
Provider provider = logisticsClient.getProvider(((Long)session.getAttribute("providerId")).longValue());
|
260 |
Provider provider = logisticsClient.getProvider(((Long)session.getAttribute("providerId")).longValue());
|
| 177 |
order = txnClient.getOrderForAwb(awbNumber);
|
261 |
order = txnClient.getOrderForAwb(awbNumber);
|
| 178 |
Warehouse warehouse = inventoryClient.getWarehouse(order.getWarehouse_id());
|
262 |
Warehouse warehouse = inventoryClient.getWarehouse(order.getWarehouse_id());
|
| 179 |
|
263 |
|
| 180 |
String accountNo;
|
264 |
String accountNo = "";
|
| - |
|
265 |
|
| - |
|
266 |
DeliveryType dt = DeliveryType.PREPAID;
|
| 181 |
if(order.isLogisticsCod())
|
267 |
if (order.isLogisticsCod()) {
|
| 182 |
accountNo = provider.getDetails().get(DeliveryType.COD).getAccountNo();
|
268 |
dt = DeliveryType.COD;
|
| 183 |
else
|
269 |
}
|
| 184 |
accountNo = provider.getDetails().get(DeliveryType.PREPAID).getAccountNo();
|
- |
|
| 185 |
|
270 |
|
| - |
|
271 |
for (ProviderDetails detail : provider.getDetails()) {
|
| - |
|
272 |
if(in.shop2020.model.v1.inventory.WarehouseLocation.findByValue((int) detail.getLogisticLocation()) == warehouse.getLogisticsLocation() && detail.getDeliveryType() == dt) {
|
| - |
|
273 |
accountNo = detail.getAccountNo();
|
| - |
|
274 |
}
|
| - |
|
275 |
}
|
| - |
|
276 |
|
| 186 |
AwbDetails detailedAwb = new AwbDetails();
|
277 |
AwbDetails detailedAwb = new AwbDetails();
|
| 187 |
|
278 |
|
| - |
|
279 |
String[] addresses = warehouse.getLocation().split(",+");
|
| - |
|
280 |
|
| - |
|
281 |
for(int i = 0; i< addresses.length; i++) {
|
| - |
|
282 |
addresses[i] = addresses[i].trim();
|
| - |
|
283 |
}
|
| - |
|
284 |
|
| - |
|
285 |
detailedAwb.setReturnAddress1(addresses[0] + addresses[1]);
|
| - |
|
286 |
detailedAwb.setReturnAddress2(addresses[2]);
|
| - |
|
287 |
String line3 = "";
|
| - |
|
288 |
for(int i = 3; i<addresses.length; i++) {
|
| - |
|
289 |
line3 += addresses[i];
|
| - |
|
290 |
}
|
| - |
|
291 |
detailedAwb.setReturnAddress3(line3);
|
| - |
|
292 |
detailedAwb.setReturnPin(warehouse.getPincode());
|
| 188 |
detailedAwb.setAwbNumber(awbNumber);
|
293 |
detailedAwb.setAwbNumber(awbNumber);
|
| 189 |
detailedAwb.setAccountCode(accountNo);
|
294 |
detailedAwb.setAccountCode(accountNo);
|
| - |
|
295 |
detailedAwb.setVendorCode((int) order.getWarehouse_id());
|
| 190 |
detailedAwb.setAddress1(order.getCustomer_address1());
|
296 |
detailedAwb.setAddress1(order.getCustomer_address1());
|
| 191 |
detailedAwb.setAddress2(order.getCustomer_address2());
|
297 |
detailedAwb.setAddress2(order.getCustomer_address2());
|
| 192 |
if(order.isLogisticsCod()){
|
298 |
if(order.isLogisticsCod()){
|
| 193 |
detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()));
|
299 |
detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
|
| 194 |
} else {
|
300 |
} else {
|
| 195 |
detailedAwb.setAmountToCollect("" + 0 );
|
301 |
detailedAwb.setAmountToCollect("" + 0 );
|
| 196 |
}
|
302 |
}
|
| 197 |
Date date = new Date(order.getPickup_timestamp());
|
303 |
Date date = new Date(order.getPickup_timestamp());
|
| 198 |
detailedAwb.setAwbDate(date.toString());
|
304 |
detailedAwb.setAwbDate(date.toString());
|
| 199 |
detailedAwb.setCity(order.getCustomer_city());
|
305 |
detailedAwb.setCity(order.getCustomer_city());
|
| 200 |
detailedAwb.setCustomerName(order.getCustomer_name());
|
306 |
detailedAwb.setCustomerName(order.getCustomer_name());
|
| 201 |
detailedAwb.setItemId("" + order.getLineitems().get(0).getId());
|
307 |
detailedAwb.setItemId("" + order.getLineitems().get(0).getItem_id());
|
| 202 |
detailedAwb.setOrderId("" + order.getId());
|
308 |
detailedAwb.setOrderId("" + order.getId());
|
| 203 |
detailedAwb.setPacketWeight("" + order.getTotal_weight());
|
309 |
detailedAwb.setPacketWeight("" + order.getTotal_weight());
|
| 204 |
if(order.isLogisticsCod()){
|
310 |
if(order.isLogisticsCod()){
|
| 205 |
detailedAwb.setPaymentMode("COD");
|
311 |
detailedAwb.setPaymentMode("COD");
|
| 206 |
} else {
|
312 |
} else {
|
| Line 209... |
Line 315... |
| 209 |
|
315 |
|
| 210 |
detailedAwb.setPhoneNumber("" + order.getCustomer_mobilenumber());
|
316 |
detailedAwb.setPhoneNumber("" + order.getCustomer_mobilenumber());
|
| 211 |
detailedAwb.setPickupLocation(warehouse.getLocation());
|
317 |
detailedAwb.setPickupLocation(warehouse.getLocation());
|
| 212 |
detailedAwb.setPinCode(order.getCustomer_pincode());
|
318 |
detailedAwb.setPinCode(order.getCustomer_pincode());
|
| 213 |
LineItem lineitem = order.getLineitems().get(0);
|
319 |
LineItem lineitem = order.getLineitems().get(0);
|
| 214 |
detailedAwb.setProductName(lineitem.getBrand() + " " + lineitem.getModel_name() + " "
|
320 |
detailedAwb.setProductName(lineitem.getBrand() + " "
|
| - |
|
321 |
+ (lineitem.getModel_name() == null ? "" : lineitem.getModel_name()) + " "
|
| - |
|
322 |
+ (lineitem.getModel_number() == null ? "" : lineitem.getModel_number()) + " "
|
| 215 |
+ lineitem.getItem_number() + " " + lineitem.getColor());
|
323 |
+ (lineitem.getColor() == null ? "" : lineitem.getColor()));
|
| 216 |
detailedAwb.setShipmentValue("" + (order.getTotal_amount()-order.getGvAmount()));
|
324 |
detailedAwb.setShipmentValue("" + (order.getTotal_amount()));
|
| 217 |
detailedAwb.setState(order.getCustomer_state());
|
325 |
detailedAwb.setState(order.getCustomer_state());
|
| 218 |
|
326 |
|
| 219 |
tempList.add(detailedAwb);
|
327 |
tempList.add(detailedAwb);
|
| 220 |
|
328 |
|
| 221 |
} catch (TTransportException e) {
|
329 |
} catch (TTransportException e) {
|
| Line 229... |
Line 337... |
| 229 |
} catch (InventoryServiceException e) {
|
337 |
} catch (InventoryServiceException e) {
|
| 230 |
setErrorMsg(e.getMessage());
|
338 |
setErrorMsg(e.getMessage());
|
| 231 |
}
|
339 |
}
|
| 232 |
setDetailedAWBs(tempList);
|
340 |
setDetailedAWBs(tempList);
|
| 233 |
}
|
341 |
}
|
| - |
|
342 |
}
|
| - |
|
343 |
|
| - |
|
344 |
|
| - |
|
345 |
public ByteArrayOutputStream generateAwbDetailsSheet(List<AwbDetails> awbDetailList) {
|
| - |
|
346 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();;
|
| - |
|
347 |
Workbook wb = new HSSFWorkbook();
|
| - |
|
348 |
CreationHelper createHelper = wb.getCreationHelper();
|
| - |
|
349 |
Sheet sheet = wb.createSheet("Saholic - Data");
|
| - |
|
350 |
|
| - |
|
351 |
CellStyle dateCellStyle = wb.createCellStyle();
|
| - |
|
352 |
dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("d/m/yyyy"));
|
| - |
|
353 |
|
| - |
|
354 |
CellStyle weightStyle = wb.createCellStyle();
|
| - |
|
355 |
weightStyle.setDataFormat(createHelper.createDataFormat().getFormat("0.000"));
|
| - |
|
356 |
|
| - |
|
357 |
Row headerRow = sheet.createRow((short)0);
|
| - |
|
358 |
headerRow.createCell(0).setCellValue("Airwaybill");
|
| - |
|
359 |
headerRow.createCell(1).setCellValue("Type"); //Values : "COD" / "NONCOD"
|
| - |
|
360 |
headerRow.createCell(2).setCellValue("Reference Number"); //OrderId
|
| - |
|
361 |
headerRow.createCell(3).setCellValue("Sender / Store name"); //"Spice Online retail pvt ltd"
|
| - |
|
362 |
headerRow.createCell(4).setCellValue("attention"); //Customer name
|
| - |
|
363 |
headerRow.createCell(5).setCellValue("address1"); //Line 1
|
| - |
|
364 |
headerRow.createCell(6).setCellValue("address2"); //Line 2
|
| - |
|
365 |
headerRow.createCell(7).setCellValue("address3"); //city + state
|
| - |
|
366 |
headerRow.createCell(8).setCellValue("pincode");
|
| - |
|
367 |
headerRow.createCell(9).setCellValue("tel number"); //Empty
|
| - |
|
368 |
headerRow.createCell(10).setCellValue("mobile number"); //Empty
|
| - |
|
369 |
headerRow.createCell(11).setCellValue("Prod/SKU code"); //ItemId
|
| - |
|
370 |
headerRow.createCell(12).setCellValue("contents"); //Product name
|
| - |
|
371 |
headerRow.createCell(13).setCellValue("weight"); //In Kgs
|
| - |
|
372 |
headerRow.createCell(14).setCellValue("Declared Value");
|
| - |
|
373 |
headerRow.createCell(15).setCellValue("Collectable Value");
|
| - |
|
374 |
headerRow.createCell(16).setCellValue("Vendor Code");
|
| - |
|
375 |
headerRow.createCell(17).setCellValue("Shipper Name");
|
| - |
|
376 |
headerRow.createCell(18).setCellValue("Return Address1");
|
| - |
|
377 |
headerRow.createCell(19).setCellValue("Return Address2");
|
| - |
|
378 |
headerRow.createCell(20).setCellValue("Return Address3");
|
| - |
|
379 |
headerRow.createCell(21).setCellValue("Return Pin");
|
| - |
|
380 |
headerRow.createCell(22).setCellValue("Length ( Cms )");
|
| - |
|
381 |
headerRow.createCell(23).setCellValue("Bredth ( Cms )");
|
| - |
|
382 |
headerRow.createCell(24).setCellValue("Height ( Cms )");
|
| - |
|
383 |
headerRow.createCell(25).setCellValue("Pieces");
|
| - |
|
384 |
headerRow.createCell(26).setCellValue("Area_customer_code");
|
| - |
|
385 |
headerRow.createCell(27).setCellValue("Handover Date ( DD/MM/YYYY )");
|
| - |
|
386 |
headerRow.createCell(28).setCellValue("Handover Time ( 24 hrs format )");
|
| - |
|
387 |
|
| - |
|
388 |
int serialNo = 0;
|
| - |
|
389 |
|
| - |
|
390 |
for(AwbDetails awbDetail : awbDetailList) {
|
| - |
|
391 |
// 0 Airwaybill 1 Type 2 Reference Number 3 Sender / Store name 4 attention 5 address1 6 address2 7 address3
|
| - |
|
392 |
// 8 pincode 9 tel number 10 mobile number 11 Prod/SKU code 12 contents 13 weight
|
| - |
|
393 |
// 14 Declared Value 15 Collectable Value
|
| - |
|
394 |
// 16 Vendor Code 17 Shipper Name 18 Return Address1 19 Return Address2 20 Return Address3 21 Return Pin
|
| - |
|
395 |
// 22 Length ( Cms ) 23 Bredth ( Cms ) 24 Height ( Cms )
|
| - |
|
396 |
// 25 Pieces 26 Area_customer_code 27 Handover Date ( DD/MM/YYYY ) 28 Handover Time ( 24 hrs format )
|
| - |
|
397 |
|
| - |
|
398 |
serialNo++;
|
| - |
|
399 |
Row contentRow = sheet.createRow((short)serialNo);
|
| - |
|
400 |
|
| - |
|
401 |
|
| - |
|
402 |
contentRow.createCell(28).setCellValue(CourierDetailsController.EMPTY_STRING);
|
| - |
|
403 |
|
| - |
|
404 |
contentRow.createCell(0).setCellValue(awbDetail.getAwbNumber());
|
| - |
|
405 |
contentRow.createCell(1).setCellValue(awbDetail.getPaymentMode().equals("COD") ? "COD" : "NONCOD");
|
| - |
|
406 |
contentRow.createCell(2).setCellValue(awbDetail.getOrderId());
|
| - |
|
407 |
contentRow.createCell(3).setCellValue("Spice Online Retail Pvt Ltd");
|
| - |
|
408 |
contentRow.createCell(4).setCellValue(awbDetail.getCustomerName());
|
| - |
|
409 |
contentRow.createCell(5).setCellValue(awbDetail.getAddress1());
|
| - |
|
410 |
contentRow.createCell(6).setCellValue(awbDetail.getAddress2());
|
| - |
|
411 |
contentRow.createCell(7).setCellValue(awbDetail.getCity() + ", " + awbDetail.getState());
|
| - |
|
412 |
contentRow.createCell(8).setCellValue(awbDetail.getPinCode());
|
| - |
|
413 |
contentRow.createCell(9).setCellValue(awbDetail.getPhoneNumber());
|
| - |
|
414 |
contentRow.createCell(10).setCellValue(awbDetail.getPhoneNumber());
|
| - |
|
415 |
contentRow.createCell(11).setCellValue(awbDetail.getItemId());
|
| - |
|
416 |
contentRow.createCell(12).setCellValue(awbDetail.getProductName());
|
| - |
|
417 |
contentRow.createCell(13).setCellValue(awbDetail.getPacketWeight());
|
| - |
|
418 |
contentRow.createCell(14).setCellValue(awbDetail.getShipmentValue());
|
| - |
|
419 |
contentRow.createCell(15).setCellValue(awbDetail.getAmountToCollect());
|
| - |
|
420 |
contentRow.createCell(16).setCellValue(awbDetail.getVendorCode());
|
| - |
|
421 |
contentRow.createCell(17).setCellValue("Spice Online Retail Pvt Ltd");
|
| - |
|
422 |
contentRow.createCell(18).setCellValue(awbDetail.getReturnAddress1());
|
| - |
|
423 |
contentRow.createCell(19).setCellValue(awbDetail.getReturnAddress2());
|
| - |
|
424 |
contentRow.createCell(20).setCellValue(awbDetail.getReturnAddress3());
|
| - |
|
425 |
contentRow.createCell(21).setCellValue(awbDetail.getReturnPin());
|
| - |
|
426 |
contentRow.createCell(22).setCellValue(CourierDetailsController.EMPTY_STRING);
|
| - |
|
427 |
contentRow.createCell(23).setCellValue(CourierDetailsController.EMPTY_STRING);
|
| - |
|
428 |
contentRow.createCell(24).setCellValue(CourierDetailsController.EMPTY_STRING);
|
| - |
|
429 |
contentRow.createCell(25).setCellValue("1");
|
| - |
|
430 |
contentRow.createCell(26).setCellValue(awbDetail.getAccountCode());
|
| - |
|
431 |
|
| - |
|
432 |
Date date = null;
|
| - |
|
433 |
SimpleDateFormat sdf4Date = new SimpleDateFormat("dd/MM/yyyy");
|
| - |
|
434 |
SimpleDateFormat sdf4Time = new SimpleDateFormat("HHmm");
|
| - |
|
435 |
|
| - |
|
436 |
try {
|
| - |
|
437 |
date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(awbDetail.getAwbDate());
|
| - |
|
438 |
} catch (ParseException e) {
|
| - |
|
439 |
// TODO Auto-generated catch block
|
| - |
|
440 |
e.printStackTrace();
|
| - |
|
441 |
}
|
| - |
|
442 |
|
| - |
|
443 |
contentRow.createCell(27).setCellValue(sdf4Date.format(date));
|
| - |
|
444 |
contentRow.createCell(28).setCellValue(sdf4Time.format(date));
|
| - |
|
445 |
|
| - |
|
446 |
/**
|
| - |
|
447 |
* According to javadoc of Date, Date.toString() converts a Date object to a String of the form:
|
| - |
|
448 |
*
|
| - |
|
449 |
dow mon dd hh:mm:ss zzz yyyy
|
| - |
|
450 |
|
| - |
|
451 |
where:
|
| - |
|
452 |
|
| - |
|
453 |
* dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
|
| - |
|
454 |
* mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
|
| - |
|
455 |
* dd is the day of the month (01 through 31), as two decimal digits.
|
| - |
|
456 |
* hh is the hour of the day (00 through 23), as two decimal digits.
|
| - |
|
457 |
* mm is the minute within the hour (00 through 59), as two decimal digits.
|
| - |
|
458 |
* ss is the second within the minute (00 through 61, as two decimal digits.
|
| - |
|
459 |
* zzz is the time zone (and may reflect daylight saving time). Standard time zone abbreviations include those recognized by the method parse. If time zone information is not available, then zzz is empty - that is, it consists of no characters at all.
|
| - |
|
460 |
* yyyy is the year, as four decimal digits.
|
| - |
|
461 |
*
|
| - |
|
462 |
* And we need to send this in format DD/MM/YYYY and time in HHMM
|
| - |
|
463 |
*/
|
| - |
|
464 |
}
|
| - |
|
465 |
|
| - |
|
466 |
try {
|
| - |
|
467 |
wb.write(baos);
|
| - |
|
468 |
baos.close();
|
| - |
|
469 |
} catch (IOException e) {
|
| - |
|
470 |
// TODO Auto-generated catch block
|
| - |
|
471 |
e.printStackTrace();
|
| - |
|
472 |
}
|
| 234 |
return "info";
|
473 |
return baos;
|
| 235 |
}
|
474 |
}
|
| - |
|
475 |
|
| 236 |
|
476 |
|
| 237 |
/**
|
477 |
/**
|
| 238 |
* Sets the daysToSubtract to -2 and then invokes the standard show() handler.
|
478 |
* Sets the daysToSubtract to -2 and then invokes the standard show() handler.
|
| 239 |
* Should be used to view day before yesterday's courier details report.
|
479 |
* Should be used to view day before yesterday's courier details report.
|
| 240 |
*
|
480 |
*
|
| Line 341... |
Line 581... |
| 341 |
}
|
581 |
}
|
| 342 |
|
582 |
|
| 343 |
public void setErrorMsg(String errorMsg) {
|
583 |
public void setErrorMsg(String errorMsg) {
|
| 344 |
this.errorMsg = errorMsg;
|
584 |
this.errorMsg = errorMsg;
|
| 345 |
}
|
585 |
}
|
| - |
|
586 |
|
| - |
|
587 |
public File getAwbFile() {
|
| - |
|
588 |
return awbFile;
|
| - |
|
589 |
}
|
| - |
|
590 |
|
| - |
|
591 |
public void setAwbFile(File awbFile) {
|
| - |
|
592 |
this.awbFile = awbFile;
|
| - |
|
593 |
}
|
| - |
|
594 |
|
| - |
|
595 |
public String getAwbFileContentType() {
|
| - |
|
596 |
return awbFileContentType;
|
| - |
|
597 |
}
|
| - |
|
598 |
|
| - |
|
599 |
public void setAwbFileContentType(String awbFileContentType) {
|
| - |
|
600 |
this.awbFileContentType = awbFileContentType;
|
| - |
|
601 |
}
|
| - |
|
602 |
|
| - |
|
603 |
public String getAwbFileFileName() {
|
| - |
|
604 |
return awbFileFileName;
|
| - |
|
605 |
}
|
| - |
|
606 |
|
| - |
|
607 |
public void setAwbFileFileName(String awbFileFileName) {
|
| - |
|
608 |
this.awbFileFileName = awbFileFileName;
|
| - |
|
609 |
}
|
| - |
|
610 |
|
| - |
|
611 |
public static void main(String[] args) {
|
| - |
|
612 |
// CourierDetailsController cdc = new CourierDetailsController();
|
| - |
|
613 |
// cdc.setAwbNumbers("4340987735");
|
| - |
|
614 |
// String msg = cdc.getAwbDetails();
|
| - |
|
615 |
// System.out.println(msg);
|
| - |
|
616 |
// //58539182004
|
| - |
|
617 |
// //43726980393
|
| - |
|
618 |
|
| - |
|
619 |
// String string = "January 2, 2010";
|
| - |
|
620 |
// Date date = null;
|
| - |
|
621 |
// Calendar cal = Calendar.getInstance();
|
| - |
|
622 |
// //cal.set(2014, 0, 20);
|
| - |
|
623 |
//
|
| - |
|
624 |
// try {
|
| - |
|
625 |
// date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(cal.getTime().toString());
|
| - |
|
626 |
// } catch (ParseException e) {
|
| - |
|
627 |
// // TODO Auto-generated catch block
|
| - |
|
628 |
// e.printStackTrace();
|
| - |
|
629 |
// }
|
| - |
|
630 |
// SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
| - |
|
631 |
// System.out.println(sdf.format(date));
|
| - |
|
632 |
|
| - |
|
633 |
String[] addresses = "fjdaks\n,24/1,hello".split(",+");
|
| - |
|
634 |
System.out.println(addresses[0].trim());
|
| - |
|
635 |
System.out.println(addresses[1]);
|
| - |
|
636 |
System.out.println(addresses[2]);
|
| - |
|
637 |
}
|
| 346 |
}
|
638 |
}
|