/**
 *
 * @(#)author  [OK]
 * @(#)version 1.0
 * @(#)date    2014-09-11
 * @(#)since   JDK 1.6.2
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 */
package kr.co.udapsoft.ebid.buyer.payment.purchase.biz;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.config.WAFConfig;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.util.ValueObject;

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 TaxInfoPopBiz extends Biz {

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

	public void doBiz() throws Exception {

		RowSet rowSet = new RowSetImpl();
		
		rowSet = getList(params);
		storage.addRowSet("rowSet", rowSet);

	}

	/**
	 * @param ValueObject
	 * @return RowSet 기 능 : 세금계산서발행리스트
	 * @author OK
	 * @version 2014. 9. 22.
	 * @since JDK1.7
	 */
	public RowSet getList(ValueObject Params) {
		Search search = new SearchImpl();
		RowSet listRowSet = null;
		StringBuffer sqlstr = new StringBuffer();

		try {
			
			sqlstr.append("SELECT CONVERSATION_ID 																	\n");
			sqlstr.append("	 FROM( 																					\n");
			sqlstr.append("		  SELECT CONVERSATION_ID 															\n");
			sqlstr.append("			FROM XXSB_DTI_MAIN@SMBLIF 														\n");
			sqlstr.append("		   WHERE APPROVE_ID = (SELECT ORI_ISSUE_ID 											\n");
			sqlstr.append("         					 FROM XXSB_DTI_MAIN@SMBLIF 									\n");
			sqlstr.append("        						WHERE CONVERSATION_ID = ?) 									\n");
			sqlstr.append("		   UNION ALL 																		\n");
			sqlstr.append("	      SELECT CONVERSATION_ID 															\n");
			sqlstr.append("		    FROM XXSB_DTI_MAIN@SMBLIF 														\n");
			sqlstr.append("		   WHERE ORI_ISSUE_ID IS NOT NULL 													\n");
			sqlstr.append("		     AND ORI_ISSUE_ID = (SELECT ORI_ISSUE_ID 										\n");
			sqlstr.append("								   FROM XXSB_DTI_MAIN@SMBLIF 								\n");
			sqlstr.append("								  WHERE CONVERSATION_ID = ?) 								\n");
			sqlstr.append("									AND INTERFACE_BATCH_ID = (SELECT INTERFACE_BATCH_ID 	\n");
			sqlstr.append("																FROM XXSB_DTI_MAIN@SMBLIF 	\n");
			sqlstr.append("															   WHERE CONVERSATION_ID = ?)	\n");
			sqlstr.append("		   UNION ALL 																		\n");
			sqlstr.append("		  SELECT CONVERSATION_ID 															\n");
			sqlstr.append("	 		FROM XXSB_DTI_MAIN@SMBLIF 														\n");
			sqlstr.append(" 	   WHERE ORI_ISSUE_ID IS NULL 														\n");
			sqlstr.append("	  		 AND CONVERSATION_ID = ? 														\n"); 
			sqlstr.append(") 																						\n");
			sqlstr.append("ORDER BY CONVERSATION_ID																	\n");

			search.setStatement(sqlstr.toString());
			search.addParameter(params.get("conversation_id"));
			search.addParameter(params.get("conversation_id"));
			search.addParameter(params.get("conversation_id"));
			search.addParameter(params.get("conversation_id"));
			
			WAFLogger.debug(search);
			WAFLogger.debug(search.getParameters());
			listRowSet = search.execute();

			return listRowSet;

		} catch (Exception e) {
			WAFLogger.error(this.getClass().getName()
					+ " --> getPrePaymentList() : " + e.getMessage());
			WAFLogger.error("SQL : " + search.getStatement());
			WAFLogger.error(e);
			return listRowSet;
		}
	}

}
