/**
 * @(#)file    TermsAgreeBiz.java
 * @(#)author  이성민
 * @(#)version 1.0
 *
 */
package kr.co.udapsoft.ebid.supplier.portal.result.biz;



import java.io.File;
import java.sql.Connection;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.config.WAFConfig;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.util.ValueObject;
import kr.co.udapsoft.common.util.Crosscert;
import kr.co.udapsoft.ebid.buyer.common.file.FileManager;
import kr.co.udapsoft.ebid.buyer.common.file.biz.FileListWorkerDelBiz;
import kr.co.udapsoft.ebid.buyer.common.file.biz.FileListWorkerSaveHtmlBiz;
import m2soft.ers.invoker.InvokerException;
import m2soft.ers.invoker.http.ReportingServerInvoker;
import oracle.toplink.internal.ox.StrBuffer;

import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;





public class ResultDetail01SaveBiz extends Biz {

	public ResultDetail01SaveBiz(HandlerStorage storage) 
	{
		super(storage);
	}

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception 
	{
		//System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::::::ResultDetail01SaveBiz::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
	    
	    if(storage.compareEvent("SAVE_DATA"))
        {
            boolean success = false;
            
            try 
            {
                conn.begin();
                
                success = save_data(params); 
                
              //System.out.println(success);
                
            } catch (Exception e) {
            	//System.out.println("save_data e======>" + e);
                e.printStackTrace();
                conn.setRollback();
            } finally {
                conn.end();
            }
            
            
            if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
            }
            
            super.storage.setSuccess(success);
        }
	    else if(storage.compareEvent("UPDATE_DATA"))
	    {
            boolean success = false;
            
            try 
            {
                conn.begin();
                
                success = update_data(params); 
                
              //System.out.println(success);
                
            } catch (Exception e) {
            	//System.out.println("update_data e======>" + e);
                e.printStackTrace();
                conn.setRollback();
            } finally {
                conn.end();
            }
            
            
            if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
            }
            
