| Line 23... |
Line 23... |
| 23 |
import in.shop2020.thrift.clients.LogisticsClient;
|
23 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 24 |
import in.shop2020.thrift.clients.TransactionClient;
|
24 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 25 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
25 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 26 |
import in.shop2020.thrift.clients.InventoryClient;
|
26 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 27 |
|
27 |
|
| - |
|
28 |
import java.awt.image.BufferedImage;
|
| 28 |
import java.io.ByteArrayOutputStream;
|
29 |
import java.io.ByteArrayOutputStream;
|
| 29 |
import java.io.File;
|
30 |
import java.io.File;
|
| 30 |
import java.io.FileOutputStream;
|
31 |
import java.io.FileOutputStream;
|
| 31 |
import java.io.IOException;
|
32 |
import java.io.IOException;
|
| - |
|
33 |
import java.io.OutputStream;
|
| 32 |
import java.text.DateFormat;
|
34 |
import java.text.DateFormat;
|
| 33 |
import java.text.DecimalFormat;
|
35 |
import java.text.DecimalFormat;
|
| 34 |
import java.util.ArrayList;
|
36 |
import java.util.ArrayList;
|
| 35 |
import java.util.Date;
|
37 |
import java.util.Date;
|
| 36 |
import java.util.List;
|
38 |
import java.util.List;
|
| Line 43... |
Line 45... |
| 43 |
import javax.servlet.http.HttpServletResponse;
|
45 |
import javax.servlet.http.HttpServletResponse;
|
| 44 |
|
46 |
|
| 45 |
import org.apache.commons.lang.StringUtils;
|
47 |
import org.apache.commons.lang.StringUtils;
|
| 46 |
import org.apache.commons.lang.WordUtils;
|
48 |
import org.apache.commons.lang.WordUtils;
|
| 47 |
import org.apache.thrift.TException;
|
49 |
import org.apache.thrift.TException;
|
| - |
|
50 |
import org.krysalis.barcode4j.impl.code128.Code128Bean;
|
| - |
|
51 |
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
|
| - |
|
52 |
import org.krysalis.barcode4j.tools.UnitConv;
|
| 48 |
import org.slf4j.Logger;
|
53 |
import org.slf4j.Logger;
|
| 49 |
import org.slf4j.LoggerFactory;
|
54 |
import org.slf4j.LoggerFactory;
|
| 50 |
|
55 |
|
| 51 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
56 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
| 52 |
|
57 |
|
| Line 297... |
Line 302... |
| 297 |
}
|
302 |
}
|
| 298 |
PdfPCell formIdCell= new PdfPCell(new Paragraph("COD Return "+order.getAirwaybill_no()+" Form id-0325", helvetica6));
|
303 |
PdfPCell formIdCell= new PdfPCell(new Paragraph("COD Return "+order.getAirwaybill_no()+" Form id-0325", helvetica6));
|
| 299 |
formIdCell.setPaddingTop(5.0f);
|
304 |
formIdCell.setPaddingTop(5.0f);
|
| 300 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
305 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
| 301 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
306 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
| 302 |
formIdCell.setPaddingBottom(15.0f);
|
- |
|
| 303 |
chargesTable.addCell(new Phrase("PRIORITY OVERNIGHT ", helvetica8));
|
307 |
chargesTable.addCell(new Phrase("PRIORITY OVERNIGHT ", helvetica8));
|
| 304 |
chargesTable.addCell(formIdCell);
|
308 |
chargesTable.addCell(formIdCell);
|
| 305 |
|
309 |
|
| 306 |
PdfPCell awbNumberCell= new PdfPCell(new Paragraph("*"+fedexCodReturnBarcode+"*", barCodeFont));
|
310 |
generateBarcode(fedexCodReturnBarcode, "fedex_codr_"+order.getId());
|
| - |
|
311 |
|
| - |
|
312 |
Image barcodeImage=null;
|
| - |
|
313 |
try {
|
| 307 |
awbNumberCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
314 |
barcodeImage = Image.getInstance("/tmp/"+"fedex_codr_"+order.getId()+".png");
|
| - |
|
315 |
} catch (Exception e) {
|
| 308 |
awbNumberCell.setBorder(Rectangle.NO_BORDER);
|
316 |
logger.error("Exception during getting Barcode Image for Fedex : ", e);
|
| 309 |
|
317 |
}
|
| 310 |
chargesTable.addCell(awbNumberCell);
|
318 |
chargesTable.addCell(barcodeImage);
|
| 311 |
|
319 |
|
| 312 |
}
|
320 |
}
|
| 313 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
321 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 314 |
} else {
|
322 |
} else {
|
| 315 |
chargesTable.addCell(new Phrase("Do not pay any extra charges to the Courier."));
|
323 |
chargesTable.addCell(new Phrase("Do not pay any extra charges to the Courier."));
|
| Line 400... |
Line 408... |
| 400 |
formIdCell = new PdfPCell(new Paragraph(order.getAirwaybill_no()+" Form id-0467", helvetica6));
|
408 |
formIdCell = new PdfPCell(new Paragraph(order.getAirwaybill_no()+" Form id-0467", helvetica6));
|
| 401 |
}
|
409 |
}
|
| 402 |
formIdCell.setPaddingTop(20.0f);
|
410 |
formIdCell.setPaddingTop(20.0f);
|
| 403 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
411 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
| 404 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
412 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
| 405 |
formIdCell.setPaddingBottom(15.0f);
|
- |
|
| 406 |
}
|
413 |
}
|
| 407 |
|
414 |
|
| 408 |
|
415 |
|
| 409 |
PdfPCell awbNumberCell= null;
|
416 |
PdfPCell awbNumberCell= null;
|
| 410 |
String fedexPackageBarcode = "";
|
417 |
String fedexPackageBarcode = "";
|
| Line 417... |
Line 424... |
| 417 |
try {
|
424 |
try {
|
| 418 |
fedexPackageBarcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Package_BarCode");
|
425 |
fedexPackageBarcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Package_BarCode");
|
| 419 |
} catch (TException e1) {
|
426 |
} catch (TException e1) {
|
| 420 |
logger.error("Error while getting the provider information.", e1);
|
427 |
logger.error("Error while getting the provider information.", e1);
|
| 421 |
}
|
428 |
}
|
| 422 |
awbNumberCell = new PdfPCell(new Paragraph("*"+fedexPackageBarcode+"*", barCodeFont));
|
429 |
awbNumberCell = new PdfPCell(new Paragraph(" ", helvetica6));
|
| 423 |
awbNumberCell.setPaddingBottom(5.0f);
|
430 |
awbNumberCell.setPaddingBottom(5.0f);
|
| 424 |
}
|
431 |
}
|
| 425 |
awbNumberCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
432 |
awbNumberCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
| 426 |
awbNumberCell.setBorder(Rectangle.NO_BORDER);
|
433 |
awbNumberCell.setBorder(Rectangle.NO_BORDER);
|
| 427 |
|
434 |
|
| 428 |
providerInfoTable.addCell(providerNameCell);
|
435 |
providerInfoTable.addCell(providerNameCell);
|
| 429 |
if(formIdCell != null){
|
436 |
if(formIdCell != null){
|
| 430 |
providerInfoTable.addCell(formIdCell);
|
437 |
providerInfoTable.addCell(formIdCell);
|
| 431 |
}
|
438 |
}
|
| 432 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
439 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| - |
|
440 |
if(order.getLogistics_provider_id()==7L){
|
| - |
|
441 |
generateBarcode(fedexPackageBarcode, "fedex_"+order.getId());
|
| - |
|
442 |
|
| - |
|
443 |
Image barcodeImage=null;
|
| - |
|
444 |
try {
|
| - |
|
445 |
barcodeImage = Image.getInstance("/tmp/"+"fedex_"+order.getId()+".png");
|
| - |
|
446 |
} catch (Exception e) {
|
| - |
|
447 |
logger.error("Exception during getting Barcode Image for Fedex : ", e);
|
| - |
|
448 |
}
|
| - |
|
449 |
providerInfoTable.addCell(barcodeImage);
|
| - |
|
450 |
}
|
| 433 |
providerInfoTable.addCell(awbNumberCell);
|
451 |
providerInfoTable.addCell(awbNumberCell);
|
| 434 |
|
- |
|
| 435 |
Warehouse warehouse = null;
|
452 |
Warehouse warehouse = null;
|
| 436 |
try{
|
453 |
try{
|
| 437 |
InventoryClient isc = new InventoryClient();
|
454 |
InventoryClient isc = new InventoryClient();
|
| 438 |
warehouse = isc.getClient().getWarehouse(order.getWarehouse_id());
|
455 |
warehouse = isc.getClient().getWarehouse(order.getWarehouse_id());
|
| 439 |
} catch(Exception e) {
|
456 |
} catch(Exception e) {
|
| Line 954... |
Line 971... |
| 954 |
|
971 |
|
| 955 |
extraInfoTable.addCell(extraInfoCell);
|
972 |
extraInfoTable.addCell(extraInfoCell);
|
| 956 |
|
973 |
|
| 957 |
return extraInfoTable;
|
974 |
return extraInfoTable;
|
| 958 |
}
|
975 |
}
|
| - |
|
976 |
|
| - |
|
977 |
private void generateBarcode(String barcodeString, String fileName){
|
| - |
|
978 |
Code128Bean bean = new Code128Bean();
|
| - |
|
979 |
|
| - |
|
980 |
final int dpi = 60;
|
| - |
|
981 |
|
| - |
|
982 |
//Configure the barcode generator
|
| - |
|
983 |
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
|
| - |
|
984 |
//width exactly one pixel
|
| - |
|
985 |
bean.setFontSize(bean.getFontSize()+1.0f);
|
| - |
|
986 |
bean.doQuietZone(false);
|
| - |
|
987 |
|
| - |
|
988 |
try {
|
| - |
|
989 |
File outputFile = new File("/tmp/"+fileName+".png");
|
| - |
|
990 |
OutputStream out = new FileOutputStream(outputFile);
|
| - |
|
991 |
|
| - |
|
992 |
//Set up the canvas provider for monochrome PNG output
|
| - |
|
993 |
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
|
| - |
|
994 |
out, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
|
| - |
|
995 |
|
| - |
|
996 |
//Generate the barcode
|
| - |
|
997 |
bean.generateBarcode(canvas, barcodeString);
|
| - |
|
998 |
|
| - |
|
999 |
//Signal end of generation
|
| - |
|
1000 |
canvas.finish();
|
| - |
|
1001 |
out.close();
|
| - |
|
1002 |
|
| - |
|
1003 |
}
|
| - |
|
1004 |
catch(Exception e){
|
| - |
|
1005 |
logger.error("Exception during generating Barcode : ", e);
|
| - |
|
1006 |
}
|
| - |
|
1007 |
}
|
| 959 |
|
1008 |
|
| 960 |
public static void main(String[] args) throws IOException {
|
1009 |
public static void main(String[] args) throws IOException {
|
| 961 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
1010 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
| 962 |
long orderId = 356324;
|
1011 |
long orderId = 356324;
|
| 963 |
ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, true, false, 1);
|
1012 |
ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, true, false, 1);
|