/*********************************************************************
*  All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*	システム名			：eo顧客基幹システム
*	モジュール名		：JBSbatAKTkskKnrnIdoInfChsht
*	ソースファイル名	：JBSbatAKTkskKnrnIdoInfChsht.java
*	作成者				：富士通　
*	作成日				：2013年05月23日
*＜機能概要＞
*　督促関連異動情報抽出部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	v1.00.00	2013/05/23   富士通		新規作成
*********************************************************************/
package eo.business.service;

import eo.business.common.JACbatDebugLogUtil;
import eo.business.common.JBSbatBusinessService;
import eo.common.constant.JACStrConst;
import eo.framework.item.JBSbatCommonItem;
import eo.framework.item.JBSbatServiceInterfaceMap;
import eo.framework.item.JBSbatOutputItem;
import eo.framework.item.JBSbatCommonDBInterface;
import eo.framework.db.JBSbatSQLAccess;

/**
* (クラスの機能概要) <p>
*<BR>
* @author 富士通
*/
public class JBSbatAKTkskKnrnIdoInfChsht extends JBSbatBusinessService
{
	/**▼▼▼▼▼▼ツールから生成した宣言です 開始▼▼▼▼▼▼*/
	/** テーブル(進捗)*/
	private static final String D_TBL_NAME_AK_CH_T_TOKUSOKU = "AK_CH_T_TOKUSOKU";

	/** SQL定義キー(AK_SELECT_007)*/
	private static final String AK_CH_T_TOKUSOKU_AK_SELECT_007 = "AK_SELECT_007";

	/** テーブルアクセスクラス(進捗)*/
	private JBSbatSQLAccess db_AK_CH_T_TOKUSOKU = null;
	/**▲▲▲▲▲▲ツールから生成した宣言です 終了▲▲▲▲▲▲*/
	
	/** フリー項目情報格納用配列 */
	private String[] fleeItemArray = null;

	/**
	 * 初期処理
	 * @param JBSbatCommonItem commonItem　バッチ共通パラメータ電文
	 * @throws Exception
	 */
	public void initial(JBSbatCommonItem commonItem) throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの初期処理を記述してください。▼▼▼▼▼▼*/
		/**▼▼▼▼▼▼ツールから生成した初期化のソースです 開始▼▼▼▼▼▼*/
		// 共通パラメータを設定します
		super.setCommonInfo(commonItem);

		// DBアクセスクラスを生成します
		db_AK_CH_T_TOKUSOKU = new JBSbatSQLAccess(commonItem, D_TBL_NAME_AK_CH_T_TOKUSOKU);
		/**▲▲▲▲▲▲ツールから生成した初期化のソースです 終了▲▲▲▲▲▲*/
		assert 	JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][initial]");
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][initial][opeDate=" + super.opeDate + "]");
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][initial][freeItem=" + super.freeItem + "]");
		
		// フリー項目情報を取得（検証対象異動区分、検証対象年月日ＦＲＯＭ、検証対象年月日ＴＯ）
		fleeItemArray = super.freeItem.split(JACStrConst.FREE_DIV);
		
		assert 	JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][initial]");
	/**▲▲▲▲▲▲業務サービスの初期処理を記述してください。▲▲▲▲▲▲*/
	}

	/**
	 * 主処理
	 * @return JBSbatOutputItem　出力情報
	 * @throws Exception
	 */
	public JBSbatOutputItem execute() throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの主処理を記述してください。▼▼▼▼▼▼*/
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][execute]");
		
		// 出力共通電文
		JBSbatOutputItem outputItem = new JBSbatOutputItem();
		
		// 督促関連異動情報の検索
		this.tokusokuAkSelect007();
		
		// 検索した督促関連異動情報の出力
		this.setOutputItems(outputItem);
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute]");
		
		return outputItem;
	/**▲▲▲▲▲▲業務サービスの主処理を記述してください。▲▲▲▲▲▲*/
	}

	/**
	 * 業務サービス終了処理
	 * @throws Exception
	 */
	public void terminal() throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの終了処理を記述してください。▼▼▼▼▼▼*/
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][terminal]");
		/**▼▼▼▼▼▼ツールから生成した終了処理のソースです 開始▼▼▼▼▼▼*/
		// DBアクセスクラスをクローズします
		db_AK_CH_T_TOKUSOKU.close();
		/**▲▲▲▲▲▲ツールから生成した終了処理のソースです 終了▲▲▲▲▲▲*/
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][terminal]");
	/**▲▲▲▲▲▲業務サービスの終了処理を記述してください。▲▲▲▲▲▲*/
	}

	/**▼▼▼▼▼▼ツールから生成したメソッドです 開始▼▼▼▼▼▼*/
	/**
	 * SQLKEY(AK_SELECT_007)でDBアクセスを行います。<br>
	 * <p>
	 * <b>処理フロー</b><br>
	 * <pre>
	 * 1.引数でバイント変数を設定します。<br>
	 *
	 * 2.DBアクセスを実行します。<br>
	 * 
	 * 3.メソッドの呼び出し方です。<br>
	 *		引数:
	 *		param:順にバイント変数の値をparam配列に入れます。バイント変数は以下に説明します。
	 *		 	検証対象異動区分
	 *		 	検証対象年月日FROM
	 *		 	検証対象年月日TO
	 * </pre>
	 * <p>
	 * @param param バイント変数の値配列。
	 * @throws Exception 業務サービス内で発生した例外全般。
	 */
	private void executeAK_CH_T_TOKUSOKU_AK_SELECT_007(Object[] param) throws Exception
	{
		// バイント変数のリストを生成します
		JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface();
		paramList.setValue(param[0].toString());
		paramList.setValue(param[1].toString());
		paramList.setValue(param[2].toString());

		// DBアクセスを実行します
		db_AK_CH_T_TOKUSOKU.selectBySqlDefine(paramList, AK_CH_T_TOKUSOKU_AK_SELECT_007);
		
		
	}
	/**▲▲▲▲▲▲ツールから生成したメソッドです 終了▲▲▲▲▲▲*/
	
	/**▼▼▼▼▼▼メソッド追加 開始▼▼▼▼▼▼*/
	
	/**
	 * SQLKEY(AK_SELECT001)でDBアクセスを行い、督促関連異動情報抽出します
	 * 
	 * @throws Exception 業務サービス内で発生した例外処理全般 
	 */
	private void tokusokuAkSelect007() throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][tokusokuAkSelect007]");
		// DBアクセス用のパラメータ定義
		JBSbatCommonDBInterface dbList = new JBSbatCommonDBInterface();
		
		// 対象キーの設定
		dbList.setValue(fleeItemArray[0]);			// 検証対象異動区分
		dbList.setValue(fleeItemArray[1]);			// 検証対象年月日FROM
		dbList.setValue(fleeItemArray[2]);			// 検証対象年月日TO
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][tokusokuAkSelect007][dbList=" + dbList.getList().toString() + "]");
		
		// 督促関連異動情報抽出
		executeAK_CH_T_TOKUSOKU_AK_SELECT_007(dbList.getList().toArray());
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][tokusokuAkSelect007]");
		
		return;
	}
	
	/**
	 * DBからの検索情報をもとに、
	 * 検索件数分の出力レコードを作成して出力情報を設定します
	 * 
	 * @param outputItem 出力情報
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private void setOutputItems(JBSbatOutputItem outputItem) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][setOutputItems]");
		// DBからの検索結果の取得
		JBSbatCommonDBInterface rec = db_AK_CH_T_TOKUSOKU.selectNext();
		
		JBSbatServiceInterfaceMap outRecord = null;
		
		while(null != rec)
		{
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][setOutputItems][rec=" + rec.getMap().toString() + "]");
			
			outRecord = new JBSbatServiceInterfaceMap();
			
			// 取得したレコードを設定します
			outRecord.setMap(rec.getMap());
			// 出力フラグを設定します
			outRecord.setOutFlg(true);
			// 出力レコード1件設定します
			outputItem.addOutMapList(outRecord);
			// 次レコード
			rec = db_AK_CH_T_TOKUSOKU.selectNext();	
		
		}
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][setOutputItems]");
	}
	/**▲▲▲▲▲▲メソッド追加 終了▲▲▲▲▲▲*/
}
