com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java Source code

Java tutorial

Introduction

Here is the source code for com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java

Source

package com.yucheng.cmis.pvp.app.component;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.sql.Connection;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtilsBean;

import com.ecc.emp.core.Context;
import com.ecc.emp.core.EMPException;
import com.ecc.emp.data.KeyedCollection;
import com.ecc.emp.data.IndexedCollection;
import com.ecc.emp.dbmodel.service.TableModelDAO;
import com.yucheng.cmis.base.CMISConstance;
import com.yucheng.cmis.base.CMISException;
import com.yucheng.cmis.cb.dao.CreditBusinessQuartzService;
import com.yucheng.cmis.cbsinterface.InternationTradeAgent;
import com.yucheng.cmis.cbsinterface.TradeAgent;
import com.yucheng.cmis.ctr.Constant;
import com.yucheng.cmis.ctr.cont.IAddContRecord;
import com.yucheng.cmis.ctr.cont.ICtrCont;
import com.yucheng.cmis.ctr.cont.domain.CtrAccpCont;
import com.yucheng.cmis.ctr.cont.domain.CtrCvrgCont;
import com.yucheng.cmis.ctr.cont.domain.CtrDiscCont;
import com.yucheng.cmis.ctr.cont.domain.CtrLoanCont;
import com.yucheng.cmis.ctr.tf.component.CtrTfCvrgComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfCvrgExtComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfIbcComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfLocComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfLocExtComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfObcComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfOiffComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfOinvfComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfPgasComponent;
import com.yucheng.cmis.ctr.tf.component.CtrTfRemitComponent;
import com.yucheng.cmis.ctr.tf.domain.CtrTfCvrg;
import com.yucheng.cmis.ctr.tf.domain.CtrTfCvrgExt;
import com.yucheng.cmis.ctr.tf.domain.CtrTfFft;
import com.yucheng.cmis.ctr.tf.domain.CtrTfIbc;
import com.yucheng.cmis.ctr.tf.domain.CtrTfLoc;
import com.yucheng.cmis.ctr.tf.domain.CtrTfLocExt;
import com.yucheng.cmis.ctr.tf.domain.CtrTfObc;
import com.yucheng.cmis.ctr.tf.domain.CtrTfOboc;
import com.yucheng.cmis.ctr.tf.domain.CtrTfOiff;
import com.yucheng.cmis.ctr.tf.domain.CtrTfOinsf;
import com.yucheng.cmis.ctr.tf.domain.CtrTfOinvf;
import com.yucheng.cmis.ctr.tf.domain.CtrTfPgas;
import com.yucheng.cmis.ctr.tf.domain.CtrTfRemit;
import com.yucheng.cmis.ctr.tf.domain.TfSecurityMsg;
import com.yucheng.cmis.ctr.tf.tfinterface.impl.CtrTfLocImpl;
import com.yucheng.cmis.cus.cusbase.domain.CusBase;
import com.yucheng.cmis.cusinterface.CustomIface;
import com.yucheng.cmis.imp.domain.ImpLoanReserve;
import com.yucheng.cmis.imp.domain.ImpMission;
import com.yucheng.cmis.iqp.accp.agent.IqpAccpAppAgent;
import com.yucheng.cmis.iqp.accp.domain.IqpAccpBill;
import com.yucheng.cmis.iqp.disc.domain.IqpDiscBillList;
import com.yucheng.cmis.iqpinterface.Iqp4PvpInterface;
import com.yucheng.cmis.pub.CMISAgentFactory;
import com.yucheng.cmis.pub.CMISComponent;
import com.yucheng.cmis.pub.CMISComponentFactory;
import com.yucheng.cmis.pub.CMISDomain;
import com.yucheng.cmis.pub.CMISMessage;
import com.yucheng.cmis.pub.ComponentHelper;
import com.yucheng.cmis.pub.CusPubConstant;
import com.yucheng.cmis.pub.PUBConstant;
import com.yucheng.cmis.pub.TradeCodeConstant;
import com.yucheng.cmis.pub.exception.ComponentException;
import com.yucheng.cmis.pub.pubopera.PubOperaInterface;
import com.yucheng.cmis.pub.sequence.CMISSequenceService;
import com.yucheng.cmis.pub.util.AmtUtil;
import com.yucheng.cmis.pub.util.TimeUtil;
import com.yucheng.cmis.pub.util.TransUtil;
import com.yucheng.cmis.pvp.account.agent.AccAgent;
import com.yucheng.cmis.pvp.account.domain.AccAccp;
import com.yucheng.cmis.pvp.account.domain.AccBillDetails;
import com.yucheng.cmis.pvp.account.domain.AccCvrg;
import com.yucheng.cmis.pvp.account.domain.AccDisc;
import com.yucheng.cmis.pvp.account.domain.AccLoan;
import com.yucheng.cmis.pvp.app.agent.PvpAccpAppAgent;
import com.yucheng.cmis.pvp.app.agent.PvpAppAgent;
import com.yucheng.cmis.pvp.app.agent.PvpAuthorizeAgent;
import com.yucheng.cmis.pvp.app.agent.PvpCvrgAppAgent;
import com.yucheng.cmis.pvp.app.agent.PvpDiscAppAgent;
import com.yucheng.cmis.pvp.app.agent.PvpLoanAppAgent;
import com.yucheng.cmis.pvp.app.agent.PvpLoanExtendAgent;
import com.yucheng.cmis.pvp.app.domain.PvpAccpApp;
import com.yucheng.cmis.pvp.app.domain.PvpAuthorize;
import com.yucheng.cmis.pvp.app.domain.PvpCvrgApp;
import com.yucheng.cmis.pvp.app.domain.PvpDiscApp;
import com.yucheng.cmis.pvp.app.domain.PvpLoanApp;
import com.yucheng.cmis.pvp.app.domain.PvpLoanExtend;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfCvrgAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfCvrgExtAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfFftAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfIbcAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfLocAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfLocExtAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfObcAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfObocAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfOiffAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfOinsfAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfOinvfAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfPgasAgent;
import com.yucheng.cmis.pvp.tfacc.agent.AccTfRemitAgent;
import com.yucheng.cmis.pvp.tfacc.component.AccTfCommComponent;
import com.yucheng.cmis.pvp.tfacc.component.AccTfCvrgComponent;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfComm;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfCvrg;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfCvrgExt;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfFft;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfIbc;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfLoc;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfLocExt;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfObc;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfOboc;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfOiff;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfOinsf;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfOinvf;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfPgas;
import com.yucheng.cmis.pvp.tfacc.domain.AccTfRemit;
import com.yucheng.cmis.pvp.tfacc.domain.LmDeviAmtTfLog;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfFftComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfLocExtComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfObcComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfObocComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfOiffComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfOinvfComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfOthExtComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfPgasComponent;
import com.yucheng.cmis.pvp.tfpvp.component.PvpTfRemitComponent;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfCvrg;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfCvrgExt;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfFft;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfIbc;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfLoc;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfLocExt;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfObc;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfOboc;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfOiff;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfOinsf;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfOinvf;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfOthExt;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfPgas;
import com.yucheng.cmis.pvp.tfpvp.domain.PvpTfRemit;
import com.yucheng.cmis.pvp.tfpvp.tfinterface.PvpTfIface;
import com.yucheng.cmis.pvp.tfpvp.tfinterface.impl.PvpTfImpl;
import com.yucheng.cmis.pub.util.TimeUtil;
import com.yucheng.cmis.pvp.tfacc.domain.TfExchangeAmtLog;
import com.yuchengtech.ycloans.common.DateOperation;

/**
 * @Classname PvpAuthorizeComponent
 * @Version 0.1
 * @Since 2009-4-10
 * @Copyright yuchengtech
 * @Author xukai
 * @Description  
 * @Lastmodified 
 * @Author
 */
public class PvpAuthorizeComponent extends CMISComponent {

    public static String checkNull(String value) {
        if (value == null) {
            return "";
        }

        return value;
    }

    /**
     * ??
     * 
     * 
     * 
     * *120=
     * @param rate
     * @return
     */
    public static String getCoreTradeRate(Double rate) {
        BigDecimal reality = new BigDecimal(rate);
        reality = reality.multiply(new BigDecimal(120));
        reality = reality.divide(new BigDecimal(1), 5, BigDecimal.ROUND_HALF_UP);

        return reality.toPlainString();
    }

    /**
     * ???
     */
    public static String optTranse(String old) {
        HashMap map = new HashMap();

        //?  
        map.put("tradeCode1004", "01");//      01
        map.put("tradeCode1007", "02");//      02
        map.put("tradeCode1010", "03");//      03
        map.put("tradeCode1008", "04");//      04?
        map.put("tradeCode1012", "05");//      05??
        map.put("tradeCode1014", "06");//      06???
        map.put("tradeCode1016", "08");//         07
        map.put("tradeCode1018", "09");//         08
        map.put("tradeCodenull", "");//         06?

        //?
        map.put("prdType01", "1");
        map.put("prdType02", "2");

        //??
        map.put("curTypeCNY", "01");//?
        map.put("curTypeGBP", "12");//
        map.put("curTypeHKD", "13");//?
        map.put("curTypeUSD", "14");//
        map.put("curTypeEUR", "38");//
        map.put("curTypeMOP", "81");//
        map.put("curTypeJPY", "27");//
        map.put("curTypenull", "");//?

        //?
        /**
         * 
         * @todo
         * ?????
         * 
         * 0   ??
         4   ?
         5   ?
         6   ????
         7   
         8   ?
            
         */
        map.put("certType10", "0");//?
        map.put("certType11", "0");//
        map.put("certType13", "4");//
        map.put("certType11", "0");
        map.put("certType11", "0");
        map.put("certType11", "0");
        map.put("certType11", "0");
        map.put("certType11", "0");

        //?
        map.put("YN1", "1"); //
        map.put("YN2", "0"); //?

        //?
        map.put("delayductType01", "101"); //
        map.put("delayductType02", "102"); //??
        map.put("delayductTypenull", ""); //?

        //?
        map.put("irAdjustMode1", "0"); //
        map.put("irAdjustMode2", "1"); //?
        map.put("irAdjustMode3", "1"); //
        map.put("irAdjustMode4", "2"); //
        map.put("irAdjustMode5", "3"); //
        map.put("irAdjustMode6", "2"); //?
        map.put("irAdjustMode7", "3"); //?
        map.put("irAdjustMode8", "4"); //?
        map.put("irAdjustModenull", "");//?

        //??
        map.put("guaranteeType1", "2"); //??
        map.put("guaranteeType2", "1"); //?
        map.put("guaranteeTypenull", ""); //?

        //??
        map.put("billType1", "2"); //
        map.put("billType2", "1"); //

        //??

        map.put("acptType1", "01");//
        map.put("acptType2", "03");//
        map.put("issualTypenull", "");//?

        //null?""
        map.put("null", "");

        return (map.get(old)) != null ? ((String) (map.get(old))) : old;
    }

    /**
     * ???
     * @param startDate, dueDate
     * @param 0-1-2-
     * @throws EMPException 
     * @throws Exception
     */
    public String calTermType(String startDate, String endDate) {
        String[] start = startDate.split("-");
        String[] end = endDate.split("-");
        int term = 0;
        String termType = "";

        term = ((Integer.parseInt(end[0]) - Integer.parseInt(start[0])) * 12
                + (Integer.parseInt(end[1]) - Integer.parseInt(start[1]))
                + (Integer.parseInt(end[2]) > Integer.parseInt(start[2]) ? 1 : 0));

        switch (term / 12) {
        case 0:
        case 1:
            termType = "0";
            break;
        case 2:
        case 3:
            termType = "1";
            break;
        default:
            termType = "3";
        }

        return termType;
    }

    /**
     * ???????
      * @param serno
      * @return PvpAuthorize
      * @throws EMPException
      */
    public PvpAuthorize queryPvpAuthorize(String serno) throws EMPException, ComponentException {
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        pvpAuthorize = pvpAuthorizeAgent.queryPvpAuthorize(serno);

        return pvpAuthorize;
    };

    /**
     * ????????
     *       ????
     * @param pvpSerno ??
     * @throws EMPException 
     * @throws InvocationTargetException 
     * @throws IllegalAccessException 
     * @throws Exception
     */
    public String addPvpLoanAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {
        Context context = this.getContext();
        Connection connn = this.getConnection();
        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpLoanAppAgent pvpLoanAppAgent = (PvpLoanAppAgent) this.getAgentInstance(PUBConstant.PVPLOANAPP);

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);

        ComponentHelper cHelper = new ComponentHelper();

        PvpLoanApp pvpLoanApp = new PvpLoanApp();
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        String billNo = "";

        //?????
        pvpLoanApp = pvpLoanAppAgent.queryPvpLoanApp(pvpSerno);
        if (pvpLoanApp == null || pvpLoanApp.getContNo() == null) {
            return strReturnMessage;
        }
        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);

        CusBase cusBase = customIface.getCusBase(pvpLoanApp.getCusId());
        //?
        String transCusId = cusBase.getTransCusId();
        //?
        String certType = cusBase.getCertType();
        //???
        String certCode = cusBase.getCertCode();
        //??
        String cusName = cusBase.getCusName();

        //???????
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        CtrLoanCont ctrLoanCont = new CtrLoanCont();
        ctrLoanCont = iCtrCont.getLoanContInfo(pvpLoanApp.getContNo());

        /*//???
        //?++6??
            
        //??????????
        String sequence = "" ;
        sequence = accAgent.getSequence(pvpLoanApp.getContNo(), 
        cHelper.modId2tabName(PUBConstant.ACCLOAN)) ;
        for(int i = sequence.length(); i < 3; i++){ 
         sequence = "0" + sequence; 
        }
        billNo = pvpLoanApp.getContNo()+sequence;
        */

        // ???
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String orgId = pvpLoanApp.getInputBrId();
        billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);

        String loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context);

        //String deductType = pvpLoanApp.getDeductType() ; //?
        String deductType = "";

        String term = "";//?
        String[] start = pvpLoanApp.getLoanStartDate().split("-");
        String[] end = pvpLoanApp.getLoanEndDate().split("-");
        term = ((Integer.parseInt(end[0]) - Integer.parseInt(start[0])) * 12
                + (Integer.parseInt(end[1]) - Integer.parseInt(start[1]))
                + (Integer.parseInt(end[2]) > Integer.parseInt(start[2]) ? 1 : 0)) + "";

        //
        String termDays = Integer
                .toString(TimeUtil.getBetweenDays(pvpLoanApp.getLoanStartDate(), pvpLoanApp.getLoanEndDate()));

        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpLoanApp.getCusManager());
        pvpAuthorize.setInputBrId(pvpLoanApp.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpLoanApp.getFinaBrId());
        pvpAuthorize.setCusId(pvpLoanApp.getCusId());
        pvpAuthorize.setCusName(pvpLoanApp.getCusName());
        pvpAuthorize.setContNo(pvpLoanApp.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpLoanApp.getLoanAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);

        //????
        pvpAuthorize.setTradeCode(TradeCodeConstant.DKCZ);
        pvpAuthorize.setFieldNum(34);
        pvpAuthorize.setFldvalue01("c@CZBH@" + loanNo); //??
        pvpAuthorize.setFldvalue02("c@FKZXBZ@" + "1"); //? 1  ?: 1  2 ?
        pvpAuthorize.setFldvalue03("c@FFLX@" + pvpLoanApp.getLoanForm()); //?1  2   
        pvpAuthorize.setFldvalue04("c@GSBZ@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //? 1/2?
        boolean isComLoanEntr = "IqpComLoanEntr".equals(pvpLoanApp.getAppForm());

        if (isComLoanEntr) {
            pvpAuthorize.setFldvalue05("c@DKLB@" + "02"); //01  02  
        } else {
            pvpAuthorize.setFldvalue05("c@DKLB@" + "01"); //01  02  
        }
        pvpAuthorize.setFldvalue06("c@DKPZ@" + "206020"); //??
        pvpAuthorize.setFldvalue07("c@HTBH@" + "HT2984662837498"); //???
        pvpAuthorize.setFldvalue08("c@JJBH@" + "JJ2384092333923"); //??
        pvpAuthorize.setFldvalue09("c@BZ@" + optTranse("curType" + pvpLoanApp.getCurType())); //??
        pvpAuthorize.setFldvalue10("c@HTJE@" + pvpLoanApp.getConAmount()); //???
        pvpAuthorize.setFldvalue11("c@DKKM@" + "12580100"); //
        pvpAuthorize.setFldvalue12("c@KHH@" + transCusId); //?
        pvpAuthorize.setFldvalue13("c@ZJLX@" + "5");//optTranse("certType"+certType));            //?
        pvpAuthorize.setFldvalue14("c@ZJHM@" + "610278333");//certCode);      //???
        pvpAuthorize.setFldvalue15("c@HM@" + cusName); //??
        pvpAuthorize.setFldvalue16("c@ZCZH@" + pvpLoanApp.getEnterAccount()); //??"81011101302100430"                        //
        pvpAuthorize.setFldvalue17("c@ZCZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //??
        pvpAuthorize.setFldvalue18("c@HBZH@" + pvpLoanApp.getRepaymentAccount());//??
        pvpAuthorize.setFldvalue19("c@HBZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //??
        //pvpAuthorize.setFldvalue20("c@HXZH@" + pvpLoanApp.getRepayIntAccount());//???
        pvpAuthorize.setFldvalue21("c@HXZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //???
        pvpAuthorize.setFldvalue22("c@WTCKZH@" + "81011101302100430");//??
        pvpAuthorize.setFldvalue23("c@WTCKZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //??         
        pvpAuthorize.setFldvalue24("c@ZCLL@" + getCoreTradeRate(pvpLoanApp.getRealityIrY())); // //*1.2*100
        pvpAuthorize.setFldvalue25("c@DKQX@" + term); //?
        pvpAuthorize.setFldvalue26("c@DKTS@" + termDays); //
        //pvpAuthorize.setFldvalue27("c@JXZQ@" + pvpLoanApp.getInterestType());            //?  ??
        //pvpAuthorize.setFldvalue28("c@JXFS@" + pvpLoanApp.getInterestCalType());            //??  ?
        //pvpAuthorize.setFldvalue29("c@HKFS@" + pvpLoanApp.getDeductType());            //?   //?
        pvpAuthorize.setFldvalue30("c@DKFFRQ@" + "20090814");//pvpLoanApp.getLoanStartDate().replace("-", ""));      //?
        pvpAuthorize.setFldvalue31("c@DKDQRQ@" + pvpLoanApp.getLoanEndDate().replace("-", "")); //
        pvpAuthorize.setFldvalue32("c@KHZDHKRQ@" + pvpLoanApp.getRepaymentDate()); //
        pvpAuthorize.setFldvalue33("c@DBFS@" + "03010101"); //??
        pvpAuthorize.setFldvalue34("c@KHJL@" + "100112");// pvpLoanApp.getCusManager());         //??

        //???
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);

        //??
        AccBillDetails accBillDetails = new AccBillDetails();
        accBillDetails.setSerno(pvpSerno);
        //accBillDetails.setSernoCore("") ;
        //accBillDetails.setTellerNo("") ;
        //accBillDetails.setContNo(pvpLoanApp.getContNo()) ;
        accBillDetails.setBillNo(billNo);
        //accBillDetails.setLoanAccount("") ;
        accBillDetails.setCusId(pvpLoanApp.getCusId());
        accBillDetails.setCusName(pvpLoanApp.getCusName());
        //accBillDetails.setDetailType("02") ;
        accBillDetails.setReturnType("");
        accBillDetails.setCurType(pvpLoanApp.getCurType());
        accBillDetails.setTradeAmount(pvpLoanApp.getLoanAmount());
        accBillDetails.setTradeDate(this.getOpenDay());
        accBillDetails.setTradeType("1");
        accBillDetails.setTradeBrief("");

        //?
        strReturnMessage = accAgent.insertAccBillDetails(accBillDetails);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            return strReturnMessage;
        }

        //????

        //????
        AccLoan accLoan = new AccLoan();

        BeanUtilsBean beanUtil = new BeanUtilsBean();
        beanUtil.copyProperties(accLoan, pvpLoanApp);

        /*
        accLoan.setCusId(pvpLoanApp.getCusId()) ;
        accLoan.setCusName(pvpLoanApp.getCusName()) ;
        accLoan.setContNo(pvpLoanApp.getContNo()) ;
        accLoan.setPrdPk(pvpLoanApp.getPrdPk()) ;
        accLoan.setPrdName(pvpLoanApp.getPrdName()) ;
        accLoan.setPrdType(pvpLoanApp.getPrdType()) ;
        accLoan.setAccountClass(pvpLoanApp.getAccountClass()) ;
        accLoan.setLoanForm(pvpLoanApp.getLoanForm()) ;
        accLoan.setLoanNature(pvpLoanApp.getLoanNature()) ;
        accLoan.setLoanTypeExt(pvpLoanApp.getLoanTypeExt()) ;
        accLoan.setBizType(pvpLoanApp.getBizType()) ;
        accLoan.setBizTypeSub(pvpLoanApp.getBizTypeSub()) ;
        accLoan.setBizTypeDetail(pvpLoanApp.getBizTypeDetail()) ;
        accLoan.setAssureMeansMain(pvpLoanApp.getAssureMeansMain()) ;
        accLoan.setAssureMeans2(pvpLoanApp.getAssureMeans2()) ;
        accLoan.setAssureMeans3(pvpLoanApp.getAssureMeans3()) ;
        accLoan.setLimitInd(pvpLoanApp.getLimitInd()) ;
        accLoan.setMortgageFlg(pvpLoanApp.getMortgageFlg()) ;
        accLoan.setRepaymentMode(pvpLoanApp.getRepaymentMode()) ;
        accLoan.setCurType(pvpLoanApp.getCurType()) ;
        accLoan.setLoanAmount(pvpLoanApp.getLoanAmount()) ;
        accLoan.setLoanStartDate(pvpLoanApp.getLoanStartDate()) ;
        accLoan.setLoanEndDate(pvpLoanApp.getLoanEndDate()) ;
        accLoan.setLoanDirection(pvpLoanApp.getLoanDirection()) ;
        accLoan.setRulingIr(pvpLoanApp.getRulingIr()) ;
        accLoan.setFloatingRate(pvpLoanApp.getFloatingRate()) ;
        accLoan.setRealityIrY(pvpLoanApp.getRealityIrY()) ;
        accLoan.setOverdueRate(pvpLoanApp.getOverdueRate()) ;
        accLoan.setOverdueIr(pvpLoanApp.getOverdueIr()) ;
        accLoan.setDefaultRate(pvpLoanApp.getDefaultRate()) ;
        accLoan.setDefaultIr(pvpLoanApp.getDefaultIr()) ;
        accLoan.setCiRate(pvpLoanApp.getCiRate()) ;
        accLoan.setCiIr(pvpLoanApp.getCiIr()) ;
        accLoan.setCusManager(pvpLoanApp.getCusManager()) ;
        accLoan.setInputBrId(pvpLoanApp.getInputBrId()) ;
        accLoan.setFinaBrId(pvpLoanApp.getFinaBrId()) ;
        accLoan.setMainBrId(pvpLoanApp.getMainBrId()) ;
        */

        accLoan.setBillNo(billNo);
        accLoan.setLoanAccount(pvpLoanApp.getEnterAccount());//?
        accLoan.setLoanBalance(pvpLoanApp.getLoanAmount());
        accLoan.setTermType(calTermType(pvpLoanApp.getLoanStartDate(), pvpLoanApp.getLoanEndDate()));
        accLoan.setCla(ctrLoanCont.getClaResult());
        accLoan.setAccountStatus(TradeCodeConstant.TZZT_ZC);
        accLoan.setRealityIrM(ctrLoanCont.getRealityIrM());
        accLoan.setSugRulingIr(ctrLoanCont.getSugRulingIr());
        accLoan.setDefaultFlag("2");
        accLoan.setLoanForm4("10");
        accLoan.setReceIntCumu(0.0);
        accLoan.setActualIntCumu(0.0);
        accLoan.setDelayIntCumu(0.0);
        accLoan.setInnerIntCumu(0.0);
        accLoan.setOffIntCumu(0.0);
        accLoan.setRevolvingTimes(0);
        accLoan.setFirstDisbDate(this.getOpenDay());
        accLoan.setExtensionTimes(0);
        accLoan.setOrigExpiDate("");
        accLoan.setCapOverdueDate("");
        accLoan.setIntOverdueDate("");
        accLoan.setOverTimesCurrent(0);
        accLoan.setOverTimesTotal(0);
        accLoan.setMaxTimesTotal(0);
        accLoan.setClaDate(this.getOpenDay());
        accLoan.setClaDatePre("");
        accLoan.setClaPre("");
        accLoan.setBadLoanFlag("2");
        accLoan.setSettlDate("");
        accLoan.setLatestDate(this.getOpenDay());
        accLoan.setInnerReceInt(0.0);
        accLoan.setOverdueReceInt(0.0);
        accLoan.setOffReceInt(0.0);
        accLoan.setCompoundReceInt(0.0);
        accLoan.setInnerOffReceInt(0.0);
        accLoan.setInnerActlInt(0.0);
        accLoan.setOverdueActlInt(0.0);
        accLoan.setOffActlInt(0.0);
        accLoan.setCompoundActlInt(0.0);
        accLoan.setInnerOffActlInt(0.0);

        accLoan.setNormalBalance(pvpLoanApp.getLoanAmount());

        //???
        strReturnMessage = accAgent.insertAccLoan(accLoan);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            return strReturnMessage;
        }

        //???????
        pvpLoanApp.setBillNo(billNo);
        pvpLoanApp.setChargeoffStatus(Constant.PVPSTATUS2);
        pvpLoanAppAgent.updatePvpLoanApp(pvpLoanApp);

        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            return strReturnMessage;
        }

        Connection connection = this.getConnection();
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
        /**????*/
        System.err.println("????");

        try {
            //cbqService.queryAccreditNotice4Trade(loanNo,connection,connection,context);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ComponentException(e.getMessage());
        }

        return strReturnMessage;

    }

    /**
     * 
     * ?????
     * ????????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    public String addPvpAccpAuthorize(String pvpSerno) throws EMPException {
        String strReturnMessage = CMISMessage.ADDDEFEAT;
        Context context = this.getContext();
        PvpAccpAppAgent pvpAccpAppAgent = (PvpAccpAppAgent) this.getAgentInstance(PUBConstant.PVPACCPAPP);

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);

        PvpAccpApp pvpAccpApp = new PvpAccpApp();
        IqpAccpBill iqpAccpBill = new IqpAccpBill();

        List iqpAccpBillList = null;
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        String authSerno = "";
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");

        IqpAccpAppAgent iqpAccpAgent = (IqpAccpAppAgent) this.getAgentInstance(PUBConstant.IQPACCPAPP);
        //IqpAccpApp iqpAccpApp = new IqpAccpApp();

        String loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context);

        //??????
        pvpAccpApp = pvpAccpAppAgent.queryPvpAccpApp(pvpSerno);
        if (pvpAccpApp == null || pvpAccpApp.getContNo() == null) {
            return strReturnMessage;
        }
        String contNo = pvpAccpApp.getContNo();
        //iqpAccpApp = iqpAccpAgent.queryIqpAccpApp(pvpSerno);

        //?????
        iqpAccpBillList = iqpAccpAgent.getIqpAccpBillList(contNo);
        if (iqpAccpBillList == null || iqpAccpBillList.size() == 0) {
            return strReturnMessage;
        }

        Iterator itrIqpAccpBillList = iqpAccpBillList.iterator();

        //???????
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        CtrAccpCont ctrAccpCont = new CtrAccpCont();
        while (itrIqpAccpBillList.hasNext()) {
            iqpAccpBill = (IqpAccpBill) itrIqpAccpBillList.next();

            authSerno = accAgent.makeNo(TradeCodeConstant.AUTH);
            String billNo = "";
            String orgId = pvpAccpApp.getFinaBrId();
            billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
            ctrAccpCont = iCtrCont.getAccpContInfo(pvpAccpApp.getContNo());
            if (ctrAccpCont == null || ctrAccpCont.getContNo() == null) {
                return strReturnMessage;
            }

            /*
            //????
            pvpAuthorize.setSerno(pvpAccpAppList.getSerno());
            pvpAuthorize.setTradeCode(TradeCodeConstant.YCCZ);
            pvpAuthorize.setCusManager(pvpAccpApp.getCusManager()) ;
            pvpAuthorize.setInputBrId(pvpAccpApp.getInputBrId());
            pvpAuthorize.setFinaBrId(pvpAccpApp.getFinaBrId()) ;
            pvpAuthorize.setCusId(pvpAccpApp.getCusId()) ;
            pvpAuthorize.setCusName(pvpAccpApp.getCusName()) ;
            pvpAuthorize.setContNo(pvpAccpApp.getContNo()) ;
            pvpAuthorize.setBillNo(pvpAccpAppList.getBillNo());
            pvpAuthorize.setTradeAmount(pvpAccpAppList.getBillAmount()) ;
            pvpAuthorize.setTradeDate(this.getOpenDay()) ;
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ) ;
            pvpAuthorize.setFieldNum(22) ;
                
                
            //???
            //??
            CustomIface customIface = (CustomIface)this.getComponentInterface(CusPubConstant.CUS_IFACE);
                
            CusBase cusBase = customIface.getCusBase(pvpAccpAppList.getCusId());
            //?
            String transCusId = cusBase.getTransCusId();
            //?
            String certType=cusBase.getCertType();
            //???
            String certCode=cusBase.getCertCode();
            //??
            String cusName = cusBase.getCusName();         
                
            //???
                
                  
            OrgCdhpAgent orgCdhpAgent = (OrgCdhpAgent)this.getAgentInstance(PUBConstant.ORGCDHP);
                
                
            //OrgCdhpAgent()?
            String type = optTranse("acptType"+pvpAccpAppList.getAcptType());
            String operateorgid=pvpAccpApp.getInputBrId();
            HashMap orgInfo = orgCdhpAgent.getOrgId(operateorgid, type);
            String applyinstno = (String)orgInfo.get("applyinstno");
            String checkinstno = (String)orgInfo.get("checkinstno");
            String payinstno = (String)orgInfo.get("payinstno");
                
                
            pvpAuthorize.setFldvalue01("c@CZBH@" + pvpAccpAppList.getSerno());   //??
            pvpAuthorize.setFldvalue02("c@YWLX@" + type);         //?
            pvpAuthorize.setFldvalue03("c@BZ@" + optTranse("curType"+pvpAccpAppList.getCurType()));      //??
            pvpAuthorize.setFldvalue04("c@PMJE@"+pvpAccpAppList.getBillAmount());            //??
            pvpAuthorize.setFldvalue05("c@HTBH@"+pvpAccpApp.getContNo());   //??? 20?
            pvpAuthorize.setFldvalue06("c@JJBH@"+pvpAccpAppList.getBillNo());         //?? 20?
            pvpAuthorize.setFldvalue07("c@CDXYBH@"+"");         //???60?
            pvpAuthorize.setFldvalue08("c@QFRQ@"+this.getOpenDay().replace("-", ""));   //?
            pvpAuthorize.setFldvalue09("c@DQRQ@"+pvpAccpAppList.getAccpDueDate().replace("-", ""));      //
            pvpAuthorize.setFldvalue10("c@SQRKHH@"+transCusId);   //?
            pvpAuthorize.setFldvalue11("c@SQRHM@"+pvpAccpAppList.getCusName());   //??
            pvpAuthorize.setFldvalue12("c@SQRZH@"+pvpAccpAppList.getIssueBankAcct());            //?
            pvpAuthorize.setFldvalue13("c@SKRHM@"+pvpAccpAppList.getReceiverName());   //??
            pvpAuthorize.setFldvalue14("c@SKRZH@"+pvpAccpAppList.getReceiverAccId());      //??
            pvpAuthorize.setFldvalue15("c@SKHMC@"+pvpAccpAppList.getReceiverBank());   //?? 
            pvpAuthorize.setFldvalue16("c@APPLYINSTNO@"+applyinstno);   // 
            pvpAuthorize.setFldvalue17("c@CHECKINSTNO@"+checkinstno);   //?
            pvpAuthorize.setFldvalue18("c@PAYINSTNO@"+payinstno);   //
            pvpAuthorize.setFldvalue19("c@BZJBL@"+pvpAccpAppList.getSecurityMoneyRate());   //?? 
            pvpAuthorize.setFldvalue20("c@BZJJE@"+pvpAccpAppList.getSecurityMoneyAmt());   //??? 
            pvpAuthorize.setFldvalue21("c@SXFBL@"+"");   // 
            pvpAuthorize.setFldvalue22("c@SXFJE@"+"1000");   //? 
                
            //???
            strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;
                
            if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
               return strReturnMessage ;
            }
                
            //??
            AccBillDetails accBillDetails = new AccBillDetails() ;
            accBillDetails.setSerno(authSerno) ;
            accBillDetails.setSernoCore("") ;
            accBillDetails.setTellerNo("") ;
            accBillDetails.setContNo(pvpAccpApp.getContNo()) ;
            accBillDetails.setBillNo(pvpAccpAppList.getBillNo()) ;
            accBillDetails.setLoanAccount("") ;
            accBillDetails.setCusId(pvpAccpApp.getCusId()) ;
            accBillDetails.setCusName(pvpAccpApp.getCusName()) ;
            accBillDetails.setDetailType("02") ;
            accBillDetails.setReturnType("") ;
            accBillDetails.setCurType(pvpAccpApp.getCurType()) ;
            accBillDetails.setTradeAmount(pvpAccpAppList.getBillAmount()) ;
            accBillDetails.setTradeDate(this.getOpenDay()) ;
            accBillDetails.setTradeType("1") ;
            accBillDetails.setTradeBrief("") ;
                
            //?
            strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
            if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
               return strReturnMessage ;
            }*/

            //????
            AccAccp accAccp = new AccAccp();

            accAccp.setPrdPk(pvpAccpApp.getPrdPk());
            accAccp.setPrdName(pvpAccpApp.getPrdName());
            accAccp.setBizType(pvpAccpApp.getBizType());
            accAccp.setContNo(pvpAccpApp.getContNo());
            accAccp.setBillNo(billNo);
            accAccp.setAccpNo("");
            accAccp.setCusId(pvpAccpApp.getCusId());
            accAccp.setCusName(pvpAccpApp.getCusName());
            accAccp.setCusInsCode("");//?
            accAccp.setIssueBankId(ctrAccpCont.getAcptBankId());//?
            accAccp.setIssueBankName(ctrAccpCont.getAcptBankName());//??
            accAccp.setIssueBankAcct(ctrAccpCont.getIssueBankAcct());//??
            accAccp.setLoanTypeExt(ctrAccpCont.getLoanTypeExt());
            accAccp.setNotHegotiableFlg("");//?
            accAccp.setEFlag(iqpAccpBill.getEFlag());
            accAccp.setAcptTreatMode(ctrAccpCont.getAcptTreatMode());
            accAccp.setAssureMeansMain(pvpAccpApp.getAssureMeansMain());
            accAccp.setAssureMeans2(pvpAccpApp.getAssureMeans2());
            accAccp.setAssureMeans3(pvpAccpApp.getAssureMeans3());
            accAccp.setLimitInd(pvpAccpApp.getLimitInd());
            accAccp.setCurType(pvpAccpApp.getCurType());
            accAccp.setExchangeRate(pvpAccpApp.getExchangeRate());
            accAccp.setAccpAmount(iqpAccpBill.getBillAmount());
            accAccp.setAccpIssueDate(pvpAccpApp.getSignDate());//
            accAccp.setAccpDueDate(pvpAccpApp.getPreDueDate());
            accAccp.setSecurityMoneyAmt(iqpAccpBill.getBillAmount() * pvpAccpApp.getSecurityMoneyRate());
            accAccp.setSecurityMoneyRt(pvpAccpApp.getSecurityMoneyRate());
            accAccp.setEquSecMoneyAmt(iqpAccpBill.getBillAmount() * pvpAccpApp.getEquSecMoneyRate());
            accAccp.setEquSecMoneyRate(pvpAccpApp.getEquSecMoneyRate());
            accAccp.setRiskOpenAmt(iqpAccpBill.getBillAmount() * pvpAccpApp.getRiskOpenRate());
            accAccp.setRiskOpenRate(pvpAccpApp.getRiskOpenRate());
            accAccp.setOverdueRate(pvpAccpApp.getOverdueRate());
            accAccp.setIssueType(ctrAccpCont.getAcptType());//?   
            accAccp.setAcptBankType(ctrAccpCont.getAcptBankType());
            accAccp.setAcptBankId(ctrAccpCont.getAcptBankId());
            accAccp.setAcptBankName(ctrAccpCont.getAcptBankName());
            accAccp.setReceiverName(iqpAccpBill.getReceiverName());
            accAccp.setReceiverBankId(iqpAccpBill.getReceiverBankId());
            accAccp.setReceiverBank(iqpAccpBill.getReceiverBank());
            accAccp.setReceiverAccId(iqpAccpBill.getReceiverAccId());
            accAccp.setLoanForm4("10");
            accAccp.setCla("00");
            accAccp.setClaDate("");
            accAccp.setClaDatePre("");
            accAccp.setClaPre("");
            accAccp.setAdvanceAmount(0);
            accAccp.setAdvanceMargin(0);
            accAccp.setAdvanceClearence(0);
            accAccp.setCancelDate("");
            accAccp.setCashDate("");
            accAccp.setLatestDate(this.getOpenDay());
            accAccp.setAccountStatus(TradeCodeConstant.TZZT_WQR);
            accAccp.setCusManager(pvpAccpApp.getCusManager());
            accAccp.setInputBrId(pvpAccpApp.getInputBrId());
            accAccp.setFinaBrId(pvpAccpApp.getFinaBrId());
            accAccp.setMainBrId(pvpAccpApp.getMainBrId());
            accAccp.setCnContNo(pvpAccpApp.getCnContNo()); //???

            //???
            strReturnMessage = accAgent.insertAccAccp(accAccp);
            if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
                return strReturnMessage;
            }
        }

        //????
        pvpAccpApp.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpAccpAppAgent.updatePvpAccpApp(pvpAccpApp);

        return strReturnMessage;
    }

    /**
     * ????????
     *       ????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    public String addPvpDiscAuthorize(String pvpSerno) throws EMPException {
        Context context = this.getContext();

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpDiscAppAgent pvpDiscAppAgent = (PvpDiscAppAgent) this.getAgentInstance(PUBConstant.PVPDISCAPP);

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        ComponentHelper cHelper = new ComponentHelper();
        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);

        PvpDiscApp pvpDiscApp = new PvpDiscApp();
        IqpDiscBillList iqpDiscBillList = new IqpDiscBillList();
        List iqpDiscBillListList = null;
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        String billNo = "";
        String loanNo = "";

        //??????
        pvpDiscApp = pvpDiscAppAgent.queryPvpDiscApp(pvpSerno);
        if (pvpDiscApp == null || pvpDiscApp.getContNo() == null) {
            return strReturnMessage;
        }

        String billType = pvpDiscApp.getBullType(); //??
        billType = optTranse("billType" + billType);

        //???????
        Iqp4PvpInterface iqp4PvpInterface = (Iqp4PvpInterface) this.getComponentInterface(PUBConstant.IQP4PVP);
        iqpDiscBillListList = iqp4PvpInterface.getIqpDiscBillList(pvpDiscApp.getContNo());
        if (iqpDiscBillListList == null || iqpDiscBillListList.size() == 0) {
            return strReturnMessage;
        }

        //???????
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        CtrDiscCont ctrDiscCont = new CtrDiscCont();
        ctrDiscCont = iCtrCont.getRediscContInfo(pvpDiscApp.getContNo());

        if (ctrDiscCont == null || ctrDiscCont.getContNo() == null) {
            return strReturnMessage;
        }

        Iterator itrIqpDiscBillList = iqpDiscBillListList.iterator();
        while (itrIqpDiscBillList.hasNext()) {
            iqpDiscBillList = (IqpDiscBillList) itrIqpDiscBillList.next();

            String dueDate = iqpDiscBillList.getBillDueDay(); //
            double pmje = iqpDiscBillList.getBillAmount(); //??
            int tzts = iqpDiscBillList.getAdjustDay(); //
            int txts = TimeUtil.getBetweenDays(this.getOpenDay(), dueDate); //
            double txll = pvpDiscApp.getDiscountIr(); //

            double txlx = pmje * txll * (txts + tzts) / 365;
            txlx = TransUtil.sswl(txlx, 2);

            CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
            //??
            String orgId = ctrDiscCont.getInputBrId();
            //???
            billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
            //???
            loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context);

            //????
            pvpAuthorize.setLoanNo(loanNo);
            /*         pvpAuthorize.setSerno(pvpSerno) ;
                     pvpAuthorize.setCusManager("?") ;
                     pvpAuthorize.setInputBrId("");
                     pvpAuthorize.setFinaBrId("2348273489") ;
                     pvpAuthorize.setCusId("2348273489") ;
                     pvpAuthorize.setCusName("2348273489") ;
                     pvpAuthorize.setContNo("2348273489") ;
                     pvpAuthorize.setBillNo("2348273489");
                     pvpAuthorize.setTradeAmount(234234) ;
                     pvpAuthorize.setTradeDate(this.getOpenDay()) ;
                     pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
                         
                     pvpAuthorize.setTradeCode(TradeCodeConstant.DBPCK);
                     pvpAuthorize.setFieldNum(7) ;
                     pvpAuthorize.setFldvalue01("c@CZBH@" + "1011141105");            //??
                     pvpAuthorize.setFldvalue02("c@KHH@" + "2020082048");               //?
                     pvpAuthorize.setFldvalue03("c@CKJG@" + "811501");               //
                     pvpAuthorize.setFldvalue04("c@DZYWBH@"+"1011411149");            //?
                     pvpAuthorize.setFldvalue05("c@DBFS@"+"10");            //??
                     pvpAuthorize.setFldvalue06("c@BZ@"+"01");            //??
                     pvpAuthorize.setFldvalue07("c@JE@"+"33333");         //?
            */
            //????
            pvpAuthorize.setLoanNo(loanNo);
            pvpAuthorize.setSerno("1011411150");
            pvpAuthorize.setCusManager("?");
            pvpAuthorize.setInputBrId("");
            pvpAuthorize.setFinaBrId("2348273489");
            pvpAuthorize.setCusId("2000225021");
            pvpAuthorize.setCusName("????");
            pvpAuthorize.setContNo("2348273489");
            pvpAuthorize.setBillNo("2348273489");
            pvpAuthorize.setTradeAmount(234234);
            pvpAuthorize.setTradeDate(this.getOpenDay());
            pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);

            pvpAuthorize.setTradeCode(TradeCodeConstant.DBPRK);
            pvpAuthorize.setFieldNum(11);
            pvpAuthorize.setFldvalue01("c@CZBH@" + loanNo); //??
            pvpAuthorize.setFldvalue02("c@KHH@" + "2020082048"); //?
            pvpAuthorize.setFldvalue03("c@RKJG@" + "811501"); //
            pvpAuthorize.setFldvalue04("c@DZYWBH@" + "1011411150"); //?
            pvpAuthorize.setFldvalue05("c@DZYWLX@" + "10005B"); //
            pvpAuthorize.setFldvalue06("c@DZYWMC@" + "3"); //??
            pvpAuthorize.setFldvalue07("c@DBFS@" + "10"); //??
            pvpAuthorize.setFldvalue08("c@PZZL@" + "01"); //??
            pvpAuthorize.setFldvalue09("c@PZH@" + "1011411129"); //??
            pvpAuthorize.setFldvalue10("c@BZ@" + "01"); //??
            pvpAuthorize.setFldvalue11("c@JE@" + "33333"); //?

            /*
            //?????
            pvpAuthorize.setSerno("1011111124") ;
            pvpAuthorize.setCusManager("?") ;
            pvpAuthorize.setInputBrId("");
            pvpAuthorize.setFinaBrId("2348273489") ;
            pvpAuthorize.setCusId("2348273489") ;
            pvpAuthorize.setCusName("2348273489") ;
            pvpAuthorize.setContNo("2348273489") ;
            pvpAuthorize.setBillNo("2348273489");
            pvpAuthorize.setTradeAmount(234234) ;
            pvpAuthorize.setTradeDate(this.getOpenDay()) ;
            pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
                
            pvpAuthorize.setTradeCode(TradeCodeConstant.TYCX);
            pvpAuthorize.setFieldNum(4) ;
            pvpAuthorize.setFldvalue01("c@CZBH@" + "1011111124");            //??
            pvpAuthorize.setFldvalue02("c@YJYLSH@" + "026290");               //??
            pvpAuthorize.setFldvalue03("c@CXYWLX@" + "04");                  //
            pvpAuthorize.setFldvalue04("c@DCXCZBH@"+"8472227424");            //??
            */

            //????
            /*
             pvpAuthorize.setLoanNo(loanNo) ;
             pvpAuthorize.setSerno(pvpDiscApp.getSerno()) ;
            pvpAuthorize.setCusManager("") ;
            pvpAuthorize.setInputBrId(pvpDiscApp.getInputBrId());
            pvpAuthorize.setFinaBrId(pvpDiscApp.getFinaBrId()) ;
            pvpAuthorize.setCusId(pvpDiscApp.getCusId()) ;
            pvpAuthorize.setCusName(pvpDiscApp.getCusName()) ;
            pvpAuthorize.setContNo(pvpDiscApp.getContNo()) ;
            pvpAuthorize.setBillNo(billNo);
            pvpAuthorize.setTradeAmount(pvpDiscApp.getParAmount()) ;
            pvpAuthorize.setTradeDate(this.getOpenDay()) ;
            pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
                
            pvpAuthorize.setTradeCode(TradeCodeConstant.TXCZ);
            pvpAuthorize.setFieldNum(24) ;
            pvpAuthorize.setFldvalue01("c@CZBH@" + loanNo);            //??
            String bullTypeStr = pvpDiscApp.getBullType();
            if(bullTypeStr.equals("1"))
               bullTypeStr = optTranse("billType2");
            else
               bullTypeStr = optTranse("billType1");
            pvpAuthorize.setFldvalue02("c@YWLX@" + "");                  //
            pvpAuthorize.setFldvalue03("c@PJLX@"+bullTypeStr);                     //?
            pvpAuthorize.setFldvalue04("c@BZ@"+  "CNY");                  //??
            pvpAuthorize.setFldvalue05("c@HTBH@"+  pvpDiscApp.getContNo());                  //???
            pvpAuthorize.setFldvalue06("c@JJBH@"+  billNo);                  //??
            pvpAuthorize.setFldvalue07("c@PJHM@"+  iqpDiscBillList.getBillNo());                  //???
            pvpAuthorize.setFldvalue08("c@QFRQ@" + iqpDiscBillList.getBillIssuingDate());               //?
            pvpAuthorize.setFldvalue09("c@DQRQ@"+  iqpDiscBillList.getBillDueDay());               //
            pvpAuthorize.setFldvalue10("c@TXRQ@"+  ctrDiscCont.getApplyDiscountDay());               //
            pvpAuthorize.setFldvalue11("c@YQHGRQ@"+  "20091201");            //
            pvpAuthorize.setFldvalue12("c@SQRKHH@"+  pvpDiscApp.getInputBrId());            //?
            pvpAuthorize.setFldvalue13("c@SQRHM@"+ "") ;      //??
            pvpAuthorize.setFldvalue14("c@SQRZH@"+ ctrDiscCont.getCusAcct()) ;       //?
            pvpAuthorize.setFldvalue15("c@SQRKHHM@"+ iqpDiscBillList.getDrawerBank()) ;       //?
            pvpAuthorize.setFldvalue16("c@CDRHM@"+ "?????") ;      //??
            pvpAuthorize.setFldvalue17("c@CDRZH@"+ iqpDiscBillList.getAcptBankAcct());      //??
            pvpAuthorize.setFldvalue18("c@CDHMC@"+ "??") ;         //??
            pvpAuthorize.setFldvalue19("c@PMJE@"+  iqpDiscBillList.getBillAmount()) ;                     //??
            pvpAuthorize.setFldvalue20("c@TXTS@"+  iqpDiscBillList.getPreDueDate()) ;         //
            pvpAuthorize.setFldvalue21("c@JXTS@"+  iqpDiscBillList.getAdjustDay()) ;   //?
            pvpAuthorize.setFldvalue22("c@TXLL@"+  iqpDiscBillList.getCostRate()) ;            //
            pvpAuthorize.setFldvalue23("c@TXLX@"+  iqpDiscBillList.getImpDiscountInt());                  //?
            pvpAuthorize.setFldvalue24("c@SFJE@"+  iqpDiscBillList.getPerDiscountAmt());                  //?
                
            */

            /*      
                  //???
                  pvpAuthorize.setSerno("2009082000005") ;
                  pvpAuthorize.setTradeCode(TradeCodeConstant.YCCZ) ;
                  pvpAuthorize.setCusManager("hahaha");
                  pvpAuthorize.setInputBrId("hahaha");
                  pvpAuthorize.setFinaBrId("hahaha") ;
                  pvpAuthorize.setCusId("hahaha") ;
                  pvpAuthorize.setCusName("hahaha") ;
                  pvpAuthorize.setContNo("hahaha") ;
                  pvpAuthorize.setBillNo("hahaha");
                  pvpAuthorize.setTradeAmount(234) ;
                  pvpAuthorize.setTradeDate(this.getOpenDay()) ;
                  pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
                  pvpAuthorize.setFieldNum(22) ;         
                  pvpAuthorize.setFldvalue01("c@CZBH@" + "2009082000005");   //??
                  pvpAuthorize.setFldvalue02("c@YWLX@" + "1");         //?
                  pvpAuthorize.setFldvalue03("c@BZ@" + "01");      //??
                  pvpAuthorize.setFldvalue04("c@PMJE@"+"1000");            //??
                  pvpAuthorize.setFldvalue05("c@HTBH@"+"BW2009082000005");   //??? 20?
                  pvpAuthorize.setFldvalue06("c@JJBH@"+"8134012009000005");         //?? 20?
                  pvpAuthorize.setFldvalue07("c@CDXYBH@"+"8134012009000005");         //???60?
                  pvpAuthorize.setFldvalue08("c@QFRQ@"+"20090914");//this.getOpenDay().replace("-", ""));   //?
                  pvpAuthorize.setFldvalue09("c@DQRQ@"+"20100101");//pvpAccpAppList.getAccpDueDate().replace("-", ""));      //
                  pvpAuthorize.setFldvalue10("c@SQRKHH@"+"2000225021");   //?
                  pvpAuthorize.setFldvalue11("c@SQRHM@"+"??");   //??
                  pvpAuthorize.setFldvalue12("c@SQRZH@"+"81150101302183177");            //?
                  pvpAuthorize.setFldvalue13("c@SKRHM@"+"?");   //??
                  pvpAuthorize.setFldvalue14("c@SKRZH@"+"81150101302166521");      //??
                  pvpAuthorize.setFldvalue15("c@SKHMC@"+"xxx");   //?? 
                  pvpAuthorize.setFldvalue16("c@APPLYINSTNO@"+"811501");   // 
                  pvpAuthorize.setFldvalue17("c@CHECKINSTNO@"+"811501");   //?
                  pvpAuthorize.setFldvalue18("c@PAYINSTNO@"+"811501");   //
                  pvpAuthorize.setFldvalue19("c@BZJBL@"+"0.03");   //?? 
                  pvpAuthorize.setFldvalue20("c@BZJJE@"+"1000");   //??? 
                  pvpAuthorize.setFldvalue21("c@SXFBL@"+"0.03");   // 
                  pvpAuthorize.setFldvalue22("c@SXFJE@"+"1000");   //? 
                   
            */
            //???
            strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);

            /**????*/
            //?
            System.err.println("????");
            Connection connection = this.getConnection();
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();

            try {
                //cbqService.queryAccreditNotice4Trade(loanNo,connection,connection,context);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                throw new ComponentException(e.getMessage());
            }

            strReturnMessage = CMISMessage.ADDSUCCEESS;
            if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
                return strReturnMessage;
            }

            //??
            /*
             * ?
            AccBillDetails accBillDetails = new AccBillDetails() ;
            String authSerno = accAgent.makeNo(TradeCodeConstant.AUTH) ;
            accBillDetails.setSerno(authSerno) ;
            accBillDetails.setSernoCore("") ;
            accBillDetails.setTellerNo("") ;
            accBillDetails.setContNo(pvpDiscApp.getContNo()) ;
            accBillDetails.setBillNo(billNo) ;
            accBillDetails.setLoanAccount("") ;
            accBillDetails.setCusId(pvpDiscApp.getCusId()) ;
            accBillDetails.setCusName(pvpDiscApp.getCusName()) ;
            accBillDetails.setDetailType("02") ;
            accBillDetails.setReturnType("") ;
            accBillDetails.setCurType(pvpDiscApp.getBillCurrency()) ;
            accBillDetails.setTradeAmount(iqpDiscBillList.getBillAmount()) ;
            accBillDetails.setTradeDate(this.getOpenDay()) ;
            accBillDetails.setTradeType("1") ;
            accBillDetails.setTradeBrief("") ;
                
            //?
            strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
            if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
               return strReturnMessage ;
            }
             */
            //????
            AccDisc accDisc = new AccDisc();

            accDisc.setBillNo(billNo);
            accDisc.setDraftNo(iqpDiscBillList.getBillNo());
            accDisc.setDiscountAcct("");
            accDisc.setContNo(pvpDiscApp.getContNo());
            accDisc.setPrdPk(pvpDiscApp.getPrdPk());
            accDisc.setPrdName(pvpDiscApp.getPrdName());
            accDisc.setBizType(pvpDiscApp.getBizType());
            accDisc.setLoanTypeExt(ctrDiscCont.getLoanTypeExt());
            accDisc.setBillType(pvpDiscApp.getBullType());
            accDisc.setCusId(pvpDiscApp.getCusId());
            accDisc.setCusName(pvpDiscApp.getCusName());
            accDisc.setCusAcct(pvpDiscApp.getCusAcct());
            accDisc.setCusAcctName(pvpDiscApp.getCusAcctName());
            accDisc.setBillCurrency(pvpDiscApp.getBillCurrency());
            accDisc.setBillAmount(pmje);
            accDisc.setBillIssuingDate(iqpDiscBillList.getBillIssuingDate());
            accDisc.setBillDueDay(dueDate);
            accDisc.setNotHegotiableFlg(iqpDiscBillList.getNotHegotiableFlg());
            accDisc.setIssueName(iqpDiscBillList.getDrawerName());
            accDisc.setIssueInsCode(iqpDiscBillList.getDrawerInsCode());
            accDisc.setIssueBankId(iqpDiscBillList.getDrawerBankId());
            accDisc.setIssueBankName(iqpDiscBillList.getDrawerBank());
            accDisc.setIssueBankAcct(iqpDiscBillList.getDrawerAccId());
            accDisc.setReceiverName(iqpDiscBillList.getReceiverName());
            accDisc.setReceiverBankId(iqpDiscBillList.getReceiverBankId());
            accDisc.setReceiverBank(iqpDiscBillList.getReceiverBank());
            accDisc.setReceiverAccId(iqpDiscBillList.getReceiverAccId());
            accDisc.setAcptType(iqpDiscBillList.getAcptType());
            accDisc.setAcptBankId(iqpDiscBillList.getAcptBankId());
            accDisc.setAcptBankName(iqpDiscBillList.getAcptBankName());
            accDisc.setAcptOrgNo(iqpDiscBillList.getAcptOrgNo());
            accDisc.setAcptBankAcct(iqpDiscBillList.getAcptBankAcct());
            accDisc.setBillIssue(iqpDiscBillList.getBillIssue());
            accDisc.setAdjustDay(tzts);
            accDisc.setDiscDate(this.getOpenDay());
            accDisc.setDiscDay(txts);
            accDisc.setDiscRate(txll);
            accDisc.setDiscInterest(txlx);
            accDisc.setCashAmount(pmje - txlx);
            accDisc.setRepuDate("");
            accDisc.setCollectDate("");
            accDisc.setLimitInd(pvpDiscApp.getLimitInd());
            accDisc.setCla("00");
            accDisc.setClaDate("");
            accDisc.setClaPre("");
            accDisc.setClaDatePre("");
            accDisc.setCancelDate("");
            accDisc.setCusManager(pvpDiscApp.getCusManager());
            accDisc.setInputBrId(pvpDiscApp.getInputBrId());
            accDisc.setFinaBrId(pvpDiscApp.getFinaBrId());
            accDisc.setMainBrId(pvpDiscApp.getMainBrId());
            accDisc.setLatestDate(this.getOpenDay());
            accDisc.setAccountStatus(TradeCodeConstant.TXTZZT00);

            //???
            strReturnMessage = accAgent.insertAccDisc(accDisc);
            if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
                return strReturnMessage;
            }

        }

        //????
        pvpDiscApp.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpDiscAppAgent.updatePvpDiscApp(pvpDiscApp);
        strReturnMessage = CMISMessage.ADDSUCCEESS;
        return strReturnMessage;

    }

    /**
     * ?????????
     *       ?????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    public String addPvpCvrgAuthorize(String pvpSerno) throws EMPException {
        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpCvrgAppAgent pvpCvrgAppAgent = (PvpCvrgAppAgent) this.getAgentInstance(PUBConstant.PVPCVRGAPP);

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        ComponentHelper cHelper = new ComponentHelper();
        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);

        PvpCvrgApp pvpCvrgApp = new PvpCvrgApp();
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        String billNo = "";
        String authSerno = accAgent.makeNo(TradeCodeConstant.AUTH);

        Context context = this.getContext();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = "loanNo";
        try {
            loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context);
        } catch (EMPException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //??????
        pvpCvrgApp = pvpCvrgAppAgent.queryPvpCvrgApp(pvpSerno);
        if (pvpCvrgApp == null || pvpCvrgApp.getContNo() == null) {
            return strReturnMessage;
        }

        //???????
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        CtrCvrgCont ctrCvrgCont = new CtrCvrgCont();
        ctrCvrgCont = iCtrCont.getCvrgContInfo(pvpCvrgApp.getContNo());
        if (ctrCvrgCont == null || ctrCvrgCont.getContNo() == null) {
            return strReturnMessage;
        }

        /*//??????????
        String sequence = "" ;
        sequence = accAgent.getSequence(pvpCvrgApp.getContNo(), 
        cHelper.modId2tabName(PUBConstant.ACCCVRG)) ;
        for(int i = sequence.length(); i < 3; i++){ 
           sequence = "0" + sequence; 
        }
        billNo = pvpCvrgApp.getContNo()+sequence;*/
        String orgId = pvpCvrgApp.getFinaBrId();
        billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);

        String guaranteeType = pvpCvrgApp.getGuaranteeType();
        guaranteeType = optTranse("guaranteeType" + guaranteeType.substring(0, 1));

        //????      //----------------------------
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setSerno(pvpCvrgApp.getSerno());
        pvpAuthorize.setTradeCode(TradeCodeConstant.BHCZ);
        pvpAuthorize.setCusManager(pvpCvrgApp.getCusManager());
        pvpAuthorize.setInputBrId(pvpCvrgApp.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpCvrgApp.getFinaBrId());
        pvpAuthorize.setCusId(pvpCvrgApp.getCusId());
        pvpAuthorize.setCusName(pvpCvrgApp.getCusName());
        pvpAuthorize.setContNo(pvpCvrgApp.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpCvrgApp.getGuaranteeAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setFieldNum(19);

        pvpAuthorize.setFldvalue01("c@T_ORGNO@" + pvpCvrgApp.getInputBrId()); //?
        pvpAuthorize.setFldvalue02("c@T_TELLNO@" + pvpCvrgApp.getCusManager()); //?
        pvpAuthorize.setFldvalue03("c@T_LICENSE_NO@" + authSerno); //??
        pvpAuthorize.setFldvalue04("c@T_LICENSE_TYPE@" + "14"); //?
        pvpAuthorize.setFldvalue05("c@T_LICENSE_KIND@" + ""); //??
        pvpAuthorize.setFldvalue06("c@T_CTR_NO@" + pvpCvrgApp.getContNo()); //???
        pvpAuthorize.setFldvalue07("c@T_ACCOUNT@" + pvpCvrgApp.getCusAccount()); //?
        pvpAuthorize.setFldvalue08("c@T_ACCOUNT_NAME@" + pvpCvrgApp.getCusName()); //??
        pvpAuthorize.setFldvalue09("c@T_TYPE1@" + guaranteeType); //??
        pvpAuthorize.setFldvalue10("c@T_CURRENCY@" + "01"); //??(?)
        pvpAuthorize.setFldvalue11("c@T_AMOUNT4@" + pvpCvrgApp.getGuaranteeAmount()); //?
        pvpAuthorize.setFldvalue12("c@T_STARTDATE@" + pvpCvrgApp.getStartDate()); //
        pvpAuthorize.setFldvalue13("c@T_DATE_END@" + pvpCvrgApp.getDueDate()); //
        pvpAuthorize.setFldvalue14("c@T_ACCOUNT_1@" + pvpCvrgApp.getSecurityMoneyAcc()); //???
        pvpAuthorize.setFldvalue15("c@T_AMOUNT@" + pvpCvrgApp.getSecurityMoneyAmt()); //???
        pvpAuthorize.setFldvalue16("c@T_AMOUNT1@" + pvpCvrgApp.getRiskOpenAmt()); //??
        pvpAuthorize.setFldvalue17("c@T_NEW_RATE@" + pvpCvrgApp.getDayRate()); //?
        pvpAuthorize.setFldvalue18("c@T_AMOUNT2@" + pvpCvrgApp.getLgFeeAmount()); //??
        pvpAuthorize.setFldvalue19("c@T_AMOUNT3@" + pvpCvrgApp.getProcFeeAmount()); //?

        pvpAuthorize.setFldvalue01("c@CZBH@" + "CX2342347289374"); //??
        pvpAuthorize.setFldvalue02("c@BZ@" + "01"); //??
        pvpAuthorize.setFldvalue03("c@SXFKSFS@" + "1"); //?
        pvpAuthorize.setFldvalue04("c@HTBH@" + "HT238749823748"); //???
        pvpAuthorize.setFldvalue05("c@CDXYBH@" + "??238749823748"); //???
        pvpAuthorize.setFldvalue06("c@QFJG@" + "810110"); //?
        pvpAuthorize.setFldvalue07("c@SQRKHH@" + "2000225021"); //?
        pvpAuthorize.setFldvalue08("c@SQRHM@" + "????"); //??
        pvpAuthorize.setFldvalue09("c@BHJE@" + "100000"); //??
        pvpAuthorize.setFldvalue10("c@HQZH@" + "81011101302100430"); //
        pvpAuthorize.setFldvalue11("c@BZJBL@" + "100"); //??
        pvpAuthorize.setFldvalue12("c@BZJJE@" + "200"); //???
        pvpAuthorize.setFldvalue13("c@SXFBL@" + "2"); //
        pvpAuthorize.setFldvalue14("c@SXFJE@" + "300"); //?
        pvpAuthorize.setFldvalue15("c@QFRQ@" + "20091001"); //?
        pvpAuthorize.setFldvalue16("c@DQRQ@" + "20091030"); //

        //???
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize); //-----------------------

        /**????*//*
                                        //?
                                        System.err.println("????");
                                        Context context = this.getContext();
                                        Connection connection = this.getConnection();
                                        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
                                            
                                        try {
                                        cbqService.queryAccreditNotice4Trade(TradeCodeConstant.BHCZ,connection,connection,context);
                                        } catch (Exception e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                        throw new ComponentException(e.getMessage());
                                        }
                                        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
                                        return strReturnMessage ;
                                        }
                                            
                                            
                                        */

        /*
        //??
        AccBillDetails accBillDetails = new AccBillDetails() ;
        accBillDetails.setSerno(authSerno) ;
        accBillDetails.setSernoCore("") ;
        accBillDetails.setTellerNo("") ;
        accBillDetails.setContNo(pvpCvrgApp.getContNo()) ;
        accBillDetails.setBillNo(billNo) ;
        accBillDetails.setLoanAccount("") ;
        accBillDetails.setCusId(pvpCvrgApp.getCusId()) ;
        accBillDetails.setCusName(pvpCvrgApp.getCusName()) ;
        accBillDetails.setDetailType("02") ;
        accBillDetails.setReturnType("") ;
        accBillDetails.setCurType(pvpCvrgApp.getCurType()) ;
        accBillDetails.setTradeAmount(pvpCvrgApp.getGuaranteeAmount()) ;
        accBillDetails.setTradeDate(this.getOpenDay()) ;
        accBillDetails.setTradeType("1") ;
        accBillDetails.setTradeBrief("") ;
            
        //?
        strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
           return strReturnMessage ;
        }
        */
        //????
        AccCvrg accCvrg = new AccCvrg();

        accCvrg.setContNo(pvpCvrgApp.getContNo());
        //accCvrg.setCnContNo(pvpCvrgApp.getCnContNo());
        accCvrg.setBillNo(billNo);
        accCvrg.setPrdPk(pvpCvrgApp.getPrdPk());
        accCvrg.setPrdName(pvpCvrgApp.getPrdName());
        accCvrg.setBizType(pvpCvrgApp.getBizType());
        accCvrg.setLoanTypeExt(ctrCvrgCont.getLoanTypeExt());
        accCvrg.setCusId(pvpCvrgApp.getCusId());
        accCvrg.setCusName(pvpCvrgApp.getCusName());
        accCvrg.setCurType(pvpCvrgApp.getCurType());
        accCvrg.setGuaranteeAmount(pvpCvrgApp.getGuaranteeAmount());
        accCvrg.setGuaranteeBalance(pvpCvrgApp.getGuaranteeAmount());
        accCvrg.setStartDate(pvpCvrgApp.getStartDate());
        accCvrg.setDueDate(pvpCvrgApp.getDueDate());
        accCvrg.setSecurityMoneyRt(pvpCvrgApp.getSecurityMoneyRate());
        accCvrg.setSecurityMoneyAmt(pvpCvrgApp.getSecurityMoneyAmt());
        accCvrg.setEquSecMoneyRate(pvpCvrgApp.getEquSecMoneyRate());
        accCvrg.setEquSecMoneyAmt(pvpCvrgApp.getEquSecMoneyAmt());
        accCvrg.setRiskOpenAmt(pvpCvrgApp.getRiskOpenAmt());
        accCvrg.setRiskOpenRate(pvpCvrgApp.getRiskOpenRate());
        accCvrg.setProcFeePetMode(pvpCvrgApp.getProcFeePetMode());
        accCvrg.setProcFeeAmount(pvpCvrgApp.getProcFeeAmount());
        accCvrg.setProcFeePercent(pvpCvrgApp.getProcFeePercent());
        accCvrg.setLgFeeAmount(pvpCvrgApp.getLgFeeAmount());
        accCvrg.setExchangeRate(pvpCvrgApp.getExchangeRate());
        accCvrg.setDayRate(pvpCvrgApp.getDayRate());
        accCvrg.setGuaranteeType(pvpCvrgApp.getGuaranteeType());
        accCvrg.setGuaranteeType2(pvpCvrgApp.getGuaranteeType2());
        accCvrg.setAssureMeansMain(pvpCvrgApp.getAssureMeansMain());
        accCvrg.setAssureMeans2(pvpCvrgApp.getAssureMeans2());
        accCvrg.setAssureMeans3(pvpCvrgApp.getAssureMeans3());
        accCvrg.setGuaranteePayWay(ctrCvrgCont.getGuaranteePayWay());
        accCvrg.setLimitInd(pvpCvrgApp.getLimitInd());
        accCvrg.setRepaymentAccount(pvpCvrgApp.getCusAccount());
        accCvrg.setRepaymentAccName(pvpCvrgApp.getCusAccountName());
        accCvrg.setLoanForm4("10");
        accCvrg.setAdvanceMargin(0);
        accCvrg.setAdvanceClearence(0);
        accCvrg.setAdvanceAmount(0);
        accCvrg.setCla("10");
        accCvrg.setClaDate("");
        accCvrg.setClaDatePre("");
        accCvrg.setClaPre("");
        accCvrg.setAccountStatus(TradeCodeConstant.TZZT_WQR);
        accCvrg.setCancelDate("");
        accCvrg.setCusManager(pvpCvrgApp.getCusManager());
        accCvrg.setInputBrId(pvpCvrgApp.getInputBrId());
        accCvrg.setFinaBrId(pvpCvrgApp.getFinaBrId());
        accCvrg.setMainBrId(pvpCvrgApp.getMainBrId());

        //???
        strReturnMessage = accAgent.insertAccCvrg(accCvrg);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            return strReturnMessage;
        }

        //????
        pvpCvrgApp.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpCvrgAppAgent.updatePvpCvrgApp(pvpCvrgApp);

        return strReturnMessage;
    }

    /**
     * ????????
     * ???????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    public String addPvpExtendAuthorize(String pvpSerno) throws EMPException {
        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpLoanExtendAgent pvpLoanExtendAgent = (PvpLoanExtendAgent) this
                .getAgentInstance(PUBConstant.PVPLOANEXTEND);

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        ComponentHelper cHelper = new ComponentHelper();
        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);

        PvpLoanExtend pvpLoanExtend = new PvpLoanExtend();
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        AccLoan accLoan = new AccLoan();

        //??????
        pvpLoanExtend = pvpLoanExtendAgent.queryPvpLoanExtend(pvpSerno);
        if (pvpLoanExtend == null || pvpLoanExtend.getContNo() == null) {
            return strReturnMessage;
        }
        accLoan = accAgent.queryAccLoanByBillNo(pvpLoanExtend.getOBillNo());

        /*String authSerno = accAgent.makeNo(TradeCodeConstant.AUTH) ;
        Context context = this.getContext();
        CMISSequenceService sequenceService = (CMISSequenceService) context
             .getService("sequenceService");
        String loanNo="loanNo";
        try {
           loanNo = sequenceService.getSequence("CZ", "fromDate", 14,context);
        } catch (EMPException e1) {
           // TODO Auto-generated catch block
           e1.printStackTrace();
        }
            
            
        //???????
          ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
          CtrLoanExtend ctrLoanExtend = new CtrLoanExtend() ;
          ctrLoanExtend = iCtrCont.getCtrLoanExtendInfo(pvpLoanExtend.getContNo()) ;
        if(ctrLoanExtend==null || ctrLoanExtend.getContNo()==null){
           return strReturnMessage ;
        }
            
        //????
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setSerno(pvpSerno) ;
        pvpAuthorize.setCusManager(pvpLoanExtend.getCusManager()) ;
        pvpAuthorize.setInputBrId(pvpLoanExtend.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpLoanExtend.getFinaBrId()) ;
        pvpAuthorize.setCusId(pvpLoanExtend.getCusId()) ;
        pvpAuthorize.setCusName(pvpLoanExtend.getCusName()) ;
        pvpAuthorize.setContNo(pvpLoanExtend.getContNo()) ;
        pvpAuthorize.setBillNo(accLoan.getBillNo());
        pvpAuthorize.setTradeAmount(pvpLoanExtend.getExtendAmt()) ;
        pvpAuthorize.setTradeDate(this.getOpenDay()) ;
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
            
           pvpAuthorize.setTradeCode(TradeCodeConstant.DKZQ) ;
           pvpAuthorize.setFieldNum(6) ;
               
           pvpAuthorize.setFldvalue01("c@CZBH@" + "CZ23947289347");         //??
           pvpAuthorize.setFldvalue02("c@GSBZ@" + "1");         //?
           pvpAuthorize.setFldvalue03("c@JJBH@" + "XXXXX");               //??
           pvpAuthorize.setFldvalue04("c@ZQKSRQ@"+"20091001");   //
           pvpAuthorize.setFldvalue05("c@ZQJZRQ@" + "20091031");//?
           pvpAuthorize.setFldvalue06("c@ZQLL@"+"3");          //
            
        //???
        //strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;
            
            
            
            
            
            
            
        //if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        //   return strReturnMessage ;
        //}
            
        //??
        AccBillDetails accBillDetails = new AccBillDetails() ;
        accBillDetails.setSerno(authSerno) ;
        accBillDetails.setSernoCore("") ;
        accBillDetails.setTellerNo("") ;
        accBillDetails.setContNo(pvpLoanExtend.getContNo()) ;
        accBillDetails.setBillNo(accLoan.getBillNo()) ;
        accBillDetails.setLoanAccount("") ;
        accBillDetails.setCusId(pvpLoanExtend.getCusId()) ;
        accBillDetails.setCusName(pvpLoanExtend.getCusName()) ;
        accBillDetails.setDetailType("04") ;
        accBillDetails.setReturnType("") ;
        accBillDetails.setCurType(accLoan.getCurType()) ;
        accBillDetails.setTradeAmount(pvpLoanExtend.getExtendAmt()) ;
        accBillDetails.setTradeDate(this.getOpenDay()) ;
        accBillDetails.setTradeType("1") ;
        accBillDetails.setTradeBrief("") ;
            
        //?
        strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
           return strReturnMessage ;
        }*/

        //????
        pvpLoanExtend.setChargeoffStatus(Constant.PVPSTATUS2);
        pvpLoanExtendAgent.updatePvpLoanExtend(pvpLoanExtend);

        //??
        accLoan.setLoanEndDate(pvpLoanExtend.getExtendEndDate());
        strReturnMessage = accAgent.updateAccLoan(accLoan);

        /**????*/
        //?
        System.err.println("????");
        Connection connection = this.getConnection();
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();

        try {
            //cbqService.queryAccreditNotice4Trade(TradeCodeConstant.DKZQ,connection,connection,context);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ComponentException(e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ?????????
     * ???????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    public String addPvpEnsureAuthorize(String pvpSerno) throws EMPException {
        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        ComponentHelper cHelper = new ComponentHelper();

        PvpAuthorize pvpAuthorize = new PvpAuthorize();

        //????
        pvpAuthorize.setSerno("2348273489");
        pvpAuthorize.setCusManager("??");
        pvpAuthorize.setInputBrId("BAOLI");
        pvpAuthorize.setFinaBrId("2348273489");
        pvpAuthorize.setCusId("2348273489");
        pvpAuthorize.setCusName("2348273489");
        pvpAuthorize.setContNo("2348273489");
        pvpAuthorize.setBillNo("2348273489");
        pvpAuthorize.setTradeAmount(234234);
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);

        pvpAuthorize.setTradeCode(TradeCodeConstant.BLCZ);
        pvpAuthorize.setFieldNum(17);

        pvpAuthorize.setFldvalue01("c@CZBH@" + "CZ23947289333");//??
        pvpAuthorize.setFldvalue02("c@BZ@" + "01"); //??
        pvpAuthorize.setFldvalue03("c@HTBH@" + "CZ23748923748");//???
        pvpAuthorize.setFldvalue04("c@BLXYBH@" + "????20091001"); //?????
        pvpAuthorize.setFldvalue05("c@QFJG@" + "810111");//?
        pvpAuthorize.setFldvalue06("c@KHH@" + "2000225021"); //?
        pvpAuthorize.setFldvalue07("c@HM@" + "????"); //?
        pvpAuthorize.setFldvalue08("c@BHJE@" + "2999"); //?
        pvpAuthorize.setFldvalue09("c@HKZH@" + "81011101302100430"); //?
        pvpAuthorize.setFldvalue10("c@SXFBL@" + "2"); //?
        pvpAuthorize.setFldvalue11("c@SXFJE@" + "32"); //?
        pvpAuthorize.setFldvalue12("c@JXZQ@" + "1"); //?
        pvpAuthorize.setFldvalue13("c@JXFS@" + "1"); //?
        pvpAuthorize.setFldvalue14("c@HKRQ@" + "21"); //?
        pvpAuthorize.setFldvalue15("c@FFRQ@" + "20100101"); //?
        pvpAuthorize.setFldvalue16("c@DQRQ@" + "20101001"); //?
        pvpAuthorize.setFldvalue17("c@ZZZH@" + "81011101302100430"); //?
        //???
        //strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;

        /**????*/
        //?
        System.err.println("????");
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();

        try {
            //cbqService.queryAccreditNotice4Trade(TradeCodeConstant.DKZQ,connection,connection,context);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new ComponentException(e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ?
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    //public String cancelAuthorize(String serno)throws ComponentException{
    public String cancelAuthorize(String serno, String tablename) throws ComponentException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        Context context = this.getContext();
        Connection connection = this.getConnection();

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        ArrayList pvpAutOldList = new ArrayList();
        try {
            pvpAutOldList = (ArrayList) pvpAuthorizeAgent
                    .queryPvpAuthorizeByCondition("where serno = '" + serno + "'");
        } catch (CMISException e2) {
            e2.printStackTrace();
            throw new ComponentException("??" + e2.getMessage());
        }

        Iterator pvpiter = pvpAutOldList.iterator();

        while (pvpiter.hasNext()) {
            PvpAuthorize pvpAuthorize = (PvpAuthorize) pvpiter.next();
            //???
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            try {
                pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);
            } catch (EMPException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
                throw new ComponentException(
                        "???" + e2.getMessage());
            }

            PvpAuthorize cancelAuthorize = new PvpAuthorize();
            CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
            String loanNo = "loanNo";
            try {
                loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context);
            } catch (EMPException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            //????
            cancelAuthorize.setSerno(pvpAuthorize.getSerno());
            cancelAuthorize.setLoanNo(loanNo);
            cancelAuthorize.setCusManager(this.getUsrId());
            cancelAuthorize.setInputBrId(this.getUsrArtiId());
            cancelAuthorize.setFinaBrId(this.getUsrBchId());
            cancelAuthorize.setCusId(pvpAuthorize.getCusId());
            cancelAuthorize.setCusName(pvpAuthorize.getCusName());
            cancelAuthorize.setContNo(pvpAuthorize.getContNo());
            cancelAuthorize.setBillNo(pvpAuthorize.getBillNo());
            cancelAuthorize.setTradeAmount(pvpAuthorize.getTradeAmount());
            cancelAuthorize.setTradeDate(this.getOpenDay());
            cancelAuthorize.setTradeStatus(TradeCodeConstant.WTZ);

            cancelAuthorize.setTradeCode(TradeCodeConstant.TYCX);
            cancelAuthorize.setFieldNum(4);

            cancelAuthorize.setFldvalue01("c@tradeCode@" + ""); //
            cancelAuthorize.setFldvalue02("c@tradeDate@" + "");//
            cancelAuthorize.setFldvalue03("c@loanNo@" + "");//
            cancelAuthorize.setFldvalue04("c@contNo@" + ""); //???
            cancelAuthorize.setFldvalue05("c@bizType@" + "");//
            cancelAuthorize.setFldvalue06("c@tradeAmount@" + "");//
            cancelAuthorize.setFldvalue07("c@locNo@" + ""); //
            cancelAuthorize.setFldvalue08("c@tradeSerno@" + "");//

            //???
            strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(cancelAuthorize);
            if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
                System.out.println("???");
                return strReturnMessage;
            }

            //
            try {
                /*??
                 CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
                 cbqService.queryAccreditNotice4Trade(loanNo,connection,connection,context);
                 */
                CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
                cbqService.queryAccreditNotice(connection, context);
            } catch (Exception e) {
                e.printStackTrace();

                /*??
                 try {
                pvpAuthorizeAgent.deletePvpAuthorize(cancelAuthorize.getSerno()) ;
                } catch (EMPException e1) {
                e1.printStackTrace();
                }
                */
                throw new ComponentException(e.getMessage());
            }

        }
        return strReturnMessage;
    }

    /**
     * ?
     * ??????????
     * @param pvpAuthorize ??
     * @throws EMPException 
     * @throws Exception
     */
    public void removeAuthorize(PvpAuthorize pvpAuthorize) throws EMPException {
        String billNo = pvpAuthorize.getBillNo().trim();
        String contNo = pvpAuthorize.getContNo().trim();
        String tradeCode = pvpAuthorize.getTradeCode().trim();
        String serno = pvpAuthorize.getSerno();

        PvpAppAgent pvpAppAgent = (PvpAppAgent) this.getAgentInstance(PUBConstant.PVPAPP);
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        IAddContRecord iAddContRecord = (IAddContRecord) this.getComponentInterface(PUBConstant.CTRCONTADDRECIMPL);

        //
        if (tradeCode.equals(TradeCodeConstant.DKCZ)) {
            //??
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);
            /*
                     //?
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCBILLDETAILS, serno) ;
                         
                         
                     //??
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCLOAN, billNo) ;
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCLOANREVOLVER, billNo) ;
                     accAgent.deleteAccLoanRevSubByBill(billNo) ;
                     //?
                     pvpAppAgent.updatePvpAppStatus("pvp_loan_app", "bill_no", billNo, TradeCodeConstant.YCX) ;
                     //??????
                     iCtrCont.reduceLoanContTotalIssue(contNo, pvpAuthorize.getTradeAmount()) ;
            */ }

        //??
        if (tradeCode.equals(TradeCodeConstant.YCCZ)) {
            //??
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);

            /*         //?
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCBILLDETAILS, serno) ;
                         
                         
                     //??
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCACCP, billNo) ;
                         
                     //?????
                     boolean flag = pvpAuthorizeAgent.checkCancelPvpAuthList(contNo) ;
                     if(flag){
                        //?????
                        pvpAppAgent.updatePvpAppStatus("pvp_accp_app", "cont_no", contNo, TradeCodeConstant.YCX) ;
                        //?????????
                        //iAddContRecord.updateAccpContBack(contNo) ;
                     }
                         
                     //??????????
                     iCtrCont.doRestoreContLmtAndGuar(contNo, "accp", pvpAuthorize.getTradeAmount()) ;
            */ }

        //??
        if (tradeCode.equals(TradeCodeConstant.TXCZ)) {
            //??
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);

            /*         //?
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCBILLDETAILS, serno) ;
                         
                         
                     //??
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCDISC, billNo) ;
                         
                     //?????
                     boolean flag = pvpAuthorizeAgent.checkCancelPvpAuthList(contNo) ;
                     if(flag){
                        //????
                        pvpAppAgent.updatePvpAppStatus("pvp_disc_app", "cont_no", contNo, TradeCodeConstant.YCX) ;
                        //?????????
                        //iAddContRecord.updateDiscContBack(contNo) ;
                     }
                
                     //??????????
                     iCtrCont.doRestoreContLmtAndGuar(contNo, "disc", pvpAuthorize.getTradeAmount()) ;
            */ }

        //???
        if (tradeCode.equals(TradeCodeConstant.BHCZ)) {

            //??
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);

            /*         //?
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCBILLDETAILS, serno) ;
                  */

            //???
            accAgent.removeCMISDomainByKeyword(PUBConstant.ACCCVRG, contNo);
            //?
            pvpAppAgent.updatePvpAppStatus("pvp_cvrg_app", "cont_no", contNo, TradeCodeConstant.YCX);
            /*         //??????
                     iAddContRecord.updateCvrgContBack(contNo) ;
            */ }

        //??
        if (tradeCode.equals(TradeCodeConstant.DKZQ)) {

            //??
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YCX);
            pvpAuthorizeAgent.updatePvpAuthorize(pvpAuthorize);
            /*
                     //?
                     accAgent.removeCMISDomainByKeyword(PUBConstant.ACCBILLDETAILS, serno) ;
                         
                     //?
                     pvpAppAgent.updatePvpAppStatus("pvp_loan_app", "bill_no", billNo, TradeCodeConstant.YCX) ;
                     //??????
                     iAddContRecord.updateCtrLoanExtendBack(contNo) ;
            */ }
    }

    /** <p></p>
    * @param tradeCode ?
    * @param reqPkg    ?
    * @return ?
    * @throws Exception 
    * @TODO ??
    */
    private String TradeAgentID = "TradeAgent";

    private KeyedCollection sendTrade(String tradeCode, String KHJG, String HSJG, String GYH, KeyedCollection kColl,
            Context con) throws Exception {

        TradeAgent trade = (TradeAgent) CMISAgentFactory.getAgentFactoryInstance().getAgentInstance(TradeAgentID,
                con);

        /**
         *  / ?????formats.xml
        trade.setReqHeadFormat(reqHeadFormat);
        trade.setReqBodyFormat(reqBodyFormat);
        trade.setRepHeadFormat(repHeadFormat);
        trade.setRepBodyFormat(repBodyFormat);
        */
        KeyedCollection repPkg = new KeyedCollection();
        //repPkg = trade.callTrade(tradeCode,this.getOpenDay().replaceAll("-", ""),HSJG,KHJG,GYH,kColl);//????kcoll
        return repPkg;

    }

    /**
     * ????????
     *       ????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    /*
    public String addPvpRediscinAuthorize(String pvpSerno)
    throws EMPException {
       String strReturnMessage = CMISMessage.ADDDEFEAT;
        
       PvpRediscinAppAgent pvpRediscinAppAgent = (PvpRediscinAppAgent) this
     .getAgentInstance(PUBConstant.PVPREDISCINAPP);
        
       PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this
     .getAgentInstance(PUBConstant.PVPAUTHORIZE);
       ComponentHelper cHelper = new ComponentHelper() ;
       AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);
        
       PvpRediscinApp pvpRediscinApp = new PvpRediscinApp() ;
       IqpBatchBillLst iqpBatchBillLst = new IqpBatchBillLst() ;
       List iqpBatchBillListList = null ;
       PvpAuthorize pvpAuthorize = new PvpAuthorize() ;
       String billNo = "" ;
       String authSerno = "" ;
        
       //??????
       pvpRediscinApp = pvpRediscinAppAgent.queryPvpRediscinApp(pvpSerno) ;
       if(pvpRediscinApp==null || pvpRediscinApp.getContNo()==null){
     return strReturnMessage ;
       }
        
       //???????
       Iqp4PvpInterface iqp4PvpInterface = (Iqp4PvpInterface) this.getComponentInterface(PUBConstant.IQP4PVP);
       iqpBatchBillListList = iqp4PvpInterface.getIqpBatchBillList(pvpRediscinApp.getContNo()) ;
    if(iqpBatchBillListList==null || iqpBatchBillListList.size()==0){
     return strReturnMessage ;
       }
           
       //???????
    ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
    CtrRediscinCont ctrRediscinCont = new CtrRediscinCont() ;
    ctrRediscinCont = iCtrCont.getRediscinContInfo(pvpRediscinApp.getContNo()) ;
       if(ctrRediscinCont==null || ctrRediscinCont.getContNo()==null){
     return strReturnMessage ;
       }
        
       Iterator itrIqpBatchBillList = iqpBatchBillListList.iterator() ;
       while(itrIqpBatchBillList.hasNext()){
     iqpBatchBillLst = (IqpBatchBillLst)itrIqpBatchBillList.next() ;
         
     authSerno = accAgent.makeNo(TradeCodeConstant.AUTH) ;
        
     String dueDate = iqpBatchBillLst.getBillDueDay() ;               //
     double pmje = iqpBatchBillLst.getBillAmount().doubleValue() ;        //??
     int tzts  = iqpBatchBillLst.getAdjustDay() ;                  //
     int txts = TimeUtil.getBetweenDays(this.getOpenDay(), dueDate) ;    //
     double txll  = pvpRediscinApp.getRediscountIr() ;               //
         
     double txlx = pmje*txll*(txts+tzts)/365 ;
     txlx = TransUtil.sswl(txlx, 2) ;
         
     String billType = pvpRediscinApp.getBillType() ;      //??
     billType = optTranse("billType"+billType) ;
         
     //??????????
     String sequence = "" ;
     sequence = accAgent.getSequence(pvpRediscinApp.getContNo(), 
           cHelper.modId2tabName(PUBConstant.ACCDISC)) ;
     for(int i = sequence.length(); i < 3; i++){ 
        sequence = "0" + sequence; 
     }
     billNo = pvpRediscinApp.getContNo()+sequence;
        
     //????
     pvpAuthorize.setSerno(authSerno) ;
     pvpAuthorize.setTradeCode(TradeCodeConstant.ZTXZRCZ) ;
     pvpAuthorize.setCusManager(pvpRediscinApp.getCusManager()) ;
     pvpAuthorize.setInputBrId(pvpRediscinApp.getInputBrId());
     pvpAuthorize.setFinaBrId(pvpRediscinApp.getFinaBrId()) ;
     pvpAuthorize.setCusId(pvpRediscinApp.getRpId()) ;
     pvpAuthorize.setCusName(pvpRediscinApp.getRpName()) ;
     pvpAuthorize.setContNo(pvpRediscinApp.getContNo()) ;
     pvpAuthorize.setBillNo(billNo);
     pvpAuthorize.setTradeAmount(iqpBatchBillLst.getBillAmount().doubleValue()) ;
     pvpAuthorize.setTradeDate(this.getOpenDay()) ;
     pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
     pvpAuthorize.setFieldNum(19) ;
        
     pvpAuthorize.setFldvalue01("c@T_ORGNO@" + pvpRediscinApp.getInputBrId());      //?
     pvpAuthorize.setFldvalue02("c@T_TELLNO@" + pvpRediscinApp.getCusManager());      //?
     pvpAuthorize.setFldvalue03("c@T_LICENSE_NO@" + authSerno);                  //??
     pvpAuthorize.setFldvalue04("c@T_LICENSE_TYPE@"+"09");                     //?
     pvpAuthorize.setFldvalue05("c@T_LICENSE_KIND@" + "");                     //??
     pvpAuthorize.setFldvalue06("c@T_TYPE1@"+  billType);                     //??
     pvpAuthorize.setFldvalue07("c@T_BANKNOTE_NO@"+  iqpBatchBillLst.getDraftNo());   //??
     pvpAuthorize.setFldvalue08("c@T_ACCOUNT_1@"+  checkNull(iqpBatchBillLst.getDrawerAccId()));//?
     pvpAuthorize.setFldvalue09("c@T_NAME1@"+  checkNull(iqpBatchBillLst.getDrawerName()));      //??
     pvpAuthorize.setFldvalue10("c@T_ACCOUNT_2@"+ checkNull(iqpBatchBillLst.getReceiverAccId())) ;//?
     pvpAuthorize.setFldvalue11("c@T_NAME2@"+ checkNull(iqpBatchBillLst.getReceiverName())) ;    //??
     pvpAuthorize.setFldvalue12("c@T_BANK_NO@"+ checkNull(iqpBatchBillLst.getDrawerBankId())) ;   //?
     pvpAuthorize.setFldvalue13("c@T_BANK_NAME@"+ checkNull(iqpBatchBillLst.getDrawerBank()));   //??
     pvpAuthorize.setFldvalue14("c@T_AMOUNT@"+ iqpBatchBillLst.getBillAmount()) ;         //?
     pvpAuthorize.setFldvalue15("c@T_DISCOUNT_RATE@"+  txll*1000) ;                     //
     pvpAuthorize.setFldvalue16("c@T_DAYCOUNT@"+  iqpBatchBillLst.getAdjustDay()) ;         //
     pvpAuthorize.setFldvalue17("c@T_STARTDATE@"+  iqpBatchBillLst.getBillIssuingDate()) ;   //??
     pvpAuthorize.setFldvalue18("c@T_DATE_END@"+  dueDate) ;                           //?
     pvpAuthorize.setFldvalue19("c@T_DISCOUNT_DATE@"+this.getOpenDay());                  //
        
     //???
     strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
     //??
     AccBillDetails accBillDetails = new AccBillDetails() ;
     accBillDetails.setSerno(authSerno) ;
     accBillDetails.setSernoCore("") ;
     accBillDetails.setTellerNo("") ;
     accBillDetails.setContNo(pvpRediscinApp.getContNo()) ;
     accBillDetails.setBillNo(billNo) ;
     accBillDetails.setLoanAccount("") ;
     accBillDetails.setCusId(pvpRediscinApp.getRpAccId()) ;
     accBillDetails.setCusName(pvpRediscinApp.getRpAccName()) ;
     accBillDetails.setDetailType("02") ;
     accBillDetails.setReturnType("") ;
     accBillDetails.setCurType(iqpBatchBillLst.getBillCurrency()) ;
     accBillDetails.setTradeAmount(iqpBatchBillLst.getBillAmount().doubleValue()) ;
     accBillDetails.setTradeDate(this.getOpenDay()) ;
     accBillDetails.setTradeType("1") ;
     accBillDetails.setTradeBrief("") ;
        
     //?
     strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
     //????
     AccDisc accDisc = new AccDisc() ;
        
     accDisc.setBillNo(billNo) ;
     accDisc.setDiscountAcct("") ;
     accDisc.setContNo(pvpRediscinApp.getContNo()) ;
     accDisc.setPrdPk(pvpRediscinApp.getPrdPk()) ;
     accDisc.setPrdName(pvpRediscinApp.getPrdName()) ;
     accDisc.setBizType(pvpRediscinApp.getBizType()) ;
     accDisc.setLoanTypeExt("") ;
     accDisc.setBillType(pvpRediscinApp.getBillType()) ;
     accDisc.setDraftNo(iqpBatchBillLst.getDraftNo()) ;
     accDisc.setCusId(pvpRediscinApp.getRpId()) ;
     accDisc.setCusName(pvpRediscinApp.getRpName()) ;
     accDisc.setCusAcct(pvpRediscinApp.getRpAccId()) ;
     accDisc.setCusAcctName(pvpRediscinApp.getRpAccName()) ;
     accDisc.setBillCurrency("01") ;
     accDisc.setBillAmount(pmje) ;
     accDisc.setBillIssuingDate(iqpBatchBillLst.getBillIssuingDate()) ;
     accDisc.setBillDueDay(dueDate) ;
     accDisc.setNotHegotiableFlg(iqpBatchBillLst.getNotHegotiableFlg()) ;
     accDisc.setIssueName(iqpBatchBillLst.getDrawerName()) ;
     accDisc.setIssueInsCode(iqpBatchBillLst.getDrawerInsCode()) ;
     accDisc.setIssueBankId(iqpBatchBillLst.getDrawerBankId()) ;
     accDisc.setIssueBankName(iqpBatchBillLst.getDrawerBank()) ;
     accDisc.setIssueBankAcct(iqpBatchBillLst.getDrawerAccId()) ;
     accDisc.setReceiverName(iqpBatchBillLst.getReceiverName()) ;
     accDisc.setReceiverBankId(iqpBatchBillLst.getReceiverBankId()) ;
     accDisc.setReceiverBank(iqpBatchBillLst.getReceiverBank()) ;
     accDisc.setReceiverAccId(iqpBatchBillLst.getReceiverAccId()) ;
     accDisc.setAcptType(iqpBatchBillLst.getAcptType()) ;
     accDisc.setAcptBankId(iqpBatchBillLst.getAcptBankId()) ;
     accDisc.setAcptBankName(iqpBatchBillLst.getAcptBankName()) ;
     accDisc.setAcptOrgNo(iqpBatchBillLst.getAcptOrgNo()) ;
     accDisc.setAcptBankAcct(iqpBatchBillLst.getAcptBankAcct()) ;
     accDisc.setBillIssue(iqpBatchBillLst.getBillIssue()) ;
     accDisc.setAdjustDay(tzts) ;
     accDisc.setDiscDate(this.getOpenDay()) ;
     accDisc.setDiscDay(txts) ;
     accDisc.setDiscRate(txll) ;
     accDisc.setDiscInterest(txlx) ;
     accDisc.setCashAmount(pmje-txlx) ;
     accDisc.setRepuDate(pvpRediscinApp.getRepuDate()) ;
     accDisc.setCollectDate("") ;
     accDisc.setLimitInd(pvpRediscinApp.getLimitInd()) ;
     accDisc.setCla("00") ;
     accDisc.setClaDate("") ;
     accDisc.setClaPre("") ;
     accDisc.setClaDatePre("") ;
     accDisc.setCancelDate("");
     accDisc.setCusManager(pvpRediscinApp.getCusManager()) ;
     accDisc.setInputBrId(pvpRediscinApp.getInputBrId()) ;
     accDisc.setFinaBrId(pvpRediscinApp.getFinaBrId()) ;
     accDisc.setMainBrId(pvpRediscinApp.getMainBrId()) ;
     accDisc.setLatestDate(this.getOpenDay()) ;
     accDisc.setAccountStatus(TradeCodeConstant.TXTZZT00) ;
        
     //???
     strReturnMessage = accAgent.insertAccDisc(accDisc) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
       }
        
       //????
       pvpRediscinApp.setChargeoffStatus(TradeCodeConstant.WTZ) ;
       pvpRediscinAppAgent.updatePvpRediscinApp(pvpRediscinApp) ;
        
       return strReturnMessage;
    }
    /**
     * ????????
     *       ????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     */
    /*
    public String addPvpRediscoutAuthorize(String pvpSerno)
    throws EMPException {
       String strReturnMessage = CMISMessage.ADDDEFEAT;
        
       PvpRediscoutAppAgent pvpRediscoutAppAgent = (PvpRediscoutAppAgent) this
     .getAgentInstance(PUBConstant.PVPREDISCOUTAPP);
        
       PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this
     .getAgentInstance(PUBConstant.PVPAUTHORIZE);
       ComponentHelper cHelper = new ComponentHelper() ;
       AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);
        
       PvpRediscoutApp pvpRediscoutApp = new PvpRediscoutApp() ;
       IqpBatchBillLst iqpBatchBillLst = new IqpBatchBillLst() ;
       AccDisc accDisc = new AccDisc() ;
       List iqpBatchBillListList = null ;
       PvpAuthorize pvpAuthorize = new PvpAuthorize() ;
       String billNo = "" ;
       String authSerno = "" ;
        
       //??????
       pvpRediscoutApp = pvpRediscoutAppAgent.queryPvpRediscoutApp(pvpSerno) ;
       if(pvpRediscoutApp==null || pvpRediscoutApp.getContNo()==null){
     return strReturnMessage ;
       }
        
       //???????
       Iqp4PvpInterface iqp4PvpInterface = (Iqp4PvpInterface) this.getComponentInterface(PUBConstant.IQP4PVP);
       iqpBatchBillListList = iqp4PvpInterface.getIqpBatchBillList(pvpRediscoutApp.getContNo()) ;
    if(iqpBatchBillListList==null || iqpBatchBillListList.size()==0){
     return strReturnMessage ;
       }
           
       //???????
    ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
    CtrRediscoutCont ctrRediscoutCont = new CtrRediscoutCont() ;
    ctrRediscoutCont = iCtrCont.getRediscoutContInfo(pvpRediscoutApp.getContNo()) ;
       if(ctrRediscoutCont==null || ctrRediscoutCont.getContNo()==null){
     return strReturnMessage ;
       }
        
       Iterator itrIqpBatchBillList = iqpBatchBillListList.iterator() ;
       while(itrIqpBatchBillList.hasNext()){
     iqpBatchBillLst = (IqpBatchBillLst)itrIqpBatchBillList.next() ;
         
     authSerno = accAgent.makeNo(TradeCodeConstant.AUTH) ;
        
     String dueDate = iqpBatchBillLst.getBillDueDay() ;               //
     double pmje = iqpBatchBillLst.getBillAmount().doubleValue() ;        //??
     int tzts  = iqpBatchBillLst.getAdjustDay() ;                  //
     int txts = TimeUtil.getBetweenDays(this.getOpenDay(), dueDate) ;    //
     double txll  = pvpRediscoutApp.getRediscountIr() ;               //
         
     double txlx = pmje*txll*(txts+tzts)/365 ;
     txlx = TransUtil.sswl(txlx, 2) ;
         
     String billType = pvpRediscoutApp.getBillType() ;      //??
     billType = optTranse("billType"+billType) ;
         
     //??????????
     String sequence = "" ;
     sequence = accAgent.getSequence(pvpRediscoutApp.getContNo(), 
           cHelper.modId2tabName(PUBConstant.ACCREDISCOUT)) ;
     for(int i = sequence.length(); i < 3; i++){ 
        sequence = "0" + sequence; 
     }
     billNo = pvpRediscoutApp.getContNo()+sequence;
        
     String oldBillNo = iqpBatchBillLst.getOldBillNo() ;
     accDisc = (AccDisc)accAgent.findCMISDomainByKeyword(accDisc, PUBConstant.ACCDISC, oldBillNo) ;
     if(accDisc == null || accDisc.getBillNo()==null){
        return strReturnMessage ;
     }
     //????
     pvpAuthorize.setSerno(authSerno) ;
     pvpAuthorize.setTradeCode(TradeCodeConstant.ZTXZCCZ) ;
     pvpAuthorize.setCusManager(pvpRediscoutApp.getCusManager()) ;
     pvpAuthorize.setInputBrId(pvpRediscoutApp.getInputBrId());
     pvpAuthorize.setFinaBrId(pvpRediscoutApp.getFinaBrId()) ;
     pvpAuthorize.setCusId(pvpRediscoutApp.getRpId()) ;
     pvpAuthorize.setCusName(pvpRediscoutApp.getRpName()) ;
     pvpAuthorize.setContNo(pvpRediscoutApp.getContNo()) ;
     pvpAuthorize.setBillNo(billNo);
     pvpAuthorize.setTradeAmount(iqpBatchBillLst.getBillAmount().doubleValue()) ;
     pvpAuthorize.setTradeDate(this.getOpenDay()) ;
     pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
     pvpAuthorize.setFieldNum(24) ;
        
     pvpAuthorize.setFldvalue01("c@T_ORGNO@" + pvpRediscoutApp.getInputBrId());      //?
     pvpAuthorize.setFldvalue02("c@T_TELLNO@" + pvpRediscoutApp.getCusManager());   //?
     pvpAuthorize.setFldvalue03("c@T_LICENSE_NO@" + authSerno);                  //??
     pvpAuthorize.setFldvalue04("c@T_LICENSE_TYPE@"+"10");                     //?
     pvpAuthorize.setFldvalue05("c@T_LICENSE_KIND@" + "");                     //??
     pvpAuthorize.setFldvalue06("c@T_ACCOUNT@"+  pvpRediscoutApp.getRpAccId());      //?
     pvpAuthorize.setFldvalue07("c@T_DISCOUNT_DATE@"+accDisc.getDiscDate());         //
     pvpAuthorize.setFldvalue08("c@T_TYPE1@"+  billType);                     //??
     pvpAuthorize.setFldvalue09("c@T_BANK_NO@"+ checkNull(iqpBatchBillLst.getDrawerBankId())) ;   //?
     pvpAuthorize.setFldvalue10("c@T_BANK_NAME@"+ checkNull(iqpBatchBillLst.getDrawerBank()));   //??
     pvpAuthorize.setFldvalue11("c@T_BANKNOTE_NO@"+  iqpBatchBillLst.getDraftNo());            //??
     pvpAuthorize.setFldvalue12("c@T_AMOUNT@"+ iqpBatchBillLst.getBillAmount()) ;            //?
     pvpAuthorize.setFldvalue13("c@T_AMOUNT1@"+ (pmje-txlx)) ;                           //?
     pvpAuthorize.setFldvalue14("c@T_STARTDATE@"+  iqpBatchBillLst.getBillIssuingDate()) ;      //??
     pvpAuthorize.setFldvalue15("c@T_DATE_END@"+  dueDate) ;                              //?
     pvpAuthorize.setFldvalue16("c@T_ACCOUNT_1@"+  checkNull(iqpBatchBillLst.getDrawerAccId()));      //?
     pvpAuthorize.setFldvalue17("c@T_NAME1@"+  checkNull(iqpBatchBillLst.getDrawerName()));         //??
     pvpAuthorize.setFldvalue18("c@T_ACCOUNT_2@"+ checkNull(iqpBatchBillLst.getReceiverAccId())) ;   //?
     pvpAuthorize.setFldvalue19("c@T_NAME2@"+ checkNull(iqpBatchBillLst.getReceiverName())) ;       //??
     pvpAuthorize.setFldvalue20("c@T_BANK_NO1@"+ checkNull(pvpRediscoutApp.getRpId())) ;            //?
     pvpAuthorize.setFldvalue21("c@T_BANK_NAME1@"+ checkNull(pvpRediscoutApp.getRpName()));         //??
     pvpAuthorize.setFldvalue22("c@T_DISCOUNT_RATE@"+  txll*1000) ;                     //
     pvpAuthorize.setFldvalue23("c@T_DISCOUNT_DATE@"+this.getOpenDay());                  //
     pvpAuthorize.setFldvalue24("c@T_DAYCOUNT@"+  iqpBatchBillLst.getAdjustDay()) ;         //
        
     //???
     strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
     //??
     AccBillDetails accBillDetails = new AccBillDetails() ;
     accBillDetails.setSerno(authSerno) ;
     accBillDetails.setSernoCore("") ;
     accBillDetails.setTellerNo("") ;
     accBillDetails.setContNo(pvpRediscoutApp.getContNo()) ;
     accBillDetails.setBillNo(billNo) ;
     accBillDetails.setLoanAccount("") ;
     accBillDetails.setCusId(pvpRediscoutApp.getRpAccId()) ;
     accBillDetails.setCusName(pvpRediscoutApp.getRpAccName()) ;
     accBillDetails.setDetailType("02") ;
     accBillDetails.setReturnType("") ;
     accBillDetails.setCurType(iqpBatchBillLst.getBillCurrency()) ;
     accBillDetails.setTradeAmount(iqpBatchBillLst.getBillAmount().doubleValue()) ;
     accBillDetails.setTradeDate(this.getOpenDay()) ;
     accBillDetails.setTradeType("1") ;
     accBillDetails.setTradeBrief("") ;
        
     //?
     strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
     //????
     AccRediscout accRediscout = new AccRediscout() ;
         
     accRediscout.setBillNo(billNo) ;
     accRediscout.setContNo(pvpRediscoutApp.getContNo()) ;
     accRediscout.setDiscountAcct(pvpRediscoutApp.getRpAccId()) ;
     accRediscout.setOrigBillNo(accDisc.getBillNo()) ;
     accRediscout.setOrigDiscNo(accDisc.getDiscountAcct()) ;
     accRediscout.setRpId(pvpRediscoutApp.getRpId()) ;
     accRediscout.setRpName(pvpRediscoutApp.getRpName()) ;
     accRediscout.setRpAccId(pvpRediscoutApp.getRpAccId()) ;
     accRediscout.setRpAccName(pvpRediscoutApp.getRpAccName()) ;
     accRediscout.setBillType(pvpRediscoutApp.getBillType()) ;
     accRediscout.setDraftNo(iqpBatchBillLst.getDraftNo()) ;
     accRediscout.setBillCurrency("01") ;
     accRediscout.setBillAmount(iqpBatchBillLst.getBillAmount().doubleValue()) ;
     accRediscout.setBillIssuingDate(iqpBatchBillLst.getBillIssuingDate()) ;
     accRediscout.setBillDueDay(iqpBatchBillLst.getBillDueDay()) ;
     accRediscout.setNotHegotiableFlg(iqpBatchBillLst.getNotHegotiableFlg()) ;
     accRediscout.setDrawerName(iqpBatchBillLst.getDrawerName()) ;
     accRediscout.setDrawerInsCode(iqpBatchBillLst.getDrawerInsCode()) ;
     accRediscout.setDrawerBankId(iqpBatchBillLst.getDrawerBankId()) ;
     accRediscout.setDrawerBank(iqpBatchBillLst.getDrawerBank()) ;
     accRediscout.setDrawerAccId(iqpBatchBillLst.getDrawerAccId()) ;
     accRediscout.setReceiverName(iqpBatchBillLst.getReceiverName()) ;
     accRediscout.setReceiverBankId(iqpBatchBillLst.getReceiverBankId()) ;
     accRediscout.setReceiverBank(iqpBatchBillLst.getReceiverBank()) ;
     accRediscout.setReceiverAccId(iqpBatchBillLst.getReceiverAccId()) ;
     accRediscout.setAcptType(iqpBatchBillLst.getAcptType()) ;
     accRediscout.setAcptBankId(iqpBatchBillLst.getAcptBankId()) ;
     accRediscout.setAcptBankName(iqpBatchBillLst.getAcptBankName()) ;
     accRediscout.setAcptOrgNo(iqpBatchBillLst.getAcptOrgNo()) ;
     accRediscout.setAcptBankAcct(iqpBatchBillLst.getAcptBankAcct()) ;
     accRediscout.setBillIssue(iqpBatchBillLst.getBillIssue()) ;
     accRediscout.setAdjustDay(iqpBatchBillLst.getAdjustDay()) ;
     accRediscout.setRepuDate(pvpRediscoutApp.getRepuDate()) ;
     accRediscout.setRediscountDate(this.getOpenDay()) ;
     accRediscout.setPreDueDays(txts) ;
     accRediscout.setCostRate(pvpRediscoutApp.getRediscountIr()) ;
     accRediscout.setRediscountInt(txlx) ;
     accRediscout.setRediscountAmt(pmje-txlx) ;
     accRediscout.setCusManager(pvpRediscoutApp.getCusManager()) ;
     accRediscout.setInputBrId(pvpRediscoutApp.getInputBrId()) ;
     accRediscout.setFinaBrId(pvpRediscoutApp.getFinaBrId()) ;
     accRediscout.setMainBrId(pvpRediscoutApp.getMainBrId()) ;
     accRediscout.setLatestDate("") ;
     accRediscout.setAccountStatus(TradeCodeConstant.TXTZZT00) ;
         
     //???
     strReturnMessage = accAgent.insertAccRediscout(accRediscout) ;
     if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
        return strReturnMessage ;
     }
        
       }
        
       //????
       pvpRediscoutApp.setChargeoffStatus(TradeCodeConstant.WTZ) ;
       pvpRediscoutAppAgent.updatePvpRediscoutApp(pvpRediscoutApp) ;
        
       return strReturnMessage;
    }
        
    */
    /**
     * ????????
     *       ????
     * @param pvpSerno ???
     * @throws EMPException 
     * @throws Exception
     *//*
        public String addPvpRevolverAuthorize(String pvpSerno)
        throws EMPException {
        String strReturnMessage = CMISMessage.ADDDEFEAT;
            
        PvpLoanAppAgent pvpLoanAppAgent = (PvpLoanAppAgent) this
        .getAgentInstance(PUBConstant.PVPLOANAPP);
            
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this
        .getAgentInstance(PUBConstant.PVPAUTHORIZE);
            
        ComponentHelper cHelper = new ComponentHelper() ;
        AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC);
            
        PvpLoanApp pvpLoanApp = new PvpLoanApp() ;
        PvpAuthorize pvpAuthorize = new PvpAuthorize() ;
        String billNo = "" ;
            
        //??????
        pvpLoanApp = pvpLoanAppAgent.queryPvpLoanApp(pvpSerno) ;
        if(pvpLoanApp==null || pvpLoanApp.getContNo()==null){
         return strReturnMessage ;
        }
            
        //???????
        ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL);
        CtrRevolverApp ctrRevolverApp = new CtrRevolverApp() ;
        ctrRevolverApp = iCtrCont.getCtrRevolverAppByContNo(pvpLoanApp.getContNo()) ;
            
        String authSerno = accAgent.makeNo(TradeCodeConstant.AUTH) ;
            
        //??????????
        String sequence = "" ;
        sequence = accAgent.getSequence(pvpLoanApp.getContNo(), 
            cHelper.modId2tabName(PUBConstant.ACCLOANREVOLVER)) ;
        for(int i = sequence.length(); i < 3; i++){ 
         sequence = "0" + sequence; 
        }
        billNo = pvpLoanApp.getContNo()+sequence;
            
        String irAdjustMode = pvpLoanApp.getIrAdjustMode() ; //?
        irAdjustMode = optTranse("irAdjustMode"+irAdjustMode) ;
            
        String interestAccMode = pvpLoanApp.getInterestAccMode() ; //?
        interestAccMode = optTranse("interestAccMode"+interestAccMode) ;
            
        String repaymentMode = pvpLoanApp.getRepaymentMode() ;      //?
        repaymentMode = optTranse("repaymentMode"+repaymentMode) ;
            
        double loanAmount = ctrRevolverApp.getCreditAmount() + ctrRevolverApp.getPledgeAmount()
                  + ctrRevolverApp.getImpawnAmount() + ctrRevolverApp.getAssureAmount() ;
            
        String term = "";//?
        String[] start = pvpLoanApp.getLoanStartDate().split("-");
        String[] end = pvpLoanApp.getLoanEndDate().split("-");
        term = ((Integer.parseInt(end[0])-Integer.parseInt(start[0]))*12 
            + (Integer.parseInt(end[1])-Integer.parseInt(start[1])) 
            + (Integer.parseInt(end[2])>Integer.parseInt(start[2])?1:0)) + "";
            
        String bizTypeSub = pvpLoanApp.getBizTypeSub() ;   //??
        String rateNo = changeRateNo(checkNull(bizTypeSub), term) ;   //?
             
        //????
        pvpAuthorize.setSerno(authSerno) ;
        pvpAuthorize.setTradeCode(TradeCodeConstant.XHCZ) ;
        pvpAuthorize.setCusManager(pvpLoanApp.getCusManager()) ;
        pvpAuthorize.setInputBrId(pvpLoanApp.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpLoanApp.getFinaBrId()) ;
        pvpAuthorize.setCusId(pvpLoanApp.getCusId()) ;
        pvpAuthorize.setCusName(pvpLoanApp.getCusName()) ;
        pvpAuthorize.setContNo(pvpLoanApp.getContNo()) ;
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpLoanApp.getLoanAmount()) ;
        pvpAuthorize.setTradeDate(this.getOpenDay()) ;
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ) ;
        pvpAuthorize.setFieldNum(37) ;
            
        pvpAuthorize.setFldvalue01("c@T_ORGNO@" + pvpLoanApp.getInputBrId());      //?
        pvpAuthorize.setFldvalue02("c@T_TELLNO@" + pvpLoanApp.getCusManager());      //?
        pvpAuthorize.setFldvalue03("c@T_LICENSE_NO@" + authSerno);               //??
        pvpAuthorize.setFldvalue04("c@T_LICENSE_TYPE@"+"02");                  //?
        pvpAuthorize.setFldvalue05("c@T_LICENSE_KIND@" + "03");                  //??
        pvpAuthorize.setFldvalue06("c@T_CUS_ID@" + pvpLoanApp.getCusId());         //?
        pvpAuthorize.setFldvalue07("c@T_CUS_NAME@" + pvpLoanApp.getCusName());      //??
        pvpAuthorize.setFldvalue08("c@T_CONT_NO@" + pvpLoanApp.getContNo());      //???
        pvpAuthorize.setFldvalue09("c@T_CURRENCY@" + "01");                     //??(?)
        pvpAuthorize.setFldvalue10("c@T_LOAN_SUB1@" + checkNull(pvpLoanApp.getCreditClass()));   //?
        pvpAuthorize.setFldvalue11("c@T_LOAN_SUB2@" + checkNull(pvpLoanApp.getPledgeClass()));   //?
        pvpAuthorize.setFldvalue12("c@T_LOAN_SUB3@" + checkNull(pvpLoanApp.getImpawnClass()));   //?
        pvpAuthorize.setFldvalue13("c@T_LOAN_SUB4@" + checkNull(pvpLoanApp.getAssureClass()));   //???
        pvpAuthorize.setFldvalue14("c@T_LMT_TOTAL@" + loanAmount);                        //?
        pvpAuthorize.setFldvalue15("c@T_LMT_LITTLE@" + ctrRevolverApp.getCreditAmount());      //?
        pvpAuthorize.setFldvalue16("c@T_LMT_MORTGAGE@" + ctrRevolverApp.getPledgeAmount());      //?
        pvpAuthorize.setFldvalue17("c@T_LMT_PLEDGE@" + ctrRevolverApp.getImpawnAmount());      //?
        pvpAuthorize.setFldvalue18("c@T_LMT_GUARANTEE@" + ctrRevolverApp.getAssureAmount());   //???
        pvpAuthorize.setFldvalue19("c@T_LIC_BEGIN@" + pvpLoanApp.getLoanStartDate());         //
        pvpAuthorize.setFldvalue20("c@T_LIC_END@" + pvpLoanApp.getLoanEndDate());            //
        pvpAuthorize.setFldvalue21("c@T_OWNBIZ_IND@" + "N");                           //?
        pvpAuthorize.setFldvalue22("c@T_OWNLEAD_DAYMAX@" + "");                           //?(??)
        pvpAuthorize.setFldvalue23("c@T_PHONEBANK_IND@" + "N");                           //??
        pvpAuthorize.setFldvalue24("c@T_NETBANK_IND@" + "N");                           //?
        pvpAuthorize.setFldvalue25("c@T_IR_ADJUST_MODE@" + irAdjustMode);                  //?
        pvpAuthorize.setFldvalue26("c@T_RATE_NO@" + rateNo);                           //?
        pvpAuthorize.setFldvalue27("c@T_CONT_RATE@" + pvpLoanApp.getRealityIrY()*1000);         //
        pvpAuthorize.setFldvalue28("c@T_CHG_FLOATINGRATE@" + pvpLoanApp.getDefaultRate()*100);   //
        pvpAuthorize.setFldvalue29("c@T_CHG_RATE@" + pvpLoanApp.getDefaultIr()*1000);         //
        pvpAuthorize.setFldvalue30("c@T_FLOATING_RATE@" + pvpLoanApp.getOverdueRate()*100) ;   //
        pvpAuthorize.setFldvalue31("c@T_OVERDUE_RATE@" + pvpLoanApp.getOverdueIr()*1000);      //
        pvpAuthorize.setFldvalue32("c@T_INTEREST_TYPE@" + interestAccMode);                  //?
        pvpAuthorize.setFldvalue33("c@T_REPAYMENT_MODE@" + repaymentMode);                  //?
        pvpAuthorize.setFldvalue34("c@T_LOAN_USE@" + "000");                           //
        pvpAuthorize.setFldvalue35("c@T_FUND_SOURCE@" + pvpLoanApp.getFundsSrc());                     //??
        pvpAuthorize.setFldvalue36("c@T_INTEREST_ACCOUNT@" + checkNull(pvpLoanApp.getRepaymentAccount())) ;   //??
        pvpAuthorize.setFldvalue37("c@T_FIVE_CLASS@" + "1");                     //
            
        //???
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize) ;
        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
         return strReturnMessage ;
        }
            
        //??
        AccBillDetails accBillDetails = new AccBillDetails() ;
        accBillDetails.setSerno(authSerno) ;
        accBillDetails.setSernoCore("") ;
        accBillDetails.setTellerNo("") ;
        accBillDetails.setContNo(pvpLoanApp.getContNo()) ;
        accBillDetails.setBillNo(billNo) ;
        accBillDetails.setLoanAccount("") ;
        accBillDetails.setCusId(pvpLoanApp.getCusId()) ;
        accBillDetails.setCusName(pvpLoanApp.getCusName()) ;
        accBillDetails.setDetailType("02") ;
        accBillDetails.setReturnType("") ;
        accBillDetails.setCurType(pvpLoanApp.getCurType()) ;
        accBillDetails.setTradeAmount(loanAmount) ;
        accBillDetails.setTradeDate(this.getOpenDay()) ;
        accBillDetails.setTradeType("1") ;
        accBillDetails.setTradeBrief("") ;
            
        //?
        strReturnMessage = accAgent.insertAccBillDetails(accBillDetails) ;
        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
         return strReturnMessage ;
        }
            
        //????
        AccLoanRevolver accLoanRevelover = new AccLoanRevolver() ;
            
        accLoanRevelover.
        setCusId(pvpLoanApp.getCusId()) ;
        accLoanRevelover.setCusName(pvpLoanApp.getCusName()) ;
        accLoanRevelover.setContNo(pvpLoanApp.getContNo()) ;
        accLoanRevelover.setCnContNo("") ;
        accLoanRevelover.setBillNo(billNo) ;
        accLoanRevelover.setPrdPk(pvpLoanApp.getPrdPk()) ;
        accLoanRevelover.setPrdName(pvpLoanApp.getPrdName()) ;
        accLoanRevelover.setBizType(pvpLoanApp.getBizType()) ;
        accLoanRevelover.setPrdType(pvpLoanApp.getPrdType()) ;
        accLoanRevelover.setLoanAccount("") ;
        accLoanRevelover.setLoanForm(pvpLoanApp.getLoanForm()) ;
        accLoanRevelover.setBizTypeSub(pvpLoanApp.getBizTypeSub()) ;
        accLoanRevelover.setAssureMeansMain(pvpLoanApp.getAssureMeansMain()) ;
        accLoanRevelover.setAssureMeans2(pvpLoanApp.getAssureMeans2()) ;
        accLoanRevelover.setAssureMeans3(pvpLoanApp.getAssureMeans3()) ;
        accLoanRevelover.setLimitInd(pvpLoanApp.getLimitInd()) ;
        accLoanRevelover.setCurType(pvpLoanApp.getCurType()) ;
        accLoanRevelover.setLoanAmount(pvpLoanApp.getLoanAmount()) ;
        accLoanRevelover.setLoanBalance(0.0) ;
        accLoanRevelover.setTermType(calTermType(pvpLoanApp.getLoanStartDate(), pvpLoanApp.getLoanEndDate())) ;
        accLoanRevelover.setLoanStartDate(pvpLoanApp.getLoanStartDate()) ;
        accLoanRevelover.setLoanEndDate(pvpLoanApp.getLoanEndDate()) ;
        accLoanRevelover.setLoanDirection(pvpLoanApp.getLoanDirection()) ;
        accLoanRevelover.setLoanNature(pvpLoanApp.getLoanNature()) ;
        accLoanRevelover.setRulingIr(pvpLoanApp.getRulingIr()) ;
        accLoanRevelover.setFloatingRate(pvpLoanApp.getFloatingRate()) ;
        accLoanRevelover.setRealityIrY(pvpLoanApp.getRealityIrY()) ;
        accLoanRevelover.setOverdueRate(pvpLoanApp.getOverdueRate()) ;
        accLoanRevelover.setOverdueIr(pvpLoanApp.getOverdueIr()) ;
        accLoanRevelover.setDefaultRate(pvpLoanApp.getDefaultRate()) ;
        accLoanRevelover.setDefaultIr(pvpLoanApp.getDefaultIr()) ;
        accLoanRevelover.setCiRate(pvpLoanApp.getCiRate()) ;
        accLoanRevelover.setCiIr(pvpLoanApp.getCiIr()) ;
        accLoanRevelover.setDefaultFlag("2") ;
        accLoanRevelover.setLoanForm4("10") ;
        accLoanRevelover.setRevolvingTimes(0) ;
        accLoanRevelover.setFirstDisbDate(this.getOpenDay()) ;
        accLoanRevelover.setExtensionTimes(0) ;
        accLoanRevelover.setOrigExpiDate("") ;
        accLoanRevelover.setCapOverdueDate("") ;
        accLoanRevelover.setIntOverdueDate("") ;
        accLoanRevelover.setOverTimesCurrent(0) ;
        accLoanRevelover.setOverTimesTotal(0) ;
        accLoanRevelover.setMaxTimesTotal(0) ;
        accLoanRevelover.setAccountStatus(TradeCodeConstant.TZZT_WQR) ;
        accLoanRevelover.setSettlDate("") ;
        accLoanRevelover.setLatestDate("") ;
        accLoanRevelover.setBadLoanFlag("2") ;
        accLoanRevelover.setMortgageFlg(pvpLoanApp.getMortgageFlg()) ;
        accLoanRevelover.setRepaymentMode(pvpLoanApp.getRepaymentMode()) ;
        accLoanRevelover.setCusManager(pvpLoanApp.getCusManager()) ;
        accLoanRevelover.setInputBrId(pvpLoanApp.getInputBrId()) ;
        accLoanRevelover.setFinaBrId(pvpLoanApp.getFinaBrId()) ;
        accLoanRevelover.setMainBrId(pvpLoanApp.getInputBrId()) ;
            
        accLoanRevelover.setInnerReceInt(0.0) ;
        accLoanRevelover.setOverdueReceInt(0.0) ;
        accLoanRevelover.setOffReceInt(0.0) ;
        accLoanRevelover.setCompoundReceInt(0.0) ;
        accLoanRevelover.setInnerOffReceInt(0.0) ;
        accLoanRevelover.setInnerActlInt(0.0) ;
        accLoanRevelover.setOverdueActlInt(0.0) ;
        accLoanRevelover.setOffActlInt(0.0) ;
        accLoanRevelover.setCompoundActlInt(0.0) ;
        accLoanRevelover.setInnerOffActlInt(0.0) ;
            
        //???
        strReturnMessage = accAgent.insertAccLoanRevolver(accLoanRevelover) ;
        if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
         return strReturnMessage ;
        }
            
        //?????
        //???
        AccLoanRevSub accLoanRevSub = new AccLoanRevSub() ;
            
        accLoanRevSub.setBillNo(billNo) ;
        accLoanRevSub.setCusId(pvpLoanApp.getCusId()) ;
        accLoanRevSub.setCusName(pvpLoanApp.getCusName()) ;
        accLoanRevSub.setContNo(pvpLoanApp.getContNo()) ;
        accLoanRevSub.setLoanAccountMain("") ;
        accLoanRevSub.setLoanAccount("") ;
        accLoanRevSub.setCurType(pvpLoanApp.getCurType()) ;
        accLoanRevSub.setLoanStartDate(pvpLoanApp.getLoanStartDate()) ;
        accLoanRevSub.setLoanEndDate(pvpLoanApp.getLoanEndDate()) ;
        accLoanRevSub.setDefaultFlag("2") ;
        accLoanRevSub.setLoanForm4("10") ;
        accLoanRevSub.setReceIntCumu(0.0) ;
        accLoanRevSub.setActualIntCumu(0.0) ;
        accLoanRevSub.setDelayIntCumu(0.0) ;
        accLoanRevSub.setInnerIntCumu(0.0) ;
        accLoanRevSub.setInnerReceInt(0.0) ;
        accLoanRevSub.setOverdueReceInt(0.0) ;
        accLoanRevSub.setOffReceInt(0.0) ;
        accLoanRevSub.setCompoundReceInt(0.0) ;
        accLoanRevSub.setInnerOffReceInt(0.0) ;
        accLoanRevSub.setInnerActlInt(0.0) ;
        accLoanRevSub.setOverdueActlInt(0.0) ;
        accLoanRevSub.setOffActlInt(0.0) ;
        accLoanRevSub.setCompoundActlInt(0.0) ;
        accLoanRevSub.setInnerOffActlInt(0.0) ;
        accLoanRevSub.setOffIntCumu(0.0) ;
        accLoanRevSub.setCapOverdueDate("") ;
        accLoanRevSub.setIntOverdueDate("") ;
        accLoanRevSub.setOverTimesCurrent(0) ;
        accLoanRevSub.setOverTimesTotal(0) ;
        accLoanRevSub.setMaxTimesTotal(0) ;
        accLoanRevSub.setAccountStatus(TradeCodeConstant.TZZT_WQR) ;
        accLoanRevSub.setSettlDate("") ;
        accLoanRevSub.setLatestDate("") ;
        accLoanRevSub.setCusManager(pvpLoanApp.getCusManager()) ;
        accLoanRevSub.setInputBrId(pvpLoanApp.getInputBrId()) ;
        accLoanRevSub.setFinaBrId(pvpLoanApp.getFinaBrId()) ;
        accLoanRevSub.setMainBrId(pvpLoanApp.getInputBrId()) ;
            
        //???
        //if(ctrRevolverApp.getAssureAmount()>0){
         accLoanRevSub.setBillNoSub(billNo+IndPubConstant.ASSURE) ;
         accLoanRevSub.setLoanAmount(ctrRevolverApp.getAssureAmount()) ;
         accLoanRevSub.setLoanBalance(0.0) ;
         accLoanRevSub.setAccountClass(pvpLoanApp.getCreditClass()) ;
         accLoanRevSub.setAssureMeansMain(IndPubConstant.ASSURE) ;
             
         strReturnMessage = accAgent.insertAccLoanRevSub(accLoanRevSub) ;
         if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
            return strReturnMessage ;
         }
        //}
        //?
        //if(ctrRevolverApp.getCreditAmount()>0){
         accLoanRevSub.setBillNoSub(billNo+IndPubConstant.CREDIT) ;
         accLoanRevSub.setLoanAmount(ctrRevolverApp.getCreditAmount()) ;
         accLoanRevSub.setLoanBalance(0.0) ;
         accLoanRevSub.setAccountClass(pvpLoanApp.getAssureClass()) ;
         accLoanRevSub.setAssureMeansMain(IndPubConstant.CREDIT) ;
             
         strReturnMessage = accAgent.insertAccLoanRevSub(accLoanRevSub) ;
         if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
            return strReturnMessage ;
         }
        //}
        //?
        //if(ctrRevolverApp.getPledgeAmount()>0){
         accLoanRevSub.setBillNoSub(billNo+IndPubConstant.GUARANTY) ;
         accLoanRevSub.setLoanAmount(ctrRevolverApp.getPledgeAmount()) ;
         accLoanRevSub.setLoanBalance(0.0) ;
         accLoanRevSub.setAccountClass(pvpLoanApp.getPledgeClass()) ;
         accLoanRevSub.setAssureMeansMain(IndPubConstant.GUARANTY) ;
             
         strReturnMessage = accAgent.insertAccLoanRevSub(accLoanRevSub) ;
         if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
            return strReturnMessage ;
         }
        //}
        //?
        //if(ctrRevolverApp.getImpawnAmount()>0){
         accLoanRevSub.setBillNoSub(billNo+IndPubConstant.IMPAWN) ;
         accLoanRevSub.setLoanAmount(ctrRevolverApp.getImpawnAmount()) ;
         accLoanRevSub.setLoanBalance(0.0) ;
         accLoanRevSub.setAccountClass(pvpLoanApp.getImpawnClass()) ;
         accLoanRevSub.setAssureMeansMain(IndPubConstant.IMPAWN) ;
             
         strReturnMessage = accAgent.insertAccLoanRevSub(accLoanRevSub) ;
         if(!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)){
            return strReturnMessage ;
         }
        //}
            
        //???????
        pvpLoanApp.setBillNo(billNo) ;
        pvpLoanApp.setChargeoffStatus(TradeCodeConstant.WTZ) ;
        pvpLoanAppAgent.updatePvpLoanApp(pvpLoanApp) ;
            
        return strReturnMessage;
        }*/

    /**
     * ???????? ????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @author modified by zhangwei
     */
    public String addPvpTfObcAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;// ??
        PvpTfObcComponent pvpTfObcComponent = (PvpTfObcComponent) this.getComponent("PvpTfObc");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);

        PvpTfObc pvpTfObc = new PvpTfObc();

        // ?????
        pvpTfObc = pvpTfObcComponent.queryPvpTfObc(pvpSerno);
        if (pvpTfObc == null || pvpTfObc.getContNo() == null) {
            System.out.println("??????");
            return strReturnMessage;
        }

        // ??
        //CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        //CusBase cusBase = customIface.getCusBase(pvpTfObc.getCusId());
        // ?
        //String transCusId = cusBase.getTransCusId();

        //????
        CtrTfObc ctrTfObc = null;
        CtrTfObcComponent ctrTfObcComponent = (CtrTfObcComponent) this.getComponent("CtrTfObc");
        ctrTfObc = ctrTfObcComponent.queryCtrTfObc(pvpTfObc.getContNo());

        //?
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfObc", pvpSerno, ctrTfObc.getContNo());

        // ?????

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfObc.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfObc.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfObc.setBillSeq(billSeqCtr);

        //????
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setTradeCode("0016"); // ?
        pvpAuthorize.setLoanNo(loanNo); // ??
        pvpAuthorize.setContNo(billNo); // ???
        pvpAuthorize.setContNo(pvpTfObc.getContNo()); // ???
        pvpAuthorize.setCusId(pvpTfObc.getCusId()); // ?
        pvpAuthorize.setCusName(pvpTfObc.getCusName()); // ??
        pvpAuthorize.setSerno(pvpSerno); // ??
        pvpAuthorize.setCusManager(pvpTfObc.getCusManager()); // ?
        pvpAuthorize.setInputBrId(pvpTfObc.getInputBrId()); // ?
        pvpAuthorize.setFinaBrId(pvpTfObc.getFinaBrId()); // ?
        pvpAuthorize.setBillNo(billNo); // ??
        if ("1".equals(pvpTfObc.getBizTypeSub())) {//1: 2:
            pvpAuthorize.setTradeAmount(pvpTfObc.getApplyAmount()); // ?
        } else {
            pvpAuthorize.setTradeAmount(pvpTfObc.getLocAmt()); // ?
        }
        pvpAuthorize.setTradeDate(this.getOpenDay()); // 
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ); // ?
        pvpAuthorize.setFieldNum(18); // ?

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfObc.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfObc.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfObc.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0016"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfObc.getLocCurType()); //???
        if ("1".equals(pvpTfObc.getBizTypeSub())) {//1: 2:
            pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfObc.getApplyAmount()); // ?
        } else {
            pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfObc.getLocAmt()); // ?
        }
        //?

        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfObc.getDueDate()); //??
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        //pvpAuthorize.setFldvalue12("c@applyOrg@" + (String)context.getDataValue("S_organno"));  //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfObc.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@bpNo@" + pvpTfObc.getBpNo()); //?
        //pvpAuthorize.setFldvalue15("c@applyAmount@" + pvpTfObc.getApplyAmount());                 //?
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue15("c@realityIrY@" + df.format(pvpTfObc.getRealityIrY() * 100)); //
        //pvpAuthorize.setFldvalue16("c@feeRate@" + df.format(pvpTfObc.getFeeRate()*100));  //

        String bizTypeSub = "";
        if (pvpTfObc.getBizTypeSub().equals("1")) {//
            bizTypeSub = "0";
        } else if (pvpTfObc.getBizTypeSub().equals("2")) {//
            bizTypeSub = "1";
        } else {
            throw new ComponentException("[" + bizTypeSub + "]");
        }
        pvpAuthorize.setFldvalue16("c@bizTypeSub@" + bizTypeSub); //?
        pvpAuthorize.setFldvalue17("c@entAccNo@" + pvpTfObc.getEntAccNo()); //??
        pvpAuthorize.setFldvalue18("c@intCalType@" + pvpTfObc.getIntCalType()); //??

        //?????,???, modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfObc.getStartDate())) {
            System.out.println("------------openday----" + this.getOpenDay());
            appterm = (int) pvpTfObc.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);
            pvpTfObc.setStartDate(this.getOpenDay());
            pvpTfObc.setDueDate(dueDate);

            ctrTfObc.setStartDate(this.getOpenDay());
            ctrTfObc.setDueDate(dueDate);

            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

        }

        // ???
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("?/??");
            return strReturnMessage;
        }

        // ????
        AccTfObc accTfObc = new AccTfObc();
        AccTfObcAgent accTfObcAgent = (AccTfObcAgent) this.getAgentInstance("AccTfObc");
        BeanUtilsBean bub = new BeanUtilsBean();
        System.err.println("pvpTfObc acpt_amt==" + pvpTfObc.getAcptAmt());
        try {
            bub.copyProperties(accTfObc, pvpTfObc);
        } catch (IllegalAccessException e) {
            new ComponentException("???");
        } catch (InvocationTargetException e) {
            new ComponentException("???");
        }
        accTfObc.setLoanForm4("10");
        accTfObc.setCla("10");
        accTfObc.setBillNo(billNo);
        accTfObc.setAccountStatus("0");
        accTfObc.setMainBrId(pvpTfObc.getInvestigatorBrId());
        accTfObc.setLoanAmount(pvpTfObc.getApplyAmount());
        accTfObc.setLoanBalance(pvpTfObc.getApplyAmount());
        System.err.println("pvpTfObc acpt_amt==" + accTfObc.getAcptAmt());
        accTfObcAgent.insertAccTfObc(accTfObc);

        // ??

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfObc);
        } catch (IllegalAccessException e) {
            new ComponentException("????");
        } catch (InvocationTargetException e) {
            new ComponentException("????");
        }

        accTfComm.setLimitAccNo(accTfObc.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        // ?
        pvpTfObc.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfObc.setBillNo(billNo);
        pvpTfObcComponent.updatePvpTfObc(pvpTfObc);

        //?????
        ctrTfObcComponent.modifyCtrTfObc(ctrTfObc);

        /** ???? */
        System.err.println("????");
        try {
            /*?
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */

            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);

        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("?" + e.getMessage());
        }

        // ???
        return strReturnMessage;
    }

    /**
     * ????????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfOinsfAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;//??

        //??
        PvpTfOinsf pvpTfOinsf = new PvpTfOinsf();
        PvpTfIface pvpTfIface = (PvpTfImpl) this.getComponentInterface("PvpTfImpl");
        pvpTfOinsf = pvpTfIface.queryPvpTfOinsfBySerNo(pvpSerno);
        if (pvpTfOinsf == null || pvpTfOinsf.getContNo() == null) {
            System.out.println("?????");
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        CusBase cusBase = customIface.getCusBase(pvpTfOinsf.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfOinsf ctrTfOinsf = new CtrTfOinsf();
        CtrTfLocImpl ctrTfLocImpl = (CtrTfLocImpl) this.getComponentInterface("CtrTfLoc");
        ctrTfOinsf = ctrTfLocImpl.getCtrTfOinsf(pvpTfOinsf.getContNo());
        if (ctrTfOinsf == null) {
            System.out.println("????????");
            return strReturnMessage;
        }

        //????
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOinsf", pvpSerno, ctrTfOinsf.getContNo());

        //??  ??
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfOinsf.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfOinsf.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfOinsf.setBillSeq(billSeqCtr);

        //???
        // ********************/
        PvpAuthorize pvpAuthorize = new PvpAuthorize();

        pvpAuthorize.setSerno(pvpSerno); //??
        pvpAuthorize.setLoanNo(loanNo); //?
        pvpAuthorize.setCusManager(pvpTfOinsf.getCusManager()); //??
        pvpAuthorize.setInputBrId(pvpTfOinsf.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfOinsf.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfOinsf.getCusId());
        pvpAuthorize.setCusName(pvpTfOinsf.getCusName());
        pvpAuthorize.setContNo(pvpTfOinsf.getContNo());
        pvpAuthorize.setBillNo(billNo); //??
        pvpAuthorize.setTradeAmount(pvpTfOinsf.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0018");
        pvpAuthorize.setFieldNum(27);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOinsf.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOinsf.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOinsf.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0018"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOinsf.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOinsf.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOinsf.getDueDate())); //??
        pvpAuthorize.setFldvalue11("c@note@" + "???"); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOinsf.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@oinsfNo@" + pvpTfOinsf.getOinsfNo());
        pvpAuthorize.setFldvalue15("c@buyerId@" + pvpTfOinsf.getBuyerId());
        pvpAuthorize.setFldvalue16("c@usedCrdRate@" + pvpTfOinsf.getUsedCrdRate());
        pvpAuthorize.setFldvalue17(
                "c@avaCrdRate@" + String.valueOf(pvpTfOinsf.getAvaCrdRate() - pvpTfOinsf.getUsedCrdRate()));
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue18("c@realityIrY@" + df.format(pvpTfOinsf.getRealityIrY() * 100));
        String sub = "";
        if ("1".equals(pvpTfOinsf.getBizTypeSub())) {
            sub = "0";
        } else if ("2".equals(pvpTfOinsf.getBizTypeSub())) {
            sub = "2";
        } else if ("3".equals(pvpTfOinsf.getBizTypeSub())) {
            sub = "1";
        }
        pvpAuthorize.setFldvalue19("c@bizTypeSub@" + sub);
        pvpAuthorize.setFldvalue20("c@enterAccount@" + pvpTfOinsf.getEnterAccount());
        pvpAuthorize.setFldvalue21("c@ciNo@" + pvpTfOinsf.getCiNo());
        pvpAuthorize.setFldvalue22("c@intCalType@" + pvpTfOinsf.getIntCalType());
        String decNo = "";
        if (pvpTfOinsf.getDecNo() != null) {
            decNo = pvpTfOinsf.getDecNo();
        }
        String nvoiceNo = "";
        if (pvpTfOinsf.getNvoiceNo() != null) {
            nvoiceNo = pvpTfOinsf.getNvoiceNo();
        }
        pvpAuthorize.setFldvalue23("c@decNo@" + decNo);
        pvpAuthorize.setFldvalue24("c@nvoiceNo@" + nvoiceNo);
        pvpAuthorize.setFldvalue25("c@nvoiceCurType@" + pvpTfOinsf.getApplyCurType());
        pvpAuthorize.setFldvalue26("c@nvoiceAmt@" + pvpTfOinsf.getNvoiceAmt());
        pvpAuthorize.setFldvalue27("c@payTransferNo@" + pvpTfOinsf.getPayTransferContNo());

        //pvpAuthorize.setFldvalue03("c@putoutSerialno@" + checkNull(loanNo));
        //?????,? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfOinsf.getStartDate())) {

            appterm = (int) pvpTfOinsf.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfOinsf.setStartDate(this.getOpenDay());
            pvpTfOinsf.setDueDate(dueDate);
            //pvpTfIface.updatePvpTfOinsf(pvpTfOinsf);

            ctrTfOinsf.setStartDate(this.getOpenDay());
            ctrTfOinsf.setDueDate(dueDate);

            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

        }

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("?????");
            return strReturnMessage;
        }

        //?????
        AccTfOinsf accTfOinsf = new AccTfOinsf();
        AccTfOinsfAgent accTfOinsfAgent = (AccTfOinsfAgent) this.getAgentInstance(PUBConstant.ACCTFOINSF);
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfOinsf, pvpTfOinsf);
        } catch (IllegalAccessException e) {
            new ComponentException("??????");
        } catch (InvocationTargetException e) {
            new ComponentException("??????");
        }
        accTfOinsf.setLoanForm4("10");
        accTfOinsf.setCla("10");
        accTfOinsf.setBillNo(billNo);
        accTfOinsf.setAccountStatus("0");
        accTfOinsf.setMainBrId(pvpTfOinsf.getInvestigatorBrId());
        accTfOinsf.setLoanAmount(pvpTfOinsf.getApplyAmount());
        accTfOinsf.setLoanBalance(pvpTfOinsf.getApplyAmount());
        accTfOinsfAgent.insertAccTfOinsf(accTfOinsf);

        //???
        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfOinsf);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }

        accTfComm.setLimitAccNo(accTfOinsf.getLimitAccNo()); //???
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //??
        pvpTfOinsf.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfIface.updatePvpTfOinsf(pvpTfOinsf);

        //?????
        ctrTfLocImpl.modifyCtrTfOinsf(ctrTfOinsf);

        // 
        try {
            /*
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
               */
            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        //????
        return strReturnMessage;
    }

    /**
     * ???????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfObocAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;//?

        //??
        PvpTfOboc pvpTfOboc = new PvpTfOboc();
        PvpTfObocComponent pvpTfObocComponent = (PvpTfObocComponent) this.getComponent("PvpTfOboc");
        pvpTfOboc = pvpTfObocComponent.queryPvpTfOboc(pvpSerno);
        if (pvpTfOboc == null || pvpTfOboc.getContNo() == null) {
            System.out.println("??");
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfOboc.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfOboc ctrTfOboc = new CtrTfOboc();
        CtrTfLocImpl ctrTfLocImpl = (CtrTfLocImpl) this.getComponentInterface("CtrTfLoc");
        ctrTfOboc = ctrTfLocImpl.getCtrTfOboc(pvpTfOboc.getContNo());
        if (ctrTfOboc == null) {
            System.out.println("????????");
            return strReturnMessage;
        }

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOboc", pvpSerno, ctrTfOboc.getContNo());

        //??  ??
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfOboc.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfOboc.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfOboc.setBillSeq(billSeqCtr);

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfOboc.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfOboc.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfOboc.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfOboc.getCusId());
        pvpAuthorize.setCusName(pvpTfOboc.getCusName());
        pvpAuthorize.setContNo(pvpTfOboc.getContNo());
        pvpAuthorize.setBillNo(billNo);
        if ("1".equals(pvpTfOboc.getBizTypeSub())) {//1  2
            pvpAuthorize.setTradeAmount(pvpTfOboc.getApplyAmount());
        } else {
            pvpAuthorize.setTradeAmount(pvpTfOboc.getAbAmt());
        }
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0017");
        pvpAuthorize.setFieldNum(19);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOboc.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOboc.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOboc.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0017"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOboc.getApplyCurType()); //???

        if ("1".equals(pvpTfOboc.getBizTypeSub())) {//1  2
            pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOboc.getApplyAmount()); //?
        } else {
            pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOboc.getAbAmt());
        }

        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfOboc.getDueDate()); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOboc.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@ocNo@" + checkNull(pvpTfOboc.getOcNo()));
        pvpAuthorize.setFldvalue15("c@locAmt@" + pvpTfOboc.getAbAmt());
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue16("c@realityIrY@" + df.format(pvpTfOboc.getRealityIrY() * 100));
        //pvpAuthorize.setFldvalue17("c@feeRate@" + df.format(pvpTfOboc.getFeeRate()*100));        //
        pvpAuthorize.setFldvalue17("c@enterAccount@" + checkNull(pvpTfOboc.getEnterAccount()));

        String bizTypeSub = "";
        if (pvpTfOboc.getBizTypeSub().equals("1")) {//
            bizTypeSub = "0";
        } else if (pvpTfOboc.getBizTypeSub().equals("2")) {//
            bizTypeSub = "1";
        } else {
            throw new ComponentException("[" + bizTypeSub + "]");
        }
        pvpAuthorize.setFldvalue18("c@bizTypeSub@" + checkNull(bizTypeSub));
        pvpAuthorize.setFldvalue19("c@intCalType@" + checkNull(pvpTfOboc.getIntCalType()));

        //pvpAuthorize.setFldvalue18("c@businessrate@" + BigDecimalUtil.mul(pvpTfOboc.getRulingIr(), 100, 6, BigDecimal.ROUND_HALF_UP)); // ???(y?Y?a?D?Y?T)
        //pvpAuthorize.setFldvalue19("c@BillNo@" + checkNull(pvpTfOboc.getOcNo())); // o???
        //pvpAuthorize.setFldvalue20("c@invamount@" +  new BigDecimal(pvpTfOboc.getAbAmt()));// ?Y?e??

        //?????,? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfOboc.getStartDate())) {
            appterm = (int) pvpTfOboc.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfOboc.setStartDate(this.getOpenDay());
            pvpTfOboc.setDueDate(dueDate);
            //pvpTfObocComponent.updatePvpTfOboc(pvpTfOboc);

            ctrTfOboc.setStartDate(this.getOpenDay());
            ctrTfOboc.setDueDate(dueDate);
            //ctrTfLocImpl.modifyCtrTfOboc(ctrTfOboc);   

            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate); //?
        }

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        try {
            strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        } catch (Exception e) {
            throw new ComponentException("???");
        }
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //???
        AccTfOboc accTfOboc = new AccTfOboc();
        AccTfObocAgent accTfObocAgent = (AccTfObocAgent) this.getAgentInstance("AccTfOboc");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfOboc, pvpTfOboc);
        } catch (IllegalAccessException e) {
            new ComponentException("????");
        } catch (InvocationTargetException e) {
            new ComponentException("????");
        }

        accTfOboc.setLoanForm4("10");
        accTfOboc.setCla("10");
        accTfOboc.setBillNo(billNo);
        accTfOboc.setAccountStatus("0");
        accTfOboc.setMainBrId(pvpTfOboc.getInvestigatorBrId());
        accTfOboc.setLoanAmount(pvpTfOboc.getApplyAmount());
        accTfOboc.setLoanBalance(pvpTfOboc.getApplyAmount());
        accTfObocAgent.insertAccTfOboc(accTfOboc);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfOboc);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }

        accTfComm.setLimitAccNo(accTfOboc.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());

        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //?
        pvpTfOboc.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfOboc.setBillNo(billNo);
        pvpTfObocComponent.updatePvpTfOboc(pvpTfOboc);

        //?????
        ctrTfLocImpl.modifyCtrTfOboc(ctrTfOboc);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */

            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        // ????
        return strReturnMessage;

    }

    /**
     * ???????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfLocAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;
        PvpTfImpl pvpTfImpl = (PvpTfImpl) this.getComponentInterface("PvpTfImpl");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);

        //???
        PvpTfLoc pvpTfLoc = new PvpTfLoc();
        pvpTfLoc = pvpTfImpl.queryPvpTfLoc(pvpSerno);
        if (pvpTfLoc == null || pvpTfLoc.getContNo() == null) {
            System.out.println("??");
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfLoc.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfLoc ctrTfLoc = null;
        CtrTfLocComponent ctrTfLocComponent = (CtrTfLocComponent) this.getComponent("CtrTfLoc");
        ctrTfLoc = ctrTfLocComponent.queryCtrTfLocByContno(pvpTfLoc.getContNo());

        //????
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfLoc", pvpSerno, ctrTfLoc.getContNo());
        CtrTfCvrgComponent ctrTfCvrgComponent = (CtrTfCvrgComponent) this.getComponent("CtrTfCvrg");

        //??????
        //String orgId = pvpTfLoc.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15,context);
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfLoc.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfLoc.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfLoc.setBillSeq(billSeqCtr);

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfLoc.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfLoc.getMainBrId());
        pvpAuthorize.setFinaBrId(pvpTfLoc.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfLoc.getCusId());
        pvpAuthorize.setCusName(pvpTfLoc.getCusName());
        pvpAuthorize.setContNo(pvpTfLoc.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfLoc.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0011");
        pvpAuthorize.setFieldNum(27);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfLoc.getImpContractNo()); //???(2013-04-22?)
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfLoc.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfLoc.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0011"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfLoc.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfLoc.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + pvpTfLoc.getDueDate()); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfLoc.getIocDate()); //??
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfLoc.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@locType@" + pvpTfLoc.getLocType()); //?
        pvpAuthorize.setFldvalue15("c@locDate@" + pvpTfLoc.getFastDay()); //??
        pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + 100 * pvpTfLoc.getSecurityMoneyRt()); //??

        DecimalFormat df = new DecimalFormat("#0.00");
        //todo:modified by wangxuyu 20101105 ????
        //?? business_phase = '2'
        List securitylist = ctrTfCvrgComponent.querySecurityByContNo(pvpTfLoc.getContNo());
        if (securitylist.size() == 0) {
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + " "); //???1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + " "); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + " ");
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + " "); //???1
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + " ");

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " "); //???2
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " "); //???2
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " "); //????2
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " "); //???1
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " ");
        } else if (securitylist.size() == 1) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " ");
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " ");
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " ");
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " ");
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " ");

        } else if (securitylist.size() == 2) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            TfSecurityMsg tfmsg2 = (TfSecurityMsg) securitylist.get(1);
            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + tfmsg2.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + df.format(tfmsg2.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + tfmsg2.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + tfmsg2.getSecurityMoneyType());
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + tfmsg2.getSecurityMoneyDueDate());

        }
        pvpAuthorize.setFldvalue27("c@assureMeansMain@" + pvpTfLoc.getAssureMeansMain()); //??
        /**   
          pvpAuthorize.setFldvalue17("c@seLimitAccNo@" + pvpTfLoc.getSecurityMoneyAcNo());         //???1
          pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + pvpTfLoc.getSecurityMoneyAmt());      //???1
          pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + pvpTfLoc.getSecurityMoneyCur());      //????1
              
          String acNo = (String)pvpTfLoc.getSecurityMoneyAcNo1();
          int count = pvpTfLoc.getSecurityCount();
          if((acNo == null || acNo.equals("null") || acNo.trim().equals("")) && count == 1){
             pvpAuthorize.setFldvalue20("c@seLimitAccNo1@" + " ");       //???2
             pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@" + " ");    //???2
             pvpAuthorize.setFldvalue22("c@securityMoneyCur1@" + " ");    //????2
          }else{
             pvpAuthorize.setFldvalue20("c@seLimitAccNo1@" + pvpTfLoc.getSecurityMoneyAcNo1());       //???2
             pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@" + pvpTfLoc.getSecurityMoneyAmt1());    //???2
             pvpAuthorize.setFldvalue22("c@securityMoneyCur1@" + pvpTfLoc.getSecurityMoneyCur1());    //????2
          }
           */

        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //?????,? modified by wxy 20110108

        //      if(!this.getOpenDay().equals(pvpTfLoc.getStartDate())) {
        //         System.out.println("------------openday----"+this.getOpenDay());
        //         appterm = String.valueOf(TimeUtil.getBetweenDays(this.getOpenDay(), pvpTfLoc.getDueDate()));
        //         pvpTfLoc.setStartDate(this.getOpenDay())   ;
        //         pvpTfLoc.setApplyTerm(appterm);      
        //
        //         ctrTfLoc.setStartDate(this.getOpenDay());
        //         ctrTfLoc.setApplyTerm(appterm);
        //                   
        //      }

        AccTfLoc accTfLoc = new AccTfLoc();
        AccTfLocAgent AccTfLocAgent = (AccTfLocAgent) this.getAgentInstance("AccTfLoc");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfLoc, pvpTfLoc);
        } catch (IllegalAccessException e) {
            new ComponentException("??????");
        } catch (InvocationTargetException e) {
            new ComponentException("??????");
        }
        accTfLoc.setLoanForm4("10");
        accTfLoc.setCla("10");
        accTfLoc.setBillNo(billNo);
        accTfLoc.setAccountStatus("0");
        accTfLoc.setMainBrId(pvpTfLoc.getInvestigatorBrId());
        accTfLoc.setLoanAmount(pvpTfLoc.getApplyAmount());
        accTfLoc.setLoanBalance(pvpTfLoc.getApplyAmount());
        accTfLoc.setStartDate(this.getOpenDay());

        AccTfLocAgent.insertAccTfLoc(accTfLoc);

        //???
        AccTfComm accTfComm = new AccTfComm();
        try {

            bub.copyProperties(accTfComm, accTfLoc);
            accTfComm.setDueDate(pvpTfLoc.getIocDate());//?
            accTfComm.setSendDate(this.getOpenDay());
        } catch (IllegalAccessException e) {
            new ComponentException("????");
        } catch (InvocationTargetException e) {
            new ComponentException("????");
        }
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfLoc.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfLoc.setBillNo(billNo);

        pvpTfImpl.updatePvpTfLoc(pvpTfLoc);

        //?????
        ctrTfLocComponent.modifyCtrTfLoc(ctrTfLoc);

        //
        try {
            /*?
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */

            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);

        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("?" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ???????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     * @throws ParseException 
     */
    public String addPvpTfIbcAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException, ParseException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;
        PvpTfIface pvpTfIface = (PvpTfIface) this.getComponentInterface("PvpTfImpl");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        PvpTfIbc pvpTfIbc = new PvpTfIbc();

        //??
        pvpTfIbc = pvpTfIface.queryPvpTfIbcBySerNo(pvpSerno);
        if (pvpTfIbc == null || pvpTfIbc.getContNo() == null) {
            System.out.println("???");
            return strReturnMessage;
        }

        // ??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfIbc.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfIbc ctrTfIbc = null;
        CtrTfIbcComponent ctrTfIbcComponent = (CtrTfIbcComponent) this.getComponent("CtrTfIbc");
        ctrTfIbc = ctrTfIbcComponent.queryCtrTfIbcDetail(pvpTfIbc.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfIbc", pvpSerno, ctrTfIbc.getContNo());

        // ?????
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfIbc.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfIbc.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfIbc.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfIbc.setBillSeq(billSeqCtr);

        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfIbc.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfIbc.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfIbc.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfIbc.getCusId());
        pvpAuthorize.setCusName(pvpTfIbc.getCusName());
        pvpAuthorize.setContNo(pvpTfIbc.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfIbc.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0012");
        pvpAuthorize.setFieldNum(18);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfIbc.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfIbc.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfIbc.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0012"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfIbc.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfIbc.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)

        //???
        /*
         *                 Calendar cal = Calendar.getInstance();
            cal.setTime(ft.parse(billDueDay_Holiday));
            cal.add(Calendar.DATE,3);
            billDueDay_Holiday_billIssue_Date = cal.getTime();
         */
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        Date openday = ft.parse((String) context.getDataValue("OPENDAY"));

        Calendar cal = Calendar.getInstance();
        cal.setTime(openday);
        cal.add(Calendar.DATE, pvpTfIbc.getApplyTerm());
        Date dueDate = cal.getTime();
        String dueDateStr = ft.format(dueDate);

        pvpAuthorize.setFldvalue10("c@dueDate@" + dueDateStr); //??
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfIbc.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue14("c@realityIrY@" + df.format(pvpTfIbc.getRealityIrY() * 100)); //
        pvpAuthorize.setFldvalue15("c@iocNo@" + pvpTfIbc.getIocNo()); //???
        pvpAuthorize.setFldvalue16("c@tfBillNo@" + pvpTfIbc.getTfBillNo()); //????
        pvpAuthorize.setFldvalue17("c@enterAccount@" + pvpTfIbc.getEnterAccount()); //?
        pvpAuthorize.setFldvalue18("c@intCalType@" + pvpTfIbc.getIntCalType()); //??

        //pvpAuthorize.setFldvalue18("c@businessrate@" + BigDecimalUtil.mul(pvpTfIbc.getRulingIr(), 100, 6, BigDecimal.ROUND_HALF_UP));
        //pvpAuthorize.setFldvalue20("c@BillNo@" + checkNull(pvpTfIbc.getTfBillNo()));

        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //?????,? modified by wxy 20110108
        int appterm = 0;
        if (!this.getOpenDay().equals(pvpTfIbc.getStartDate())) {
            System.out.println("------------openday----" + this.getOpenDay());
            appterm = pvpTfIbc.getApplyTerm();
            pvpTfIbc.setStartDate(this.getOpenDay());
            pvpTfIbc.setApplyTerm(appterm);
            pvpTfIbc.setDueDate(dueDateStr);

            ctrTfIbc.setStartDate(this.getOpenDay());
            ctrTfIbc.setApplyTerm(appterm);
            ctrTfIbc.setDueDate(dueDateStr);

        }

        //????
        AccTfIbc accTfIbc = new AccTfIbc();
        AccTfIbcAgent accTfIbcAgent = (AccTfIbcAgent) this.getAgentInstance(PUBConstant.ACCTFIBC);
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfIbc, pvpTfIbc);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfIbc.setLoanForm4("10");
        accTfIbc.setCla("10");
        accTfIbc.setBillNo(billNo);
        accTfIbc.setAccountStatus("0");
        accTfIbc.setMainBrId(pvpTfIbc.getInvestigatorBrId());
        accTfIbc.setLoanAmount(pvpTfIbc.getApplyAmount());
        accTfIbc.setLoanBalance(pvpTfIbc.getApplyAmount());
        accTfIbcAgent.insertAccTfIbc(accTfIbc);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfIbc);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfIbc.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //?
        pvpTfIbc.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfIbc.setBillNo(billNo);
        pvpTfIface.updatePvpTfIbc(pvpTfIbc);

        //?????
        ctrTfIbcComponent.modifyCtrTfIbc(ctrTfIbc);

        //
        try {
            /*
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */
            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ??????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfCvrgAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;
        PvpTfIface pvpTfIface = (PvpTfIface) this.getComponentInterface("PvpTfImpl");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        PvpTfCvrg pvpTfCvrg = new PvpTfCvrg();

        //??
        pvpTfCvrg = pvpTfIface.queryPvpTfCvrgBySerNo(pvpSerno);
        if (pvpTfCvrg == null || pvpTfCvrg.getContNo() == null) {
            System.out.println("???");
            return strReturnMessage;
        }

        // ??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfCvrg.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfCvrg ctrTfCvrg = null;
        CtrTfCvrgComponent ctrTfCvrgComponent = (CtrTfCvrgComponent) this.getComponent("CtrTfCvrg");
        ctrTfCvrg = ctrTfCvrgComponent.queryCtrTfCvrgDetail(pvpTfCvrg.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfCvrg", pvpSerno, ctrTfCvrg.getContNo());

        // ?????
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfCvrg.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfCvrg.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfCvrg.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfCvrg.setBillSeq(billSeqCtr);

        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfCvrg.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfCvrg.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfCvrg.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfCvrg.getCusId());
        pvpAuthorize.setCusName(pvpTfCvrg.getCusName());
        pvpAuthorize.setContNo(pvpTfCvrg.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfCvrg.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0013");
        pvpAuthorize.setFieldNum(28);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfCvrg.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfCvrg.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfCvrg.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0013"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfCvrg.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfCvrg.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfCvrg.getDueDate()); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfCvrg.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@guaranteeType@" + pvpTfCvrg.getGuaranteeType()); //?
        pvpAuthorize.setFldvalue15("c@cvrgType@" + pvpTfCvrg.getCvrgType()); //??
        String cvrgType = pvpTfCvrg.getCvrgType();
        if (cvrgType.equals("1")) {
            pvpAuthorize.setFldvalue16("c@applyTerm@" + " "); //?
        } else {
            pvpAuthorize.setFldvalue16("c@applyTerm@" + pvpTfCvrg.getApplyTerm()); //?
        }
        pvpAuthorize.setFldvalue17("c@securityMoneyRt@" + 100 * pvpTfCvrg.getSecurityMoneyRt()); //??
        DecimalFormat df = new DecimalFormat("#0.00");

        //todo:modified by wangxuyu 20101105 ????
        List securitylist = ctrTfCvrgComponent.querySecurityByContNo(pvpTfCvrg.getContNo());
        if (securitylist.size() == 0) {
            pvpAuthorize.setFldvalue18("c@securityMoneyAcNo@" + " "); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyAmt@" + " "); //???1
            pvpAuthorize.setFldvalue20("c@securityMoneyCur@" + " ");
            pvpAuthorize.setFldvalue21("c@securityMoneyType@" + " "); //???1
            pvpAuthorize.setFldvalue22("c@securityMoneyDueDate@" + " ");

            pvpAuthorize.setFldvalue23("c@securityMoneyAcNo1@" + " "); //???2
            pvpAuthorize.setFldvalue24("c@securityMoneyAmt1@" + " "); //???2
            pvpAuthorize.setFldvalue25("c@securityMoneyCur1@" + " "); //????2
            pvpAuthorize.setFldvalue26("c@securityMoneyType1@" + " "); //???1
            pvpAuthorize.setFldvalue27("c@securityMoneyDueDate1@" + " ");
        } else if (securitylist.size() == 1) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue18("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue19("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue20("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue21("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue22("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            pvpAuthorize.setFldvalue23("c@securityMoneyAcNo1@" + " ");
            pvpAuthorize.setFldvalue24("c@securityMoneyAmt1@" + " ");
            pvpAuthorize.setFldvalue25("c@securityMoneyCur1@" + " ");
            pvpAuthorize.setFldvalue26("c@securityMoneyType1@" + " ");
            pvpAuthorize.setFldvalue27("c@securityMoneyDueDate1@" + " ");
        } else if (securitylist.size() == 2) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue18("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue19("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue20("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue21("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue22("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            TfSecurityMsg tfmsg2 = (TfSecurityMsg) securitylist.get(1);
            pvpAuthorize.setFldvalue23("c@securityMoneyAcNo1@" + tfmsg2.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue24("c@securityMoneyAmt1@" + df.format(tfmsg2.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue25("c@securityMoneyCur1@" + tfmsg2.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue26("c@securityMoneyType1@" + tfmsg2.getSecurityMoneyType());
            pvpAuthorize.setFldvalue27("c@securityMoneyDueDate1@" + tfmsg2.getSecurityMoneyDueDate());

        }
        pvpAuthorize.setFldvalue28("c@assureMeansMain@" + pvpTfCvrg.getAssureMeansMain()); //??

        /**
        pvpAuthorize.setFldvalue18("c@securityMoneyAcNo@" + pvpTfCvrg.getSecurityMoneyAcNo());    //???1
        pvpAuthorize.setFldvalue19("c@securityMoneyAmt@" + pvpTfCvrg.getSecurityMoneyAmt());      //???1
        pvpAuthorize.setFldvalue20("c@securityMoneyCur@" + pvpTfCvrg.getSecurityMoneyCur());      //????1
            
        String acNo1 = pvpTfCvrg.getSecurityMoneyAcNo1();
        if(acNo1 == null || acNo1.equals("null") || acNo1.trim().equals("")){
           pvpAuthorize.setFldvalue21("c@securityMoneyAcNo1@" + " ");                            //???2
           pvpAuthorize.setFldvalue22("c@securityMoneyAmt1@" + " ");                             //???2
           pvpAuthorize.setFldvalue23("c@securityMoneyCur1@" + " ");                             //????2
        }else{
           pvpAuthorize.setFldvalue21("c@securityMoneyAcNo1@" + pvpTfCvrg.getSecurityMoneyAcNo1());  //???2
           pvpAuthorize.setFldvalue22("c@securityMoneyAmt1@" + pvpTfCvrg.getSecurityMoneyAmt1());    //???2
           pvpAuthorize.setFldvalue23("c@securityMoneyCur1@" + pvpTfCvrg.getSecurityMoneyCur1());    //????2
        }
         */
        //pvpAuthorize.setFldvalue18("c@businessrate@" + BigDecimalUtil.mul(pvpTfCvrg.getRulingIr(), 100, 6, BigDecimal.ROUND_HALF_UP));
        //pvpAuthorize.setFldvalue20("c@BillNo@" + checkNull(pvpTfCvrg.getTfBillNo()));

        //?????,? modified by wxy 20110108
        //      int appterm =0;
        //      String dueDate;
        //      if(!this.getOpenDay().equals(pvpTfCvrg.getStartDate())) {
        //         System.out.println("------------openday----"+this.getOpenDay());
        //         appterm =(int)pvpTfCvrg.getApplyTerm();
        //         dueDate = TimeUtil.ADD_DAY(this.getOpenDay(),appterm);
        //         
        //         pvpTfCvrg.setStartDate(this.getOpenDay())   ;
        //         pvpTfCvrg.setDueDate(dueDate);
        //         
        //         ctrTfCvrg.setStartDate(this.getOpenDay());
        //         ctrTfCvrg.setDueDate(dueDate);
        //         
        //         pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);   
        //         //ctrTfLocImpl.modifyCtrTfOinsf(ctrTfOinsf);
        //                   
        //      }
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //????
        AccTfCvrg accTfCvrg = new AccTfCvrg();
        AccTfCvrgAgent accTfCvrgAgent = (AccTfCvrgAgent) this.getAgentInstance(PUBConstant.ACCTFCVRG);
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfCvrg, pvpTfCvrg);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfCvrg.setLoanForm4("10");
        accTfCvrg.setCla("10");
        accTfCvrg.setBillNo(billNo);
        accTfCvrg.setAccountStatus("0");
        accTfCvrg.setMainBrId(pvpTfCvrg.getMainBrId());
        accTfCvrg.setLoanAmount(pvpTfCvrg.getApplyAmount());
        accTfCvrg.setLoanBalance(pvpTfCvrg.getApplyAmount());
        accTfCvrgAgent.insertAccTfCvrg(accTfCvrg);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfCvrg);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfCvrg.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfCvrg.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfIface.updatePvpTfCvrg(pvpTfCvrg);

        //?????
        ctrTfCvrgComponent.modifyCtrTfCvrg(ctrTfCvrg);

        //
        try {
            /*
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */
            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ??????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfCvrgExtAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;
        PvpTfIface pvpTfIface = (PvpTfIface) this.getComponentInterface("PvpTfImpl");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        PvpTfCvrgExt pvpTfCvrgExt = new PvpTfCvrgExt();

        //??
        pvpTfCvrgExt = pvpTfIface.queryPvpTfCvrgExtBySerNo(pvpSerno);
        if (pvpTfCvrgExt == null || pvpTfCvrgExt.getContNo() == null) {
            System.out.println("???");
            return strReturnMessage;
        }

        // ??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfCvrgExt.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfCvrgExt ctrTfCvrgExt = null;
        CtrTfCvrgExtComponent ctrTfCvrgExtComponent = (CtrTfCvrgExtComponent) this.getComponent("CtrTfCvrgExt");
        ctrTfCvrgExt = ctrTfCvrgExtComponent.queryCtrTfCvrgExtDetail(pvpTfCvrgExt.getContNo());

        //???
        AccTfCvrg accTfCvrg = null;
        AccTfCvrgComponent accTfCvrgComponent = (AccTfCvrgComponent) this.getComponent("AccTfCvrg");
        accTfCvrg = accTfCvrgComponent.queryAccTfCvrgByContNoAndCondition(ctrTfCvrgExt.getOldContNo());

        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        AccTfComm accTfCommIns = new AccTfComm();
        accTfCommIns = accTfCommComponent.findAccTfCommByBillNo(ctrTfCvrgExt.getOldBillNo());
        //?
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfCvrgExt", pvpSerno, ctrTfCvrgExt.getContNo());

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfCvrgExt.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfCvrgExt.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfCvrgExt.setBillSeq(billSeqCtr);

        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfCvrgExt.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfCvrgExt.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfCvrgExt.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfCvrgExt.getCusId());
        pvpAuthorize.setCusName(pvpTfCvrgExt.getCusName());
        pvpAuthorize.setContNo(pvpTfCvrgExt.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfCvrgExt.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0034");
        pvpAuthorize.setFieldNum(26);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfCvrgExt.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfCvrgExt.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfCvrgExt.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0034"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfCvrgExt.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfCvrgExt.getNewApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfCvrgExt.getNewDueDate()); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfCvrgExt.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@iocNo@" + accTfCommIns.getSernoInternation()); //?
        pvpAuthorize.setFldvalue15("c@applyTerm@" + " ");
        //pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + pvpTfCvrgExt.getSecurityMoneyRt());
        DecimalFormat df = new DecimalFormat("#0.00");//??
        pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + 100 * pvpTfCvrgExt.getSecurityMoneyRt()); //??
        List<TfSecurityMsg> securitylist = ctrTfCvrgExtComponent.querySecurityByCont(pvpTfCvrgExt.getContNo()); //?????

        if (securitylist.size() == 0) {
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + " "); //???1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + " "); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + " ");
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + " "); //???1
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + " ");

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " "); //???2
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " "); //???2
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " "); //????2
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " "); //???1
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
        } else if (securitylist.size() == 1) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " ");
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " ");
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " ");
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " ");
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
        } else if (securitylist.size() == 2) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            TfSecurityMsg tfmsg2 = (TfSecurityMsg) securitylist.get(1);
            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + tfmsg2.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + df.format(tfmsg2.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + tfmsg2.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + tfmsg2.getSecurityMoneyType());
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + tfmsg2.getSecurityMoneyDueDate());
        }

        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //????
        AccTfCvrgExt accTfCvrgExt = new AccTfCvrgExt();
        AccTfCvrgExtAgent accTfCvrgExtAgent = (AccTfCvrgExtAgent) this.getAgentInstance(PUBConstant.ACCTFCVRGEXT);
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfCvrgExt, pvpTfCvrgExt);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfCvrgExt.setLoanForm4("10");
        accTfCvrgExt.setCla("10");
        accTfCvrgExt.setBillNo(billNo);
        accTfCvrgExt.setAccountStatus("0");
        accTfCvrgExt.setLoanAmount(pvpTfCvrgExt.getApplyAmount());
        accTfCvrgExt.setLoanBalance(pvpTfCvrgExt.getApplyAmount());
        accTfCvrgExtAgent.insertAccTfCvrgExt(accTfCvrgExt);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfCvrgExt);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfCvrgExt.getLimitAccNo());
        accTfComm.setApplyAmount(accTfCvrgExt.getNewApplyAmount());
        accTfComm.setLoanAmount(accTfCvrgExt.getNewApplyAmount());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfCvrgExt.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfCvrgExt.setBillNo(billNo);
        pvpTfIface.updatePvpTfCvrgExt(pvpTfCvrgExt);

        //?????
        ctrTfCvrgExtComponent.modifyCtrTfCvrgExt(ctrTfCvrgExt);

        //
        try {
            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ????????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfPgasAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        PvpTfPgasComponent pvpTfPgasComponent = (PvpTfPgasComponent) this.getComponent("PvpTfPgas");
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        PvpTfPgas pvpTfPgas = new PvpTfPgas();

        //?
        pvpTfPgas = pvpTfPgasComponent.queryPvpTfPgasBySerNo(pvpSerno);
        if (pvpTfPgas == null || pvpTfPgas.getContNo() == null) {
            System.out.println("??");
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfPgas.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfPgas ctrTfPgas = null;
        CtrTfPgasComponent ctrTfPgasComponent = (CtrTfPgasComponent) this.getComponent("CtrTfPgas");
        ctrTfPgas = ctrTfPgasComponent.queryCtrTfPgasDetail(pvpTfPgas.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        //      accTfCommComponent.checkConditionBeforeAuthorize("PvpTfPgas", pvpSerno, ctrTfPgas.getContNo());

        // ?????
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfPgas.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfPgas.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfPgas.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfPgas.setBillSeq(billSeqCtr);

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfPgas.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfPgas.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfPgas.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfPgas.getCusId());
        pvpAuthorize.setCusName(pvpTfPgas.getCusName());
        pvpAuthorize.setContNo(pvpTfPgas.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfPgas.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0015");
        pvpAuthorize.setFieldNum(26);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfPgas.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfPgas.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfPgas.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0015"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfPgas.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfPgas.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + checkNull(pvpTfPgas.getStartDate())); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfPgas.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfPgas.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        pvpAuthorize.setFldvalue14("c@billId@" + pvpTfPgas.getBillId()); //?????
        pvpAuthorize.setFldvalue15("c@iocNo@" + pvpTfPgas.getIocNo()); //???
        pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + 100 * pvpTfPgas.getSecurityMoneyRt()); //??

        //????Tf_Security_Msg????()
        String conditionStr = " where cont_no ='" + checkNull(pvpTfPgas.getContNo()) + "'";
        PubOperaInterface pubOperaInterface = (PubOperaInterface) CMISComponentFactory.getComponentFactoryInstance()
                .getComponentInterface(PUBConstant.PUBOPERA, context, connection);
        List<CMISDomain> TfSecurityMsgList = new ArrayList<CMISDomain>();
        TfSecurityMsgList = pubOperaInterface.getCMISDomainByCondition(TfSecurityMsg.class, conditionStr);
        KeyedCollection tempKcoll = new KeyedCollection();
        if (TfSecurityMsgList.size() == 0) {
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@"); //????1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@"); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@"); //????1
            pvpAuthorize.setFldvalue20("c@securityMoneyAcNo1@"); //????2
            pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@"); //???2
            pvpAuthorize.setFldvalue22("c@securityMoneyCur1@");
        } else if (TfSecurityMsgList.size() == 1) {
            TfSecurityMsg tfSecurityMsg = (TfSecurityMsg) TfSecurityMsgList.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + checkNull(tfSecurityMsg.getSecurityMoneyAcNo())); //????1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + tfSecurityMsg.getSecurityMoneyAmt()); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + checkNull(tfSecurityMsg.getSecurityMoneyCur())); //????1
            pvpAuthorize.setFldvalue20("c@securityMoneyAcNo1@"); //????2
            pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@"); //???2
            pvpAuthorize.setFldvalue22("c@securityMoneyCur1@"); //????2
        } else if (TfSecurityMsgList.size() == 2) {
            TfSecurityMsg tfSecurityMsg = (TfSecurityMsg) TfSecurityMsgList.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + checkNull(tfSecurityMsg.getSecurityMoneyAcNo())); //????1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + tfSecurityMsg.getSecurityMoneyAmt()); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + checkNull(tfSecurityMsg.getSecurityMoneyCur())); //????1
            TfSecurityMsg tfSecurityMsg1 = (TfSecurityMsg) TfSecurityMsgList.get(1);
            pvpAuthorize.setFldvalue20("c@securityMoneyAcNo1@" + checkNull(tfSecurityMsg1.getSecurityMoneyAcNo())); //????2
            pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@" + tfSecurityMsg.getSecurityMoneyAmt()); //???2
            pvpAuthorize.setFldvalue22("c@securityMoneyCur1@" + checkNull(tfSecurityMsg.getSecurityMoneyCur())); //????2
        } else if (TfSecurityMsgList.size() > 2) {
            throw new EMPException("????");
        }
        //??????,
        for (int i = 0; i < TfSecurityMsgList.size(); i++) {
            TfSecurityMsg tfSecurityMsg = (TfSecurityMsg) TfSecurityMsgList.get(i);
            tfSecurityMsg.setBillNo(billNo);
            pubOperaInterface.updateCMISDomain(tfSecurityMsg);
        }

        //      pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + checkNull(pvpTfPgas.getSecurityMoneyAcNo()));    //????1
        //      pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + pvpTfPgas.getSecurityMoneyAmt());                 //???1
        //      pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + checkNull(pvpTfPgas.getSecurityMoneyCur()));      //????1
        //      String securityMoneyAcNo1 = pvpTfPgas.getSecurityMoneyAcNo1();
        //      if(securityMoneyAcNo1 == null || securityMoneyAcNo1.equals("null") || securityMoneyAcNo1.trim().equals("")){
        //         pvpAuthorize.setFldvalue20("c@securityMoneyAcNo1@");                                      //????2
        //         pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@");                                       //???2
        //         pvpAuthorize.setFldvalue22("c@securityMoneyCur1@");                                       //????2
        //      }else{
        //         pvpAuthorize.setFldvalue20("c@securityMoneyAcNo1@" + pvpTfPgas.getSecurityMoneyAcNo1());  //????2
        //         pvpAuthorize.setFldvalue21("c@securityMoneyAmt1@" + pvpTfPgas.getSecurityMoneyAmt1());    //???2
        //         pvpAuthorize.setFldvalue22("c@securityMoneyCur1@" + pvpTfPgas.getSecurityMoneyCur1());    //????2
        //      }

        //pvpAuthorize.setFldvalue05("c@artificialno@" + checkNull(pvpTfPgas.getCnContNo()));
        //pvpAuthorize.setFldvalue18("c@businessrate@" + BigDecimalUtil.mul(pvpTfPgas.getRulingIr(), 100, 6, BigDecimal.ROUND_HALF_UP)); 
        //pvpAuthorize.setFldvalue23("c@Bailrate@" + BigDecimalUtil.mul(pvpTfPgas.getSecurityMoneyRt(), 100, 6, BigDecimal.ROUND_HALF_UP));

        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //?????,? modified by wxy 20110108
        //      double appterm =0;
        //      if(pvpTfPgas.getStartDate()!=null&&!this.getOpenDay().equals(pvpTfPgas.getStartDate())) {
        //         System.out.println("------------openday----"+this.getOpenDay());
        //         appterm = TimeUtil.getBetweenDays(this.getOpenDay(), pvpTfPgas.getDueDate());
        //         pvpTfPgas.setStartDate(this.getOpenDay())   ;
        //         pvpTfPgas.setApplyTerm(appterm);
        //         
        //         ctrTfPgas.setStartDate(this.getOpenDay());
        //         ctrTfPgas.setApplyTerm(appterm);
        //         
        //         //ctrTfLocImpl.modifyCtrTfOinsf(ctrTfOinsf);
        //                   
        //      }   
        //????
        AccTfPgas accTfPgas = new AccTfPgas();
        AccTfPgasAgent accTfPgasAgent = (AccTfPgasAgent) this.getAgentInstance("AccTfPgas");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfPgas, pvpTfPgas);
        } catch (IllegalAccessException e) {
            new ComponentException("????????");
        } catch (InvocationTargetException e) {
            new ComponentException("???????");
        }

        accTfPgas.setLoanForm4("10");
        accTfPgas.setCla("10");
        accTfPgas.setBillNo(billNo);
        accTfPgas.setAccountStatus("0");
        accTfPgas.setMainBrId(pvpTfPgas.getInvestigatorBrId());
        accTfPgas.setLoanAmount(pvpTfPgas.getApplyAmount());
        accTfPgas.setLoanBalance(pvpTfPgas.getApplyAmount());
        accTfPgasAgent.insertAccTfPgas(accTfPgas);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfPgas);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfPgas.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfPgas.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfPgas.setBillNo(billNo);
        pvpTfPgasComponent.updatePvpTfPgas(pvpTfPgas);

        //?????
        ctrTfPgasComponent.modifyCtrTfPgas(ctrTfPgas);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */

            //???
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);

        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;

    }

    /**
     * ????????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfOiffAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        //??
        PvpTfOiffComponent pvpTfOiffComponent = (PvpTfOiffComponent) this.getComponent("PvpTfOiff");
        PvpTfOiff pvpTfOiff = new PvpTfOiff();
        pvpTfOiff = pvpTfOiffComponent.queryPvpTfOiff(pvpSerno);
        if (pvpTfOiff == null || pvpTfOiff.getContNo() == null) {
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfOiff.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfOiff ctrTfOiff = null;
        CtrTfOiffComponent ctrTfOiffComponent = (CtrTfOiffComponent) this.getComponent("CtrTfOiff");
        ctrTfOiff = ctrTfOiffComponent.queryCtrTfOiff(pvpTfOiff.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOiff", pvpSerno, ctrTfOiff.getContNo());

        // ?????
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOiff.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        //???
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfOiff.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfOiff.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfOiff.setBillSeq(billSeqCtr);

        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfOiff.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfOiff.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfOiff.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfOiff.getCusId());
        pvpAuthorize.setCusName(pvpTfOiff.getCusName());
        pvpAuthorize.setContNo(pvpTfOiff.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfOiff.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0019");
        pvpAuthorize.setFieldNum(17);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOiff.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOiff.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOiff.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0019"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOiff.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOiff.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOiff.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOiff.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@ifNo@" + checkNull(pvpTfOiff.getIfNo())); //???          
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue15("c@realityIrY@" + df.format(pvpTfOiff.getRealityIrY() * 100)); //  
        pvpAuthorize.setFldvalue16("c@enterAccount@" + checkNull(pvpTfOiff.getEnterAccount())); //?          
        pvpAuthorize.setFldvalue17("c@intCalType@" + pvpTfOiff.getIntCalType()); //?          

        //?????,? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfOiff.getStartDate())) {
            System.out.println("------------openday----" + this.getOpenDay());
            appterm = (int) pvpTfOiff.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfOiff.setStartDate(this.getOpenDay());
            pvpTfOiff.setDueDate(dueDate);
            //pvpTfOiffComponent.updatePvpTfOiff(pvpTfOiff);

            ctrTfOiff.setStartDate(this.getOpenDay());
            ctrTfOiff.setDueDate(dueDate);
            // ctrTfOiffComponent.modifyCtrTfOiff(ctrTfOiff);
            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

        }

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            return strReturnMessage;
        }

        //??????
        AccTfOiff accTfOiff = new AccTfOiff();
        AccTfOiffAgent accTfOiffAgent = (AccTfOiffAgent) this.getAgentInstance("AccTfOiff");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfOiff, pvpTfOiff);
        } catch (IllegalAccessException e) {
            new ComponentException("???????");
        } catch (InvocationTargetException e) {
            new ComponentException("???????");
        }

        accTfOiff.setBillNo(billNo);
        accTfOiff.setAccountStatus("0");
        accTfOiff.setMainBrId(pvpTfOiff.getInvestigatorBrId());
        accTfOiff.setLoanAmount(pvpTfOiff.getApplyAmount());
        accTfOiff.setLoanBalance(pvpTfOiff.getApplyAmount());
        accTfOiffAgent.insertAccTfOiff(accTfOiff);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfOiff);

        } catch (IllegalAccessException e) {
            new ComponentException("??????");
        } catch (InvocationTargetException e) {
            new ComponentException("??????");
        }

        accTfComm.setLimitAccNo(accTfOiff.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfOiff.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfOiff.setBillNo(billNo);
        pvpTfOiffComponent.updatePvpTfOiff(pvpTfOiff);

        //?????
        ctrTfOiffComponent.modifyCtrTfOiff(ctrTfOiff);

        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
             */
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("?????" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ????????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfOinvfAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;// ??231|??

        //??
        PvpTfOinvfComponent pvpTfOinvfComponent = (PvpTfOinvfComponent) this.getComponent("PvpTfOinvf");
        PvpTfOinvf pvpTfOinvf = new PvpTfOinvf();
        pvpTfOinvf = pvpTfOinvfComponent.queryPvpTfOinvf(pvpSerno);
        if (pvpTfOinvf == null || pvpTfOinvf.getContNo() == null) {
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfOinvf.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfOinvf ctrTfOinvf = null;
        CtrTfOinvfComponent ctrTfOinvfComponent = (CtrTfOinvfComponent) this.getComponent("CtrTfOinvf");
        ctrTfOinvf = ctrTfOinvfComponent.queryCtrTfOinvf(pvpTfOinvf.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOinvf", pvpSerno, ctrTfOinvf.getContNo());

        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOinvf.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        //???
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfOinvf.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfOinvf.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfOinvf.setBillSeq(billSeqCtr);

        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfOinvf.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfOinvf.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfOinvf.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfOinvf.getCusId());
        pvpAuthorize.setCusName(pvpTfOinvf.getCusName());
        pvpAuthorize.setContNo(pvpTfOinvf.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfOinvf.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0022");
        pvpAuthorize.setFieldNum(23);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOinvf.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOinvf.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOinvf.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0022"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOinvf.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOinvf.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOinvf.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOinvf.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue14("c@realityIrY@" + df.format(pvpTfOinvf.getRealityIrY() * 100)); //
        pvpAuthorize.setFldvalue15("c@buyerName@" + pvpTfOinvf.getBuyerName()); //??
        pvpAuthorize.setFldvalue16("c@tranDocDate@" + pvpTfOinvf.getTranDocDate()); //???
        pvpAuthorize.setFldvalue17("c@enterAccount@" + pvpTfOinvf.getEnterAccount()); //?
        pvpAuthorize.setFldvalue18("c@decNo@" + pvpTfOinvf.getDecNo()); //??
        pvpAuthorize.setFldvalue19("c@intCalType@" + pvpTfOinvf.getIntCalType()); //??
        pvpAuthorize.setFldvalue20("c@oinvfBizType@" + "0"); //
        pvpAuthorize.setFldvalue21("c@nvoiceNo@" + pvpTfOinvf.getNvoiceNo()); //???
        pvpAuthorize.setFldvalue22("c@nvoiceCurType@" + pvpTfOinvf.getNvoiceCurType()); //???    
        pvpAuthorize.setFldvalue23("c@nvoiceAmt@" + pvpTfOinvf.getNvoiceAmt()); //??

        //?????,??? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfOinvf.getStartDate())) {

            appterm = (int) pvpTfOinvf.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfOinvf.setStartDate(this.getOpenDay());
            pvpTfOinvf.setDueDate(dueDate);
            //pvpTfOinvfComponent.updatePvpTfOinvf(pvpTfOinvf);

            ctrTfOinvf.setStartDate(this.getOpenDay());
            ctrTfOinvf.setDueDate(dueDate);
            //ctrTfOinvfComponent.modifyCtrTfOinvf(ctrTfOinvf);        
            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);
        }
        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //??????
        AccTfOinvf accTfOinvf = new AccTfOinvf();
        AccTfOinvfAgent accTfOinvfAgent = (AccTfOinvfAgent) this.getAgentInstance("AccTfOinvf");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfOinvf, pvpTfOinvf);
        } catch (IllegalAccessException e) {
            new ComponentException("???????");
        } catch (InvocationTargetException e) {
            new ComponentException("???????");
        }
        accTfOinvf.setLoanForm4("10");
        accTfOinvf.setCla("10");
        accTfOinvf.setBillNo(billNo);
        accTfOinvf.setAccountStatus("0");
        accTfOinvf.setMainBrId(pvpTfOinvf.getInvestigatorBrId());
        accTfOinvf.setLoanAmount(pvpTfOinvf.getApplyAmount());
        accTfOinvf.setLoanBalance(pvpTfOinvf.getApplyAmount());
        accTfOinvfAgent.insertAccTfOinvf(accTfOinvf);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfOinvf);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfOinvf.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfOinvf.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfOinvf.setBillNo(billNo);
        pvpTfOinvfComponent.updatePvpTfOinvf(pvpTfOinvf);

        //?????
        ctrTfOinvfComponent.modifyCtrTfOinvf(ctrTfOinvf);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
             */

            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("?????" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ??????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfLocExtAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        //??
        PvpTfLocExtComponent pvpTfLocExtComponent = (PvpTfLocExtComponent) this
                .getComponent(PUBConstant.PVPTFLOCEXT);
        PvpTfLocExt pvpTfLocExt = pvpTfLocExtComponent.queryPvpTfLocExtBySerNo(pvpSerno);
        if (pvpTfLocExt == null || pvpTfLocExt.getContNo() == null) {
            return strReturnMessage;
        }

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfLocExt", pvpSerno, pvpTfLocExt.getContNo());
        CtrTfCvrgComponent ctrTfCvrgComponent = (CtrTfCvrgComponent) this.getComponent("CtrTfCvrg");
        //AccTfLocComponent accTfLocComponent = (AccTfLocComponent) this.getComponent("AccTfLoc");
        //AccTfLoc accTfLoc = accTfLocComponent.queryAccTfLocByIocNo(pvpTfLocExt.getIocNo());

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfLocExt.getCusId());
        String transCusId = cusBase.getTransCusId();

        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOinvf.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        //???1 = ???1 + ???1
        //      double securityMoneyAmtFin = pvpTfLocExt.getSecurityAmtFin();
        double securityMoneyOld = pvpTfLocExt.getSecurityAmtOld(); //???1
        double securitymoneyAmt = pvpTfLocExt.getSecurityMoneyAmt();//???1
        double securityMoneyAmt = securitymoneyAmt; //???1
        String smt = securityMoneyAmt + "";
        if (securityMoneyAmt == 0)
            smt = "";

        //???2 = ???2 + ???2
        //      double securityMoneyAmtFin1 = pvpTfLocExt.getSecurityAmtFin1();
        double securityMoneyOld1 = pvpTfLocExt.getSecurityAmtOld1(); //???2
        double securitymoneyAmt1 = pvpTfLocExt.getSecurityMoneyAmt1(); //???2
        double securityMoneyAmt1 = securitymoneyAmt1;//???2
        String smt1 = securityMoneyAmt1 + "";
        if (securityMoneyAmt1 == 0)
            smt1 = "";

        //???
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //????
        CtrTfLocExt ctrTfLocExt = null;
        CtrTfLocExtComponent ctrTfLocExtComponent = (CtrTfLocExtComponent) this.getComponent("CtrTfLocExt");
        ctrTfLocExt = ctrTfLocExtComponent.queryCtrTfLocExtDetail(pvpTfLocExt.getContNo());
        ctrTfLocExt.setBillSeq(1); //???
        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfLocExt.getBillSeq();//???????????????
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfLocExt.getContNo() + billSeq; // ??? ??????

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfLocExt.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfLocExt.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfLocExt.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfLocExt.getCusId());
        pvpAuthorize.setCusName(pvpTfLocExt.getCusName());
        pvpAuthorize.setContNo(pvpTfLocExt.getContNo());
        //pvpAuthorize.setBillNo(accTfLoc.getBillNo());
        pvpAuthorize.setTradeAmount(pvpTfLocExt.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0024");

        pvpAuthorize.setFieldNum(26);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + pvpTfLocExt.getBillNoOld()); //????(???)
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfLocExt.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfLocExt.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfLocExt.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0024"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfLocExt.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfLocExt.getApplyAmountFin()); //?--???
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfLocExt.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfLocExt.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@iocNo@" + pvpTfLocExt.getIocNo()); //?
        pvpAuthorize.setFldvalue15("c@applyTerm@" + pvpTfLocExt.getApplyTerm()); //??
        pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + 100 * pvpTfLocExt.getSecurityMoneyRt()); //??
        DecimalFormat df = new DecimalFormat("#0.00");
        //???
        List securitylist = ctrTfCvrgComponent.querySecurityByContNo(pvpTfLocExt.getContNo());
        if (securitylist.size() == 0) {

            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + " "); //???1
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + " "); //???1
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + " ");
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + " "); //???1
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + " ");

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " "); //???2
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " "); //???2
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " "); //????2
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " "); //???1
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
        } else if (securitylist.size() == 1) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " ");
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " ");
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " ");
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " ");
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
        } else if (securitylist.size() == 2) {
            TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
            pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
            pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

            TfSecurityMsg tfmsg2 = (TfSecurityMsg) securitylist.get(1);
            pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + tfmsg2.getSecurityMoneyAcNo());
            pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + df.format(tfmsg2.getSecurityMoneyAmt()));
            pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + tfmsg2.getSecurityMoneyCur());
            pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + tfmsg2.getSecurityMoneyType());
            pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + tfmsg2.getSecurityMoneyDueDate()); //????2

        }

        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //????
        AccTfLocExt accTfLocExt = new AccTfLocExt();
        AccTfLocExtAgent accTfLocExtAgent = (AccTfLocExtAgent) this.getAgentInstance("AccTfLocExt");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfLocExt, pvpTfLocExt);
        } catch (IllegalAccessException e) {
            new ComponentException("???????");
        } catch (InvocationTargetException e) {
            new ComponentException("???????");
        }

        accTfLocExt.setBillNo(billNo);
        accTfLocExt.setAccountStatus("0");//
        accTfLocExt.setMainBrId(pvpTfLocExt.getInvestigatorBrId());
        accTfLocExtAgent.insertAccTfLocExt(accTfLocExt);

        //????
        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfLocExt);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }
        accTfComm.setLimitAccNo(accTfLocExt.getLimitAccNo());
        accTfComm.setApplyAmount(accTfLocExt.getApplyAmountFin());//?????????
        accTfComm.setLoanAmount(accTfLocExt.getApplyAmountFin());//??
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfLocExt.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfLocExt.setBillNo(billNo);
        pvpTfLocExtComponent.updatePvpTfLocExt(pvpTfLocExt);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
               */

            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("???" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ?????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfRemitAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        //??
        PvpTfRemitComponent pvpTfRemitComponent = (PvpTfRemitComponent) this.getComponent("PvpTfRemit");
        PvpTfRemit pvpTfRemit = new PvpTfRemit();
        pvpTfRemit = pvpTfRemitComponent.queryPvpTfRemit(pvpSerno);
        if (pvpTfRemit == null || pvpTfRemit.getContNo() == null) {
            System.out.println("???");
            return strReturnMessage;
        }

        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfRemit.getCusId());
        String transCusId = cusBase.getTransCusId();

        //????
        CtrTfRemit ctrTfRemit = null;
        CtrTfRemitComponent ctrTfRemitComponent = (CtrTfRemitComponent) this.getComponent("CtrTfRemit");
        ctrTfRemit = ctrTfRemitComponent.queryCtrTfRemit(pvpTfRemit.getContNo());

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfRemit", pvpSerno, ctrTfRemit.getContNo());

        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOinvf.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        //???
        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfRemit.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfRemit.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfRemit.setBillSeq(billSeqCtr);

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfRemit.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfRemit.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfRemit.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfRemit.getCusId());
        pvpAuthorize.setCusName(pvpTfRemit.getCusName());
        pvpAuthorize.setContNo(pvpTfRemit.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfRemit.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0023");
        pvpAuthorize.setFieldNum(19);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfRemit.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfRemit.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfRemit.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0023"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfRemit.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfRemit.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfRemit.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfRemit.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue14("c@realityIrY@" + df.format(pvpTfRemit.getRealityIrY() * 100));
        pvpAuthorize.setFldvalue15("c@remitType@" + "3");
        pvpAuthorize.setFldvalue16("c@intCalType@" + pvpTfRemit.getIntCalType()); //??
        pvpAuthorize.setFldvalue17("c@nvoiceNo@" + pvpTfRemit.getNvoiceNo());
        pvpAuthorize.setFldvalue18("c@nvoiceCurType@" + pvpTfRemit.getNvoiceCur());
        //pvpAuthorize.setFldvalue17("c@nvoiceCurType@" + "USD");
        pvpAuthorize.setFldvalue19("c@nvoiceAmt@" + pvpTfRemit.getNvoiceAmt());

        //?????,? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfRemit.getStartDate())) {
            System.out.println("------------openday----" + this.getOpenDay());
            appterm = (int) pvpTfRemit.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfRemit.setStartDate(this.getOpenDay());
            pvpTfRemit.setDueDate(dueDate);

            pvpTfRemit.setStartDate(this.getOpenDay());
            pvpTfRemit.setDueDate(dueDate);

            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);
        }

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //???
        AccTfRemit accTfRemit = new AccTfRemit();
        AccTfRemitAgent accTfRemitAgent = (AccTfRemitAgent) this.getAgentInstance("AccTfRemit");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfRemit, pvpTfRemit);
        } catch (IllegalAccessException e) {
            new ComponentException("????");
        } catch (InvocationTargetException e) {
            new ComponentException("????");
        }
        accTfRemit.setLoanForm4("10");
        accTfRemit.setCla("10");
        accTfRemit.setBillNo(billNo);
        accTfRemit.setAccountStatus("0");
        accTfRemit.setMainBrId(pvpTfRemit.getInvestigatorBrId());
        accTfRemit.setLoanAmount(pvpTfRemit.getApplyAmount());
        accTfRemit.setLoanBalance(pvpTfRemit.getApplyAmount());
        accTfRemitAgent.insertAccTfRemit(accTfRemit);

        //????

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfRemit);
        } catch (IllegalAccessException e) {
            new ComponentException("?????");
        } catch (InvocationTargetException e) {
            new ComponentException("?????");
        }

        accTfComm.setLimitAccNo(accTfRemit.getLimitAccNo());
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfRemit.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfRemit.setBillNo(billNo);
        pvpTfRemitComponent.updatePvpTfRemit(pvpTfRemit);

        //?????
        ctrTfRemitComponent.modifyCtrTfRemit(ctrTfRemit);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
               */
            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;

    }

    /**
     * ?????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfOthExtAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        //?
        PvpTfOthExtComponent pvpTfOthExtComponent = (PvpTfOthExtComponent) this.getComponent("PvpTfOthExt");
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent("AccTfComm");
        PvpTfOthExt pvpTfOthExt = new PvpTfOthExt();
        pvpTfOthExt = pvpTfOthExtComponent.queryPvpTfOthExt(pvpSerno);
        AccTfComm accTfComm = new AccTfComm();
        accTfComm = (AccTfComm) accTfCommComponent.getCMISDomainByKeyword(accTfComm, pvpTfOthExt.getBizNo());
        if (pvpTfOthExt == null || pvpTfOthExt.getContNo() == null) {
            return strReturnMessage;
        }

        //?
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOthExt", pvpSerno, pvpTfOthExt.getContNo());
        //??
        CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        CusBase cusBase = customIface.getCusBase(pvpTfOthExt.getCusId());
        String transCusId = cusBase.getTransCusId();

        // ???
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOinvf.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);
        String prdType = ""; //??
        String bizType = pvpTfOthExt.getBizType();
        if (bizType == null || "".equals(bizType.trim())) {
            throw new EMPException("?????");
        } else {
            if ("032290".equals(bizType.trim())) { //?? 
                prdType = "0012";
            } else if ("032273".equals(bizType.trim())) { //??/
                prdType = "0016";
            } else if ("032291".equals(bizType.trim())) { //?/
                prdType = "0017";
            } else if ("032278".equals(bizType.trim())) { //???
                prdType = "0018";
            } else if ("032274".equals(bizType.trim())) { //???
                prdType = "0022";
            } else if ("032295".equals(bizType.trim())) { //?
                prdType = "0023";
            } else if ("032270".equals(bizType.trim())) { //???
                prdType = "0019";
            } else {
                throw new EMPException("???" + bizType + "?");
            }
        }

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfOthExt.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfOthExt.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfOthExt.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfOthExt.getCusId());
        pvpAuthorize.setCusName(pvpTfOthExt.getCusName());
        pvpAuthorize.setContNo(pvpTfOthExt.getContNo());
        pvpAuthorize.setBillNo(pvpTfOthExt.getBizNo());
        pvpAuthorize.setTradeAmount(pvpTfOthExt.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0021");
        pvpAuthorize.setFieldNum(17);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + checkNull(loanNo)); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + checkNull(pvpTfOthExt.getBizNo())); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + checkNull(pvpTfOthExt.getContNo())); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + checkNull(pvpTfOthExt.getCusId())); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + checkNull(pvpTfOthExt.getCusName())); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0021"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + checkNull(pvpTfOthExt.getApplyCurType())); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOthExt.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + checkNull((String) context.getDataValue("OPENDAY"))); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOthExt.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOthExt.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@serno@" + checkNull(accTfComm.getSernoInternation()));
        //pvpAuthorize.setFldvalue14("c@serno@" + "NC808ON2010006");
        pvpAuthorize.setFldvalue15("c@dueDate2@" + checkNull(pvpTfOthExt.getDueDate()));
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue16("c@realityIrY@" + df.format(pvpTfOthExt.getRulingIr() * 100));
        pvpAuthorize.setFldvalue17("c@prdType@" + prdType);
        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        pvpTfOthExt.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfOthExtComponent.updatePvpTfOthExt(pvpTfOthExt);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
               */

            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ?????????????
     * 
     * @param pvpLoanApp   domain     
     * @param billNo       ??
     * @param ctrLoanCont  ??domain
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfPckRMBAuthorize(PvpLoanApp pvpLoanApp, String billNo, CtrLoanCont ctrLoanCont)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;
        Context context = this.getContext();
        Connection connection = this.getConnection();

        //????
        String contNo = ctrLoanCont.getContNo();
        TableModelDAO taDao = (TableModelDAO) this.getContext().getService(CMISConstance.ATTR_TABLEMODELDAO);
        KeyedCollection ctrComLoanPack = taDao.queryAllDetail("CtrComLoanPack", contNo, connection);

        String locDueDate = ctrComLoanPack.getDataValue("CtrPckLoan.loc_due_date").toString();
        String iocNo = ctrComLoanPack.getDataValue("CtrComLoanPack.ioc_no").toString();
        String locAmt = ctrComLoanPack.getDataValue("CtrComLoanPack.loc_amt").toString();
        if (locAmt == null || locAmt.length() == 0) {
            locAmt = "0";
        }

        //???
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //??
        PvpAuthorize pvpAuthorize = new PvpAuthorize();
        pvpAuthorize.setSerno(pvpLoanApp.getSerno());
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpLoanApp.getCusManager());
        pvpAuthorize.setInputBrId(pvpLoanApp.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpLoanApp.getFinaBrId());
        pvpAuthorize.setCusId(pvpLoanApp.getCusId());
        pvpAuthorize.setCusName(pvpLoanApp.getCusName());
        pvpAuthorize.setContNo(pvpLoanApp.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpLoanApp.getLoanAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0020");
        pvpAuthorize.setFieldNum(15);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + "111"); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + "111"); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + "7919085059"); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + "???"); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0020"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + "USD"); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + "10000.00"); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + "2009-10-10"); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + (String) context.getDataValue("S_organno")); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        pvpAuthorize.setFldvalue14("c@bpNo@" + "NC808TH1000007");

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
            */

            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("???" + e.getMessage());
        }

        return strReturnMessage;
    }

    /**
     * ??????????????
     * 
     * @param pvpSerno
     *            ??
     * @throws EMPException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @throws Exception
     * @since 2009-09-17
     * @author modified by zhangwei
     */
    public String addPvpTfFftAuthorize(String pvpSerno)
            throws EMPException, IllegalAccessException, InvocationTargetException {

        String strReturnMessage = CMISMessage.ADDDEFEAT;

        //?
        PvpTfFftComponent pvpTfFftComponent = (PvpTfFftComponent) this.getComponent("PvpTfFft");
        PvpTfFft pvpTfFft = new PvpTfFft();
        pvpTfFft = pvpTfFftComponent.queryPvpTfFftBySerNo(pvpSerno);
        if (pvpTfFft == null || pvpTfFft.getContNo() == null) {
            return strReturnMessage;
        }

        //??
        //      CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
        //      CusBase cusBase = customIface.getCusBase(pvpTfFft.getCusId());
        //      String transCusId = cusBase.getTransCusId();

        //????
        CtrTfFft ctrTfFft = new CtrTfFft();
        CtrTfLocImpl ctrTfLocImpl = (CtrTfLocImpl) this.getComponentInterface("CtrTfLoc");
        ctrTfFft = ctrTfLocImpl.getCtrTfFft(pvpTfFft.getContNo());
        if (ctrTfFft == null) {
            System.out.println("????????");
            return strReturnMessage;
        }

        //?
        AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
        accTfCommComponent.checkConditionBeforeAuthorize("PvpTfFft", pvpSerno, ctrTfFft.getContNo());
        // ???
        //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        //String orgId = pvpTfOinvf.getInputBrId();
        //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
        //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
        //loanNo = loanNo.substring(2);

        Context context = this.getContext();
        Connection connection = this.getConnection();
        CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
        String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

        //???
        String[] billZero = { "", "00", "0", "" };
        int billSeqCtr = ctrTfFft.getBillSeq();
        String billSeq = String.valueOf(billSeqCtr);
        billSeq = billZero[billSeq.length()] + billSeq;
        String billNo = pvpTfFft.getContNo() + billSeq; // ??? ??????
        billSeqCtr++;
        ctrTfFft.setBillSeq(billSeqCtr);

        //???
        PvpAuthorize pvpAuthorize = new PvpAuthorize();

        pvpAuthorize.setSerno(pvpSerno);
        pvpAuthorize.setLoanNo(loanNo);
        pvpAuthorize.setCusManager(pvpTfFft.getCusManager());
        pvpAuthorize.setInputBrId(pvpTfFft.getInputBrId());
        pvpAuthorize.setFinaBrId(pvpTfFft.getFinaBrId());
        pvpAuthorize.setCusId(pvpTfFft.getCusId());
        pvpAuthorize.setCusName(pvpTfFft.getCusName());
        pvpAuthorize.setContNo(pvpTfFft.getContNo());
        pvpAuthorize.setBillNo(billNo);
        pvpAuthorize.setTradeAmount(pvpTfFft.getApplyAmount());
        pvpAuthorize.setTradeDate(this.getOpenDay());
        pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
        pvpAuthorize.setTradeCode("0014");
        pvpAuthorize.setFieldNum(25);

        //
        pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
        pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
        pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfFft.getContNo()); //???
        pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfFft.getCusId()); //?
        pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfFft.getCusName()); //??
        pvpAuthorize.setFldvalue06("c@bizType@" + "0014"); //??
        pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfFft.getApplyCurType()); //???
        pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfFft.getApplyAmount()); //?
        pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
        pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfFft.getDueDate())); //?
        pvpAuthorize.setFldvalue11("c@note@" + ""); //
        pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfFft.getFinaBrId()); //
        pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

        //?
        //1  2?  3
        String no = "";
        String fftType = "";
        String bizTypeSub = pvpTfFft.getBizTypeSub();
        if (bizTypeSub.equals("BMTH")) {
            no = pvpTfFft.getPriceNo();
            fftType = "3";
        } else if (bizTypeSub.equals("ZMTH")) {
            no = pvpTfFft.getPriceNo();
            fftType = "2";
        } else if (bizTypeSub.equals("ZXMR")) {
            no = pvpTfFft.getBpNo();
            fftType = "1";
        } else
            throw new ComponentException("?[" + bizTypeSub + "]");

        DecimalFormat sf = new DecimalFormat("#");
        pvpAuthorize.setFldvalue14("c@bpNo@" + checkNull(no));
        pvpAuthorize.setFldvalue15("c@fftType@" + checkNull(fftType));
        pvpAuthorize.setFldvalue16("c@enterAccount@" + checkNull(pvpTfFft.getEntAccNo()));
        pvpAuthorize.setFldvalue17("c@billCurType@" + checkNull(pvpTfFft.getApplyCurType()));
        pvpAuthorize.setFldvalue18("c@billAmt@" + pvpTfFft.getApplyAmount());
        pvpAuthorize.setFldvalue19("c@applyTerm@" + String.valueOf(sf.format(pvpTfFft.getApplyTerm())));
        pvpAuthorize.setFldvalue20("c@graceTerm@" + String.valueOf(sf.format(pvpTfFft.getDaysOfGrace())));
        DecimalFormat df = new DecimalFormat("#.000000");
        pvpAuthorize.setFldvalue21("c@discRate@" + df.format(pvpTfFft.getRealityIrY() * 100));
        pvpAuthorize.setFldvalue22("c@bearTerm@" + String.valueOf(sf.format(pvpTfFft.getBearDays())));
        pvpAuthorize.setFldvalue23("c@bearRate@" + df.format(pvpTfFft.getBearRate() * 100));
        pvpAuthorize.setFldvalue24("c@withholdingFee@" + pvpTfFft.getPreAmount());
        pvpAuthorize.setFldvalue25("c@chargeFee@" + pvpTfFft.getFeeAmt());

        //?????,? modified by wxy 20110108
        int appterm = 0;
        String dueDate;
        if (!this.getOpenDay().equals(pvpTfFft.getStartDate())) {

            appterm = (int) pvpTfFft.getApplyTerm();
            dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

            pvpTfFft.setStartDate(this.getOpenDay());
            pvpTfFft.setDueDate(dueDate);

            ctrTfFft.setStartDate(this.getOpenDay());
            ctrTfFft.setDueDate(dueDate);

            pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

        }

        //??
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
        if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
            System.out.println("???");
            return strReturnMessage;
        }

        AccTfFft accTfFft = new AccTfFft();
        AccTfFftAgent AccTfFftAgent = (AccTfFftAgent) this.getAgentInstance("AccTfFft");
        BeanUtilsBean bub = new BeanUtilsBean();
        try {
            bub.copyProperties(accTfFft, pvpTfFft);
        } catch (IllegalAccessException e) {
            new ComponentException("??????");
        } catch (InvocationTargetException e) {
            new ComponentException("??????");
        }
        accTfFft.setLoanForm4("10");
        accTfFft.setCla("10");
        accTfFft.setBillNo(billNo);
        accTfFft.setAccountStatus("0");
        accTfFft.setMainBrId(pvpTfFft.getInvestigatorBrId());
        accTfFft.setLoanAmount(pvpTfFft.getApplyAmount());
        accTfFft.setLoanBalance(pvpTfFft.getApplyAmount());
        AccTfFftAgent.insertAccTfFft(accTfFft);

        //???

        AccTfComm accTfComm = new AccTfComm();
        try {
            bub.copyProperties(accTfComm, accTfFft);
        } catch (IllegalAccessException e) {
            new ComponentException("????");
        } catch (InvocationTargetException e) {
            new ComponentException("????");
        }
        accTfComm.setSendDate(this.getOpenDay());
        try {
            accTfCommComponent.addAccTfComm(accTfComm);
        } catch (Exception e) {
            accTfCommComponent.updateDomain(accTfComm);
        }

        //
        pvpTfFft.setChargeoffStatus(Constant.PVPSTATUS3);
        pvpTfFftComponent.updatePvpTfFft(pvpTfFft);

        //???
        ctrTfLocImpl.modifyCtrTfFft(ctrTfFft);

        //
        try {
            /*??
            IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
                  loanNo, connection, connection, context);
            KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
            String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
                  .trim();
            pvpAuthorize.setHostSerno(hostSerNo);
            pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
            pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
               */

            CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
            cbqService.queryAccreditNotice(connection, context);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ComponentException("??" + e.getMessage());
        }

        return strReturnMessage;
    }

    public void updatePvpAuthorizeBySerno(String serno) throws EMPException {
        PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
        pvpAuthorizeAgent.updatePvpAuthorizeBySerno(serno);

    }

}