| 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{
|
| 55 |
if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
|
56 |
if(count!=1 && nextLine[5].equalsIgnoreCase("Amazon") && nextLine[6].equalsIgnoreCase("Amazon.in")){
|
| 56 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
57 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
| 57 |
istFormatter .setLenient(false);
|
58 |
istFormatter .setLenient(false);
|
| 58 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
59 |
TimeZone zone= TimeZone.getTimeZone("GMT");
|
| 59 |
istFormatter.setTimeZone(zone);
|
60 |
istFormatter.setTimeZone(zone);
|
| 60 |
Date date = istFormatter.parse(nextLine[2]);
|
61 |
Date date = istFormatter.parse(nextLine[2]);
|
| 61 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
62 |
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
| 62 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
63 |
Date date_key = dateFormat.parse(dateFormat.format(date));
|
| 63 |
System.out.println(nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[13] + " " + nextLine[14]);
|
64 |
System.out.println(nextLine[0]+" "+date_key+" "+ nextLine[11] +" " + nextLine[13] + " " + nextLine[14]);
|
| 64 |
Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
|
65 |
Long itemid = Long.parseLong(nextLine[11].replaceAll("FBA",""));
|
| 65 |
Integer qty=0;
|
66 |
Integer qty=0;
|
| 66 |
if(nextLine[14].length()!=0){
|
67 |
if(nextLine[14].length()!=0){
|
| 67 |
qty = new Integer(nextLine[14]);
|
68 |
qty = new Integer(nextLine[14]);
|
| 68 |
}
|
69 |
}
|
| 69 |
Float itemSale = null;
|
70 |
Float itemSale = null;
|
| 70 |
if(nextLine[16].length()!=0){
|
71 |
if(nextLine[16].length()!=0){
|
| 71 |
itemSale = new Float(nextLine[16]);
|
72 |
itemSale = new Float(nextLine[16]);
|
| 72 |
}
|
73 |
}
|
| 73 |
else{
|
74 |
else{
|
| 74 |
continue;
|
75 |
continue;
|
| 75 |
}
|
76 |
}
|
| 76 |
Float itemDiscount;
|
77 |
Float itemDiscount;
|
| 77 |
if(nextLine[22].length()!=0){
|
78 |
if(nextLine[22].length()!=0){
|
| 78 |
itemDiscount = new Float(nextLine[22]);
|
79 |
itemDiscount = new Float(nextLine[22]);
|
| 79 |
}
|
80 |
}
|
| 80 |
else{
|
81 |
else{
|
| 81 |
itemDiscount = new Float(0);
|
82 |
itemDiscount = new Float(0);
|
| 82 |
}
|
83 |
}
|
| 83 |
if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[4].equalsIgnoreCase("Cancelled")){
|
84 |
if(nextLine[4].equalsIgnoreCase("Cancelled") || nextLine[4].equalsIgnoreCase("Cancelled")){
|
| 84 |
itemSale = (float) 0;
|
85 |
itemSale = (float) 0;
|
| 85 |
itemDiscount = (float) 0;
|
86 |
itemDiscount = (float) 0;
|
| 86 |
qty = 0;
|
87 |
qty = 0;
|
| 87 |
}
|
88 |
}
|
| 88 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
89 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
| 89 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
90 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(itemid)){
|
| 90 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
91 |
FbaSalesSnapshot fbaSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(itemid);
|
| 91 |
if(itemDiscount!=0){
|
92 |
if(itemDiscount!=0){
|
| 92 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
93 |
fbaSalesSnapshot.setPromotionOrderCount(fbaSalesSnapshot.getPromotionOrderCount()+qty);
|
| 93 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
94 |
fbaSalesSnapshot.setTotalPromotionSale(fbaSalesSnapshot.getTotalPromotionSale() + (itemSale - itemDiscount));
|
| - |
|
95 |
}
|
| - |
|
96 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
| - |
|
97 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
| - |
|
98 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
| - |
|
99 |
}
|
| - |
|
100 |
else{
|
| - |
|
101 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| - |
|
102 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| - |
|
103 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
| - |
|
104 |
if(itemDiscount!=0){
|
| - |
|
105 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| - |
|
106 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| - |
|
107 |
}
|
| - |
|
108 |
else{
|
| - |
|
109 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| - |
|
110 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| - |
|
111 |
}
|
| - |
|
112 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
| 94 |
}
|
113 |
}
|
| 95 |
fbaSalesSnapshot.setTotalOrderCount(fbaSalesSnapshot.getTotalOrderCount() + qty);
|
- |
|
| 96 |
fbaSalesSnapshot.setTotalSale(fbaSalesSnapshot.getTotalSale() + itemSale - itemDiscount);
|
- |
|
| 97 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
- |
|
| 98 |
}
|
114 |
}
|
| 99 |
else{
|
115 |
else{
|
| - |
|
116 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
| 100 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
117 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
| 101 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
118 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
| 102 |
fbaSalesSnapshot.setTotalSale(itemSale - itemDiscount);
|
119 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
| 103 |
if(itemDiscount!=0){
|
120 |
if(itemDiscount!=0){
|
| 104 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
- |
|
| 105 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
121 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
| - |
|
122 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
| 106 |
}
|
123 |
}
|
| 107 |
else{
|
124 |
else{
|
| 108 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 109 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
125 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
| - |
|
126 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
| 110 |
}
|
127 |
}
|
| 111 |
orderDateItemIdFbaSaleSnapshotMap.get(date_key).put(itemid,fbaSalesSnapshot);
|
128 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
| 112 |
}
|
- |
|
| 113 |
}
|
- |
|
| 114 |
else{
|
- |
|
| 115 |
Map<Long,FbaSalesSnapshot> ItemIdFbaSaleSnapshotMap = new HashMap<Long,FbaSalesSnapshot>();
|
129 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
| 116 |
FbaSalesSnapshot fbaSalesSnapshot = new FbaSalesSnapshot();
|
- |
|
| 117 |
fbaSalesSnapshot.setTotalOrderCount(qty);
|
- |
|
| 118 |
fbaSalesSnapshot.setTotalSale(itemSale);
|
- |
|
| 119 |
if(itemDiscount!=0){
|
- |
|
| 120 |
fbaSalesSnapshot.setTotalPromotionSale(itemSale - itemDiscount);
|
- |
|
| 121 |
fbaSalesSnapshot.setPromotionOrderCount(qty);
|
- |
|
| 122 |
}
|
- |
|
| 123 |
else{
|
- |
|
| 124 |
fbaSalesSnapshot.setTotalPromotionSale((float) 0);
|
- |
|
| 125 |
fbaSalesSnapshot.setPromotionOrderCount(0);
|
- |
|
| 126 |
}
|
130 |
}
|
| 127 |
ItemIdFbaSaleSnapshotMap.put(itemid,fbaSalesSnapshot);
|
- |
|
| 128 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key,ItemIdFbaSaleSnapshotMap);
|
- |
|
| 129 |
}
|
131 |
}
|
| 130 |
}
|
132 |
}
|
| - |
|
133 |
catch(Exception e){
|
| - |
|
134 |
e.printStackTrace();
|
| - |
|
135 |
}
|
| 131 |
count++;
|
136 |
count++;
|
| 132 |
}
|
137 |
}
|
| 133 |
InventoryClient inventoryServiceClient = null;
|
138 |
InventoryClient inventoryServiceClient = null;
|
| 134 |
TransactionClient transactionServiceClient = null;
|
139 |
TransactionClient transactionServiceClient = null;
|
| 135 |
CatalogClient catalogServiceClient = null;
|
140 |
CatalogClient catalogServiceClient = null;
|
| Line 155... |
Line 160... |
| 155 |
Date date_start = dateFormat.parse(dateFormat.format(cal.getTime()));
|
160 |
Date date_start = dateFormat.parse(dateFormat.format(cal.getTime()));
|
| 156 |
System.out.println("Start Date = " + date_start);
|
161 |
System.out.println("Start Date = " + date_start);
|
| 157 |
System.out.println("End Date = " + date_end);
|
162 |
System.out.println("End Date = " + date_end);
|
| 158 |
Date d = date_start;
|
163 |
Date d = date_start;
|
| 159 |
while(!d.equals(date_end)){
|
164 |
while(!d.equals(date_end)){
|
| 160 |
cal.setTime(d);
|
165 |
cal.setTime(d);
|
| 161 |
cal.add(Calendar.DATE,1);
|
166 |
cal.add(Calendar.DATE,1);
|
| 162 |
d = cal.getTime();
|
167 |
d = cal.getTime();
|
| 163 |
dates.add(d);
|
168 |
dates.add(d);
|
| 164 |
}
|
169 |
}
|
| 165 |
List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist = inventoryClient.getAllAmazonFbaItemInventory();
|
170 |
List<AmazonFbaInventorySnapshot> nonzeroFbaInventorySnapshotlist = inventoryClient.getAllAmazonFbaItemInventory();
|
| 166 |
for(Date date:dates){
|
171 |
for(Date date:dates){
|
| Line 351... |
Line 356... |
| 351 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
356 |
amazonfbasalessnapshot.setAmazonFbaInventory(inventory);
|
| 352 |
transactionClient.addOrUpdateAmazonFbaSalesSnapshot(amazonfbasalessnapshot);
|
357 |
transactionClient.addOrUpdateAmazonFbaSalesSnapshot(amazonfbasalessnapshot);
|
| 353 |
}
|
358 |
}
|
| 354 |
}
|
359 |
}
|
| 355 |
}
|
360 |
}
|
| 356 |
|
361 |
|
| 357 |
catch (IOException e) {
|
362 |
catch (IOException e) {
|
| 358 |
// TODO Auto-generated catch block
|
363 |
// TODO Auto-generated catch block
|
| 359 |
e.printStackTrace();
|
364 |
e.printStackTrace();
|
| 360 |
} catch (ParseException e) {
|
365 |
} catch (ParseException e) {
|
| 361 |
// TODO Auto-generated catch block
|
366 |
// TODO Auto-generated catch block
|