⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hexiaoreptotal.java

📁 文件的上传和下载的实现,用JAva编写,非常简单
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package edu.whut.cwts.pg.hexiao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

public class HexiaoRepTotal {
	public static ArrayList getYijingHexiaoTotal(String highZddm,
			String lowZddm, String dprdm, String syzt, String pzzl)
			throws NumberFormatException, SQLException {
		// 获取各级站点对应下级单位已经核销的票证组
		ArrayList result = new ArrayList();
		ConnectDB conndb = new ConnectDB();
		int levelfirst = DepartmentCtrl.getLogicLevel(highZddm);// 获取本站点逻辑级别
		int levelsecond = DepartmentCtrl.getLogicLevel(lowZddm);// 获取直属下级站点逻辑级别
		GregorianCalendar g=new GregorianCalendar();
		String hexiaoTimeYear=String.valueOf(g.get(Calendar.YEAR)); //获取当年的年份
		String hexiaoTimeStart=hexiaoTimeYear+"-01"+"-01";
		//String hexiaoTimeStart = new java.util.Date().getYear();
		String hexiaoTimeEnd = new java.util.Date().toLocaleString();
		String sql = "select * from pjztb  where ";
		if (levelfirst == 3) {// 选取打票员,jxzt为1,syzt为5,zddm为自身的票据
			//String jxzt = "1";
			sql = sql + "dprdm='" + dprdm.trim() + "' and jxzt>='1'  and syzt='" + syzt.trim() + "'and zddm='"
					+ highZddm.trim() + "' and pzzl = '" + pzzl.trim() + "' and r_d_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
			// sql = sql + "dprdm='123'";
			// Assert.pl(sql);
		}
		if (levelfirst == 2) {
			String jxzt = "2";
			sql = sql + "jxzt>='2'  and syzt='" + syzt.trim()
					+ "' and  zddm='" + lowZddm.trim() + "' and pzzl = '"
					+ pzzl.trim() + "' and d_z_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
		}
		if (levelfirst == 1 && levelsecond == 2) {
			String jxzt = "3";
			String lowZddmSub1 = lowZddm.substring(0, 4);// 拆取直属下级代码前4位
			sql = sql + "jxzt>='3' and syzt='" + syzt.trim()
					+ "' and substring(zddm,1,4) ='" + lowZddmSub1.trim()
					+ "' and pzzl = '" + pzzl.trim() + "' and z_zx_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
		}
		if (levelfirst == 1 && levelsecond == 3) {
			String jxzt = "3";
			sql = sql + "jxzt>='3' and syzt='" + syzt.trim()
					+ "' and zddm ='" + lowZddm.trim() + "' and pzzl = '"
					+ pzzl.trim() + "' and z_zx_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
		}
		if (levelfirst == 0 && levelsecond == 1) {
			String jxzt = "4";
			String lowZddmSub2 = lowZddm.substring(0, 2);// 拆取直属下级代码前2位
			sql = sql + "jxzt='" + jxzt.trim() + "' and syzt='" + syzt.trim()
					+ "' and substring(zddm,1,2) ='" + lowZddmSub2.trim()
					+ "' and pzzl = '" + pzzl.trim() + "' and zx_c_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
		}
		if (levelfirst == 0 && levelsecond == 3) {
			String jxzt = "4";
			sql = sql + "jxzt='" + jxzt.trim() + "' and syzt='" + syzt.trim()
					+ "' and zddm ='" + lowZddm.trim() + "' and zx_c_jxsj between '"
						+ hexiaoTimeStart.trim()
						+ "' and '"
						+ hexiaoTimeEnd.trim()+ "'";
		}
		Assert.pl(sql);
		ResultSet rs = conndb.executeQuery(sql);
		if (rs == null)
			return null;
		while (rs.next()) {
			result.add(new Pzzt(rs.getString("pzzl"), rs.getString("pzhm"), rs
					.getString("syzt"), rs.getString("jxzt"), rs
					.getString("zfzt"), rs.getString("c_zpsj"), rs
					.getString("c_zx_f"), rs.getString("zx_z_f"), rs
					.getString("z_d_f"), rs.getString("d_r_f"), rs
					.getString("r_d_jxsj"), rs.getString("d_z_jxsj"), rs
					.getString("z_zx_jxsj"), rs.getString("zx_c_jxsj"), rs
					.getString("dprdm"), rs.getString("zddm")));
		}
		conndb.close();
		return result;
	}

