/*********************************************************************
*  All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*	システム名			：eo顧客基幹システム
*	モジュール名		：JBSbatAKKapSoteiPrc
*	ソースファイル名	：JBSbatAKKapSoteiPrc.java
*	作成者				：富士通　
*	作成日				：2013年03月12日
*＜機能概要＞
*　想定金額算出（割賦関連料金）部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	v1.00.00	2013/03/12   富士通		新規作成
*	v5.00.00	2013/11/11   FJ) 前田	【ANK-1580-00-00】eoスマートリンク改修対応
*	v9.00.00	2014/05/07   FJ) 前田	【ANK-2054-00-00】スマートリンク端末故障対応
*********************************************************************/
package eo.business.service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;

import eo.business.common.JACbatDebugLogUtil;
import eo.business.common.JACbatRknBusinessUtil;
import eo.business.common.JACbatSchdlUtil;
import eo.business.common.JBSbatBusinessService;
import eo.business.util.file.JBSbatAKIFM020;
import eo.business.util.file.JBSbatAKIFM062;
import eo.business.util.table.JBSbatAK_M_KAP_SOTEI_PRC;

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 JBSbatAKKapSoteiPrc extends JBSbatBusinessService
{
	/**▼▼▼▼▼▼ツールから生成した宣言です 開始▼▼▼▼▼▼*/
	/** テーブル(割賦想定料金)*/
	private static final String D_TBL_NAME_AK_M_KAP_SOTEI_PRC = "AK_M_KAP_SOTEI_PRC";

	/** SQL定義キー(AK_SELECT_002)*/
	private static final String AK_M_KAP_SOTEI_PRC_AK_SELECT_002 = "AK_SELECT_002";

	/** テーブルアクセスクラス(割賦想定料金)*/
	private JBSbatSQLAccess db_AK_M_KAP_SOTEI_PRC = null;
	/**▲▲▲▲▲▲ツールから生成した宣言です 終了▲▲▲▲▲▲*/
	
	/** 退避．想定料金マップ */
	private HashMap<String, ArrayList<JBSbatCommonDBInterface>> tmpKapSoteiPrcMap = null;
	
	/** 退避．想定料金割引額マップ */
	private HashMap<String, JBSbatCommonDBInterface> tmpKapSoteiPrcWriMap = null;
	
	/** 退避．請求年月 */
	private String tmpSeikyYm = null;
	
	/** 退避．月初日 */
	private String tmpMonStaDay = null;
	
	/** 退避．月末日 */
	private String tmpMonEndDay = null;
	
	/** 退避．料金計算日 */
	private String tmpEventYmd = null;
	
	/** ワーク．出力フラグ */
	private int outFlg = 0;
	
	/** 固定値：0 */
	private static final BigDecimal ZERO = new BigDecimal("0");
	
	/** 固定値：1 */
	private static final BigDecimal ONE = new BigDecimal("1");

	/** 想定料金内容コード：割引額 */
	private static final String SOTEI_PRC_NAIYO_CD_WRIB = "2";
	
	/** 割賦違約金 */
	private static final String  KAPPNLTY = "KAPPNLTY";
	
	/**
	 * 初期処理
	 * @param JBSbatCommonItem commonItem　バッチ共通パラメータ電文
	 * @throws Exception
	 */
	public void initial(JBSbatCommonItem commonItem) throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの初期処理を記述してください。▼▼▼▼▼▼*/
		/**▼▼▼▼▼▼ツールから生成した初期化のソースです 開始▼▼▼▼▼▼*/
		// 共通パラメータを設定します
		super.setCommonInfo(commonItem);

		// DBアクセスクラスを生成します
		db_AK_M_KAP_SOTEI_PRC = new JBSbatSQLAccess(commonItem, D_TBL_NAME_AK_M_KAP_SOTEI_PRC);
		/**▲▲▲▲▲▲ツールから生成した初期化のソースです 終了▲▲▲▲▲▲*/

		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][initial]");
		
		// 割賦想定料金ＭＡＰ作成
		this.makeKapSoteiPrcMap();
		
		// 請求年月・月初日・月末日・料金計算日・暦日数取得
		this.getSchdlInfo();
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][initial]");

	/**▲▲▲▲▲▲業務サービスの初期処理を記述してください。▲▲▲▲▲▲*/
	}

	/**
	 * 主処理
	 * @param inMap　入力電文
	 * @return JBSbatOutputItem　出力情報
	 * @throws Exception
	 */
	public JBSbatOutputItem execute(JBSbatServiceInterfaceMap inMap) throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの主処理を記述してください。▼▼▼▼▼▼*/
		
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][execute][inMap = " + inMap.getMap().toString() + "]") : true;
		
		JBSbatOutputItem outputItem = new JBSbatOutputItem();

		HashMap<String, Object> workMap = new HashMap<String, Object>();
		
		outFlg = 1;
		
		// 想定料金算出（料金パラメータ）
		soteiPrcCalc(inMap, workMap);
		
		// 請求パターン内訳情報（金額算出済）出力
		// ファイル出力
		if(outFlg != 0)
		{
			makeOutputInfo(inMap, workMap, outputItem);
		}
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute]");
		return outputItem;
		
	/**▲▲▲▲▲▲業務サービスの主処理を記述してください。▲▲▲▲▲▲*/
	}

	/**
	 * 業務サービス終了処理
	 * @throws Exception
	 */
	public void terminal() throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの終了処理を記述してください。▼▼▼▼▼▼*/
		/**▼▼▼▼▼▼ツールから生成した終了処理のソースです 開始▼▼▼▼▼▼*/
		// DBアクセスクラスをクローズします
		db_AK_M_KAP_SOTEI_PRC.close();
		/**▲▲▲▲▲▲ツールから生成した終了処理のソースです 終了▲▲▲▲▲▲*/
	/**▲▲▲▲▲▲業務サービスの終了処理を記述してください。▲▲▲▲▲▲*/
	}

	/**▼▼▼▼▼▼ツールから生成したメソッドです 開始▼▼▼▼▼▼*/
	/**
	 * SQLKEY(AK_SELECT_002)でDBアクセスを行います。<br>
	 * <p>
	 * <b>処理フロー</b><br>
	 * <pre>
	 * 1.引数でバイント変数を設定します。<br>
	 *
	 * 2.DBアクセスを実行します。<br>
	 * 
	 * 3.メソッドの呼び出し方です。<br>
	 *		引数:
	 *		param:順にバイント変数の値をparam配列に入れます。バイント変数は以下に説明します。
	 *		 	月末日
	 * </pre>
	 * <p>
	 * @param param バイント変数の値配列。
	 * @throws Exception 業務サービス内で発生した例外全般。
	 */
	private void executeAK_M_KAP_SOTEI_PRC_AK_SELECT_002(Object[] param) throws Exception
	{
		// バイント変数のリストを生成します
		JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface();
		paramList.setValue(param[0].toString());

		// DBアクセスを実行します
		db_AK_M_KAP_SOTEI_PRC.selectBySqlDefine(paramList, AK_M_KAP_SOTEI_PRC_AK_SELECT_002);
	}
	/**▲▲▲▲▲▲ツールから生成したメソッドです 終了▲▲▲▲▲▲*/
	

	
	/**
	 * 割賦想定料金マスタを検索して、
	 * 料金コースコード・料金サービスコード・割引サービス単価コード・料金項目コード・支払契約識別コード・下限値・上限値毎に想定料金ＭＡＰを作成します。
	 * 
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private void makeKapSoteiPrcMap() throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeKapSoteiPrcMap]");

		JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface();
	
		// 想定料金適用開始年月日
		paramList.setValue(super.opeDate);
		// 想定料金適用終了年月日
		paramList.setValue(super.opeDate);

		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][makeKapSoteiPrcMap][paramList=" + paramList.getList().toString() + "]");

		// SQL実行
		executeAK_M_KAP_SOTEI_PRC_AK_SELECT_002(paramList.getList().toArray());
		JBSbatCommonDBInterface dbMap = db_AK_M_KAP_SOTEI_PRC.selectNext();
		
		this.tmpKapSoteiPrcWriMap = new HashMap<String, JBSbatCommonDBInterface>();
		this.tmpKapSoteiPrcMap = new HashMap<String, ArrayList<JBSbatCommonDBInterface>>();
		ArrayList<JBSbatCommonDBInterface> dbList = new ArrayList<JBSbatCommonDBInterface>();
		
		// 取得出来た場合
		if(dbMap != null)
		{
			// KEY：料金コースコード＋割賦プランコード＋割引サービス単価＋ 加入契約支払方式コード＋支払契約識別コード
			String tihKey = makeStr(dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.PCRS_CD), dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.KAP_PLAN_CD),
					dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.WRIB_SVC_TANKA_NO), dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.PRC_KMK_CD));
			// 取得件数分処理を繰り返す
			while(dbMap != null)
			{
				// 想定料金マップの設定
				String key = makeStr(dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.PCRS_CD), dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.KAP_PLAN_CD),
					dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.WRIB_SVC_TANKA_NO), dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.PRC_KMK_CD));
				// キーが同じ場合、リストに追加
				if(key.equals(tihKey))
				{
					dbList.add(dbMap);	// リストに追加
				}
				else
				{
					this.tmpKapSoteiPrcMap.put(tihKey, dbList);			// HashMapへ設定
					tihKey = key;										// 退避キーの置き換え
					dbList = new ArrayList<JBSbatCommonDBInterface>();	// 初期化
					dbList.add(dbMap);
				}
				
				// 想定料金割引額マップの設定
				String soteiPrcNaiyoCd = dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.SOTEI_PRC_NAIYO_CD);
				if(SOTEI_PRC_NAIYO_CD_WRIB.equals(soteiPrcNaiyoCd))
				{
					String key2 = makeStr(dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.PCRS_CD), dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.KAP_PLAN_CD),
							dbMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.WRIB_SVC_TANKA_NO));
					this.tmpKapSoteiPrcWriMap.put(key2, dbMap);			// HashMap想定料金割引額へ設定
				}
				
				// 次レコード取得
				dbMap = db_AK_M_KAP_SOTEI_PRC.selectNext(); 
			}
			this.tmpKapSoteiPrcMap.put(tihKey, dbList);	// HashMapへ設定
		}
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKapSoteiPrcMap]");
		return;
	}
	
	/**
	 * 文字を連結します。
	 * 
	 * @param  string 文字
	 * @return strBuf 連結した文字列
	 */
	private String makeStr(String ...string)
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeStr]");
		
		StringBuffer strBuf = new StringBuffer();
		for(String str:string)
		{
			if(str == null)
			{
				strBuf.append(JACStrConst.KARA_MOJI);
			}
			else
			{
				strBuf.append(str);
			}
		}
		
		assert strBuf != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][strBuf][strBuf = " + strBuf.toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeStr]");
		
		return strBuf.toString();
	}
	
	/**
	 * 料金スケジュール定義アクセス部品を使用してスケジュール情報を取得します。
	 * 
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private void getSchdlInfo() throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][getSchdlInfo]");
		
		JACbatSchdlUtil schdlUtil = new JACbatSchdlUtil(commonItem);
		try
		{
			// 請求年月
			this.tmpSeikyYm 		= schdlUtil.getBillDate(super.opeDate, JACStrConst.EVENT_CD_PRC_CALC_DAY);
			// 月初日[0] 月末日[1]
			String[] ymd 		= schdlUtil.getUseStrEnd(this.tmpSeikyYm, JACStrConst.EVENT_CD_USE_STAYMD, JACStrConst.EVENT_CD_USE_ENDYMD);
			this.tmpMonStaDay 	= ymd[0];
			this.tmpMonEndDay 	= ymd[1];
			// 料金計算日
			this.tmpEventYmd 	= schdlUtil.getUseStrEnd(this.tmpSeikyYm, JACStrConst.EVENT_CD_USE_STAYMD, JACStrConst.EVENT_CD_PRC_CALC_DAY)[1];
			
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][getSchdlInfo][請求年月=" + this.tmpSeikyYm + "]");
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][getSchdlInfo][月初日=" + this.tmpMonStaDay + "]");
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][getSchdlInfo][月末日=" + this.tmpMonEndDay + "]");
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][getSchdlInfo][料金計算日=" + this.tmpEventYmd + "]");
		}
		finally
		{
			schdlUtil.close();
		}
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][getSchdlInfo]");
		return;
	}
	
	/**
	 * 想定料金を算出します。
	 * 
	 * @param inMap 入力情報
	 * @param workMap 結果受渡領域
	 * @return tmpWkSoteiAmnt 想定料金
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private void soteiPrcCalc(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][soteiPrcCalc]");
		
		boolean returnCode = false;		
		
		BigDecimal tmpWkSoteiAmnt = null;
		
		//入力．想定金額算出方法コードを取得
		String soteiAmntSnstWayCd = inMap.getString(JBSbatAKIFM020.SOTEI_AMNT_SNST_WAY_CD);
		
		if((JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWRI1.equals(soteiAmntSnstWayCd))
			|| (JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWRI2.equals(soteiAmntSnstWayCd))
			|| (JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWI.equals(soteiAmntSnstWayCd)))
		{
			// 割賦割引料金算出
			returnCode = snstKapWribPrc(inMap, workMap);
			if(false == returnCode)
			{
				// 割賦想定料金マスタからデータが取得できない場合
				// 想定金額に0を設定
				tmpWkSoteiAmnt = BigDecimal.ZERO;
				workMap.put(JBSbatAKIFM062.SOTEI_AMNT, tmpWkSoteiAmnt.toString());
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][soteiPrcCalc][該当データなしのため想定金額=0で返却]");
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][soteiPrcCalc]");
				
				return;
			}
			
			//想定金額算出
			tmpWkSoteiAmnt = snstSoteiAmntKapWri(inMap, workMap);
			workMap.put(JBSbatAKIFM062.SOTEI_AMNT, tmpWkSoteiAmnt.toString());

			return;
		}
		else if(JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAP_PNL.equals(soteiAmntSnstWayCd))
		{
			// 割賦違約金算出
			returnCode = snstKapPnltyPrc(inMap, workMap);
			if(false == returnCode)
			{
				// 割賦想定料金マスタからデータが取得できない場合
				// 出力しない
				outFlg = 0;
				return;
			}
			
			// 想定金額算出
			tmpWkSoteiAmnt = (BigDecimal)workMap.get(KAPPNLTY);
			workMap.put(JBSbatAKIFM062.SOTEI_AMNT, tmpWkSoteiAmnt.toString());

			return;

		}
		else
		{
			// 上記以外は出力フラグをOFFにする。
			outFlg = 0;
		}
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][soteiPrcCalc][想定算出料金：" + tmpWkSoteiAmnt + "]");
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][soteiPrcCalc]");
		return;
	}


	/**
	 * 想定料金(割賦割引料金)を算出します。
	 * 
	 * @param inMap 入力情報
	 * @param workMap  結果受渡領域
	 * @return tmpWkSoteiAmnt 想定料金
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private BigDecimal snstSoteiAmntKapWri(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][snstSoteiAmntKapWri]");

		//想定金額に0を設定
		BigDecimal tmpWkSoteiAmnt = BigDecimal.ZERO;
		
		//入力．想定金額算出方法コードを取得
		String soteiAmntSnstWayCd = inMap.getString(JBSbatAKIFM020.SOTEI_AMNT_SNST_WAY_CD);

		if(JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWRI1.equals(soteiAmntSnstWayCd))
		{
			//想定金額　←　割賦想定料金ＭＡＰ．初回想定料金
			tmpWkSoteiAmnt = (BigDecimal)workMap.get(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC);
		}
		else if(JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWRI2.equals(soteiAmntSnstWayCd))
		{
			//想定金額　←　割賦想定料金ＭＡＰ．継続想定料金
			tmpWkSoteiAmnt = (BigDecimal)workMap.get(JBSbatAK_M_KAP_SOTEI_PRC.KEIZOKU_SOTEI_PRC);
		}
		else if(JACStrConst.SOTEI_AMNT_SNST_WAY_CD_KAPWI.equals(soteiAmntSnstWayCd))
		{
			// 割賦一括切替時想定金額算出
			tmpWkSoteiAmnt = snstKapIktSwichSoteiAmnt(inMap, workMap);
		}
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstSoteiAmntKapWri][想定金額：" + tmpWkSoteiAmnt + "]");
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstSoteiAmntKapWri]");
		
		return tmpWkSoteiAmnt;
	}
	
	/**
	 * 割賦一括切替時想定金額算出
	 * 
	 * @param inMap 入力情報
	 * @param workMap 結果受渡領域
	 * @param tmpWkKapSoteiAmnt 割賦一括切替時想定金額
	 * @return tmpWkSoteiAmnt 想定金額
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private BigDecimal snstKapIktSwichSoteiAmnt(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][snstKapIktSwichSoteiAmnt]");
	
		BigDecimal tmpWkSoteiAmnt  = BigDecimal.ZERO;
		BigDecimal tmpFirstSoteiPrc = (BigDecimal)workMap.get(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC);
		BigDecimal tmpKeizokuSoteiPrc = (BigDecimal)workMap.get(JBSbatAK_M_KAP_SOTEI_PRC.KEIZOKU_SOTEI_PRC);
		
				
		int intkapSeikyZumiCnt = (inMap.getBigDecimal(JBSbatAKIFM020.KAP_SEIKY_ZUMI_CNT).intValue()); // 割賦請求済回数
		
		if(intkapSeikyZumiCnt > 0)
		{
			// 割賦支払残回数　×　継続想定料金
			tmpWkSoteiAmnt	=  inMap.getBigDecimal(JBSbatAKIFM020.KAP_PAY_ZAN_CNT).multiply(tmpKeizokuSoteiPrc);
		}
		else if (intkapSeikyZumiCnt == 0)
		{
			// 想定金額　＝　初回想定金額　＋　(入力．割賦支払残回数 − １) 　×　継続想定料金
			tmpWkSoteiAmnt = tmpFirstSoteiPrc.add(((inMap.getBigDecimal(JBSbatAKIFM020.KAP_PAY_ZAN_CNT)).subtract(ONE)).multiply(tmpKeizokuSoteiPrc));
		}
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapIktSwichSoteiAmnt][割賦一括切替時想定金額：" + tmpWkSoteiAmnt + "]");
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapIktSwichSoteiAmnt]");
		return tmpWkSoteiAmnt;
	}
	
	/**
	 * 割賦割引料金算出
	 * 
	 * @param inMap 入力情報
	 * @param workMap 結果受渡領域
	 * @return true ；検索結果あり　false ：検索結果なし
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private boolean snstKapWribPrc(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap) throws Exception
	{
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][snstKapWribPrc]");
		
		// 割賦想定料金マスタ検索
		// KEY：入力．料金コースコード ＋ 入力．割賦プランコード ＋ 入力．内訳料金サービスコード ＋ 入力．内訳料金科目サービスコード
		String serchKey = makeStr(inMap.getString(JBSbatAKIFM020.PCRS_CD), inMap.getString(JBSbatAKIFM020.KAP_PLAN_CD),
				inMap.getString(JBSbatAKIFM020.UW_PRC_SVC_CD), inMap.getString(JBSbatAKIFM020.UW_PRC_KMK_CD));

		if(this.tmpKapSoteiPrcMap.containsKey(serchKey))
		{
			ArrayList<JBSbatCommonDBInterface> dbList = this.tmpKapSoteiPrcMap.get(serchKey);
			
			// 該当なしを設定する。
			boolean existFlg = false;

			for(int i = 0; i <  dbList.size(); i++)	
			{
				JBSbatCommonDBInterface soteiMap = dbList.get(i);
				
				// 判定条件取得
				BigDecimal lowlValue = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.LOWL_VALUE);		// 配列情報[]．下限値
				BigDecimal upplValue = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.UPPL_VALUE);		// 配列情報[]．上限値
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapWribPrc][下限値：" + lowlValue + "]");
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapWribPrc][上限値：" + upplValue + "]");
				
			
				if((ZERO.compareTo(lowlValue) == 0) && (ONE.compareTo(upplValue) == 0))
				{
					// 初回想定料金
					// 継続想定料金
					// 出力料金サービスコード

					BigDecimal firstSoteiPrc = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC);
					BigDecimal keizokuSoteiPrc = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.KEIZOKU_SOTEI_PRC);
					String outputPrcSvcCd = soteiMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.OUTPUT_PRC_SVC_CD);
					
					workMap.put(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC, (Object)firstSoteiPrc);
					workMap.put(JBSbatAK_M_KAP_SOTEI_PRC.KEIZOKU_SOTEI_PRC, (Object)keizokuSoteiPrc);
					workMap.put(JBSbatAK_M_KAP_SOTEI_PRC.OUTPUT_PRC_SVC_CD, (Object)outputPrcSvcCd);
					
					// 該当ありの場合、trueを設定する。
					assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapWribPrc][該当あり]");
					assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
					existFlg = true;
				}
				
			}
			
			// 該当あり、該当なしを判定し該当なしの場合は上位にfalseを返却する。
			if(!existFlg)
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapWribPrc][該当なし]");
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
				return false;
			}
		}
		else
		{
			// 割賦想定料金マスタにデータが存在しない場合は上位にfalseを返却する。
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapWribPrc][マスタに未存在]");
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
			return false;
		}

		return true;
	}
	
	/**
	 * 割賦違約金料金算出
	 * 
	 * @param inMap 入力情報
	 * @param workMap 結果受渡領域
	 * @return true ；検索結果あり　false ：検索結果なし
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private boolean snstKapPnltyPrc(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap) throws Exception
	{
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][snstKapPnltyPrc]");
		BigDecimal tmpChrgKeizokuMonCnt = inMap.getBigDecimal(JBSbatAKIFM020.CHRG_KEIZOKU_MON_CNT);
		
		
		// 割賦想定料金マスタ検索
		// KEY：入力．料金コースコード ＋ 入力．割賦プランコード ＋ 入力．内訳料金サービスコード ＋ 入力．内訳料金科目コード
		String serchKey = makeStr(inMap.getString(JBSbatAKIFM020.PCRS_CD), inMap.getString(JBSbatAKIFM020.KAP_PLAN_CD),
				inMap.getString(JBSbatAKIFM020.UW_PRC_SVC_CD), inMap.getString(JBSbatAKIFM020.UW_PRC_KMK_CD));

		if(this.tmpKapSoteiPrcMap.containsKey(serchKey))
		{
			ArrayList<JBSbatCommonDBInterface> dbList = this.tmpKapSoteiPrcMap.get(serchKey);
			
			// 該当なしを設定する。
			boolean existFlg = false;

			for(int i = 0; i <  dbList.size(); i++)	
			{
				JBSbatCommonDBInterface soteiMap = dbList.get(i);
				
				// 判定条件取得
				BigDecimal lowlValue = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.LOWL_VALUE);		// 配列情報[]．下限値
				BigDecimal upplValue = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.UPPL_VALUE);		// 配列情報[]．上限値
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapPnltyPrc][下限値：" + lowlValue + "]");
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapPnltyPrc][上限値：" + upplValue + "]");
				
			
				if((tmpChrgKeizokuMonCnt.compareTo(lowlValue) >= 0) && (tmpChrgKeizokuMonCnt.compareTo(upplValue) < 0))
				{
					// 割賦想定料金からは1レコードのみ取得対象となる想定（複数とれる場合はマスタ設定不備とみなしてよいとのこと）
					// 初回想定料金
					// 出力料金サービスコード

					BigDecimal firstSoteiPrc = soteiMap.getBigDecimal(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC);
					String outputPrcSvcCd = soteiMap.getString(JBSbatAK_M_KAP_SOTEI_PRC.OUTPUT_PRC_SVC_CD);
					
					workMap.put(JBSbatAK_M_KAP_SOTEI_PRC.FIRST_SOTEI_PRC, (Object)firstSoteiPrc);
					workMap.put(JBSbatAK_M_KAP_SOTEI_PRC.OUTPUT_PRC_SVC_CD, (Object)outputPrcSvcCd);
					
					// 入力ファイル（請求パターン内訳割賦契約情報付加）の割賦支払残回数を取得
					BigDecimal kapPayZanCnt = inMap.getBigDecimal(JBSbatAKIFM020.KAP_PAY_ZAN_CNT);

					
					//割賦違約金の計算
					BigDecimal kapPnlty = firstSoteiPrc.multiply(kapPayZanCnt);

					workMap.put(KAPPNLTY, (Object)kapPnlty);
					
					// 該当ありの場合、trueを設定する。
					assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapPnltyPrc][該当あり]");
					assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
					existFlg = true;
				}
				
			}
			
			// 該当あり、該当なしを判定し該当なしの場合は上位にfalseを返却する。
			if(existFlg == false)
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapPnltyPrc][該当なし]");
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
				return false;
			}
		}
		else
		{
			// 割賦想定料金マスタにデータが存在しない場合は上位にfalseを返却する。
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][snstKapPnltyPrc][マスタに未存在]");
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][snstKapWribPrc]");
			return false;
		}

		return true;
	}
	
	
	/**
	 * 割賦請求パターン内訳情報を出力します。
	 * 
	 * @param inMap 入力情報
	 * @param workMap 結果受渡領域
	 * @param outputInItem  出力情報
	 * @throws Exception 業務サービス内で発生した例外全般。
	 */
	private void makeOutputInfo(JBSbatServiceInterfaceMap inMap, HashMap<String, Object> workMap, JBSbatOutputItem outputInItem) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputInfo]");
		
		JBSbatServiceInterfaceMap outMap = new JBSbatServiceInterfaceMap();
		
		// 単純移送項目
		outMap.getMap().putAll(inMap.getMap());
		
		// 以下編集項目
		// 内訳料金サービスコード
		String uwPrcSvcCd = (String)workMap.get(JBSbatAK_M_KAP_SOTEI_PRC.OUTPUT_PRC_SVC_CD);
		if(null != uwPrcSvcCd)
		{
			outMap.setString(JBSbatAKIFM062.UW_PRC_SVC_CD, 			uwPrcSvcCd);
		}
		else
		{
			outMap.setString(JBSbatAKIFM062.UW_PRC_SVC_CD, 			inMap.getString(JBSbatAKIFM020.UW_PRC_SVC_CD));
		}
		
		// 想定金額
		String soteiAmnt = (String)workMap.get(JBSbatAKIFM020.SOTEI_AMNT);
		if(null != soteiAmnt)
		{
			outMap.setString(JBSbatAKIFM062.SOTEI_AMNT, 			soteiAmnt);
		}
		
		// サービス詳細識別番号を空白埋め（30桁）
		String tmpSvcDtlStbtNo =JACbatRknBusinessUtil.fillHalfSpace(inMap.getString(JBSbatAKIFM020.KKTK_SVC_KEI_NO)
						, JACStrConst.SVC_DTL_SKBT_NO_LENGTH, true);
		
		// サービス詳細識別番号に機器提供サービス契約番号を設定
		outMap.setString(JBSbatAKIFM062.SVC_DTL_SKBT_NO, tmpSvcDtlStbtNo);
		
		// 出力フラグ設定
		outMap.setOutFlg(true);
		outputInItem.addOutMapList(outMap);

		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint,
						"[S][makeOutputInfo][outMap = " + outMap.getMap().toString() + "]") : true;		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeOutputInfo]");

		return;
	}

	
}
