| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.services;
|
1 |
package in.shop2020.support.services;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.logistics.DeliveryType;
|
3 |
import in.shop2020.logistics.DeliveryType;
|
| 4 |
import in.shop2020.logistics.LogisticsServiceException;
|
4 |
import in.shop2020.logistics.LogisticsServiceException;
|
| - |
|
5 |
import in.shop2020.logistics.PickupStore;
|
| 5 |
import in.shop2020.logistics.Provider;
|
6 |
import in.shop2020.logistics.Provider;
|
| 6 |
import in.shop2020.logistics.ProviderDetails;
|
7 |
import in.shop2020.logistics.ProviderDetails;
|
| 7 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
8 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 8 |
import in.shop2020.model.v1.inventory.Warehouse;
|
9 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 9 |
import in.shop2020.model.v1.order.LineItem;
|
10 |
import in.shop2020.model.v1.order.LineItem;
|
| Line 18... |
Line 19... |
| 18 |
import java.io.FileNotFoundException;
|
19 |
import java.io.FileNotFoundException;
|
| 19 |
import java.io.FileOutputStream;
|
20 |
import java.io.FileOutputStream;
|
| 20 |
import java.io.IOException;
|
21 |
import java.io.IOException;
|
| 21 |
import java.util.ArrayList;
|
22 |
import java.util.ArrayList;
|
| 22 |
import java.util.Date;
|
23 |
import java.util.Date;
|
| - |
|
24 |
import java.util.HashMap;
|
| 23 |
import java.util.List;
|
25 |
import java.util.List;
|
| - |
|
26 |
import java.util.Map;
|
| 24 |
|
27 |
|
| 25 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
28 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| 26 |
import org.apache.poi.ss.usermodel.Cell;
|
29 |
import org.apache.poi.ss.usermodel.Cell;
|
| 27 |
import org.apache.poi.ss.usermodel.CellStyle;
|
30 |
import org.apache.poi.ss.usermodel.CellStyle;
|
| 28 |
import org.apache.poi.ss.usermodel.CreationHelper;
|
31 |
import org.apache.poi.ss.usermodel.CreationHelper;
|
| Line 93... |
Line 96... |
| 93 |
// Create the header row and put all the titles in it. Rows are 0 based.
|
96 |
// Create the header row and put all the titles in it. Rows are 0 based.
|
| 94 |
Row headerRow = sheet.createRow((short)0);
|
97 |
Row headerRow = sheet.createRow((short)0);
|
| 95 |
headerRow.createCell(0).setCellValue("Sl No");
|
98 |
headerRow.createCell(0).setCellValue("Sl No");
|
| 96 |
headerRow.createCell(1).setCellValue("AWB No");
|
99 |
headerRow.createCell(1).setCellValue("AWB No");
|
| 97 |
headerRow.createCell(2).setCellValue("AWB Date");
|
100 |
headerRow.createCell(2).setCellValue("AWB Date");
|
| 98 |
headerRow.createCell(3).setCellValue("Order No");
|
101 |
headerRow.createCell(3).setCellValue("Saholic Order Id");
|
| 99 |
headerRow.createCell(4).setCellValue("Name");
|
102 |
headerRow.createCell(4).setCellValue("Name");
|
| 100 |
headerRow.createCell(5).setCellValue("Address 1");
|
103 |
headerRow.createCell(5).setCellValue("Address 1");
|
| 101 |
headerRow.createCell(6).setCellValue("Address 2");
|
104 |
headerRow.createCell(6).setCellValue("Address 2");
|
| 102 |
headerRow.createCell(7).setCellValue("City");
|
105 |
headerRow.createCell(7).setCellValue("City");
|
| 103 |
headerRow.createCell(8).setCellValue("State");
|
106 |
headerRow.createCell(8).setCellValue("State");
|
| Line 105... |
Line 108... |
| 105 |
headerRow.createCell(10).setCellValue("Telephone No 1");
|
108 |
headerRow.createCell(10).setCellValue("Telephone No 1");
|
| 106 |
headerRow.createCell(11).setCellValue("Telephone No 2");
|
109 |
headerRow.createCell(11).setCellValue("Telephone No 2");
|
| 107 |
headerRow.createCell(12).setCellValue("Paymode");
|
110 |
headerRow.createCell(12).setCellValue("Paymode");
|
| 108 |
headerRow.createCell(13).setCellValue("Amount to be Collected");
|
111 |
headerRow.createCell(13).setCellValue("Amount to be Collected");
|
| 109 |
headerRow.createCell(14).setCellValue("Shipment Value");
|
112 |
headerRow.createCell(14).setCellValue("Shipment Value");
|
| 110 |
headerRow.createCell(15).setCellValue("Item ID");
|
- |
|
| 111 |
headerRow.createCell(16).setCellValue("Packet Weight(in Kg)");
|
113 |
headerRow.createCell(15).setCellValue("Packet Weight(in Kg)");
|
| 112 |
headerRow.createCell(17).setCellValue("Product Name");
|
114 |
headerRow.createCell(16).setCellValue("Product Name");
|
| 113 |
headerRow.createCell(18).setCellValue("Pickup Location");
|
115 |
headerRow.createCell(17).setCellValue("Pickup Location");
|
| 114 |
headerRow.createCell(19).setCellValue("Customer A/C Code");
|
116 |
headerRow.createCell(18).setCellValue("Customer A/C Code");
|
| 115 |
|
117 |
|
| 116 |
String accountNo = "";
|
118 |
String accountNo = "";
|
| 117 |
DeliveryType dt = DeliveryType.PREPAID;
|
119 |
DeliveryType dt = DeliveryType.PREPAID;
|
| 118 |
if (isCod) {
|
120 |
if (isCod) {
|
| 119 |
dt = DeliveryType.COD;
|
121 |
dt = DeliveryType.COD;
|
| Line 125... |
Line 127... |
| 125 |
}
|
127 |
}
|
| 126 |
}
|
128 |
}
|
| 127 |
Date awbDate = new Date();
|
129 |
Date awbDate = new Date();
|
| 128 |
String location = removeNewLines(warehouse.getLocation());
|
130 |
String location = removeNewLines(warehouse.getLocation());
|
| 129 |
|
131 |
|
| - |
|
132 |
Map<String, List<Order>> logisticsTxnIdOrdersMap = new HashMap<String, List<Order>>();
|
| - |
|
133 |
Map<Long, String> itemNamesMap = new HashMap<Long, String>();
|
| - |
|
134 |
Map<String, Map<Long, Double>> logisticsTxnIdOrderQuantityMap = new HashMap<String, Map<Long, Double>>();
|
| - |
|
135 |
|
| - |
|
136 |
for(Order order:orders){
|
| - |
|
137 |
if(order.getLogistics_provider_id()!=providerId)
|
| - |
|
138 |
continue;
|
| - |
|
139 |
if(order.isLogisticsCod() != isCod)
|
| - |
|
140 |
continue;
|
| - |
|
141 |
LineItem lineItem = order.getLineitems().get(0);
|
| - |
|
142 |
if(order.isSetLogisticsTransactionId()){
|
| - |
|
143 |
if(logisticsTxnIdOrdersMap.containsKey(order.getLogisticsTransactionId())){
|
| - |
|
144 |
List<Order> orderList = logisticsTxnIdOrdersMap.get(order.getLogisticsTransactionId());
|
| - |
|
145 |
orderList.add(order);
|
| - |
|
146 |
logisticsTxnIdOrdersMap.put(order.getLogisticsTransactionId(), orderList);
|
| - |
|
147 |
} else{
|
| - |
|
148 |
List<Order> orderList = new ArrayList<Order>();
|
| - |
|
149 |
orderList.add(order);
|
| - |
|
150 |
logisticsTxnIdOrdersMap.put(order.getLogisticsTransactionId(), orderList);
|
| - |
|
151 |
}
|
| - |
|
152 |
if(logisticsTxnIdOrderQuantityMap.containsKey(order.getLogisticsTransactionId())){
|
| - |
|
153 |
Map<Long, Double> orderItemQuantityMap = logisticsTxnIdOrderQuantityMap.get(order.getLogisticsTransactionId());
|
| - |
|
154 |
double orderQuantity = orderItemQuantityMap.get(lineItem.getItem_id())+ lineItem.getQuantity();
|
| - |
|
155 |
orderItemQuantityMap.put(lineItem.getItem_id(),orderQuantity);
|
| - |
|
156 |
logisticsTxnIdOrderQuantityMap.put(order.getLogisticsTransactionId(), orderItemQuantityMap);
|
| - |
|
157 |
}else{
|
| - |
|
158 |
Map<Long, Double> orderItemQuantityMap = new HashMap<Long, Double>();
|
| - |
|
159 |
orderItemQuantityMap.put(lineItem.getItem_id(), lineItem.getQuantity());
|
| - |
|
160 |
logisticsTxnIdOrderQuantityMap.put(order.getLogisticsTransactionId(), orderItemQuantityMap);
|
| - |
|
161 |
}
|
| - |
|
162 |
}else{
|
| - |
|
163 |
List<Order> orderList = new ArrayList<Order>();
|
| - |
|
164 |
orderList.add(order);
|
| - |
|
165 |
logisticsTxnIdOrdersMap.put(order.getId()+"", orderList);
|
| - |
|
166 |
Map<Long, Double> orderItemQuantityMap = new HashMap<Long, Double>();
|
| - |
|
167 |
orderItemQuantityMap.put(lineItem.getItem_id(), lineItem.getQuantity());
|
| - |
|
168 |
logisticsTxnIdOrderQuantityMap.put(order.getId()+"", orderItemQuantityMap);
|
| - |
|
169 |
}
|
| - |
|
170 |
if(!itemNamesMap.containsKey(lineItem.getItem_id())){
|
| - |
|
171 |
itemNamesMap.put(lineItem.getItem_id(), getItemDisplayName(lineItem, false));
|
| - |
|
172 |
}
|
| - |
|
173 |
}
|
| - |
|
174 |
|
| 130 |
int serialNo = 0;
|
175 |
int serialNo = 0;
|
| - |
|
176 |
for(String logisticsTxnId : logisticsTxnIdOrdersMap.keySet()){
|
| - |
|
177 |
serialNo++;
|
| - |
|
178 |
Row contentRow = sheet.createRow((short)serialNo);
|
| - |
|
179 |
contentRow.createCell(0).setCellValue(serialNo);
|
| - |
|
180 |
List<Order> ordersList = logisticsTxnIdOrdersMap.get(logisticsTxnId);
|
| - |
|
181 |
double totalAmount = 0.0;
|
| - |
|
182 |
double totalWeight = 0.0;
|
| - |
|
183 |
for(Order o:ordersList){
|
| - |
|
184 |
totalAmount = totalAmount + (o.getTotal_amount()-o.getGvAmount());
|
| - |
|
185 |
totalWeight = totalWeight + o.getTotal_weight();
|
| - |
|
186 |
}
|
| - |
|
187 |
Order order = logisticsTxnIdOrdersMap.get(logisticsTxnId).get(0);
|
| - |
|
188 |
contentRow.createCell(1).setCellValue(order.getAirwaybill_no());
|
| - |
|
189 |
Cell awbDateCell = contentRow.createCell(2);
|
| - |
|
190 |
awbDateCell.setCellValue(awbDate);
|
| - |
|
191 |
awbDateCell.setCellStyle(dateCellStyle);
|
| - |
|
192 |
contentRow.createCell(3).setCellValue(logisticsTxnId);
|
| - |
|
193 |
if(order.getPickupStoreId() != 0){
|
| - |
|
194 |
PickupStore store = null;
|
| - |
|
195 |
try {
|
| - |
|
196 |
store = logisticsClient.getPickupStore(order.getPickupStoreId());
|
| - |
|
197 |
} catch (TException e) {
|
| - |
|
198 |
// TODO Auto-generated catch block
|
| - |
|
199 |
e.printStackTrace();
|
| - |
|
200 |
}
|
| - |
|
201 |
contentRow.createCell(4).setCellValue(getValueForEmptyString(store.getName()));
|
| - |
|
202 |
contentRow.createCell(5).setCellValue(getValueForEmptyString(store.getLine1()));
|
| - |
|
203 |
contentRow.createCell(6).setCellValue(getValueForEmptyString(store.getLine2()));
|
| - |
|
204 |
contentRow.createCell(7).setCellValue(getValueForEmptyString(store.getCity()));
|
| - |
|
205 |
contentRow.createCell(8).setCellValue(getValueForEmptyString(store.getState()));
|
| - |
|
206 |
contentRow.createCell(9).setCellValue(getValueForEmptyString(store.getPin()));
|
| - |
|
207 |
contentRow.createCell(10).setCellValue(getValueForEmptyString(store.getPhone()));
|
| - |
|
208 |
}else{
|
| - |
|
209 |
contentRow.createCell(4).setCellValue(getValueForEmptyString(order.getCustomer_name()));
|
| - |
|
210 |
contentRow.createCell(5).setCellValue(getValueForEmptyString(order.getCustomer_address1()));
|
| - |
|
211 |
contentRow.createCell(6).setCellValue(getValueForEmptyString(order.getCustomer_address2()));
|
| - |
|
212 |
contentRow.createCell(7).setCellValue(getValueForEmptyString(order.getCustomer_city()));
|
| - |
|
213 |
contentRow.createCell(8).setCellValue(getValueForEmptyString(order.getCustomer_state()));
|
| - |
|
214 |
contentRow.createCell(9).setCellValue(getValueForEmptyString(order.getCustomer_pincode()));
|
| - |
|
215 |
contentRow.createCell(10).setCellValue(getValueForEmptyString(order.getCustomer_mobilenumber()));
|
| - |
|
216 |
}
|
| - |
|
217 |
contentRow.createCell(11).setCellValue("-");
|
| - |
|
218 |
if(isCod){
|
| - |
|
219 |
contentRow.createCell(12).setCellValue("COD");
|
| - |
|
220 |
contentRow.createCell(13).setCellValue(totalAmount);
|
| - |
|
221 |
} else {
|
| - |
|
222 |
contentRow.createCell(12).setCellValue("Prepaid");
|
| - |
|
223 |
contentRow.createCell(13).setCellValue(0);
|
| - |
|
224 |
}
|
| - |
|
225 |
contentRow.createCell(14).setCellValue(totalAmount);
|
| - |
|
226 |
Cell weightCell = contentRow.createCell(15);
|
| - |
|
227 |
weightCell.setCellValue(totalWeight);
|
| - |
|
228 |
weightCell.setCellStyle(weightStyle);
|
| - |
|
229 |
StringBuffer productNameBuffer = new StringBuffer();
|
| - |
|
230 |
int skuSizeTxn = logisticsTxnIdOrderQuantityMap.get(logisticsTxnId).keySet().size();
|
| - |
|
231 |
int count = 1;
|
| - |
|
232 |
for(Long itemId : logisticsTxnIdOrderQuantityMap.get(logisticsTxnId).keySet()){
|
| - |
|
233 |
Map<Long, Double> quantityMap = logisticsTxnIdOrderQuantityMap.get(logisticsTxnId);
|
| - |
|
234 |
double quantity = quantityMap.get(itemId);
|
| - |
|
235 |
productNameBuffer.append(itemNamesMap.get(itemId)+"("+quantity+")");
|
| - |
|
236 |
if(count<skuSizeTxn){
|
| - |
|
237 |
productNameBuffer.append(",");
|
| - |
|
238 |
}
|
| - |
|
239 |
count++;
|
| - |
|
240 |
}
|
| - |
|
241 |
contentRow.createCell(16).setCellValue(productNameBuffer.toString());
|
| - |
|
242 |
contentRow.createCell(17).setCellValue(location);
|
| - |
|
243 |
contentRow.createCell(18).setCellValue(accountNo);
|
| - |
|
244 |
|
| - |
|
245 |
}
|
| 131 |
for(int i = 0; i<orders.size(); i++){
|
246 |
/*for(int i = 0; i<orders.size(); i++){
|
| 132 |
Order order = orders.get(i);
|
247 |
Order order = orders.get(i);
|
| 133 |
if(order.getLogistics_provider_id()!=providerId)
|
248 |
if(order.getLogistics_provider_id()!=providerId)
|
| 134 |
continue;
|
249 |
continue;
|
| 135 |
if(order.isLogisticsCod() != isCod)
|
250 |
if(order.isLogisticsCod() != isCod)
|
| 136 |
continue;
|
251 |
continue;
|
| Line 166... |
Line 281... |
| 166 |
weightCell.setCellValue(lineItem.getTotal_weight());
|
281 |
weightCell.setCellValue(lineItem.getTotal_weight());
|
| 167 |
weightCell.setCellStyle(weightStyle);
|
282 |
weightCell.setCellStyle(weightStyle);
|
| 168 |
contentRow.createCell(17).setCellValue(lineItem.getBrand() + " " + lineItem.getModel_number() + " " + lineItem.getModel_name() + " " + lineItem.getColor());
|
283 |
contentRow.createCell(17).setCellValue(lineItem.getBrand() + " " + lineItem.getModel_number() + " " + lineItem.getModel_name() + " " + lineItem.getColor());
|
| 169 |
contentRow.createCell(18).setCellValue(location);
|
284 |
contentRow.createCell(18).setCellValue(location);
|
| 170 |
contentRow.createCell(19).setCellValue(accountNo);
|
285 |
contentRow.createCell(19).setCellValue(accountNo);
|
| 171 |
}
|
286 |
}*/
|
| 172 |
|
287 |
|
| 173 |
// Write the workbook to the output stream
|
288 |
// Write the workbook to the output stream
|
| 174 |
try {
|
289 |
try {
|
| 175 |
wb.write(baosXLS);
|
290 |
wb.write(baosXLS);
|
| 176 |
baosXLS.close();
|
291 |
baosXLS.close();
|
| Line 190... |
Line 305... |
| 190 |
|
305 |
|
| 191 |
private String removeNewLines(String str){
|
306 |
private String removeNewLines(String str){
|
| 192 |
return str.replace('\n', ' ');
|
307 |
return str.replace('\n', ' ');
|
| 193 |
}
|
308 |
}
|
| 194 |
|
309 |
|
| - |
|
310 |
private String getItemDisplayName(LineItem lineitem, boolean appendIMEI){
|
| - |
|
311 |
StringBuffer itemName = new StringBuffer();
|
| - |
|
312 |
if(lineitem.getBrand()!= null)
|
| - |
|
313 |
itemName.append(lineitem.getBrand() + " ");
|
| - |
|
314 |
if(lineitem.getModel_name() != null)
|
| - |
|
315 |
itemName.append(lineitem.getModel_name() + " ");
|
| - |
|
316 |
if(lineitem.getModel_number() != null )
|
| - |
|
317 |
itemName.append(lineitem.getModel_number() + " ");
|
| - |
|
318 |
if(lineitem.getColor() != null && !lineitem.getColor().trim().equals("NA"))
|
| - |
|
319 |
itemName.append("("+lineitem.getColor()+")");
|
| - |
|
320 |
if(appendIMEI && lineitem.isSetSerial_number()){
|
| - |
|
321 |
itemName.append("\nIMEI No. " + lineitem.getSerial_number());
|
| - |
|
322 |
}
|
| - |
|
323 |
|
| - |
|
324 |
return itemName.toString();
|
| - |
|
325 |
}
|
| - |
|
326 |
|
| 195 |
/**
|
327 |
/**
|
| 196 |
* @param args
|
328 |
* @param args
|
| 197 |
*/
|
329 |
*/
|
| 198 |
public static void main(String[] args) {
|
330 |
public static void main(String[] args) {
|
| 199 |
System.out.println("Hey There");
|
331 |
System.out.println("Hey There");
|