            super.storage.setSuccess(success);
	    }
	    else if(storage.compareEvent("UPDATE_ISSUE"))
        {
            boolean success = false;
            
            try 
            {
                conn.begin();
                
                success = update_data(params); 
                
                success = update_issue(params); 
                
                
              //System.out.println(success);
                
            } catch (Exception e) {
            	//System.out.println("update_data e======>" + e);
                e.printStackTrace();
                conn.setRollback();
            } finally {
                
//                test();
                conn.end();
            }
            
            
            if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
            }
            
            super.storage.setSuccess(success);
        }
	    else if(storage.compareEvent("DELETE_DATA"))
        {
            boolean success = false;
            
            try 
            {
                conn.begin();
                
                success = deleteInfo(params);
                success = deleteDetail(params);
                
              //System.out.println(success);
                
            } catch (Exception e) {
            	//System.out.println("update_data e======>" + e);
                e.printStackTrace();
                conn.setRollback();
            } finally {
                
//                test();
                conn.end();
            }
            
            
            if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
            }
            
            super.storage.setSuccess(success);
        }else if(storage.compareEvent("SIGN_OK")){
        	try 
            {
                conn.begin();
	            
				String sMsg="";
				Crosscert crossErt = new Crosscert();
				sMsg = crossErt.chkSignVerify(params.get("CONT_SIGNDATA"));
				
				if(sMsg.equals("SIGN_SUCCESS")){
	
					CONT_SignOk(super.conn.getConnection(), params);	//서명저장
					params.set("prog_stat_cd", "20");
					update_issue(params);	//상태 변경
	
					//Send(params, storage.getEvent());		//서명요청 메일과 SMS 전송
	
					super.storage.setSuccess(true);
				}else{
					super.storage.setSuccess(false);	
					super.storage.setMessage("인증서 검증에 실패 하였습니다.");
				}
            } catch (Exception e) {
                e.printStackTrace();
                conn.setRollback();
            } finally {
                
//                test();
                conn.end();
            }
		}else if(storage.compareEvent("PREVIEW_PDF")){
			createPdf(params);
			RowSet fileRowSet = FileManager.getFileList("RESULT_PDF", params.get("p_sub_cont_mod_id")+params.get("soc_cd")+params.get("p_acmp_yyyy"));
			storage.addRowSet("RESULT_PDF", fileRowSet);
			super.storage.setSuccess(true);
		}
    }
	
	private boolean save_data(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
    sqlstr.append("             INSERT INTO RESULT_PLOOF_INFO                   \n")
            .append("               (                                               \n")
            .append("                   SUB_CONT_MOD_ID                \n")
            .append("                 , ACMP_YYYY                \n")
            .append("                 , SOC_CD                \n")
            .append("                 , DEPT_CD                \n")
            .append("                 , DEPT_NM                \n")
            .append("                 , ISSUE_NO                \n")
            .append("                 , ISU_VENDNM                \n")
            .append("                 , ISU_PRES_NM                \n")
            .append("                 , ISU_ADDR                \n")
            .append("                 , ISU_PHONE                \n")
            .append("                 , REG_NO                \n")
            .append("                 , CONT_NM                \n")
            .append("                 , WORK_PLACE                \n")
            .append("                 , WORK_KIND                \n")
            .append("                 , LIC_NM                \n")
            .append("                 , LIC_ORG                \n")
            .append("                 , LIC_DATE                \n")
            .append("                 , CONT_CDATE                \n")
            .append("                 , CONT_SDATE                \n")
            .append("                 , CONT_EDATE                \n")
            .append("                 , CONT_LOC_NO                \n")
            .append("                 , ORD_NM                \n")
            .append("                 , ORI_CONT_NM                \n")
            .append("                 , CONT_WAY_NM                \n")
            .append("                 , CONT_KIND                \n")
            .append("                 , SUB_COMP_NM                \n")
            .append("                 , SUB_COMP_NO                \n")
            .append("                 , ENTRY_NO                \n")
            .append("                 , ETC                \n")
            .append("                 , CONT_TAMT                \n")
            .append("                 , CUR_CONT_AMT                \n")
            .append("                 , CUR_PAY_AMT                \n")
            .append("                 , CUR_PAY_SAMT                \n")
            .append("                 , CUR_PAY_NAMT                \n")
            .append("                 , CUR_CONT_AAMT                \n")
            .append("                 , PRV_PAY_AMT                \n")
            .append("                 , PRV_PAY_SAMT                \n")
            .append("                 , PRV_PAY_NAMT                \n")
            .append("                 , PRV_TRANS_AMT                \n")
            .append("                 , SUB_AMT                \n")
            .append("                 , GOV_MA_AMT                \n")
            .append("                 , OTHER_PAY_AMT                \n")
            .append("                 , REG_VENDNM                \n")
            .append("                 , REG_CORP_NO                \n")
            .append("                 , REG_PRES_NM                \n")
            .append("                 , REG_ADDR                \n")
            .append("                 , REG_PHONE                \n")
            .append("                 , ISU_CHARGE_NM                \n")
            .append("                 , ISU_REQ_HP1                \n")
            .append("                 , ISU_REQ_HP2                \n")
            .append("                 , ISU_REQ_HP3                \n")
            .append("                 , PROG_STAT_CD                \n")
            .append("                 , CORP_ID                \n")
            .append("                 , CON_AMT                \n") 
            .append("                 , CONT_TAMT_O                                          \n")
            .append("                 , PRV_PAY_AMT_O                                          \n")
            .append("                 , CUR_PAY_AMT_O                                          \n")
            .append("                 , CUR_PAY_NAMT_O                                          \n")
            .append("                 , UPD_DATE                                          \n")
            .append("                 , ADD_01                                          \n")
            .append("                 , ADD_02                                          \n")
            .append("               )VALUES(                            \n")
            .append("                    ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  SYSDATE                                 \n")
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("               )                                            \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("p_sub_cont_mod_id").trim());
            persistent.addParameter(params.get("p_acmp_yyyy").trim());
            persistent.addParameter(params.get("p_soc_cd").trim());
            persistent.addParameter(params.get("dept_cd").trim());
            persistent.addParameter(params.get("dept_nm").trim());
            persistent.addParameter(params.get("issue_no").trim());
            persistent.addParameter(params.get("isu_vendnm").trim());
            persistent.addParameter(params.get("isu_pres_nm").trim());
            persistent.addParameter(params.get("isu_addr").trim());
            persistent.addParameter(params.get("isu_phone").trim());
            persistent.addParameter(params.get("reg_no").trim());
            persistent.addParameter(params.get("cont_nm").trim());
            persistent.addParameter(params.get("work_place").trim());
            persistent.addParameter(params.get("work_kind").trim());
            persistent.addParameter(params.get("lic_nm").trim());
            persistent.addParameter(params.get("lic_org").trim());
            persistent.addParameter(params.get("lic_date").trim().replace("-", ""));
            persistent.addParameter(params.get("cont_cdate").trim().replace("-", ""));
            persistent.addParameter(params.get("cont_sdate").trim().replace("-", ""));
            persistent.addParameter(params.get("cont_edate").trim().replace("-", ""));
            persistent.addParameter(params.get("cont_loc_no").trim());
            persistent.addParameter(params.get("ord_nm").trim());
            persistent.addParameter(params.get("ori_cont_nm").trim());
            persistent.addParameter(params.get("cont_way_nm").trim());
            persistent.addParameter(params.get("cont_kind").trim());
            persistent.addParameter(params.get("sub_comp_nm").trim());
            persistent.addParameter(params.get("sub_comp_no").trim());
            persistent.addParameter(params.get("entry_no").trim());
            persistent.addParameter(params.get("etc").trim());
            persistent.addParameter(params.get("cont_tamt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_cont_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_samt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_namt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_cont_aamt").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_pay_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_pay_samt").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_pay_namt").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_trans_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("sub_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("gov_ma_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("other_pay_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("reg_vendnm").trim());
            persistent.addParameter(params.get("reg_corp_no").trim());
            persistent.addParameter(params.get("reg_pres_nm").trim());
            persistent.addParameter(params.get("reg_addr").trim());
            persistent.addParameter(params.get("reg_phone").trim());
            persistent.addParameter(params.get("isu_charge_nm").trim());
            persistent.addParameter(params.get("isu_req_hp1").trim());
            persistent.addParameter(params.get("isu_req_hp2").trim());
            persistent.addParameter(params.get("isu_req_hp3").trim());
            persistent.addParameter(params.get("prog_stat_cd").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            persistent.addParameter(params.get("con_amt").trim().trim().replace(",", ""));            
            persistent.addParameter(params.get("cont_tamt_o").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_pay_amt_o").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_amt_o").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_namt_o").trim().replace(",", ""));
            persistent.addParameter(params.get("ADD_01").trim());
            persistent.addParameter(params.get("ADD_02").trim());
            
            
          //System.out.println(persistent.getParameters());
          //System.out.println(sqlstr.toString() );
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	
	private boolean update_data(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
    sqlstr.append("             UPDATE RESULT_PLOOF_INFO SET                  \n")
            .append("                   ISSUE_NO  = ?              \n")
            .append("                 , LIC_ORG   = ?                    \n")
            .append("                 , LIC_DATE   = ?         \n")
            .append("                 , LIC_NM  = ?                  \n")
            .append("                 , REG_NO   = ?                  \n")
            .append("                 , ETC  = ?                    \n")
            .append("                 , ISU_CHARGE_NM  = ?       \n")
            .append("                 , ISU_REQ_HP1    = ?                      \n")
            .append("                 , ISU_REQ_HP2    = ?                      \n")
            .append("                 , ISU_REQ_HP3    = ?                      \n")
            .append("                 , WORK_KIND  = ?                                           \n")
            .append("                 , SUB_AMT  = ?                                           \n")
            .append("                 , PROG_STAT_CD  = ?                                           \n")
            .append("                 , PRV_TRANS_AMT  = ?                                           \n")
            .append("                 , CUR_PAY_AMT  = ?                                           \n")
            .append("                 , CUR_PAY_NAMT  = ?                                           \n")
            .append("                 , UPD_DATE  = SYSDATE                                           \n")
            .append("                 , ADD_01  = ?                                           \n")
            .append("                 , ADD_02  = ?                                           \n")
            .append("                 WHERE CORP_ID = ?                        \n")
            .append("                 AND SUB_CONT_MOD_ID = ?                        \n")
            .append("                 AND ACMP_YYYY = ?                        \n")
            .append("                 AND SOC_CD = ?                        \n");
            
    
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("issue_no").trim());
            persistent.addParameter(params.get("lic_org").trim());
            persistent.addParameter(params.get("lic_date").trim().replace("-", ""));
            persistent.addParameter(params.get("lic_nm").trim());
            persistent.addParameter(params.get("reg_no").trim());
            persistent.addParameter(params.get("etc").trim());
            persistent.addParameter(params.get("isu_charge_nm").trim());
            persistent.addParameter(params.get("isu_req_hp1").trim());
            persistent.addParameter(params.get("isu_req_hp2").trim());
            persistent.addParameter(params.get("isu_req_hp3").trim());
            persistent.addParameter(params.get("work_kind").trim());
            persistent.addParameter(params.get("sub_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("prog_stat_cd").trim());
            persistent.addParameter(params.get("prv_trans_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_pay_namt").trim().replace(",", ""));
            persistent.addParameter(params.get("ADD_01").trim());
            persistent.addParameter(params.get("ADD_02").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            persistent.addParameter(params.get("p_sub_cont_mod_id").trim());
            persistent.addParameter(params.get("p_acmp_yyyy").trim());
            persistent.addParameter(params.get("p_soc_cd").trim());
            
            
            
          //System.out.println(persistent.getParameters());
          //System.out.println(sqlstr.toString());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	//System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	
	private boolean update_issue(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
    sqlstr.append("             UPDATE RESULT_PLOOF_INFO SET                  \n")
            .append("                   PROG_STAT_CD  = ?              \n")
            .append("                 WHERE CORP_ID = ?                        \n")
            .append("                 AND SUB_CONT_MOD_ID = ?                        \n")
            .append("                 AND ACMP_YYYY = ?                        \n")
            .append("                 AND SOC_CD = ?                        \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("prog_stat_cd").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            persistent.addParameter(params.get("p_sub_cont_mod_id").trim());
            persistent.addParameter(params.get("p_acmp_yyyy").trim());
            persistent.addParameter(params.get("p_soc_cd").trim());
            
            
            
          //System.out.println(persistent.getParameters());
          //System.out.println(sqlstr.toString());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	//System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	
	private boolean deleteInfo(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
    sqlstr.append("             DELETE FROM  RESULT_PLOOF_INFO                   \n")
            .append("                 WHERE CORP_ID = ?                        \n")
            .append("                 AND SUB_CONT_MOD_ID = ?                        \n")
            .append("                 AND ACMP_YYYY = ?                        \n")
            .append("                 AND SOC_CD = ?                        \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("p_corp_id").trim());
            persistent.addParameter(params.get("p_sub_cont_mod_id").trim());
            persistent.addParameter(params.get("p_acmp_yyyy").trim());
            persistent.addParameter(params.get("p_soc_cd").trim());
            
            
            
          //System.out.println(persistent.getParameters());
          //System.out.println(sqlstr.toString());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	//System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	
	private boolean deleteDetail(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sqlstr.append("             DELETE FROM  RESULT_PLOOF_DETAIL                   \n")
                    .append("                 WHERE SUB_CONT_MOD_ID = ?                        \n")
                    .append("                 AND ACMP_YYYY = ?                        \n")
                    .append("                 AND SOC_CD = ?                        \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("p_sub_cont_mod_id").trim());
            persistent.addParameter(params.get("p_acmp_yyyy").trim());
            persistent.addParameter(params.get("p_soc_cd").trim());
            
            
            
          //System.out.println(persistent.getParameters());
          //System.out.println(sqlstr.toString());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	//System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	
	
	
	
	public void test() throws Exception
	{
	    ReportingServerInvoker invoker = new ReportingServerInvoker("http://211.38.140.244:8090/ReportingServer/service");
	      
	      invoker.setCharacterEncoding("euc-kr"); //캐릭터셋
	      invoker.setReconnectionCount(3);        //재접속 시도 회수
	      invoker.setConnectTimeout(10000);           //커넥션 타임아웃
	      invoker.setReadTimeout(30000);             //송수신 타임아웃

	      
	      invoker.addParameter("opcode", "500");
	      invoker.addParameter("mrd_path", "http://211.38.140.244:8082/report/mrd/buyer/supplier/outside/OutSupplierReport.mrd");
//	       invoker.addParameter("mrd_path", "/report/mrd/buyer/supplier/purchase/PuSupplierReport.mrd");
//	       invoker.addParameter("mrd_path", "http://211.38.140.244:8090/ReportingServer/mrd/qqqq.mrd");
	      invoker.addParameter("mrd_param", "/rp [79] [1] [2014]");
	      
//	       invoker.addParameter("mrd_param", "/rp [79]  [1]  [2014]");
	     
	      invoker.addParameter("export_type", "pdf");
	      invoker.addParameter("export_name","");
	      invoker.addParameter("protocol", "file");
	      
	      try
	      {
	        // 방법 1,2,3 중 한 가지를 선택하여 사용.
	                 // 방법 1 : 파일 경로 전달
//	      invoker.invoke("C:/test.pdf"); 
	        
	        // 방법 2 : 파일 객체 전달
	        invoker.invoke(new File("C:/pdf_test.pdf"));
	        
	        // 방법 3 : 스트림 전달
	        /*
	        InputStream is = null;
	        OutputStream os = null;
	        try
	        {
	           is = invoker.invokeAndGetStream();
	           os = new FileOutputStream(new File("C:/test.pdf"));
	                    
	           byte[] buffer = new byte[102400];
	           int read = -1;
	           while((read = is.read(buffer)) != -1)
	           {
	              os.write(buffer, 0, read);
	           }
	        }
	        finally
	        {
	        try{ if(is != null) is.close(); } catch(IOException ignore){}
	            try{ if(os != null) os.close(); } catch(IOException ignore){}
	                    
	            invoker.disconnect();
	        }
	      */
	      
	      }
	      catch(InvokerException e)
	      {
	         e.printStackTrace();
	         invoker.disconnect();
	      
	      }
	      
	      invoker.disconnect();
	}
	
	public boolean CONT_SignOk(Connection connection, ValueObject valueObject) throws Exception {

        Persistent persistent = new PersistentImpl(connection);
        StrBuffer sqlstr = new StrBuffer();
        try {
        	sqlstr.append("UPDATE RESULT_PLOOF_INFO SET  	\n");
        	sqlstr.append(" SUPP_SIGN_DT = SYSDATE					\n");
        	sqlstr.append(" ,SUPP_SIGN_USER = ?					\n");
        	sqlstr.append(" ,SUPP_SIGN_DATA = ?					\n");
        	sqlstr.append("WHERE SUB_CONT_MOD_ID = ?						\n");
        	sqlstr.append(" 	AND SIGN_SEQ=2						\n");
        	sqlstr.append("     AND SOC_CD = ?                        \n");
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(valueObject.get("CONT_SIGNDN"));
            persistent.addParameter(valueObject.get("CONT_SIGNDATA"));
            persistent.addParameter(valueObject.get("SUB_CONT_MOD_ID"));
            persistent.addParameter(valueObject.get("p_soc_cd"));
            persistent.execute();
            
            return true;
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> updUser() : " + e.getMessage());
            WAFLogger.error("SQL : " + sqlstr);
            WAFLogger.error(e);
            //System.out.println("Exception : " + e.getMessage());
            throw e;
        }
    }	
	
	public void createPdf(ValueObject params) throws Exception
	{
		System.out.println("미리보기 생성중");
	    ReportingServerInvoker invoker = new ReportingServerInvoker(WAFConfig.get("waf.rd_report.searver"));
	      
	      invoker.setCharacterEncoding("euc-kr"); //캐릭터셋
	      invoker.setReconnectionCount(3);        //재접속 시도 회수
	      invoker.setConnectTimeout(10000);           //커넥션 타임아웃
	      invoker.setReadTimeout(30000);             //송수신 타임아웃
	      
	      
//	      String rd_path = WAFConfig.get("waf.rd_report.path.root");
	      String sever_root = WAFConfig.get("waf.ServerURL");
	      
	      invoker.addParameter("opcode", "500");
	      
	      if(params.get("soc_cd").equals("01"))
	      {
	          invoker.addParameter("mrd_path", sever_root + "/report/mrd/buyer/supplier/buld_application2.mrd");
	          invoker.addParameter("mrd_param", "/rp ["+params.get("corp_id")+"] ["+params.get("sub_cont_mod_id")+"] ["+params.get("acmp_yyyy")+"] ["+params.get("soc_cd")+"]");  // CORP_ID, SUB_CONT_MOD_ID, ACMP_YYYY
	      }
	      else if(params.get("soc_cd").equals("02"))
          {
              invoker.addParameter("mrd_path", sever_root + "/report/mrd/buyer/supplier/buld_application.mrd");
              invoker.addParameter("mrd_param", "/rp ["+params.get("corp_id")+"] ["+params.get("sub_cont_mod_id")+"] ["+params.get("acmp_yyyy")+"] ["+params.get("soc_cd")+"]");  // CORP_ID, SUB_CONT_MOD_ID, ACMP_YYYY
          }
	      else if(params.get("soc_cd").equals("03"))
          {
              invoker.addParameter("mrd_path", sever_root + "/report/mrd/buyer/supplier/fire_application.mrd");
              invoker.addParameter("mrd_param", "/rp ["+params.get("corp_id")+"] ["+params.get("sub_cont_mod_id")+"] ["+params.get("acmp_yyyy")+"] ["+params.get("soc_cd")+"]");  // CORP_ID, SUB_CONT_MOD_ID, ACMP_YYYY
          }
	      else if(params.get("soc_cd").equals("04"))
          {
              invoker.addParameter("mrd_path", sever_root + "/report/mrd/buyer/supplier/info_application.mrd");
              invoker.addParameter("mrd_param", "/rp ["+params.get("corp_id")+"] ["+params.get("sub_cont_mod_id")+"] ["+params.get("acmp_yyyy")+"] ["+params.get("soc_cd")+"]");  // CORP_ID, SUB_CONT_MOD_ID, ACMP_YYYY
          }
	      else if(params.get("soc_cd").equals("05"))
          {
              invoker.addParameter("mrd_path", sever_root + "/report/mrd/buyer/supplier/electricity_application.mrd");
              invoker.addParameter("mrd_param", "/rp ["+params.get("corp_id")+"] ["+params.get("sub_cont_mod_id")+"] ["+params.get("acmp_yyyy")+"] ["+params.get("soc_cd")+"]");  // CORP_ID, SUB_CONT_MOD_ID, ACMP_YYYY
          }
	      
	      WAFLogger.debug(params.get("corp_id"));
	      WAFLogger.debug(params.get("sub_cont_mod_id"));
	      WAFLogger.debug(params.get("acmp_yyyy"));
	      WAFLogger.debug(params.get("soc_cd"));
	      
	      
	      invoker.addParameter("export_type", "pdf");
	      invoker.addParameter("export_name","");
	      invoker.addParameter("protocol", "file");
	      
	      try
	      {
	    	  FileListWorkerSaveHtmlBiz fileSave = new FileListWorkerSaveHtmlBiz(storage);
	          FileListWorkerDelBiz delFile = new FileListWorkerDelBiz(storage);
	          
              
	        // 방법 1,2,3 중 한 가지를 선택하여 사용.
	                 // 방법 1 : 파일 경로 전달
//	      invoker.invoke("C:/test.pdf"); 
	        
		        // 방법 2 : 파일 객체 전달
	           String path = WAFConfig.get("waf.repository.path") + "/";
	           String yyyymmdd = (new java.text.SimpleDateFormat ("yyyyMMdd")).format (new java.util.Date());
	           String yyyymm = (new java.text.SimpleDateFormat ("yyyyMM")).format (new java.util.Date());
		          
		        String fileName = "";
		        String saveFileName = "";
		        
		        if(params.get("soc_cd").equals("01"))
		        {
		            fileName = "대한전문건설협회_실적증명서";
		            saveFileName ="preview";
		        }
		        else if(params.get("soc_cd").equals("02"))
		        {
		            fileName = "대한기계설비공사협회_실적증명서";
		            saveFileName ="preview";
		        }
		        else if(params.get("soc_cd").equals("03"))
		        {
		            fileName = "한국소방시설협회_실적증명서";
		            saveFileName ="preview";
		        }
		        else if(params.get("soc_cd").equals("04"))
		        {
		            fileName = "한국정보통신공사협회_실적증명서";
		            saveFileName ="preview";
		        }
		        else if(params.get("soc_cd").equals("05"))
		        {
		            fileName = "한국전기공사협회_실적증명서";
		            saveFileName ="preview";
		        }
		        
		        
		        RowSet fileRowSet = FileManager.getFileList("RESULT_PDF", params.get("sub_cont_mod_id")+params.get("soc_cd")+params.get("p_acmp_yyyy"));
		        if(fileRowSet.size() != 0)
		        {
	           	   	String file_map_id[] =  {fileRowSet.getRow(0).get("FILE_MAP_ID")};
	           	   	delFile.delFiles(file_map_id);
		        }
		        
		        File file = new File(path + "result/" + params.get("sub_cont_mod_id") + "/" +  params.get("acmp_yyyy"));
		           if(!file.exists()){
		                //없다면 생성
		               file.mkdirs(); 
		           }
		           
		           
		        
		        invoker.invoke(new File(path + "result/" + params.get("sub_cont_mod_id") + "/" +  params.get("acmp_yyyy") + "/" + saveFileName + "_" + params.get("corp_id") + ".pdf"));
		        
		        
		        // 방법 3 : 스트림 전달
		        /*
		        InputStream is = null;
		        OutputStream os = null;
		        try
		        {
		           is = invoker.invokeAndGetStream();
		           os = new FileOutputStream(new File("C:/test.pdf"));
		                     
		           byte[] buffer = new byte[102400];
		           int read = -1;
		           while((read = is.read(buffer)) != -1)
		           {
		              os.write(buffer, 0, read);
		           }
		        }
		        finally
		        {
		        try{ if(is != null) is.close(); } catch(IOException ignore){}
		            try{ if(os != null) os.close(); } catch(IOException ignore){}
		                    
		            invoker.disconnect();
		        }
		      */
		        
		        
		        
		           
		           /*
		           // 삭제할 파일맵에 연결된 FILE_ID를 가진 RowSet을 리턴한다.
		           RowSet fileIDrowSet =getFileIDRowSet(conn.getConnection(), fileRowSet.getRow(0).get("FILE_MAP_ID"));
		
		           // 파일맵 삭제
		           delFileMap(conn.getConnection(), fileRowSet.getRow(0).get("FILE_MAP_ID"));
		           
		           // 파일맵과 연결이 끈어진 파일 정보를 삭제한다.
		           FileManager fileManager = new FileManager();
		           fileManager.delDisConnectFileProc(conn.getConnection(), fileIDrowSet);
		           */
		           
		        WAFLogger.debug("fileRowSet=====?????==============>" + fileRowSet.size());
		           
		           boolean success = fileSave.addFilesProc(new File(path + "result/" + params.get("sub_cont_mod_id") + "/" +  params.get("acmp_yyyy") + "/" + saveFileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf"), fileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf", "", "RESULT_PDF", params.get("sub_cont_mod_id")+params.get("soc_cd")+params.get("p_acmp_yyyy"), "");
	          
//	              if(fileRowSet.size() != 0)
//	              {
//	                  boolean success = fileSave.addFilesProc(new File(path + "result/" + params.get("sub_cont_mod_id") + "/" +  params.get("acmp_yyyy") + "/" + saveFileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf"), fileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf", "", "RESULT_PDF", params.get("sub_cont_mod_id")+params.get("soc_cd"), "");
//	              }
//	              else
//	              {
//	                  boolean success = fileSave.addFilesProc(new File(path + "result/" + params.get("sub_cont_mod_id") + "/" +  params.get("acmp_yyyy") + "/" + saveFileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf"), fileName + "_" + yyyymmdd + "_" + params.get("corp_id") + ".pdf", "", "RESULT_PDF", params.get("sub_cont_mod_id")+params.get("soc_cd"), "");
//	              }
	              
	      }
	      catch(InvokerException e)
	      {
	    	  WAFLogger.error("=================>" + e);
	    	  e.printStackTrace();
	    	  invoker.disconnect();
	      
	      }
	      
	      invoker.disconnect();
	}
	
}