/**
 * @(#)file    InspectionDetailBiz.java
 * @(#)author  gyeongmo an
 * @(#)date    2014.09.01
 * Copyright (c) www.udapsoft.co.kr, Inc.
 */
package kr.co.udapsoft.ebid.buyer.process.process.biz;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

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.ebid.buyer.common.file.FileManager;

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 InspectionDetailBiz extends Biz {
	
	public InspectionDetailBiz(HandlerStorage storage) {
		super(storage);
	}
	
	public void doBiz() throws Exception {
		boolean success = false;
		ValueObject vo_file = new ValueObject();
		
		if( storage.compareEvent("") ){
			ValueObject vo = new ValueObject();
	        storage.addValueObject("inspectionDetail", vo);
		} 
		else if ( storage.compareEvent("GET_INSPECTION_DETAIL") ) {
			ValueObject vo = getInspectionDetail(params);
	        storage.addValueObject("inspectionDetail", vo);
	        
	        RowSet rowSet = FileManager.getFileList("INSPECTION_DETAIL", params.get("inspection_no"));
	    	
	        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_file.set("INSPECTION_DETAIL", str);
	        
	        
		} else if ( storage.compareEvent("REG_INSPECTION_DETAIL") ) {
			ValueObject voInspectionNo = getInspectionNo(super.conn.getConnection());
			params.set("inspection_no", voInspectionNo.get("inspection_no"));
			ValueObject vo = new ValueObject();
			storage.addValueObject("inspectionDetail", vo);
		}  else if ( storage.compareEvent("SAVE_INSPECTION_DETAIL") ) {
			try {
				ValueObject temp = getInspectionCnt(params.get("psr_id"), params.get("inspectionDate"));
	    		String count = temp.get("cnt");
	    		
	    		if (!"0".equals(count)) {
	    			String message = "동일한 날짜에 검사한 내역이 존재합니다.";
	                Exception e = new Exception(message);
	                throw e;
	    		}else{
	    			success = saveInspectionDetail(params);
	                storage.setSuccess(success);
	    		}
			}catch (Exception e) {
				WAFLogger.error(e);
				super.storage.setSuccess(false);
				super.conn.setRollback();
				super.doException(e);
				super.storage.setMessage(e.getMessage());
				super.storage.setDetailMessage(e);
			}
		} else if ( storage.compareEvent("UPDATE_INSPECTION_DETAIL") ) {
			
			try {
	    		success = updateInspectionDetail(params);
    			
                storage.setSuccess(success);
                
			}catch (Exception e) {
				WAFLogger.error(e);
				super.storage.setSuccess(false);
				super.conn.setRollback();
				super.doException(e);
				super.storage.setMessage(e.getMessage());
				super.storage.setDetailMessage(e);
			}
		} else if ( storage.compareEvent("DELETE_INSPECTION_DETAIL") ) {
			success = deleteInspectionDetail(params);
            storage.setSuccess(success);

		} else if( storage.compareEvent("REG_INSPECTION_DETAIL_SHEET") ) {
			params.set("sheet1", getNewInspectionDetailSheet());
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		} else if( storage.compareEvent("GET_INSPECTION_DETAIL_SHEET") ) {
			params.set("sheet1", getInspectionDetailSheet(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		} else if ( storage.compareEvent("SAVE_INSPECTION_DETAIL_SHEET") ) {
			String[] status = super.gets("SHEET1.status");
			
			try {
				super.conn.begin();
				
				for (int i = 0; i < status.length; i++) {
					if (IBSheet7Utils.equalStatusInsert(status[i])) {
						success = saveInspectionDetailSheet(super.conn.getConnection(), IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
					}
					if (IBSheet7Utils.equalStatusUpdate(status[i])) {
						success = updateInspectionDetailSheet(super.conn.getConnection(), IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
					}
				}
				super.storage.setSuccess(success);
				storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
			} catch (Exception e) {
				WAFLogger.error(e);
				storage.addObject("ibsheet7Data", IBSheet7Utils.exceptionHandle(storage.request, e));
				super.conn.setRollback();
				throw new Exception(e);
			} finally {
				super.conn.close();
			}

		} 
		
		storage.addValueObject("INSPECTION_DETAIL", vo_file);
	}
		
	
	private ValueObject getInspectionDetail(ValueObject params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sql = new StringBuffer();
        ValueObject vo = new ValueObject();
        try {
        	sql.append("	SELECT                                                                                                                		\n");
        	sql.append("	    GET_USER_SABUN_NM(A.INSPECTOR) INSPECTOR_NAME                                                                                                       		\n");
        	sql.append("	    , A.INSPECTOR			\n");
        	sql.append("	    , A.INSPECTION_DATE                                                                                               		\n");
        	sql.append("	    , A.INSPECTION_KIND                                                                                               		\n");
        	sql.append("	    , A.IRN_DATE                                                                                               		\n");
        	sql.append("	    , A.FINAL_FLAG                                                                                                    		\n");
        	sql.append("	    , A.INSPECTION_END_FLAG                                                                                                 		\n");
        	sql.append("	    , A.REMARKS                                                                                                       		\n");
        	sql.append("	    , A.INSPECTION_NO                                                                                                       		\n");
        	sql.append("	FROM INSPECTION A                                                                                  		\n");
        	sql.append("	WHERE A.INSPECTION_NO = ?                                                                                                      		\n");
        	
        	
        	search.setStatement(sql);
        	search.addParameter(params.get("inspection_no"));
        	WAFLogger.debug(sql.toString());
        	
            rowSet = search.execute();
            if(rowSet.size()>0){
                vo = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
            return vo;
        }
        catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
        }
        finally{
            if( vo == null) vo = new ValueObject();
            return vo;
        }
	}
	
	public RowSet getNewInspectionDetailSheet() {
		Search search 	  = new SearchImpl();
		RowSet rowSet 	  = new RowSetImpl();
		StringBuffer sql  = new StringBuffer();
		
		try {
			sql.append("	SELECT                               	\n");
			sql.append("	    	'1' INSPECTION_YN              	\n");
			sql.append("	    	, DETAILCD INSPECTION_ITEM_CD  	\n");
			sql.append("	    	, DETAILNM INSPECTION_DESC     	\n");
			sql.append("	    FROM EBID_COM911T                	\n");
			sql.append("	    WHERE BASECD = 'INSPECTION_ITEM' 	\n");
			sql.append("	    ORDER BY SORT_NO                 	\n");
			
			WAFLogger.debug(sql.toString());
			search.setStatement(sql.toString());
			rowSet = search.execute();
		} catch (WAFSQLException se) {
			WAFLogger.error(this.getClass().getName() + " --> getNewInspectionDetailSheet() : \n" + se.getMessage());
			WAFLogger.error("SQL : " + search.getStatement());
			WAFLogger.error(se);
			storage.setDetailMessage(se);
		}
		finally {    
			if(rowSet == null) rowSet = new RowSetImpl();
			return rowSet;
		}
	}
	
	public RowSet getInspectionDetailSheet(ValueObject params) {
		Search search 	  = new SearchImpl();
		RowSet rowSet 	  = new RowSetImpl();
		StringBuffer sql  = new StringBuffer();
		
		try {
			
			sql.append("	SELECT                                                                                                                		\n");
			sql.append("	    INSPECTION_YN                                                                                                     		\n");
			sql.append("	    , INSPECTION_ITEM_CD                                                                                              		\n");
			sql.append("	    , INSPECTION_DESC                                                                                                 		\n");
			sql.append("	    , INSPECTION_NO                                                                                                   		\n");
			sql.append("	FROM INSPECTION_ITEM                                                                                                  		\n");
			sql.append("	WHERE INSPECTION_NO = ?                                                                                               		\n");
			
			WAFLogger.debug(sql.toString());
			search.setStatement(sql.toString());
			search.addParameter(params.get("inspection_no"));
			rowSet = search.execute();
		} catch (WAFSQLException se) {
			WAFLogger.error(this.getClass().getName() + " --> getInspectionDetailSheet() : \n" + se.getMessage());
			WAFLogger.error("SQL : " + search.getStatement());
			WAFLogger.error(se);
			storage.setDetailMessage(se);
		}
		finally {    
			if(rowSet == null) rowSet = new RowSetImpl();
			return rowSet;
		}
	}
	
	private ValueObject getInspectionNo(Connection conn) throws Exception {
	
		Persistent persistent_q = null;
		
		ValueObject vo = new ValueObject();
		ValueObject row = null;
		String sqlstr = "";
		
		try{
			persistent_q = new PersistentImpl(conn);
			sqlstr = "SELECT INSPECTION_S.NEXTVAL INSPECTION_NO FROM DUAL";
			persistent_q.setStatement(sqlstr); 
			row = RowSetUtility.getValueObject(persistent_q.query().getRow(0));
			vo.set("inspection_no", row.get("inspection_no"));
		}catch(Exception e){
			WAFLogger.error(this.getClass().getName() + " --> getInspectionNo() : " + e.getMessage());
			WAFLogger.error(e);
			throw e;
            
		}finally{
			if(vo == null) vo = new ValueObject();
		}
		
		return vo;
	}
	
	public boolean saveInspectionDetail(ValueObject params) {
        Persistent persistent = null;
        StringBuffer sql   = new StringBuffer();
        
        
        sql.append("	INSERT INTO INSPECTION (       	\n");
    	sql.append("		INSPECTION_NO                	\n");
    	sql.append("		, PSR_ID                     	\n");
    	sql.append("		, PSR_ACTIVITY_CD            	\n");
    	sql.append("		, INSPECTION_DATE            	\n");
    	sql.append("		, INSPECTOR                  	\n");
    	sql.append("		, FINAL_FLAG                 	\n");
    	sql.append("		, IRN_DATE                   	\n");
    	sql.append("		, INSPECTION_END_FLAG        	\n");
    	sql.append("		, REMARKS                    	\n");
    	sql.append("		, CRE_BY                     	\n");
    	sql.append("		, CRE_DATE                   	\n");
    	sql.append("		, INSPECTION_KIND            	\n");
    	sql.append("	)VALUES (                      	\n");
    	sql.append("		?                            	\n");
    	sql.append("		,?                           	\n");
    	sql.append("		,'45'                           	\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");
    	sql.append("		)                            	\n");
    	
    	
		try {
            conn.begin();
            Connection connection = super.conn.getConnection(); 
            persistent = new PersistentImpl(connection);
            persistent.setStatement(sql.toString());
            
            persistent.addParameter(params.get("inspection_no"));
            persistent.addParameter(params.get("psr_id"));
//            persistent.addParameter(params.get("psr_activity_cd"));
            persistent.addParameter(params.get("inspectionDate"));
            persistent.addParameter(params.get("inspector"));
            persistent.addParameter(params.get("finalFlag"));
            persistent.addParameter(params.get("irnDate"));
            persistent.addParameter(params.get("inspectionEndFlag"));
            persistent.addParameter(params.get("remarks"));
            persistent.addParameter(storage.getUser().get("ACCT_ID"));
            persistent.addParameter(params.get("inspection_kind"));
            
            WAFLogger.debug(sql.toString());
            persistent.execute();
            persistent.clearParameters();

            
            if("45".equals(params.get("inspection_kind"))) {
            	psrUpdate(connection, params);
            }
            
            
            return true;
		}
        catch(Exception e) {
            super.doException(e);
            super.storage.setMessage(e.getMessage());
            super.storage.setDetailMessage(e);
            super.conn.setRollback();
            return false;
        }
        finally {
            super.conn.end();
        }
    }
		
	public boolean updateInspectionDetail(ValueObject params) {
		Persistent persistent = null;
		StringBuffer sql   = new StringBuffer();
		
		sql.append("		UPDATE INSPECTION SET       	\n");
		sql.append("			INSPECTOR = ?             	\n");
		sql.append("			, INSPECTION_DATE = ?     	\n");
		sql.append("			, INSPECTION_KIND = ?     	\n");
		sql.append("			, IRN_DATE = ?            	\n");
		sql.append("			, FINAL_FLAG = ?          	\n");
		sql.append("			, INSPECTION_END_FLAG = ? 	\n");
		sql.append("			, REMARKS = ?             	\n");
		sql.append("			, UPD_BY = ?              	\n");
		sql.append("			, UPD_DATE = SYSDATE      	\n");
		sql.append("		WHERE INSPECTION_NO = ?     	\n");
		
		
		try {
			conn.begin();
			Connection connection = super.conn.getConnection();
			persistent = new PersistentImpl(connection);
			persistent.setStatement(sql.toString());
			
			persistent.addParameter(params.get("inspector"));
			persistent.addParameter(params.get("inspectionDate"));
			persistent.addParameter(params.get("inspection_kind"));
			persistent.addParameter(params.get("irnDate"));
			persistent.addParameter(params.get("finalFlag"));
			persistent.addParameter(params.get("inspectionEndFlag"));
			persistent.addParameter(params.get("remarks"));
			persistent.addParameter(storage.getUser().get("ACCT_ID"));
			persistent.addParameter(params.get("inspection_no"));
			
			WAFLogger.debug(sql.toString());
			persistent.execute();
			persistent.clearParameters();
			
			 if("45".equals(params.get("inspection_kind"))) {
	            	psrUpdate(connection, params);
	            }
			 
			 
			 
			return true;
		}
		catch(Exception e) {
			super.doException(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setDetailMessage(e);
			super.conn.setRollback();
			return false;
		}
		finally {
			super.conn.end();
		}
	}
	
	public boolean deleteInspectionDetail(ValueObject params) {
		Persistent persistent = null;
		StringBuffer sql   = new StringBuffer();
		
		sql.append("		DELETE FROM INSPECTION WHERE INSPECTION_NO = ?	\n");
		
		try {
			conn.begin();
			
			RowSet rowset = getInspectionDetailSheet(params);
			if(rowset.size() > 0) {
				deleteInspectionItem(params);
			}
			
			persistent = new PersistentImpl(super.conn.getConnection());
			persistent.setStatement(sql.toString());
			
			persistent.addParameter(params.get("inspection_no"));
			
			WAFLogger.debug(sql.toString());
			persistent.execute();
			persistent.clearParameters();
			
			return true;
		}
		catch(Exception e) {
			super.doException(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setDetailMessage(e);
			super.conn.setRollback();
			return false;
		}
		finally {
			super.conn.end();
		}
	}
	
	public boolean deleteInspectionItem(ValueObject params) throws Exception {
		Persistent persistent = null;
		StringBuffer sql   = new StringBuffer();
		
		sql.append("		DELETE FROM INSPECTION_ITEM WHERE INSPECTION_NO = ?	\n");
		
		try {
			conn.begin();
			
			persistent = new PersistentImpl(super.conn.getConnection());
			persistent.setStatement(sql.toString());
			
			persistent.addParameter(params.get("inspection_no"));
			
			WAFLogger.debug(sql.toString());
			persistent.execute();
			persistent.clearParameters();
			
			return true;
		}
		catch(Exception e) {
			throw e;
		}
	}
	
	public boolean saveInspectionDetailSheet(Connection connection, ValueObject sqlParams) throws Exception {
	   PreparedStatement pstmt = null;
	   StringBuffer sql   = new StringBuffer();
	   
	   try {
		   
		   sql.append("		INSERT INTO INSPECTION_ITEM (	\n");
			sql.append("			INSPECTION_ITEM_CD         	\n");
			sql.append("			, INSPECTION_NO            	\n");
			sql.append("			, INSPECTION_YN            	\n");
			sql.append("			, INSPECTION_DESC          	\n");
			sql.append("			, CRE_BY                   	\n");
			sql.append("			, CRE_DATE                 	\n");
			sql.append("		) VALUES (                   	\n");
			sql.append("			?                          	\n");
			sql.append("			,?                         	\n");
			sql.append("			,?                         	\n");
			sql.append("			,?                         	\n");
			sql.append("			,?                         	\n");
			sql.append("			,SYSDATE                   	\n");
			sql.append("		)                            	\n");
			
	        pstmt = connection.prepareStatement(sql.toString());
	        int paramIdx = 1;
			pstmt.setString(paramIdx++, sqlParams.get("inspection_item_cd"));
			pstmt.setString(paramIdx++, params.get("inspection_no"));
			pstmt.setString(paramIdx++, sqlParams.get("inspection_yn"));
			pstmt.setString(paramIdx++, sqlParams.get("inspection_desc"));
			pstmt.setInt(paramIdx++, storage.getUser().getInt("ACCT_ID"));
					
			pstmt.executeUpdate();
			
			return true;
	    }
	    catch(Exception e) {
	    	WAFLogger.error(e);
			throw new Exception(e);
	    }
	    finally {
	    	try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
	    }
	}
	
	
	public boolean updateInspectionDetailSheet(Connection connection, ValueObject sqlParams) throws Exception {
	   PreparedStatement pstmt = null;
	   StringBuffer sql   = new StringBuffer();
	   
	   try {
			sql.append("		UPDATE INSPECTION_ITEM SET  	\n");
			sql.append("		INSPECTION_YN = ?           	\n");
			sql.append("		, UPD_BY = ?                	\n");
			sql.append("		, UPD_DATE = SYSDATE        	\n");
			sql.append("		WHERE INSPECTION_ITEM_CD = ?	\n");
			sql.append("		AND INSPECTION_NO = ?       	\n");
			
		   
	        pstmt = connection.prepareStatement(sql.toString());
	        int paramIdx = 1;
			pstmt.setString(paramIdx++, sqlParams.get("inspection_yn"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("inspection_item_cd"));
			pstmt.setString(paramIdx++, sqlParams.get("inspection_no"));
			pstmt.executeUpdate();
			
			return true;
        }
        catch(Exception e) {
        	WAFLogger.error(e);
			throw new Exception(e);
        }
        finally {
        	try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
        }
    }
	
	public boolean psrUpdate(Connection conn, ValueObject params) throws Exception {
		CallableStatement cs 	= null;
		ValueObject rtnVo = new ValueObject();
		String pssql			= "";
		
		try {
        	pssql = "{call SP_REG_PSR_STATUS(?,?,?,?,?,?,?,?,?,?,?,?)}";
        	/*
        	 *    VI_DEPT_CD       IN VARCHAR2,         --PROJECT_CD
				   VI_ACTIVITY_CD   IN VARCHAR2,         --PSR_ACTIVITY_CD
				   VI_ACTIVITY_KIND IN VARCHAR2,         --1=PLAN, 2=FORECASTING,3=ACTUAL
				   VI_MR_NO         IN VARCHAR2,         --MR_NO
				   VI_DEMANDED_ID   IN NUMBER,           --DEMANDED_ID
				   VI_PUR_CONT_ID   IN NUMBER,           --PUR_CONT_ID
				   VI_IN_USER_CD    IN NUMBER,           --작성자 사번  
				   VI_ACTIVITY_DATE IN VARCHAR2,         --일자
        	 */
        	
        	cs = conn.prepareCall(pssql);
        	cs.setString(1, params.get("dept_cd2"));
        	cs.setString(2, params.get("inspection_kind"));
        	cs.setString(3, "3");
        	cs.setString(4, params.get("mr_no"));
        	cs.setInt(5, params.getInt("demanded_id"));
        	cs.setInt(6, params.getInt("pur_cont_id"));
        	cs.setString(7, "");
        	cs.setInt(8, storage.getUser().getInt("ACCT_ID"));
        	cs.setString(9, params.get("inspectionDate"));
        	cs.setString(10, params.get("remarks"));
        	cs.registerOutParameter(11, java.sql.Types.VARCHAR);
            cs.registerOutParameter(12, java.sql.Types.VARCHAR);
        	
            
/*            WAFLogger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            WAFLogger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            WAFLogger.debug("1 => " + params.get("dept_cd2"));
            WAFLogger.debug("2 => " + params.get("inspection_kind"));
            WAFLogger.debug("3 => " + "3");
            WAFLogger.debug("4 => " + params.get("mr_no"));
            WAFLogger.debug("5 => " + params.getInt("demanded_id"));
            WAFLogger.debug("6 => " + params.getInt("pur_cont_id"));
            WAFLogger.debug("7 => " + "");
            WAFLogger.debug("8 => " + storage.getUser().getInt("ACCT_ID"));
            WAFLogger.debug("9 => " + params.get("inspectionDate"));
            WAFLogger.debug("10 => " + params.get("remarks"));
            WAFLogger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            WAFLogger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
*/
            
            
        	cs.execute();
        	
        	rtnVo.set("VO_SUCCESS_CD",cs.getString(11));
            rtnVo.set("VO_MESSAGE",cs.getString(12));
            
            return true;
        }
        catch(Exception e) {
        	throw e;
        }
        finally {
        	super.conn.end();
        }
	}
	
	public ValueObject getInspectionCnt(String psr_id, String inspectionDate) throws Exception {
        Search search = new SearchImpl();
        StringBuffer sql = new StringBuffer();
        ValueObject vo = new ValueObject();
        
        try {
        	sql.append("	SELECT COUNT(*) CNT		\n")
    			.append("		             FROM INSPECTION	\n")
				.append("	WHERE PSR_ID = ? AND TO_CHAR(INSPECTION_DATE, 'YYYYMMDD') = ?	\n");
            
        	search.setStatement(sql.toString());        	
        	search.addParameter(psr_id);
        	search.addParameter(inspectionDate.replaceAll("-", ""));
        	
        	WAFLogger.debug(search.getParameters());
            
        	vo = RowSetUtility.getValueObject(search.execute().getRow(0));
            
        } catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> get_conDocNo_cnt() : \n" + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            
        } finally {
        	if(vo == null) vo = new ValueObject();
        }
        
        return vo;
    }
	
}
