| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.services;
|
1 |
package in.shop2020.support.services;
|
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayOutputStream;
|
3 |
import java.io.ByteArrayOutputStream;
|
| - |
|
4 |
import java.io.File;
|
| - |
|
5 |
import java.io.FileOutputStream;
|
| 4 |
import java.io.IOException;
|
6 |
import java.io.IOException;
|
| 5 |
import java.net.MalformedURLException;
|
7 |
import java.net.MalformedURLException;
|
| 6 |
import java.text.DateFormat;
|
8 |
import java.text.DateFormat;
|
| - |
|
9 |
import java.text.DecimalFormat;
|
| 7 |
import java.util.Date;
|
10 |
import java.util.Date;
|
| 8 |
import java.util.List;
|
11 |
import java.util.List;
|
| 9 |
|
12 |
|
| 10 |
import org.apache.thrift.TException;
|
13 |
import org.apache.thrift.TException;
|
| 11 |
|
14 |
|
| Line 37... |
Line 40... |
| 37 |
|
40 |
|
| 38 |
public class ManifestGenerator {
|
41 |
public class ManifestGenerator {
|
| 39 |
private TransactionServiceClient tsc = null;
|
42 |
private TransactionServiceClient tsc = null;
|
| 40 |
private CatalogServiceClient csc = null;
|
43 |
private CatalogServiceClient csc = null;
|
| 41 |
private LogisticsServiceClient lsc = null;
|
44 |
private LogisticsServiceClient lsc = null;
|
| 42 |
|
- |
|
| - |
|
45 |
private DecimalFormat weightFormat = new DecimalFormat("0.000");
|
| 43 |
public ManifestGenerator() {
|
46 |
public ManifestGenerator() {
|
| 44 |
try {
|
47 |
try {
|
| 45 |
tsc = new TransactionServiceClient();
|
48 |
tsc = new TransactionServiceClient();
|
| 46 |
csc = new CatalogServiceClient();
|
49 |
csc = new CatalogServiceClient();
|
| 47 |
lsc = new LogisticsServiceClient();
|
50 |
lsc = new LogisticsServiceClient();
|
| Line 87... |
Line 90... |
| 87 |
document.open();
|
90 |
document.open();
|
| 88 |
PdfPTable table = new PdfPTable(1);
|
91 |
PdfPTable table = new PdfPTable(1);
|
| 89 |
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
92 |
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 90 |
table.getDefaultCell().setPaddingBottom(10.0f);
|
93 |
table.getDefaultCell().setPaddingBottom(10.0f);
|
| 91 |
|
94 |
|
| 92 |
String logoPath = ManifestGenerator.class.getResource("/logo.png").getPath();
|
95 |
String logoPath = ManifestGenerator.class.getResource("/logo.jpg").getPath();
|
| 93 |
PdfPCell logoCell = new PdfPCell(Image.getInstance(logoPath), false);
|
96 |
PdfPCell logoCell = new PdfPCell(Image.getInstance(logoPath), false);
|
| 94 |
logoCell.setBorder(Rectangle.NO_BORDER);
|
97 |
logoCell.setBorder(Rectangle.NO_BORDER);
|
| 95 |
|
98 |
|
| 96 |
String addressString = warehouse.getLocation() + "\nPIN " + warehouse.getPincode()+ "\n\n";
|
99 |
String addressString = warehouse.getLocation() + "\nPIN " + warehouse.getPincode()+ "\n\n";
|
| 97 |
Paragraph addressParagraph = new Paragraph(addressString, new Font(FontFamily.TIMES_ROMAN,8f));
|
100 |
Paragraph addressParagraph = new Paragraph(addressString, new Font(FontFamily.TIMES_ROMAN,8f));
|
| Line 123... |
Line 126... |
| 123 |
weight += lineItem.getTotal_weight();
|
126 |
weight += lineItem.getTotal_weight();
|
| 124 |
|
127 |
|
| 125 |
ordersTable.addCell(new Phrase(serialNo + "", helvetica8));
|
128 |
ordersTable.addCell(new Phrase(serialNo + "", helvetica8));
|
| 126 |
ordersTable.addCell(new Phrase(order.getId() + "", helvetica8));
|
129 |
ordersTable.addCell(new Phrase(order.getId() + "", helvetica8));
|
| 127 |
ordersTable.addCell(new Phrase(order.getAirwaybill_no(), helvetica8));
|
130 |
ordersTable.addCell(new Phrase(order.getAirwaybill_no(), helvetica8));
|
| 128 |
ordersTable.addCell(new Phrase(weight+"", helvetica8));
|
131 |
ordersTable.addCell(new Phrase(weightFormat.format(weight/1000.0), helvetica8));
|
| 129 |
ordersTable.addCell(new Phrase(order.getCustomer_name(), helvetica8));
|
132 |
ordersTable.addCell(new Phrase(order.getCustomer_name(), helvetica8));
|
| 130 |
ordersTable.addCell(new Phrase(order.getCustomer_city(), helvetica8));
|
133 |
ordersTable.addCell(new Phrase(order.getCustomer_city(), helvetica8));
|
| 131 |
ordersTable.addCell(new Phrase(order.getCustomer_pincode(), helvetica8));
|
134 |
ordersTable.addCell(new Phrase(order.getCustomer_pincode(), helvetica8));
|
| 132 |
ordersTable.addCell(new Phrase(order.getCustomer_state(), helvetica8));
|
135 |
ordersTable.addCell(new Phrase(order.getCustomer_state(), helvetica8));
|
| 133 |
}
|
136 |
}
|
| Line 151... |
Line 154... |
| 151 |
e.printStackTrace();
|
154 |
e.printStackTrace();
|
| 152 |
}
|
155 |
}
|
| 153 |
|
156 |
|
| 154 |
return baosPDF;
|
157 |
return baosPDF;
|
| 155 |
}
|
158 |
}
|
| - |
|
159 |
|
| - |
|
160 |
public static void main(String[] args) throws IOException {
|
| - |
|
161 |
ManifestGenerator manifestGenerator = new ManifestGenerator();
|
| - |
|
162 |
ByteArrayOutputStream baos = manifestGenerator.generateManifestFile(1, 1);
|
| - |
|
163 |
File f = new File("/home/ashish/Downloads/manifest-1-2.pdf");
|
| - |
|
164 |
FileOutputStream fos = new FileOutputStream(f);
|
| - |
|
165 |
baos.writeTo(fos);
|
| - |
|
166 |
}
|
| 156 |
}
|
167 |
}
|