package kr.co.udapsoft.common.util;

import kr.co.hsnc.common.logger.Logger;
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.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;

public class SignLineUtil {
	/**
	 * 2018.11.28
	 * 이인오
	 * 그룹웨어 결재라인조회
	 * @param docId
	 * @return
	 * @throws Exception
	 */
	public static RowSet getSignUser(String docId) throws Exception {
		
		Search search = new SearchImpl();
    	search.setDSName("jdbc/gwsql");
    	RowSet rowSet = new RowSetImpl();
    	StringBuffer sqlstr = new StringBuffer();
    	
    	try {
    		
    		sqlstr.append(" SELECT	APRSTATE AS SIGN_RESULT													\n");
    		sqlstr.append(" 		,REPLACE(APRMEMBERID,SUBSTRING(APRMEMBERID,1,4),'') AS APPROVAL_SABUN	\n");
    		sqlstr.append(" 		,APRMEMBERNAME AS APPROVAL_USER											\n");
    		sqlstr.append(" 		,APRMEMBERJOBTITLE AS A_POSITION										\n");
    		sqlstr.append(" 		,REPLACE(CONVERT(VARCHAR(10),PROCESSDATE,120),'','') AS APPROVAL_DATE	\n");
    		sqlstr.append(" FROM	TBENDAPRLINEINFO                                              			\n");
    		sqlstr.append(" WHERE	APRTYPE = 'A03001'                                               		\n");
    		sqlstr.append(" AND		DOCID = ?                        										\n");
    		sqlstr.append(" ORDER BY APRMEMBERSN                                                			\n");
    		
    		search.setStatement(sqlstr.toString());
    		search.addParameter(docId);
    		rowSet = search.execute();
    		
    	}catch(WAFSQLException se) {
    		Logger.err.println("SQL : \n" + se.getStatement());
    		Logger.err.println("PARAM : \n" + se.getParameter());
    		throw se;
    	}
    	
    	return rowSet;
	}
	
}
