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



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

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.util.ValueObject;
import m2soft.ers.invoker.InvokerException;
import m2soft.ers.invoker.http.ReportingServerInvoker;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.modular.web.ibsheet7.util.IBSheet7Utils;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;





public class PurResultDetail03SaveBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception 
	{
		WAFLogger.debug(":::::::::::::::::::::::::::::::::::::::::::::::::::::::PurResultDetail03SaveBiz 내부::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
	    
	    if(storage.compareEvent("SAVE_LIST"))
        {
            boolean success = false;
            boolean success2 = false;
            String[] status = super.gets("sheet1.STATUS");
            
            try 
            {
                conn.begin();
                Connection con = conn.getConnection();
                
                
                success = save_data(con, params); 
                
                for (int i = 0; i < status.length; i++) 
                {
                	WAFLogger.debug(IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success2 = save_sheet(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    }
                }
                
                storage.setSuccess(true);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
                
            } catch (Exception e) {
            	WAFLogger.error("save_data e======>" + e);
                e.printStackTrace();
                storage.setSuccess(false);
                conn.setRollback();
            } finally {
                conn.end();
            }
            
        }
	    else if(storage.compareEvent("UPDATE_DATA"))
	    {
            boolean success = false;
            boolean success2 = true;
            boolean success3 = true;
            String[] status = super.gets("sheet1.STATUS");
            
            try 
            {
                conn.begin();
                Connection con = conn.getConnection();
                
                success = update_data(con, params); 
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success2 = save_sheet(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    }
                    else if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                    {
                        success2 = update_sheet(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    }
                    else if (IBSheet7Utils.equalStatusDelete(status[i])) 
                    {
                        success2 = delete_sheet(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    }
                }
                
                storage.setSuccess(true);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
                
            } catch (Exception e) {
            	storage.setSuccess(false);
                storage.setMessage(e.getMessage());
                storage.setDetailMessage(e);;
                conn.setRollback();
            } finally {
                conn.end();
            }
	    }
	    else if(storage.compareEvent("UPDATE_ISSUE"))
        {
            boolean success = false;
            
            try 
            {
                conn.begin();
                
                success = update_issue(params); 
                
                System.out.println(success);
                
            } catch (Exception e) {
            	storage.setSuccess(false);
                storage.setMessage(e.getMessage());
                storage.setDetailMessage(e);;
                conn.setRollback();
            } finally {
                conn.end();
            }
            
            
            if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
            }
            
            storage.setSuccess(success);
        }
	    
    }
	
	private boolean save_data(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            sqlstr.append("             INSERT INTO PUR_RESULT_PLOOF_INFO                   \n")
            .append("               (                                               \n")
            .append("                   PUR_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("                 , BID_RESULT               \n")//2016.1.8
            .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") //2016.1.8
            .append("                 ,  ?                                       \n")
            .append("                 ,  ?                                       \n")
            .append("               )                                            \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("pur_cont_mod_id").trim());
            persistent.addParameter(params.get("acmp_yyyy").trim());
            persistent.addParameter(params.get("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("corp_id").trim());
            persistent.addParameter(params.get("con_amt").trim());
            persistent.addParameter(params.get("bid_yb").trim());
            persistent.addParameter(params.get("ADD_01").trim());
            persistent.addParameter(params.get("ADD_02").trim());
            
            
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	
	private boolean update_data(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
    sqlstr.append("             UPDATE PUR_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("                 , CONT_LOC_NO  = ?                                           \n")
            .append("                 , WORK_PLACE  = ?                                           \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("                 , SUB_AMT  = ?                                           \n")
            .append("                 , ENTRY_NO  = ?                                           \n")
            .append("                 , OTHER_PAY_AMT  = ?                                           \n")
            .append("                 , CUR_CONT_AAMT  = ?                                           \n")
            .append("                 , PRV_PAY_NAMT  = ?                                           \n")
            .append("                 , BID_RESULT  = ?                                           \n")
            .append("                 , ADD_01  = ?                                           \n")
            .append("                 , ADD_02  = ?                                           \n")
            .append("                 WHERE CORP_ID = ?                        \n")
            .append("                 AND PUR_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("cont_loc_no").trim());
            persistent.addParameter(params.get("work_place").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("sub_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("entry_no").trim().replace(",", ""));
            persistent.addParameter(params.get("other_pay_amt").trim().replace(",", ""));
            persistent.addParameter(params.get("cur_cont_aamt").trim().replace(",", ""));
            persistent.addParameter(params.get("prv_pay_namt").trim().replace(",", ""));
            persistent.addParameter(params.get("BID_YB").trim());
            persistent.addParameter(params.get("ADD_01").trim());
            persistent.addParameter(params.get("ADD_02").trim());
            
            persistent.addParameter(params.get("corp_id").trim());
            persistent.addParameter(params.get("pur_cont_mod_id").trim());
            persistent.addParameter(params.get("acmp_yyyy").trim());
            persistent.addParameter(params.get("soc_cd").trim());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	
	private boolean update_issue(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(conn.getConnection());
            
    sqlstr.append("             UPDATE PUR_RESULT_PLOOF_INFO SET                  \n")
            .append("                   PROG_STAT_CD  = ?              \n")
            .append("                 WHERE CORP_ID = ?                        \n")
            .append("                 AND PUR_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("corp_id").trim());
            persistent.addParameter(params.get("pur_cont_mod_id").trim());
            persistent.addParameter(params.get("acmp_yyyy").trim());
            persistent.addParameter(params.get("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();
	}
	
	
	
	private boolean save_sheet(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    INSERT INTO PUR_RESULT_PLOOF_DETAIL          \n ");
            sql.append("    (                                           \n ");
            sql.append("          SEQ                                   \n ");
            sql.append("        , PUR_CONT_MOD_ID                             \n ");
            sql.append("        , ACMP_YYYY                             \n ");
            sql.append("        , SOC_CD                   \n ");
            sql.append("        , CONT_NM                   \n ");
            sql.append("        , CONT_SDATE                   \n ");
            sql.append("        , CONT_EDATE                   \n ");
            sql.append("        , CONT_AMT                   \n ");
            sql.append("        , PRV_PAY_AMT                   \n ");
            sql.append("        , CUR_PAY_AMT                   \n ");
            sql.append("        , SCONT_AMT                   \n ");
            sql.append("        , PAY_NAMT                   \n ");
            sql.append("        , SUB_SOC_CD                   \n ");
            sql.append("        , UPD_DATE                   \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          (SELECT DECODE(MAX(SEQ), '', 1, MAX(SEQ)+1) FROM  PUR_RESULT_PLOOF_DETAIL WHERE PUR_CONT_MOD_ID = ? AND SOC_CD = ?  AND ACMP_YYYY = ? )                                   \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , ?                                   \n ");
            sql.append("        , SYSDATE                                   \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("pur_cont_mod_id"));
            persistent.addParameter(params.get("soc_cd"));
            persistent.addParameter(params.get("acmp_yyyy"));
            persistent.addParameter(params.get("pur_cont_mod_id"));
            persistent.addParameter(params.get("acmp_yyyy"));
            persistent.addParameter(params.get("soc_cd"));
            
            persistent.addParameter(sqlParams.get("cont_nm"));
            persistent.addParameter(sqlParams.get("cont_sdate"));
            persistent.addParameter(sqlParams.get("cont_edate"));
            persistent.addParameter(sqlParams.get("scont_amt"));
            persistent.addParameter(sqlParams.get("prv_pay_amt"));
            persistent.addParameter(sqlParams.get("cur_pay_amt"));
            persistent.addParameter(sqlParams.get("scont_amt"));
            persistent.addParameter(sqlParams.get("pay_namt"));
            persistent.addParameter(sqlParams.get("sub_soc_cd"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
	
	
	private boolean update_sheet(Connection con, ValueObject sqlParams) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            sqlstr.append("    UPDATE PUR_RESULT_PLOOF_DETAIL SET                  \n")
                   .append("        , CONT_NM                   \n ")
                   .append("        , CONT_SDATE                   \n ")
                   .append("        , CONT_EDATE                   \n ")
                   .append("        , CONT_AMT                   \n ")
                   .append("        , PRV_PAY_AMT                   \n ")
                   .append("        , CUR_PAY_AMT                   \n ")
                   .append("        , SCONT_AMT                   \n ")
                   .append("        , PAY_NAMT                   \n ")
                   .append("        , SUB_SOC_CD                   \n ")
                   .append("        , UPD_DATE                   \n ")
                   .append("    WHERE CORP_ID = ?                        \n")
                   .append("        AND PUR_CONT_MOD_ID = ?                        \n")
                   .append("        AND ACMP_YYYY = ?                        \n")
                   .append("        AND SOC_CD = ?                        \n")
                   .append("        AND SEQ = ?                        \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(sqlParams.get("cont_nm"));
            persistent.addParameter(sqlParams.get("cont_sdate"));
            persistent.addParameter(sqlParams.get("cont_edate"));
            persistent.addParameter(sqlParams.get("scont_amt"));
            persistent.addParameter(sqlParams.get("prv_pay_amt"));
            persistent.addParameter(sqlParams.get("cur_pay_amt"));
            persistent.addParameter(sqlParams.get("scont_amt"));
            persistent.addParameter(sqlParams.get("pay_namt"));
            
            
            persistent.addParameter(sqlParams.get("pur_cont_mod_id").trim());
            persistent.addParameter(sqlParams.get("acmp_yyyy").trim());
            persistent.addParameter(sqlParams.get("soc_cd").trim());
            persistent.addParameter(sqlParams.get("seq").trim());
            
            
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	private boolean delete_sheet(Connection con, ValueObject sqlParams) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            sqlstr.append("    DELETE FROM  PUR_RESULT_PLOOF_DETAIL                   \n")
                   .append("    WHERE  PUR_CONT_MOD_ID = ?                        \n")
                   .append("        AND ACMP_YYYY = ?                        \n")
                   .append("        AND SOC_CD = ?                        \n")
                   .append("        AND SEQ = ?                        \n");
            
            
            persistent.setStatement(sqlstr.toString());
            
            persistent.addParameter(sqlParams.get("pur_cont_mod_id").trim());
            persistent.addParameter(sqlParams.get("acmp_yyyy").trim());
            persistent.addParameter(sqlParams.get("soc_cd").trim());
            persistent.addParameter(sqlParams.get("seq").trim());
            
            
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	
	
	
}