Subversion Repositories SmartDukaan

Rev

Rev 12176 | Rev 12178 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12176 Rev 12177
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
			String mtFile = createXlsFile(movingStockSaleListMT, slowMovingStockSaleListMT, nonMovingStockSaleListMT, true);
706
			createXlsFile(movingStockSaleListMT, slowMovingStockSaleListMT, nonMovingStockSaleListMT, true);
707
			String emtFile = createXlsFile(movingStockSaleListEMT, slowMovingStockSaleListEMT, nonMovingStockSaleListEMT, false);
707
			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 +"/"+ mtFile, "/tmp/MobileTablets-StockSales-file.htm");
711
			mailer.sendSSLMessage(mailTo, "Stock Sales Report - Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+ stockSalesReportMT.getName(), "/tmp/MobileTablets-StockSales-file.htm");
712
			mailer.sendSSLMessage(mailTo, "Stock Sales Report - Except Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+emtFile, "/tmp/ExceptMobileTablets-StockSales-file.htm");
712
			mailer.sendSSLMessage(mailTo, "Stock Sales Report - Except Mobile And Tablets ", "", senderAccountMail, senderAccountPswd, tmpDir +"/"+stockSalesReportEMT.getName(), "/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 String createXlsFile(List<StockSaleDetail> movingStockSaleList, 
720
	private static void 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 = "";
-
 
725
		try{
724
		try{
726
			HSSFWorkbook mtWorkbook = new HSSFWorkbook();
725
			HSSFWorkbook workbook = new HSSFWorkbook();
727
			HSSFWorkbook emtWorkbook = new HSSFWorkbook();
-
 
728
			HSSFSheet movingSheet;
-
 
729
			HSSFSheet nonMovingSheet;
-
 
730
			HSSFSheet slowMovingSheet;
-
 
731
			if(mobTab){
-
 
732
				movingSheet = mtWorkbook.createSheet("Moving-Stock");
726
			HSSFSheet movingSheet = workbook.createSheet("Moving-Stock");
733
				nonMovingSheet = mtWorkbook.createSheet("Non-Moving-Stock");
727
			HSSFSheet nonMovingSheet = workbook.createSheet("Non-Moving-Stock");
734
				slowMovingSheet = mtWorkbook.createSheet("Non-Moving-Stock");
728
			HSSFSheet slowMovingSheet = workbook.createSheet("Slow-Moving-Stock");
735
			} else {
-
 
736
				movingSheet = emtWorkbook.createSheet("Moving-Stock");
-
 
737
				nonMovingSheet = emtWorkbook.createSheet("Non-Moving-Stock");
-
 
738
				slowMovingSheet = emtWorkbook.createSheet("Non-Moving-Stock");
-
 
739
			}
-
 
740
			
-
 
741
			Row row = movingSheet.createRow(0);
729
			Row row = movingSheet.createRow(0);
742
 
730
 
743
			row.createCell(0).setCellValue("ItemId");
731
			row.createCell(0).setCellValue("ItemId");
744
			row.createCell(1).setCellValue("Category");
732
			row.createCell(1).setCellValue("Category");
745
			row.createCell(2).setCellValue("ProductGroup");
733
			row.createCell(2).setCellValue("ProductGroup");
Line 901... Line 889...
901
				row.createCell(21).setCellValue(ssDetail.getSalesHistoryMFN());
889
				row.createCell(21).setCellValue(ssDetail.getSalesHistoryMFN());
902
				row.createCell(22).setCellValue(ssDetail.getAvgSalesMFN());
890
				row.createCell(22).setCellValue(ssDetail.getAvgSalesMFN());
903
				i++;
891
				i++;
904
			}
892
			}
905
 
893
 
906
			FileOutputStream out;
894
			FileOutputStream out = null;
907
			if(mobTab){
895
			if(mobTab){
908
				File stockSalesReportMT = new File(tmpDir + "/StockSaleReport-MT" + (new Date()) + ".xls");
-
 
909
				out = new FileOutputStream(stockSalesReportMT);
896
				out = new FileOutputStream(stockSalesReportMT);
910
				fileName = stockSalesReportMT.getName();
-
 
911
				mtWorkbook.write(out);
-
 
912
			} else {
897
			} else {
913
				File stockSalesReportEMT = new File(tmpDir + "/StockSaleReport-EMT" + (new Date()) + ".xls");
-
 
914
				out = new FileOutputStream(stockSalesReportEMT);
898
				out = new FileOutputStream(stockSalesReportEMT);
915
				fileName = stockSalesReportEMT.getName();
-
 
916
				emtWorkbook.write(out);
-
 
917
			}
899
			}
918
			
900
			workbook.write(out);
919
			out.close();
901
			out.close();
920
			System.out.println("Excel written successfully..");
902
			System.out.println("Excel written successfully..");
921
		}catch(Exception e){
903
		}catch(Exception e){
922
			e.printStackTrace();
904
			e.printStackTrace();
923
		}
905
		}
924
		
-
 
925
		return fileName;
-
 
926
 
906
 
927
	}
907
	}
928
 
908
 
929
	public static void main(String[] args) {
909
	public static void main(String[] args) {
930
		createAndMailReport();
910
		createAndMailReport();