/*********************************************************************
*  All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*	システム名			：eo顧客基幹システム
*	モジュール名		：JBSbatCHSkenitakNkinSksi
*	ソースファイル名	：JBSbatCHSkenitakNkinSksi.java
*	作成者				：富士通　
*	作成日				：2011年12月02日
*＜機能概要＞
*　債権委託入金表作成部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	v1.00.00	2011/12/02   富士通		新規作成
*	v4.00.00	2013/05/06  FJ)藤田		会計計上月ゼロサプレス対応
*                                       収納管理帳票処理区分をコード名称管理マスタから取得するようにする
*	v4.01.00	2013/05/20	FJ)早崎		小計情報出力処理を追加
*	v4.02.00	2013/05/21	FJ)藤田		【TG1-2013-0000541】小計出力のタイミングを集計キー２のブレイク時とする
*********************************************************************/
package eo.business.service;

import java.math.BigDecimal;
import java.util.HashMap;

import eo.business.common.JACbatDebugLogUtil;
import eo.business.common.JBSbatBusinessService;
import eo.business.common.JCHbatSeikyKaknoBusinessUtil;
import eo.business.util.file.JBSbatCHIFE041;
import eo.business.util.file.JBSbatCHIFM105;
import eo.business.util.table.JBSbatZM_M_CD_NM_KANRI;
import eo.common.constant.JACStrConst;
import eo.common.constant.JPCBatchMessageConstant;
import eo.common.constant.JZM0171Constant;
import eo.common.util.JCHCommonFormatUtil;
import eo.common.util.JPCUtilCommon;
import eo.framework.application.JBSbatBusinessException;
import eo.framework.db.JBSbatSQLAccess;
import eo.framework.item.JBSbatCommonDBInterface;
import eo.framework.item.JBSbatCommonItem;
import eo.framework.item.JBSbatOutputItem;
import eo.framework.item.JBSbatServiceInterfaceMap;

/**
* (クラスの機能概要) <p>
*<BR>
* @author 富士通
*/
public class JBSbatCHSkenitakNkinSksi extends JBSbatBusinessService
{
	/**▼▼▼▼▼▼ツールから生成した宣言です 開始▼▼▼▼▼▼*/
	/**▲▲▲▲▲▲ツールから生成した宣言です 終了▲▲▲▲▲▲*/

	/** 退避．キー項目１ */
	private String befSaveKey1 = null;
	
	/** 退避．キー項目２ */
	private String befSaveKey2 = null;
	
	/** 退避．キー項目３ */
	private String befSaveKey3 = null;
	
	/** 退避．キー項目４ */
	private String befSaveKey4 = null;
	
	/** 退避．キー項目５ */
	private String befSaveKey5 = null;
	
	/** 入力．キー項目１ */
	private String inSaveKey1 = null;
	
	/** 入力．キー項目２ */
	private String inSaveKey2 = null;
	
	/** 入力．キー項目３ */
	private String inSaveKey3 = null;
	
	/** 入力．キー項目４ */
	private String inSaveKey4 = null;
	
	/** 入力．キー項目５ */
	private String inSaveKey5 = null;
	
	/** ファイル編集用 */
	private HashMap<String, String> fileEdit = null;
	
	/** 集計項目（明細） */
	private HashMap<String, BigDecimal> shukMeisaiMap = null;
	
	/** 集計項目（小計） */
	private HashMap<String, BigDecimal> shukSyokeiMap = null;
	
	/** 集計項目（合計） */
	private HashMap<String, BigDecimal> shukGoukeiMap = null;
	
	/** 請求収納業務共通クラス */
	private JCHbatSeikyKaknoBusinessUtil chBusinessUtil = null;
	
	/** 編集用文字列（月度） */
	private static final String MONTH = "月度";
	
	/** 編集用 文字数制限値（４５） */
	private static final int MOJISUU_45 = 45;
	
	/** 処理区分(2) */
	private static final String DIV_TRAN_2 = "入金登録";
	
	/** 処理区分(3) */
	private static final String DIV_TRAN_3 = "取消";
	
	/** 編集用文字列（小計） */
	private static final String SMALL_SUM = "小計";
	
	/** 編集用文字列（合計） */
	private static final String GOUKEI_SUM = "合計";
	
	/** 固定値　BigDecimal 「30000」*/
	private static final BigDecimal BIGDECIMAL_30000 = new BigDecimal("30000");
	
	/** 債権委託会社フラグ */
	private boolean sknFlg = true;
	
	/** 収納管理帳票処理区分 */
	private HashMap<String, String> shunoKbnMap = null;

	/** テーブル(コード名称管理)*/
	private static final String D_TBL_NAME_ZM_M_CD_NM_KANRI = "ZM_M_CD_NM_KANRI";

