| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.services;
|
1 |
package in.shop2020.support.services;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.config.ConfigException;
|
| 3 |
import in.shop2020.logistics.LogisticsServiceException;
|
4 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 4 |
import in.shop2020.logistics.Provider;
|
5 |
import in.shop2020.logistics.Provider;
|
| 5 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
6 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
| 6 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
7 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
| 7 |
import in.shop2020.model.v1.catalog.Warehouse;
|
8 |
import in.shop2020.model.v1.catalog.Warehouse;
|
| Line 9... |
Line 10... |
| 9 |
import in.shop2020.model.v1.order.Order;
|
10 |
import in.shop2020.model.v1.order.Order;
|
| 10 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
11 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 11 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
12 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
| 12 |
import in.shop2020.thrift.clients.LogisticsServiceClient;
|
13 |
import in.shop2020.thrift.clients.LogisticsServiceClient;
|
| 13 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
14 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
| - |
|
15 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 14 |
|
16 |
|
| 15 |
import java.io.ByteArrayOutputStream;
|
17 |
import java.io.ByteArrayOutputStream;
|
| 16 |
import java.io.File;
|
18 |
import java.io.File;
|
| 17 |
import java.io.FileOutputStream;
|
19 |
import java.io.FileOutputStream;
|
| 18 |
import java.io.IOException;
|
20 |
import java.io.IOException;
|
| Line 62... |
Line 64... |
| 62 |
|
64 |
|
| 63 |
Order order = null;
|
65 |
Order order = null;
|
| 64 |
Warehouse warehouse = null;
|
66 |
Warehouse warehouse = null;
|
| 65 |
Provider provider = null;
|
67 |
Provider provider = null;
|
| 66 |
String destCode = null;
|
68 |
String destCode = null;
|
| - |
|
69 |
int barcodeFontSize = 0;
|
| 67 |
try {
|
70 |
try {
|
| 68 |
order = tclient.getOrder(orderId);
|
71 |
order = tclient.getOrder(orderId);
|
| 69 |
warehouse = iclient.getWarehouse(order.getWarehouse_id());
|
72 |
warehouse = iclient.getWarehouse(order.getWarehouse_id());
|
| 70 |
long providerId = order.getLogistics_provider_id();
|
73 |
long providerId = order.getLogistics_provider_id();
|
| 71 |
provider = logisticsClient.getProvider(providerId);
|
74 |
provider = logisticsClient.getProvider(providerId);
|
| 72 |
destCode = logisticsClient.getDestinationCode(providerId, order.getCustomer_pincode());
|
75 |
destCode = logisticsClient.getDestinationCode(providerId, order.getCustomer_pincode());
|
| - |
|
76 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
| 73 |
} catch (TransactionServiceException e1) {
|
77 |
} catch (TransactionServiceException e1) {
|
| 74 |
e1.printStackTrace();
|
78 |
e1.printStackTrace();
|
| 75 |
return baosPDF;
|
79 |
return baosPDF;
|
| 76 |
} catch (TException e1) {
|
80 |
} catch (TException e1) {
|
| 77 |
e1.printStackTrace();
|
81 |
e1.printStackTrace();
|
| Line 80... |
Line 84... |
| 80 |
e.printStackTrace();
|
84 |
e.printStackTrace();
|
| 81 |
return baosPDF;
|
85 |
return baosPDF;
|
| 82 |
} catch (LogisticsServiceException e) {
|
86 |
} catch (LogisticsServiceException e) {
|
| 83 |
e.printStackTrace();
|
87 |
e.printStackTrace();
|
| 84 |
return baosPDF;
|
88 |
return baosPDF;
|
| - |
|
89 |
} catch (ConfigException e) {
|
| - |
|
90 |
e.printStackTrace();
|
| - |
|
91 |
return baosPDF;
|
| 85 |
}
|
92 |
}
|
| 86 |
|
93 |
|
| 87 |
try {
|
94 |
try {
|
| 88 |
baosPDF = new ByteArrayOutputStream();
|
95 |
baosPDF = new ByteArrayOutputStream();
|
| 89 |
|
96 |
|
| 90 |
String fontPath = InvoiceGenerationService.class.getResource("/" + provider.getName().toLowerCase() + "/barcode.TTF").getPath();
|
97 |
String fontPath = InvoiceGenerationService.class.getResource("/" + provider.getName().toLowerCase() + "/barcode.TTF").getPath();
|
| 91 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
98 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
| 92 |
ttfFontFactory.register(fontPath, "barcode");
|
99 |
ttfFontFactory.register(fontPath, "barcode");
|
| 93 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, 32);
|
100 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, barcodeFontSize);
|
| 94 |
Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
|
101 |
Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
|
| 95 |
Font helvetica10 = FontFactory.getFont(FontFactory.HELVETICA, 10);
|
102 |
Font helvetica10 = FontFactory.getFont(FontFactory.HELVETICA, 10);
|
| 96 |
Font helvetica12 = FontFactory.getFont(FontFactory.HELVETICA, 12);
|
103 |
Font helvetica12 = FontFactory.getFont(FontFactory.HELVETICA, 12);
|
| 97 |
Font helvetica16 = FontFactory.getFont(FontFactory.HELVETICA, 16);
|
104 |
Font helvetica16 = FontFactory.getFont(FontFactory.HELVETICA, 16);
|
| 98 |
|
105 |
|