| 21234 |
kshitij.so |
1 |
package in.shop2020.hotspot.dashbaord.server;
|
|
|
2 |
|
| 21237 |
kshitij.so |
3 |
import in.shop2020.model.v1.order.Order;
|
|
|
4 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
| 21234 |
kshitij.so |
5 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
6 |
|
|
|
7 |
import java.io.File;
|
|
|
8 |
import java.io.FileInputStream;
|
|
|
9 |
import java.util.ArrayList;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
|
|
|
12 |
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
13 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
14 |
import org.slf4j.Logger;
|
|
|
15 |
import org.slf4j.LoggerFactory;
|
|
|
16 |
|
|
|
17 |
public class ProcessBulkBilling{
|
|
|
18 |
private static Logger logger = LoggerFactory.getLogger(ProcessBulkBilling.class);
|
| 21237 |
kshitij.so |
19 |
|
|
|
20 |
private String fileName;
|
|
|
21 |
private String logisticsTransactionId;
|
|
|
22 |
private String packageDimensions;
|
|
|
23 |
private ArrayList<String> imei_list = new ArrayList<String>();
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
ProcessBulkBilling(String fileName, String logisticsTransactionId, String packageDimensions) {
|
|
|
27 |
logger.info("FileName "+fileName+" logisticsTransactionId "+logisticsTransactionId+" packageDimension "+packageDimensions);
|
|
|
28 |
this.fileName = fileName;
|
|
|
29 |
this.logisticsTransactionId = logisticsTransactionId;
|
|
|
30 |
this.packageDimensions = packageDimensions;
|
|
|
31 |
}
|
| 21234 |
kshitij.so |
32 |
|
| 21237 |
kshitij.so |
33 |
public boolean processReport() {
|
| 21234 |
kshitij.so |
34 |
logger.info("Inside bulk billing process");
|
|
|
35 |
try{
|
|
|
36 |
|
|
|
37 |
FileInputStream iFile = new FileInputStream(new File(fileName));
|
|
|
38 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
|
|
39 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
40 |
|
|
|
41 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 21237 |
kshitij.so |
42 |
String imei = (sheet.getRow(iterator).getCell(0).getStringCellValue()).trim();
|
|
|
43 |
if (imei == null || imei.isEmpty()){
|
|
|
44 |
break;
|
|
|
45 |
}
|
|
|
46 |
imei_list.add(imei);
|
| 21234 |
kshitij.so |
47 |
}
|
|
|
48 |
return true;
|
|
|
49 |
}
|
|
|
50 |
catch(Exception e){
|
|
|
51 |
e.printStackTrace();
|
|
|
52 |
return false;
|
|
|
53 |
}
|
|
|
54 |
}
|
| 21237 |
kshitij.so |
55 |
|
|
|
56 |
public String checkBillingDetails(){
|
|
|
57 |
List<Order> orders_list;
|
|
|
58 |
try{
|
|
|
59 |
Client tc = new TransactionClient().getClient();
|
|
|
60 |
orders_list = tc.getGroupOrdersByLogisticsTxnId(logisticsTransactionId);
|
|
|
61 |
}
|
|
|
62 |
catch(Exception e){
|
|
|
63 |
e.printStackTrace();
|
|
|
64 |
return "Service Error!!!";
|
|
|
65 |
}
|
|
|
66 |
long total_quantity = 0;
|
|
|
67 |
for (Order o : orders_list){
|
|
|
68 |
total_quantity = (long) (total_quantity + o.getLineitems().get(0).getQuantity());
|
|
|
69 |
}
|
|
|
70 |
if (total_quantity != imei_list.size()){
|
|
|
71 |
return "Quantity and imei mismatch.Supplied imei's not equal to quantity to bill";
|
|
|
72 |
}
|
|
|
73 |
return "Success";
|
|
|
74 |
}
|
| 21234 |
kshitij.so |
75 |
|
|
|
76 |
}
|