Subversion Repositories SmartDukaan

Rev

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

Rev 13276 Rev 13361
Line 164... Line 164...
164
	
164
	
165
	/**
165
	/**
166
	 * Use this method to view details of a given awb number
166
	 * Use this method to view details of a given awb number
167
	 */
167
	 */
168
	public String viewAwbDetails() {
168
	public String viewAwbDetails() {
169
	    if(awbNumbers.isEmpty()) {
169
		if(awbNumbers.isEmpty()) {
170
	        setErrorMsg("Field cannot be empty");
170
			setErrorMsg("Field cannot be empty");
171
	        return "info";
171
			return "info";
172
	    }
172
		}
173
	    String [] awbArray = awbNumbers.split(",");
173
		String [] awbArray = awbNumbers.split(",");
174
	    createAwbDetailList(awbArray);
174
		createAwbDetailList(awbArray);
175
	    return "info";
175
		return "info";
176
	}
176
	}
177
 
177
 
178
	/**
178
	/**
179
     * Use this method to download details of given comma separated list of awb numbers
179
	 * Use this method to download details of given comma separated list of awb numbers
180
     */
180
	 */
181
	
181
 
182
	public String getAwbDetails() {
182
	public String getAwbDetails() {
183
	    if(awbNumbers.isEmpty()) {
183
		if(awbNumbers.isEmpty()) {
184
            setErrorMsg("Field cannot be empty");
184
			setErrorMsg("Field cannot be empty");
185
            return "info";
185
			return "info";
186
        }
186
		}
187
        String [] awbArray = awbNumbers.split(",");
187
		String [] awbArray = awbNumbers.split(",");
188
        createAwbDetailList(awbArray);
188
		createAwbDetailList(awbArray);
189
        ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
189
		ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
190
        response.setContentType("application/vnd.ms-excel");
190
		response.setContentType("application/vnd.ms-excel");
191
        response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
191
		response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
192
        ServletOutputStream sos;
192
		ServletOutputStream sos;
193
        try {
193
		try {
194
            sos = response.getOutputStream();
194
			sos = response.getOutputStream();
195
            baos.writeTo(sos);
195
			baos.writeTo(sos);
196
            sos.flush();
196
			sos.flush();
197
        } catch (IOException e) {
197
		} catch (IOException e) {
198
            logger.error("Encountered error while sending invoice response: ", e);
198
			logger.error("Encountered error while sending invoice response: ", e);
199
        }
199
		}
200
        return "info";
200
		return "info";
201
    }
201
	}
202
	
202
 
203
	/**
203
	/**
204
     * Use this method to download details of given list of awb numbers uploaded in a text file
204
	 * Use this method to download details of given list of awb numbers uploaded in a text file
205
     */
205
	 */
206
	
206
 
207
	public String getAwbDetailsByFile() {
207
	public String getAwbDetailsByFile() {
208
	    if(awbFile == null) {
208
		if(awbFile == null) {
209
	        return null;
209
			return null;
210
	    }
210
		}
211
 
211
 
212
	    List<String> awbList = new ArrayList<String>();
212
		List<String> awbList = new ArrayList<String>();
213
 
213
 
214
	    try {
214
		try {
215
	        BufferedReader in = new BufferedReader(new FileReader(awbFile));
215
			BufferedReader in = new BufferedReader(new FileReader(awbFile));
216
	        String line;
216
			String line;
217
	        while((line = in.readLine()) != null) {
217
			while((line = in.readLine()) != null) {
218
	            awbList.add(line.trim());
218
				awbList.add(line.trim());
219
	        }
219
			}
220
	    } catch (FileNotFoundException e1) {
220
		} catch (FileNotFoundException e1) {
221
	        logger.error("File not found", e1);
221
			logger.error("File not found", e1);
222
	        return null;
222
			return null;
223
	    } catch (IOException e) {
223
		} catch (IOException e) {
224
	        logger.error("Unable to read file", e);
224
			logger.error("Unable to read file", e);
225
	        return null;
225
			return null;
226
	    }
226
		}
227
	    
227
 
228
	    String[] awbArray  = awbList.toArray(new String [awbList.size()]);
228
		String[] awbArray  = awbList.toArray(new String [awbList.size()]);
229
	    createAwbDetailList(awbArray);
229
		createAwbDetailList(awbArray);
230
 
230
 
231
	    ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
231
		ByteArrayOutputStream baos = generateAwbDetailsSheet(this.detailedAWBs);
232
	    response.setContentType("application/vnd.ms-excel");
232
		response.setContentType("application/vnd.ms-excel");
233
        response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
233
		response.setHeader("Content-disposition", "inline; filename=awbDetails-" + Calendar.getInstance().getTime().toString() + ".xls");
234
	    ServletOutputStream sos;
234
		ServletOutputStream sos;
235
	    try {
235
		try {
236
	        sos = response.getOutputStream();
236
			sos = response.getOutputStream();
237
	        baos.writeTo(sos);
237
			baos.writeTo(sos);
238
	        sos.flush();
238
			sos.flush();
239
	    } catch (IOException e) {
239
		} catch (IOException e) {
240
	        logger.error("Encountered error while sending invoice response: ", e);
240
			logger.error("Encountered error while sending invoice response: ", e);
241
	    }
241
		}
242
	    return "info";
242
		return "info";
243
	}
243
	}
244
 
244
 
245
    private void createAwbDetailList(String[] awbArray) {
245
	private void createAwbDetailList(String[] awbArray) {
246
        Order order = null;
246
		List<Order> orderList;
247
	    List<AwbDetails> tempList = new ArrayList<AwbDetails>() ;
247
		List<AwbDetails> tempList = new ArrayList<AwbDetails>() ;
248
	    for(String awbNumber : awbArray) {
248
		for(String awbNumber : awbArray) {
249
	        try {
249
			try {
250
	            LogisticsClient lsc = new LogisticsClient();
250
				LogisticsClient lsc = new LogisticsClient();
251
	            TransactionClient tsc = new TransactionClient();
251
				TransactionClient tsc = new TransactionClient();
252
	            InventoryClient isc = new InventoryClient();
252
				InventoryClient isc = new InventoryClient();
253
	            in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = isc.getClient();
253
				in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = isc.getClient();
254
	            in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
254
				in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
255
	            in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
255
				in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
256
	            
256
 
257
	            /*
257
				/*
258
	             * Get required stuff
258
				 * Get required stuff
259
	             * FIXME: Reduce service calls 
259
				 * FIXME: Reduce service calls 
260
	             */
260
				 */
261
	            logger.info("Session : " + session);
261
				logger.info("Session : " + session);
262
	            logger.info("provider Id : " + ((Long)session.getAttribute("providerId")).longValue());
262
				logger.info("provider Id : " + ((Long)session.getAttribute("providerId")).longValue());
263
	            Provider provider = logisticsClient.getProvider(((Long)session.getAttribute("providerId")).longValue());
263
				Provider provider = logisticsClient.getProvider(((Long)session.getAttribute("providerId")).longValue());
264
	            order = txnClient.getOrderForAwb(awbNumber).get(0);
264
				orderList = txnClient.getOrderForAwb(awbNumber);
265
	            Warehouse warehouse = inventoryClient.getWarehouse(order.getWarehouse_id());
265
				for(Order order : orderList){
266
	           
266
					Warehouse warehouse = inventoryClient.getWarehouse(order.getWarehouse_id());
267
	            String accountNo = "";
267
 
268
	            
268
					String accountNo = "";
269
	            DeliveryType dt =  DeliveryType.PREPAID;
269
 
270
	            if (order.isLogisticsCod()) {
270
					DeliveryType dt =  DeliveryType.PREPAID;
271
	                dt = DeliveryType.COD;
271
					if (order.isLogisticsCod()) {
272
	            }
272
						dt = DeliveryType.COD;
273
	            
273
					}
274
	            for (ProviderDetails detail : provider.getDetails()) {
274
 
275
	                if(in.shop2020.model.v1.inventory.WarehouseLocation.findByValue((int) detail.getLogisticLocation()) == warehouse.getLogisticsLocation() && detail.getDeliveryType() == dt) {
275
					for (ProviderDetails detail : provider.getDetails()) {
276
	                    accountNo = detail.getAccountNo();
276
						if(in.shop2020.model.v1.inventory.WarehouseLocation.findByValue((int) detail.getLogisticLocation()) == warehouse.getLogisticsLocation() && detail.getDeliveryType() == dt) {
277
	                }
277
							accountNo = detail.getAccountNo();
278
	            }
278
						}
279
	           
279
					}
280
	            AwbDetails detailedAwb = new AwbDetails();
280
 
281
	            
281
					AwbDetails detailedAwb = new AwbDetails();
282
	            String[] addresses = warehouse.getLocation().split(",+");
282
 
283
	            
283
					String[] addresses = warehouse.getLocation().split(",+");
284
	            detailedAwb.setReturnAddress1((addresses[0].trim() + ", " + addresses[1].trim()).replace("\n", ", "));
284
 
285
	            detailedAwb.setReturnAddress2((addresses[2].trim() + (addresses.length > 3 ? ", " + addresses[3].trim() : "")).replace("\n", ", "));
285
					detailedAwb.setReturnAddress1((addresses[0].trim() + ", " + addresses[1].trim()).replace("\n", ", "));
286
	            
286
					detailedAwb.setReturnAddress2((addresses[2].trim() + (addresses.length > 3 ? ", " + addresses[3].trim() : "")).replace("\n", ", "));
287
	            String line3 = "";
287
 
288
	            if(addresses.length > 4) {
288
					String line3 = "";
289
	                for(int i = 4; i<addresses.length; i++) {
289
					if(addresses.length > 4) {
290
	                    line3 += addresses[i] + ", ";
290
						for(int i = 4; i<addresses.length; i++) {
291
	                }
291
							line3 += addresses[i] + ", ";
292
	            }
292
						}
293
	            
293
					}
294
	            if(StringUtils.isNotEmpty(line3)) {
294
 
295
	                detailedAwb.setReturnAddress3(line3.trim().replace("\n", ", "));
295
					if(StringUtils.isNotEmpty(line3)) {
296
	            } else {
296
						detailedAwb.setReturnAddress3(line3.trim().replace("\n", ", "));
297
	                detailedAwb.setReturnAddress3(EMPTY_STRING);
297
					} else {
298
	            }
298
						detailedAwb.setReturnAddress3(EMPTY_STRING);
299
	            detailedAwb.setReturnPin(warehouse.getPincode());
299
					}
300
	            detailedAwb.setAwbNumber(awbNumber);
300
					detailedAwb.setReturnPin(warehouse.getPincode());
301
	            detailedAwb.setAccountCode(accountNo);
301
					detailedAwb.setAwbNumber(awbNumber);
302
	            detailedAwb.setVendorCode((int) order.getWarehouse_id());
302
					detailedAwb.setAccountCode(accountNo);
303
	            if(order.isLogisticsCod()){
303
					detailedAwb.setVendorCode((int) order.getWarehouse_id());
304
	                detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
304
					if(order.isLogisticsCod()){
305
	            } else {
305
						detailedAwb.setAmountToCollect("" + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
306
	                detailedAwb.setAmountToCollect("" + 0 );
306
					} else {
307
	            }
307
						detailedAwb.setAmountToCollect("" + 0 );
308
	            
308
					}
309
	            if(order.getShipping_timestamp() > 0) {
309
 
310
    	            Date date = new Date(order.getShipping_timestamp());
310
					if(order.getShipping_timestamp() > 0) {
311
    	            detailedAwb.setAwbDate(date.toString());
311
						Date date = new Date(order.getShipping_timestamp());
312
	            } else {
312
						detailedAwb.setAwbDate(date.toString());
313
	                detailedAwb.setAwbDate("N/A");
313
					} else {
314
	            }
314
						detailedAwb.setAwbDate("N/A");
315
	            
315
					}
316
	            if(order.getPickupStoreId() > 0) {
316
 
317
	                PickupStore store = lsc.getClient().getPickupStore(order.getPickupStoreId());
317
					if(order.getPickupStoreId() > 0) {
318
	                detailedAwb.setAddress1(store.getLine1());
318
						PickupStore store = lsc.getClient().getPickupStore(order.getPickupStoreId());
319
	                detailedAwb.setAddress2(store.getLine2());
319
						detailedAwb.setAddress1(store.getLine1());
320
	                detailedAwb.setCity(store.getCity());
320
						detailedAwb.setAddress2(store.getLine2());
321
	                detailedAwb.setCustomerName("Spice Hotspot");
321
						detailedAwb.setCity(store.getCity());
322
	                detailedAwb.setPhoneNumber("" + store.getPhone());
322
						detailedAwb.setCustomerName("Spice Hotspot");
323
	                detailedAwb.setPinCode(store.getPin());
323
						detailedAwb.setPhoneNumber("" + store.getPhone());
324
	                detailedAwb.setState(store.getState());
324
						detailedAwb.setPinCode(store.getPin());
325
	            } else {
325
						detailedAwb.setState(store.getState());
326
	                detailedAwb.setAddress1(order.getCustomer_address1());
326
					} else {
327
	                detailedAwb.setAddress2(order.getCustomer_address2());
327
						detailedAwb.setAddress1(order.getCustomer_address1());
328
	                detailedAwb.setCity(order.getCustomer_city());
328
						detailedAwb.setAddress2(order.getCustomer_address2());
329
	                detailedAwb.setCustomerName(order.getCustomer_name());
329
						detailedAwb.setCity(order.getCustomer_city());
330
	                detailedAwb.setPhoneNumber("" + order.getCustomer_mobilenumber());
330
						detailedAwb.setCustomerName(order.getCustomer_name());
331
	                detailedAwb.setPinCode(order.getCustomer_pincode());
331
						detailedAwb.setPhoneNumber("" + order.getCustomer_mobilenumber());
332
	                detailedAwb.setState(order.getCustomer_state());
332
						detailedAwb.setPinCode(order.getCustomer_pincode());
333
	            }
333
						detailedAwb.setState(order.getCustomer_state());
334
	            
334
					}
335
	            detailedAwb.setItemId("" + order.getLineitems().get(0).getItem_id());
335
 
336
	            detailedAwb.setOrderId("" + order.getId());
336
					detailedAwb.setItemId("" + order.getLineitems().get(0).getItem_id());
337
	            detailedAwb.setPacketWeight("" + order.getTotal_weight());
337
					detailedAwb.setOrderId("" + order.getId());
338
	            if(order.isLogisticsCod()){
338
					detailedAwb.setPacketWeight("" + order.getTotal_weight());
339
	                detailedAwb.setPaymentMode("COD");
339
					if(order.isLogisticsCod()){
340
	            } else {
340
						detailedAwb.setPaymentMode("COD");
341
	                detailedAwb.setPaymentMode("Prepaid");
341
					} else {
342
	            }
342
						detailedAwb.setPaymentMode("Prepaid");
343
	            
343
					}
344
	            
344
 
345
	            detailedAwb.setPickupLocation(warehouse.getLocation());
345
 
346
	            
346
					detailedAwb.setPickupLocation(warehouse.getLocation());
347
	            LineItem lineitem = order.getLineitems().get(0);
347
 
348
	            detailedAwb.setProductName(lineitem.getBrand() + " " 
348
					LineItem lineitem = order.getLineitems().get(0);
349
	                                         + (lineitem.getModel_name() == null ? "" : lineitem.getModel_name()) + " " 
349
					detailedAwb.setProductName(lineitem.getBrand() + " " 
350
	                                         + (lineitem.getModel_number() == null ? "" : lineitem.getModel_number()) + " " 
350
							+ (lineitem.getModel_name() == null ? "" : lineitem.getModel_name()) + " " 
351
	                                         + (lineitem.getColor() == null ? "" : lineitem.getColor()));
351
							+ (lineitem.getModel_number() == null ? "" : lineitem.getModel_number()) + " " 
352
	            if (order.getFreebieItemId() > 0) {
352
							+ (lineitem.getColor() == null ? "" : lineitem.getColor()));
353
	                //If order has a freebie order attached with it
353
					if (order.getFreebieItemId() > 0) {
354
	                detailedAwb.setShipmentValue("" + (order.getTotal_amount()));
354
						//If order has a freebie order attached with it
355
	            } else {
355
						detailedAwb.setShipmentValue("" + (order.getTotal_amount()));
356
	                //else if the order is itself a split freebie order then we don't know how much was the selling price at the time of order
356
					} else {
357
	                //so we set the transfer price as shipment value
357
						//else if the order is itself a split freebie order then we don't know how much was the selling price at the time of order
358
	                if (lineitem.getExtra_info() != null && lineitem.getExtra_info().contains("Freebie Order for Order ID")) {
358
						//so we set the transfer price as shipment value
359
	                    detailedAwb.setShipmentValue("" + (lineitem.getTransfer_price()));
359
						if (lineitem.getExtra_info() != null && lineitem.getExtra_info().contains("Freebie Order for Order ID")) {
360
	                } else {
360
							detailedAwb.setShipmentValue("" + (lineitem.getTransfer_price()));
361
	                    //Else set total amount
361
						} else {
362
	                    detailedAwb.setShipmentValue("" + (order.getTotal_amount()));
362
							//Else set total amount
363
	                }
363
							detailedAwb.setShipmentValue("" + (order.getTotal_amount()));
364
	            }
364
						}
365
	            
365
					}
366
	            tempList.add(detailedAwb);
366
					
367
 
367
					if(order.isSetLogisticsTransactionId()){
368
	        } catch (TTransportException e) {
368
						detailedAwb.setMasterOrderId(order.getLogisticsTransactionId());
369
	            setErrorMsg("Your request cannot be processed due to technical error. Please try later.");
369
					}else{
370
	        } catch (TException e) {
370
						detailedAwb.setMasterOrderId("-");
371
	            setErrorMsg(e.getMessage());
371
					}
372
	        } catch (TransactionServiceException e) {
372
 
373
	            setErrorMsg(e.getMessage());
373
					tempList.add(detailedAwb);
374
	        } catch (LogisticsServiceException e) {
374
				}
375
	            setErrorMsg(e.getMessage());
375
 
376
            } catch (InventoryServiceException e) {
376
			} catch (TTransportException e) {
377
                setErrorMsg(e.getMessage());
377
				setErrorMsg("Your request cannot be processed due to technical error. Please try later.");
378
            }
378
			} catch (TException e) {
379
	    }
379
				setErrorMsg(e.getMessage());
380
	    setDetailedAWBs(tempList);
380
			} catch (TransactionServiceException e) {
381
    }
381
				setErrorMsg(e.getMessage());
382
	
382
			} catch (LogisticsServiceException e) {
383
	
383
				setErrorMsg(e.getMessage());
-
 
384
			} catch (InventoryServiceException e) {
-
 
385
				setErrorMsg(e.getMessage());
-
 
386
			}
-
 
387
		}
-
 
388
		setDetailedAWBs(tempList);
-
 
389
	}
-
 
390
 
-
 
391
 
384
	public ByteArrayOutputStream generateAwbDetailsSheet(List<AwbDetails> awbDetailList) {
392
	public ByteArrayOutputStream generateAwbDetailsSheet(List<AwbDetails> awbDetailList) {
385
	    ByteArrayOutputStream baos = new ByteArrayOutputStream();;
393
		ByteArrayOutputStream baos = new ByteArrayOutputStream();;
386
	    Workbook wb = new HSSFWorkbook();
394
		Workbook wb = new HSSFWorkbook();
387
        CreationHelper createHelper = wb.getCreationHelper();
395
		CreationHelper createHelper = wb.getCreationHelper();
388
        Sheet sheet = wb.createSheet("Saholic - Data");
396
		Sheet sheet = wb.createSheet("Saholic - Data");
389
        
397
 
390
        CellStyle dateCellStyle = wb.createCellStyle();
398
		CellStyle dateCellStyle = wb.createCellStyle();
391
        dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("d/m/yyyy"));
399
		dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("d/m/yyyy"));
392
        
400
 
393
        CellStyle weightStyle = wb.createCellStyle();
401
		CellStyle weightStyle = wb.createCellStyle();
394
        weightStyle.setDataFormat(createHelper.createDataFormat().getFormat("0.000"));
402
		weightStyle.setDataFormat(createHelper.createDataFormat().getFormat("0.000"));
395
 
403
 
396
        Row headerRow = sheet.createRow((short)0);
404
		Row headerRow = sheet.createRow((short)0);
397
        headerRow.createCell(0).setCellValue("Airwaybill");
405
		headerRow.createCell(0).setCellValue("Airwaybill");
398
        headerRow.createCell(1).setCellValue("Type"); //Values : "COD" / "NONCOD"
406
		headerRow.createCell(1).setCellValue("Type"); //Values : "COD" / "NONCOD"
399
        headerRow.createCell(2).setCellValue("Reference Number"); //OrderId
407
		headerRow.createCell(2).setCellValue("Mater Order Id");
400
        headerRow.createCell(3).setCellValue("Sender / Store name"); //"Spice Online retail pvt ltd"
408
		headerRow.createCell(3).setCellValue("Reference Number"); //OrderId
401
        headerRow.createCell(4).setCellValue("attention"); //Customer name
409
		headerRow.createCell(4).setCellValue("Sender / Store name"); //"Spice Online retail pvt ltd"
402
        headerRow.createCell(5).setCellValue("address1"); //Line 1
410
		headerRow.createCell(5).setCellValue("attention"); //Customer name
403
        headerRow.createCell(6).setCellValue("address2"); //Line 2
411
		headerRow.createCell(6).setCellValue("address1"); //Line 1
404
        headerRow.createCell(7).setCellValue("address3"); //city + state
412
		headerRow.createCell(7).setCellValue("address2"); //Line 2
405
        headerRow.createCell(8).setCellValue("pincode");
413
		headerRow.createCell(8).setCellValue("address3"); //city + state
406
        headerRow.createCell(9).setCellValue("tel number"); //Empty
414
		headerRow.createCell(9).setCellValue("pincode");
407
        headerRow.createCell(10).setCellValue("mobile number"); //Empty
415
		headerRow.createCell(10).setCellValue("tel number"); //Empty
408
        headerRow.createCell(11).setCellValue("Prod/SKU code");  //ItemId
416
		headerRow.createCell(11).setCellValue("mobile number"); //Empty
409
        headerRow.createCell(12).setCellValue("contents"); //Product name
417
		headerRow.createCell(12).setCellValue("Prod/SKU code");  //ItemId
410
        headerRow.createCell(13).setCellValue("weight");  //In Kgs
418
		headerRow.createCell(13).setCellValue("contents"); //Product name
411
        headerRow.createCell(14).setCellValue("Declared Value");  
419
		headerRow.createCell(14).setCellValue("weight");  //In Kgs
412
        headerRow.createCell(15).setCellValue("Collectable Value");
420
		headerRow.createCell(15).setCellValue("Declared Value");  
413
        headerRow.createCell(16).setCellValue("Vendor Code");
421
		headerRow.createCell(16).setCellValue("Collectable Value");
414
        headerRow.createCell(17).setCellValue("Shipper Name");  
422
		headerRow.createCell(17).setCellValue("Vendor Code");
415
        headerRow.createCell(18).setCellValue("Return Address1");
423
		headerRow.createCell(18).setCellValue("Shipper Name");  
416
        headerRow.createCell(19).setCellValue("Return Address2");
424
		headerRow.createCell(19).setCellValue("Return Address1");
417
        headerRow.createCell(20).setCellValue("Return Address3");
425
		headerRow.createCell(20).setCellValue("Return Address2");
418
        headerRow.createCell(21).setCellValue("Return Pin");
426
		headerRow.createCell(21).setCellValue("Return Address3");
419
        headerRow.createCell(22).setCellValue("Length ( Cms )");
427
		headerRow.createCell(22).setCellValue("Return Pin");
420
        headerRow.createCell(23).setCellValue("Bredth ( Cms )");
428
		headerRow.createCell(23).setCellValue("Length ( Cms )");
421
        headerRow.createCell(24).setCellValue("Height ( Cms )");
429
		headerRow.createCell(24).setCellValue("Bredth ( Cms )");
422
        headerRow.createCell(25).setCellValue("Pieces");       
430
		headerRow.createCell(25).setCellValue("Height ( Cms )");
423
        headerRow.createCell(26).setCellValue("Area_customer_code");
431
		headerRow.createCell(26).setCellValue("Pieces");       
424
        headerRow.createCell(27).setCellValue("Handover Date ( DD/MM/YYYY )");
432
		headerRow.createCell(27).setCellValue("Area_customer_code");
425
        headerRow.createCell(28).setCellValue("Handover Time ( 24 hrs format )");
433
		headerRow.createCell(28).setCellValue("Handover Date ( DD/MM/YYYY )");
426
 
434
		headerRow.createCell(29).setCellValue("Handover Time ( 24 hrs format )");
427
        int serialNo = 0;
435
 
428
        
436
		int serialNo = 0;
429
        for(AwbDetails awbDetail : awbDetailList) {
437
 
430
//          0  Airwaybill   1 Type    2 Reference Number  3 Sender / Store name 4 attention   5 address1    6 address2    7 address3    
438
		for(AwbDetails awbDetail : awbDetailList) {
431
//          8 pincode    9 tel number     10 mobile number   11 Prod/SKU code    12 contents    13 weight  
439
			//          0  Airwaybill   1 Type    2 Reference Number  3 Sender / Store name 4 attention   5 address1    6 address2    7 address3    
432
//          14 Declared Value   15 Collectable Value   
440
			//          8 pincode    9 tel number     10 mobile number   11 Prod/SKU code    12 contents    13 weight  
433
//          16 Vendor Code    17 Shipper Name    18 Return Address1    19 Return Address2    20 Return Address3     21 Return Pin  
441
			//          14 Declared Value   15 Collectable Value   
434
//          22 Length ( Cms )   23 Breadth ( Cms )      24 Height ( Cms )  
442
			//          16 Vendor Code    17 Shipper Name    18 Return Address1    19 Return Address2    20 Return Address3     21 Return Pin  
435
//          25 Pieces  26 Area_customer_code  27 Handover Date ( DD/MM/YYYY )   28 Handover Time ( 24 hrs format )  
443
			//          22 Length ( Cms )   23 Breadth ( Cms )      24 Height ( Cms )  
436
 
444
			//          25 Pieces  26 Area_customer_code  27 Handover Date ( DD/MM/YYYY )   28 Handover Time ( 24 hrs format )  
437
            serialNo++;
445
 
438
            Row contentRow = sheet.createRow((short)serialNo);
446
			serialNo++;
439
            
447
			Row contentRow = sheet.createRow((short)serialNo);
440
            contentRow.createCell(0).setCellValue(awbDetail.getAwbNumber());
448
 
441
            contentRow.createCell(1).setCellValue(awbDetail.getPaymentMode().equals("COD") ? "COD" : "NONCOD");
449
			contentRow.createCell(0).setCellValue(awbDetail.getAwbNumber());
442
            contentRow.createCell(2).setCellValue(awbDetail.getOrderId());
450
			contentRow.createCell(1).setCellValue(awbDetail.getPaymentMode().equals("COD") ? "COD" : "NONCOD");
443
            contentRow.createCell(3).setCellValue("Spice Online Retail Pvt Ltd");
451
			contentRow.createCell(2).setCellValue(awbDetail.getMasterOrderId());
444
            contentRow.createCell(4).setCellValue(awbDetail.getCustomerName());
452
			contentRow.createCell(3).setCellValue(awbDetail.getOrderId());
445
            contentRow.createCell(5).setCellValue(awbDetail.getAddress1());
453
			contentRow.createCell(4).setCellValue("Spice Online Retail Pvt Ltd");
446
            contentRow.createCell(6).setCellValue(awbDetail.getAddress2());
454
			contentRow.createCell(5).setCellValue(awbDetail.getCustomerName());
447
            contentRow.createCell(7).setCellValue(awbDetail.getCity() + ", " + awbDetail.getState());
455
			contentRow.createCell(6).setCellValue(awbDetail.getAddress1());
448
            contentRow.createCell(8).setCellValue(awbDetail.getPinCode());
456
			contentRow.createCell(7).setCellValue(awbDetail.getAddress2());
449
            contentRow.createCell(9).setCellValue(awbDetail.getPhoneNumber());
457
			contentRow.createCell(8).setCellValue(awbDetail.getCity() + ", " + awbDetail.getState());
450
            contentRow.createCell(10).setCellValue(awbDetail.getPhoneNumber());
458
			contentRow.createCell(9).setCellValue(awbDetail.getPinCode());
451
            contentRow.createCell(11).setCellValue(awbDetail.getItemId());
459
			contentRow.createCell(10).setCellValue(awbDetail.getPhoneNumber());
452
            contentRow.createCell(12).setCellValue(awbDetail.getProductName());
460
			contentRow.createCell(11).setCellValue(awbDetail.getPhoneNumber());
453
            contentRow.createCell(13).setCellValue(awbDetail.getPacketWeight());
461
			contentRow.createCell(12).setCellValue(awbDetail.getItemId());
454
            contentRow.createCell(14).setCellValue(awbDetail.getShipmentValue());
462
			contentRow.createCell(13).setCellValue(awbDetail.getProductName());
455
            contentRow.createCell(15).setCellValue(awbDetail.getAmountToCollect());
463
			contentRow.createCell(14).setCellValue(awbDetail.getPacketWeight());
456
            contentRow.createCell(16).setCellValue(awbDetail.getVendorCode());
464
			contentRow.createCell(15).setCellValue(awbDetail.getShipmentValue());
457
            contentRow.createCell(17).setCellValue("Spice Online Retail Pvt Ltd");
465
			contentRow.createCell(16).setCellValue(awbDetail.getAmountToCollect());
458
            contentRow.createCell(18).setCellValue(awbDetail.getReturnAddress1());
466
			contentRow.createCell(17).setCellValue(awbDetail.getVendorCode());
459
            contentRow.createCell(19).setCellValue(awbDetail.getReturnAddress2());
467
			contentRow.createCell(18).setCellValue("Spice Online Retail Pvt Ltd");
460
            contentRow.createCell(20).setCellValue(awbDetail.getReturnAddress3());
468
			contentRow.createCell(19).setCellValue(awbDetail.getReturnAddress1());
461
            contentRow.createCell(21).setCellValue(awbDetail.getReturnPin());
469
			contentRow.createCell(20).setCellValue(awbDetail.getReturnAddress2());
462
            contentRow.createCell(22).setCellValue(CourierDetailsController.EMPTY_STRING);
470
			contentRow.createCell(21).setCellValue(awbDetail.getReturnAddress3());
463
            contentRow.createCell(23).setCellValue(CourierDetailsController.EMPTY_STRING);
471
			contentRow.createCell(22).setCellValue(awbDetail.getReturnPin());
464
            contentRow.createCell(24).setCellValue(CourierDetailsController.EMPTY_STRING);
472
			contentRow.createCell(23).setCellValue(CourierDetailsController.EMPTY_STRING);
465
            contentRow.createCell(25).setCellValue("1");
473
			contentRow.createCell(24).setCellValue(CourierDetailsController.EMPTY_STRING);
466
            contentRow.createCell(26).setCellValue(awbDetail.getAccountCode());
474
			contentRow.createCell(25).setCellValue(CourierDetailsController.EMPTY_STRING);
467
             
475
			contentRow.createCell(26).setCellValue("1");
468
            Date date = null;
476
			contentRow.createCell(27).setCellValue(awbDetail.getAccountCode());
469
            SimpleDateFormat sdf4Date = new SimpleDateFormat("dd/MM/yyyy");                
477
 
470
            SimpleDateFormat sdf4Time = new SimpleDateFormat("HHmm");
478
			Date date = null;
471
            
479
			SimpleDateFormat sdf4Date = new SimpleDateFormat("dd/MM/yyyy");                
472
            if(!awbDetail.getAwbDate().equals("N/A")) {
480
			SimpleDateFormat sdf4Time = new SimpleDateFormat("HHmm");
473
                try {
481
 
474
                    date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(awbDetail.getAwbDate());
482
			if(!awbDetail.getAwbDate().equals("N/A")) {
475
                } catch (ParseException e) {
483
				try {
476
                    // TODO Auto-generated catch block
484
					date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(awbDetail.getAwbDate());
477
                    e.printStackTrace();
485
				} catch (ParseException e) {
478
                }
486
					// TODO Auto-generated catch block
479
                contentRow.createCell(27).setCellValue(sdf4Date.format(date));
487
					e.printStackTrace();
480
                contentRow.createCell(28).setCellValue(sdf4Time.format(date));
488
				}
481
            } else {
489
				contentRow.createCell(28).setCellValue(sdf4Date.format(date));
482
                contentRow.createCell(27).setCellValue("N/A");
490
				contentRow.createCell(29).setCellValue(sdf4Time.format(date));
483
                contentRow.createCell(28).setCellValue("N/A");
491
			} else {
484
            }
492
				contentRow.createCell(28).setCellValue("N/A");
485
            
493
				contentRow.createCell(29).setCellValue("N/A");
486
            
494
			}
487
            
495
 
488
            /**
496
 
489
             * According to javadoc of Date, Date.toString() converts a Date object to a String of the form:
497
 
490
             * 
498
			/**
-
 
499
			 * According to javadoc of Date, Date.toString() converts a Date object to a String of the form:
-
 
500
			 * 
491
                 dow mon dd hh:mm:ss zzz yyyy
501
                 dow mon dd hh:mm:ss zzz yyyy
492
 
502
 
493
            where:
503
            where:
494
 
504
 
495
             * dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
505
			 * dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
496
             * mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
506
			 * mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
497
             * dd is the day of the month (01 through 31), as two decimal digits.
507
			 * dd is the day of the month (01 through 31), as two decimal digits.
498
             * hh is the hour of the day (00 through 23), as two decimal digits.
508
			 * hh is the hour of the day (00 through 23), as two decimal digits.
499
             * mm is the minute within the hour (00 through 59), as two decimal digits.
509
			 * mm is the minute within the hour (00 through 59), as two decimal digits.
500
             * ss is the second within the minute (00 through 61, as two decimal digits.
510
			 * ss is the second within the minute (00 through 61, as two decimal digits.
501
             * 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.
511
			 * 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.
502
             * yyyy is the year, as four decimal digits. 
512
			 * yyyy is the year, as four decimal digits. 
503
             * 
513
			 * 
504
             * And we need to send this in format DD/MM/YYYY and time in HHMM
514
			 * And we need to send this in format DD/MM/YYYY and time in HHMM
505
             */
515
			 */
506
        }
516
		}
507
        
517
 
508
        try {
518
		try {
509
            wb.write(baos);
519
			wb.write(baos);
510
            baos.close();
520
			baos.close();
511
        } catch (IOException e) {
521
		} catch (IOException e) {
512
            // TODO Auto-generated catch block
522
			// TODO Auto-generated catch block
513
            e.printStackTrace();
523
			e.printStackTrace();
514
        }
524
		}
515
	    return baos;
525
		return baos;
516
	}
526
	}
517
	
-
 
518
 
527
 
-
 
528
 
519
    /**
529
	/**
520
	 * Sets the daysToSubtract to -2 and then invokes the standard show() handler.
530
	 * Sets the daysToSubtract to -2 and then invokes the standard show() handler.
521
	 * Should be used to view day before yesterday's courier details report.
531
	 * Should be used to view day before yesterday's courier details report.
522
	 * 
532
	 * 
523
     * @return the same string tokens as show
533
	 * @return the same string tokens as show
524
     */
534
	 */
525
	public String dayBefore(){
535
	public String dayBefore(){
526
		daysToSubtract = -2;
536
		daysToSubtract = -2;
527
		return show();
537
		return show();
528
	}
538
	}
529
 
539
 
530
    /**
540
	/**
531
     * Sets the daysToSubtract to -1 and then invokes the standard show()
541
	 * Sets the daysToSubtract to -1 and then invokes the standard show()
532
     * handler. Should be used to view yesterday's courier details report.
542
	 * handler. Should be used to view yesterday's courier details report.
533
     * 
543
	 * 
534
     * @return the same string tokens as show
544
	 * @return the same string tokens as show
535
     */
545
	 */
536
	public String yesterday(){
546
	public String yesterday(){
537
		daysToSubtract = -1;
547
		daysToSubtract = -1;
538
		return show();
548
		return show();
539
	}
549
	}
540
 
550
 
541
    /**
551
	/**
542
     * Sets the daysToSubtract to 0 and then invokes the standard show()
552
	 * Sets the daysToSubtract to 0 and then invokes the standard show()
543
     * handler. Should be used to view today's courier details report.
553
	 * handler. Should be used to view today's courier details report.
544
     * 
554
	 * 
545
     * @return the same string tokens as show
555
	 * @return the same string tokens as show
546
     */
556
	 */
547
	public String today(){
557
	public String today(){
548
		daysToSubtract = 0;
558
		daysToSubtract = 0;
549
		return show();
559
		return show();
550
	}
560
	}
551
		
561
 
552
	@Override
562
	@Override
553
	public void setServletContext(ServletContext context) {
563
	public void setServletContext(ServletContext context) {
554
		this.context = context;
564
		this.context = context;
555
	}
565
	}
556
	
566
 
557
	@Override
567
	@Override
558
	public void setServletResponse(HttpServletResponse response) {
568
	public void setServletResponse(HttpServletResponse response) {
559
		this.response  = response;
569
		this.response  = response;
560
	}
570
	}
561
 
571
 
Line 566... Line 576...
566
	}
576
	}
567
 
577
 
568
	public String getId(){
578
	public String getId(){
569
		return id;
579
		return id;
570
	}
580
	}
