| Line 22... |
Line 22... |
| 22 |
import javax.servlet.http.HttpServletRequest;
|
22 |
import javax.servlet.http.HttpServletRequest;
|
| 23 |
import javax.servlet.http.HttpServletResponse;
|
23 |
import javax.servlet.http.HttpServletResponse;
|
| 24 |
import javax.servlet.http.HttpSession;
|
24 |
import javax.servlet.http.HttpSession;
|
| 25 |
|
25 |
|
| 26 |
import org.apache.axis.utils.ByteArrayOutputStream;
|
26 |
import org.apache.axis.utils.ByteArrayOutputStream;
|
| - |
|
27 |
import org.apache.poi.ss.usermodel.Cell;
|
| - |
|
28 |
import org.apache.poi.ss.usermodel.CellStyle;
|
| 27 |
import org.apache.poi.ss.usermodel.Row;
|
29 |
import org.apache.poi.ss.usermodel.Row;
|
| 28 |
import org.apache.poi.ss.usermodel.Sheet;
|
30 |
import org.apache.poi.ss.usermodel.Sheet;
|
| - |
|
31 |
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
|
| 29 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
32 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 30 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
33 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| 31 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
34 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 32 |
import org.apache.struts2.convention.annotation.Result;
|
35 |
import org.apache.struts2.convention.annotation.Result;
|
| 33 |
import org.apache.struts2.convention.annotation.Results;
|
36 |
import org.apache.struts2.convention.annotation.Results;
|
| Line 222... |
Line 225... |
| 222 |
}
|
225 |
}
|
| 223 |
|
226 |
|
| 224 |
public String download() throws Exception {
|
227 |
public String download() throws Exception {
|
| 225 |
InputStream is = getClass().getClassLoader().getResourceAsStream("orderformat.xlsx");
|
228 |
InputStream is = getClass().getClassLoader().getResourceAsStream("orderformat.xlsx");
|
| 226 |
logger.info("is stream is " + (is==null?"null" : "not null"));
|
229 |
logger.info("is stream is " + (is==null?"null" : "not null"));
|
| 227 |
XSSFWorkbook workbook = new XSSFWorkbook(is);
|
230 |
XSSFWorkbook workBook = new XSSFWorkbook(is);
|
| - |
|
231 |
XSSFDataFormat df1 = workBook.createDataFormat();
|
| - |
|
232 |
CellStyle cs = workBook.createCellStyle();
|
| - |
|
233 |
cs.setDataFormat(df1.getFormat("dd-mm-yy HH:mm"));
|
| 228 |
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
234 |
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
| 229 |
Sheet sheet = workbook.getSheetAt(0);
|
235 |
Sheet sheet = workBook.getSheetAt(0);
|
| 230 |
workbook.setSheetName(0, this.getMy());
|
236 |
workBook.setSheetName(0, this.getMy());
|
| 231 |
DateFormat df = new SimpleDateFormat("MMM, yyyy");
|
237 |
DateFormat df = new SimpleDateFormat("MMM, yyyy");
|
| 232 |
Date fromDate = df.parse(this.getMy());
|
238 |
Date fromDate = df.parse(this.getMy());
|
| 233 |
|
239 |
|
| 234 |
Calendar toDateCal = Calendar.getInstance();
|
240 |
Calendar toDateCal = Calendar.getInstance();
|
| 235 |
toDateCal.add(Calendar.MONTH, 1);
|
241 |
toDateCal.add(Calendar.MONTH, 1);
|
| 236 |
List<Order> orders = tClient.getAllOrders(new ArrayList<OrderStatus>(), fromDate.getTime(), toDateCal.getTime().getTime(), 0);
|
242 |
List<Order> orders = tClient.getAllOrders(new ArrayList<OrderStatus>(), fromDate.getTime(), toDateCal.getTime().getTime(), 0);
|
| 237 |
int rowNum=2;
|
243 |
int rowNum=2;
|
| 238 |
for(Order o : orders){
|
244 |
for(Order o : orders){
|
| 239 |
Row row = sheet.createRow(rowNum);
|
245 |
Row row = sheet.createRow(rowNum);
|
| 240 |
int i=0;
|
246 |
int i=0;
|
| 241 |
row.createCell(++i).setCellValue(o.getId());
|
247 |
row.createCell(i++).setCellValue(o.getId());
|
| - |
|
248 |
Cell created = row.createCell(i++);
|
| 242 |
row.createCell(++i).setCellValue(new Date(o.getCreated_timestamp()));
|
249 |
created.setCellValue(new Date(o.getCreated_timestamp()));
|
| - |
|
250 |
created.setCellStyle(cs);
|
| 243 |
|
251 |
|
| 244 |
++i;
|
252 |
i++;
|
| - |
|
253 |
if(o.getVerification_timestamp()>0){
|
| - |
|
254 |
Cell verified = row.createCell(i++);
|
| 245 |
row.createCell(++i).setCellValue(new Date(o.getVerification_timestamp()));
|
255 |
verified.setCellValue(new Date(o.getVerification_timestamp()));
|
| - |
|
256 |
verified.setCellStyle(cs);
|
| - |
|
257 |
} else {
|
| - |
|
258 |
i++;
|
| - |
|
259 |
}
|
| 246 |
++i;
|
260 |
i++;
|
| 247 |
|
261 |
|
| 248 |
row.createCell(++i).setCellValue(o.getInvoice_number());
|
262 |
row.createCell(i++).setCellValue(o.getInvoice_number());
|
| 249 |
row.createCell(++i).setCellValue(o.getBilled_by());
|
263 |
row.createCell(i++).setCellValue(o.getBilled_by());
|
| 250 |
++i;
|
264 |
i++;
|
| - |
|
265 |
if(o.getBilling_timestamp()>0){
|
| - |
|
266 |
Cell billed = row.createCell(i++);
|
| 251 |
row.createCell(++i).setCellValue(new Date(o.getBilling_timestamp()));
|
267 |
billed.setCellValue(new Date(o.getBilling_timestamp()));
|
| - |
|
268 |
billed.setCellStyle(cs);
|
| - |
|
269 |
} else {
|
| - |
|
270 |
i++;
|
| - |
|
271 |
}
|
| - |
|
272 |
if(o.getShipping_timestamp()>0) {
|
| - |
|
273 |
Cell shipped = row.createCell(i++);
|
| 252 |
row.createCell(++i).setCellValue(new Date(o.getShipping_timestamp()));
|
274 |
shipped.setCellValue(new Date(o.getShipping_timestamp()));
|
| - |
|
275 |
shipped.setCellStyle(cs);
|
| - |
|
276 |
} else {
|
| - |
|
277 |
i++;
|
| - |
|
278 |
}
|
| 253 |
row.createCell(++i).setCellValue(o.getAirwaybill_no());
|
279 |
row.createCell(i++).setCellValue(o.getAirwaybill_no());
|
| 254 |
row.createCell(++i).setCellValue(o.getLogistics_provider_id());
|
280 |
row.createCell(i++).setCellValue(o.getLogistics_provider_id());
|
| 255 |
++i;
|
281 |
i++;
|
| - |
|
282 |
if(o.getDelivery_timestamp()>0){
|
| - |
|
283 |
Cell delivered = row.createCell(i++);
|
| 256 |
row.createCell(++i).setCellValue(new Date(o.getDelivery_timestamp()));
|
284 |
delivered.setCellValue(new Date(o.getDelivery_timestamp()));
|
| - |
|
285 |
delivered.setCellStyle(cs);
|
| - |
|
286 |
} else {
|
| - |
|
287 |
i++;
|
| - |
|
288 |
}
|
| 257 |
row.createCell(++i).setCellValue(o.getLineitems().get(0).getQuantity());
|
289 |
row.createCell(i++).setCellValue(o.getLineitems().get(0).getQuantity());
|
| 258 |
row.createCell(++i).setCellValue(o.getTotal_amount() + o.getShippingCost());
|
290 |
row.createCell(i++).setCellValue(o.getTotal_amount() + o.getShippingCost());
|
| 259 |
if(o.getStatus().equals(OrderStatus.DELIVERY_SUCCESS)) {
|
291 |
if(o.getStatus().equals(OrderStatus.DELIVERY_SUCCESS)) {
|
| 260 |
row.createCell(++i).setCellValue(o.getTotal_amount() + o.getShippingCost());
|
292 |
row.createCell(i++).setCellValue(o.getTotal_amount() + o.getShippingCost());
|
| 261 |
}else {
|
293 |
}else {
|
| 262 |
++i;
|
294 |
i++;
|
| 263 |
}
|
295 |
}
|
| 264 |
if(o.isCod()) {
|
296 |
if(o.isCod()) {
|
| 265 |
row.createCell(++i).setCellValue("COD");
|
297 |
row.createCell(i++).setCellValue("COD");
|
| 266 |
} else {
|
298 |
} else {
|
| 267 |
row.createCell(++i).setCellValue("PREPAID");
|
299 |
row.createCell(i++).setCellValue("PREPAID");
|
| 268 |
}
|
300 |
}
|
| 269 |
row.createCell(++i).setCellValue(o.getStatusDescription());
|
301 |
row.createCell(i++).setCellValue(o.getStatusDescription());
|
| 270 |
row.createCell(++i).setCellValue(o.getCustomer_city());
|
302 |
row.createCell(i++).setCellValue(o.getCustomer_city());
|
| 271 |
|
303 |
rowNum++;
|
| 272 |
}
|
304 |
}
|
| 273 |
ServletOutputStream os = response.getOutputStream();
|
305 |
ServletOutputStream os = response.getOutputStream();
|
| 274 |
workbook.write(bos);
|
306 |
workBook.write(bos);
|
| 275 |
bos.writeTo(os);
|
307 |
bos.writeTo(os);
|
| 276 |
String filename=this.getMy() + "-order.xlsx";
|
308 |
String filename=this.getMy() + "-order.xlsx";
|
| 277 |
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
309 |
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 278 |
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
|
310 |
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
|
| 279 |
|
311 |
|