| Line 701... |
Line 701... |
| 701 |
out = new BufferedWriter(new FileWriter("/tmp/ExceptMobileTablets-StockSales-file.htm"));
|
701 |
out = new BufferedWriter(new FileWriter("/tmp/ExceptMobileTablets-StockSales-file.htm"));
|
| 702 |
out.write(sb.toString());
|
702 |
out.write(sb.toString());
|
| 703 |
out.flush();
|
703 |
out.flush();
|
| 704 |
out.close();
|
704 |
out.close();
|
| 705 |
|
705 |
|
| 706 |
createXlsFile(movingStockSaleListMT, slowMovingStockSaleListMT, nonMovingStockSaleListMT, true);
|
706 |
String mtFile = createXlsFile(movingStockSaleListMT, slowMovingStockSaleListMT, nonMovingStockSaleListMT, true);
|
| 707 |
createXlsFile(movingStockSaleListEMT, slowMovingStockSaleListEMT, nonMovingStockSaleListEMT, false);
|
707 |
String emtFile = createXlsFile(movingStockSaleListEMT, slowMovingStockSaleListEMT, nonMovingStockSaleListEMT, false);
|
| 708 |
|
708 |
|
| 709 |
|
709 |
|
| 710 |
GmailUtils mailer = new GmailUtils();
|
710 |
GmailUtils mailer = new GmailUtils();
|
| 711 |
mailer.sendSSLMessage(mailTo, "Stock Sales Report - Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+ stockSalesReportMT.getName(), "/tmp/MobileTablets-StockSales-file.htm");
|
711 |
mailer.sendSSLMessage(mailTo, "Stock Sales Report - Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+ mtFile, "/tmp/MobileTablets-StockSales-file.htm");
|
| 712 |
mailer.sendSSLMessage(mailTo, "Stock Sales Report - Except Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+stockSalesReportEMT.getName(), "/tmp/ExceptMobileTablets-StockSales-file.htm");
|
712 |
mailer.sendSSLMessage(mailTo, "Stock Sales Report - Except Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+emtFile, "/tmp/ExceptMobileTablets-StockSales-file.htm");
|
| 713 |
} catch (Exception e) {
|
713 |
} catch (Exception e) {
|
| 714 |
logger.error("Error in generating/sending Stock Sales Report", e);
|
714 |
logger.error("Error in generating/sending Stock Sales Report", e);
|
| 715 |
}
|
715 |
}
|
| 716 |
|
716 |
|
| 717 |
|
717 |
|
| 718 |
}
|
718 |
}
|
| 719 |
|
719 |
|
| 720 |
private static void createXlsFile(List<StockSaleDetail> movingStockSaleList,
|
720 |
private static String createXlsFile(List<StockSaleDetail> movingStockSaleList,
|
| 721 |
List<StockSaleDetail> slowMovingStockSaleList,
|
721 |
List<StockSaleDetail> slowMovingStockSaleList,
|
| 722 |
List<StockSaleDetail> nonMovingStockSaleList,
|
722 |
List<StockSaleDetail> nonMovingStockSaleList,
|
| 723 |
boolean mobTab) {
|
723 |
boolean mobTab) {
|
| - |
|
724 |
String fileName = "";
|
| 724 |
try{
|
725 |
try{
|
| 725 |
HSSFWorkbook workbook = new HSSFWorkbook();
|
726 |
HSSFWorkbook workbook = new HSSFWorkbook();
|
| 726 |
HSSFSheet movingSheet = workbook.createSheet("Moving-Stock");
|
727 |
HSSFSheet movingSheet = workbook.createSheet("Moving-Stock");
|
| 727 |
HSSFSheet nonMovingSheet = workbook.createSheet("Non-Moving-Stock");
|
728 |
HSSFSheet nonMovingSheet = workbook.createSheet("Non-Moving-Stock");
|
| 728 |
HSSFSheet slowMovingSheet = workbook.createSheet("Non-Moving-Stock");
|
729 |
HSSFSheet slowMovingSheet = workbook.createSheet("Non-Moving-Stock");
|
| Line 889... |
Line 890... |
| 889 |
row.createCell(21).setCellValue(ssDetail.getSalesHistoryMFN());
|
890 |
row.createCell(21).setCellValue(ssDetail.getSalesHistoryMFN());
|
| 890 |
row.createCell(22).setCellValue(ssDetail.getAvgSalesMFN());
|
891 |
row.createCell(22).setCellValue(ssDetail.getAvgSalesMFN());
|
| 891 |
i++;
|
892 |
i++;
|
| 892 |
}
|
893 |
}
|
| 893 |
|
894 |
|
| 894 |
FileOutputStream out = null;
|
895 |
FileOutputStream out;
|
| 895 |
if(mobTab){
|
896 |
if(mobTab){
|
| - |
|
897 |
File stockSalesReportMT = new File(tmpDir + "/StockSaleReport-MT" + (new Date()) + ".xls");
|
| 896 |
out = new FileOutputStream(stockSalesReportMT);
|
898 |
out = new FileOutputStream(stockSalesReportMT);
|
| - |
|
899 |
fileName = stockSalesReportMT.getName();
|
| 897 |
} else {
|
900 |
} else {
|
| - |
|
901 |
File stockSalesReportEMT = new File(tmpDir + "/StockSaleReport-EMT" + (new Date()) + ".xls");
|
| 898 |
out = new FileOutputStream(stockSalesReportEMT);
|
902 |
out = new FileOutputStream(stockSalesReportEMT);
|
| - |
|
903 |
fileName = stockSalesReportEMT.getName();
|
| 899 |
}
|
904 |
}
|
| 900 |
workbook.write(out);
|
905 |
workbook.write(out);
|
| 901 |
out.close();
|
906 |
out.close();
|
| 902 |
System.out.println("Excel written successfully..");
|
907 |
System.out.println("Excel written successfully..");
|
| 903 |
}catch(Exception e){
|
908 |
}catch(Exception e){
|
| 904 |
e.printStackTrace();
|
909 |
e.printStackTrace();
|
| 905 |
}
|
910 |
}
|
| - |
|
911 |
|
| - |
|
912 |
return fileName;
|
| 906 |
|
913 |
|
| 907 |
}
|
914 |
}
|
| 908 |
|
915 |
|
| 909 |
public static void main(String[] args) {
|
916 |
public static void main(String[] args) {
|
| 910 |
createAndMailReport();
|
917 |
createAndMailReport();
|