571
	
581
 
572
	public void setId(String id){
582
	public void setId(String id){
573
		this.id = id;
583
		this.id = id;
574
	}
584
	}
575
	
585
 
576
	public String getSessionUserName(){
586
	public String getSessionUserName(){
577
		return (String) session.getAttribute("username");
587
		return (String) session.getAttribute("username");
578
	}
588
	}
579
 
589
 
580
    /**
590
	/**
581
     * Gets the list of all warehouses and maps the warehouse ids to their
591
	 * Gets the list of all warehouses and maps the warehouse ids to their
582
     * display name.
592
	 * display name.
583
     * 
593
	 * 
584
     * @return the mapping of warehouse if to its display namee
594
	 * @return the mapping of warehouse if to its display namee
585
     */
595
	 */
586
	public Map<Long, String> getWarehouses(){
596
	public Map<Long, String> getWarehouses(){
587
		Map<Long, String> warehouseMap = new HashMap<Long, String>();
597
		Map<Long, String> warehouseMap = new HashMap<Long, String>();
588
		try{
598
		try{
589
			InventoryClient isc = new InventoryClient();
599
			InventoryClient isc = new InventoryClient();
590
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient= isc.getClient();
600
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient= isc.getClient();
Line 600... Line 610...
600
 
610
 
601
	public String getServletContextPath(){
611
	public String getServletContextPath(){
602
		return context.getContextPath();
612
		return context.getContextPath();
603
	}
613
	}
604
 
614
 
605
    public String getAwbNumbers() {
615
	public String getAwbNumbers() {
606
        return awbNumbers;
616
		return awbNumbers;
607
    }
617
	}
608
 
618
 
609
    public void setAwbNumbers(String awbNumbers) {
619
	public void setAwbNumbers(String awbNumbers) {
610
        this.awbNumbers = awbNumbers;
620
		this.awbNumbers = awbNumbers;
611
    }
621
	}
612
 
622
 
613
    public List<AwbDetails> getDetailedAWBs() {
623
	public List<AwbDetails> getDetailedAWBs() {
614
        return detailedAWBs;
624
		return detailedAWBs;
615
    }
625
	}
616
 
626
 
617
    public void setDetailedAWBs(List<AwbDetails> detailedAWBs) {
627
	public void setDetailedAWBs(List<AwbDetails> detailedAWBs) {
618
        this.detailedAWBs = detailedAWBs;
628
		this.detailedAWBs = detailedAWBs;
619
    }
629
	}
620
 
630
 
621
    public String getErrorMsg() {
631
	public String getErrorMsg() {
622
        return errorMsg;
632
		return errorMsg;
623
    }
633
	}
624
 
634
 
625
    public void setErrorMsg(String errorMsg) {
635
	public void setErrorMsg(String errorMsg) {
626
        this.errorMsg = errorMsg;
636
		this.errorMsg = errorMsg;
627
    }
637
	}
628
 
638
 
629
    public File getAwbFile() {
639
	public File getAwbFile() {
630
        return awbFile;
640
		return awbFile;
631
    }
641
	}
632
 
642
 
633
    public void setAwbFile(File awbFile) {
643
	public void setAwbFile(File awbFile) {
634
        this.awbFile = awbFile;
644
		this.awbFile = awbFile;
635
    }
645
	}
636
 
646
 
637
    public String getAwbFileContentType() {
647
	public String getAwbFileContentType() {
638
        return awbFileContentType;
648
		return awbFileContentType;
639
    }
649
	}
640
 
650
 
641
    public void setAwbFileContentType(String awbFileContentType) {
651
	public void setAwbFileContentType(String awbFileContentType) {
642
        this.awbFileContentType = awbFileContentType;
652
		this.awbFileContentType = awbFileContentType;
643
    }
653
	}
644
 
654
 
645
    public String getAwbFileFileName() {
655
	public String getAwbFileFileName() {
646
        return awbFileFileName;
656
		return awbFileFileName;
647
    }
657
	}
648
 
658
 
649
    public void setAwbFileFileName(String awbFileFileName) {
659
	public void setAwbFileFileName(String awbFileFileName) {
650
        this.awbFileFileName = awbFileFileName;
660
		this.awbFileFileName = awbFileFileName;
651
    }
661
	}
652
    
662
 
653
    public static void main(String[] args) {
663
	public static void main(String[] args) {
654
//        CourierDetailsController cdc = new CourierDetailsController();
664
		//        CourierDetailsController cdc = new CourierDetailsController();
655
//        cdc.setAwbNumbers("4340987735");
665
		//        cdc.setAwbNumbers("4340987735");
656
//        String msg = cdc.getAwbDetails();
666
		//        String msg = cdc.getAwbDetails();
657
//        System.out.println(msg);
667
		//        System.out.println(msg);
658
//        //58539182004
668
		//        //58539182004
659
//        //43726980393
669
		//        //43726980393
660
        
670
 
661
//        String string = "January 2, 2010";
671
		//        String string = "January 2, 2010";
662
//        Date date = null;
672
		//        Date date = null;
663
//        Calendar cal = Calendar.getInstance();
673
		//        Calendar cal = Calendar.getInstance();
664
//        //cal.set(2014, 0, 20);
674
		//        //cal.set(2014, 0, 20);
665
//        
675
		//        
666
//        try {
676
		//        try {
667
//            date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(cal.getTime().toString());
677
		//            date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(cal.getTime().toString());
668
//        } catch (ParseException e) {
678
		//        } catch (ParseException e) {
669
//            // TODO Auto-generated catch block
679
		//            // TODO Auto-generated catch block
670
//            e.printStackTrace();
680
		//            e.printStackTrace();
671
//        }
681
		//        }
672
//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
682
		//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
673
//        System.out.println(sdf.format(date));
683
		//        System.out.println(sdf.format(date));
674
        
684
 
675
        String[] addresses = "fjdaks\n,24/1,hello".split(",+");
685
		String[] addresses = "fjdaks\n,24/1,hello".split(",+");
676
        System.out.println(addresses[0].trim());
686
		System.out.println(addresses[0].trim());
677
        System.out.println(addresses[1]);
687
		System.out.println(addresses[1]);
678
        System.out.println(addresses[2]);
688
		System.out.println(addresses[2]);
679
    }
689
	}
680
}
690
}