	/** SQL定義キー(CH_SELECT_005)*/
	private static final String ZM_M_CD_NM_KANRI_CH_SELECT_005 = "CH_SELECT_005";

	/** テーブルアクセスクラス(コード名称管理)*/
	private JBSbatSQLAccess db_ZM_M_CD_NM_KANRI = null;

	/**
	 * 初期処理
	 * @param JBSbatCommonItem commonItem　バッチ共通パラメータ電文
	 * @throws Exception
	 */
	public void initial(JBSbatCommonItem commonItem) throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの初期処理を記述してください。▼▼▼▼▼▼*/
		/**▼▼▼▼▼▼ツールから生成した初期化のソースです 開始▼▼▼▼▼▼*/
		// 共通パラメータを設定します
		super.setCommonInfo(commonItem);
		/**▲▲▲▲▲▲ツールから生成した初期化のソースです 終了▲▲▲▲▲▲*/
		
		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 + "]");

		// DBアクセスクラスを生成します
		db_ZM_M_CD_NM_KANRI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_ZM_M_CD_NM_KANRI);
		
		chBusinessUtil = new JCHbatSeikyKaknoBusinessUtil(commonItem);
		
		// 初期化
		this.shukMeisaiMap = formSyukei();
		this.shukSyokeiMap = formSyukei();
		this.shukGoukeiMap = formSyukei();
		
		// 収納管理帳票処理区分取得
		shunoKbnMap = makeShunoKikanMap(JZM0171Constant.CD01593);
		// コード「１」の場合は空文字を取得できるようにここでセットしておく
		shunoKbnMap.put("1", "");

		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][initial]");
		
	/**▲▲▲▲▲▲業務サービスの初期処理を記述してください。▲▲▲▲▲▲*/
	}
	/**
	 * 収納機関コードマップを作成します。
	 * 
	 * @throws Exception 業務サービス内で発生した例外全般
	 */
	private HashMap<String, String> makeShunoKikanMap(String cdSbt) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeShunoKikanMap]");
		
		JBSbatCommonDBInterface whereParam = new JBSbatCommonDBInterface();
		
		HashMap<String, String>retMap = new HashMap<String, String>();
		// コード種別コード
		whereParam.setValue(cdSbt);
		// 適用開始年月日
		whereParam.setValue(super.opeDate);
		// 適用終了年月日
		whereParam.setValue(super.opeDate);

		// SQL実行
		executeZM_M_CD_NM_KANRI_CH_SELECT_005(whereParam.getList().toArray());
		JBSbatCommonDBInterface selectMap = db_ZM_M_CD_NM_KANRI.selectNext(); 
		
		// 取得結果判定
		if (selectMap != null)
		{
			while (selectMap != null)
			{
				//収納機関マップに格納する
				//KEY（コード区分）:VALUE（コード区分名称）
				String cdDiv = selectMap.getString(JBSbatZM_M_CD_NM_KANRI.CD_DIV);
				retMap.put(cdDiv, selectMap.getString(JBSbatZM_M_CD_NM_KANRI.CD_DIV_NM));
				selectMap = db_ZM_M_CD_NM_KANRI.selectNext();
			}
		}
		else
		{
			// ログ出力（【最重要】ＤＢ未存在エラー）
			String[] msgParam = new String[]{ JBSbatZM_M_CD_NM_KANRI.TABLE_NAME, whereParam.getList().toString() + "(" + cdSbt + ")"};
			throw new JBSbatBusinessException(JPCBatchMessageConstant.ECHB0270CH, msgParam);
		}
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeShunoKikanMap]");

		return retMap;
	}

	/**
	 * 主処理
	 * @param inMap　入力電文
	 * @param outputInItem 入力情報
	 * @return JBSbatOutputItem　出力情報
	 * @throws Exception
	 */
	public JBSbatOutputItem execute(JBSbatServiceInterfaceMap inMap, JBSbatOutputItem outputInItem) throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの主処理を記述してください。▼▼▼▼▼▼*/
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][execute]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][execute][inMap = " + inMap.getMap().toString() + "]") : true;
		
		JBSbatServiceInterfaceMap outMap = new JBSbatServiceInterfaceMap();
		
		// 入力キー初期化
		this.inSaveKey1 = null;
		this.inSaveKey2 = null;
		this.inSaveKey3 = null;
		this.inSaveKey4 = null;
		this.inSaveKey5 = null;
		
		// キー項目の作成
		if(inMap != null)
		{
			makeKeySubject(inMap);
		}
		
		// 債権委託入金表作成
		{
			if(this.befSaveKey1 != null && !this.befSaveKey1.equals(this.inSaveKey1))
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク１[S]=" + inSaveKey1 + "]");
				// 明細出力処理
				outMap = makeOutputMeisai(inMap);
				outputInItem.addOutMapList(outMap);
				// 小計出力処理
				outMap = makeOutputShokei(inMap);
				outputInItem.addOutMapList(outMap);
				// 合計出力処理
				outMap = makeOutputGoukei(inMap);
				outputInItem.addOutMapList(outMap);
				
				// 最終レコード以外の場合
				if (inMap != null)
				{
					// 退避情報初期化
					shukMeisaiMap = formSyukei();
					shukSyokeiMap = formSyukei();
					shukGoukeiMap = formSyukei();
					sknFlg = true;
				}
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク１[E]=" + inSaveKey1 + "]");
			}
			else if(befSaveKey2 != null && !befSaveKey2.equals(inSaveKey2))
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク２[S]=" + inSaveKey2 + "]");
				// 明細出力処理
				outMap = makeOutputMeisai(inMap);
				outputInItem.addOutMapList(outMap);
				// 小計出力処理
				outMap = makeOutputShokei(inMap);
				outputInItem.addOutMapList(outMap);

				
				// 最終レコード以外の場合
				if (inMap != null)
				{
					// 退避情報初期化
					shukMeisaiMap = formSyukei();
					shukSyokeiMap = formSyukei();
					sknFlg = true;
				}
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク２[E]=" + inSaveKey2 + "]");
			}
			else if(befSaveKey3 != null && !befSaveKey3.equals(inSaveKey3))
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク３[S]=" + inSaveKey3 + "]");
				// 明細出力処理
				outMap = makeOutputMeisai(inMap);
				outputInItem.addOutMapList(outMap);
				
				// 最終レコード以外の場合
				if (inMap != null)
				{
					// 退避情報初期化
					shukMeisaiMap = formSyukei();
					sknFlg = false;
				}
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク３[E]=" + inSaveKey3 + "]");
			}
			else if(befSaveKey4 != null && !befSaveKey4.equals(inSaveKey4))
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク４[S]=" + inSaveKey4 + "]");
				// 明細出力処理
				outMap = makeOutputMeisai(inMap);
				outputInItem.addOutMapList(outMap);
				
				// 最終レコード以外の場合
				if (inMap != null)
				{
					// 退避情報初期化
					shukMeisaiMap = formSyukei();
					sknFlg = false;
				}
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク４[E]=" + inSaveKey4 + "]");
			}
			else if(befSaveKey5 != null && !befSaveKey5.equals(inSaveKey5))
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク５[S]=" + inSaveKey5 + "]");
				// 明細出力処理
				outMap = makeOutputMeisai(inMap);
				outputInItem.addOutMapList(outMap);
				
				// 最終レコード以外の場合
				if (inMap != null)
				{
					// 退避情報初期化
					shukMeisaiMap = formSyukei();
					sknFlg = false;
				}
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][キーブレーク５[E]=" + inSaveKey5 + "]");
			}
			
		}
		
		// 最終レコード以外の場合
		if (inMap != null)
		{
			//集計処理
			{
				//集計項目（明細）を計算する
				shukMeisaiMap = doMeisaiSummary(inMap, shukMeisaiMap);
				
				//集計項目（小計）を計算する
				shukSyokeiMap = doGoukeiSummary(inMap, shukSyokeiMap);
				
				//集計項目（合計）を計算する
				shukGoukeiMap = doGoukeiSummary(inMap, shukGoukeiMap);
				
			}
			//ファイル編集用情報退避
			makeSaveInfo(inMap);
			
			//1件目のレコードの場合
			if(!outputInItem.isOutMapList())
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][execute][1件目のレコード]");
				assert outputInItem != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute][outputInItem=" + outputInItem.getOutMapList().toString() + "]") : true;
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute]");
				
				outputInItem.addOutMapList(inMap);
				return outputInItem;
			}
			
		}
		
		assert outputInItem != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute][outputBean=" + outputInItem.getOutMapList().toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][execute]");
		return outputInItem;
	/**▲▲▲▲▲▲業務サービスの主処理を記述してください。▲▲▲▲▲▲*/
	}

	/**
	 * キー項目を作成します
	 * @param inMap　入力電文
	 * @throws Exception
	 */
	private void makeKeySubject(JBSbatServiceInterfaceMap inMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeKeySubject]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeKeySubject][inMap=" + inMap.getMap().toString() + "]") : true;
		
		//キー項目１
		inSaveKey1 = makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap
				.getString(JBSbatCHIFM105.SHUNOKIKAN_CD));
		//キー項目２
		inSaveKey2 = makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap
				.getString(JBSbatCHIFM105.SHUNOKIKAN_CD), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK1));
		//キー項目３
		inSaveKey3 = makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap
				.getString(JBSbatCHIFM105.SHUNOKIKAN_CD), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK1), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK2));
		//キー項目４
		inSaveKey4 = makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap
				.getString(JBSbatCHIFM105.SHUNOKIKAN_CD), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK1), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK2), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK3));
		//キー項目５
		inSaveKey5 = makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap
				.getString(JBSbatCHIFM105.SHUNOKIKAN_CD), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK1), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK2), inMap
				.getString(JBSbatCHIFM105.KEY_SHUK3), inMap
				.getString(JBSbatCHIFM105.DIV_TRAN));

		assert inSaveKey1 != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject][key1 = " + inSaveKey1 + "]") : true;
		assert inSaveKey2 != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject][key2 = " + inSaveKey2 + "]") : true;
		assert inSaveKey3 != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject][key3 = " + inSaveKey3 + "]") : true;
		assert inSaveKey4 != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject][key4 = " + inSaveKey4 + "]") : true;
		assert inSaveKey5 != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject][key5 = " + inSaveKey5 + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeKeySubject]");
	}

	/**
	 * 集計項目の初期化をします。
	 * @return shukeiMap　集計項目マップ
	 */
	private HashMap<String, BigDecimal> formSyukei()
	{
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][formSyukei]");
		
		HashMap<String, BigDecimal> shukeiMap = new HashMap<String, BigDecimal>();
		shukeiMap.put(JBSbatCHIFE041.MI_CNT, BigDecimal.ZERO);
		shukeiMap.put(JBSbatCHIFE041.MI_AMNT, BigDecimal.ZERO);
		shukeiMap.put(JBSbatCHIFE041.IJ_CNT, BigDecimal.ZERO);
		shukeiMap.put(JBSbatCHIFE041.IJ_AMNT, BigDecimal.ZERO);
		shukeiMap.put(JBSbatCHIFE041.GOKEI_CNT, BigDecimal.ZERO);
		shukeiMap.put(JBSbatCHIFE041.GOKEI_AMNT, BigDecimal.ZERO);
		
		assert shukeiMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][formSyukei][shukeiMap=" + shukeiMap.toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][formSyukei]");
		return shukeiMap;
	}
	
	/**
	 * 債権委託入金表（合計）を作成します
	 * @param inMap　入力電文
	 * @param outMap　出力情報(合計)
	 * @return outMap　出力情報
	 * @throws Exception
	 */
	private JBSbatServiceInterfaceMap makeOutputGoukei(JBSbatServiceInterfaceMap inMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputGoukei]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputGoukei][inMap=" + inMap.getMap().toString() + "]") : true;
		assert shukMeisaiMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputGoukei][shukMeisaiMap= " + shukMeisaiMap.toString() + "]") : true;
		
		JBSbatServiceInterfaceMap outMap = new JBSbatServiceInterfaceMap();
		
		// 1.改ページキー
		outMap.set(JBSbatCHIFE041.KAI_PAGE_KEY, fileEdit.get(JBSbatCHIFE041.KAI_PAGE_KEY));
		// 2.会計計上月
		outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, JACStrConst.KARA_MOJI);
		String seikyYm = fileEdit.get(JBSbatCHIFM105.SEIKY_YM);
		if(2 < seikyYm.length())
		{
			String seikyMonth = JCHCommonFormatUtil.toZeroSuppress(seikyYm.substring(seikyYm.length() - 2));
			outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, this.makeStr(chBusinessUtil.chgHanZenMoji(seikyMonth), MONTH));
		}
		// 3.債権委託会社
		outMap.set(JBSbatCHIFE041.SKITAKCOMP, GOUKEI_SUM);
		// 4.収納日
		outMap.set(JBSbatCHIFE041.OUT_ORG_SHUNO_YMD, JACStrConst.KARA_MOJI);
		// 5.3万円未満件数
		outMap.set(JBSbatCHIFE041.MI_CNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.MI_CNT).toString()));
		// 6.3万円未満金額
		outMap.set(JBSbatCHIFE041.MI_AMNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.MI_AMNT).toString()));
		// 7.3万円以上件数
		outMap.set(JBSbatCHIFE041.IJ_CNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.IJ_CNT).toString()));
		// 8.3万円以上金額
		outMap.set(JBSbatCHIFE041.IJ_AMNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.IJ_AMNT).toString()));
		// 9.合計件数
		outMap.set(JBSbatCHIFE041.GOKEI_CNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.GOKEI_CNT).toString()));
		// 10.合計金額
		outMap.set(JBSbatCHIFE041.GOKEI_AMNT, JPCUtilCommon.formatNumber(shukGoukeiMap.get(JBSbatCHIFE041.GOKEI_AMNT).toString()));
		// 11.コメント
		outMap.set(JBSbatCHIFE041.COMMENT, JACStrConst.KARA_MOJI);

		//「""」で囲む
		outMap.setMap(JCHbatSeikyKaknoBusinessUtil.quote(outMap.getMap(), JACStrConst.DOUBLE_QUOTE, JACStrConst.DOUBLE_QUOTE));

		// 出力フラグ設定
		outMap.setOutFlg(true);

		assert outMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][makeOutputGoukei][outputItem = " + outMap.getMap().toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeOutputGoukei]");

		return outMap;
	}

	
	/**
	 * 債権委託入金表（小計）を作成します
	 * @param inMap　入力電文
	 * @param outMap　出力情報(合計)
	 * @return outMap　出力情報
	 * @throws Exception
	 */
	private JBSbatServiceInterfaceMap makeOutputShokei(JBSbatServiceInterfaceMap inMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputShokei]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputShokei][inMap=" + inMap.getMap().toString() + "]") : true;
		assert shukMeisaiMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputShokei][shukSyokeiMap= " + shukSyokeiMap.toString() + "]") : true;
		
		JBSbatServiceInterfaceMap outMap = new JBSbatServiceInterfaceMap();
		
		// 1.改ページキー
		outMap.set(JBSbatCHIFE041.KAI_PAGE_KEY, fileEdit.get(JBSbatCHIFE041.KAI_PAGE_KEY));
		// 2.会計計上月
		outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, JACStrConst.KARA_MOJI);
		String seikyYm = fileEdit.get(JBSbatCHIFM105.SEIKY_YM);
		if(2 < seikyYm.length())
		{
			String seikyMonth = JCHCommonFormatUtil.toZeroSuppress(seikyYm.substring(seikyYm.length() - 2));
			outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, this.makeStr(chBusinessUtil.chgHanZenMoji(seikyMonth), MONTH));
		}
		// 3.債権委託会社
		outMap.set(JBSbatCHIFE041.SKITAKCOMP, SMALL_SUM);
		// 4.収納日
		outMap.set(JBSbatCHIFE041.OUT_ORG_SHUNO_YMD, JACStrConst.KARA_MOJI);
		// 5.3万円未満件数
		outMap.set(JBSbatCHIFE041.MI_CNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.MI_CNT).toString()));
		// 6.3万円未満金額
		outMap.set(JBSbatCHIFE041.MI_AMNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.MI_AMNT).toString()));
		// 7.3万円以上件数
		outMap.set(JBSbatCHIFE041.IJ_CNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.IJ_CNT).toString()));
		// 8.3万円以上金額
		outMap.set(JBSbatCHIFE041.IJ_AMNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.IJ_AMNT).toString()));
		// 9.合計件数
		outMap.set(JBSbatCHIFE041.GOKEI_CNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.GOKEI_CNT).toString()));
		// 10.合計金額
		outMap.set(JBSbatCHIFE041.GOKEI_AMNT, JPCUtilCommon.formatNumber(shukSyokeiMap.get(JBSbatCHIFE041.GOKEI_AMNT).toString()));
		// 11.コメント
		outMap.set(JBSbatCHIFE041.COMMENT, JACStrConst.KARA_MOJI);

		//「""」で囲む
		outMap.setMap(JCHbatSeikyKaknoBusinessUtil.quote(outMap.getMap(), JACStrConst.DOUBLE_QUOTE, JACStrConst.DOUBLE_QUOTE));

		// 出力フラグ設定
		outMap.setOutFlg(true);

		assert outMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][makeOutputShokei][outputItem = " + outMap.getMap().toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeOutputShokei]");

		return outMap;
	}

	
	/**
	 *  債権委託入金表（明細）を作成します
	 * @param inMap　入力電文
	 * @return outMap　出力情報
	 * @throws Exception
	 */
	private JBSbatServiceInterfaceMap makeOutputMeisai(JBSbatServiceInterfaceMap inMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputMeisai]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputMeisai][inMap=" + inMap.getMap().toString() + "]") : true;
		assert shukMeisaiMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeOutputMeisai][shukMeisaiMap=" + shukMeisaiMap.toString() + "]") : true;
		
		JBSbatServiceInterfaceMap outMap = new JBSbatServiceInterfaceMap();
		
		// 1.改ページキー
		outMap.set(JBSbatCHIFE041.KAI_PAGE_KEY, fileEdit.get(JBSbatCHIFE041.KAI_PAGE_KEY));
		// 2.会計計上月
		outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, JACStrConst.KARA_MOJI);
		String seikyYm = fileEdit.get(JBSbatCHIFM105.SEIKY_YM);
		if(2 < seikyYm.length())
		{
			String seikyMonth = JCHCommonFormatUtil.toZeroSuppress(seikyYm.substring(seikyYm.length() - 2));
			outMap.set(JBSbatCHIFE041.KAIK_SUMUP_MON, this.makeStr(chBusinessUtil.chgHanZenMoji(seikyMonth), MONTH));
		}
		// 3.債権委託会社
		if (!sknFlg)
		{
			// 債権委託会社フラグがfalseの場合
			outMap.set(JBSbatCHIFE041.SKITAKCOMP, JACStrConst.KARA_MOJI);
		}
		else
		{
			outMap.set(JBSbatCHIFE041.SKITAKCOMP, getLCutString(fileEdit.get(JBSbatCHIFM105.SKN_SKNKSITKCM_NM), MOJISUU_45));
		}
		// 4.収納日
		outMap.set(JBSbatCHIFE041.OUT_ORG_SHUNO_YMD, JPCUtilCommon.formatDate(fileEdit.get(JBSbatCHIFM105.OUT_ORG_SHUNO_YMD)));
		
		// 5.3万円未満件数
		outMap.set(JBSbatCHIFE041.MI_CNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.MI_CNT).toString()));
		// 6.3万円未満金額
		outMap.set(JBSbatCHIFE041.MI_AMNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.MI_AMNT).toString()));
		// 7.3万円以上件数
		outMap.set(JBSbatCHIFE041.IJ_CNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.IJ_CNT).toString()));
		// 8.3万円以上金額
		outMap.set(JBSbatCHIFE041.IJ_AMNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.IJ_AMNT).toString()));
		// 9.合計件数
		outMap.set(JBSbatCHIFE041.GOKEI_CNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.GOKEI_CNT).toString()));
		// 10.合計金額
		outMap.set(JBSbatCHIFE041.GOKEI_AMNT, JPCUtilCommon.formatNumber(shukMeisaiMap.get(JBSbatCHIFE041.GOKEI_AMNT).toString()));
		
		// 11.コメント
		outMap.set(JBSbatCHIFE041.COMMENT, shunoKbnMap.get(fileEdit.get(JBSbatCHIFM105.DIV_TRAN)));
		
		//「""」で囲む
		outMap.setMap(JCHbatSeikyKaknoBusinessUtil.quote(outMap.getMap(), JACStrConst.DOUBLE_QUOTE, JACStrConst.DOUBLE_QUOTE));

		// 出力フラグ設定
		outMap.setOutFlg(true);

		assert outMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeOutputMeisai][outMap = " + outMap.getMap().toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeOutputMeisai]");

		return outMap;
	}
	
	/**
	 * ファイル編集用情報を退避します
	 * @param inMap　入力電文
	 * @throws Exception 
	 */
	private void makeSaveInfo(JBSbatServiceInterfaceMap inMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeSaveInfo]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeSaveInfo][inMap=" + inMap.getMap().toString() + "]") : true;
		
		//退避・キー項目
		befSaveKey1 = inSaveKey1;
		befSaveKey2 = inSaveKey2;
		befSaveKey3 = inSaveKey3;
		befSaveKey4 = inSaveKey4;
		befSaveKey5 = inSaveKey5;
		
		//ファイル編集用情報
		fileEdit = new HashMap<String, String>();
		
		//退避．会計年月
		fileEdit.put(JBSbatCHIFM105.SEIKY_YM, inMap.getString(JBSbatCHIFM105.SEIKY_YM));
		//退避．収納機関コード
		fileEdit.put(JBSbatCHIFM105.SHUNOKIKAN_CD, inMap.getString(JBSbatCHIFM105.SHUNOKIKAN_CD));
		//退避．集計キー１
		fileEdit.put(JBSbatCHIFM105.KEY_SHUK1, inMap.getString(JBSbatCHIFM105.KEY_SHUK1));
		//退避．集計キー２
		fileEdit.put(JBSbatCHIFM105.KEY_SHUK2, inMap.getString(JBSbatCHIFM105.KEY_SHUK2));
		//退避．集計キー３
		fileEdit.put(JBSbatCHIFM105.KEY_SHUK3, inMap.getString(JBSbatCHIFM105.KEY_SHUK3));
		//退避．処理区分
		fileEdit.put(JBSbatCHIFM105.DIV_TRAN, inMap.getString(JBSbatCHIFM105.DIV_TRAN));
		//退避．債権委託会社名
		fileEdit.put(JBSbatCHIFM105.SKN_SKNKSITKCM_NM, inMap.getString(JBSbatCHIFM105.SKN_SKNKSITKCM_NM));
		//退避．収納日
		fileEdit.put(JBSbatCHIFM105.OUT_ORG_SHUNO_YMD, JPCUtilCommon.formatDate(inMap.getString(JBSbatCHIFM105.OUT_ORG_SHUNO_YMD)));
		//退避．改ページキー(会計年月＋債権回収委託会社コード)
		fileEdit.put(JBSbatCHIFE041.KAI_PAGE_KEY, makeStr(inMap.getString(JBSbatCHIFM105.SEIKY_YM), inMap.getString(JBSbatCHIFM105.SKN_SKNKSITKCM_CD)));
		
		assert fileEdit != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][makeSaveInfo][fileEdit = " + fileEdit.toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][makeSaveInfo]");
	}
	
	/**
	 * 計算方法（明細）で集計項目を計算します
	 * @param inMap　入力電文
	 * @param inSyukMap　入力集計項目マップ
	 * @return syukMap　集計項目マップ
	 * @throws Exception 
	 */
	private HashMap<String, BigDecimal> doMeisaiSummary(JBSbatServiceInterfaceMap inMap, HashMap<String, BigDecimal> inSyukMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doMeisaiSummary]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doMeisaiSummary][inMap=" 	+ inMap.getMap().toString() + "]") : true;
		assert inSyukMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doMeisaiSummary][inSyukMap=" + inSyukMap.toString() + "]") : true;
		
		HashMap<String, BigDecimal> syukMap = inSyukMap;
		
		// 合計件数＋１
		syukMap.put(JBSbatCHIFE041.GOKEI_CNT, syukMap.get(JBSbatCHIFE041.GOKEI_CNT).add(BigDecimal.ONE));
		// 合計金額＋入金額
		syukMap.put(JBSbatCHIFE041.GOKEI_AMNT, syukMap.get(JBSbatCHIFE041.GOKEI_AMNT).add(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
		
		//入力．入金額＜30000　の場合
		if(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT).compareTo(BIGDECIMAL_30000) < 0)
		{
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doMeisaiSummary][入力．入金額＜30000　NYUKIN_AMNT=" + inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT) + "]");
			
			//3万円未満件数＋１
			syukMap.put(JBSbatCHIFE041.MI_CNT, syukMap.get(JBSbatCHIFE041.MI_CNT).add(BigDecimal.ONE));
			
			//3万円未満金額＋入金額
			syukMap.put(JBSbatCHIFE041.MI_AMNT, syukMap.get(JBSbatCHIFE041.MI_AMNT).add(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
		}
		else
		{
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doMeisaiSummary][入力．入金額＞30000　NYUKIN_AMNT=" + inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT) + "]");
			
			//3万円以上件数＋１
			syukMap.put(JBSbatCHIFE041.IJ_CNT, syukMap.get(JBSbatCHIFE041.IJ_CNT).add(BigDecimal.ONE));
			
			//3万円以上金額＋入金額
			syukMap.put(JBSbatCHIFE041.IJ_AMNT, syukMap.get(JBSbatCHIFE041.IJ_AMNT).add(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
		}
		
		assert syukMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doMeisaiSummary][syukMap = " + syukMap.toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][doMeisaiSummary]");
		
		return syukMap;
	}
	
	/**
	 * 計算方法（合計）で集計項目を計算します
	 * @param inMap　入力電文
	 * @param inSyukMap　入力集計項目マップ
	 * @return syukMap　集計項目マップ
	 * @throws Exception
	 */
	private HashMap<String, BigDecimal> doGoukeiSummary(JBSbatServiceInterfaceMap inMap, HashMap<String, BigDecimal> inSyukMap) throws Exception
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doGoukeiSummary]");
		assert inMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doGoukeiSummary][inMap=" 	+ inMap.getMap().toString() + "]") : true;
		assert inSyukMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][doGoukeiSummary][inSyukMap=" 	+ inSyukMap.toString() + "]") : true;
		
		HashMap<String, BigDecimal> syukMap = inSyukMap;
		
		//入力．処理区分 ≠ "3"（取消）の場合
		if (!JACStrConst.TRN_DIV_CL.equals(inMap.get(JBSbatCHIFM105.DIV_TRAN)))
		{
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doGoukeiSummary][処理区分 ≠ 3（取消）の場合、計算方法（明細）を実行]");
			syukMap = doMeisaiSummary(inMap, syukMap);
		}
		else
		{
			assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doGoukeiSummary][処理区分 ＝ 3（取消）の場合、計算方法（合計）を実行]");
			
			// 合計件数＋１
			syukMap.put(JBSbatCHIFE041.GOKEI_CNT, syukMap.get(JBSbatCHIFE041.GOKEI_CNT).add(BigDecimal.ONE));
			// 合計金額 - 入金額
			syukMap.put(JBSbatCHIFE041.GOKEI_AMNT, syukMap.get(JBSbatCHIFE041.GOKEI_AMNT).subtract(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
			
			// 入金額＜30000の場合
			if(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT).compareTo(BIGDECIMAL_30000) < 0)
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doGoukeiSummary][入力．入金額＜30000　NYUKIN_AMNT=" + inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT) + "]");
				
				//3万円未満件数＋１
				syukMap.put(JBSbatCHIFE041.MI_CNT, syukMap.get(JBSbatCHIFE041.MI_CNT).add(BigDecimal.ONE));
				//3万円未満金額‐入金額
				syukMap.put(JBSbatCHIFE041.MI_AMNT, syukMap.get(JBSbatCHIFE041.MI_AMNT).subtract(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
			}
			else
			{
				assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doMeisaiSummary][入力．入金額＞30000　NYUKIN_AMNT=" + inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT) + "]");
				
				//3万円以上件数＋１
				syukMap.put(JBSbatCHIFE041.IJ_CNT, syukMap.get(JBSbatCHIFE041.IJ_CNT).add(BigDecimal.ONE));
				//3万円以上金額‐入金額
				syukMap.put(JBSbatCHIFE041.IJ_AMNT, syukMap.get(JBSbatCHIFE041.IJ_AMNT).subtract(inMap.getBigDecimal(JBSbatCHIFM105.NYUKIN_AMNT)));
			}
		}
		assert syukMap != null ? JACbatDebugLogUtil.printDebugLog(super.logPrint, "[L][doGoukeiSummary][syukMap = " + syukMap.toString() + "]") : true;
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][doGoukeiSummary]");
		return syukMap;		
	}

	/**
	 * 対象文字列から指定桁数分の文字列を切出し取得する
	 * @param  value 対象文字列
	 * @param  length 桁数
	 * @return value 指定桁数の文字列
	 */
	private String getLCutString(String value, int length)
	{
		String ret = "";

		if(length < value.length())
		{
			ret = value.substring(0, length);
		}
		else
		{
			ret = value;
		}

		return ret;
	}

	/**
	 * 文字を連結します
	 * @param string　文字
	 * @return strBuf　連結した文字列
	 */
	private String makeStr(String ...string)
	{
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][makeStr]");
		
		StringBuffer strBuf = new StringBuffer();
		for(String str:string){
			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();
	}

	/**
	 * SQLKEY(CH_SELECT_005)でDBアクセスを行います。<br>
	 * <p>
	 * <b>処理フロー</b><br>
	 * <pre>
	 * 1.引数でバイント変数を設定します。<br>
	 *
	 * 2.DBアクセスを実行します。<br>
	 * 
	 * 3.メソッドの呼び出し方です。<br>
	 *		引数:
	 *		param:順にバイント変数の値をparam配列に入れます。バイント変数は以下に説明します。
	 *		 	コード種別コード
	 *		 	適用開始年月日
	 *		 	適用終了年月日
	 * </pre>
	 * <p>
	 * @param param バイント変数の値配列。
	 * @throws Exception 業務サービス内で発生した例外全般。
	 */
	private void executeZM_M_CD_NM_KANRI_CH_SELECT_005(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_ZM_M_CD_NM_KANRI.selectBySqlDefine(paramList, ZM_M_CD_NM_KANRI_CH_SELECT_005);
	}

	/**
	 * 業務サービス終了処理
	 * @throws Exception
	 */
	public void terminal() throws Exception
	{
	/**▼▼▼▼▼▼業務サービスの終了処理を記述してください。▼▼▼▼▼▼*/
		/**▼▼▼▼▼▼ツールから生成した終了処理のソースです 開始▼▼▼▼▼▼*/
		/**▲▲▲▲▲▲ツールから生成した終了処理のソースです 終了▲▲▲▲▲▲*/
		
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[S][terminal]");
		chBusinessUtil.close();
		assert JACbatDebugLogUtil.printDebugLog(super.logPrint, "[E][terminal]");
		
	/**▲▲▲▲▲▲業務サービスの終了処理を記述してください。▲▲▲▲▲▲*/
	}

	/**▼▼▼▼▼▼ツールから生成したメソッドです 開始▼▼▼▼▼▼*/
	/**▲▲▲▲▲▲ツールから生成したメソッドです 終了▲▲▲▲▲▲*/
}
