`

用输入输出流写CSV报表文件

    博客分类:
  • Java
阅读更多
package com.kingsoft.main;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.sql.*;
import java.util.ArrayList;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class JavaExcel implements Serializable{
	static Connection conn = null;
	static PreparedStatement pstmt = null;
	
	public static void updateLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("updateLineCNT startTime:"+startTime);
		ArrayList al = getLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY "
					+ "set LINE_CNT=?"
					+ "where MON=?";
				pstmt = conn.prepareStatement(sql);
				int i = 1;
				pstmt.setInt(i++, ((JeDO) al.get(j)).getLineCNT());
				pstmt.setString(i++, ((JeDO)al.get(j)).getMonth());
				int cnt= pstmt.executeUpdate();
				System.out.println("updateLineCNT sql:"+sql);
				System.out.println("updateLineCNT:"+cnt);
				pstmt.close();
			}
			long stopTime = System.currentTimeMillis();
//			System.out.println("updateLineCNT stopTime:"+stopTime);
			System.out.println("updateLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateNewLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("updateNewLineCNT startTime:"+startTime);
		ArrayList al = getNewLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY "
					+ "set NEW_LINE_CNT=?"
					+ "where MON=?";
				pstmt = conn.prepareStatement(sql);
				int i = 1;
				pstmt.setInt(i++, ((JeDO) al.get(j)).getNewLineCNT());
				pstmt.setString(i++, ((JeDO)al.get(j)).getMonth());
				int cnt= pstmt.executeUpdate();
				System.out.println("updateNewLineCNT sql:"+sql);
				System.out.println("updateNewLineCNT:"+cnt);
				pstmt.close();
			}
			long stopTime = System.currentTimeMillis();
//			System.out.println("updateNewLineCNT stopTime:"+stopTime);
			System.out.println("updateNewLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateTmnLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("updateTmnLineCNT startTime:"+startTime);
		ArrayList al = getTmnLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY "
					+ "set TMN_LINE_CNT=?"
					+ "where MON=?";
				pstmt = conn.prepareStatement(sql);
				int i = 1;
				pstmt.setInt(i++, ((JeDO) al.get(j)).getTmnLineCNT());
				pstmt.setString(i++, ((JeDO)al.get(j)).getMonth());
				int cnt= pstmt.executeUpdate();
				System.out.println("updateTmnLineCNT sql:"+sql);
				System.out.println("updateTmnLineCNT:"+cnt);
				pstmt.close();
			}
			long stopTime = System.currentTimeMillis();
//			System.out.println("updateTmnLineCNT stopTime:"+stopTime);
			System.out.println("updateTmnLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSuspendLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("updateSuspendLineCNT startTime:"+startTime);
		ArrayList al = getSuspendLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY "
					+ "set SUSPEND_LINE_CNT=?"
					+ "where MON=?";
				pstmt = conn.prepareStatement(sql);
				int i = 1;
				pstmt.setInt(i++, ((JeDO) al.get(j)).getSuspendLineCNT());
				pstmt.setString(i++, ((JeDO)al.get(j)).getMonth());
				int cnt= pstmt.executeUpdate();
				System.out.println("updateSuspendLineCNT sql:"+sql);
				System.out.println("updateSuspendLineCNT:"+cnt);
				pstmt.close();
			}
			long stopTime = System.currentTimeMillis();
//			System.out.println("updateSuspendLineCNT stopTime:"+stopTime);
			System.out.println("updateSuspendLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateResumeLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("updateResumeLineCNT startTime:"+startTime);
		ArrayList al = getResumeLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY "
					+ "set RESUME_LINE_CNT=?"
					+ "where MON=?";
				pstmt = conn.prepareStatement(sql);
				int i = 1;
				pstmt.setInt(i++, ((JeDO) al.get(j)).getResumeLineCNT());
				pstmt.setString(i++, ((JeDO)al.get(j)).getMonth());
				int cnt= pstmt.executeUpdate();
				System.out.println("updateResumeLineCNT sql:"+sql);
				System.out.println("updateResumeLineCNT:"+cnt);
				pstmt.close();
			}
			long stopTime = System.currentTimeMillis();
//			System.out.println("updateResumeLineCNT stopTime:"+stopTime);
			System.out.println("updateResumeLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void clearAll() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("clearAll startTime:"+startTime);
		ArrayList al = getLineCNT();
		try {
			for (int j = 0; j < al.size(); j++) {
				String sql = "update ops$e21team4_ro.RPT_WFX_MONTHLY set LINE_CNT='',NEW_LINE_CNT='',TMN_LINE_CNT='',SUSPEND_LINE_CNT='',RESUME_LINE_CNT='',LINE_SUM=''";
				pstmt = conn.prepareStatement(sql);
				int cnt= pstmt.executeUpdate();
				pstmt.close();
			}
			System.out.println("Clear All is Success");
			long stopTime = System.currentTimeMillis();
//			System.out.println("clearAll stopTime:"+stopTime);
			System.out.println("clearAll 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static ArrayList getLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("getLineCNT startTime:"+startTime);
		ArrayList result = new ArrayList();
		String sql = "select to_char(TRUNC(SERV_STRT_DATE,'MM'),'yyyymm') AS MONTH, " +
					"COUNT(DISTINCT LINE_NO) AS LINE_NO " +
					"From lis_line_subscription where prod_id = 789 and sts<>'I' " +
					"GROUP BY TRUNC(SERV_STRT_DATE,'MM') ";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO bean = new JeDO();
			bean.setMonth(rs.getString(1));
			bean.setLineCNT(rs.getInt(2));
			result.add(bean);
		}
		
		/*
		for(int i=0;i<result.size();i++){
			System.out.println(">>>>>>>>>>>>"+((JeDO) result.get(i)).getLineNo());
			System.out.println("<<<<<<<<<<<<"+((JeDO) result.get(i)).getMonth());
		}
		*/
		long stopTime = System.currentTimeMillis();
//		System.out.println("getLineCNT stopTime:"+stopTime);
		System.out.println("getLineCNT 总共运行时长为:"+(stopTime-startTime));
		pstmt.close();
		return result;
	}
	
	public static ArrayList getNewLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		ArrayList result = new ArrayList();
		String sql = "select /*+rule*/ to_char(TRUNC(SIC.NWT_ASG_RFS_DATE,'MM'),'yyyymm') AS MONTH,count(line_no) AS NEW_LINE " +
					"from soh_service_order_header soh,sic_so_line_info sic, oty_order_type oty " +
					"where soh.ORD_TYPE_ID = oty.ORD_TYPE_id and oty.ORD_TYPE_CD='N' " +
					"and soh.so_no = sic.so_no  " +
					"and sic.SO_LINE_STS_CD = 'PO' " +
					"and OTY.PROD_ID = 789 " +
					"AND SIC.PROD_CD ='WFX' " +
					"GROUP BY  " +
					"TRUNC(SIC.NWT_ASG_RFS_DATE,'MM') ";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO bean = new JeDO();
			bean.setMonth(rs.getString(1));
			bean.setNewLineCNT(rs.getInt(2));
			result.add(bean);
		}
		
		long stopTime = System.currentTimeMillis();
		System.out.println("getNewLineCNT 总共运行时长为:"+(stopTime-startTime));
		pstmt.close();
		return result;
	}
	
	public static ArrayList getTmnLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("getTmnLineCNT startTime:"+startTime);
		ArrayList result = new ArrayList();
		String sql = "select /*+rule*/ to_char(TRUNC(SIC.NWT_ASG_RFS_DATE,'MM'),'yyyymm') AS MONTH,count(line_no) AS TERM_LINE " +
					"from soh_service_order_header soh,sic_so_line_info sic, oty_order_type oty " +
					"where soh.ORD_TYPE_ID = oty.ORD_TYPE_id and oty.ORD_TYPE_CD='T' " +
					"and soh.so_no = sic.so_no  " +
					"and sic.SO_LINE_STS_CD = 'PO' " +
					"and OTY.PROD_ID = 789 " +
					"AND SIC.PROD_CD ='WFX' " +
					"GROUP BY  " +
					"TRUNC(SIC.NWT_ASG_RFS_DATE,'MM')";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO bean = new JeDO();
			bean.setMonth(rs.getString(1));
			bean.setTmnLineCNT(rs.getInt(2));
			result.add(bean);
		}
		
		long stopTime = System.currentTimeMillis();
//		System.out.println("getTmnLineCNT stopTime:"+stopTime);
		System.out.println("getTmnLineCNT 总共运行时长为:"+(stopTime-startTime));
		pstmt.close();
		return result;
	}
	
	public static ArrayList getSuspendLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("getSuspendLineCNT startTime:"+startTime);
		ArrayList result = new ArrayList();
		String sql = "SELECT to_char(TRUNC(SRP.LAST_UPD_DATE,'MM'),'yyyymm'),COUNT(LINE_NO) " +
					"fROM SRR_SUSPEND_RESUME_REQUEST SRP,SRD_SUSPEND_RESUME_DETAIL SRD " +
					"WHERE SRP.SUS_RES_REQ_ID = SRD.SUS_RES_REQ_ID " +
					"AND PROD_ID =  789 " +
					"AND SRP.REQ_STS='CP' " +
					"AND REQ_ACTION = 'S' " +
					"GROUP BY  TRUNC(SRP.LAST_UPD_DATE,'MM')";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO bean = new JeDO();
			bean.setMonth(rs.getString(1));
			bean.setSuspendLineCNT(rs.getInt(2));
			result.add(bean);
		}
		
		long stopTime = System.currentTimeMillis();
//		System.out.println("getSuspendLineCNT stopTime:"+stopTime);
		System.out.println("getSuspendLineCNT 总共运行时长为:"+(stopTime-startTime));
		pstmt.close();
		return result;
	}
	
	public static ArrayList getResumeLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
//		System.out.println("getResumeLineCNT startTime:"+startTime);
		ArrayList result = new ArrayList();
		String sql = "SELECT to_char(TRUNC(SRP.LAST_UPD_DATE,'MM'),'yyyymm'),COUNT(LINE_NO) " +
					"fROM SRR_SUSPEND_RESUME_REQUEST SRP,SRD_SUSPEND_RESUME_DETAIL SRD " +
					"WHERE SRP.SUS_RES_REQ_ID = SRD.SUS_RES_REQ_ID " +
					"AND PROD_ID =  789 " +
					"AND SRP.REQ_STS='CP' " +
					"AND REQ_ACTION = 'R' " +
					"GROUP BY  TRUNC(SRP.LAST_UPD_DATE,'MM')";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO bean = new JeDO();
			bean.setMonth(rs.getString(1));
			bean.setResumeLineCNT(rs.getInt(2));
			result.add(bean);
		}
		
		long stopTime = System.currentTimeMillis();
//		System.out.println("getResumeLineCNT stopTime:"+stopTime);
		System.out.println("getResumeLineCNT 总共运行时长为:"+(stopTime-startTime));
		pstmt.close();
		return result;
	}
	
	public static void updateLineSUM() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY SET LINE_SUM=NEW_LINE_CNT-TMN_LINE_CNT";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateLineSUM 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSumLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY " +
						"SET LINE_CNT=(SELECT SUM(LINE_CNT) FROM ops$e21team4_ro.RPT_WFX_MONTHLY where mon<>'SUM') " +
						"WHERE MON='SUM'";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateSumLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSumNewLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY " +
						"SET NEW_LINE_CNT=(SELECT SUM(NEW_LINE_CNT) FROM ops$e21team4_ro.RPT_WFX_MONTHLY where mon<>'SUM') " +
						"WHERE MON='SUM'";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateSumNewLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSumTmnLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY " +
						"SET TMN_LINE_CNT=(SELECT SUM(TMN_LINE_CNT) FROM ops$e21team4_ro.RPT_WFX_MONTHLY where mon<>'SUM') " +
						"WHERE MON='SUM'";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateSumTmnLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSumSuspendLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY " +
						"SET SUSPEND_LINE_CNT=(SELECT SUM(SUSPEND_LINE_CNT) FROM ops$e21team4_ro.RPT_WFX_MONTHLY where mon<>'SUM') " +
						"WHERE MON='SUM'";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateSumSuspendLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateSumResumeLineCNT() throws SQLException{
		long startTime = System.currentTimeMillis();
		try {
			
			String sql = "UPDATE ops$e21team4_ro.RPT_WFX_MONTHLY " +
						"SET RESUME_LINE_CNT=(SELECT SUM(RESUME_LINE_CNT) FROM ops$e21team4_ro.RPT_WFX_MONTHLY where mon<>'SUM') " +
						"WHERE MON='SUM'";
			pstmt = conn.prepareStatement(sql);
			int cnt= pstmt.executeUpdate();
			System.out.println("updateResumeLineCNT sql:"+sql);
			System.out.println("updateResumeLineCNT:"+cnt);
			pstmt.close();
			
			long stopTime = System.currentTimeMillis();
			System.out.println("updateSumResumeLineCNT 总共运行时长为:"+(stopTime-startTime));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
	
	
	public static ArrayList getAll() throws SQLException{
		long startTime = System.currentTimeMillis();
		ArrayList sb = new ArrayList();
		String sql = "select mon,LINE_CNT,NEW_LINE_CNT,TMN_LINE_CNT,SUSPEND_LINE_CNT,RESUME_LINE_CNT,LINE_SUM " +
					"from ops$e21team4_ro.RPT_WFX_MONTHLY " +
					"where mon<=to_char(TRUNC(sysdate,'MM'),'yyyymm') or mon='SUM' order by mon asc";
		pstmt = conn.prepareStatement(sql);
		System.out.println(sql);
		ResultSet rs = pstmt.executeQuery();
	
		while(rs.next()){
			JeDO jdo = new JeDO();
			jdo.setMonth(rs.getString(1));
			jdo.setLineCNT(rs.getInt(2));
			jdo.setNewLineCNT(rs.getInt(3));
			jdo.setTmnLineCNT(rs.getInt(4));
			jdo.setSuspendLineCNT(rs.getInt(5));
			jdo.setResumeLineCNT(rs.getInt(6));
			jdo.setLineSum(rs.getInt(7));
			sb.add(jdo);
		}
		
		long stopTime = System.currentTimeMillis();
		System.out.println("getAll 总共运行时长为:"+(stopTime-startTime));
		
		/*
		for(int j=0;j<sb.size();j++){
			System.out.println("-----------"+((JeDO) sb.get(j)).getMonth());
			System.out.println("+++++++++++"+((JeDO) sb.get(j)).getLineCNT());
			System.out.println("..........."+((JeDO) sb.get(j)).getNewLineCNT());
			System.out.println("```````````"+((JeDO) sb.get(j)).getTmnLineCNT());
			System.out.println("***********"+((JeDO) sb.get(j)).getSuspendLineCNT());
			System.out.println("$$$$$$$$$$$"+((JeDO) sb.get(j)).getResumeLineCNT());
			System.out.println("@@@@@@@@@@@"+((JeDO) sb.get(j)).getLineSum());
		}
		*/
		
		pstmt.close();
		return sb;
	}
	
	
	public static void outputCSV() throws Exception{
		ArrayList al = getAll();

		FileOutputStream fos = new FileOutputStream("webfax_reports.csv");
		OutputStreamWriter pw = new OutputStreamWriter(fos,"UTF8");
		java.util.Date d = new java.util.Date();
		pw.write("REPORT DATE :"+d);
		StringBuffer sb1 = new StringBuffer("MONTH");
		StringBuffer sb2 = new StringBuffer("LINE_NO");
		StringBuffer sb3 = new StringBuffer("NEW LINE");
		StringBuffer sb4 = new StringBuffer("TERM LINE");
		StringBuffer sb5 = new StringBuffer("NEW-TERM");
		StringBuffer sb6 = new StringBuffer("SUSPEND");
		StringBuffer sb7 = new StringBuffer("RESUME");
		for(int j=0;j<al.size();j++){
			String a = ((JeDO) al.get(j)).getMonth();
			if(a == null){
				sb1.append(",");
			}else{
				sb1.append(","+a);
			}
			
			int b = ((JeDO) al.get(j)).getLineCNT();
			if(b == 0){
				sb2.append(",");
			}else{
				sb2.append(","+b);
			}
			
			int c = ((JeDO) al.get(j)).getNewLineCNT();
			if(c == 0){
				sb3.append(",");
			}else{
				sb3.append(","+c);
			}
			
			int e = ((JeDO) al.get(j)).getTmnLineCNT();
			if(e == 0){
				sb4.append(",");
			}else{
				sb4.append(","+e);
			}
		
			int f = ((JeDO) al.get(j)).getLineSum();
			if(f == 0){
				sb5.append(",");
			}else{
				sb5.append(","+f);
			}
			
			int k = ((JeDO) al.get(j)).getSuspendLineCNT();
			if(k == 0){
				sb6.append(",");
			}else{
				sb6.append(","+k);
			}
			
			int h = ((JeDO) al.get(j)).getResumeLineCNT();
			if(h == 0){
				sb7.append(",");
			}else{
				sb7.append(","+h);
			}
		}
		pw.write("\n"+sb1.toString());
		pw.write("\n"+sb2.toString());
		pw.write("\n"+sb3.toString());
		pw.write("\n"+sb4.toString());
		pw.write("\n"+sb5.toString());
		pw.write("\n");
		pw.write("\n"+sb6.toString());
		pw.write("\n"+sb7.toString());
		pw.flush();
		pw.close();
		System.out.println("outputCSV is success!");
	}
	
	public static void getConnection(){
		try{
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(java.lang.ClassNotFoundException e){
			System.out.println(e.getMessage());
		}
		
		try {
			String url = "jdbc:oracle:thin:@neptune:1523:E21DB2";
			String user = "ops$e21team4_ro";
			String password = "abcapr";

			conn = DriverManager.getConnection(url, user, password);
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println(e.getMessage());
		}
	}
	
	public static void updateTabel() throws Exception{
		updateLineCNT();
		updateNewLineCNT();
		updateTmnLineCNT();
		updateSuspendLineCNT();
		updateResumeLineCNT();
		updateSumLineCNT();
		updateSumNewLineCNT();
		updateSumTmnLineCNT();
		updateSumSuspendLineCNT();
		updateSumResumeLineCNT();
		updateLineSUM();
	}
	
	public static void main(String[] args) throws Exception{
		long kl = System.currentTimeMillis();
		getConnection();
		clearAll();
		updateTabel();
		outputCSV();
		long st = System.currentTimeMillis();
		System.out.println("Time is running:"+(st-kl));
		
	}
}