	public static ArrayList getPzqzsWeiHexiao(String highZddm,
			String lowZddm, String dprdm, String syzt, String pzzl)
			throws SQLException {
    //  将获取的所有的未核销票证信息全部分段;(起号、止号、种类、该核销票段总金额)
		ArrayList singleTickets = HexiaoShowList.getHexiaoList(highZddm,lowZddm,dprdm,syzt,pzzl);
		ArrayList pzqzLists = new ArrayList();
		Iterator itor = singleTickets.iterator();
		TreeMap treemap = new TreeMap();
		while (itor.hasNext()) {
			Pzzt pzzt = (Pzzt) itor.next();

			treemap.put(new Long(Long.parseLong(pzzt.getPzhm().trim())), pzzt
					.getPzhm().trim());
		}
		Iterator itor1 = treemap.values().iterator();

		PzqzHexiao pzqzhexiao = new PzqzHexiao();
		while (itor1.hasNext()) {
			String sNext = (String) itor1.next();
			long iNext = Long.parseLong(sNext);
			String sStartNum = pzqzhexiao.getPzqh();
			String sEndNum = pzqzhexiao.getPzzh();
			// System.out.println(sStartNum);
			// System.out.println(sEndNum);
			if (sStartNum == null) {
				pzqzhexiao.setPzqh(sNext);
				pzqzhexiao.setPzzh(sNext);
				pzqzhexiao.setPzzl(pzzl);
				//pzqzhexiao.setHexiaoJe(200);
			} else {
				if (iNext == Long.parseLong(sEndNum) + 1) {
					pzqzhexiao.setPzzh(sNext);
				} else {
					pzqzhexiao.setPzzl(pzzl);
					PzqzHexiao pzqztemp = new PzqzHexiao();
					pzqztemp.setPzzl(pzzl);
					pzqztemp.setPzqh(pzqzhexiao.getPzqh());
					pzqztemp.setPzzh(pzqzhexiao.getPzzh());
	/*				
					if(pzqzhexiao.getPzzl().equals("1"))
					{
						 sql = "select sum(jfje) as jeTotal from gjhc where pzzl='1' and sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";	
					}
					if(pzqzhexiao.getPzzl().equals("2"))
					{
						 sql = "select sum(jfje) as jeTotal from gnhc where sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";						
						//pzqztemp.setHexiaoJe(233);
						 System.out.println("dddfrsd");
					}
					if(pzqzhexiao.getPzzl().equals("3"))
					{
						 sql = "select sum(jfje) as jeTotal from tjp where sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";						
						//pzqztemp.setHexiaoJe(333);	
					}
					if(pzqzhexiao.getPzzl().equals("4"))
					{
						 sql = "select sum(jfje) as jeTotal from gnhc where pzzl='4' and sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";						
						//pzqztemp.setHexiaoJe(433);	
					}
					System.out.println(sql);
					ResultSet rs = conndb.executeQuery(sql);
					if (rs == null)
						{pzqztemp.setHexiaoJe(0);}
					 while (rs.next()) {
						 result.add(rs.getString("jeTotal"));	
						}
				    je = Float.parseFloat(String.valueOf(result.get(0)));
				    */
				    pzqztemp.setHexiaoJe(0);//设置每票段的金额
					pzqzLists.add(pzqztemp);
					pzqzhexiao.setPzqh(sNext);//每次拆分后要对最后一段进行特殊处理
					pzqzhexiao.setPzzh(sNext);				
				}
			}
		}
		pzqzLists.add(pzqzhexiao);
		if (pzqzhexiao.getPzqh() == null)
			pzqzLists.remove(pzqzhexiao);
		return pzqzLists;
	}	
	
	
	
	
	public static ArrayList getPzqzsYijingHexiao(String highZddm,
			String lowZddm, String dprdm, String syzt, String pzzl)
			throws SQLException {
    //  将获取的所有的已经核销票证信息全部分段;(起号、止号、种类、该核销票段总金额)
		float je;
		String sql = "";
		ArrayList result = new ArrayList();
		ArrayList result1 = new ArrayList();		
		ConnectDB conndb = new ConnectDB();
		ArrayList singleTickets = HexiaoRepTotal.getYijingHexiaoTotal(highZddm,
				lowZddm, dprdm, syzt, pzzl);
		ArrayList pzqzLists = new ArrayList();
		Iterator itor = singleTickets.iterator();
		TreeMap treemap = new TreeMap();
		while (itor.hasNext()) {
			Pzzt pzzt = (Pzzt) itor.next();

			treemap.put(new Long(Long.parseLong(pzzt.getPzhm().trim())), pzzt
					.getPzhm().trim());
		}
		Iterator itor1 = treemap.values().iterator();

		PzqzHexiao pzqzhexiao = new PzqzHexiao();
		while (itor1.hasNext()) {
			String sNext = (String) itor1.next();
			long iNext = Long.parseLong(sNext);
			String sStartNum = pzqzhexiao.getPzqh();
			String sEndNum = pzqzhexiao.getPzzh();
			// System.out.println(sStartNum);
			// System.out.println(sEndNum);
			if (sStartNum == null) {
				pzqzhexiao.setPzqh(sNext);
				pzqzhexiao.setPzzh(sNext);
				pzqzhexiao.setPzzl(pzzl);
				//pzqzhexiao.setHexiaoJe(200);
				if(pzqzhexiao.getPzzl().equals("1"))
				{
					 sql = "select sum(jfje) as jeTotal from gjhc where pzzl='1' and sfzf='否' and  pzhm between '"
						+ pzqzhexiao.getPzqh()
						+ "' and '"
						+ pzqzhexiao.getPzzh() + "'";	
				}
				if(pzqzhexiao.getPzzl().equals("2"))
				{
					 sql = "select sum(jfje) as jeTotal from gnhc where sfzf='否' and  pzhm between '"
						+ pzqzhexiao.getPzqh()
						+ "' and '"
						+ pzqzhexiao.getPzzh() + "'";						
					//pzqztemp.setHexiaoJe(233);	
				}
				if(pzqzhexiao.getPzzl().equals("3"))
				{
					 sql = "select sum(jfje) as jeTotal from tjp where sfzf='否' and  pzhm between '"
						+ pzqzhexiao.getPzqh()
						+ "' and '"
						+ pzqzhexiao.getPzzh() + "'";						
					//pzqztemp.setHexiaoJe(333);	
				}
				if(pzqzhexiao.getPzzl().equals("4"))
				{
					 sql = "select sum(jfje) as jeTotal from gnhc where pzzl='4' and sfzf='否' and  pzhm between '"
						+ pzqzhexiao.getPzqh()
						+ "' and '"
						+ pzqzhexiao.getPzzh() + "'";						
					//pzqztemp.setHexiaoJe(433);	
				}
				System.out.println(sql);
				ResultSet rs1 = conndb.executeQuery(sql);
				if (rs1 == null)
					{pzqzhexiao.setHexiaoJe(0);}
				 while (rs1.next()) {
					 result1.add(rs1.getString("jeTotal"));	
					}
			    je = Float.parseFloat(donull(String.valueOf(result1.get(0))));
			    pzqzhexiao.setHexiaoJe(je);//设置每票段的金额						

			} else {
				if (iNext == Long.parseLong(sEndNum) + 1) {
					pzqzhexiao.setPzzh(sNext);
				} else {
					pzqzhexiao.setPzzl(pzzl);
					PzqzHexiao pzqztemp = new PzqzHexiao();
					pzqztemp.setPzzl(pzzl);
					pzqztemp.setPzqh(pzqzhexiao.getPzqh());
					pzqztemp.setPzzh(pzqzhexiao.getPzzh());
					
					if(pzqzhexiao.getPzzl().equals("1"))
					{
						 sql = "select sum(jfje) as jeTotal from gjhc where pzzl='1' and sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";	
					}
					if(pzqzhexiao.getPzzl().equals("2"))
					{
						 sql = "select sum(jfje) as jeTotal from gnhc where sfzf='否' and  pzhm between '"
							+ pzqztemp.getPzqh()
							+ "' and '"
							+ pzqztemp.getPzzh() + "'";						

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -