/**
 * @(#)file    PuSupplierBiz.java
 * @(#)author  이성민
 * @(#)version 1.0
 * @(#)date    2014.06.25
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of udapsoft Inc.
 */
package kr.co.udapsoft.ebid.buyer.supplier.purchase.biz;



import java.sql.Connection;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.Row;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.sql.util.RowSetUtility;
import kr.co.hsnc.common.util.ValueObject;
import kr.co.udapsoft.common.code.CommCodeManager;
import kr.co.udapsoft.ebid.buyer.common.file.FileManager;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

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






public class PuSupplierBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception {

		
		
		WAFLogger.debug("event==============>" + storage.getEvent());
		
		if(storage.compareEvent("GET_DETAIL"))
		{
//	        RowSet acctTypeRowSet = common.getAcctTypeUseRowSet(storage.getUser().get("ACCT_TYPE_CODE"));
//	        storage.addRowSet("AcctTypeRowSet", acctTypeRowSet);
			
		    String yyyy = (new java.text.SimpleDateFormat ("yyyy")).format (new java.util.Date());
		    params.set("p_base_year", Integer.parseInt(yyyy) -1);
		    
		    ValueObject basicVo = new ValueObject();
		    ValueObject corpInfoVo = new ValueObject();
		    RowSet nationRowSet = getNationList(params);          
		    
		    RowSet rowset = null;
            
            
	        corpInfoVo = getCorpInfoList(params);
            basicVo = getSuppJoinRequestList(params);
            
            if(basicVo.get("MFTR_DIV_CD").equals("1"))
            {
                params.set("p_doc_cd", "01");
            }
            else
            {
                params.set("p_doc_cd", "02");
            }
//            rowset = getApprSrdList(params);
            
            rowset = getApprYear(params);
            
            RowSet rowSet = getOutLicMaster_searchCombo();
            
            storage.addRowSet("getApprYearList", rowset);
            storage.addValueObject("corpInfoVo", corpInfoVo);
            storage.addValueObject("InfoBaseList", basicVo);
            storage.addRowSet("nationRowSet", nationRowSet);
            storage.addValueObject("TERMS_AGREE_INFO", getfilelist("TERMS_AGREE_INFO",basicVo.get("corp_id"),"TERMS_AGREE_INFO"));
            storage.addRowSet("licMasterList", rowSet);
            
		}
		else if(storage.compareEvent("GET_OUT_DETAIL"))
		{
		    String yyyy = (new java.text.SimpleDateFormat ("yyyy")).format (new java.util.Date());
            params.set("p_base_year", Integer.parseInt(yyyy) -1);
            
            ValueObject basicVo = new ValueObject();
            ValueObject corpInfoVo = new ValueObject();
            RowSet nationRowSet = getNationList(params);          
            
            RowSet rowset = null;
            
            
            corpInfoVo = getCorpInfoList(params);
            basicVo = getSuppJoinRequestList(params);
            
            if(basicVo.get("MFTR_DIV_CD").equals("1"))
            {
                params.set("p_doc_cd", "01");
            }
            else
            {
                params.set("p_doc_cd", "02");
            }
//            rowset = getApprSrdList(params);
            
            rowset = getApprYear(params);
            
            RowSet rowSet = getOutLicMaster_searchCombo();
            
            storage.addRowSet("getApprYearList", rowset);
            storage.addValueObject("corpInfoVo", corpInfoVo);
            storage.addValueObject("InfoBaseList", basicVo);
            storage.addRowSet("nationRowSet", nationRowSet);
            storage.addValueObject("TERMS_AGREE_INFO", getfilelist("TERMS_AGREE_INFO",basicVo.get("corp_id"),"TERMS_AGREE_INFO"));
            storage.addRowSet("licMasterList", rowSet);            
		}
		else if(storage.compareEvent("REG_DATA"))
		{
		    String yyyy = (new java.text.SimpleDateFormat ("yyyy")).format (new java.util.Date());
            params.set("p_base_year", Integer.parseInt(yyyy) -1);
            
            ValueObject corp_id = getCorp_id(super.conn.getConnection()); 
            params.set("p_corp_id", corp_id.get("SEQ"));
            
            ValueObject basicVo = new ValueObject();
            ValueObject corpInfoVo = new ValueObject();
            RowSet rowset = null;
            RowSet nationRowSet = null;
            
            
            if(params.get("p_doc_cd").trim().equals(""))
            {
                params.set("p_doc_cd", "11");
            }
            
            
            corpInfoVo = getCorpInfoList(params);
            basicVo = getSuppJoinRequestList(params);
            rowset = getApprYear(params);
            nationRowSet = getNationList(params);   
            
            RowSet rowSet = getOutLicMaster_searchCombo();
            
            storage.addRowSet("getApprYearList", rowset);
            storage.addValueObject("corpInfoVo", corpInfoVo);
            storage.addValueObject("InfoBaseList", basicVo);
            storage.addRowSet("nationRowSet", nationRowSet);
            storage.addValueObject("TERMS_AGREE_INFO", getfilelist("TERMS_AGREE_INFO",params.get("p_corp_id"),"TERMS_AGREE_INFO"));
            storage.addRowSet("licMasterList", rowSet);
		}
//		else if(storage.compareEvent("GET_APPR_STD_LIST"))
//        {
//            RowSet rowset = null;
//            rowset = getApprSrdList(params);
//		    
//		    storage.addRowSet("ROWSET", rowset);
//            super.storage.setSuccess(true);
//            
//        }
		else if(storage.compareEvent("SAVE_DATA"))
        {
		    //WAFLogger.debug("=================================================");
		    boolean success = false;
		    
		    success = updateInfo(params);
		    
		    if(success == true)
            {
                String message = "등록성공";
                ValueObject errMsg = new ValueObject();
                errMsg.set("errMsg", message);
                storage.addValueObject("VALUEOBJECT", errMsg);
                
                super.storage.setSuccess(success);
            }
            
		    //storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
		else if(storage.compareEvent("GET_LIST"))
        {
            RowSet rowset = null;
            
            rowset = getList(params);
            
            
            //getList2
            
            Document xmlData = getXml(rowset);
            
            XMLOutputter xmlOutputter = new XMLOutputter();
            xmlOutputter.setFormat(Format.getRawFormat());
            
//            WAFLogger.debug(xmlOutputter.outputString(xmlData));
            
            storage.addObject("ibsheet7Data", xmlData);
        }
		else if(storage.compareEvent("GET_MY_LIST"))
        {
            params.set("sheet2", getList2(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
		else if(storage.compareEvent("GET_APPR_LIST"))
        {
            
            params.set("sheet3", geApprtList(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
		else if(storage.compareEvent("GET_CHARGE_LIST"))
        {
		    params.set("sheet4", getSuppCarge(params));
		    storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
		else if(storage.compareEvent("GET_DELIVER_LIST"))
        {
            params.set("sheet5", getDeliverList(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
		else if(storage.compareEvent("GET_CRET_LIST"))
        {
            params.set("sheet6", getCertList(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
        else if(storage.compareEvent("GET_PRIZE_LIST"))
        {
            params.set("sheet7", getSuppPrize(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
        else if(storage.compareEvent("GET_PATENT_LIST"))
        {
            params.set("sheet8", getSuppPatTent(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
        else if(storage.compareEvent("GET_CRET2_LIST"))
        {
            params.set("sheet9", getCert2List(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }		
	}
		
		
		
	
	
	
	/**
     * rowset 데이터를 ibsheet에 맞는 xml 형식으로 변환한다.(트리메뉴 사용시)
     * @param rowset
     * @return
     */
    public Document getXml(RowSet rowset)
    {
        
          Document doc = new Document();  
            
          Element root = new Element("Grid");
          
          Element pack = new Element("DATA");
          
          Element pack_tr = new Element("TR");
          
          Element pack_td = new Element("TD");
          
        try {

              root.addContent(pack);//root element 의 하위 element 를 만들기
              pack.addContent(pack_tr);
              pack_tr.addContent(pack_td);
              
              for(int i=0; i < rowset.size(); i++)
              {
                  if( i != 0)
                  {
                      pack_tr = new Element("TR");
                      pack.addContent(pack_tr);
                  }
                  
                  pack_tr.setAttribute("LEVEL", rowset.getRow(i).get("MATERIAL_LEVEL"));
                  
                  if( i != 0)
                  {
                      pack_td = new Element("TD");
                      pack_tr.addContent(pack_td);
                  }
                 
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("MATERIALGROUPNAME") + "]]>");
                  
                  pack_td = new Element("TD");
                  pack_tr.addContent(pack_td);
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("GUBUN_1") + "]]>");
                  
                  pack_td = new Element("TD");
                  pack_tr.addContent(pack_td);
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("GUBUN_2") + "]]>");
                  
                  pack_td = new Element("TD");
                  pack_tr.addContent(pack_td);
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("GUBUN_3") + "]]>");
                  
                  pack_td = new Element("TD");
                  pack_tr.addContent(pack_td);
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("MATERIAL_LEVEL") + "]]>");
                  
                  pack_td = new Element("TD");
                  pack_tr.addContent(pack_td);
                  pack_td.addContent("<![CDATA[" + rowset.getRow(i).get("MATERIALGROUP") + "]]>");
                  
                  
//                WAFLogger.debug(rowset.getRow(i).get("GUBUN_1") + "/" + rowset.getRow(i).get("GUBUN_2") + "/" + rowset.getRow(i).get("GUBUN_3"));
              }
              
              doc.setRootElement(root);
              
              
                  
              } catch (Exception e) {                                         
                  WAFLogger.debug("getXml===========> " +e.getMessage());
            	  System.err.println(e);                                        
              }
        return doc;
        
    }
    
    
    /**
     * 업체별 평가년도 가져오기
     * 
     */
     private RowSet getApprYear(ValueObject Params) {
         
         
         Search search = new SearchImpl();
         RowSet rowSet = new RowSetImpl();
         StringBuffer sqlStr = new StringBuffer();
         
         try {
             sqlStr.append(" SELECT SUBSTR(APPR_DY, 0, 4) APPR_DY, A.ARR_ID,A.DOC_CD , B.ADM_YEAR                            \n")                           
                   .append("   FROM SUPP_APPR A, SUPP_APPR_ITEM B                                                            \n")            
                   .append("  WHERE A.CORP_ID = B.CORP_ID AND A.ARR_ID = B.ARR_ID AND A.DOC_CD = B.DOC_CD AND A.CORP_ID = ?  \n") 
                   .append("  GROUP BY A.CORP_ID, A.ARR_ID, A.APPR_DY, A.DOC_CD, B.ADM_YEAR                                  \n") 
                   .append("  ORDER BY ARR_ID  DESC                                                                          \n"); 

             search.setStatement(sqlStr.toString());
             search.addParameter(params.get("p_corp_id").trim());
             rowSet = search.execute();
         }
         catch (WAFSQLException se) {
             super.doException(se);
             this.storage.setSuccess(false);
             this.storage.setMessage(se.getMessage());
             storage.setDetailMessage(se);
             se.printStackTrace();
         }
         finally {    
             if(rowSet == null) rowSet = new RowSetImpl();
             return rowSet;
         }
     }
     
     private RowSet getNationList(ValueObject Params) {
         
         
         Search search = new SearchImpl();
         RowSet rowSet = new RowSetImpl();
         StringBuffer sqlStr = new StringBuffer();
         
         try {
             sqlStr.append("    SELECT DETAILCD, DETAILNM                          \n")
                    .append("        FROM EBID_COM911T                              \n")
                    .append("    WHERE BASECD = 'NATION_CD'                         \n")
                    .append("    ORDER BY DETAILNM ASC                                   \n");
             

             search.setStatement(sqlStr.toString());
             rowSet = search.execute();
         }
         catch (WAFSQLException se) {
             super.doException(se);
             this.storage.setSuccess(false);
             this.storage.setMessage(se.getMessage());
             storage.setDetailMessage(se);
             se.printStackTrace();
         }
         finally {    
             if(rowSet == null) rowSet = new RowSetImpl();
             return rowSet;
         }
         
     }
     
    
    
    
    
    
    /**
     * 목록을 검색하여 리턴
     * @param Params
     * @return
     */
    private RowSet getList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            sqlStr.append("     SELECT                                                                                                                  \n")
                    .append("        MATERIAL_LEVEL,    MATERIALGROUPNAME  ,   MATERIALGROUP,                                  \n")
                    .append("        GUBUN_1,                                                                                                             \n")
                    .append("        GUBUN_2,                                                                                                         \n")
                    .append("        GUBUN_3                                                                                                         \n")
                    .append("        FROM        PMM_MATERIALGROUP_V                                                                  \n");
            
                
            
            search.setStatement(sqlStr.toString());
            //WAFLogger.debug(sqlStr.toString());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
        	WAFLogger.debug("getList ==================> " +se.getMessage());
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
    
    
    
    
    /**
     * 등록한 구분 목록
     * @param Params
     * @return
     */
    private RowSet getList2(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            sqlStr.append("         SELECT                                                                          \n")
                   .append("              B.GUBUN_1 KIND_BIG_NAME                                           \n")
                   .append("            , B.GUBUN_2 KIND_MID_NAME                                            \n")
                   .append("            , B.MATERIALGROUP                                                       \n")
                   .append("            , A.KIND_SMALL  ITEM_CODE                                          \n")
                   .append("            , A.CORP_ID                                                                 \n")
                   .append("            , B.GUBUN_3 KIND_SMALL_NAME                                     \n")
                   .append("            , DECODE(A.REPRE_YN, 'Y', '1', '0') MAIN_ITEM                   \n")
                   .append("        FROM SUPP_PUR_ITEM A, PMM_MATERIALGROUP_V B             \n")
                   .append("        WHERE A.KIND_SMALL = B.MATERIALGROUP                            \n")
                   .append("            AND A.CORP_ID = ?      ORDER BY  A.KIND_SMALL ASC         \n");
            
            
            /*   
            //Paging 처리를 위한 Helper Object 생성
            super.createPageAnchorInfo();
            //한페이지에 가져올 목록의 갯수 지정(미지정시  waf.properties 파일의 기본값을 사용)
            super.anchor.range = 10000;
            //Paging 처리에 사용될 Parameter를  세팅
            super.anchor.setParams(this.params);
            //검색할  SQL 세팅 : SQL은 Paging처리를 하지 않고 작성
            super.anchor.setSQL(sqlStr.toString());
            //전체 Record 숫자를 조회
            super.anchor.doTotalCountSQL(); // 전체 숫자를 조회
            
            //Paging처리가 된 SQL을 Helper Object에서 가져옴
            String temp = super.anchor.getPagingSQL();
            */
            
            
            
            search.setStatement(sqlStr.toString());
            search.addParameter(params.get("p_corp_id"));
            //WAFLogger.debug(sqlStr.toString());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
        	WAFLogger.debug("getList2=========>" + se.getMessage());
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
        	super.storage.setSuccess(true);
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
  
  
  
  
    private RowSet geApprtList(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
              /*
              sqlStr.append("            SELECT     \n")
                     .append("                      TO_CHAR(TO_DATE(CREDIT_STA_DY, 'YYYY-MM-DD'), 'YYYY-MM-DD') CREDIT_STA_DY        \n")
                     .append("                    , DECODE(CREDIT_CORP_CD, 'E', '이크레더블', 'S', '서울신용평가', 'N', '나이스디앤비', 'K', '한국기업데이터', 'M', '나이스평가정보') CREDIT_CORP_CD     \n")
                     .append("                    , CREDIT_GRADE             \n")
                     .append("                    , CASH_GRADE        \n")
                     .append("                    , CREDIT_END_DY     \n")
                     .append("                     FROM SUPP_INFO     \n")
                     .append("                    WHERE CORP_ID = ?      \n");
              */
              
              sqlStr.append("            SELECT     \n")
                      .append("                     'Y' CREDIT_YN        \n")
                      .append("                    ,TO_CHAR( TO_DATE(MAX(A.SUVDT), 'YYYY-MM-DD'), 'YYYY-MM-DD') CREDIT_STA_DY        \n")
                      .append("                    , DECODE(A.EVAL_CMP, 'E', '이크레더블', 'S', '서울신용평가', 'N', '나이스디앤비', 'K', '한국기업데이터', 'M', '나이스평가정보','없음') CREDIT_CORP_CD     \n")
                      .append("                    , LASTGRD2 CREDIT_GRADE        \n")
                      .append("                    , DECISION CASH_GRADE      \n")
                      .append("                    , EXPIRE_DATE CREDIT_END_DY     \n")
                      .append("                    , CHK_CREDIT(C.CORP_ID) CREDIT_GUBUN     \n")
                      .append("                    , A.EVAL_CMP GUBUN_CODE     \n")
                      .append("                     FROM DCC_PACKET01 A, DCC_PACKET11 B, SUPP_INFO C     \n")
                      .append("                    WHERE C.CORP_ID = ?      \n")
                      .append("                    AND A.RESNO = B.RESNO     \n")
                      .append("                    AND A.SUVDT = B.SUVDT     \n")
                      .append("                    AND B.RESNO = C.CORP_REG_NO   \n")
                      .append("                    AND A.EXPIRE_DATE > TO_CHAR(SYSDATE, 'YYYYMMDD')   \n")
                      .append("                    AND C.JOB_DIV = 'P'   \n")
                      .append("                    GROUP BY A.EVAL_CMP, A.LASTGRD2, B.DECISION, A.EXPIRE_DATE, C.CORP_ID    \n");
              
              
              /*   
              //Paging 처리를 위한 Helper Object 생성
              super.createPageAnchorInfo();
              //한페이지에 가져올 목록의 갯수 지정(미지정시  waf.properties 파일의 기본값을 사용)
              super.anchor.range = 10000;
              //Paging 처리에 사용될 Parameter를  세팅
              super.anchor.setParams(this.params);
              //검색할  SQL 세팅 : SQL은 Paging처리를 하지 않고 작성
              super.anchor.setSQL(sqlStr.toString());
              //전체 Record 숫자를 조회
              super.anchor.doTotalCountSQL(); // 전체 숫자를 조회
              
              //Paging처리가 된 SQL을 Helper Object에서 가져옴
              String temp = super.anchor.getPagingSQL();
              */
              
              
              
              search.setStatement(sqlStr.toString());
              //search.addParameter(params.get("p_corp_id"));
              search.addParameter(params.get("p_corp_id"));
              //WAFLogger.debug(sqlStr.toString());
             // WAFLogger.debug(search.getParameters());
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
  
      /**
       * 담당자 정보
       * @param Params
       * @return
       */
      private RowSet getSuppCarge(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
              sqlStr.append("            SELECT     \n")
                     .append("                      CORP_ID        \n")
                     .append("                    , USER_ID        \n")
                     .append("                    , PASSWD     \n")
                     .append("                    , CHARGE_SEQ        \n")
                     .append("                    , USER_NAME        \n")
                     .append("                    , DIVISION        \n")
                     .append("                    , POSITION     \n")
                     .append("                    , TEL_NUM     \n")
                     .append("                    , FAX_NUM     \n")
                     .append("                    , HP1     \n")
                     .append("                    , HP2     \n")
                   	 .append("                    , HP3     \n")
                   	 .append("                    , EMAIL     \n")
                     .append("                    , NOTE     \n")
                     .append("                    , '-' BAR1     \n")
                     .append("                    , '-' BAR2     \n")
                     .append("                     FROM SUPP_CHARGE    \n")
                     .append("                    WHERE CORP_ID = ?      \n");
                                                 
              
              
              /*   
              //Paging 처리를 위한 Helper Object 생성
              super.createPageAnchorInfo();
              //한페이지에 가져올 목록의 갯수 지정(미지정시  waf.properties 파일의 기본값을 사용)
              super.anchor.range = 10000;
              //Paging 처리에 사용될 Parameter를  세팅
              super.anchor.setParams(this.params);
              //검색할  SQL 세팅 : SQL은 Paging처리를 하지 않고 작성
              super.anchor.setSQL(sqlStr.toString());
              //전체 Record 숫자를 조회
              super.anchor.doTotalCountSQL(); // 전체 숫자를 조회
              
              //Paging처리가 된 SQL을 Helper Object에서 가져옴
              String temp = super.anchor.getPagingSQL();
              */
              
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              //WAFLogger.debug(sqlStr.toString());
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
  
  
  
      /**
       * 회사정보
       */
      public ValueObject getSuppJoinRequestList(ValueObject params){
          Search search = new SearchImpl();
          ValueObject vo = null;
          RowSet rowSet = new RowSetImpl();
          
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
      /*
          sqlstr.append("    SELECT                                                         \n")
                 .append("                        A.CORP_REG_NO                             \n")
                 .append("                      , A.CORP_KOR                             \n")
                 .append("                      , A.REP_NAME                             \n")
                 .append("                      , A.CORP_DIV_CD                             \n")
                 .append("                      , A.REG_REQ_DT                             \n")
                 .append("                      , A.CRE_DATE                             \n")
                 .append("                      , A.HEAD_CORP_REG_N                             \n")
                 .append("                      , A.SUB_PLACE_NO                             \n")
                 .append("                      , A.TAX_ADDR_CD                             \n")
                 .append("                      , DECODE(A.STATUS, '00', '가입요청', '01', '대기', '02', '가등록', '03', '등록', '91', '거래중지', '99', '거래취소') STATUS                             \n")
                 .append("                      , A.CORP_ID                             \n")
                 .append("                      , A.COPR_NO                             \n")
                 .append("                      , A.CORP_STS                             \n")
                 .append("                      , A.BIZ_FORM                             \n")
                 .append("                      , TO_CHAR(A.ESTA_DATE, 'YYYY-MM-DD') ESTA_DATE                             \n")
                 .append("                      , A.CORP_TEL                             \n")
                 .append("                      , A.CORP_FAX                             \n")
                 .append("                      , DECODE(TRIM(A.CORP_SCALE), '대기업', 'B', 'S') CORP_SCALE                             \n")
                 .append("                      , A.POST_NO                             \n")
                 .append("                      , A.ADDRESS                             \n")
                 .append("                      , A.PLACE_POST_NO                             \n")
                 .append("                      , A.PLACE_ADDRESS                             \n")
                 .append("                      , A.CREDIT_CORP_CD                             \n")
                 .append("                      , A.CREDIT_GRADE                             \n")
                 .append("                      , A.CASH_GRADE                             \n")
                 .append("                      , A.CREDIT_STA_DY                             \n")
                 .append("                      , A.CREDIT_END_DY                             \n")
                 .append("                      , A.FACTOR_CD                             \n")
                 .append("                      , A.MFTR_DIV_CD                             \n")
                 .append("                      , A.CREDIT_YN                             \n")
                 .append("                      , B.USER_NAME                             \n")
                 .append("                      , C.APPR_DY                             \n")
                 .append("                FROM SUPP_INFO A, SUPP_CHARGE B, SUPP_APPR C                             \n")
                 .append("                WHERE A.CORP_ID = B.CORP_ID                      \n")
                 .append("                  AND B.CORP_ID = C.CORP_ID(+)                      \n")
                 .append("                  AND B.DEFAULT_YN = 'Y'                        \n")             
                 .append("                  AND A.CORP_ID = ?                             \n");             
          */
              
              
              sqlstr.append("SELECT A.CORP_REG_NO                             								\n")
                    .append("       ,A.CORP_KOR                             								\n")
                    .append("       ,A.REP_NAME                             								\n")
                    .append("       ,A.CORP_DIV_CD                             								\n")
                    .append("       ,TO_CHAR(A.REG_REQ_DT, 'YYYY-MM-DD') REG_REQ_DT							\n")
                    .append("       ,A.CRE_DATE                             								\n")
                    .append("       ,A.HEAD_CORP_REG_N                             							\n")
                    .append("       ,A.SUB_PLACE_NO                             							\n")
                    .append("       ,A.TAX_ADDR_CD                             								\n")
                    .append("       ,F_GET_CODE_NAME('SUPP_INFO_STATUS',A.STATUS) STATUS					\n")
                    .append("       ,A.CORP_ID                             									\n")
                    .append("       ,A.COPR_NO                             									\n")
                    .append("       ,A.CORP_STS                             								\n")
                    .append("       ,A.BIZ_FORM                             								\n")
                    .append("       ,TO_CHAR(A.ESTA_DATE, 'YYYY-MM-DD') ESTA_DATE           				\n")
                    .append("       ,A.CORP_TEL                             								\n")
                    .append("       ,A.CORP_FAX                             								\n")
                    .append("       ,A.CORP_SCALE                             								\n")
                    .append("       ,A.POST_NO                             									\n")
                    .append("       ,A.ADDRESS                             									\n")
                    .append("       ,A.PLACE_POST_NO                             							\n")
                    .append("       ,A.PLACE_ADDRESS                             							\n")
                    .append("       ,A.CREDIT_CORP_CD                             							\n")
                    .append("       ,A.CREDIT_GRADE                             							\n")
                    .append("       ,A.CASH_GRADE                             								\n")
                    .append("       ,A.CREDIT_STA_DY                             							\n")
                    .append("       ,A.CREDIT_END_DY                             							\n")
                    .append("       ,A.FACTOR_CD                             								\n")
                    .append("       ,NVL(A.FACTOR_CONFIRM,'N') AS FACTOR_CONFIRM							\n")
                    .append("       ,DECODE(NVL(A.FACTOR_CONFIRM,'N'),'Y','승인','미승인') AS FACTOR_CONFIRM_NM	\n")
                    .append("       ,A.MFTR_DIV_CD                             								\n")
                    .append("       ,A.CREDIT_YN                             								\n")
                    .append("       ,B.APPR_DY                             									\n")
                    .append("       ,B.ARR_ID                             									\n")
                    .append("       ,B.ITEM_STD_CD                             								\n")
                    .append("       ,A.STATUS STATUS_CODE                             						\n")
                    .append("       ,TO_CHAR(TO_DATE(A.USE_END_DY, 'YYYY-MM-DD'), 'YYYY-MM-DD') USE_END_DY	\n")
                    .append("       ,TO_CHAR(A.REG_DT, 'YYYY-MM-DD') REG_DT                             	\n")
                    .append("       ,TO_CHAR(A.APPR_DT, 'YYYY-MM-DD') APPR_DT                             	\n")
                    .append("       ,TO_CHAR(A.CAN_DT, 'YYYY-MM-DD') CAN_DT                             	\n")
                    .append("       ,\"COMMENT\"                             								\n")
                    .append("       ,MANAGE_NO                              								\n")
                    .append("       ,NATION_CD                              								\n")
                    .append("       ,F_GET_USER_NM(A.UPD_BY ) MANAGE_NAME                              		\n")
                    .append("       ,A.BANK_CD                              								\n") //2019.04.24 은행코드,계좌 지정
                    .append("       ,A.BANK_NM                              								\n")
                    .append("       ,A.BANK_ACCT                              								\n")
                    .append("       ,A.UPD_BY                              									\n");
                      if(storage.compareEvent("GET_OUT_DETAIL"))
                      {
                          sqlstr.append("                      ,  C.USER_NAME                             \n")
                                  .append("                     ,  C.DIVISION                             \n")
                                  .append("                     ,  C.POSITION                             \n")
                                  .append("                     ,  C.EMAIL                             \n")
                                  .append("                     ,  C.TEL_NUM                             \n")
                                  .append("                     ,  C.FAX_NUM                             \n")
                                  .append("                     ,  C.HP1                             \n")
                                  .append("                     ,  C.HP2                             \n")
                                  .append("                     ,  C.HP3                             \n");
                      }
              sqlstr.append("                FROM SUPP_INFO A,                             \n")
                      .append("                            (SELECT ARR_ID, SUBSTR(APPR_DY, 0, 4) APPR_DY, CORP_ID, ITEM_STD_CD  FROM SUPP_APPR                         \n")
                      .append("                             WHERE CORP_ID = ?     AND ARR_ID = (SELECT MAX(ARR_ID) FROM SUPP_APPR WHERE CORP_ID = ? )                                                                                                                                                                              \n")
                      .append("                            ) B                                                                                                                                                               \n");
                       if(storage.compareEvent("GET_OUT_DETAIL"))
                      {
                           sqlstr.append("                 , SUPP_CHARGE C                              \n");   
                      }
              sqlstr.append("                WHERE A.CORP_ID = B.CORP_ID(+)                            \n");
                      if(storage.compareEvent("GET_OUT_DETAIL"))
                      {
                           sqlstr.append("                AND A.CORP_ID = C.CORP_ID AND C.DEFAULT_YN = 'Y'    \n");   
                      }
              sqlstr.append("                   AND A.CORP_ID = ?                             \n");
                      
                      
          
              search.setStatement(sqlstr.toString());
              search.addParameter(params.get("p_corp_id").trim());
              search.addParameter(params.get("p_corp_id").trim());
              search.addParameter(params.get("p_corp_id").trim());
              
              //WAFLogger.debug(sqlstr.toString());
              //WAFLogger.debug(search.getParameters());
              
              
              rowSet = search.execute();
              
              
              if(rowSet.size()>0){
                  vo = RowSetUtility.getValueObject(rowSet.getRow(0));
              }
              
          }catch(Exception e){
        	  WAFLogger.error("getSuppJoinRequestList===>" + e);
              e.printStackTrace();
              throw e;
          }finally{
              if( vo == null) vo = new ValueObject();
              return vo;
          }
      } 
      
      /**
       * 첨부파일
       * @param filegb
       * @param id
       * @param returnid
       * @return
       */
      private ValueObject getfilelist(String filegb,String id,String returnid){
          ValueObject vo = new ValueObject();
          RowSet rowSet = FileManager.getFileList(filegb, id);
          String str="";
              for(int i=0;i<rowSet.size();i++){
                  Row row=rowSet.getRow(i);
                  str += (i+1)+" : "+row.get("FILE_NAME")+" ("+ row.get("FILE_SIZE")+")";
                  if(i+1!=rowSet.size()){
                      str +="\r\n";
                  }
              }
              vo.set(returnid, str);
          return vo;
      }
      
      
      
      private RowSet getDeliverList(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
              
              
                  sqlStr.append("            SELECT DELI_CORP_NM -- 납품처명                      \n")
                          .append("                      ,DELI_CORP_NO-- 납품처사업자번호                      \n")
                          .append("                      ,ITEM_NM -- 품목명                      \n")
                          .append("                      ,CONT_AMT -- 계약금액                      \n")
                          .append("                      ,QTY -- 수량                      \n")
                          .append("                      ,STD -- 규격                      \n")
                          .append("                      ,DELI_START_DY -- 납품시작일부                      \n")
                          .append("                      ,DELI_END_DY -- 납품종료일                      \n")
                          .append("                      ,SEQ                      \n")
                          .append("                      ,DELI_FILE_ID                      \n")
                          .append("                      ,DELIRESULT_CONFIRM                      \n")
                          .append("                      ,CREDIT_END_DY                      \n")
                          .append("                      ,CREDIT_YN                      \n")
                          .append("                      ,DECODE(NVL(DELIRESULT_CONFIRM,'N'),'N','미승인','승인') AS DELIRESULT_CONFIRM_NM                      \n")
                          .append("                      ,(SELECT DECODE(DELI_FILE_ID, '0', '신평사인증',  DECODE (MAX (AA.FILE_ID), NULL, '파일첨부', '1'))      \n")
                          .append("                          FROM PUB0510T AA, PUB0500T BB                           \n")
                          .append("                         WHERE AA.FILE_ID = BB.FILE_ID                            \n")
                          .append("                           AND FILE_GB = 'DELIRESULT'                             \n")
                          .append("                           AND ID = A.DELI_FILE_ID)    AS FILE_YN                 \n")
                          .append("                      ,(SELECT MAX (AA.FILE_ID)                                   \n")
                          .append("                          FROM PUB0510T AA, PUB0500T BB                           \n")
                          .append("                         WHERE AA.FILE_ID = BB.FILE_ID                            \n")
                          .append("                           AND FILE_GB = 'DELIRESULT'                             \n")
                          .append("                           AND ID = A.DELI_FILE_ID)    AS FILE_ID                      \n")
                          .append("                      FROM SUPP_PUR_DELIRESULT A                    \n")
                          .append("                      WHERE CORP_ID = ?                      \n");
              
              
              
              /*
               
               sqlStr.append("            SELECT DELI_CORP_NM -- 납품처명                      \n")
                     .append("                      ,DELI_CORP_NO-- 납품처사업자번호                      \n")
                     .append("                      ,ITEM_NM -- 품목명                      \n")
                     .append("                      ,CONT_AMT -- 계약금액                      \n")
                     .append("                      ,QTY -- 수량                      \n")
                     .append("                      ,STD -- 규격                      \n")
                     .append("                      ,DELI_START_DY -- 납품시작일부                      \n")
                     .append("                      ,DELI_END_DY -- 납품종료일                      \n")
                     .append("                      FROM SUPP_PUR_DELIRESULT                      \n")
                     .append("                      WHERE CORP_ID = ?                      \n");
               
               
               */
                                                 
              
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              
              //WAFLogger.debug(sqlStr.toString());
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getDeliverList=========>" + se.getMessage());
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      
      private RowSet getCertList(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
              
                  sqlStr.append("            SELECT  CERT_DIV_CD -- 종류코드                             \n")
                          .append("                     , CERT_NO -- 인증번호                             \n")
                          .append("                     , CERT_CTNT -- 인증명                             \n")
                          .append("                     , CERT_SCOPE -- 인증범위                             \n")
                          .append("                     , CERT_GOV -- 인증기관                             \n")
                          .append("                     , EXP_STA_DY -- 취득일                             \n")
                          .append("                     , EXP_END_DY-- 만료일                             \n")
                          .append("                     , CERT_SEQ                          \n")
                          .append("                     , CERT_FILE_ID                      \n")
                          .append("                     , CERT_CONFIRM                      \n")
                          .append("                     ,CREDIT_END_DY                      \n")
                          .append("                     ,CREDIT_YN                      \n")
                          .append("                      ,DECODE(NVL(CERT_CONFIRM,'N'),'N','미승인','승인') AS CERT_CONFIRM_NM                                 \n")
                          .append("                      ,(SELECT DECODE(CERT_FILE_ID, '0', '신평사인증',  DECODE (MAX (AA.FILE_ID), NULL, '파일첨부', '1'))     \n")
                          .append("                          FROM PUB0510T AA, PUB0500T BB                           \n")
                          .append("                         WHERE AA.FILE_ID = BB.FILE_ID                            \n")
                          .append("                           AND FILE_GB = 'CERT'                             \n")
                          .append("                           AND ID = A.CERT_FILE_ID)    AS FILE_YN                 \n")
                          .append("                      ,(SELECT MAX (AA.FILE_ID)                                   \n")
                          .append("                          FROM PUB0510T AA, PUB0500T BB                           \n")
                          .append("                         WHERE AA.FILE_ID = BB.FILE_ID                            \n")
                          .append("                           AND FILE_GB = 'CERT'                             \n")
                          .append("                           AND ID = A.CERT_FILE_ID)    AS FILE_ID                      \n")
                          .append("                     FROM SUPP_CERT A                              \n")
                          .append("                     WHERE CORP_ID = ?                             \n");
              
              /*
              sqlStr.append("            SELECT CASE WHEN INSTR(REPLACE(CERT_DIV_CD,' ',''),'KOSHA') > 0 THEN '03'                               \n")
                      .append("                     WHEN INSTR(REPLACE(CERT_DIV_CD,' ',''),'KS') > 0 THEN '04'                             \n")
                      .append("                     WHEN INSTR(REPLACE(CERT_DIV_CD,' ',''),'ISO환경인증') > 0 THEN '02'                             \n")
                      .append("                     WHEN INSTR(REPLACE(CERT_DIV_CD,' ',''),'ISO') > 0 THEN '01'                             \n")
                      .append("                     ELSE '99'                             \n")
                      .append("                     END CERT_DIV_CD -- 종류코드                             \n")
                      .append("                     , CERT_NO -- 인증번호                             \n")
                      .append("                     , CERT_CTNT -- 인증명                             \n")
                      .append("                     , CERT_SCOPE -- 인증범위                             \n")
                      .append("                     , CERT_GOV -- 인증기관                             \n")
                      .append("                     , EXP_STA_DY -- 취득일                             \n")
                      .append("                     , EXP_END_DY-- 만료일                             \n")
                      .append("                     FROM SUPP_CERT                             \n")
                      .append("                     WHERE CORP_ID = ?                             \n");
              */

              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              
              
              //WAFLogger.debug(sqlStr.toString());
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getCertList=========>" + se.getMessage());
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      
      private RowSet getSuppPrize(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
                  sqlStr.append("           SELECT  PRZ_DY -- 수상일              \n")
                          .append("                     , PRZ_NM -- 수상자              \n")
                          .append("                     , PRZ_GIVER -- 수여자              \n")
                          .append("                     , PRZ_INFO -- 수상내용              \n")
                          .append("                     , PRZ_SEQ            \n")    
                          .append("                     , CREDIT_END_DY                      \n")
                          .append("                     , CREDIT_YN                      \n")
                          .append("                     FROM SUPP_PRIZE              \n")
                          .append("                     WHERE CORP_ID = ?              \n");
              
              /*
                sqlStr.append("           SELECT  PRZ_DY -- 수상일              \n")
                     .append("                     , PRZ_NM -- 수상자              \n")
                     .append("                     , PRZ_GIVER -- 수여자              \n")
                     .append("                     , PRZ_INFO -- 수상내용              \n")
                     .append("                     FROM SUPP_PRIZE              \n")
                     .append("                     WHERE CORP_ID = ?              \n");
               
               */
                                                 
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              
              
              
              //WAFLogger.debug(sqlStr.toString());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getSuppPrize=========>" + se.getMessage());
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      
      private RowSet getSuppPatTent(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
                  sqlStr.append("          SELECT CASE WHEN INSTR(TRIM(PAT_CD),'01') > 0 THEN '01'        \n")
                          .append("                    WHEN INSTR(TRIM(PAT_CD),'02') > 0 THEN '02'        \n")
                          .append("                    WHEN INSTR(TRIM(PAT_CD),'03') > 0 THEN '03'        \n")
                          .append("                    WHEN INSTR(TRIM(PAT_CD),'04') > 0 THEN '04'        \n")
                          .append("                    ELSE '99'                                                              \n")
                          .append("                    END PAT_CD -- 산업재산권 구분        \n")
                          .append("                    , PAT_DY -- 특허일        \n")
                          .append("                    , PAT_INFO -- 명칭        \n")
                          .append("                    , PAT_SEQ       \n")
                          .append("                    , CREDIT_END_DY                      \n")
                          .append("                    , CREDIT_YN                      \n")
                          .append("                    FROM SUPP_PATENT        \n")
                          .append("                    WHERE CORP_ID = ?                                             \n");
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              
              
              //WAFLogger.debug("getSuppPatTent====>" + sqlStr.toString()); 
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getSuppPrize=========>" + se.getMessage());
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      
      
      public ValueObject getCorpInfoList(ValueObject params){
          Search search = new SearchImpl();
          ValueObject vo = null;
          RowSet rowSet = new RowSetImpl();
          
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              sqlstr.append("     SELECT        BASE_YEAR-- 기준년도                                \n")
                      .append("                     ,CAPITAL_AMT -- 자본금                                \n")
                      .append("                     ,FLOAT_ASSET -- 유동자산                                \n")
                      .append("                     ,FLOAT_DEBT -- 유동부채                                \n")
                      .append("                     ,OWN_CAP-- 자기자본                                \n")
                      .append("                     ,TOT_CAP -- 총자본                                \n")
                      .append("                     ,CUR_PROFIT-- 당기순이익                                \n")
                      .append("                     ,GROSS_ASSET-- 총자산                                \n")
                      .append("                     ,SALES_AMT-- 매출액                                \n")
                      .append("                     ,CUR_SALES_AMT -- 당기매출액                                \n")
                      .append("                     ,PRI_SALES_AMT -- 전기매출액                                \n")
                      .append("                     ,CREDIT_END_DY                      \n")
                      .append("                     ,CREDIT_YN                      \n")
                      .append("                     ,CASE WHEN CREDIT_END_DY > TO_CHAR(SYSDATE,'YYYYMMDD') THEN 'Y' ELSE 'N' END AS RE_YN                      \n")
                      .append("                     FROM SUPP_FINANCE                                \n")
                      .append("                     WHERE  CORP_ID = ?                                \n");
                      //.append("                     AND BASE_YEAR = ?                                \n");
              
              
              search.setStatement(sqlstr.toString());
              search.addParameter(params.get("p_corp_id"));
              //search.addParameter(params.get("p_base_year"));
          
              //WAFLogger.debug(sqlstr.toString());
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
              
              if(rowSet.size()>0){
                  vo = RowSetUtility.getValueObject(rowSet.getRow(0));
              }
              
          }catch(Exception e){
              e.printStackTrace();
              WAFLogger.error("getCorpInfoList===>" + e.getMessage());
              
          }finally{
              if( vo == null) vo = new ValueObject();
              return vo;
          }
      }
      
      
      
      /**
       * 회사정보 저장
       * @param params
       * @return
       * @throws Exception
       */
      private boolean updateInfo(ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              conn.begin();
              persistent = new PersistentImpl(super.conn.getConnection());
              
              
              sqlstr.append("     UPDATE SUPP_INFO SET            \n")
                     .append("           HEAD_CORP_REG_N = ?           \n")
                     .append("          ,COPR_NO = ?           \n")
                     .append("          ,SUB_PLACE_NO = ?           \n")
                     .append("          ,CORP_KOR = ?           \n")
                     .append("          ,REP_NAME = ?           \n")
                     .append("          ,CORP_STS = ?           \n")
                     .append("          ,BIZ_FORM = ?           \n")
                     .append("          ,CORP_DIV_CD = ?           \n")
                     .append("          ,ESTA_DATE = ?           \n")
                     .append("          ,CORP_TEL = ?           \n")
                     .append("          ,CORP_FAX = ?           \n")
                     .append("          ,CORP_SCALE = ?           \n")
                     .append("          ,POST_NO = ?                     \n")
                     .append("          ,ADDRESS = ?                  \n")
                     .append("          ,PLACE_POST_NO = ?           \n")
                     .append("          ,PLACE_ADDRESS = ?        \n")
                     .append("          ,TAX_ADDR_CD = ?              \n")
                     .append("          ,FACTOR_CD = ?              \n")
                     .append("          ,MFTR_DIV_CD = ?              \n")
                     .append("          ,UPD_BY = ?                       \n")
                     .append("          ,UPD_DATE = sysdate           \n")
                     .append("          ,BANK_CD = ?                       \n")
                     .append("          ,BANK_NM = ?                       \n")
                     .append("          ,BANK_ACCT = ?                       \n")
                     .append("      WHERE CORP_ID = ?                 \n");
              
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("head_corp_reg_n"));
              persistent.addParameter(params.get("copr_no"));
              persistent.addParameter(params.get("sub_place_no"));
              persistent.addParameter(params.get("corp_kor"));
              persistent.addParameter(params.get("rep_name"));
              persistent.addParameter(params.get("corp_sts"));
              persistent.addParameter(params.get("biz_form"));
              persistent.addParameter(params.get("corp_div_cd"));
              persistent.addParameter(params.get("esta_date"));
              persistent.addParameter(params.get("corp_tel"));
              persistent.addParameter(params.get("corp_fax"));
              persistent.addParameter(params.get("corp_scale"));
              persistent.addParameter(params.get("post_no_1") + "" + params.get("post_no_2"));
              persistent.addParameter(params.get("address"));
              persistent.addParameter(params.get("place_post_no_1") + "" + params.get("place_post_no_2"));
              persistent.addParameter(params.get("place_address"));
              persistent.addParameter(params.get("tax_addr_cd"));
              persistent.addParameter(params.get("factor_cd"));
              persistent.addParameter(params.get("mftr_div_cd"));
              
              persistent.addParameter(storage.getUser().get("acct_id"));
              persistent.addParameter(params.get("bank_cd"));
              persistent.addParameter(params.get("bank_nm"));
              persistent.addParameter(params.get("bank_acct"));
              
              persistent.addParameter(params.get("p_corp_id"));
              
              //WAFLogger.debug(persistent.getParameters());
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  WAFLogger.error("updateInfo====>" + e);
              e.printStackTrace();
              conn.setRollback();
              throw e;
              
          }
          
          finally {
              super.conn.end();
          }
      }
  
      
      
      private RowSet getApprSrdList(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
              
              
                 sqlStr.append("        SELECT  A.APPR_LEVEL,    A.APPR_ACLS,     A.APPR_CD,  A.GUBUN_1,  A.GUBUN_2,  A.GUBUN_3,  A.STOCK_RATE,  A.A_CONTENT,                                     \n")
                         .append("                        A.A_RATE, A.B_CONTENT, A.B_RATE, A.C_CONTENT, A.C_RATE, A.D_CONTENT, A.D_RATE, A.E_CONTENT, A.E_RATE, A.NOTI , A.DOC_CD,                    \n")
                         .append("                        B.APPR_RESULT_CD,  B.APPR_RATE                                                                                                      \n")
                         .append("                         FROM                                                                                                                   \n")   
                         .append("                               (                                                                                                              \n")
                         .append("                                  SELECT                                                                                                             \n")
                         .append("                                        Z.APPR_LEVEL,    Z.APPR_ACLS,     Z.APPR_CD,  Z.DOC_CD,                                                  \n")
                         .append("                                        LAST_VALUE(Z.GUBUN_1 IGNORE NULLS) OVER(ORDER BY Z.APPR_CD) GUBUN_1,                                               \n")
                         .append("                                        LAST_VALUE(Z.GUBUN_2 IGNORE NULLS) OVER(ORDER BY Z.APPR_CD) GUBUN_2,                                           \n")    
                         .append("                                        LAST_VALUE(Z.GUBUN_3 IGNORE NULLS) OVER(ORDER BY Z.APPR_CD) GUBUN_3,                                      \n")
                         .append("                                        A_CONTENT, A_RATE, B_CONTENT, B_RATE, C_CONTENT, C_RATE, D_CONTENT, D_RATE, E_CONTENT, E_RATE, NOTI, STOCK_RATE             \n")                                      
                         .append("                                        FROM                                                                                                                                                         \n")
                         .append("                                        (                                                                                                                                                                  \n")
                         .append("                                             SELECT LEVEL APPR_LEVEL,    X.APPR_ACLS  , X.APPR_CD, X.STOCK_RATE,   X.DOC_CD,                                   \n")
                         .append("                                                DECODE(LEVEL, '1', X.APPR_ACLS || '(' || X.STOCK_RATE || ')' , '') GUBUN_1,                                                                 \n")
                         .append("                                                DECODE(TRIM(X.APPR_ACLS), '', ' ', DECODE(LEVEL, '2', X.APPR_ACLS  || '(' || X.STOCK_RATE || ')', '')) GUBUN_2,                                              \n")            
                         .append("                                                DECODE(X.APPR_ACLS, '', '', DECODE(LEVEL, '3', X.APPR_ACLS, '')) GUBUN_3,                                                                                              \n")                                     
                         .append("                                                X.A_CONTENT, X.A_RATE, X.B_CONTENT, X.B_RATE, X.C_CONTENT, X.C_RATE, X.D_CONTENT, X.D_RATE, X.E_CONTENT, X.E_RATE, NOTI             \n")                                                                  
                         .append("                                                FROM(                                                                                      \n")                                                   
                         .append("                                                        SELECT ADM_YEAR,                                                       \n")                                                     
                         .append("                                                                   DOC_CD,                                                     \n")                                                   
                         .append("                                                                   PARENT_LEVEL,                                       \n")
                         .append("                                                                   APPR_CD,                                                          \n")                                
                         .append("                                                                   APPR_MCD,                                                   \n")                                                      
                         .append("                                                                   APPR_ACLS,                                             \n")                                                    
                         .append("                                                                   STOCK_RATE,                                      \n")
                         .append("                                                                   A_CONTENT,                                     \n") 
                         .append("                                                                   A_RATE,                                      \n")
                         .append("                                                                   B_CONTENT,                                     \n") 
                         .append("                                                                   B_RATE,                                      \n")
                         .append("                                                                   C_CONTENT,                                     \n") 
                         .append("                                                                   C_RATE,                                      \n")
                         .append("                                                                   D_CONTENT,                                     \n") 
                         .append("                                                                   D_RATE,                                      \n")
                         .append("                                                                   E_CONTENT,                                     \n") 
                         .append("                                                                   E_RATE,                                      \n")
                         .append("                                                                   NOTI                                                                                     \n")
                         .append("                                                               FROM APPR_STD X                                                                                   \n")    
                         .append("                                                               WHERE  DOC_CD = ?                                                                            \n")       
                         .append("                                                        )  X                                                                                                         \n")                               
                         .append("                                         START WITH PARENT_LEVEL = 'S'                                                                            \n")                                 
                         .append("                                             CONNECT BY PRIOR APPR_CD = PARENT_LEVEL                                                     \n")                        
                         .append("                                             AND LEVEL <= 3                                                                                               \n")                                 
                         .append("                                             ORDER SIBLINGS BY PARENT_LEVEL ASC, APPR_CD ASC                                      \n")
                         .append("                                    )   Z                                                                                                                 \n")                  
                         .append("                           ) A, SUPP_APPR_ITEM B, SUPP_APPR  C                                                                      \n")
                         .append("                           WHERE A.DOC_CD = B.DOC_CD                                                                            \n")
                         .append("                                AND A.APPR_CD = B.APPR_CD                                                                           \n")
                         .append("                                AND B.DOC_CD = C.DOC_CD                                                                             \n")
                         .append("                                AND B.ARR_ID = C.ARR_ID                                                                                 \n")
                         .append("                                AND B.CORP_ID = C.CORP_ID                                                                                \n")
                         .append("                                AND A.GUBUN_3 IS NOT NULL                                                                            \n")                       
                         .append("                                AND A.A_CONTENT IS NOT NULL                                                                          \n")
                         .append("                                AND C.CORP_ID = ?                                                                          \n");
                                                 
              
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_doc_cd"));
              search.addParameter(params.get("p_corp_id"));
              
              //WAFLogger.debug(sqlStr.toString());
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getApprSrdList=========>" + se);
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      
      public ValueObject getCorp_id(Connection conn) throws Exception{
          
          Persistent persistent_q = null;
          
          
          ValueObject vo = new ValueObject();
          ValueObject row = null;
          StringBuffer sqlstr =  new StringBuffer();
          
          try{
              persistent_q = new PersistentImpl(conn);
              
              sqlstr.append("         SELECT SUPP_INFO_S.NEXTVAL AS SEQ  FROM DUAL                                                 \n");
              
              persistent_q.setStatement(sqlstr.toString()); 
              row = RowSetUtility.getValueObject(persistent_q.query().getRow(0));
              vo.set("seq", row.get("seq"));
          }
          catch(Exception e) {
              e.printStackTrace();
          }finally{
              if(vo == null) vo = new ValueObject();
          }
          return vo;
      }
      
      public RowSet getOutLicMaster_searchCombo(){
    	    
          Search search = new SearchImpl();
          RowSet listRowSet = null;
          String sqlstr = "";
          
          try {
              sqlstr = " SELECT LIC_CD, LIC_NM  FROM OUT_LIC_MASTER ORDER BY LIC_CD ASC                 \n";
               
              search.setStatement(sqlstr);
              
              //System.out.println("search=======>" + sqlstr);
              listRowSet = search.execute();
              
          }catch(Exception e){
              //System.out.println(e);
              e.printStackTrace();
          }finally{
      
              if( listRowSet == null ){
                  listRowSet = new RowSetImpl();
              }
              
              return listRowSet;
          }
      }
      
      private RowSet getCert2List(ValueObject Params) {
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          StringBuffer sqlStr = new StringBuffer();
          
          try {
                  sqlStr.append("          SELECT CON_SEQ        \n")
                          .append("                    ,BASE_YEAR        \n")
                          .append("                    ,LIC_CD        \n")
                          .append("                    ,LIC_NM        \n")
                          .append("                    ,LIC_NO                                                              \n")
                          .append("                    ,CONREYR        \n")
                          .append("                    FROM SUPP_ABILLTY        \n")
                          .append("                    WHERE CORP_ID = ?                                             \n");
              
              
              search.setStatement(sqlStr.toString());
              search.addParameter(params.get("p_corp_id"));
              
              
              //WAFLogger.debug("getSuppPatTent====>" + sqlStr.toString()); 
              //WAFLogger.debug(search.getParameters());
              
              rowSet = search.execute();
          }
          catch (WAFSQLException se) {
        	  WAFLogger.error("getCert2List=========>" + se.getMessage());
              super.doException(se);
              this.storage.setSuccess(false);
              this.storage.setMessage(se.getMessage());
              storage.setDetailMessage(se);
              se.printStackTrace();
          }
          finally {    
              if(rowSet == null) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
  
}