class JeDO implements Serializable{
	int lineCNT;
	int newLineCNT;
	int tmnLineCNT;
	int suspendLineCNT;
	int resumeLineCNT;
	int lineSum;
	String month;
	
	public int getLineSum() {
		return lineSum;
	}
	public void setLineSum(int lineSum) {
		this.lineSum = lineSum;
	}
	public int getLineCNT() {
		return lineCNT;
	}
	public void setLineCNT(int lineCNT) {
		this.lineCNT = lineCNT;
	}
	public int getNewLineCNT() {
		return newLineCNT;
	}
	public void setNewLineCNT(int newLineCNT) {
		this.newLineCNT = newLineCNT;
	}
	public int getTmnLineCNT() {
		return tmnLineCNT;
	}
	public void setTmnLineCNT(int tmnLineCNT) {
		this.tmnLineCNT = tmnLineCNT;
	}
	public int getSuspendLineCNT() {
		return suspendLineCNT;
	}
	public void setSuspendLineCNT(int suspendLineCNT) {
		this.suspendLineCNT = suspendLineCNT;
	}
	public int getResumeLineCNT() {
		return resumeLineCNT;
	}
	public void setResumeLineCNT(int resumeLineCNT) {
		this.resumeLineCNT = resumeLineCNT;
	}
	public String getMonth() {
		return month;
	}
	public void setMonth(String month) {
		this.month = month;
	}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics