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

📄 investmentjoin.java

📁 java swing源码 欢迎下载 有问题请联系 我一定负责到底
💻 JAVA
字号:
/**
 * 投连
 */
package com.NCL;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.sinosoft.common.DBAccess;
import com.sinosoft.common.Data;
import com.sinosoft.common.IndexMap;

public class InvestmentJoin {

	/**
	 * @param args
	 * @author Vincent	 * 
	 */
	protected IndexMap propList;
	protected HashSet Property;
	private List strList = new ArrayList();
	private boolean EOF = false;
	private int COUNT;
	protected String fMakeDate = "";
	protected String tMakeDate = "";
	protected String fValuationDate = "";
	protected String tValuationDate = "";
	/**
	 * 构造函数
	 *
	 */
	public InvestmentJoin(){
		propList = new IndexMap();
		Property = new HashSet();
		Property.add("RiskCode");		//险种编码
		Property.add("RiskName");		//险种名称
		Property.add("AccountCode");	//账户编码
		Property.add("AccountName");	//账户名称
		Property.add("ValuationDate");	//计价日
		Property.add("BuyInGrate");		//买入价
		Property.add("SellInGprice");	//卖出价
		Property.add("ValuationUnit");	//计价日单位 年月周日(Y,M,W,D)
		Property.add("MakeDate");		//创建日期
		Property.add("IsDisplay");		//是否发布	
		Property.add("ID");				//ID
		Property.add("RiskType");		//险种类型 投连
		Property.add("BalancePeriod");	//结算期间
	}
	/**
	 * 初始化
	 * @param ID ID
	 */
	public void Init(String ID){
		DBAccess d  = new DBAccess();
		String sql = "SELECT * from InvestmentJoin where ID=?";
		this.propList = d.init(sql,ID,this.Property);	
	}
	/**
	 * 创建
	 * @return boolean
	 */
	public boolean create(){
		DBAccess d = new DBAccess();
		String BuyInGrate = this.get("BuyInGrate");
		String SellInGprice = this.get("SellInGprice");
		String date = this.get("ValuationDate");
		try{
			java.text.DecimalFormat df=new java.text.DecimalFormat("##0.000000");
			if(Data.dateDiff("", date, "2007-11-16")>0)df=new java.text.DecimalFormat("##0.0000");
			BuyInGrate = df.format(Double.parseDouble(BuyInGrate));
			SellInGprice = df.format(Double.parseDouble(SellInGprice));
		}catch(Exception e){
			e.printStackTrace();
		}
		this.set("BuyInGrate", BuyInGrate);
		this.set("SellInGprice", SellInGprice);
		String sql = "insert into InvestmentJoin(RiskCode,RiskName,AccountCode,AccountName," +
												"ValuationDate,BuyInGrate,SellInGprice,ValuationUnit," +
												"MakeDate,IsDisPlay,RiskType,BalancePeriod,ID) values(?,?,?,?,to_date(?,'yyyy-MM-dd'),?,?,?,sysdate,?,?,?,INVESTMENTJOIN_SQE.nextval)";
		
		return d.execute(sql, this.propList);
	}
	/**
	 * 更新
	 * @return boolean
	 */
	public boolean update(){
		try{
			StringBuffer sql = new StringBuffer("update InvestmentJoin set ");
			List l = new ArrayList();
			for(int i=0;i<strList.size();i++){
				Object[] strArray =(Object[]) strList.get(i);
				sql.append(strArray[0]);
				sql.append("=?,");
				l.add(strArray[1]);
			}
			sql.deleteCharAt(sql.lastIndexOf(","));
			sql.append(" where ID=?");
			l.add(this.get("ID"));
			strList.clear();
			DBAccess q = new DBAccess();
			return q.executeUpdate(sql.toString(),l);
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("InvestmentJoin.update():" + e.getMessage());
			return false;
		}
	}
	/**
	 * 删除
	 * @param ID ID
	 * @return boolean
	 */
	public boolean delete(String ID){
		DBAccess DBA= new DBAccess();
		String SQL = "DELETE from InvestmentJoin WHERE ID=?";		
		return DBA.executeDelete(SQL,ID);
	}
	
	/**
	 * 查找最新的公布日期
	 * @return String
	 */
	public String findLastValuationDate(){
		String result = "";
		String sql = "select max(ValuationDate) from InvestmentJoin where IsDisplay='1' order by ValuationDate desc";
		DBAccess d = new DBAccess();
		List l = d.parseSQL(sql, new ArrayList());
		if(l==null || l.size()==0)return null;
		else {
			try{
				result = Data.dateFormat((String)l.get(0),"MM/dd/yyyy hh:mm:ss", "yyyy-MM-dd");
			}catch(Exception e){
				e.printStackTrace();
				result = null;
			}
		}
		return result;
	}
	
	/**
	 * 查找已经发布的险种代码
	 * @return List
	 */
	public List findRiskCode(){
		String sql = "SELECT distinct RiskCode from InvestmentJoin where IsDisplay='1' order by RiskCode";
		DBAccess d = new DBAccess();
		return d.parseSQL(sql, new ArrayList());
	}
	
	/**
	 * 判断是否存在已经发布的记录
	 * @return boolean
	 */
	public boolean hasDisplay(){
		String sql = "SELECT distinct ID from InvestmentJoin where IsDisplay='1'";
		DBAccess d = new DBAccess();
		if(Data.hasValue(d.executeQuery(sql, new IndexMap(), 1, 1)))return true;
		else return false;
	}

	/**
	 * 查找已经发布的账号名称
	 * @param RiskCode 险种代码
	 * @return String
	 */
	public String findAccountCode(String RiskCode){
		IndexMap m = new IndexMap();
		m.put("RiskCode", RiskCode);
		StringBuffer sql = new StringBuffer("SELECT distinct AccountCode from InvestmentJoin where IsDisplay='1'");
		if(Data.hasValue(RiskCode))
			sql.append(" and RiskCode = ?");
		sql.append(" order by AccountCode");
		DBAccess q = new DBAccess();
		return q.executeQuery(sql.toString(), m, 0, 1);
	}
	/**
	 * 根据条件查询
	 * @param I			对象
	 * @param pageSize	分页大小
	 * @param pageIndex	分页页码
	 * @return
	 */
	public String find(InvestmentJoin I,int pageSize,int pageIndex){
		String result="";
		String RiskCode = I.get("RiskCode");
		String RiskName = I.get("RiskName");
		String AccountCode = I.get("AccountCode");
		String AccountName = I.get("AccountName");
		String BuyInGrate = I.get("BuyInGrate");
		String SellInGprice = I.get("SellInGprice");
		String ValuationUnit = I.get("ValuationUnit");
		String IsDisplay = I.get("IsDisplay");
		String ID = I.get("ID");
		String RiskType = I.get("RiskType");
		String fMakeDate = I.getfMakeDate();
		String tMakeDate = I.gettMakeDate();
		String fValuationDate = I.getfValuationDate();
		String tValuationDate = I.gettValuationDate();
		StringBuffer sql = new StringBuffer("select ID from InvestmentJoin where 1=1");	
		if(Data.hasValue(RiskCode))
			sql.append(" and RiskCode=?");
		if(Data.hasValue(RiskName))
			sql.append(" and RiskName like ?");
		if(Data.hasValue(AccountCode))
			sql.append(" and AccountCode=?");
		if(Data.hasValue(AccountName))
			sql.append(" and AccountName like ?");
		if(Data.hasValue(BuyInGrate))
			sql.append(" and BuyInGrate=?");
		if(Data.hasValue(SellInGprice))
			sql.append(" and SellInGprice=?");
		if(Data.hasValue(ValuationUnit))
			sql.append(" and ValuationUnit=?");	
		if(Data.hasValue(IsDisplay))
			sql.append(" and IsDisplay=?");
		if(Data.hasValue(ID))
			sql.append(" and ID=?");
		if(Data.hasValue(RiskType))
			sql.append(" and RiskType=?");
		if(Data.hasValue(fMakeDate))
			sql.append(" and MakeDate>=to_date('" + fMakeDate + "','yyyy-MM-dd')");
		if(Data.hasValue(tMakeDate))
			sql.append(" and MakeDate<=to_date('" + tMakeDate + " 23:59:59','yyyy-MM-dd hh24:mi:ss')");
		if(Data.hasValue(fValuationDate))
			sql.append(" and ValuationDate>=to_date('" + fValuationDate + "','yyyy-MM-dd')");
		if(Data.hasValue(tValuationDate))
			sql.append(" and ValuationDate<=to_date('" + tValuationDate + " 23:59:59','yyyy-MM-dd hh24:mi:ss')");
		sql.append(" order by ValuationDate desc");
		DBAccess q = new DBAccess();
		result = q.executeQuery(sql.toString(), I.propList, pageSize, pageIndex);
		setCOUNT(q.COUNT);
		setEOF(q.EOF);
		return result;	
		
	}
	
	/**
	 * 在此映射中关联指定值与指定键
	 * @param name 指定键
	 * @param value 指定值
	 */
	public void setUpdateValue(String name,Object value){
		if(this.set(name,value)){
			Object[] uValue = new Object[2];
			uValue[0] = name;
			uValue[1] = value;
			strList.add(uValue);
		}
	}
	/**
	 * 在此映射中关联指定值与指定键
	 * @param name 指定键
	 * @param value 指定值
	 */
	public boolean set(String name, Object value){
		if(Property.contains(name)){
			propList.put(name,value);
			return true;
		}else
			return false;		
	}
	/**
	 * 返回指定键在此映射中所映射的值
	 * @param name 指定键
	 * @return
	 */
	public String get(String name){
		if (Property.contains(name)){
			String value = (String)propList.get(name);
			if(value != null && !value.equals(""))
				return value;
			else
				return "";
		}else 
			return "";
	}
	/**
	 * 返回COUNT
	 * @return int
	 */
	public int getCOUNT() {
		return COUNT;
	}
	/**
	 * 设置COUNT
	 * @param count
	 */
	public void setCOUNT(int count) {
		COUNT = count;
	}
	/**
	 * 返回EOF
	 * @return boolean
	 */
	public boolean isEOF() {
		return EOF;
	}
	/**
	 * 设置EOF
	 * @param eof
	 */
	public void setEOF(boolean eof) {
		EOF = eof;
	}
	/**
	 * 清空propList
	 *
	 */
	public void clear(){
		propList.clear();
	}
	/**
	 * 获取fMakeDate
	 * @return String
	 */
	public String getfMakeDate() {
		return fMakeDate;
	}
	/**
	 * 设置fMakeDate
	 * @param str 日期
	 */
	public void setfMakeDate(String str) {
		fMakeDate = str;
	}
	/**
	 * 获取tMakeDate
	 * @return String
	 */
	public String gettMakeDate() {
		return tMakeDate;
	}
	/**
	 * 设置tMakeDate
	 * @param str 日期
	 */
	public void settMakeDate(String str) {
		tMakeDate = str;
	}
	/**
	 * 获取fValuationDate
	 * @return String
	 */
	public String getfValuationDate() {
		return fValuationDate;
	}
	/**
	 * 设置fValuationDate
	 * @param str 日期
	 */
	public void setfValuationDate(String str) {
		fValuationDate = str;
	}
	/**
	 * 获取tValuationDate
	 * @return String
	 */
	public String gettValuationDate() {
		return tValuationDate;
	}
	/**
	 * 设置tValuationDate
	 * @param str 日期
	 */
	public void settValuationDate(String str) {
		tValuationDate = str;
	}
}

⌨️ 快捷键说明

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