`
michelecindy
  • 浏览: 173093 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

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

    博客分类:
  • Java
阅读更多
package test;

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;
	}
	
}


分享到:
评论

相关推荐

    delphi-使用delphi开发的CSV解释器-parser.zip

    - **组件库利用**:Delphi有许多内置和第三方的组件可以帮助开发,如 TStringGrid 可能用于显示和编辑解析后的CSV数据,而 TOpenDialog 和 TSaveDialog 可以用于选择输入和输出文件。 在实际应用中,Delphi开发的...

    用java实现报表的生成

    3. **Java I/O流**:处理输入输出,如读取CSV或Excel文件,将数据加载到内存中,为报表生成做准备。 4. **模板引擎**:例如FreeMarker或Velocity,这些模板引擎可以帮助开发者将动态数据与静态布局结合,生成定制化...

    java插件,组件 读写Excel文件

    - 写入文件:最后,通过`Workbook`对象的`write()`方法,将数据写入到指定的输出流,通常是一个文件输出流。 除了Apache POI,还有其他工具和库可以处理Excel文件,如JExcelApi(适用于较旧的.xls格式)和OpenCSV...

    javabaobiao.rar_java 报表_java报表

    1. **数据源**:报表数据通常来自数据库、XML文件、CSV文件或其他业务系统。 2. **模板设计**:设计报表布局,包括字段、表格、图表等元素。 3. **报表引擎**:处理数据源,填充模板,生成报表。 4. **输出格式**:...

    IReport+jasperReports实现flash报表查询功能

    你需要在报表的JRXML文件中指定输出类型为"SWF",并配置相应的Flash参数。 3. **设置数据连接和查询**:IReport允许你定义SQL查询或者使用自定义脚本来获取数据。对于Flash报表,通常需要动态数据,因此可能需要...

    使用java Apache poi 根据word模板生成word报表.rar

    测试时,你可以用提供的工具类和这个模板,输入自己的数据来生成报表。 在实际应用中,为了提高效率和灵活性,可以设计一个通用的接口或者服务,接受模板文件、数据源和输出文件路径作为参数,这样就可以轻松地扩展...

    c#水晶报表初学案例(附源码)

    总之,学习C#水晶报表的初学者,通过案例源码和视频教程,能够逐步理解报表设计、数据绑定、参数化和输出等多个方面,从而提升数据呈现和分析的能力。不断实践和探索,你将能够创建满足各种业务需求的定制化报告。

    JasperReports 报表

    5. **在JSP中展示**:JSP页面接收导出的报表内容,可以以流的形式直接输出,或者通过iframe、AJAX等方式呈现。 **四、高级特性** 1. **子报表**:允许在一个报表中嵌套另一个报表,实现复杂报表结构。 2. **图表*...

    JAVA水晶报表帮助手册

    水晶报表支持定义参数,使得报表能够根据用户的输入动态生成内容。开发者可以设定参数类型、默认值以及参数之间的依赖关系,实现灵活的报表交互性。 ### 5. 分组与汇总 水晶报表提供了强大的分组和汇总功能。开发者...

    动态报表dynamicreports

    它支持多种数据源,包括数据库查询结果、CSV文件、XML数据等,可以处理各种数据格式并将其转化为清晰、美观的报表。 描述中提到,dynamicreports不仅提供动态生成报表的功能,还支持JasperReports模板类型的设计。...

    java操作Excel文件

    - 总是关闭工作簿和输入/输出流,以释放资源。 - 使用异常处理,确保程序在遇到错误时能优雅地失败。 - 考虑性能,如批量操作和使用缓冲。 8. **其他库** - OpenCSV:专注于CSV文件,适合简单的表格数据。 - ...

    C++ Excel文件写入

    首先,C++标准库中的fstream是处理输入/输出流的核心组件,它可以用于与各种类型的文件进行交互,包括文本文件和二进制文件。对于Excel文件,由于它本质上是一种二进制格式(.xlsx为OOXML格式,.xls为早期的BIFF格式...

    大智慧365导出除权文件(PWR)和财务文件(FIN)转换成分析家格式文件

    2. 文件编码:确认输入和输出文件的编码格式一致,避免因编码问题导致的数据乱码。 3. 软件版本兼容性:转换程序可能需要特定版本的大智慧365或分析家软件,确保两者版本匹配。 4. 安全性:运行未知来源的可执行文件...

    CSV

    CSV文件用纯文本形式存储表格数据,每一行代表一条记录,各列数据之间用特定的分隔符(通常是逗号)进行区分。 在CSV文件中,每一行代表一个数据记录,每列则对应记录中的一个字段。例如,一个简单的CSV文件可能...

    knime 组件节点说明手册

    #### 一、数据输入输出 **1.1 读取** - **EXCEL文件读取**: 该节点用于从Excel文件中读取数据。支持多种Excel文件格式,如.xlsx和.xls。 - **普通文件读取**: 通用文件读取节点,适用于读取非特定格式的数据文件。...

    ostermillerutils-1.08.02-bin.zip

    提供了方便的日志记录机制,以及对输入/输出流的控制,使得在开发过程中跟踪和调试变得更加容易。 5. 跨平台兼容性: ostermillerutils-1.08.02-bin.zip包含了适用于多种操作系统(如Windows、Linux和Mac OS)的...

    iReport-5.6.0-windows-installer.zip

    2. 报表参数:报表可以接受输入参数,使得同一报表能根据不同参数产生不同的输出。 3. 组合单元:iReport支持组合单元,可以将多个报表元素组合在一起,便于重复使用或进行复杂的布局。 4. 报表样式和主题:用户可以...

    C++表格读文件 读取外部文件

    C++提供了标准库`fstream`,它包含了`ifstream`(输入文件流)和`ofstream`(输出文件流)类,分别用于读取和写入文件。使用这些类,我们可以打开、读取和关闭文件。 1. **打开文件**: 使用`ifstream`类的构造...

    pscad的数据输入与输出接口说明,pscad与matlab接口互联说明(pdf、ppt)。

    此外,PSCAD支持文本文件输入,例如ASCII格式的元件库文件和电路描述文件,这使得批量处理和自动化工作流成为可能。对于复杂的电路或仿真需求,通过编写脚本或利用API(应用程序编程接口)进行数据输入,能够实现更...

    FastReport 使用手冊

    它可以连接到多种类型的数据库,如SQL Server、Oracle、MySQL等,也可以使用XML、CSV等文件作为数据源。用户可以设置查询条件,定义数据绑定,使得报表能动态地从数据库中获取和展示数据。 **参数** FastReport支持...

Global site tag (gtag.js) - Google Analytics