package core.stlmes.server.sale.dao;

import CoreFS.SA06.CoreReturnObject;
import core.stlmes.server.sale.po.SlmBalanceTransMoneyBean;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class SlmBalanceTransMoneyDao extends BaseService
{
	private List<SlmBalanceTransMoneyBean> query(String sqlCondition)
			throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlStr = "select * from SLM_BALANCE_TRANSMONEY  where 1 = 1 ";
		sqlStr = sqlStr + sqlCondition;
		java.sql.ResultSet set = super.executeForResult(sqlStr);
		list = SlmBalanceTransMoneyBean.convertResultSetToBeanList(set);
		set.close();
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getunInvoiceSlmBalanceTransMoneyByBuyerCode(
			String buyercode) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("buyercode",
				buyercode);
		sqlCondition += "   and STATUS_CD in( '1','0')   and MONEY_TYPE = '运费' and TICKETTYPE = '应收' ";
		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getunInvoiceOutStockMnySlmBalanceTransMoneyByAskPlanId(
			String askPlandid) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ASKPLAN_ID",
				askPlandid);
		sqlCondition += "  and STATUS_CD in( '1','0')    and MONEY_TYPE = '出库费'  ";
		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getOutStockMnySlmBalanceTransMoneyByAskPlanId(
			String askPlandid) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ASKPLAN_ID",
				askPlandid);
		sqlCondition += "   and MONEY_TYPE = '出库费'  ";
		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getOutStockMnySlmBalanceTransMoneyByListnumber(
			String listnumber) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("LISTNUMBER",
				listnumber);

		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getSlmBalanceTransMoneyByAskPlanId(
			String askPlandid) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ASKPLAN_ID",
				askPlandid);

		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getunInvoiceOutStockMnySlmBalanceTransMoneyByBuyerCode(
			String buyercode) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("buyercode",
				buyercode);
		sqlCondition += "   and STATUS_CD in( '1','0')   and MONEY_TYPE = '出库费' and TICKETTYPE = '应收' ";
		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getunInvoiceOutStockMnySlmBalanceTransMoneyByRealInvoiceNo(
			String REALINVOICENO) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue(
				"REALINVOICENO", REALINVOICENO);

		list = query(sqlCondition);
		return list;
	}

	public List<SlmBalanceTransMoneyBean> getunInvoiceOutStockMnySlmBalanceTransMoneyByRealInvoiceNoOrg(
			String REALINVOICENO) throws SQLException
	{
		List<SlmBalanceTransMoneyBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue(
				"REALINVOICENO_ORG", REALINVOICENO);

		list = query(sqlCondition);
		return list;
	}

	public SlmBalanceTransMoneyBean getSlmBalanceTransMoneyBeanByTransPk(
			String trans_pk) throws SQLException
	{
		String sqlCondition = super.GetSqlConditionByStringValue("TRANS_PK",
				trans_pk);
		List<SlmBalanceTransMoneyBean> list = query(sqlCondition);
		if (list == null) return null;
		return list.get(0);
	}

	public CoreReturnObject updateInvoiceNo(String invoiceNo, String person,
			String TRANS_PK) throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  TRANS_PK = ?";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, TRANS_PK });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject deleteTransMoneyByAskPlanIdAndOrdPkAndLineAndDelPkAndSeq(
			String askplanid, String ORD_PK, String ORD_LN_PK,
			String ORD_LN_DLY_PK, String INDEX_SEQ)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  delete from  slm_balance_transmoney a where  "
				+ "  a.askplan_id||a.ord_pk||a.ord_ln_pk||a.ord_ln_dly_pk||a.agency_fl = ? "
				+ " and money_type = '运费'  and status_cd <> '2' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ askplanid + ORD_PK + ORD_LN_PK + ORD_LN_DLY_PK + INDEX_SEQ });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject updateTransMoneyInvoiceNo(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  askplan_id = ? "
				+ "  and STATUS_CD in( '1','0')   and MONEY_TYPE = '运费' and TICKETTYPE = '应收'";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, askPlanId });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject updateTransMoneyInvoiceNoByBuyerCode(
			String invoiceNo, String person, String buyercodeAndForeName)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  buyercode||forecorpname = ? "
				+ "  and STATUS_CD in( '1')   and MONEY_TYPE = '运费' and TICKETTYPE = '应收'";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, buyercodeAndForeName });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String updateTransMoneyInvoiceNoByBuyerCodeSqlStr(String invoiceNo,
			String person, String buyercodeAndForeName)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,INVOICE_MONTH = to_char(sysdate,'yyyymm'),STATUS_CD = '2'   where  buyercode||forecorpname = ? "
				+ "  and STATUS_CD in( '1')   and MONEY_TYPE = '运费' and TICKETTYPE = '应收'";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, buyercodeAndForeName });
		return sql;

	}

	public String updateTransMoneyAndStockMnyInvoiceNoByBusiseq(
			String invoiceNo, String person, String busiseq)
	{
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  trans_pk = ? "
				+ "  and STATUS_CD in( '1','0')    and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, busiseq });
		return sql;

	}

	public String updateTransMoneyAndStockMnyInvoiceNoOrgByBusiseq(
			String invoiceNo, String person, String busiseq)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = ?, "
				+ "  invoicedate_org = sysdate,invoiceperson_org = ?  where trans_pk = ? "
				+ "  and  invoiceno_org is null   and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, busiseq });
		return sql;

	}

	public CoreReturnObject updateTransMoneyInvoiceNoOrg(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = ?,"
				+ "  invoicedate_org = sysdate   where  askplan_id = ? "
				+ "  and invoiceno_org is  null   and MONEY_TYPE = '运费' and TICKETTYPE = '应收'";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, askPlanId });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String updateTransMoneyInvoiceNoOrgSqlStr(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = ?,"
				+ "  invoicedate_org = sysdate ,STATUS_CD_ORG = '2',INVOICEPERSON_ORG = ?  where  askplan_id = ? "
				+ "  and invoiceno_org is  null   and MONEY_TYPE = '运费' and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, askPlanId });
		return sql;

	}

	public CoreReturnObject updateOutStockMoneyInvoiceNo(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  askplan_id = ? "
				+ "  and STATUS_CD in( '1')   and MONEY_TYPE = '出库费' and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, askPlanId });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String updateOutStockMoneyInvoiceNoSqlStr(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = ?,INVOICE_ID = ?,"
				+ "INVOICE_MONTH = to_char(sysdate,'yyyymm'),Invoice_Sts = '0' ,"
				+ "  INVOICEDATE = sysdate,STATUS_CD = '2'   where  askplan_id = ? "
				+ "  and STATUS_CD in( '1')   and MONEY_TYPE = '出库费' and TICKETTYPE = '应收'";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, askPlanId });
		return sql;

	}

	public CoreReturnObject updateOutStockMoneyInvoiceNoOgr(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = ?,"
				+ "  invoicedate_org = sysdate  where  askplan_id = ? "
				+ "  and invoiceno_org is  null    and MONEY_TYPE = '出库费' and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, askPlanId });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String updateOutStockMoneyInvoiceNoOgrSqlStr(String invoiceNo,
			String person, String askPlanId) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = ?,"
				+ "  invoicedate_org = sysdate,STATUS_CD_ORG = '2',INVOICEPERSON_ORG = ?  where  askplan_id = ? "
				+ "  and invoiceno_org is  null    and MONEY_TYPE = '出库费' and TICKETTYPE = '应收' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo, person, askPlanId });
		return sql;

	}

	public String affrimTransTickets(String listnumber, String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set ticketstatus = '1',"
				+ "  TICKETDATE = sysdate,TICKETPERSON = ?  where  LISTNUMBER = ? ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ person, listnumber });
		return sql;

	}

	public String unaffrimTransTickets(String listnumber, String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set ticketstatus = '0',"
				+ "  TICKETDATE = null,TICKETPERSON = null  where  LISTNUMBER = ? ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ listnumber });
		return sql;

	}

	public CoreReturnObject rollbackInvoiceNo(String invoiceNo, String person)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set INVOICENO = '',INVOICE_ID = '',"
				+ "  INVOICEDATE = null,STATUS_CD = '1',REALINVOICENO = ''   where  INVOICENO = ?";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject rollbackInvoiceNoOrg(String invoiceNo, String person)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set invoiceno_org = '',REALINVOICENO_ORG = '',"
				+ "  invoicedate_org = null,invoiceperson_org = '',STATUS_CD_org = '1'  where  invoiceno_org = ?";
		sql = super.getPreparedSQL(sql, new Object[]
		{ invoiceNo });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject updateRealInvoiceNo(String invoiceNo,
			String realInvoiceNo, String person) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set realinvoiceno = ?,"
				+ "  realinvoice_date = sysdate " + "    where  invoiceno = ? ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ realInvoiceNo, invoiceNo });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject updateRealInvoiceNoOrg(String invoiceNo,
			String realInvoiceNo, String person) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "  update slm_balance_transmoney set realinvoiceno_org = ?,"
				+ "  REALINVOICE_ORG_DATE = sysdate "
				+ "    where  invoiceno_org = ? ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ realInvoiceNo, invoiceNo });
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject insert(SlmBalanceTransMoneyBean bean)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = getInsertSql(bean);
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public void insert(java.sql.Connection con, SlmBalanceTransMoneyBean bean)
			throws java.sql.SQLException,java.lang.Exception
	{
		String sql = getInsertSql(bean);
		PreparedStatement ps = con.prepareStatement(sql);
		ps.executeUpdate();
		ps.close();
	}

	public void deleteOutStockMnyByBillNo(java.sql.Connection con, String billno)
			throws java.sql.SQLException,java.lang.Exception
	{
		String sql = "delete from SLM_BALANCE_TRANSMONEY  where ASKPLAN_ID = ? "
				+ " and STATUS_CD <> '2'  and money_type = '出库费' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ billno });
		PreparedStatement ps = con.prepareStatement(sql);
		ps.executeUpdate();
		ps.close();
	}

	public String deleteOutStockMnyByBillNoSql(String billno)
	{
		String sql = "delete from SLM_BALANCE_TRANSMONEY  where ASKPLAN_ID = ? "
				+ " and STATUS_CD <> '2'  and money_type = '出库费' ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ billno });
		return sql;
	}

	public String deleteTranskMnyByBillNoSql(String billno)
	{
		String sql = "delete from SLM_BALANCE_TRANSMONEY  where ASKPLAN_ID = ? "
				+ " and STATUS_CD <> '2'  and money_type = '运费'  ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ billno });
		return sql;
	}

	public CoreReturnObject delete(String TRANS_PK)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "delete from SLM_BALANCE_TRANSMONEY  where TRANS_PK = ? ";
		sql = super.getPreparedSQL(sql, new Object[]
		{ TRANS_PK });

		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject update(String transpk, double ticketNum,
			double money, String person) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY " + " set TICKETNUM = ?,"
				+ " money = ?,REG_ID = ? " + " where TRANS_PK = ? ";
		Object[] param = new Object[]
		{ ticketNum, money, person, transpk };
		sql = super.getPreparedSQL(sql, param);
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public CoreReturnObject affrimAskPlanIdFroTransMny(String askPlanid,
			String person) throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY " + " set STATUS_CD = '1',"
				+ "AFFRIM_TIME = sysdate,AFFRIM_ID = ? "
				+ " where ASKPLAN_ID = ?  and MONEY_TYPE = '运费' ";
		Object[] param = new Object[]
		{ person, askPlanid };
		sql = super.getPreparedSQL(sql, param);
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String affrimAskPlanIdFroTransSql(String askPlanid, String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY "
				+ " set STATUS_CD = '1',"
				+ "AFFRIM_TIME = sysdate,AFFRIM_ID = ? "
				+ " where ASKPLAN_ID = ?  and  STATUS_CD = '0' and TICKETSTATUS = '1'";
		Object[] param = new Object[]
		{ person, askPlanid };
		sql = super.getPreparedSQL(sql, param);

		return sql;

	}

	public String affrimAskPlanIdFroTransSqlOrg(String askPlanid, String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY "
				+ " set STATUS_CD_ORG = '1',"
				+ "STATUS_CD_ORG_DATE = sysdate,STATUS_CD_ORG_PER = ? "
				+ " where ASKPLAN_ID = ?  and  STATUS_CD_ORG = '0' and TICKETSTATUS = '1' ";
		Object[] param = new Object[]
		{ person, askPlanid };
		sql = super.getPreparedSQL(sql, param);

		return sql;

	}

	public String unAffrimAskPlanIdFroTransSql(String askPlanid, String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY "
				+ " set STATUS_CD = '0',"
				+ "AFFRIM_TIME = null,AFFRIM_ID = null "
				+ " where ASKPLAN_ID = ?  and  STATUS_CD = '1' and TICKETSTATUS = '1'  ";
		Object[] param = new Object[]
		{ askPlanid };
		sql = super.getPreparedSQL(sql, param);

		return sql;

	}

	public String unaffrimAskPlanIdFroTransSqlOrg(String askPlanid,
			String person)
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY "
				+ " set STATUS_CD_ORG = '0',"
				+ "STATUS_CD_ORG_DATE = null,STATUS_CD_ORG_PER = null "
				+ " where ASKPLAN_ID = ?  and  STATUS_CD_ORG = '1' and TICKETSTATUS = '1' ";
		Object[] param = new Object[]
		{ askPlanid };
		sql = super.getPreparedSQL(sql, param);

		return sql;

	}

	public CoreReturnObject unaffrimAskPlanIdFroTransMny(String askPlanid,
			String person) throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		String sql = "update SLM_BALANCE_TRANSMONEY " + " set STATUS_CD = '0',"
				+ "AFFRIM_TIME = null,AFFRIM_ID = ? "
				+ " where ASKPLAN_ID = ?  and MONEY_TYPE = '运费' ";
		Object[] param = new Object[]
		{ person, askPlanid };
		sql = super.getPreparedSQL(sql, param);
		obj = super.ExcuteNonQueryIgnoreTrans(sql);
		return obj;

	}

	public String getmaxInvoiceNo() throws java.sql.SQLException
	{
		String sqlStr = "select NVL(max(replace(a.invoiceno, 'T', '')),"
				+ "           to_char(sysdate, 'yyyymmdd') || '00001')  INV"
				+ "  from slm_balance_transmoney a WHERE "
				+ "  a.invoiceno  like '%'||to_char(sysdate,'yyyymmdd')||'%' ";
		java.sql.ResultSet set = super.executeForResult(sqlStr);
		if (set == null) throw new SQLException();
		while (set.next())
		{
			return set.getString("INV");
		}

		return "";
	}

	private String getInsertSql(SlmBalanceTransMoneyBean bean)
	{
		java.lang.StringBuilder sb = new StringBuilder();
		sb.append(" insert into SLM_BALANCE_TRANSMONEY ( ");
		sb.append("TRANS_PK, ");
		sb.append("ASKPLAN_ID, ");
		sb.append("TALLYSHEET_NO, ");
		sb.append("LOADVEHICLE_NO, ");
		sb.append("ORD_PK, ");
		sb.append("ORD_LN_PK, ");
		sb.append("ORD_LN_DLY_PK, ");
		sb.append("AGENCY_FL, ");
		sb.append("RECEIV_ADDR, ");
		sb.append("TICKETNUM, ");
		sb.append("ORDER_NO, ");
		sb.append("ORDER_SEQ, ");
		sb.append("DELIVERY_NO, ");
		sb.append("INDEX_SEQ, ");
		sb.append("DELVRY_ADDR, ");
		sb.append("BUYERCODE, ");
		sb.append("BUYERNAME, ");
		sb.append("FORECORPCODE, ");
		sb.append("FORECORPNAME, ");
		sb.append("FST_DRAWEE_UNIT, ");
		sb.append("INCEPTCORPCODE, ");
		sb.append("TRANS_TYPE, ");
		sb.append("MOTORMANNAME, ");
		sb.append("DOCKNAME, ");
		sb.append("TICKETTYPE, ");
		sb.append("TICKETNO, ");
		sb.append("MONEY_TYPE, ");
		sb.append("MONEY, ");
		sb.append("INVOICENO, ");
		sb.append("INVOICEDATE, ");
		sb.append("INVOICE_ID, ");
		sb.append("STATUS_CD, ");
		sb.append("REG_ID, ");
		sb.append("REG_DTIME, ");
		sb.append("AFFRIM_ID, ");
		sb.append("AFFRIM_TIME, ");
		sb.append("WEIGHT, ");
		sb.append("INVOICENO_ORG, ");
		sb.append("INVOICEDATE_ORG, ");
		sb.append("INVOICEPERSON_ORG, ");
		sb.append("REALINVOICENO, ");
		sb.append("REALINVOICENO_ORG, ");
		sb.append("APPLY_PERSON, ");
		sb.append("APPLY_DATE, ");
		sb.append("APPLY_NO, ");
		sb.append("LISTNUMBER, ");
		sb.append("TICKETSTATUS, ");
		sb.append("TICKETDATE, ");
		sb.append("TICKETPERSON, ");
		sb.append("STATUS_CD_ORG, ");
		sb.append("STATUS_CD_ORG_PER, ");
		sb.append("STATUS_CD_ORG_DATE, ");
		sb.append("APPLY_DATE_STS, ");
		sb.append("RPY_APPLY_NO, ");
		sb.append("REALINVOICE_DATE, ");
		sb.append("REALINVOICE_ORG_DATE, ");
		sb.append("INVOICE_MONTH, ");
		sb.append("INVOICE_STS, ");
		sb.append("DISBURASES_BILL, ");
		sb.append("TRANS_NO, ");
		sb.append("STAMP_DUTY_MONEY ");
		sb.append(" ) values ( ");
		sb.append(" sys_guid() ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ");
		sb.append(" ) ");

		Object[] param = new Object[]
		{ bean.getAskplan_id(), bean.getTallysheet_no(),
				bean.getLoadvehicle_no(), bean.getOrd_pk(),
				bean.getOrd_ln_pk(), bean.getOrd_ln_dly_pk(),
				bean.getAgency_fl(), bean.getReceiv_addr(),
				bean.getTicketnum(), bean.getOrder_no(), bean.getOrder_seq(),
				bean.getDelivery_no(), bean.getIndex_seq(),
				bean.getDelvry_addr(), bean.getBuyercode(),
				bean.getBuyername(), bean.getForecorpcode(),
				bean.getForecorpname(), bean.getFst_drawee_unit(),
				bean.getInceptcorpcode(), bean.getTrans_type(),
				bean.getMotormanname(), bean.getDockname(),
				bean.getTickettype(), bean.getTicketno(), bean.getMoney_type(),
				bean.getMoney(), bean.getInvoiceno(), bean.getInvoicedate(),
				bean.getInvoice_id(), bean.getStatus_cd(), bean.getReg_id(),
				bean.getReg_dtime(), bean.getAffrim_id(),
				bean.getAffrim_time(), bean.getWeight(),
				bean.getInvoiceno_org(), bean.getInvoicedate_org(),
				bean.getInvoiceperson_org(), bean.getRealinvoiceno(),
				bean.getRealinvoiceno_org(), bean.getApply_person(),
				bean.getApply_date(), bean.getApply_no(), bean.getListnumber(),
				bean.getTicketstatus(), bean.getTicketdate(),
				bean.getTicketperson(), bean.getStatus_cd_org(),
				bean.getStatus_cd_org_per(), bean.getStatus_cd_org_date(),
				bean.getApply_date_sts(), bean.getRpy_apply_no(),
				bean.getRealinvoice_date(), bean.getRealinvoice_org_date(),
				bean.getInvoice_month(), bean.getInvoice_sts(),bean.getDisburases_bill(),bean.getTrans_no(),
				bean.getStampDutyMoney()};
		String sql = sb.toString();
		for (int i = 0; i < param.length; i++)
		{
			Object parm=param[i];
			if (parm == null)
				continue;
			if(parm.toString().contains("'")){
				parm=parm.toString().replace("'", "''");
				param[i]=parm;
				String a=parm.toString();
			}
		}
		sql = super.getPreparedSQL(sql, param);
		return sql;

	}
}
