Subversion Repositories SmartDukaan

Rev

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

Rev 7792 Rev 7811
Line 39... Line 39...
39
import javax.servlet.ServletOutputStream;
39
import javax.servlet.ServletOutputStream;
40
import javax.servlet.http.HttpServletRequest;
40
import javax.servlet.http.HttpServletRequest;
41
import javax.servlet.http.HttpServletResponse;
41
import javax.servlet.http.HttpServletResponse;
42
import javax.servlet.http.HttpSession;
42
import javax.servlet.http.HttpSession;
43
 
43
 
-
 
44
import org.apache.commons.lang.StringUtils;
44
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
45
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
45
import org.apache.poi.ss.usermodel.Cell;
46
import org.apache.poi.ss.usermodel.Cell;
46
import org.apache.poi.ss.usermodel.CellStyle;
47
import org.apache.poi.ss.usermodel.CellStyle;
47
import org.apache.poi.ss.usermodel.CreationHelper;
48
import org.apache.poi.ss.usermodel.CreationHelper;
48
import org.apache.poi.ss.usermodel.Row;
49
import org.apache.poi.ss.usermodel.Row;
Line 276... Line 277...
276
	           
277
	           
277
	            AwbDetails detailedAwb = new AwbDetails();
278
	            AwbDetails detailedAwb = new AwbDetails();
278
	            
279
	            
279
	            String[] addresses = warehouse.getLocation().split(",+");
280
	            String[] addresses = warehouse.getLocation().split(",+");
280
	            
281
	            
281
	            for(int i = 0; i< addresses.length; i++) {
282
	            detailedAwb.setReturnAddress1((addresses[0].trim() + ", " + addresses[1].trim()).replace("\n", ", "));
282
	                addresses[i] = addresses[i].trim();
283
	            detailedAwb.setReturnAddress2((addresses[2].trim() + (addresses.length > 3 ? ", " + addresses[3].trim() : "")).replace("\n", ", "));
283
	            }
-
 
284
	            
284
	            
285
	            detailedAwb.setReturnAddress1(addresses[0] + addresses[1]);
-
 
286
	            detailedAwb.setReturnAddress2(addresses[2]);
-
 
287
	            String line3 = "";
285
	            String line3 = "";
-
 
286
	            if(addresses.length > 4) {
288
	            for(int i = 3; i<addresses.length; i++) {
287
	                for(int i = 4; i<addresses.length; i++) {
289
                    line3 += addresses[i];
288
	                    line3 += addresses[i] + ", ";
290
                }
289
	                }
-
 
290
	            }
-
 
291
	            
-
 
292
	            if(StringUtils.isNotEmpty(line3)) {
-
 
293
	                detailedAwb.setReturnAddress3(line3.trim().replace("\n", ", "));
-
 
294
	            } else {
291
	            detailedAwb.setReturnAddress3(line3);
295
	                detailedAwb.setReturnAddress3(EMPTY_STRING);
-
 
296
	            }
292
	            detailedAwb.setReturnPin(warehouse.getPincode());
297
	            detailedAwb.setReturnPin(warehouse.getPincode());
293
	            detailedAwb.setAwbNumber(awbNumber);
298
	            detailedAwb.setAwbNumber(awbNumber);
294
	            detailedAwb.setAccountCode(accountNo);
299
	            detailedAwb.setAccountCode(accountNo);
295
	            detailedAwb.setVendorCode((int) order.getWarehouse_id());
300
	            detailedAwb.setVendorCode((int) order.getWarehouse_id());
296
	            detailedAwb.setAddress1(order.getCustomer_address1());
301
	            detailedAwb.setAddress1(order.getCustomer_address1());
Line 298... Line 303...
298
	            if(order.isLogisticsCod()){
303
	            if(order.isLogisticsCod()){
299
	                detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
304
	                detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
300
	            } else {
305
	            } else {
301
	                detailedAwb.setAmountToCollect("" + 0 );
306
	                detailedAwb.setAmountToCollect("" + 0 );
302
	            }
307
	            }
-
 
308
	            
-
 
309
	            if(order.getShipping_timestamp() > 0) {
303
	            Date date = new Date(order.getPickup_timestamp());
310
    	            Date date = new Date(order.getShipping_timestamp());
304
	            detailedAwb.setAwbDate(date.toString());
311
    	            detailedAwb.setAwbDate(date.toString());
-
 
312
	            } else {
-
 
313
	                detailedAwb.setAwbDate("N/A");
-
 
314
	            }
305
	            detailedAwb.setCity(order.getCustomer_city());
315
	            detailedAwb.setCity(order.getCustomer_city());
306
	            detailedAwb.setCustomerName(order.getCustomer_name());
316
	            detailedAwb.setCustomerName(order.getCustomer_name());
307
	            detailedAwb.setItemId("" + order.getLineitems().get(0).getItem_id());
317
	            detailedAwb.setItemId("" + order.getLineitems().get(0).getItem_id());
308
	            detailedAwb.setOrderId("" + order.getId());
318
	            detailedAwb.setOrderId("" + order.getId());
309
	            detailedAwb.setPacketWeight("" + order.getTotal_weight());
319
	            detailedAwb.setPacketWeight("" + order.getTotal_weight());
Line 335... Line 345...
335
	        } catch (LogisticsServiceException e) {
345
	        } catch (LogisticsServiceException e) {
336
	            setErrorMsg(e.getMessage());
346
	            setErrorMsg(e.getMessage());
337
            } catch (InventoryServiceException e) {
347
            } catch (InventoryServiceException e) {
338
                setErrorMsg(e.getMessage());
348
                setErrorMsg(e.getMessage());
339
            }
349
            }
340
        setDetailedAWBs(tempList);
-
 
341
	    }
350
	    }
-
 
351
	    setDetailedAWBs(tempList);
342
    }
352
    }
343
	
353
	
344
	
354
	
345
	public ByteArrayOutputStream generateAwbDetailsSheet(List<AwbDetails> awbDetailList) {
355
	public ByteArrayOutputStream generateAwbDetailsSheet(List<AwbDetails> awbDetailList) {
346
	    ByteArrayOutputStream baos = new ByteArrayOutputStream();;
356
	    ByteArrayOutputStream baos = new ByteArrayOutputStream();;
Line 396... Line 406...
396
//          25 Pieces  26 Area_customer_code  27 Handover Date ( DD/MM/YYYY )   28 Handover Time ( 24 hrs format )  
406
//          25 Pieces  26 Area_customer_code  27 Handover Date ( DD/MM/YYYY )   28 Handover Time ( 24 hrs format )  
397
 
407
 
398
            serialNo++;
408
            serialNo++;
399
            Row contentRow = sheet.createRow((short)serialNo);
409
            Row contentRow = sheet.createRow((short)serialNo);
400
            
410
            
401
 
-
 
402
            contentRow.createCell(28).setCellValue(CourierDetailsController.EMPTY_STRING);
-
 
403
            
-
 
404
            contentRow.createCell(0).setCellValue(awbDetail.getAwbNumber());
411
            contentRow.createCell(0).setCellValue(awbDetail.getAwbNumber());
405
            contentRow.createCell(1).setCellValue(awbDetail.getPaymentMode().equals("COD") ? "COD" : "NONCOD");
412
            contentRow.createCell(1).setCellValue(awbDetail.getPaymentMode().equals("COD") ? "COD" : "NONCOD");
406
            contentRow.createCell(2).setCellValue(awbDetail.getOrderId());
413
            contentRow.createCell(2).setCellValue(awbDetail.getOrderId());
407
            contentRow.createCell(3).setCellValue("Spice Online Retail Pvt Ltd");
414
            contentRow.createCell(3).setCellValue("Spice Online Retail Pvt Ltd");
408
            contentRow.createCell(4).setCellValue(awbDetail.getCustomerName());
415
            contentRow.createCell(4).setCellValue(awbDetail.getCustomerName());
Line 431... Line 438...
431
             
438
             
432
            Date date = null;
439
            Date date = null;
433
            SimpleDateFormat sdf4Date = new SimpleDateFormat("dd/MM/yyyy");                
440
            SimpleDateFormat sdf4Date = new SimpleDateFormat("dd/MM/yyyy");                
434
            SimpleDateFormat sdf4Time = new SimpleDateFormat("HHmm");
441
            SimpleDateFormat sdf4Time = new SimpleDateFormat("HHmm");
435
            
442
            
-
 
443
            if(!awbDetail.getAwbDate().equals("N/A")) {
436
            try {
444
                try {
437
                date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(awbDetail.getAwbDate());
445
                    date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(awbDetail.getAwbDate());
438
            } catch (ParseException e) {
446
                } catch (ParseException e) {
439
                // TODO Auto-generated catch block
447
                    // TODO Auto-generated catch block
440
                e.printStackTrace();
448
                    e.printStackTrace();
-
 
449
                }
-
 
450
                contentRow.createCell(27).setCellValue(sdf4Date.format(date));
-
 
451
                contentRow.createCell(28).setCellValue(sdf4Time.format(date));
-
 
452
            } else {
-
 
453
                contentRow.createCell(27).setCellValue("N/A");
-
 
454
                contentRow.createCell(28).setCellValue("N/A");
441
            }
455
            }
442
            
456
            
443
            contentRow.createCell(27).setCellValue(sdf4Date.format(date));
-
 
444
            contentRow.createCell(28).setCellValue(sdf4Time.format(date));
457
            
445
            
458
            
446
            /**
459
            /**
447
             * According to javadoc of Date, Date.toString() converts a Date object to a String of the form:
460
             * According to javadoc of Date, Date.toString() converts a Date object to a String of the form:
448
             * 
461
             * 
449
                 dow mon dd hh:mm:ss zzz yyyy
462
                 dow mon dd hh:mm:ss zzz yyyy