| Line 57... |
Line 57... |
| 57 |
} catch (Exception e) {
|
57 |
} catch (Exception e) {
|
| 58 |
logger.error("Error while initializing one of the thrift clients", e);
|
58 |
logger.error("Error while initializing one of the thrift clients", e);
|
| 59 |
}
|
59 |
}
|
| 60 |
}
|
60 |
}
|
| 61 |
|
61 |
|
| 62 |
public ByteArrayOutputStream generateManifestFile(long warehouseId, long providerId, boolean isCod) {
|
62 |
public ByteArrayOutputStream generateManifestFile(long warehouseId, long providerId, boolean isCod, List<Long> orderIds) {
|
| 63 |
ByteArrayOutputStream baosPDF = null;
|
63 |
ByteArrayOutputStream baosPDF = null;
|
| 64 |
in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
|
64 |
in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
|
| 65 |
in.shop2020.model.v1.catalog.InventoryService.Client inventoryClient = csc.getClient();
|
65 |
in.shop2020.model.v1.catalog.InventoryService.Client inventoryClient = csc.getClient();
|
| 66 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
66 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
| 67 |
|
67 |
|
| Line 71... |
Line 71... |
| 71 |
|
71 |
|
| 72 |
List<Order> orders = null;
|
72 |
List<Order> orders = null;
|
| 73 |
Warehouse warehouse = null;
|
73 |
Warehouse warehouse = null;
|
| 74 |
Provider provider = null;
|
74 |
Provider provider = null;
|
| 75 |
try {
|
75 |
try {
|
| 76 |
if(!txnClient.markOrdersAsManifested(warehouseId, providerId, isCod)){
|
76 |
// if(!txnClient.markOrdersAsManifested(warehouseId, providerId, isCod)){
|
| 77 |
return baosPDF;
|
77 |
// return baosPDF;
|
| 78 |
}
|
78 |
// }
|
| 79 |
orders = txnClient.getOrdersInBatch(statuses, 0, 0, warehouseId);
|
79 |
orders = txnClient.getOrdersInBatch(statuses, 0, 0, warehouseId);
|
| 80 |
warehouse = inventoryClient.getWarehouse(warehouseId);
|
80 |
warehouse = inventoryClient.getWarehouse(warehouseId);
|
| 81 |
provider = logisticsClient.getProvider(providerId);
|
81 |
provider = logisticsClient.getProvider(providerId);
|
| 82 |
} catch (TException e) {
|
82 |
} catch (TException e) {
|
| 83 |
logger.error("Error getting information from one of the Thrift Services: ", e);
|
83 |
logger.error("Error getting information from one of the Thrift Services: ", e);
|
| Line 127... |
Line 127... |
| 127 |
ordersTable.addCell(new Phrase("State", helvetica8));
|
127 |
ordersTable.addCell(new Phrase("State", helvetica8));
|
| 128 |
|
128 |
|
| 129 |
int serialNo = 0;
|
129 |
int serialNo = 0;
|
| 130 |
for(int i=0; i < orders.size();i++){
|
130 |
for(int i=0; i < orders.size();i++){
|
| 131 |
Order order = orders.get(i);
|
131 |
Order order = orders.get(i);
|
| - |
|
132 |
if(!orderIds.contains(order.getId()))
|
| - |
|
133 |
continue;
|
| 132 |
if(order.getLogistics_provider_id()!=providerId)
|
134 |
if(order.getLogistics_provider_id()!=providerId)
|
| 133 |
continue;
|
135 |
continue;
|
| 134 |
if(order.isCod() != isCod)
|
136 |
if(order.isCod() != isCod)
|
| 135 |
continue;
|
137 |
continue;
|
| 136 |
//TODO: These are exactly the orders which will be shipped now. Shouldn't we change their status to be SHIPPED?
|
138 |
//TODO: These are exactly the orders which will be shipped now. Shouldn't we change their status to be SHIPPED?
|
| Line 175... |
Line 177... |
| 175 |
return baosPDF;
|
177 |
return baosPDF;
|
| 176 |
}
|
178 |
}
|
| 177 |
|
179 |
|
| 178 |
public static void main(String[] args) throws IOException {
|
180 |
public static void main(String[] args) throws IOException {
|
| 179 |
ManifestGenerator manifestGenerator = new ManifestGenerator();
|
181 |
ManifestGenerator manifestGenerator = new ManifestGenerator();
|
| 180 |
ByteArrayOutputStream baos = manifestGenerator.generateManifestFile(1, 1, true);
|
182 |
ByteArrayOutputStream baos = manifestGenerator.generateManifestFile(1, 1, true, null);
|
| 181 |
File f = new File("/home/ashish/Downloads/manifest-1-2.pdf");
|
183 |
File f = new File("/home/ashish/Downloads/manifest-1-2.pdf");
|
| 182 |
FileOutputStream fos = new FileOutputStream(f);
|
184 |
FileOutputStream fos = new FileOutputStream(f);
|
| 183 |
baos.writeTo(fos);
|
185 |
baos.writeTo(fos);
|
| 184 |
}
|
186 |
}
|
| 185 |
}
|
187 |
}
|