| Line 50... |
Line 50... |
| 50 |
String [] nextLine;
|
50 |
String [] nextLine;
|
| 51 |
try {
|
51 |
try {
|
| 52 |
int count =1;
|
52 |
int count =1;
|
| 53 |
Map<Date,Map<Long,FbaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<Long,FbaSalesSnapshot>>();
|
53 |
Map<Date,Map<Long,FbaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<Long,FbaSalesSnapshot>>();
|
| 54 |
while ((nextLine = orderreportreader.readNext()) != null) {
|
54 |
while ((nextLine = orderreportreader.readNext()) != null) {
|
| 55 |
try{
|
- |
|
| 56 |
if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
|
55 |
if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
|
| 57 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
56 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
| 58 |
istFormatter .setLenient(false);
|
57 |
istFormatter .setLenient(false);
|
| 59 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
58 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
| 60 |
istFormatter.setTimeZone(zone);
|
59 |
istFormatter.setTimeZone(zone);
|
| 61 |
Date date = istFormatter.parse(nextLine[2]);
|
60 |
Date date = istFormatter.parse(nextLine[2]);
|
| 62 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
61 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
| 63 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
62 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
| 64 |
if(nextLine[11].equals("FBA13465")){
|
63 |
if(nextLine[11].equals("FBA13465")){
|
| 65 |
System.out.println("Order Details " + nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[14] + " " + nextLine[4] + " " + nextLine[13] );
|
64 |
System.out.println("Order Details " + nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[14] + " " + nextLine[4] + " " + nextLine[13] );
|
| 66 |
}
|
65 |
}
|
| 67 |
Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
|
66 |
Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
|
| 68 |
Integer qty=0;
|
67 |
Integer qty=0;
|
| 69 |
if(nextLine[14].length()!=0){
|
68 |
if(nextLine[14].length()!=0){
|
| 70 |
qty = new Integer(nextLine[14]);
|
69 |
qty = new Integer(nextLine[14]);
|
| 71 |
}
|
70 |
}
|
| 72 |
Float itemSale = null;
|
71 |
Float itemSale = null;
|
| 73 |
if(nextLine[16].length()!=0){
|
72 |
if(nextLine[16].length()!=0){
|
| 74 |
itemSale = new Float(nextLine[16]);
|
73 |
itemSale = new Float(nextLine[16]);
|
| 75 |
}
|
74 |
}
|
| 76 |
else{
|
75 |
else{
|
| 77 |
itemSale = (float) 0;
|
76 |
itemSale = (float) 0;
|
| 78 |
}
|
77 |
}
|
| 79 |
Float itemDiscount;
|
78 |
Float itemDiscount;
|
| 80 |
if(nextLine[22].length()!=0){
|
79 |
if(nextLine[22].length()!=0){
|
| 81 |
itemDiscount = new Float(nextLine[22]);
|
80 |
itemDiscount = new Float(nextLine[22]);
|
| 82 |
}
|
81 |
}
|
| 83 |
else{
|
82 |
else{
|
| 84 |
itemDiscount = new Float(0);
|
83 |
itemDiscount = new Float(0);
|
| 85 |
}
|
84 |
}
|
| 86 |
if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[13].equalsIgnoreCase("Cancelled")){
|
85 |
if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[13].equalsIgnoreCase("Cancelled")){
|
| 87 |
itemSale = (float) 0;
|
86 |
itemSale = (float) 0;
|
| 88 |
itemDiscount = (float) 0;
|
87 |
itemDiscount = (float) 0;
|
| 89 |
qty = 0;
|
88 |
qty = 0;
|
| 90 |
}
|
89 |
}
|
| 91 |
if(itemid==13465){
|
90 |
if(itemid==13465){
|
| 92 |
System.out.println("Order Details after parsing " + nextLine[0]+" "+date_key+" "+ itemid +" " + qty);
|
91 |
System.out.println("Order Details after parsing " + nextLine[0]+" "+date_key+" "+ itemid +" " + qty);
|
| 93 |
}
|
92 |
}
|
| 94 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
93 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
| 95 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap;
|
94 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap;
|
| 96 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
95 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
| 97 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
96 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
| 98 |
if(itemDiscount!=0){
|
97 |
if(itemDiscount!=0){
|
| 99 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
98 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
| 100 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
99 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
| 101 |
}
|
- |
|
| 102 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
- |
|
| 103 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
- |
|
| 104 |
ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
- |
|
| 105 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
- |
|
| 106 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
- |
|
| 107 |
}
|
- |
|
| 108 |
else{
|
- |
|
| 109 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
- |
|
| 110 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
- |
|
| 111 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
- |
|
| 112 |
if(itemDiscount!=0){
|
- |
|
| 113 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
- |
|
| 114 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
- |
|
| 115 |
}
|
- |
|
| 116 |
else{
|
- |
|
| 117 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 118 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 119 |
}
|
- |
|
| 120 |
ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
- |
|
| 121 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
- |
|
| 122 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
- |
|
| 123 |
}
|
100 |
}
|
| - |
|
101 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
| - |
|
102 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
| - |
|
103 |
ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
| - |
|
104 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
| - |
|
105 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| 124 |
}
|
106 |
}
|
| 125 |
else{
|
107 |
else{
|
| 126 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
- |
|
| 127 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
108 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 128 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
109 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 129 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
110 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
| 130 |
if(itemDiscount!=0){
|
111 |
if(itemDiscount!=0){
|
| 131 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
- |
|
| 132 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
112 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| - |
|
113 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| 133 |
}
|
114 |
}
|
| 134 |
else{
|
115 |
else{
|
| 135 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 136 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
116 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| - |
|
117 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 137 |
}
|
118 |
}
|
| - |
|
119 |
ItemIdFbaSaleSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
| 138 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
120 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
| 139 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
121 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| 140 |
}
|
122 |
}
|
| 141 |
}
|
123 |
}
|
| - |
|
124 |
else{
|
| - |
|
125 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
| - |
|
126 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| - |
|
127 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| - |
|
128 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
| - |
|
129 |
if(itemDiscount!=0){
|
| - |
|
130 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| - |
|
131 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 142 |
}
|
132 |
}
|
| 143 |
catch(Exception e){
|
133 |
else{
|
| - |
|
134 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| 144 |
e.printStackTrace();
|
135 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| - |
|
136 |
}
|
| - |
|
137 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
| - |
|
138 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| - |
|
139 |
}
|
| 145 |
}
|
140 |
}
|
| 146 |
count++;
|
141 |
count++;
|
| 147 |
}
|
142 |
}
|
| 148 |
InventoryClient inventoryServiceClient = null;
|
143 |
InventoryClient inventoryServiceClient = null;
|
| 149 |
TransactionClient transactionServiceClient = null;
|
144 |
TransactionClient transactionServiceClient = null;
|